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 <Alex.Crezoff@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Alexey Shumkin committed
Sep 5, 2015 at 01:24 UTC
5b6ab38bd31790d072aabbc23fe936ba5e1b072a
2 files changed
+48
-1
contrib/subtree/git-subtree.sh
+1
-1
@@ -735,7 +735,7 @@ cmd_push()
735
refspec=$2
736
echo "git push using: " $repository $refspec
737
localrev=$(git subtree split --prefix="$prefix") || die
738
- git push $repository $localrev:refs/heads/$refspec
738
+ git push "$repository" $localrev:refs/heads/$refspec
739
else
740
die "'$dir' must already exist. Try 'git subtree add'."
741
fi
contrib/subtree/t/t7900-subtree.sh
+47
@@ -1,6 +1,7 @@
1
#!/bin/sh
2
#
3
# Copyright (c) 2012 Avery Pennaraum
4
+# Copyright (c) 2015 Alexey Shumkin
5
#
6
test_description='Basic porcelain support for subtrees
7
@@ -471,4 +472,50 @@ test_expect_success 'verify one file change per commit' '
472
))
473
'
474
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
+
521
test_done