@matheusbsbs / matheus-bagliano / commits / fc1f458c35
Fork 0

cvsexportcommit -p : fix the usage of git-apply -C.

Unlike 'patch --fuzz=NUM', which specifies the number of lines allowed to mismatch, 'git-apply -CNUM' requests the match of NUM lines of context. Omitting -C requests full context match, and that's what should be used for cvsexportcommit -p. Signed-off-by: Junio C Hamano <junkio@cox.net>

Tomash Brechko committed Apr 9, 2007 at 15:24 UTC fc1f458c3506ea3f76a328f10b4008c45af32c4b
1 file changed +8 -3
git-cvsexportcommit.perl
+8 -3
@@ -124,12 +124,17 @@ close MSG;
124 `git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff";
125
126 ## apply non-binary changes
127 -my $fuzz = $opt_p ? 0 : 2;
127 +
128 +# In pedantic mode require all lines of context to match. In normal
129 +# mode, be compatible with diff/patch: assume 3 lines of context and
130 +# require at least one line match, i.e. ignore at most 2 lines of
131 +# context, like diff/patch do by default.
132 +my $context = $opt_p ? '' : '-C1';
133
134 print "Checking if patch will apply\n";
135
136 my @stat;
132 -open APPLY, "GIT_DIR= git-apply -C$fuzz --binary --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch";
137 +open APPLY, "GIT_DIR= git-apply $context --binary --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch";
138 @stat=<APPLY>;
139 close APPLY || die "Cannot patch";
140 my (@bfiles,@files,@afiles,@dfiles);
@@ -196,7 +201,7 @@ if ($dirty) {
201 }
202
203 print "Applying\n";
199 -`GIT_DIR= git-apply -C$fuzz --binary --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";
204 +`GIT_DIR= git-apply $context --binary --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";
205
206 print "Patch applied successfully. Adding new files and directories to CVS\n";
207 my $dirtypatch = 0;