git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH v1 2/2] contrib/subtree: respect spaces in a repository path

From
Alexey Shumkin <alex.crezoff@gmail.com>
Date
Sep 4, 2015, 22:24 UTC
Message-ID
<4531a80be47397632eb6293707a0ac08ef18f528.1441404851.git.Alex.Crezoff@gmail.com>
In-Reply-To
<cover.1441404851.git.Alex.Crezoff@gmail.com>
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>
---
 contrib/subtree/git-subtree.sh     |  2 +-
 contrib/subtree/t/t7900-subtree.sh | 47 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
diff --git a/contrib/subtree/git-subtree.sh b/contrib/subtree/git-subtree.sh
index 72a20c0..308b777 100755
--- a/contrib/subtree/git-subtree.sh
+++ b/contrib/subtree/git-subtree.sh
@@ -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
diff --git a/contrib/subtree/t/t7900-subtree.sh b/contrib/subtree/t/t7900-subtree.sh
index 9979827..dfbe443 100755
--- a/contrib/subtree/t/t7900-subtree.sh
+++ b/contrib/subtree/t/t7900-subtree.sh
@@ -1,6 +1,7 @@
 #!/bin/sh
 #
 # Copyright (c) 2012 Avery Pennaraum
+# Copyright (c) 2015 Alexey Shumkin
 #
 test_description='Basic porcelain support for subtrees
 
@@ -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
-- 
2.4.1-21
Previous: Alexey ShumkinNext: Junio C Hamano
Message 3 of 5 in “contrib/subtree: make it respect spaces in a repository path”
  1. 0/2 contrib/subtree: make it respect spaces in a repository pathAlexey Shumkin, Sep 4, 2015
  2. 1/2 t7900-subtree: test the "space in a subdirectory name" caseAlexey Shumkin, Sep 4, 2015
  3. 2/2 contrib/subtree: respect spaces in a repository pathAlexey Shumkin, Sep 4, 2015
  4. Junio C HamanoSep 4, 2015
  5. Alexey ShumkinSep 7, 2015

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.