{"thread":{"id":"3537","subject":"[PATCH 6/9] contrib/git-svn: create a more recent master if one does not exist","startedAt":"2006-03-03T09:20:08Z","lastAt":"2006-03-03T09:20:09Z","messageCount":2,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"17111","messageId":"11413776081545-git-send-email-normalperson@yhbt.net","threadId":"3537","inReplyTo":"11413776082506-git-send-email-normalperson@yhbt.net","subject":"[PATCH 5/9] contrib/git-svn: cleanup option parsing","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-03-03T09:20:08Z","receivedAt":"2006-03-03T09:20:08Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Signed-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |   65 +++++++++++++++++++++++-------------------\n 1 files changed, 35 insertions(+), 30 deletions(-)\n\na080e189728de9a7aa834b61205df9d8de1025ba\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex c2b4ee9..5d547e8 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -24,6 +24,7 @@ $ENV{LC_ALL} = 'C';\n # If SVN:: library support is added, please make the dependencies\n # optional and preserve the capability to use the command-line client.\n # use eval { require SVN::... } to make it lazy load\n+# We don't use any modules not in the standard Perl distribution:\n use Carp qw/croak/;\n use IO::File qw//;\n use File::Basename qw/dirname basename/;\n@@ -37,26 +38,25 @@ my ($_revision,$_stdin,$_no_ignore_ext,$\n \t$_find_copies_harder, $_l, $_version, $_upgrade, $_authors);\n my (@_branch_from, %tree_map, %users);\n \n-GetOptions(\t'revision|r=s' => \\$_revision,\n-\t\t'no-ignore-externals' => \\$_no_ignore_ext,\n-\t\t'stdin|' => \\$_stdin,\n-\t\t'edit|e' => \\$_edit,\n-\t\t'rmdir' => \\$_rmdir,\n-\t\t'upgrade' => \\$_upgrade,\n-\t\t'help|H|h' => \\$_help,\n+my %fc_opts = ( 'no-ignore-externals' => \\$_no_ignore_ext,\n \t\t'branch|b=s' => \\@_branch_from,\n-\t\t'find-copies-harder' => \\$_find_copies_harder,\n-\t\t'authors-file|authors|A=s' => \\$_authors,\n-\t\t'l=i' => \\$_l,\n-\t\t'version|V' => \\$_version,\n-\t\t'no-stop-on-copy' => \\$_no_stop_copy );\n+\t\t'authors-file|A=s' => \\$_authors );\n my %cmd = (\n-\tfetch => [ \\&fetch, \"Download new revisions from SVN\" ],\n-\tinit => [ \\&init, \"Initialize and fetch (import)\"],\n-\tcommit => [ \\&commit, \"Commit git revisions to SVN\" ],\n-\t'show-ignore' => [ \\&show_ignore, \"Show svn:ignore listings\" ],\n-\trebuild => [ \\&rebuild, \"Rebuild git-svn metadata (after git clone)\" ],\n-\thelp => [ \\&usage, \"Show help\" ],\n+\tfetch => [ \\&fetch, \"Download new revisions from SVN\",\n+\t\t\t{ 'revision|r=s' => \\$_revision, %fc_opts } ],\n+\tinit => [ \\&init, \"Initialize and fetch (import)\", { } ],\n+\tcommit => [ \\&commit, \"Commit git revisions to SVN\",\n+\t\t\t{\t'stdin|' => \\$_stdin,\n+\t\t\t\t'edit|e' => \\$_edit,\n+\t\t\t\t'rmdir' => \\$_rmdir,\n+\t\t\t\t'find-copies-harder' => \\$_find_copies_harder,\n+\t\t\t\t'l=i' => \\$_l,\n+\t\t\t\t%fc_opts,\n+\t\t\t} ],\n+\t'show-ignore' => [ \\&show_ignore, \"Show svn:ignore listings\", { } ],\n+\trebuild => [ \\&rebuild, \"Rebuild git-svn metadata (after git clone)\",\n+\t\t\t{ 'no-ignore-externals' => \\$_no_ignore_ext,\n+\t\t\t  'upgrade' => \\$_upgrade } ],\n );\n my $cmd;\n for (my $i = 0; $i < @ARGV; $i++) {\n@@ -75,21 +75,14 @@ foreach (keys %cmd) {\n \t}\n }\n \n-# '<svn username> = real-name <email address>' mapping based on git-svnimport:\n-if ($_authors) {\n-\topen my $authors, '<', $_authors or die \"Can't open $_authors $!\\n\";\n-\twhile (<$authors>) {\n-\t\tchomp;\n-\t\tnext unless /^(\\S+?)\\s*=\\s*(.+?)\\s*<(.+)>\\s*$/;\n-\t\tmy ($user, $name, $email) = ($1, $2, $3);\n-\t\t$users{$user} = [$name, $email];\n-\t}\n-\tclose $authors or croak $!;\n-}\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 usage(0) if $_help;\n version() if $_version;\n-usage(1) unless (defined $cmd);\n+usage(1) unless defined $cmd;\n+load_authors() if $_authors;\n svn_check_ignore_externals();\n $cmd{$cmd}->[0]->(@ARGV);\n exit 0;\n@@ -1047,6 +1040,18 @@ sub map_tree_joins {\n \t}\n }\n \n+# '<svn username> = real-name <email address>' mapping based on git-svnimport:\n+sub load_authors {\n+\topen my $authors, '<', $_authors or die \"Can't open $_authors $!\\n\";\n+\twhile (<$authors>) {\n+\t\tchomp;\n+\t\tnext unless /^(\\S+?)\\s*=\\s*(.+?)\\s*<(.+)>\\s*$/;\n+\t\tmy ($user, $name, $email) = ($1, $2, $3);\n+\t\t$users{$user} = [$name, $email];\n+\t}\n+\tclose $authors or croak $!;\n+}\n+\n __END__\n \n Data structures:\n-- \n1.2.3.g4676\n"},{"id":"17110","messageId":"11413776092820-git-send-email-normalperson@yhbt.net","threadId":"3537","inReplyTo":"11413776081545-git-send-email-normalperson@yhbt.net","subject":"[PATCH 6/9] contrib/git-svn: create a more recent master if one does not exist","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":"In a new repository, the initial fetch creates a master branch\nif one does not exist so HEAD has something to point to.\n\nIt now creates a master at the end of the initial fetch run,\npointing to the latest revision.  Previously it pointed to the\nfirst revision imported, which is generally less useful.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n\n---\n\n contrib/git-svn/git-svn.perl |    6 +++---\n 1 files changed, 3 insertions(+), 3 deletions(-)\n\n7d3cf853ffbe0d1ce8a15fa5ac3dad793ddb5021\ndiff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl\nindex 5d547e8..69b6be3 100755\n--- a/contrib/git-svn/git-svn.perl\n+++ b/contrib/git-svn/git-svn.perl\n@@ -224,9 +224,6 @@ sub fetch {\n \t\tsys(@svn_co, $SVN_URL, $SVN_WC);\n \t\tchdir $SVN_WC or croak $!;\n \t\t$last_commit = git_commit($base, @parents);\n-\t\tunless (-f \"$GIT_DIR/refs/heads/master\") {\n-\t\t\tsys(qw(git-update-ref refs/heads/master),$last_commit);\n-\t\t}\n \t\tassert_svn_wc_clean($base->{revision}, $last_commit);\n \t} else {\n \t\tchdir $SVN_WC or croak $!;\n@@ -242,6 +239,9 @@ sub fetch {\n \t\t$last_commit = git_commit($log_msg, $last_commit, @parents);\n \t}\n \tassert_svn_wc_clean($last_rev, $last_commit);\n+\tunless (-e \"$GIT_DIR/refs/heads/master\") {\n+\t\tsys(qw(git-update-ref refs/heads/master),$last_commit);\n+\t}\n \treturn pop @$svn_log;\n }\n \n-- \n1.2.3.g4676\n"}]}