---- snip ----
I posted the following on the git list earlier today, but after
Johannes mentioned that
it might be msys-specific I figured I might as well fix it. [Johannes
- I know that you're
out of the msysgit game now, but perhaps in time you'll reconsider?]
BUG: "git stash apply <arg>" broken, "git-stash apply <arg>" works
Synopsis:
"git stash apply [EMAIL PROTECTED]" doesn't work, but
"git-stash apply [EMAIL PROTECTED]" does.
Platform:
win xp (yeah, I know, I know)
msys (Git-1.5.5-preview20080413.exe)
git version 1.5.5.1015.g9d258
To reproduce:
# Create a minimal repo
mkdir stash-bug
cd stash-bug
git init
echo line1 > file
git add file
git commit -m initial
# Create the stash that we'll use
echo "This is correct" > file
git stash save "Save off correct line in what will be [EMAIL PROTECTED]"
# Create another stash (the default one) which we won't use
echo "This should not be shown" > file
git stash save "Save off incorrect line in what will be [EMAIL
PROTECTED]"
# They are correctly created
git stash list
# "git-stash apply arg" works
git reset --hard
git-stash apply [EMAIL PROTECTED]
echo "git-stash apply respects its argument"
cat file
# But "git stash apply arg" doesn't
git reset --hard
git stash apply [EMAIL PROTECTED]
echo "git stash apply (no dash) doesn't respect its argument"
cat file
A fix is attached.
---- snap ----
Although seemingly undocumented, CreateProcess() filters curly
brackets out of the command line unless they are quoted.
This commit fixes (at least) the case of "git stash apply [EMAIL PROTECTED]".
Note that "git-stash apply [EMAIL PROTECTED]" works even without this patch
(because it is executed directly by /bin/sh).
Note that git-stash still has a bug whereby it doesn't validate
its final argument ("[EMAIL PROTECTED]" in this case). This commit does
nothing to fix that problem.
---
compat/mingw.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)
diff --git a/compat/mingw.c b/compat/mingw.c
index a5b43bc..95ba563 100644
--- a/compat/mingw.c
+++ b/compat/mingw.c
@@ -380,7 +380,7 @@ static const char *quote_arg(const char *arg)
const char *p = arg;
if (!*p) force_quotes = 1;
while (*p) {
- if (isspace(*p) || *p == '*' || *p == '?')
+ if (isspace(*p) || *p == '*' || *p == '?' || *p == '{')
force_quotes = 1;
else if (*p == '"')
n++;
--
1.5.5.1015.g9d258.dirty