@matheusbsbs / matheus-bagliano / commits / 227f781147
Fork 0

Fix behaviour if you have a branch named the same as your --prefix

We were trying to 'git checkout $prefix', which is ambiguous if $prefix names a directory *and* a branch. Do 'git checkout -- $prefix' instead. The main place this appeared was in 'git subtree add'. Reported by several people.

Avery Pennarun committed Aug 26, 2009 at 10:43 UTC 227f78114752eee2e8ae3368089716d73d32dd8b
3 files changed +2 -7
git-subtree.sh
+1 -1
@@ -426,7 +426,7 @@ cmd_add()
426
427 debug "Adding $dir as '$rev'..."
428 git read-tree --prefix="$dir" $rev || exit $?
429 - git checkout "$dir" || exit $?
429 + git checkout -- "$dir" || exit $?
430 tree=$(git write-tree) || exit $?
431
432 headrev=$(git rev-parse HEAD) || exit $?
test.sh
+1
@@ -78,6 +78,7 @@ git init
78 create main4
79 git commit -m 'main4'
80 git branch -m master mainline
81 +git branch subdir
82
83 git fetch ../subproj sub1
84 git branch sub1 FETCH_HEAD
todo
-6
@@ -20,9 +20,6 @@
20
21 automated tests for --squash stuff
22
23 - test.sh fails in msysgit?
24 - sort error - see Thell's email
25 -
23 "add" command non-obviously requires a commitid; would be easier if
24 it had a "pull" sort of mode instead
25
@@ -43,9 +40,6 @@
40 should detect (and fix) it if it does. Otherwise the
41 log message looks weird.
42
46 - totally weird behavior in 'git subtree add' if --prefix matches
47 - a branch name
48 -
43 "pull --squash" should do fetch-synthesize-merge, but instead just
44 does "pull" directly, which doesn't work at all.
45