summaryrefslogtreecommitdiff
path: root/git-svn.perl
diff options
context:
space:
mode:
Diffstat (limited to 'git-svn.perl')
-rwxr-xr-xgit-svn.perl50
1 files changed, 21 insertions, 29 deletions
diff --git a/git-svn.perl b/git-svn.perl
index 4aa208f..b0d0a50 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1,11 +1,12 @@
#!/usr/bin/perl
# Copyright (C) 2006, Eric Wong <normalperson@yhbt.net>
# License: GPL v2 or later
-use 5.008;
-use warnings;
+use 5.008001;
+use warnings $ENV{GIT_PERL_FATAL_WARNINGS} ? qw(FATAL all) : ();
use strict;
use vars qw/ $AUTHOR $VERSION
- $sha1 $sha1_short $_revision $_repository
+ $oid $oid_short $oid_length
+ $_revision $_repository
$_q $_authors $_authors_prog %users/;
$AUTHOR = 'Eric Wong <normalperson@yhbt.net>';
$VERSION = '@@GIT_VERSION@@';
@@ -103,8 +104,9 @@ sub _req_svn {
}
}
-$sha1 = qr/[a-f\d]{40}/;
-$sha1_short = qr/[a-f\d]{4,40}/;
+$oid = qr/(?:[a-f\d]{40}(?:[a-f\d]{24})?)/;
+$oid_short = qr/[a-f\d]{4,64}/;
+$oid_length = 40;
my ($_stdin, $_help, $_edit,
$_message, $_file, $_branch_dest,
$_template, $_shared,
@@ -271,7 +273,6 @@ my %cmd = (
'fetch-all|all' => \$_fetch_all,
'dry-run|n' => \$_dry_run,
'rebase-merges|p' => \$_rebase_merges,
- 'preserve-merges|p' => \$_rebase_merges,
%fc_opts } ],
'commit-diff' => [ \&cmd_commit_diff,
'Commit a diff between two trees',
@@ -296,28 +297,12 @@ my %cmd = (
{} ],
);
-package FakeTerm;
-sub new {
- my ($class, $reason) = @_;
- return bless \$reason, shift;
-}
-sub readline {
- my $self = shift;
- die "Cannot use readline on FakeTerm: $$self";
-}
-package main;
-
my $term;
sub term_init {
- $term = eval {
- require Term::ReadLine;
- $ENV{"GIT_SVN_NOTTY"}
+ require Term::ReadLine;
+ $term = $ENV{"GIT_SVN_NOTTY"}
? new Term::ReadLine 'git-svn', \*STDIN, \*STDOUT
: new Term::ReadLine 'git-svn';
- };
- if ($@) {
- $term = new FakeTerm "$@: going non-interactive";
- }
}
my $cmd;
@@ -498,6 +483,7 @@ sub do_git_init_db {
command_noisy('config', "$pfx.preserve-empty-dirs", 'true');
command_noisy('config', "$pfx.placeholder-filename", $$fname);
}
+ load_object_format();
}
sub init_subdir {
@@ -582,7 +568,7 @@ sub cmd_set_tree {
print "Reading from stdin...\n";
@commits = ();
while (<STDIN>) {
- if (/\b($sha1_short)\b/o) {
+ if (/\b($oid_short)\b/o) {
unshift @commits, $1;
}
}
@@ -1831,7 +1817,7 @@ sub get_tree_from_treeish {
if ($type eq 'commit') {
$expected = (grep /^tree /, command(qw/cat-file commit/,
$treeish))[0];
- ($expected) = ($expected =~ /^tree ($sha1)$/o);
+ ($expected) = ($expected =~ /^tree ($oid)$/o);
die "Unable to get tree from $treeish\n" unless $expected;
} elsif ($type eq 'tree') {
$expected = $treeish;
@@ -1975,9 +1961,15 @@ sub read_git_config {
}
}
}
+ load_object_format();
delete @$opts{@config_only} if @config_only;
}
+sub load_object_format {
+ chomp(my $hash = `git config --get extensions.objectformat`);
+ $::oid_length = 64 if $hash eq 'sha256';
+}
+
sub extract_metadata {
my $id = shift or return (undef, undef, undef);
my ($url, $rev, $uuid) = ($id =~ /^\s*git-svn-id:\s+(.*)\@(\d+)
@@ -2006,10 +1998,10 @@ sub cmt_sha2rev_batch {
print $out $sha, "\n";
while (my $line = <$in>) {
- if ($first && $line =~ /^[[:xdigit:]]{40}\smissing$/) {
+ if ($first && $line =~ /^$::oid\smissing$/) {
last;
} elsif ($first &&
- $line =~ /^[[:xdigit:]]{40}\scommit\s(\d+)$/) {
+ $line =~ /^$::oid\scommit\s(\d+)$/) {
$first = 0;
$size = $1;
next;
@@ -2036,7 +2028,7 @@ sub working_head_info {
my $hash;
my %max;
while (<$fh>) {
- if ( m{^commit ($::sha1)$} ) {
+ if ( m{^commit ($::oid)$} ) {
unshift @$refs, $hash if $hash and $refs;
$hash = $1;
next;