LucasLarson/gunstage

regression: filenames with spaces cause unexpected results on Linux

LucasLarson opened this issue · 2 comments

Bug initially identified in #32 (comment):

filenames with spaces in them no longer mirror vanilla Git’s behavior. The wrong files are now unstaged if you perform the following sequence:

git init && touch a a\ b b # create three files: “a”, “a b”, and “b”
git add . # stage the new files
git unstage a\ b # try to unstage only “a b”, but “a b” is the only file that remains staged

After @unixorn’s 28d982b, the bug is no longer present on macOS 11.0.1, but is still present on:

  • Alpine 3.12
  • Ubuntu 18.04
  • Debian 9.12

That's peculiar. It's getting passed the arguments exactly as if it was being called as gunstage.

I did some more testing and found that in the above example (three files staged, whose names’re “a”, “a b”, and “b” and the command
gunstage a\ b upstages only “a” and “b” whereas
git restore ‑‑staged a\ b unstages only “a b”).

What surprisingly works is escaping the already-escaped sequence. That is
gunstage a\\ b works identically to
git restore ‑‑staged a\ b.