|
17 | 17 | use warnings; |
18 | 18 | use Getopt::Std; |
19 | 19 | use File::Spec; |
20 | | -use File::Temp qw(tempfile); |
| 20 | +use File::Temp qw(tempfile tmpnam); |
21 | 21 | use File::Path qw(mkpath); |
22 | 22 | use File::Basename qw(basename dirname); |
23 | 23 | use Time::Local; |
@@ -467,13 +467,12 @@ ($$) |
467 | 467 | $orig_git_index = $ENV{GIT_INDEX_FILE} if exists $ENV{GIT_INDEX_FILE}; |
468 | 468 |
|
469 | 469 | my %index; # holds filenames of one index per branch |
470 | | -{ # init with an index for origin |
471 | | - my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx', |
472 | | - DIR => File::Spec->tmpdir()); |
473 | | - close ($fh); |
474 | | - $index{$opt_o} = $fn; |
475 | | -} |
| 470 | +$index{$opt_o} = tmpnam(); |
| 471 | + |
476 | 472 | $ENV{GIT_INDEX_FILE} = $index{$opt_o}; |
| 473 | +system("git-read-tree", $opt_o); |
| 474 | +die "read-tree failed: $?\n" if $?; |
| 475 | + |
477 | 476 | unless(-d $git_dir) { |
478 | 477 | system("git-init-db"); |
479 | 478 | die "Cannot init the GIT db at $git_tree: $?\n" if $?; |
@@ -502,10 +501,7 @@ ($$) |
502 | 501 |
|
503 | 502 | # populate index |
504 | 503 | unless ($index{$last_branch}) { |
505 | | - my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx', |
506 | | - DIR => File::Spec->tmpdir()); |
507 | | - close ($fh); |
508 | | - $index{$last_branch} = $fn; |
| 504 | + $index{$last_branch} = tmpnam(); |
509 | 505 | } |
510 | 506 | $ENV{GIT_INDEX_FILE} = $index{$last_branch}; |
511 | 507 | system('git-read-tree', $last_branch); |
@@ -818,16 +814,26 @@ sub commit { |
818 | 814 | if(($ancestor || $branch) ne $last_branch) { |
819 | 815 | print "Switching from $last_branch to $branch\n" if $opt_v; |
820 | 816 | unless ($index{$branch}) { |
821 | | - my ($fh, $fn) = tempfile('gitXXXXXX', SUFFIX => '.idx', |
822 | | - DIR => File::Spec->tmpdir()); |
823 | | - close ($fh); |
824 | | - $index{$branch} = $fn; |
| 817 | + $index{$branch} = tmpnam(); |
825 | 818 | $ENV{GIT_INDEX_FILE} = $index{$branch}; |
826 | 819 | system("git-read-tree", $branch); |
827 | 820 | die "read-tree failed: $?\n" if $?; |
828 | | - } else { |
| 821 | + } |
| 822 | + # just in case |
| 823 | + $ENV{GIT_INDEX_FILE} = $index{$branch}; |
| 824 | + if ($ancestor) { |
| 825 | + print "have ancestor $ancestor" if $opt_v; |
| 826 | + system("git-read-tree", $ancestor); |
| 827 | + die "read-tree failed: $?\n" if $?; |
| 828 | + } |
| 829 | + } else { |
| 830 | + # just in case |
| 831 | + unless ($index{$branch}) { |
| 832 | + $index{$branch} = tmpnam(); |
829 | 833 | $ENV{GIT_INDEX_FILE} = $index{$branch}; |
830 | | - } |
| 834 | + system("git-read-tree", $branch); |
| 835 | + die "read-tree failed: $?\n" if $?; |
| 836 | + } |
831 | 837 | } |
832 | 838 | $last_branch = $branch if $branch ne $last_branch; |
833 | 839 | $state = 9; |
|
0 commit comments