[PATCH] git-parse-remote: fix ambiguous shell bug in expand_refs_wildcard
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(-)
Show changes to git-parse-remote.sh +1 −1
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