[PATCH 0/3] apply: handle traditional patches with spaces in filename

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



The goal: let ‘git apply’ handle such filenames as
“b/debian/licenses/LICENSE.Apache (v2.0)” in patches produced by
non-git tools without erroring out.

When we last left our heroes[1] in April:

> | The name and last modification time of each file shall be output in
> | the following format:
> |
> | "---[space]%s  %s%s%s", file1, <file1 timestamp>, <file1 frac>, <file1 zone>
> | "+++[space]%s  %s%s%s", file2, <file2 timestamp>, <file2 frac>, <file2 zone>
[...]
> If this is really describing the format of patches in the wild, that
> means we should only look for a tab character to terminate the filename.
[...]
> A big downside: this does not cope with copy-and-pasted patches with
> tabs transformed to spaces.  The example [2] consists mostly of
> file-creation patches, so we can’t look to the repository for hints.
> Maybe the space-plus-date-plus-newline sequence should be used as a
> delimiter.

It turns out that is not so hard.  Maybe it could be rewritten using
regcomp() and regexec(); if someone wants to do that, I won’t stop
them. ;-)

Patch 1 factors out a function to handle "GNU-format" C-style quoted
filenames in patches.  The only tool I know of that produces this
format is git; the discussion in [2] about what characters to escape
seems to have come to no conclusion.

Patch 2 adds some tests for all those weird characters that might
appear in a filename.  They abuse “diff” and “pr”; testing on weird
platforms would be helpful.

Patch 3 adds the logic to search for a date at the end of a filename
line, for traditional (non --git) patches only.  If no date is found
at the end, we return to the previous heuristic, except that the only
accepted filename terminator is a tab.  Whitespace damage is only
accepted if there is a timestamp at the end of the line.

Thoughts, suggestions, improvements welcome.

Jonathan Nieder (3):
  apply: Split quoted filename handling into new function
  tests: Test how well “git apply” copes 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 |  119 ++++++++++++++++++
 3 files changed, 363 insertions(+), 42 deletions(-)
 create mode 100755 t/t4135-apply-weird-filenames.sh

[1] http://thread.gmane.org/gmane.linux.debian.devel.bugs.general/697969/focus=145543
[2] http://thread.gmane.org/gmane.comp.version-control.git/9813/focus=10046
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]