git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] parse-remote: handle detached HEAD
@ 2010-12-05 23:47 Santi Béjar
  2010-12-05 23:49 ` Sverre Rabbelier
  0 siblings, 1 reply; 8+ messages in thread
From: Santi Béjar @ 2010-12-05 23:47 UTC (permalink / raw)
  To: git; +Cc: Sverre Rabbelier

In get_remote_merge_branch 'git for-each-ref' is used to know the
upstream branch of the current branch ($curr_branch). But $curr_branch
can be empty when in detached HEAD, so the call to for-each-ref is
made without a pattern.

Quote the $curr_branch variable in the git for-each-ref call to always
provide a pattern (the current branch or an empty string) Otherwise it
would mean all refs.

This fixes a bug reported by Sverre Rabbelier. The overall results
were correct but not the output text.

Signed-off-by: Santi Béjar <santi@agolina.net>
---
Hi *,

Sorry Sverre, but the patch you tested fixed your case but broke all
the others :(

Hope you can also test it. Now it passes the test suite.

Thanks,
Santi
 git-parse-remote.sh |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-parse-remote.sh b/git-parse-remote.sh
index 5f47b18..07060c3 100644
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -68,7 +68,7 @@ get_remote_merge_branch () {
 	    test -z "$origin" && origin=$default
 	    curr_branch=$(git symbolic-ref -q HEAD)
 	    [ "$origin" = "$default" ] &&
-	    echo $(git for-each-ref --format='%(upstream)' $curr_branch)
+	    echo $(git for-each-ref --format='%(upstream)' "$curr_branch")
 	    ;;
 	*)
 	    repo=$1
-- 
1.7.3.3.399.gea47f

^ permalink raw reply related	[flat|nested] 8+ messages in thread

end of thread, other threads:[~2010-12-06 17:15 UTC | newest]

Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-12-05 23:47 [PATCH] parse-remote: handle detached HEAD Santi Béjar
2010-12-05 23:49 ` Sverre Rabbelier
2010-12-05 23:58   ` [PATCHv2] " Santi Béjar
2010-12-06  3:33     ` Junio C Hamano
2010-12-06 10:20       ` [PATCHv3] " Santi Béjar
2010-12-06 14:32         ` Santi Béjar
2010-12-06 16:03         ` Junio C Hamano
2010-12-06 17:14           ` Sverre Rabbelier

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).