{"thread":{"id":"14874","subject":"[PATCH] git-svn: add ability to specify --commit-url for dcommit","startedAt":"2008-08-07T09:06:16Z","lastAt":"2008-08-07T09:06:16Z","messageCount":1,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"86403","messageId":"20080807090616.GA9335@untitled","threadId":"14874","inReplyTo":null,"subject":"[PATCH] git-svn: add ability to specify --commit-url for dcommit","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2008-08-07T09:06:16Z","receivedAt":"2008-08-07T09:06:16Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"This allows one to use public svn:// URLs for fetch and\nsvn+ssh:// URLs for committing (without using the complicated\nrewriteRoot option, reimporting or git-filter-branch).\n\nUsing this can also help avoid unnecessary server\nauthentication/encryption overhead on busy SVN servers.\n\nAlong with the new --revision option, this can also be allowed\nto override the branch detection in dcommit, too.  This is\npotentially dangerous and not recommended!  (And also purposely\nundocumented, but the loaded gun is there in case somebody\nwants to make it safe).\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n Documentation/git-svn.txt |    9 +++++++++\n git-svn.perl              |    9 ++++++---\n 2 files changed, 15 insertions(+), 3 deletions(-)\n\ndiff --git a/Documentation/git-svn.txt b/Documentation/git-svn.txt\nindex 773ae96..1e644ca 100644\n--- a/Documentation/git-svn.txt\n+++ b/Documentation/git-svn.txt\n@@ -138,6 +138,15 @@ and have no uncommitted changes.\n +\n --no-rebase;;\n \tAfter committing, do not rebase or reset.\n+--commit-url <URL>;;\n+\tCommit to this SVN URL (the full path).  This is intended to\n+\tallow existing git-svn repositories created with one transport\n+\tmethod (e.g. `svn://` or `http://` for anonymous read) to be\n+\treused if a user is later given access to an alternate transport\n+\tmethod (e.g. `svn+ssh://` or `https://`) for commit.\n+\n+\tUsing this option for any other purpose (don't ask)\n+\tis very strongly discouraged.\n --\n \n 'log'::\ndiff --git a/git-svn.perl b/git-svn.perl\nindex df0ed90..06a82c8 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -66,7 +66,7 @@ my ($_stdin, $_help, $_edit,\n \t$_version, $_fetch_all, $_no_rebase,\n \t$_merge, $_strategy, $_dry_run, $_local,\n \t$_prefix, $_no_checkout, $_url, $_verbose,\n-\t$_git_format);\n+\t$_git_format, $_commit_url);\n $Git::SVN::_follow_parent = 1;\n my %remote_opts = ( 'username=s' => \\$Git::SVN::Prompt::_username,\n                     'config-dir=s' => \\$Git::SVN::Ra::config_dir,\n@@ -127,6 +127,8 @@ my %cmd = (\n \t\t\t  'verbose|v' => \\$_verbose,\n \t\t\t  'dry-run|n' => \\$_dry_run,\n \t\t\t  'fetch-all|all' => \\$_fetch_all,\n+\t\t\t  'commit-url=s' => \\$_commit_url,\n+\t\t\t  'revision|r=i' => \\$_revision,\n \t\t\t  'no-rebase' => \\$_no_rebase,\n \t\t\t%cmt_opts, %fc_opts } ],\n \t'set-tree' => [ \\&cmd_set_tree,\n@@ -416,6 +418,8 @@ sub cmd_dcommit {\n \t$head ||= 'HEAD';\n \tmy @refs;\n \tmy ($url, $rev, $uuid, $gs) = working_head_info($head, \\@refs);\n+\t$url = $_commit_url if defined $_commit_url;\n+\tmy $last_rev = $_revision if defined $_revision;\n \tif ($url) {\n \t\tprint \"Committing to $url ...\\n\";\n \t}\n@@ -423,7 +427,6 @@ sub cmd_dcommit {\n \t\tdie \"Unable to determine upstream SVN information from \",\n \t\t    \"$head history.\\nPerhaps the repository is empty.\";\n \t}\n-\tmy $last_rev;\n \tmy ($linear_refs, $parents) = linearize_history($gs, \\@refs);\n \tif ($_no_rebase && scalar(@$linear_refs) > 1) {\n \t\twarn \"Attempting to commit more than one change while \",\n@@ -446,7 +449,7 @@ sub cmd_dcommit {\n \t\t\tmy $cmt_rev;\n \t\t\tmy %ed_opts = ( r => $last_rev,\n \t\t\t                log => get_commit_entry($d)->{log},\n-\t\t\t                ra => Git::SVN::Ra->new($gs->full_url),\n+\t\t\t                ra => Git::SVN::Ra->new($url),\n \t\t\t                config => SVN::Core::config_get_config(\n \t\t\t                        $Git::SVN::Ra::config_dir\n \t\t\t                ),\n-- \nEric Wong\n"}]}