Skip to content

Commit

Permalink
contrib/subtree: respect spaces in a repository path
Browse files Browse the repository at this point in the history
Remote repository may have spaces in its path, so take it into account.

Also, as far as there are no tests for the `push` command, add them.

Signed-off-by: Alexey Shumkin <Alex.Crezoff@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Alexey Shumkin authored and Junio C Hamano committed Sep 8, 2015
1 parent c61eb41 commit 5b6ab38
Show file tree
Hide file tree
Showing 2 changed files with 48 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 @@ -735,7 +735,7 @@ cmd_push()
refspec=$2
echo "git push using: " $repository $refspec
localrev=$(git subtree split --prefix="$prefix") || die
git push $repository $localrev:refs/heads/$refspec
git push "$repository" $localrev:refs/heads/$refspec
else
die "'$dir' must already exist. Try 'git subtree add'."
fi
Expand Down
47 changes: 47 additions & 0 deletions contrib/subtree/t/t7900-subtree.sh
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
#!/bin/sh
#
# Copyright (c) 2012 Avery Pennaraum
# Copyright (c) 2015 Alexey Shumkin
#
test_description='Basic porcelain support for subtrees
Expand Down Expand Up @@ -471,4 +472,50 @@ test_expect_success 'verify one file change per commit' '
))
'

# test push

cd ../..

mkdir test-push

cd test-push

test_expect_success 'init main' '
test_create_repo main
'

test_expect_success 'init sub' '
test_create_repo "sub project"
'

cd ./"sub project"

test_expect_success 'add subproject' '
create "sub project" &&
git commit -m "Sub project: 1" &&
git branch sub-branch-1
'

cd ../main

test_expect_success 'make first commit and add subproject' '
create "main-1" &&
git commit -m "main: 1" &&
git subtree add "../sub project" --prefix "sub dir" --message "Added subproject" sub-branch-1 &&
check_equal "$(last_commit_message)" "Added subproject"
'

test_expect_success 'make second commit to a subproject file and push it into a sub project' '
create "sub dir/sub1" &&
git commit -m "Sub project: 2" &&
git subtree push "../sub project" --prefix "sub dir" sub-branch-1
'

cd ../"sub project"

test_expect_success 'Test second commit is pushed' '
git checkout sub-branch-1 &&
check_equal "$(last_commit_message)" "Sub project: 2"
'

test_done

0 comments on commit 5b6ab38

Please sign in to comment.