git-svn: add ability to specify --commit-url for dcommit
This allows one to use public svn:// URLs for fetch and svn+ssh:// URLs for committing (without using the complicated rewriteRoot option, reimporting or git-filter-branch). Using this can also help avoid unnecessary server authentication/encryption overhead on busy SVN servers. Along with the new --revision option, this can also be allowed to override the branch detection in dcommit, too. This is potentially dangerous and not recommended! (And also purposely undocumented, but the loaded gun is there in case somebody wants to make it safe). Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Eric Wong committed
Aug 7, 2008 at 02:06 UTC
ba24e7457aa1f958370bbb67dfb97e3ec806fd4a
2 files changed
+15
-3
Documentation/git-svn.txt
+9
@@ -138,6 +138,15 @@ and have no uncommitted changes.
138
+
139
--no-rebase;;
140
After committing, do not rebase or reset.
141
+--commit-url <URL>;;
142
+ Commit to this SVN URL (the full path). This is intended to
143
+ allow existing git-svn repositories created with one transport
144
+ method (e.g. `svn://` or `http://` for anonymous read) to be
145
+ reused if a user is later given access to an alternate transport
146
+ method (e.g. `svn+ssh://` or `https://`) for commit.
147
+
148
+ Using this option for any other purpose (don't ask)
149
+ is very strongly discouraged.
150
--
151
152
'log'::
git-svn.perl
+6
-3
@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,
66
$_version, $_fetch_all, $_no_rebase,
67
$_merge, $_strategy, $_dry_run, $_local,
68
$_prefix, $_no_checkout, $_url, $_verbose,
69
- $_git_format);
69
+ $_git_format, $_commit_url);
70
$Git::SVN::_follow_parent = 1;
71
my %remote_opts = ( 'username=s' => \$Git::SVN::Prompt::_username,
72
'config-dir=s' => \$Git::SVN::Ra::config_dir,
@@ -127,6 +127,8 @@ my %cmd = (
127
'verbose|v' => \$_verbose,
128
'dry-run|n' => \$_dry_run,
129
'fetch-all|all' => \$_fetch_all,
130
+ 'commit-url=s' => \$_commit_url,
131
+ 'revision|r=i' => \$_revision,
132
'no-rebase' => \$_no_rebase,
133
%cmt_opts, %fc_opts } ],
134
'set-tree' => [ \&cmd_set_tree,
@@ -416,6 +418,8 @@ sub cmd_dcommit {
418
$head ||= 'HEAD';
419
my @refs;
420
my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
421
+ $url = $_commit_url if defined $_commit_url;
422
+ my $last_rev = $_revision if defined $_revision;
423
if ($url) {
424
print "Committing to $url ...\n";
425
}
@@ -423,7 +427,6 @@ sub cmd_dcommit {
427
die "Unable to determine upstream SVN information from ",
428
"$head history.\nPerhaps the repository is empty.";
429
}
426
- my $last_rev;
430
my ($linear_refs, $parents) = linearize_history($gs, \@refs);
431
if ($_no_rebase && scalar(@$linear_refs) > 1) {
432
warn "Attempting to commit more than one change while ",
@@ -446,7 +449,7 @@ sub cmd_dcommit {
449
my $cmt_rev;
450
my %ed_opts = ( r => $last_rev,
451
log => get_commit_entry($d)->{log},
449
- ra => Git::SVN::Ra->new($gs->full_url),
452
+ ra => Git::SVN::Ra->new($url),
453
config => SVN::Core::config_get_config(
454
$Git::SVN::Ra::config_dir
455
),