mirror of
https://github.com/git/git.git
synced 2026-03-14 10:53:25 +01:00
Merge branch 'jc/commit-careful' into next
* jc/commit-careful: git-commit: show --summary after successful commit. git-svn: exit with status 1 for test failures git-svn: correctly access repos when only given partial read permissions git-branch -D: make it work even when on a yet-to-be-born branch Add -v and --abbrev options to git-branch git-clone: stop dumb protocol from copying refs outside heads/ and tags/.
This commit is contained in:
@@ -8,7 +8,7 @@ git-branch - List, create, or delete branches.
|
||||
SYNOPSIS
|
||||
--------
|
||||
[verse]
|
||||
'git-branch' [-r] [-a]
|
||||
'git-branch' [-r] [-a] [-v] [--abbrev=<length>]
|
||||
'git-branch' [-l] [-f] <branchname> [<start-point>]
|
||||
'git-branch' (-d | -D) <branchname>...
|
||||
|
||||
@@ -52,6 +52,13 @@ OPTIONS
|
||||
-a::
|
||||
List both remote-tracking branches and local branches.
|
||||
|
||||
-v::
|
||||
Show sha1 and subject message for each head.
|
||||
|
||||
--abbrev=<length>::
|
||||
Alter minimum display length for sha1 in output listing,
|
||||
default value is 7.
|
||||
|
||||
<branchname>::
|
||||
The name of the branch to create or delete.
|
||||
The new branch name must pass all checks defined by
|
||||
|
||||
@@ -23,6 +23,7 @@ $ echo 'hello world' > file.txt
|
||||
$ git add .
|
||||
$ git commit -a -m "initial commit"
|
||||
Committing initial tree 92b8b694ffb1675e5975148e1121810081dbdffe
|
||||
create mode 100644 file.txt
|
||||
$ echo 'hello world!' >file.txt
|
||||
$ git commit -a -m "add emphasis"
|
||||
------------------------------------------------
|
||||
|
||||
@@ -11,7 +11,7 @@
|
||||
#include "builtin.h"
|
||||
|
||||
static const char builtin_branch_usage[] =
|
||||
"git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | [-r] | [-a]";
|
||||
"git-branch (-d | -D) <branchname> | [-l] [-f] <branchname> [<start-point>] | [-r | -a] [-v] [--abbrev=<length>] ";
|
||||
|
||||
|
||||
static const char *head;
|
||||
@@ -38,12 +38,16 @@ static int in_merge_bases(const unsigned char *sha1,
|
||||
|
||||
static void delete_branches(int argc, const char **argv, int force)
|
||||
{
|
||||
struct commit *rev, *head_rev;
|
||||
struct commit *rev, *head_rev = head_rev;
|
||||
unsigned char sha1[20];
|
||||
char *name;
|
||||
int i;
|
||||
|
||||
head_rev = lookup_commit_reference(head_sha1);
|
||||
if (!force) {
|
||||
head_rev = lookup_commit_reference(head_sha1);
|
||||
if (!head_rev)
|
||||
die("Couldn't look up commit object for HEAD");
|
||||
}
|
||||
for (i = 0; i < argc; i++) {
|
||||
if (!strcmp(head, argv[i]))
|
||||
die("Cannot delete the branch you are currently on.");
|
||||
@@ -53,8 +57,8 @@ static void delete_branches(int argc, const char **argv, int force)
|
||||
die("Branch '%s' not found.", argv[i]);
|
||||
|
||||
rev = lookup_commit_reference(sha1);
|
||||
if (!rev || !head_rev)
|
||||
die("Couldn't look up commit objects.");
|
||||
if (!rev)
|
||||
die("Couldn't look up commit object for '%s'", name);
|
||||
|
||||
/* This checks whether the merge bases of branch and
|
||||
* HEAD contains branch -- which means that the HEAD
|
||||
@@ -87,10 +91,11 @@ static void delete_branches(int argc, const char **argv, int force)
|
||||
struct ref_item {
|
||||
char *name;
|
||||
unsigned int kind;
|
||||
unsigned char sha1[20];
|
||||
};
|
||||
|
||||
struct ref_list {
|
||||
int index, alloc;
|
||||
int index, alloc, maxwidth;
|
||||
struct ref_item *list;
|
||||
int kinds;
|
||||
};
|
||||
@@ -100,6 +105,7 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
|
||||
struct ref_list *ref_list = (struct ref_list*)(cb_data);
|
||||
struct ref_item *newitem;
|
||||
int kind = REF_UNKNOWN_TYPE;
|
||||
int len;
|
||||
|
||||
/* Detect kind */
|
||||
if (!strncmp(refname, "refs/heads/", 11)) {
|
||||
@@ -128,6 +134,10 @@ static int append_ref(const char *refname, const unsigned char *sha1, int flags,
|
||||
newitem = &(ref_list->list[ref_list->index++]);
|
||||
newitem->name = xstrdup(refname);
|
||||
newitem->kind = kind;
|
||||
hashcpy(newitem->sha1, sha1);
|
||||
len = strlen(newitem->name);
|
||||
if (len > ref_list->maxwidth)
|
||||
ref_list->maxwidth = len;
|
||||
|
||||
return 0;
|
||||
}
|
||||
@@ -151,7 +161,24 @@ static int ref_cmp(const void *r1, const void *r2)
|
||||
return strcmp(c1->name, c2->name);
|
||||
}
|
||||
|
||||
static void print_ref_list(int kinds)
|
||||
static void print_ref_info(const unsigned char *sha1, int abbrev)
|
||||
{
|
||||
struct commit *commit;
|
||||
char subject[256];
|
||||
|
||||
|
||||
commit = lookup_commit(sha1);
|
||||
if (commit && !parse_commit(commit))
|
||||
pretty_print_commit(CMIT_FMT_ONELINE, commit, ~0,
|
||||
subject, sizeof(subject), 0,
|
||||
NULL, NULL, 0);
|
||||
else
|
||||
strcpy(subject, " **** invalid ref ****");
|
||||
|
||||
printf(" %s %s\n", find_unique_abbrev(sha1, abbrev), subject);
|
||||
}
|
||||
|
||||
static void print_ref_list(int kinds, int verbose, int abbrev)
|
||||
{
|
||||
int i;
|
||||
char c;
|
||||
@@ -169,7 +196,13 @@ static void print_ref_list(int kinds)
|
||||
!strcmp(ref_list.list[i].name, head))
|
||||
c = '*';
|
||||
|
||||
printf("%c %s\n", c, ref_list.list[i].name);
|
||||
if (verbose) {
|
||||
printf("%c %-*s", c, ref_list.maxwidth,
|
||||
ref_list.list[i].name);
|
||||
print_ref_info(ref_list.list[i].sha1, abbrev);
|
||||
}
|
||||
else
|
||||
printf("%c %s\n", c, ref_list.list[i].name);
|
||||
}
|
||||
|
||||
free_ref_list(&ref_list);
|
||||
@@ -215,6 +248,7 @@ static void create_branch(const char *name, const char *start,
|
||||
int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
int delete = 0, force_delete = 0, force_create = 0;
|
||||
int verbose = 0, abbrev = DEFAULT_ABBREV;
|
||||
int reflog = 0;
|
||||
int kinds = REF_LOCAL_BRANCH;
|
||||
int i;
|
||||
@@ -255,6 +289,14 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
reflog = 1;
|
||||
continue;
|
||||
}
|
||||
if (!strncmp(arg, "--abbrev=", 9)) {
|
||||
abbrev = atoi(arg+9);
|
||||
continue;
|
||||
}
|
||||
if (!strcmp(arg, "-v")) {
|
||||
verbose = 1;
|
||||
continue;
|
||||
}
|
||||
usage(builtin_branch_usage);
|
||||
}
|
||||
|
||||
@@ -268,7 +310,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
|
||||
if (delete)
|
||||
delete_branches(argc - i, argv + i, force_delete);
|
||||
else if (i == argc)
|
||||
print_ref_list(kinds);
|
||||
print_ref_list(kinds, verbose, abbrev);
|
||||
else if (i == argc - 1)
|
||||
create_branch(argv[i], head, force_create, reflog);
|
||||
else if (i == argc - 2)
|
||||
|
||||
@@ -48,6 +48,10 @@ Perhaps git-update-server-info needs to be run there?"
|
||||
case "$name" in
|
||||
*^*) continue;;
|
||||
esac
|
||||
case "$bare,$name" in
|
||||
yes,* | ,heads/* | ,tags/*) ;;
|
||||
*) continue ;;
|
||||
esac
|
||||
if test -n "$use_separate_remote" &&
|
||||
branch_name=`expr "z$name" : 'zheads/\(.*\)'`
|
||||
then
|
||||
|
||||
@@ -629,4 +629,7 @@ if test -x "$GIT_DIR"/hooks/post-commit && test "$ret" = 0
|
||||
then
|
||||
"$GIT_DIR"/hooks/post-commit
|
||||
fi
|
||||
|
||||
test "$ret" = 0 && git-diff-tree --summary --root --no-commit-id HEAD
|
||||
|
||||
exit "$ret"
|
||||
|
||||
157
git-svn.perl
157
git-svn.perl
@@ -21,6 +21,7 @@ $ENV{TZ} = 'UTC';
|
||||
$ENV{LC_ALL} = 'C';
|
||||
$| = 1; # unbuffer STDOUT
|
||||
|
||||
sub fatal (@) { print STDERR $@; exit 1 }
|
||||
# If SVN:: library support is added, please make the dependencies
|
||||
# optional and preserve the capability to use the command-line client.
|
||||
# use eval { require SVN::... } to make it lazy load
|
||||
@@ -39,7 +40,7 @@ memoize('revisions_eq');
|
||||
memoize('cmt_metadata');
|
||||
memoize('get_commit_time');
|
||||
|
||||
my ($SVN_PATH, $SVN, $SVN_LOG, $_use_lib, $AUTH_BATON, $AUTH_CALLBACKS);
|
||||
my ($SVN, $_use_lib);
|
||||
|
||||
sub nag_lib {
|
||||
print STDERR <<EOF;
|
||||
@@ -381,10 +382,7 @@ sub fetch_cmd {
|
||||
sub fetch_lib {
|
||||
my (@parents) = @_;
|
||||
$SVN_URL ||= file_to_s("$GIT_SVN_DIR/info/url");
|
||||
my $repo;
|
||||
($repo, $SVN_PATH) = repo_path_split($SVN_URL);
|
||||
$SVN_LOG ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($SVN_URL);
|
||||
my ($last_rev, $last_commit) = svn_grab_base_rev();
|
||||
my ($base, $head) = libsvn_parse_revision($last_rev);
|
||||
if ($base > $head) {
|
||||
@@ -426,7 +424,7 @@ sub fetch_lib {
|
||||
# performance sucks with it enabled, so it's much
|
||||
# faster to fetch revision ranges instead of relying
|
||||
# on the limiter.
|
||||
libsvn_get_log($SVN_LOG, '/'.$SVN_PATH,
|
||||
libsvn_get_log(libsvn_dup_ra($SVN), [''],
|
||||
$min, $max, 0, 1, 1,
|
||||
sub {
|
||||
my $log_msg;
|
||||
@@ -528,7 +526,6 @@ sub commit_lib {
|
||||
my $commit_msg = "$GIT_SVN_DIR/.svn-commit.tmp.$$";
|
||||
|
||||
my $repo;
|
||||
($repo, $SVN_PATH) = repo_path_split($SVN_URL);
|
||||
set_svn_commit_env();
|
||||
foreach my $c (@revs) {
|
||||
my $log_msg = get_commit_message($c, $commit_msg);
|
||||
@@ -537,13 +534,11 @@ sub commit_lib {
|
||||
# can't track down... (it's probably in the SVN code)
|
||||
defined(my $pid = open my $fh, '-|') or croak $!;
|
||||
if (!$pid) {
|
||||
$SVN_LOG = libsvn_connect($repo);
|
||||
$SVN = libsvn_connect($repo);
|
||||
my $ed = SVN::Git::Editor->new(
|
||||
{ r => $r_last,
|
||||
ra => $SVN_LOG,
|
||||
ra => libsvn_dup_ra($SVN),
|
||||
c => $c,
|
||||
svn_path => $SVN_PATH
|
||||
svn_path => $SVN->{svn_path},
|
||||
},
|
||||
$SVN->get_commit_editor(
|
||||
$log_msg->{msg},
|
||||
@@ -575,7 +570,7 @@ sub commit_lib {
|
||||
$no = 1;
|
||||
}
|
||||
}
|
||||
close $fh or croak $?;
|
||||
close $fh or exit 1;
|
||||
if (! defined $r_new && ! defined $cmt_new) {
|
||||
unless ($no) {
|
||||
die "Failed to parse revision information\n";
|
||||
@@ -661,10 +656,9 @@ sub show_ignore_cmd {
|
||||
|
||||
sub show_ignore_lib {
|
||||
my $repo;
|
||||
($repo, $SVN_PATH) = repo_path_split($SVN_URL);
|
||||
$SVN ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($SVN_URL);
|
||||
my $r = defined $_revision ? $_revision : $SVN->get_latest_revnum;
|
||||
libsvn_traverse_ignore(\*STDOUT, $SVN_PATH, $r);
|
||||
libsvn_traverse_ignore(\*STDOUT, $SVN->{svn_path}, $r);
|
||||
}
|
||||
|
||||
sub graft_branches {
|
||||
@@ -790,7 +784,7 @@ sub show_log {
|
||||
} elsif (/^:\d{6} \d{6} $sha1_short/o) {
|
||||
push @{$c->{raw}}, $_;
|
||||
} elsif (/^[ACRMDT]\t/) {
|
||||
# we could add $SVN_PATH here, but that requires
|
||||
# we could add $SVN->{svn_path} here, but that requires
|
||||
# remote access at the moment (repo_path_split)...
|
||||
s#^([ACRMDT])\t# $1 #;
|
||||
push @{$c->{changed}}, $_;
|
||||
@@ -856,10 +850,7 @@ sub commit_diff {
|
||||
$_message ||= get_commit_message($tb,
|
||||
"$GIT_DIR/.svn-commit.tmp.$$")->{msg};
|
||||
}
|
||||
my $repo;
|
||||
($repo, $SVN_PATH) = repo_path_split($SVN_URL);
|
||||
$SVN_LOG ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($SVN_URL);
|
||||
if ($r eq 'HEAD') {
|
||||
$r = $SVN->get_latest_revnum;
|
||||
} elsif ($r !~ /^\d+$/) {
|
||||
@@ -868,8 +859,9 @@ sub commit_diff {
|
||||
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef, 0) : ();
|
||||
my $rev_committed;
|
||||
my $ed = SVN::Git::Editor->new({ r => $r,
|
||||
ra => $SVN_LOG, c => $tb,
|
||||
svn_path => $SVN_PATH
|
||||
ra => libsvn_dup_ra($SVN),
|
||||
c => $tb,
|
||||
svn_path => $SVN->{svn_path}
|
||||
},
|
||||
$SVN->get_commit_editor($_message,
|
||||
sub {
|
||||
@@ -877,13 +869,16 @@ sub commit_diff {
|
||||
print "Committed $_[0]\n";
|
||||
}, @lock)
|
||||
);
|
||||
my $mods = libsvn_checkout_tree($ta, $tb, $ed);
|
||||
if (@$mods == 0) {
|
||||
print "No changes\n$ta == $tb\n";
|
||||
$ed->abort_edit;
|
||||
} else {
|
||||
$ed->close_edit;
|
||||
}
|
||||
eval {
|
||||
my $mods = libsvn_checkout_tree($ta, $tb, $ed);
|
||||
if (@$mods == 0) {
|
||||
print "No changes\n$ta == $tb\n";
|
||||
$ed->abort_edit;
|
||||
} else {
|
||||
$ed->close_edit;
|
||||
}
|
||||
};
|
||||
fatal "$@\n" if $@;
|
||||
$_message = $_file = undef;
|
||||
return $rev_committed;
|
||||
}
|
||||
@@ -1147,8 +1142,7 @@ sub graft_file_copy_lib {
|
||||
my $tree_paths = $l_map->{$u};
|
||||
my $pfx = common_prefix([keys %$tree_paths]);
|
||||
my ($repo, $path) = repo_path_split($u.$pfx);
|
||||
$SVN_LOG ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($repo);
|
||||
$SVN = libsvn_connect($repo);
|
||||
|
||||
my ($base, $head) = libsvn_parse_revision();
|
||||
my $inc = 1000;
|
||||
@@ -1157,7 +1151,8 @@ sub graft_file_copy_lib {
|
||||
$SVN::Error::handler = \&libsvn_skip_unknown_revs;
|
||||
while (1) {
|
||||
my $pool = SVN::Pool->new;
|
||||
libsvn_get_log($SVN_LOG, "/$path", $min, $max, 0, 1, 1,
|
||||
libsvn_get_log(libsvn_dup_ra($SVN), [$path],
|
||||
$min, $max, 0, 1, 1,
|
||||
sub {
|
||||
libsvn_graft_file_copies($grafts, $tree_paths,
|
||||
$path, @_);
|
||||
@@ -1267,13 +1262,9 @@ sub repo_path_split {
|
||||
return ($u, $full_url);
|
||||
}
|
||||
}
|
||||
|
||||
if ($_use_lib) {
|
||||
my $tmp = libsvn_connect($full_url);
|
||||
my $url = $tmp->get_repos_root;
|
||||
$full_url =~ s#^\Q$url\E/*##;
|
||||
push @repo_path_split_cache, qr/^(\Q$url\E)/;
|
||||
return ($url, $full_url);
|
||||
return ($tmp->{repos_root}, $tmp->{svn_path});
|
||||
} else {
|
||||
my ($url, $path) = ($full_url =~ m!^([a-z\+]+://[^/]*)(.*)$!i);
|
||||
$path =~ s#^/+##;
|
||||
@@ -2815,34 +2806,41 @@ sub _read_password {
|
||||
|
||||
sub libsvn_connect {
|
||||
my ($url) = @_;
|
||||
if (!$AUTH_BATON || !$AUTH_CALLBACKS) {
|
||||
SVN::_Core::svn_config_ensure($_config_dir, undef);
|
||||
($AUTH_BATON, $AUTH_CALLBACKS) = SVN::Core::auth_open_helper([
|
||||
SVN::Client::get_simple_provider(),
|
||||
SVN::Client::get_ssl_server_trust_file_provider(),
|
||||
SVN::Client::get_simple_prompt_provider(
|
||||
\&_simple_prompt, 2),
|
||||
SVN::Client::get_ssl_client_cert_prompt_provider(
|
||||
\&_ssl_client_cert_prompt, 2),
|
||||
SVN::Client::get_ssl_client_cert_pw_prompt_provider(
|
||||
\&_ssl_client_cert_pw_prompt, 2),
|
||||
SVN::Client::get_username_provider(),
|
||||
SVN::Client::get_ssl_server_trust_prompt_provider(
|
||||
\&_ssl_server_trust_prompt),
|
||||
SVN::Client::get_username_prompt_provider(
|
||||
\&_username_prompt, 2),
|
||||
]);
|
||||
}
|
||||
SVN::Ra->new(url => $url, auth => $AUTH_BATON,
|
||||
auth_provider_callbacks => $AUTH_CALLBACKS);
|
||||
SVN::_Core::svn_config_ensure($_config_dir, undef);
|
||||
my ($baton, $callbacks) = SVN::Core::auth_open_helper([
|
||||
SVN::Client::get_simple_provider(),
|
||||
SVN::Client::get_ssl_server_trust_file_provider(),
|
||||
SVN::Client::get_simple_prompt_provider(
|
||||
\&_simple_prompt, 2),
|
||||
SVN::Client::get_ssl_client_cert_prompt_provider(
|
||||
\&_ssl_client_cert_prompt, 2),
|
||||
SVN::Client::get_ssl_client_cert_pw_prompt_provider(
|
||||
\&_ssl_client_cert_pw_prompt, 2),
|
||||
SVN::Client::get_username_provider(),
|
||||
SVN::Client::get_ssl_server_trust_prompt_provider(
|
||||
\&_ssl_server_trust_prompt),
|
||||
SVN::Client::get_username_prompt_provider(
|
||||
\&_username_prompt, 2),
|
||||
]);
|
||||
my $ra = SVN::Ra->new(url => $url, auth => $baton,
|
||||
pool => SVN::Pool->new,
|
||||
auth_provider_callbacks => $callbacks);
|
||||
$ra->{svn_path} = $url;
|
||||
$ra->{repos_root} = $ra->get_repos_root;
|
||||
$ra->{svn_path} =~ s#^\Q$ra->{repos_root}\E/*##;
|
||||
push @repo_path_split_cache, qr/^(\Q$ra->{repos_root}\E)/;
|
||||
return $ra;
|
||||
}
|
||||
|
||||
sub libsvn_dup_ra {
|
||||
my ($ra) = @_;
|
||||
SVN::Ra->new(map { $_ => $ra->{$_} }
|
||||
qw/url auth auth_provider_callbacks repos_root svn_path/);
|
||||
}
|
||||
|
||||
sub libsvn_get_file {
|
||||
my ($gui, $f, $rev, $chg) = @_;
|
||||
my $p = $f;
|
||||
if (length $SVN_PATH > 0) {
|
||||
return unless ($p =~ s#^\Q$SVN_PATH\E/##);
|
||||
}
|
||||
$f =~ s#^/##;
|
||||
print "\t$chg\t$f\n" unless $_q;
|
||||
|
||||
my ($hash, $pid, $in, $out);
|
||||
@@ -2879,7 +2877,7 @@ sub libsvn_get_file {
|
||||
waitpid $pid, 0;
|
||||
$hash =~ /^$sha1$/o or die "not a sha1: $hash\n";
|
||||
}
|
||||
print $gui $mode,' ',$hash,"\t",$p,"\0" or croak $!;
|
||||
print $gui $mode,' ',$hash,"\t",$f,"\0" or croak $!;
|
||||
}
|
||||
|
||||
sub libsvn_log_entry {
|
||||
@@ -2897,7 +2895,6 @@ sub libsvn_log_entry {
|
||||
|
||||
sub process_rm {
|
||||
my ($gui, $last_commit, $f) = @_;
|
||||
$f =~ s#^\Q$SVN_PATH\E/?## or return;
|
||||
# remove entire directories.
|
||||
if (safe_qx('git-ls-tree',$last_commit,'--',$f) =~ /^040000 tree/) {
|
||||
defined(my $pid = open my $ls, '-|') or croak $!;
|
||||
@@ -2919,9 +2916,11 @@ sub libsvn_fetch {
|
||||
my ($last_commit, $paths, $rev, $author, $date, $msg) = @_;
|
||||
open my $gui, '| git-update-index -z --index-info' or croak $!;
|
||||
my @amr;
|
||||
my $p = $SVN->{svn_path};
|
||||
foreach my $f (keys %$paths) {
|
||||
my $m = $paths->{$f}->action();
|
||||
$f =~ s#^/+##;
|
||||
$f =~ s#^/\Q$p\E/##;
|
||||
next if $f =~ m#^/#;
|
||||
if ($m =~ /^[DR]$/) {
|
||||
print "\t$m\t$f\n" unless $_q;
|
||||
process_rm($gui, $last_commit, $f);
|
||||
@@ -3011,9 +3010,9 @@ sub libsvn_parse_revision {
|
||||
|
||||
sub libsvn_traverse {
|
||||
my ($gui, $pfx, $path, $rev, $files) = @_;
|
||||
my $cwd = "$pfx/$path";
|
||||
my $cwd = length $pfx ? "$pfx/$path" : $path;
|
||||
my $pool = SVN::Pool->new;
|
||||
$cwd =~ s#^/+##g;
|
||||
$cwd =~ s#^\Q$SVN->{svn_path}\E##;
|
||||
my ($dirent, $r, $props) = $SVN->get_dir($cwd, $rev, $pool);
|
||||
foreach my $d (keys %$dirent) {
|
||||
my $t = $dirent->{$d}->kind;
|
||||
@@ -3037,7 +3036,7 @@ sub libsvn_traverse_ignore {
|
||||
my $pool = SVN::Pool->new;
|
||||
my ($dirent, undef, $props) = $SVN->get_dir($path, $r, $pool);
|
||||
my $p = $path;
|
||||
$p =~ s#^\Q$SVN_PATH\E/?##;
|
||||
$p =~ s#^\Q$SVN->{svn_path}\E/##;
|
||||
print $fh length $p ? "\n# $p\n" : "\n# /\n";
|
||||
if (my $s = $props->{'svn:ignore'}) {
|
||||
$s =~ s/[\r\n]+/\n/g;
|
||||
@@ -3064,7 +3063,7 @@ sub revisions_eq {
|
||||
if ($_use_lib) {
|
||||
# should be OK to use Pool here (r1 - r0) should be small
|
||||
my $pool = SVN::Pool->new;
|
||||
libsvn_get_log($SVN, "/$path", $r0, $r1,
|
||||
libsvn_get_log($SVN, [$path], $r0, $r1,
|
||||
0, 1, 1, sub {$nr++}, $pool);
|
||||
$pool->clear;
|
||||
} else {
|
||||
@@ -3079,7 +3078,7 @@ sub revisions_eq {
|
||||
|
||||
sub libsvn_find_parent_branch {
|
||||
my ($paths, $rev, $author, $date, $msg) = @_;
|
||||
my $svn_path = '/'.$SVN_PATH;
|
||||
my $svn_path = '/'.$SVN->{svn_path};
|
||||
|
||||
# look for a parent from another branch:
|
||||
my $i = $paths->{$svn_path} or return;
|
||||
@@ -3090,7 +3089,7 @@ sub libsvn_find_parent_branch {
|
||||
$branch_from =~ s#^/##;
|
||||
my $l_map = {};
|
||||
read_url_paths_all($l_map, '', "$GIT_DIR/svn");
|
||||
my $url = $SVN->{url};
|
||||
my $url = $SVN->{repos_root};
|
||||
defined $l_map->{$url} or return;
|
||||
my $id = $l_map->{$url}->{$branch_from};
|
||||
if (!defined $id && $_follow_parent) {
|
||||
@@ -3112,7 +3111,7 @@ sub libsvn_find_parent_branch {
|
||||
$GIT_SVN = $ENV{GIT_SVN_ID} = $id;
|
||||
init_vars();
|
||||
$SVN_URL = "$url/$branch_from";
|
||||
$SVN_LOG = $SVN = undef;
|
||||
$SVN = undef;
|
||||
setup_git_svn();
|
||||
# we can't assume SVN_URL exists at r+1:
|
||||
$_revision = "0:$r";
|
||||
@@ -3149,7 +3148,7 @@ sub libsvn_new_tree {
|
||||
}
|
||||
my ($paths, $rev, $author, $date, $msg) = @_;
|
||||
open my $gui, '| git-update-index -z --index-info' or croak $!;
|
||||
libsvn_traverse($gui, '', $SVN_PATH, $rev);
|
||||
libsvn_traverse($gui, '', $SVN->{svn_path}, $rev);
|
||||
close $gui or croak $?;
|
||||
return libsvn_log_entry($rev, $author, $date, $msg);
|
||||
}
|
||||
@@ -3234,11 +3233,10 @@ sub libsvn_commit_cb {
|
||||
|
||||
sub libsvn_ls_fullurl {
|
||||
my $fullurl = shift;
|
||||
my ($repo, $path) = repo_path_split($fullurl);
|
||||
$SVN ||= libsvn_connect($repo);
|
||||
$SVN ||= libsvn_connect($fullurl);
|
||||
my @ret;
|
||||
my $pool = SVN::Pool->new;
|
||||
my ($dirent, undef, undef) = $SVN->get_dir($path,
|
||||
my ($dirent, undef, undef) = $SVN->get_dir($SVN->{svn_path},
|
||||
$SVN->get_latest_revnum, $pool);
|
||||
foreach my $d (keys %$dirent) {
|
||||
if ($dirent->{$d}->kind == $SVN::Node::dir) {
|
||||
@@ -3260,8 +3258,9 @@ sub libsvn_skip_unknown_revs {
|
||||
# Wonderfully consistent library, eh?
|
||||
# 160013 - svn:// and file://
|
||||
# 175002 - http(s)://
|
||||
# 175007 - http(s):// (this repo required authorization, too...)
|
||||
# More codes may be discovered later...
|
||||
if ($errno == 175002 || $errno == 160013) {
|
||||
if ($errno == 175007 || $errno == 175002 || $errno == 160013) {
|
||||
return;
|
||||
}
|
||||
croak "Error from SVN, ($errno): ", $err->expanded_message,"\n";
|
||||
@@ -3349,8 +3348,7 @@ sub split_path {
|
||||
}
|
||||
|
||||
sub repo_path {
|
||||
(defined $_[1] && length $_[1]) ? "$_[0]->{svn_path}/$_[1]"
|
||||
: $_[0]->{svn_path}
|
||||
(defined $_[1] && length $_[1]) ? $_[1] : ''
|
||||
}
|
||||
|
||||
sub url_path {
|
||||
@@ -3382,10 +3380,9 @@ sub rmdirs {
|
||||
exec qw/git-ls-tree --name-only -r -z/, $self->{c} or croak $!;
|
||||
}
|
||||
local $/ = "\0";
|
||||
my @svn_path = split m#/#, $self->{svn_path};
|
||||
while (<$fh>) {
|
||||
chomp;
|
||||
my @dn = (@svn_path, (split m#/#, $_));
|
||||
my @dn = split m#/#, $_;
|
||||
while (pop @dn) {
|
||||
delete $rm->{join '/', @dn};
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user