[Webkit-unassigned] [Bug 111066] svn-apply cannot apply patches which is generated by git to files that contain space characters in their path

bugzilla-daemon at webkit.org bugzilla-daemon at webkit.org
Mon Jun 3 16:29:53 PDT 2013


https://bugs.webkit.org/show_bug.cgi?id=111066





--- Comment #18 from David Farler <dfarler at apple.com>  2013-06-03 16:28:25 PST ---
(In reply to comment #17)
> I spoke with Chris Jerdonek, who wrote most of the Git diff parsing machinery, about this patch. We felt that it's sufficient to start with a simple solution and iterate on it as needed. One such simple solution is to use the first path segment w of the source file path to determine where the target file path begins. Consider the following diff --git line:
> 
> diff --git WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess)2.xcscheme
> 
> Take w := "WebKit.xcworkspace/". Then locate the second occurrence of w and split the string accordingly. The source and destination file paths would then be "WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess).xcscheme", and "WebKit.xcworkspace/xcshareddata/xcschemes/All Source (target WebProcess)2.xcscheme", respectively.
> 
> Such a solution would have the form:
> 
> sub parseGitDiffHeader($$)
> {
>     ...
>     my $indexPath;
>     if (/$gitDiffStartRegEx/) {
>         ...
>         $indexPath = adjustPathForRecentRenamings(parseGitDiffStartLineForTargetPath($_));
>         # Use $POSTMATCH to preserve the end-of-line character.
>         $_ = "Index: $indexPath$POSTMATCH"; # Convert to SVN format.
>     } else {
>         die("Could not parse leading \"diff --git\" line: \"$line\".");
>     }
>     ...
>     while (1) {
>         ...
>         } elsif (/^--- \S+/) {
>             ...
>             $_ = "--- $indexPath\t(revision 0)";
>         } elsif (/^\+\+\+ \S+/) {
>             ...
>             $_ = "+++ $indexPath\t(working copy)";
>         }
>         ...
>     }
>     ...
> }
> 
> sub parseGitDiffStartLine($)
> {
>     ...
>     if (/$gitDiffStartWithPrefixRegEx/ || /$gitDiffStartWithoutPrefixNoSpaceRegEx/) {
>         return $2;
>     }
>     ...
> }
> 
> We expect that this approach will handle almost all cases in practice. However, initially it won't handle cases where the top-level directory changes or certain rare cases where the first path segment may occur later in the source path (e.g. diff --git A/B A/C.txt A/D.txt; source path = "A/B A/C.txt", target path = "A/D.txt"). Moreover, if we ever want to handle non-prefix Git diffs for binary files, the approach of parsing only the first line will be necessary because such diffs only reference the source and target path in this line.
> 
> Starting with a simple solution is attractive as the implementation tends to be concise and maintains the readability and hackability of the code base. Should the simple solution turn out to be insufficient we can iterate on it towards a more comprehensive solution.

If we like, we can also just see how git does it:

builtin/apply.c

static int find_header(const char *line, unsigned long size, int *hdrsize, struct patch *patch)
:1490
static int parse_git_header(const char *line, int len, unsigned int size, struct patch *patch)
:1280
static char *git_header_name(const char *line, int llen)

-- 
Configure bugmail: https://bugs.webkit.org/userprefs.cgi?tab=email
------- You are receiving this mail because: -------
You are the assignee for the bug.



More information about the webkit-unassigned mailing list