]> git.xonotic.org Git - xonotic/xonotic.git/commitdiff
import-pk3: init index with merge base, not always master
authorJānis Rūcis <parasti@gmail.com>
Mon, 16 Aug 2010 12:32:45 +0000 (15:32 +0300)
committerJānis Rūcis <parasti@gmail.com>
Mon, 16 Aug 2010 12:37:18 +0000 (15:37 +0300)
Otherwise the commit history gets lost.

misc/tools/git-import-pk3

index 54c8593e48030a8bb0c40f73334bdd06596cc725..a2c243a4ba8e3c5b043e60c247757f0d86150508 100755 (executable)
@@ -72,17 +72,19 @@ unzip -n -qq "$pk3path" -d "$GIT_WORK_TREE" ||
 die "couldn't extract PK3 contents"
 trap 'find "$GIT_WORK_TREE" -mindepth 1 -delete' EXIT
 
-# Note the refs
+# Note the refs and the common ancestor
 master=refs/heads/master
 ref=refs/heads/$branch
+base=$(git merge-base $master $ref 2> /dev/null) ||
+base=$master
 
 # Figure out the parent commit
 parent=\
-$(git rev-parse --verify -q $ref || git rev-parse --verify -q $master) ||
+$(git rev-parse --verify -q $ref || git rev-parse --verify -q $base) ||
 die "couldn't determine parent commit"
 
-# Read the tree at master into index
-git read-tree $master ||
+# Read the tree at base into index
+git read-tree $base ||
 die "couldn't initialize index"
 
 # Reject any modified files, the mapper should create a branch instead