{"thread":{"id":"3536","subject":"[PATCH 8/9] contrib/git-svn: add --id/-i=$GIT_SVN_ID command-line switch","startedAt":"2006-03-03T09:20:09Z","lastAt":"2006-03-03T09:20:09Z","messageCount":3,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"17106","messageId":"11413776092524-git-send-email-normalperson@yhbt.net","threadId":"3536","inReplyTo":"11413776092493-git-send-email-normalperson@yhbt.net","subject":"[PATCH 8/9] contrib/git-svn: add --id/-i=$GIT_SVN_ID command-line switch","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-03T09:20:09Z","receivedAt":"2006-03-03T09:20:09Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"I ended up using GIT_SVN_ID far more than I ever thought I\nwould.  Typing less is good.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |   19 +++++++++++--------\n 1 files changed, 11 insertions(+), 8 deletions(-)\n\n1d3dc63f7ed276863c71f9a212471658f359ef75\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex 041791b..db199a3 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -10,13 +10,6 @@ use vars qw/\t$AUTHOR $VERSION\n $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';\n $VERSION = '0.10.0';\n $GIT_DIR = $ENV{GIT_DIR} || \"$ENV{PWD}/.git\";\n-$GIT_SVN = $ENV{GIT_SVN_ID} || 'git-svn';\n-$GIT_SVN_INDEX = \"$GIT_DIR/$GIT_SVN/index\";\n-$ENV{GIT_DIR} ||= $GIT_DIR;\n-$SVN_URL = undef;\n-$REV_DIR = \"$GIT_DIR/$GIT_SVN/revs\";\n-$SVN_WC = \"$GIT_DIR/$GIT_SVN/tree\";\n-\n # make sure the svn binary gives consistent output between locales and TZs:\n $ENV{TZ} = 'UTC';\n $ENV{LC_ALL} = 'C';\n@@ -78,7 +71,17 @@ foreach (keys %cmd) {\n my %opts;\n %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);\n \n-GetOptions(%opts, 'help|H|h' => \\$_help, 'version|V' => \\$_version ) or exit 1;\n+GetOptions(%opts, 'help|H|h' => \\$_help,\n+\t\t'version|V' => \\$_version,\n+\t\t'id|i=s' => \\$GIT_SVN) or exit 1;\n+\n+$GIT_SVN ||= $ENV{GIT_SVN_ID} || 'git-svn';\n+$GIT_SVN_INDEX = \"$GIT_DIR/$GIT_SVN/index\";\n+$ENV{GIT_DIR} ||= $GIT_DIR;\n+$SVN_URL = undef;\n+$REV_DIR = \"$GIT_DIR/$GIT_SVN/revs\";\n+$SVN_WC = \"$GIT_DIR/$GIT_SVN/tree\";\n+\n usage(0) if $_help;\n version() if $_version;\n usage(1) unless defined $cmd;\n-- \n1.2.3.g4676\n"},{"id":"17108","messageId":"11413776092558-git-send-email-normalperson@yhbt.net","threadId":"3536","inReplyTo":"11413776092524-git-send-email-normalperson@yhbt.net","subject":"[PATCH 9/9] contrib/git-svn: better documenting of CLI switches","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-03T09:20:09Z","receivedAt":"2006-03-03T09:20:09Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Also, fix a asciidoc formatting error\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |   29 +++++++++++++++--------------\n contrib/git-svn/git-svn.txt  |   17 ++++++++++++++++-\n 2 files changed, 31 insertions(+), 15 deletions(-)\n\n65d8e4920084c96f82b4604ded1bd4e4fa91d3d8\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex db199a3..808b933 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -60,16 +60,7 @@ for (my $i = 0; $i < @ARGV; $i++) {\n \t}\n };\n \n-# we may be called as git-svn-(command), or git-svn(command).\n-foreach (keys %cmd) {\n-\tif (/git\\-svn\\-?($_)(?:\\.\\w+)?$/) {\n-\t\t$cmd = $1;\n-\t\tlast;\n-\t}\n-}\n-\n-my %opts;\n-%opts = %{$cmd{$cmd}->[2]} if (defined $cmd);\n+my %opts = %{$cmd{$cmd}->[2]} if (defined $cmd);\n \n GetOptions(%opts, 'help|H|h' => \\$_help,\n \t\t'version|V' => \\$_version,\n@@ -97,15 +88,25 @@ sub usage {\n \tprint $fd <<\"\";\n git-svn - bidirectional operations between a single Subversion tree and git\n Usage: $0 <command> [options] [arguments]\\n\n-Available commands:\n+\n+\tprint $fd \"Available commands:\\n\" unless $cmd;\n \n \tforeach (sort keys %cmd) {\n+\t\tnext if $cmd && $cmd ne $_;\n \t\tprint $fd '  ',pack('A13',$_),$cmd{$_}->[1],\"\\n\";\n+\t\tforeach (keys %{$cmd{$_}->[2]}) {\n+\t\t\t# prints out arguments as they should be passed:\n+\t\t\tmy $x = s#=s$## ? '<arg>' : s#=i$## ? '<num>' : '';\n+\t\t\tprint $fd ' ' x 17, join(', ', map { length $_ > 1 ?\n+\t\t\t\t\t\t\t\"--$_\" : \"-$_\" }\n+\t\t\t\t\t\tsplit /\\|/,$_),\" $x\\n\";\n+\t\t}\n \t}\n \tprint $fd <<\"\";\n-\\nGIT_SVN_ID may be set in the environment to an arbitrary identifier if\n-you're tracking multiple SVN branches/repositories in one git repository\n-and want to keep them separate.  See git-svn(1) for more information.\n+\\nGIT_SVN_ID may be set in the environment or via the --id/-i switch to an\n+arbitrary identifier if you're tracking multiple SVN branches/repositories in\n+one git repository and want to keep them separate.  See git-svn(1) for more\n+information.\n \n \texit $exit;\n }\ndiff --git a/contrib/git-svn/git-svn.txt b/contrib/git-svn/git-svn.txt\nindex 7306048..8e9a971 100644\n--- a/contrib/git-svn/git-svn.txt\n+++ b/contrib/git-svn/git-svn.txt\n@@ -116,6 +116,8 @@ OPTIONS\n \tThey are both passed directly to git-diff-tree see\n \tgit-diff-tree(1) for more information.\n \n+ADVANCED OPTIONS\n+----------------\n -b<refname>::\n --branch <refname>::\n \tUsed with 'fetch' or 'commit'.\n@@ -131,8 +133,21 @@ OPTIONS\n \tThis option may be specified multiple times, once for each\n \tbranch.\n \n+-i<GIT_SVN_ID>::\n+--id <GIT_SVN_ID>::\n+\tThis sets GIT_SVN_ID (instead of using the environment).  See\n+\tthe section on \"Tracking Multiple Repositories or Branches\" for\n+\tmore information on using GIT_SVN_ID.\n+\n COMPATIBILITY OPTIONS\n ---------------------\n+--upgrade::\n+\tOnly used with the 'rebuild' command.\n+\n+\tRun this if you used an old version of git-svn that used\n+\t'git-svn-HEAD' instead of 'remotes/git-svn' as the branch\n+\tfor tracking the remote.\n+\n --no-ignore-externals::\n \tOnly used with the 'fetch' and 'rebuild' command.\n \n@@ -177,7 +192,7 @@ Tracking and contributing to an Subversi\n \tgit-svn commit remotes/git-svn..my-branch\n # Something is committed to SVN, pull the latest into your branch::\n \tgit-svn fetch && git pull . remotes/git-svn\n-# Append svn:ignore settings to the default git exclude file:\n+# Append svn:ignore settings to the default git exclude file::\n \tgit-svn show-ignore >> .git/info/exclude\n \n DESIGN PHILOSOPHY\n-- \n1.2.3.g4676\n"},{"id":"17112","messageId":"11413776092493-git-send-email-normalperson@yhbt.net","threadId":"3536","inReplyTo":"11413776092820-git-send-email-normalperson@yhbt.net","subject":"[PATCH 7/9] contrib/git-svn: avoid re-reading the repository uuid, it never changes","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-03T09:20:09Z","receivedAt":"2006-03-03T09:20:09Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"If it does change, we're screwed anyways as SVN will refuse to\ncommit or update.  We also never access more than one SVN\nrepository per-invocation, so we can store it as a global, too.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |   27 ++++++++++++---------------\n 1 files changed, 12 insertions(+), 15 deletions(-)\n\n3dc689059bd5cffa12bb2b8cdc0f1965d5f6cee2\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex 69b6be3..041791b 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -4,7 +4,7 @@\n use warnings;\n use strict;\n use vars qw/\t$AUTHOR $VERSION\n-\t\t$SVN_URL $SVN_INFO $SVN_WC\n+\t\t$SVN_URL $SVN_INFO $SVN_WC $SVN_UUID\n \t\t$GIT_SVN_INDEX $GIT_SVN\n \t\t$GIT_DIR $REV_DIR/;\n $AUTHOR = 'Eric Wong <normalperson@yhbt.net>';\n@@ -114,7 +114,6 @@ sub version {\n \n sub rebuild {\n \t$SVN_URL = shift or undef;\n-\tmy $repo_uuid;\n \tmy $newest_rev = 0;\n \tif ($_upgrade) {\n \t\tsys('git-update-ref',\"refs/remotes/$GIT_SVN\",\"$GIT_SVN-HEAD\");\n@@ -150,7 +149,7 @@ sub rebuild {\n \n \t\t# if we merged or otherwise started elsewhere, this is\n \t\t# how we break out of it\n-\t\tnext if (defined $repo_uuid && ($uuid ne $repo_uuid));\n+\t\tnext if (defined $SVN_UUID && ($uuid ne $SVN_UUID));\n \t\tnext if (defined $SVN_URL && ($url ne $SVN_URL));\n \n \t\tprint \"r$rev = $c\\n\";\n@@ -159,7 +158,7 @@ sub rebuild {\n \t\t\t\tcroak \"SVN repository location required: $url\\n\";\n \t\t\t}\n \t\t\t$SVN_URL ||= $url;\n-\t\t\t$repo_uuid ||= setup_git_svn();\n+\t\t\t$SVN_UUID ||= setup_git_svn();\n \t\t\t$latest = $rev;\n \t\t}\n \t\tassert_revision_eq_or_unknown($rev, $c);\n@@ -252,7 +251,7 @@ sub commit {\n \t\tprint \"Reading from stdin...\\n\";\n \t\t@commits = ();\n \t\twhile (<STDIN>) {\n-\t\t\tif (/\\b($sha1_short)\\b/) {\n+\t\t\tif (/\\b($sha1_short)\\b/o) {\n \t\t\t\tunshift @commits, $1;\n \t\t\t}\n \t\t}\n@@ -320,14 +319,14 @@ sub setup_git_svn {\n \tmkpath([\"$GIT_DIR/$GIT_SVN/info\"]);\n \tmkpath([$REV_DIR]);\n \ts_to_file($SVN_URL,\"$GIT_DIR/$GIT_SVN/info/url\");\n-\tmy $uuid = svn_info($SVN_URL)->{'Repository UUID'} or\n+\t$SVN_UUID = svn_info($SVN_URL)->{'Repository UUID'} or\n \t\t\t\t\tcroak \"Repository UUID unreadable\\n\";\n-\ts_to_file($uuid,\"$GIT_DIR/$GIT_SVN/info/uuid\");\n+\ts_to_file($SVN_UUID,\"$GIT_DIR/$GIT_SVN/info/uuid\");\n \n \topen my $fd, '>>', \"$GIT_DIR/$GIT_SVN/info/exclude\" or croak $!;\n \tprint $fd '.svn',\"\\n\";\n \tclose $fd or croak $!;\n-\treturn $uuid;\n+\treturn $SVN_UUID;\n }\n \n sub assert_svn_wc_clean {\n@@ -850,9 +849,7 @@ sub git_commit {\n \tmy ($log_msg, @parents) = @_;\n \tassert_revision_unknown($log_msg->{revision});\n \tmy $out_fh = IO::File->new_tmpfile or croak $!;\n-\tmy $info = svn_info('.');\n-\tmy $uuid = $info->{'Repository UUID'};\n-\tdefined $uuid or croak \"Unable to get Repository UUID\\n\";\n+\t$SVN_UUID ||= svn_info('.')->{'Repository UUID'};\n \n \tmap_tree_joins() if (@_branch_from && !%tree_map);\n \n@@ -891,11 +888,11 @@ sub git_commit {\n \t\tmy $msg_fh = IO::File->new_tmpfile or croak $!;\n \t\tprint $msg_fh $log_msg->{msg}, \"\\ngit-svn-id: \",\n \t\t\t\t\t\"$SVN_URL\\@$log_msg->{revision}\",\n-\t\t\t\t\t\" $uuid\\n\" or croak $!;\n+\t\t\t\t\t\" $SVN_UUID\\n\" or croak $!;\n \t\t$msg_fh->flush == 0 or croak $!;\n \t\tseek $msg_fh, 0, 0 or croak $!;\n \n-\t\tset_commit_env($log_msg, $uuid);\n+\t\tset_commit_env($log_msg);\n \n \t\tmy @exec = ('git-commit-tree',$tree);\n \t\tpush @exec, '-p', $_  foreach @exec_parents;\n@@ -923,10 +920,10 @@ sub git_commit {\n }\n \n sub set_commit_env {\n-\tmy ($log_msg, $uuid) = @_;\n+\tmy ($log_msg) = @_;\n \tmy $author = $log_msg->{author};\n \tmy ($name,$email) = defined $users{$author} ?  @{$users{$author}}\n-\t\t\t\t: ($author,\"$author\\@$uuid\");\n+\t\t\t\t: ($author,\"$author\\@$SVN_UUID\");\n \t$ENV{GIT_AUTHOR_NAME} = $ENV{GIT_COMMITTER_NAME} = $name;\n \t$ENV{GIT_AUTHOR_EMAIL} = $ENV{GIT_COMMITTER_EMAIL} = $email;\n \t$ENV{GIT_AUTHOR_DATE} = $ENV{GIT_COMMITTER_DATE} = $log_msg->{date};\n-- \n1.2.3.g4676\n"}]}