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

[PATCHv2] parse-remote: handle detached HEAD

From
SBSanti Béjar <santi@agolina.net>
Date
Dec 5, 2010, 23:58 UTC
Message-ID
<1291593517-4406-1-git-send-email-santi@agolina.net>
In-Reply-To
<AANLkTi=yfuiFuatshYuS2Q0EV0Ytj-QFKpuXAWeGerQB@mail.gmail.com>

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.

Reported-by: Sverre Rabbelier <srabbelier@gmail.com>
Signed-off-by: Santi Béjar <santi@agolina.net>
Tested-by: Sverre Rabbelier <srabbelier@gmail.com>
---
Changes since v1:
  Tags for Reported-by and Tested-by.
 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
Previous: Sverre RabbelierNext: Junio C Hamano
Message 3 of 8 in “parse-remote: handle detached HEAD”
  1. parse-remote: handle detached HEADSanti Béjar, Dec 5, 2010
  2. Sverre RabbelierDec 5, 2010
  3. [PATCHv2] parse-remote: handle detached HEADSanti Béjar, Dec 5, 2010
  4. Junio C HamanoDec 6, 2010
  5. [PATCHv3] parse-remote: handle detached HEADSanti Béjar, Dec 6, 2010
  6. Santi BéjarDec 6, 2010
  7. Junio C HamanoDec 6, 2010
  8. Sverre RabbelierDec 6, 2010

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.