Skip to contentSkip to conversation

contrib/subtree: make it respect spaces in a repository path

PATCH In review Alexey Shumkin 2 participants 5 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

cover contrib/subtree: make it respect spaces in a repository path

Some repositories may have spaces in their paths. Currently git-subtree raises an error in such cases.
Also, git-subtree currently does not have tests for its 'push' command. Following patches are to fix these statements.

Alexey Shumkin (2):
t7900-subtree: test the "space in a subdirectory name" case contrib/subtree: respect spaces in a repository path

 contrib/subtree/git-subtree.sh     |   4 +-
 contrib/subtree/t/t7900-subtree.sh | 194 +++++++++++++++++++++++--------------
 2 files changed, 124 insertions(+), 74 deletions(-)
Signature · 1 line
2.4.1-21
#1 lore raw

PATCH 1/2 t7900-subtree: test the "space in a subdirectory name" case

In common case there can be spaces in a subdirectory name. Change tests accorgingly to this statement.

Also, as far as a call to the rejoin_msg function (in cmd_split) does not take into account such a case this patch fixes commit message when --rejoin option is set .

Besides, as fixnl and multiline functions did not take into account the "new" tested "space in a subdirectory name" case they become unused and redundant, so they are removed.

---
 contrib/subtree/git-subtree.sh     |   2 +-
 contrib/subtree/t/t7900-subtree.sh | 147 +++++++++++++++++++------------------
 2 files changed, 76 insertions(+), 73 deletions(-)
contrib/subtree/git-subtree.sh +1 -1
index 9f06571..72a20c0 100755
@@ -648,7 +648,7 @@ cmd_split()
 		debug "Merging split branch into HEAD..."
 		latest_old=$(cache_get latest_old)
 		git merge -s ours \
-			-m "$(rejoin_msg $dir $latest_old $latest_new)" \
+			-m "$(rejoin_msg "$dir" $latest_old $latest_new)" \
 			$latest_new >&2 || exit $?
 	fi
 	if [ -n "$branch" ]; then
contrib/subtree/t/t7900-subtree.sh +75 -72

326 lines not on this page · raw message

Signature · 1 line
2.4.1-21
#2 lore raw

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

In reply to Alexey Shumkin

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.

---
 contrib/subtree/git-subtree.sh     |  2 +-
 contrib/subtree/t/t7900-subtree.sh | 47 ++++++++++++++++++++++++++++++++++++++
 2 files changed, 48 insertions(+), 1 deletion(-)
contrib/subtree/git-subtree.sh +1 -1
index 72a20c0..308b777 100755
@@ -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
contrib/subtree/t/t7900-subtree.sh +47 -0

57 lines not on this page · raw message

Signature · 1 line
2.4.1-21
#3 lore raw
In reply to Alexey Shumkin
Quoted 8 lines · Alexey Shumkin

Some repositories may have spaces in their paths. Currently git-subtree raises an error in such cases.
Also, git-subtree currently does not have tests for its 'push' command. Following patches are to fix these statements.

Alexey Shumkin (2):
t7900-subtree: test the "space in a subdirectory name" case contrib/subtree: respect spaces in a repository path

Doesn't this order break bisection? It seems that you turn "subdir" to "sub dir" in existing tests, and I understand that the whole point of this series is that such a change will expose that the tool is broken, making tests fail.

Also, if you feel up to it, it might be a good idea to clean t7900 test up to the current best practice before doing any other changes as a pure preparatory clean-up patch.

Namely, using cd outside a subshell of the tests to move around is a bad thing to do, and you are adding more instance of it in this series. If one test with such a cd to go down fails before it has a chance to come back up (or go up and then fail to come back down), the later tests will be left in an unexpected place.

Quoted 3 lines
 contrib/subtree/git-subtree.sh     |   4 +-
 contrib/subtree/t/t7900-subtree.sh | 194 +++++++++++++++++++++++--------------
 2 files changed, 124 insertions(+), 74 deletions(-)

Thanks.

#4 lore raw
Quoted 7 lines · Junio C Hamano
Quoted 5 lines · Alexey Shumkin

Some repositories may have spaces in their paths. Currently git-subtree raises an error in such cases.
Also, git-subtree currently does not have tests for its 'push' command. Following patches are to fix these statements.

Quoted 8 lines
Quoted 3 lines

Alexey Shumkin (2):
t7900-subtree: test the "space in a subdirectory name" case contrib/subtree: respect spaces in a repository path

Doesn't this order break bisection? It seems that you turn "subdir" to "sub dir" in existing tests, and I understand that the whole point of this series is that such a change will expose that the tool is broken, making tests fail.

It seems I have to reword commit messages to avoid such an interpretation. Because, the first commit does not break anything. It is to change the tests for git-subtree "to show" that git-subtrees already tested commands (almost) work correctly if there are spaces in paths (except --rejoin-msg issue).
And the second commit adds missing tests and the fix.
Should I add/commit the breaking test first and then commit the fix?

Quoted 10 lines

Also, if you feel up to it, it might be a good idea to clean t7900 test up to the current best practice before doing any other changes as a pure preparatory clean-up patch.

Namely, using cd outside a subshell of the tests to move around is a bad thing to do, and you are adding more instance of it in this series. If one test with such a cd to go down fails before it has a chance to come back up (or go up and then fail to come back down), the later tests will be left in an unexpected place.

I understand this issue with "cd" (I've just followed the existing t7900 tests "code style").

Quoted 6 lines
Quoted 4 lines
 contrib/subtree/git-subtree.sh     |   4 +-
 contrib/subtree/t/t7900-subtree.sh | 194 +++++++++++++++++++++++--------------
 2 files changed, 124 insertions(+), 74 deletions(-)

Thanks.

Signature · 5 lines
Alexey Shumkin
E-mail: [email protected]
ICQ: 118001447
Jabber (GoogleTalk): [email protected]
Skype: crezoff