Skip to content

Commit

Permalink
contrib/subtree: Handle '--prefix' argument with a slash appended
Browse files Browse the repository at this point in the history
'git subtree merge' will fail if the argument of '--prefix' has a slash
appended.

Signed-off-by: Techlive Zheng <techlivezheng@gmail.com>
Signed-off-by: David A. Greene <greened@obbligato.org>
Signed-off-by: Jeff King <peff@peff.net>
  • Loading branch information
Techlive Zheng authored and Jeff King committed Nov 13, 2015
1 parent 4371174 commit d16031c
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 1 deletion.
2 changes: 1 addition & 1 deletion contrib/subtree/git-subtree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ while [ $# -gt 0 ]; do
--annotate) annotate="$1"; shift ;;
--no-annotate) annotate= ;;
-b) branch="$1"; shift ;;
-P) prefix="$1"; shift ;;
-P) prefix="${1%/}"; shift ;;
-m) message="$1"; shift ;;
--no-prefix) prefix= ;;
--onto) onto="$1"; shift ;;
Expand Down
20 changes: 20 additions & 0 deletions contrib/subtree/t/t7900-subtree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -257,6 +257,26 @@ test_expect_success 'merge the added subproj again, should do nothing' '
)
'

next_test
test_expect_success 'merge new subproj history into subdir/ with a slash appended to the argument of --prefix' '
test_create_repo "$test_count" &&
test_create_repo "$test_count/subproj" &&
test_create_commit "$test_count" main1 &&
test_create_commit "$test_count/subproj" sub1 &&
(
cd "$test_count" &&
git fetch ./subproj master &&
git subtree add --prefix=subdir/ FETCH_HEAD
) &&
test_create_commit "$test_count/subproj" sub2 &&
(
cd "$test_count" &&
git fetch ./subproj master &&
git subtree merge --prefix=subdir/ FETCH_HEAD &&
check_equal "$(last_commit_message)" "Merge commit '\''$(git rev-parse FETCH_HEAD)'\''"
)
'

#
# Tests for 'git subtree split'
#
Expand Down

0 comments on commit d16031c

Please sign in to comment.