@matheusbsbs / matheus-bagliano / commits / 6f2012cdc0
Fork 0

If someone provides a --prefix that ends with slash, strip the slash.

Prefixes that differ only in the trailing slash should be considered identical. Also update the test to check that this works.

Avery Pennarun committed Oct 2, 2009 at 15:22 UTC 6f2012cdc021f6b47ed19bc7fe64159ce9eeda8a
3 files changed +5 -9
git-subtree.sh
+3 -3
@@ -102,7 +102,7 @@ esac
102 if [ -z "$prefix" ]; then
103 die "You must provide the --prefix option."
104 fi
105 -dir="$prefix"
105 +dir="$(dirname "$prefix/.")"
106
107 if [ "$command" != "pull" ]; then
108 revs=$(git rev-parse $default --revs-only "$@") || exit $?
@@ -175,7 +175,7 @@ find_latest_squash()
175 sq=
176 main=
177 sub=
178 - git log --grep="^git-subtree-dir: $dir\$" \
178 + git log --grep="^git-subtree-dir: $dir/*\$" \
179 --pretty=format:'START %H%n%s%n%n%b%nEND%n' HEAD |
180 while read a b junk; do
181 debug "$a $b $junk"
@@ -210,7 +210,7 @@ find_existing_splits()
210 revs="$2"
211 main=
212 sub=
213 - git log --grep="^git-subtree-dir: $dir\$" \
213 + git log --grep="^git-subtree-dir: $dir/*\$" \
214 --pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs |
215 while read a b junk; do
216 case "$a" in
test.sh
+2 -2
@@ -82,7 +82,7 @@ git branch subdir
82
83 git fetch ../subproj sub1
84 git branch sub1 FETCH_HEAD
85 -git subtree add --prefix=subdir FETCH_HEAD
85 +git subtree add --prefix=subdir/ FETCH_HEAD
86
87 # this shouldn't actually do anything, since FETCH_HEAD is already a parent
88 git merge -m 'merge -s -ours' -s ours FETCH_HEAD
@@ -118,7 +118,7 @@ create sub9
118 git commit -m 'sub9'
119
120 cd ../mainline
121 -split2=$(git subtree split --annotate='*' --prefix subdir --rejoin)
121 +split2=$(git subtree split --annotate='*' --prefix subdir/ --rejoin)
122 git branch split2 "$split2"
123
124 create subdir/main-sub10
todo
-4
@@ -36,10 +36,6 @@
36 one of the other git tools that git-subtree calls. Should
37 detect this situation and print the *real* problem.
38
39 - In fact, the prefix should *not* end with slash, and we
40 - should detect (and fix) it if it does. Otherwise the
41 - log message looks weird.
42 -
39 "pull --squash" should do fetch-synthesize-merge, but instead just
40 does "pull" directly, which doesn't work at all.
41