Skip to content

Commit

Permalink
Fix behaviour if you have a branch named the same as your --prefix
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
apenwarr committed Aug 26, 2009
1 parent 33aaa69 commit 227f781
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 7 deletions.
2 changes: 1 addition & 1 deletion git-subtree.sh
Expand Up @@ -426,7 +426,7 @@ cmd_add()

debug "Adding $dir as '$rev'..."
git read-tree --prefix="$dir" $rev || exit $?
git checkout "$dir" || exit $?
git checkout -- "$dir" || exit $?
tree=$(git write-tree) || exit $?

headrev=$(git rev-parse HEAD) || exit $?
Expand Down
1 change: 1 addition & 0 deletions test.sh
Expand Up @@ -78,6 +78,7 @@ git init
create main4
git commit -m 'main4'
git branch -m master mainline
git branch subdir

git fetch ../subproj sub1
git branch sub1 FETCH_HEAD
Expand Down
6 changes: 0 additions & 6 deletions todo
Expand Up @@ -20,9 +20,6 @@

automated tests for --squash stuff

test.sh fails in msysgit?
sort error - see Thell's email

"add" command non-obviously requires a commitid; would be easier if
it had a "pull" sort of mode instead

Expand All @@ -43,9 +40,6 @@
should detect (and fix) it if it does. Otherwise the
log message looks weird.

totally weird behavior in 'git subtree add' if --prefix matches
a branch name

"pull --squash" should do fetch-synthesize-merge, but instead just
does "pull" directly, which doesn't work at all.

Expand Down

0 comments on commit 227f781

Please sign in to comment.