Re: [Bug report] git status doesn't escape paths of untracked files
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Sep 8, 2020, 01:13 UTC
- Message-ID
- <xmqqa6y1135o.fsf@gitster.c.googlers.com>
- In-Reply-To
- <CAMRL+qb0YC1EOTM-LDfMpJ=AJJ014LT5ufBcs0v77byN74A0vw@mail.gmail.com>
Patrick Fong <patrickf3139@gmail.com> writes:
Show 14 quoted lines
> What did you do before the bug happened? (Steps to reproduce your issue) > touch "this is escaped" > touch "this is not escaped" > git add "this is escaped" > git status --short > > What did you expect to happen? (Expected behavior) > I expected that git status --short would string escape both "this is > escaped" and "this is not escaped" since they both contain spaces that > need escaping. > > What happened instead? (Actual behavior) > git status did not string escape "this is not escaped" but it does if > you add it to the index.
It indeed is a disturbing inconsistency, and the code that shows the untracked paths should be fixed. I wonder what is done to ignored paths when the "--ignored" option is given.
wt-status.c::wt_shortstatus_status() has a strange special case that says "whitespace alone does not usually deserve quoting, but we special case it and manually quote"; this discrepancy/special casing was introduced at dbfdc625 (status: Quote paths with spaces in short format, 2010-11-08). A fix would probably be to port the same fix to wt-status.c::wt_shortstatus_other().
In the longer term, quote.c::quote_path() may want to learn an optional flag to tell it to do the the special casing.
Thanks.