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

[PATCH] git-parse-remote: fix ambiguous shell bug in expand_refs_wildcard

From
Jeff King <peff@peff.net>
Date
Dec 18, 2006, 08:09 UTC
Message-ID
<20061218080941.GA3857@coredump.intra.peff.net>

Bash and dash parse "${name%'^{}'}" differently, with bash quoting the ^{}, and dash assuming the first } is the end of the variable (and thus tacking '} to the end). Instead, use backslash to quote the closing brace.

Signed-off-by: Jeff King <peff@peff.net>
---
Please sanity check that I understand what the code is supposed to be
doing. The bug I was getting was this:
$ readlink /bin/sh
dash
$ git-clone git://git.kernel.org/pub/scm/git/git.git
[...]
$ cd git && git-pull
Warning: No merge candidate found because value of config option
         "branch.master.merge" does not match any remote branch fetched.

A shell trace showed lots of tests against strings like "refs/heads/master'}". Expand_refs_wildcard returned no entries, so it couldn't match the branch.master.merge field.

 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 f27c3c2..ab79042 100755
--- a/git-parse-remote.sh
+++ b/git-parse-remote.sh
@@ -116,7 +116,7 @@ expand_refs_wildcard () {
 			while read sha1 name
 			do
 				mapped=${name#"$from"}
-				if test "z$name" != "z${name%'^{}'}" ||
+				if test "z$name" != "z${name%'^{\}'}" ||
 					test "z$name" = "z$mapped"
 				then
 					continue
Next: Jeff King
Message 1 of 7 in “git-parse-remote: fix ambiguous shell bug in expand_refs_wildcard”
  1. git-parse-remote: fix ambiguous shell bug in expand_refs_wildcardJeff King, Dec 18, 2006
  2. Jeff KingDec 18, 2006
  3. Jeff KingDec 18, 2006
  4. Herbert XuDec 19, 2006
  5. Herbert XuMay 5, 2007
  6. Jeff KingMay 7, 2007
  7. Herbert XuMay 7, 2007

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.