Skip to content

Commit

Permalink
cvsexportcommit -p : fix the usage of git-apply -C.
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
kroki authored and Junio C Hamano committed Apr 10, 2007
1 parent 24c64d6 commit fc1f458
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions git-cvsexportcommit.perl
Expand Up @@ -124,12 +124,17 @@
`git-diff-tree --binary -p $parent $commit >.cvsexportcommit.diff`;# || die "Cannot diff";

## apply non-binary changes
my $fuzz = $opt_p ? 0 : 2;

# In pedantic mode require all lines of context to match. In normal
# mode, be compatible with diff/patch: assume 3 lines of context and
# require at least one line match, i.e. ignore at most 2 lines of
# context, like diff/patch do by default.
my $context = $opt_p ? '' : '-C1';

print "Checking if patch will apply\n";

my @stat;
open APPLY, "GIT_DIR= git-apply -C$fuzz --binary --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch";
open APPLY, "GIT_DIR= git-apply $context --binary --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch";
@stat=<APPLY>;
close APPLY || die "Cannot patch";
my (@bfiles,@files,@afiles,@dfiles);
Expand Down Expand Up @@ -196,7 +201,7 @@
}

print "Applying\n";
`GIT_DIR= git-apply -C$fuzz --binary --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";
`GIT_DIR= git-apply $context --binary --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch";

print "Patch applied successfully. Adding new files and directories to CVS\n";
my $dirtypatch = 0;
Expand Down

0 comments on commit fc1f458

Please sign in to comment.