|
22 | 22 | my $repo = Git->repository();
|
23 | 23 | $opt_w = $repo->config('cvsexportcommit.cvsdir') unless defined $opt_w;
|
24 | 24 |
|
| 25 | +my $tmpdir = File::Temp->newdir; |
| 26 | +my $hash_algo = $repo->config('extensions.objectformat') || 'sha1'; |
| 27 | +my $hexsz = $hash_algo eq 'sha256' ? 64 : 40; |
| 28 | + |
25 | 29 | if ($opt_w || $opt_W) {
|
26 | 30 | # Remember where GIT_DIR is before changing to CVS checkout
|
27 | 31 | unless ($ENV{GIT_DIR}) {
|
|
96 | 100 | }
|
97 | 101 |
|
98 | 102 | if ($stage eq 'headers') {
|
99 |
| - if ($line =~ m/^parent (\w{40})$/) { # found a parent |
| 103 | + if ($line =~ m/^parent ([0-9a-f]{$hexsz})$/) { # found a parent |
100 | 104 | push @parents, $1;
|
101 | 105 | } elsif ($line =~ m/^author (.+) \d+ [-+]\d+$/) {
|
102 | 106 | $author = $1;
|
|
111 | 115 | }
|
112 | 116 | }
|
113 | 117 |
|
114 |
| -my $noparent = "0000000000000000000000000000000000000000"; |
| 118 | +my $noparent = "0" x $hexsz; |
115 | 119 | if ($parent) {
|
116 | 120 | my $found;
|
117 | 121 | # double check that it's a valid parent
|
|
174 | 178 | print "Checking if patch will apply\n";
|
175 | 179 |
|
176 | 180 | my @stat;
|
177 |
| -open APPLY, "GIT_DIR= git-apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; |
| 181 | +open APPLY, "GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat<.cvsexportcommit.diff|" || die "cannot patch"; |
178 | 182 | @stat=<APPLY>;
|
179 | 183 | close APPLY || die "Cannot patch";
|
180 | 184 | my (@bfiles,@files,@afiles,@dfiles);
|
|
329 | 333 | if ($opt_W) {
|
330 | 334 | system("git checkout -q $commit^0") && die "cannot patch";
|
331 | 335 | } else {
|
332 |
| - `GIT_DIR= git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; |
| 336 | + `GIT_INDEX_FILE=$tmpdir/index git-apply $context --summary --numstat --apply <.cvsexportcommit.diff` || die "cannot patch"; |
333 | 337 | }
|
334 | 338 |
|
335 | 339 | print "Patch applied successfully. Adding new files and directories to CVS\n";
|
|
407 | 411 |
|
408 | 412 | if ($opt_W) {
|
409 | 413 | system("git checkout $go_back_to") && die "cannot move back to $go_back_to";
|
410 |
| - if (!($go_back_to =~ /^[0-9a-fA-F]{40}$/)) { |
| 414 | + if (!($go_back_to =~ /^[0-9a-fA-F]{$hexsz}$/)) { |
411 | 415 | system("git symbolic-ref HEAD $go_back_to") &&
|
412 | 416 | die "cannot move back to $go_back_to";
|
413 | 417 | }
|
|
0 commit comments