Skip to content

apply: handle traditional patches with space in filename

Jonathan Nieder git 2 versions In review

Get series with b4
b4 am 20100819014516.GA7175@burratino

Versions newest first · linked by author and title

  1. v2 Latest3 patches 2 repliesIn review
  2. v13 patches 2 repliesSuperseded

Patches in v2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/3apply: split quoted filename handling into new functionbuiltin/apply.c t/t4120-apply-popt.sh+71 -340 replies
2/3tests: exercise "git apply" with weird filenamest/t4135-apply-weird-filenames.sh t/t4135/.gitignore t/t4135/add-plain.diff +16 more+213 -00 replies
3/3apply: handle traditional patches with space in filenamebuiltin/apply.c t/t4135-apply-weird-filenames.sh+181 -160 replies

Reviews trailers per patch

1 of 3 patches has a Reviewed-by or Acked-by.

PatchAndreas SchwabJohannes SixtGuido Günther
1/3
2/3Helped-by Helped-by
3/3A-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.

Read the v2 thread

Cover letter [PATCH v2 0/3] apply: handle traditional patches with space in filename
Quoted 2 lines · Johannes Sixt

Why not just write an explicit test vector? The result of expand will be constant, no?

Sorry for the long delay. Here's a re-roll, meant to replace jn/apply-filename-with-sp from pu.

Patch 1 fixes an edge case for git apply -p when traditional patches have quotation marks in file names (so: an edge case of an edge). But that is only a side-effect; the main purpose is to rearrange code to prepare for patch 3. Except for the commit message, it is unchanged from the version in pu.

Patch 2 contains the funny-filenames tests. Testing on Windows would be welcome. The test vectors are included in the patch to avoid a source of non-determinism (for example, GNU diff could stop emiting traditional patches some day). The script used to generate them is provided to make the test easy to change.

Patch 3 is basically as before, except that find_name_traditional() calls find_name_common() directly now instead of redundantly checking again for quotes at the beginning of filenames. As before, the purpose is to handle patches to files with whitespace in their names, by trying to use the timestamp instead of arbitrary whitespace as a name terminator (falling back to the old method if that fails).

Thanks for your help so far. The code would be much worse without it.

Jonathan Nieder (3):
apply: split quoted filename handling into new function
tests: exercise "git apply" with weird filenames
apply: handle traditional patches with space in filename

 builtin/apply.c                  |  251 ++++++++++++++++++++++++++++++++------
 t/t4120-apply-popt.sh            |   35 +++++-
 t/t4135-apply-weird-filenames.sh |   75 +++++++++++
 t/t4135/.gitignore               |    3 +
 t/t4135/add-plain.diff           |    5 +
 t/t4135/add-with backslash.diff  |    5 +
 t/t4135/add-with quote.diff      |    5 +
 t/t4135/add-with spaces.diff     |    5 +
 t/t4135/add-with tab.diff        |    5 +
 t/t4135/damaged.diff             |    5 +
 t/t4135/diff-plain.diff          |    5 +
 t/t4135/diff-with backslash.diff |    5 +
 t/t4135/diff-with quote.diff     |    5 +
 t/t4135/diff-with spaces.diff    |    5 +
 t/t4135/diff-with tab.diff       |    5 +
 t/t4135/git-plain.diff           |    7 +
 t/t4135/git-with backslash.diff  |    7 +
 t/t4135/git-with quote.diff      |    7 +
 t/t4135/git-with spaces.diff     |    7 +
 t/t4135/git-with tab.diff        |    7 +
 t/t4135/make-patches             |   45 +++++++
 21 files changed, 457 insertions(+), 42 deletions(-)
 create mode 100755 t/t4135-apply-weird-filenames.sh
 create mode 100644 t/t4135/.gitignore
 create mode 100644 t/t4135/add-plain.diff
 create mode 100644 t/t4135/add-with backslash.diff
 create mode 100644 t/t4135/add-with quote.diff
 create mode 100644 t/t4135/add-with spaces.diff
 create mode 100644 t/t4135/add-with tab.diff
 create mode 100644 t/t4135/damaged.diff
 create mode 100644 t/t4135/diff-plain.diff
 create mode 100644 t/t4135/diff-with backslash.diff
 create mode 100644 t/t4135/diff-with quote.diff
 create mode 100644 t/t4135/diff-with spaces.diff
 create mode 100644 t/t4135/diff-with tab.diff
 create mode 100644 t/t4135/git-plain.diff
 create mode 100644 t/t4135/git-with backslash.diff
 create mode 100644 t/t4135/git-with quote.diff
 create mode 100644 t/t4135/git-with spaces.diff
 create mode 100644 t/t4135/git-with tab.diff
 create mode 100755 t/t4135/make-patches
Signature · 1 line
1.7.2.1.544.ga752d.dirty