4 use vars qw
/ $AUTHOR $VERSION
5 $SVN_URL $SVN_INFO $SVN_WC
6 $GIT_SVN_INDEX $GIT_SVN
8 $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
10 $GIT_DIR = $ENV{GIT_DIR
} || "$ENV{PWD}/.git";
11 $GIT_SVN = $ENV{GIT_SVN_ID
} || 'git-svn';
12 $GIT_SVN_INDEX = "$GIT_DIR/$GIT_SVN/index";
13 $ENV{GIT_DIR
} ||= $GIT_DIR;
15 $REV_DIR = "$GIT_DIR/$GIT_SVN/revs";
16 $SVN_WC = "$GIT_DIR/$GIT_SVN/tree";
18 # make sure the svn binary gives consistent output between locales and TZs:
22 # If SVN:: library support is added, please make the dependencies
23 # optional and preserve the capability to use the command-line client.
24 # See what I do with XML::Simple to make the dependency optional.
27 use File
::Basename qw
/dirname basename/;
28 use File
::Path qw
/mkpath/;
29 use Getopt
::Long qw
/:config gnu_getopt no_ignore_case auto_abbrev/;
31 my $sha1 = qr/[a-f\d]{40}/;
32 my $sha1_short = qr/[a-f\d]{6,40}/;
33 my ($_revision,$_stdin,$_no_ignore_ext,$_no_stop_copy,$_help,$_rmdir,$_edit,
34 $_find_copies_harder, $_l);
36 GetOptions
( 'revision|r=s' => \
$_revision,
37 'no-ignore-externals' => \
$_no_ignore_ext,
41 'help|H|h' => \
$_help,
42 'find-copies-harder' => \
$_find_copies_harder,
44 'no-stop-on-copy' => \
$_no_stop_copy );
46 fetch
=> [ \
&fetch
, "Download new revisions from SVN" ],
47 init
=> [ \
&init
, "Initialize and fetch (import)"],
48 commit
=> [ \
&commit
, "Commit git revisions to SVN" ],
49 rebuild
=> [ \
&rebuild
, "Rebuild git-svn metadata (after git clone)" ],
50 help
=> [ \
&usage
, "Show help" ],
53 for (my $i = 0; $i < @ARGV; $i++) {
54 if (defined $cmd{$ARGV[$i]}) {
61 # we may be called as git-svn-(command), or git-svn(command).
63 if (/git\-svn\-?($_)(?:\.\w+)?$/) {
69 usage
(1) unless (defined $cmd);
70 svn_check_ignore_externals
();
71 $cmd{$cmd}->[0]->(@ARGV);
74 ####################### primary functions ######################
76 my $exit = shift || 0;
77 my $fd = $exit ? \
*STDERR
: \
*STDOUT
;
79 git
-svn
- bidirectional operations between a single Subversion tree
and git
80 Usage
: $0 <command
> [options
] [arguments
]\n
83 foreach (sort keys %cmd) {
84 print $fd ' ',pack('A10',$_),$cmd{$_}->[1],"\n";
87 \nGIT_SVN_ID may be set
in the environment to an arbitrary identifier
if
88 you
're tracking multiple SVN branches/repositories in one git repository
89 and want to keep them separate.
95 $SVN_URL = shift or undef;
99 my $pid = open(my $rev_list,'-|');
100 defined $pid or croak $!;
102 exec("git-rev-list","$GIT_SVN-HEAD") or croak $!;
105 while (<$rev_list>) {
108 croak "Non-SHA1: $c\n" unless $c =~ /^$sha1$/o;
109 my @commit = grep(/^git-svn-id: /,`git-cat-file commit $c`);
110 next if (!@commit); # skip merges
111 my $id = $commit[$#commit];
112 my ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\s(\S+?)\@(\d+)
114 if (!$rev || !$uuid || !$url) {
115 # some of the original repositories I made had
116 # indentifiers like this:
117 ($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)
119 if (!$rev || !$uuid) {
120 croak "Unable to extract revision or UUID from ",
124 print "r$rev = $c\n";
125 unless (defined $first) {
126 if (!$SVN_URL && !$url) {
127 croak "SVN repository location required: $url\n";
130 $repo_uuid = setup_git_svn();
133 if ($uuid ne $repo_uuid) {
134 croak "Repository UUIDs do not match!\ngot: $uuid\n",
135 "expected: $repo_uuid\n";
137 assert_revision_eq_or_unknown($rev, $c);
138 sys('git
-update
-ref',"$GIT_SVN/revs/$rev",$c);
139 $newest_rev = $rev if ($rev > $newest_rev);
141 close $rev_list or croak $?;
142 if (!chdir $SVN_WC) {
143 my @svn_co = ('svn
','co
',"-r$first");
144 push @svn_co, '--ignore
-externals
' unless $_no_ignore_ext;
145 sys(@svn_co, $SVN_URL, $SVN_WC);
146 chdir $SVN_WC or croak $!;
150 defined $pid or croak $!;
152 my @svn_up = qw(svn up);
153 push @svn_up, '--ignore-externals' unless $_no_ignore_ext;
154 sys
(@svn_up,"-r$newest_rev");
155 $ENV{GIT_INDEX_FILE
} = $GIT_SVN_INDEX;
157 exec('git-write-tree');
163 $SVN_URL = shift or croak
"SVN repository location required\n";
164 unless (-d
$GIT_DIR) {
172 $SVN_URL ||= file_to_s
("$GIT_DIR/$GIT_SVN/info/url");
173 my @log_args = -d
$SVN_WC ?
($SVN_WC) : ($SVN_URL);
174 unless ($_revision) {
175 $_revision = -d
$SVN_WC ?
'BASE:HEAD' : '0:HEAD';
177 push @log_args, "-r$_revision";
178 push @log_args, '--stop-on-copy' unless $_no_stop_copy;
180 eval { require XML
::Simple
or croak
$! };
181 my $svn_log = $@ ? svn_log_raw
(@log_args) : svn_log_xml
(@log_args);
182 @
$svn_log = sort { $a->{revision
} <=> $b->{revision
} } @
$svn_log;
184 my $base = shift @
$svn_log or croak
"No base revision!\n";
185 my $last_commit = undef;
186 unless (-d
$SVN_WC) {
187 my @svn_co = ('svn','co',"-r$base->{revision}");
188 push @svn_co,'--ignore-externals' unless $_no_ignore_ext;
189 sys
(@svn_co, $SVN_URL, $SVN_WC);
190 chdir $SVN_WC or croak
$!;
191 $last_commit = git_commit
($base, @parents);
192 unless (-f
"$GIT_DIR/refs/heads/master") {
193 sys
(qw(git-update-ref refs/heads/master),$last_commit);
195 assert_svn_wc_clean
($base->{revision
}, $last_commit);
197 chdir $SVN_WC or croak
$!;
198 $last_commit = file_to_s
("$REV_DIR/$base->{revision}");
200 my @svn_up = qw(svn up);
201 push @svn_up, '--ignore-externals' unless $_no_ignore_ext;
202 my $last_rev = $base->{revision
};
203 foreach my $log_msg (@
$svn_log) {
204 assert_svn_wc_clean
($last_rev, $last_commit);
205 $last_rev = $log_msg->{revision
};
206 sys
(@svn_up,"-r$last_rev");
207 $last_commit = git_commit
($log_msg, $last_commit, @parents);
209 assert_svn_wc_clean
($last_rev, $last_commit);
210 return pop @
$svn_log;
215 if ($_stdin || !@commits) {
216 print "Reading from stdin...\n";
219 if (/\b([a-f\d]{6,40})\b/) {
220 unshift @commits, $1;
225 foreach my $c (@commits) {
226 chomp(my @tmp = safe_qx
('git-rev-parse',$c));
227 if (scalar @tmp == 1) {
229 } elsif (scalar @tmp > 1) {
230 push @revs, reverse (safe_qx
('git-rev-list',@tmp));
232 die "Failed to rev-parse $c\n";
238 chdir $SVN_WC or croak
$!;
239 my $svn_current_rev = svn_info
('.')->{'Last Changed Rev'};
240 foreach my $c (@revs) {
241 print "Committing $c\n";
242 svn_checkout_tree
($svn_current_rev, $c);
243 $svn_current_rev = svn_commit_tree
($svn_current_rev, $c);
245 print "Done committing ",scalar @revs," revisions to SVN\n";
249 ########################### utility functions #########################
252 defined $SVN_URL or croak
"SVN repository location required\n";
253 unless (-d
$GIT_DIR) {
254 croak
"GIT_DIR=$GIT_DIR does not exist!\n";
256 mkpath
(["$GIT_DIR/$GIT_SVN"]);
257 mkpath
(["$GIT_DIR/$GIT_SVN/info"]);
259 s_to_file
($SVN_URL,"$GIT_DIR/$GIT_SVN/info/url");
260 my $uuid = svn_info
($SVN_URL)->{'Repository UUID'} or
261 croak
"Repository UUID unreadable\n";
262 s_to_file
($uuid,"$GIT_DIR/$GIT_SVN/info/uuid");
264 open my $fd, '>>', "$GIT_DIR/$GIT_SVN/info/exclude" or croak
$!;
265 print $fd '.svn',"\n";
266 close $fd or croak
$!;
270 sub assert_svn_wc_clean
{
271 my ($svn_rev, $commit) = @_;
272 croak
"$svn_rev is not an integer!\n" unless ($svn_rev =~ /^\d+$/);
273 croak
"$commit is not a sha1!\n" unless ($commit =~ /^$sha1$/o);
274 my $svn_info = svn_info
('.');
275 if ($svn_rev != $svn_info->{'Last Changed Rev'}) {
276 croak
"Expected r$svn_rev, got r",
277 $svn_info->{'Last Changed Rev'},"\n";
279 my @status = grep(!/^Performing status on external/,(`svn status`));
280 @status = grep(!/^\s*$/,@status);
281 if (scalar @status) {
282 print STDERR
"Tree ($SVN_WC) is not clean:\n";
283 print STDERR
$_ foreach @status;
286 my ($tree_a) = grep(/^tree $sha1$/o,`git-cat-file commit $commit`);
287 $tree_a =~ s/^tree //;
289 chomp(my $tree_b = `GIT_INDEX_FILE=$GIT_SVN_INDEX git-write-tree`);
290 if ($tree_a ne $tree_b) {
291 croak
"$svn_rev != $commit, $tree_a != $tree_b\n";
295 sub parse_diff_tree
{
301 chomp $_; # this gets rid of the trailing "\0"
303 if ($state eq 'meta' && /^:(\d
{6})\s
(\d
{6})\s
304 $sha1\s
($sha1)\s
([MTCRAD
])\d
*$/xo
) {
305 push @mods, { mode_a
=> $1, mode_b
=> $2,
306 sha1_b
=> $3, chg
=> $4 };
307 if ($4 =~ /^(?:C|R)$/) {
312 } elsif ($state eq 'file_a') {
313 my $x = $mods[$#mods] or croak __LINE__
,": Empty array\n";
314 if ($x->{chg
} !~ /^(?:C|R)$/) {
315 croak __LINE__
,": Error parsing $_, $x->{chg}\n";
319 } elsif ($state eq 'file_b') {
320 my $x = $mods[$#mods] or croak __LINE__
,": Empty array\n";
321 if (exists $x->{file_a
} && $x->{chg
} !~ /^(?:C|R)$/) {
322 croak __LINE__
,": Error parsing $_, $x->{chg}\n";
324 if (!exists $x->{file_a
} && $x->{chg
} =~ /^(?:C|R)$/) {
325 croak __LINE__
,": Error parsing $_, $x->{chg}\n";
330 croak __LINE__
,": Error parsing $_\n";
333 close $diff_fh or croak
$!;
337 sub svn_check_prop_executable
{
339 if ($m->{mode_b
} =~ /755$/ && $m->{mode_a
} !~ /755$/) {
340 sys
(qw(svn propset svn:executable 1), $m->{file_b
});
341 } elsif ($m->{mode_b
} !~ /755$/ && $m->{mode_a
} =~ /755$/) {
342 sys
(qw(svn propdel svn:executable), $m->{file_b
});
346 sub svn_ensure_parent_path
{
347 my $dir_b = dirname
(shift);
348 svn_ensure_parent_path
($dir_b) if ($dir_b ne File
::Spec
->curdir);
349 mkpath
([$dir_b]) unless (-d
$dir_b);
350 sys
(qw(svn add -N), $dir_b) unless (-d
"$dir_b/.svn");
353 sub svn_checkout_tree
{
354 my ($svn_rev, $commit) = @_;
355 my $from = file_to_s
("$REV_DIR/$svn_rev");
356 assert_svn_wc_clean
($svn_rev,$from);
357 print "diff-tree '$from' '$commit'\n";
358 my $pid = open my $diff_fh, '-|';
359 defined $pid or croak
$!;
361 my @diff_tree = qw(git-diff-tree -z -r -C);
362 push @diff_tree, '--find-copies-harder' if $_find_copies_harder;
363 push @diff_tree, "-l$_l" if defined $_l;
364 exec(@diff_tree, $from, $commit) or croak
$!;
366 my $mods = parse_diff_tree
($diff_fh);
368 # git can do empty commits, SVN doesn't allow it...
372 foreach my $m (@
$mods) {
373 if ($m->{chg
} eq 'C') {
374 svn_ensure_parent_path
( $m->{file_b
} );
375 sys
(qw(svn cp), $m->{file_a
}, $m->{file_b
});
376 blob_to_file
( $m->{sha1_b
}, $m->{file_b
});
377 svn_check_prop_executable
($m);
378 } elsif ($m->{chg
} eq 'D') {
379 $rm{dirname
$m->{file_b
}}->{basename
$m->{file_b
}} = 1;
380 sys
(qw(svn rm --force), $m->{file_b
});
381 } elsif ($m->{chg
} eq 'R') {
382 svn_ensure_parent_path
( $m->{file_b
} );
383 sys
(qw(svn mv --force), $m->{file_a
}, $m->{file_b
});
384 blob_to_file
( $m->{sha1_b
}, $m->{file_b
});
385 svn_check_prop_executable
($m);
386 $rm{dirname
$m->{file_a
}}->{basename
$m->{file_a
}} = 1;
387 } elsif ($m->{chg
} eq 'M') {
388 if ($m->{mode_b
} =~ /^120/ && $m->{mode_a
} =~ /^120/) {
389 unlink $m->{file_b
} or croak
$!;
390 blob_to_symlink
($m->{sha1_b
}, $m->{file_b
});
392 blob_to_file
($m->{sha1_b
}, $m->{file_b
});
394 svn_check_prop_executable
($m);
395 } elsif ($m->{chg
} eq 'T') {
396 sys
(qw(svn rm --force),$m->{file_b
});
397 if ($m->{mode_b
} =~ /^120/ && $m->{mode_a
} =~ /^100/) {
398 blob_to_symlink
($m->{sha1_b
}, $m->{file_b
});
400 blob_to_file
($m->{sha1_b
}, $m->{file_b
});
402 svn_check_prop_executable
($m);
403 sys
(qw(svn add --force), $m->{file_b
});
404 } elsif ($m->{chg
} eq 'A') {
405 svn_ensure_parent_path
( $m->{file_b
} );
406 blob_to_file
( $m->{sha1_b
}, $m->{file_b
});
407 if ($m->{mode_b
} =~ /755$/) {
408 chmod 0755, $m->{file_b
};
410 sys
(qw(svn add --force), $m->{file_b
});
412 croak
"Invalid chg: $m->{chg}\n";
416 my $old_index = $ENV{GIT_INDEX_FILE
};
417 $ENV{GIT_INDEX_FILE
} = $GIT_SVN_INDEX;
418 foreach my $dir (keys %rm) {
419 my $files = $rm{$dir};
421 foreach (safe_qx
('svn','ls',$dir)) {
423 push @files, $_ unless $files->{$_};
425 sys
(qw(svn rm),$dir) unless @files;
428 $ENV{GIT_INDEX_FILE
} = $old_index;
430 delete $ENV{GIT_INDEX_FILE
};
435 sub svn_commit_tree
{
436 my ($svn_rev, $commit) = @_;
437 my $commit_msg = "$GIT_DIR/$GIT_SVN/.svn-commit.tmp.$$";
438 open my $msg, '>', $commit_msg or croak
$!;
440 chomp(my $type = `git-cat-file -t $commit`);
441 if ($type eq 'commit') {
442 my $pid = open my $msg_fh, '-|';
443 defined $pid or croak
$!;
446 exec(qw(git-cat-file commit), $commit) or croak
$!;
451 $in_msg = 1 if (/^\s*$/);
453 print $msg $_ or croak
$!;
456 close $msg_fh or croak
$!;
458 close $msg or croak
$!;
460 if ($_edit || ($type eq 'tree')) {
461 my $editor = $ENV{VISUAL
} || $ENV{EDITOR
} || 'vi';
462 system($editor, $commit_msg);
464 my @ci_output = safe_qx
(qw(svn commit -F),$commit_msg);
465 my ($committed) = grep(/^Committed revision \d+\./,@ci_output);
467 defined $committed or croak
468 "Commit output failed to parse committed revision!\n",
469 join("\n",@ci_output),"\n";
470 my ($rev_committed) = ($committed =~ /^Committed revision (\d+)\./);
473 my @svn_up = (qw(svn up), "-r$svn_rev");
474 push @svn_up, '--ignore-externals' unless $_no_ignore_ext;
476 return fetch
("$rev_committed=$commit")->{revision
};
481 my $log_fh = IO
::File
->new_tmpfile or croak
$!;
484 defined $pid or croak
$!;
487 open STDOUT
, '>&', $log_fh or croak
$!;
488 exec (qw(svn log --xml), @log_args) or croak
$!
496 my $log = XML
::Simple
::XMLin
( $log_fh,
497 ForceArray
=> ['path','revision','logentry'],
499 KeyAttr
=> { logentry
=> '+revision',
502 foreach my $r (sort {$a <=> $b} keys %$log) {
503 my $log_msg = $log->{$r};
504 my ($Y,$m,$d,$H,$M,$S) = ($log_msg->{date
} =~
505 /(\d
{4})\
-(\d\d
)\
-(\d\d
)T
506 (\d\d
)\
:(\d\d
)\
:(\d\d
)\
.\d
+Z
$/x
)
507 or croak
"Failed to parse date: ",
509 $log_msg->{date
} = "+0000 $Y-$m-$d $H:$M:$S";
511 # XML::Simple can't handle <msg></msg> as a string:
512 if (ref $log_msg->{msg
} eq 'HASH') {
513 $log_msg->{msg
} = "\n";
515 $log_msg->{msg
} .= "\n";
517 push @svn_log, $log->{$r};
524 my $pid = open my $log_fh,'-|';
525 defined $pid or croak
$!;
528 exec (qw(svn log), @log_args) or croak
$!
538 # if we have an empty log message, put something there:
540 $svn_log[$#svn_log]->{msg
} ||= "\n";
544 if ($state eq 'rev' && s/^r(\d+)\s*\|\s*//) {
546 my ($author, $date) = split(/\s*\|\s*/, $_, 2);
547 my ($Y,$m,$d,$H,$M,$S,$tz) = ($date =~
548 /(\d
{4})\
-(\d\d
)\
-(\d\d
)\s
549 (\d\d
)\
:(\d\d
)\
:(\d\d
)\s
([\
-\
+]\d
+)/x
)
550 or croak
"Failed to parse date: $date\n";
551 my %log_msg = ( revision
=> $rev,
552 date
=> "$tz $Y-$m-$d $H:$M:$S",
555 push @svn_log, \
%log_msg;
556 $state = 'msg_start';
559 # skip the first blank line of the message:
560 if ($state eq 'msg_start' && /^$/) {
562 } elsif ($state eq 'msg') {
563 $svn_log[$#svn_log]->{msg
} .= $_."\n";
566 close $log_fh or croak
$?
;
571 my $url = shift || $SVN_URL;
573 my $pid = open my $info_fh, '-|';
574 defined $pid or croak
$!;
577 exec(qw(svn info),$url) or croak
$!;
581 # only single-lines seem to exist in svn info output
584 if (m
#^([^:]+)\s*:\s*(\S*)$#) {
586 push @
{$ret->{-order
}}, $1;
589 close $info_fh or croak
$!;
593 sub sys
{ system(@_) == 0 or croak
$?
}
596 system( "git-diff-files --name-only -z ".
597 " | git-update-index --remove -z --stdin; ".
598 "git-ls-files -z --others ".
599 "'--exclude-from=$GIT_DIR/$GIT_SVN/info/exclude'".
600 " | git-update-index --add -z --stdin; "
605 my ($str, $file, $mode) = @_;
606 open my $fd,'>',$file or croak
$!;
607 print $fd $str,"\n" or croak
$!;
608 close $fd or croak
$!;
609 chmod ($mode &~ umask, $file) if (defined $mode);
614 open my $fd,'<',$file or croak
"$!: file: $file\n";
617 close $fd or croak
$!;
622 sub assert_revision_unknown
{
624 if (-f
"$REV_DIR/$revno") {
625 croak
"$REV_DIR/$revno already exists! ",
626 "Why are we refetching it?";
630 sub assert_revision_eq_or_unknown
{
631 my ($revno, $commit) = @_;
632 if (-f
"$REV_DIR/$revno") {
633 my $current = file_to_s
("$REV_DIR/$revno");
634 if ($commit ne $current) {
635 croak
"$REV_DIR/$revno already exists!\n",
636 "current: $current\nexpected: $commit\n";
643 my ($log_msg, @parents) = @_;
644 assert_revision_unknown
($log_msg->{revision
});
645 my $out_fh = IO
::File
->new_tmpfile or croak
$!;
646 my $info = svn_info
('.');
647 my $uuid = $info->{'Repository UUID'};
648 defined $uuid or croak
"Unable to get Repository UUID\n";
650 # commit parents can be conditionally bound to a particular
651 # svn revision via: "svn_revno=commit_sha1", filter them out here:
653 foreach my $p (@parents) {
654 next unless defined $p;
655 if ($p =~ /^(\d+)=($sha1_short)$/o) {
656 if ($1 == $log_msg->{revision
}) {
657 push @exec_parents, $2;
660 push @exec_parents, $p if $p =~ /$sha1_short/o;
665 defined $pid or croak
$!;
667 $ENV{GIT_INDEX_FILE
} = $GIT_SVN_INDEX;
669 chomp(my $tree = `git-write-tree`);
671 my $msg_fh = IO
::File
->new_tmpfile or croak
$!;
672 print $msg_fh $log_msg->{msg
}, "\ngit-svn-id: ",
673 "$SVN_URL\@$log_msg->{revision}",
674 " $uuid\n" or croak
$!;
675 $msg_fh->flush == 0 or croak
$!;
676 seek $msg_fh, 0, 0 or croak
$!;
678 $ENV{GIT_AUTHOR_NAME
} = $ENV{GIT_COMMITTER_NAME
} =
680 $ENV{GIT_AUTHOR_EMAIL
} = $ENV{GIT_COMMITTER_EMAIL
} =
681 $log_msg->{author
}."\@$uuid";
682 $ENV{GIT_AUTHOR_DATE
} = $ENV{GIT_COMMITTER_DATE
} =
684 my @exec = ('git-commit-tree',$tree);
685 push @exec, '-p', $_ foreach @exec_parents;
686 open STDIN
, '<&', $msg_fh or croak
$!;
687 open STDOUT
, '>&', $out_fh or croak
$!;
688 exec @exec or croak
$!;
693 $out_fh->flush == 0 or croak
$!;
694 seek $out_fh, 0, 0 or croak
$!;
695 chomp(my $commit = do { local $/; <$out_fh> });
696 if ($commit !~ /^$sha1$/o) {
697 croak
"Failed to commit, invalid sha1: $commit\n";
699 my @update_ref = ('git-update-ref',"refs/heads/$GIT_SVN-HEAD",$commit);
700 if (my $primary_parent = shift @exec_parents) {
701 push @update_ref, $primary_parent;
704 sys
('git-update-ref',"$GIT_SVN/revs/$log_msg->{revision}",$commit);
705 print "r$log_msg->{revision} = $commit\n";
709 sub blob_to_symlink
{
710 my ($blob, $link) = @_;
711 defined $link or croak
"\$link not defined!\n";
712 croak
"Not a sha1: $blob\n" unless $blob =~ /^$sha1$/o;
713 my $dest = `git-cat-file blob $blob`; # no newline, so no chomp
714 symlink $dest, $link or croak
$!;
718 my ($blob, $file) = @_;
719 defined $file or croak
"\$file not defined!\n";
720 croak
"Not a sha1: $blob\n" unless $blob =~ /^$sha1$/o;
721 open my $blob_fh, '>', $file or croak
"$!: $file\n";
723 defined $pid or croak
$!;
726 open STDOUT
, '>&', $blob_fh or croak
$!;
727 exec('git-cat-file','blob',$blob);
732 close $blob_fh or croak
$!;
736 my $pid = open my $child, '-|';
737 defined $pid or croak
$!;
739 exec(@_) or croak
$?
;
741 my @ret = (<$child>);
742 close $child or croak
$?
;
743 die $?
if $?
; # just in case close didn't error out
744 return wantarray ?
@ret : join('',@ret);
747 sub svn_check_ignore_externals
{
748 return if $_no_ignore_ext;
749 unless (grep /ignore-externals/,(safe_qx
(qw(svn co -h)))) {
750 print STDERR
"W: Installed svn version does not support ",
751 "--ignore-externals\n";
759 @svn_log = array of log_msg hashes
763 msg
=> 'whitespace-formatted log entry
764 ', # trailing newline is preserved
765 revision
=> '8', # integer
766 date
=> '2004-02-24T17:01:44.108345Z', # commit date
767 author
=> 'committer name'
771 @mods = array of diff
-index line hashes
, each element represents one line
774 diff
-index line
($m hash
)
776 mode_a
=> first column of diff
-index output
, no leading
':',
777 mode_b
=> second column of diff
-index output
,
778 sha1_b
=> sha1sum of the final blob
,
779 chg
=> change type
[MCRAD
],
780 file_a
=> original file name of a file
(iff chg is
'C' or 'R')
781 file_b
=> new
/current file name of a file
(any chg
)