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
F13275140: D19389.diff
Fri, May 31, 4:27 AM
F13261210: D19389.diff
Mon, May 27, 12:47 AM
F13245151: D19389.diff
Thu, May 23, 5:48 AM
F13218624: D19389.diff
Sat, May 18, 12:53 PM
F13217307: D19389.id.diff
Sat, May 18, 4:27 AM
F13199835: D19389.id46381.diff
Mon, May 13, 7:09 PM
F13195352: D19389.diff
Sun, May 12, 10:19 PM
F13193805: D19389.id.diff
Sun, May 12, 6:07 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