Skip to content

Commit 5b6ab38

Browse files
ashumkingitster
authored andcommitted
contrib/subtree: respect spaces in a repository path
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent c61eb41 commit 5b6ab38

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -735,7 +735,7 @@ cmd_push()
735735
refspec=$2
736736
echo "git push using: " $repository $refspec
737737
localrev=$(git subtree split --prefix="$prefix") || die
738-
git push $repository $localrev:refs/heads/$refspec
738+
git push "$repository" $localrev:refs/heads/$refspec
739739
else
740740
die "'$dir' must already exist. Try 'git subtree add'."
741741
fi

contrib/subtree/t/t7900-subtree.sh

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/bin/sh
22
#
33
# Copyright (c) 2012 Avery Pennaraum
4+
# Copyright (c) 2015 Alexey Shumkin
45
#
56
test_description='Basic porcelain support for subtrees
67
@@ -471,4 +472,50 @@ test_expect_success 'verify one file change per commit' '
471472
))
472473
'
473474

475+
# test push
476+
477+
cd ../..
478+
479+
mkdir test-push
480+
481+
cd test-push
482+
483+
test_expect_success 'init main' '
484+
test_create_repo main
485+
'
486+
487+
test_expect_success 'init sub' '
488+
test_create_repo "sub project"
489+
'
490+
491+
cd ./"sub project"
492+
493+
test_expect_success 'add subproject' '
494+
create "sub project" &&
495+
git commit -m "Sub project: 1" &&
496+
git branch sub-branch-1
497+
'
498+
499+
cd ../main
500+
501+
test_expect_success 'make first commit and add subproject' '
502+
create "main-1" &&
503+
git commit -m "main: 1" &&
504+
git subtree add "../sub project" --prefix "sub dir" --message "Added subproject" sub-branch-1 &&
505+
check_equal "$(last_commit_message)" "Added subproject"
506+
'
507+
508+
test_expect_success 'make second commit to a subproject file and push it into a sub project' '
509+
create "sub dir/sub1" &&
510+
git commit -m "Sub project: 2" &&
511+
git subtree push "../sub project" --prefix "sub dir" sub-branch-1
512+
'
513+
514+
cd ../"sub project"
515+
516+
test_expect_success 'Test second commit is pushed' '
517+
git checkout sub-branch-1 &&
518+
check_equal "$(last_commit_message)" "Sub project: 2"
519+
'
520+
474521
test_done

0 commit comments

Comments
 (0)