From 6f2012cdc021f6b47ed19bc7fe64159ce9eeda8a Mon Sep 17 00:00:00 2001 From: Avery Pennarun Date: Fri, 2 Oct 2009 15:22:15 -0400 Subject: [PATCH] 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. --- git-subtree.sh | 6 +++--- test.sh | 4 ++-- todo | 4 ---- 3 files changed, 5 insertions(+), 9 deletions(-) diff --git a/git-subtree.sh b/git-subtree.sh index 454ce7ef2..0949fefe2 100755 --- a/git-subtree.sh +++ b/git-subtree.sh @@ -102,7 +102,7 @@ esac if [ -z "$prefix" ]; then die "You must provide the --prefix option." fi -dir="$prefix" +dir="$(dirname "$prefix/.")" if [ "$command" != "pull" ]; then revs=$(git rev-parse $default --revs-only "$@") || exit $? @@ -175,7 +175,7 @@ find_latest_squash() sq= main= sub= - git log --grep="^git-subtree-dir: $dir\$" \ + git log --grep="^git-subtree-dir: $dir/*\$" \ --pretty=format:'START %H%n%s%n%n%b%nEND%n' HEAD | while read a b junk; do debug "$a $b $junk" @@ -210,7 +210,7 @@ find_existing_splits() revs="$2" main= sub= - git log --grep="^git-subtree-dir: $dir\$" \ + git log --grep="^git-subtree-dir: $dir/*\$" \ --pretty=format:'START %H%n%s%n%n%b%nEND%n' $revs | while read a b junk; do case "$a" in diff --git a/test.sh b/test.sh index bed7f2790..12b045657 100755 --- a/test.sh +++ b/test.sh @@ -82,7 +82,7 @@ git branch subdir git fetch ../subproj sub1 git branch sub1 FETCH_HEAD -git subtree add --prefix=subdir FETCH_HEAD +git subtree add --prefix=subdir/ FETCH_HEAD # this shouldn't actually do anything, since FETCH_HEAD is already a parent git merge -m 'merge -s -ours' -s ours FETCH_HEAD @@ -118,7 +118,7 @@ create sub9 git commit -m 'sub9' cd ../mainline -split2=$(git subtree split --annotate='*' --prefix subdir --rejoin) +split2=$(git subtree split --annotate='*' --prefix subdir/ --rejoin) git branch split2 "$split2" create subdir/main-sub10 diff --git a/todo b/todo index 5e72b2e51..7e44b0024 100644 --- a/todo +++ b/todo @@ -36,10 +36,6 @@ one of the other git tools that git-subtree calls. Should detect this situation and print the *real* problem. - In fact, the prefix should *not* end with slash, and we - should detect (and fix) it if it does. Otherwise the - log message looks weird. - "pull --squash" should do fetch-synthesize-merge, but instead just does "pull" directly, which doesn't work at all. -- 2.30.2