Page MenuHomePhabricator

Correctly parse `git status --porcelain=2` output with filenames with spaces
ClosedPublic

Authored by alexmv on Apr 20 2018, 1:57 AM.
Tags
None
Referenced Files
F13108210: D19389.diff
Sun, Apr 28, 12:56 AM
F13105970: D19389.diff
Sat, Apr 27, 5:51 PM
Unknown Object (File)
Thu, Apr 25, 1:31 AM
Unknown Object (File)
Fri, Apr 19, 7:42 PM
Unknown Object (File)
Thu, Apr 11, 9:04 AM
Unknown Object (File)
Sat, Mar 30, 6:22 AM
Unknown Object (File)
Mar 15 2024, 7:27 AM
Unknown Object (File)
Feb 22 2024, 8:50 PM
Subscribers

Details

Summary

Filenames are last in git status --porcelain=2 lines; they
are not escaped in any way, despite the fields being
whitespace-delimited. explode thus happily chops apart filenames
with spaces in them, causing later git operations to operate only on
the filename up to the first space.

Split the lines into the right number of elements -- in all cases,
this is one more than the index we're using, since filenames come last.

Test Plan

Altering a file with a space in its path, and running arc diff -a.

Added tests.

Diff Detail

Repository
rARC Arcanist
Branch
up-whitespace (branched from master)
Lint
Lint Passed
Unit
Tests Passed
Build Status
Buildable 20193
Build 27403: Run Core Tests
Build 27402: arc lint + arc unit