{"thread":{"id":"5888","subject":"[PATCH] git-svn: multi-init saves and reuses --tags and --branches arguments","startedAt":"2006-10-11T18:53:21Z","lastAt":"2006-10-11T18:53:22Z","messageCount":2,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"28622","messageId":"11605928022833-git-send-email-normalperson@yhbt.net","threadId":"5888","inReplyTo":null,"subject":"[PATCH] git-svn: multi-init saves and reuses --tags and --branches arguments","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-10-11T18:53:21Z","receivedAt":"2006-10-11T18:53:21Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"This should make it much easier to track newly added tags and\nbranches.  Re-running multi-init without command-line arguments\nshould now detect new-tags and branches.\n\n--trunk shouldn't change often, but running multi-init on it\nis now idempotent.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   18 ++++++++++++++----\n 1 files changed, 14 insertions(+), 4 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex f5c7d46..5a6c87e 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -682,12 +682,17 @@ sub multi_init {\n \t\t}\n \t\t$_trunk = $url . $_trunk;\n \t}\n+\tmy $ch_id;\n \tif ($GIT_SVN eq 'git-svn') {\n-\t\tprint \"GIT_SVN_ID set to 'trunk' for $_trunk\\n\";\n+\t\t$ch_id = 1;\n \t\t$GIT_SVN = $ENV{GIT_SVN_ID} = 'trunk';\n \t}\n \tinit_vars();\n-\tinit($_trunk);\n+\tunless (-d $GIT_SVN_DIR) {\n+\t\tprint \"GIT_SVN_ID set to 'trunk' for $_trunk\\n\" if $ch_id;\n+\t\tinit($_trunk);\n+\t\tsys('git-repo-config', 'svn.trunk', $_trunk);\n+\t}\n \tcomplete_url_ls_init($url, $_branches, '--branches/-b', '');\n \tcomplete_url_ls_init($url, $_tags, '--tags/-t', 'tags/');\n }\n@@ -937,16 +942,21 @@ sub complete_url_ls_init {\n \t\t\t\tprint STDERR \"W: Unrecognized URL: $u\\n\";\n \t\t\t\tdie \"This should never happen\\n\";\n \t\t\t}\n+\t\t\t# don't try to init already existing refs\n \t\t\tmy $id = $pfx.$1;\n-\t\t\tprint \"init $u => $id\\n\";\n \t\t\t$GIT_SVN = $ENV{GIT_SVN_ID} = $id;\n \t\t\tinit_vars();\n-\t\t\tinit($u);\n+\t\t\tunless (-d $GIT_SVN_DIR) {\n+\t\t\t\tprint \"init $u => $id\\n\";\n+\t\t\t\tinit($u);\n+\t\t\t}\n \t\t}\n \t\texit 0;\n \t}\n \twaitpid $pid, 0;\n \tcroak $? if $?;\n+\tmy ($n) = ($switch =~ /^--(\\w+)/);\n+\tsys('git-repo-config', \"svn.$n\", $var);\n }\n \n sub common_prefix {\n-- \n1.4.2.3.gc5a8\n"},{"id":"28623","messageId":"11605928042812-git-send-email-normalperson@yhbt.net","threadId":"5888","inReplyTo":"11605928022833-git-send-email-normalperson@yhbt.net","subject":"[PATCH] git-svn: log command fixes","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-10-11T18:53:22Z","receivedAt":"2006-10-11T18:53:22Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Change the --verbose flag to more closely match svn.  I was\nsomehow under the impression that --summary included --raw diff\noutput, but I was wrong.  We now pass -r --raw --name-status as\narguments if passed -v/--verbose.\n\n-r (recursive) is passed by default, since users usually want\nit, and accepting it causes difficulty with the -r<revision>\noption used by svn users.  A --non-recursive switch has been\nadded to disable this.\n\nOf course, --summary, --raw, -p and any other git-log options\ncan still be passed directly (without --name-status).\n\nAlso, several warnings about referencing undefined variables\nhave been fixed.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   32 +++++++++++++++++++++++++-------\n 1 files changed, 25 insertions(+), 7 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 5a6c87e..4f6e6a3 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -52,7 +52,7 @@ my ($_revision,$_stdin,$_no_ignore_ext,$\n \t$_template, $_shared, $_no_default_regex, $_no_graft_copy,\n \t$_limit, $_verbose, $_incremental, $_oneline, $_l_fmt, $_show_commit,\n \t$_version, $_upgrade, $_authors, $_branch_all_refs, @_opt_m,\n-\t$_merge, $_strategy, $_dry_run, $_ignore_nodate);\n+\t$_merge, $_strategy, $_dry_run, $_ignore_nodate, $_non_recursive);\n my (@_branch_from, %tree_map, %users, %rusers, %equiv);\n my ($_svn_co_url_revs, $_svn_pg_peg_revs);\n my @repo_path_split_cache;\n@@ -114,6 +114,7 @@ my %cmd = (\n \t\t\t  'incremental' => \\$_incremental,\n \t\t\t  'oneline' => \\$_oneline,\n \t\t\t  'show-commit' => \\$_show_commit,\n+\t\t\t  'non-recursive' => \\$_non_recursive,\n \t\t\t  'authors-file|A=s' => \\$_authors,\n \t\t\t} ],\n \t'commit-diff' => [ \\&commit_diff, 'Commit a diff between two trees',\n@@ -752,13 +753,18 @@ sub show_log {\n \t\t\t# ignore\n \t\t} elsif (/^:\\d{6} \\d{6} $sha1_short/o) {\n \t\t\tpush @{$c->{raw}}, $_;\n+\t\t} elsif (/^[ACRMDT]\\t/) {\n+\t\t\t# we could add $SVN_PATH here, but that requires\n+\t\t\t# remote access at the moment (repo_path_split)...\n+\t\t\ts#^([ACRMDT])\\t#   $1 #;\n+\t\t\tpush @{$c->{changed}}, $_;\n \t\t} elsif (/^diff /) {\n \t\t\t$d = 1;\n \t\t\tpush @{$c->{diff}}, $_;\n \t\t} elsif ($d) {\n \t\t\tpush @{$c->{diff}}, $_;\n \t\t} elsif (/^    (git-svn-id:.+)$/) {\n-\t\t\t(undef, $c->{r}, undef) = extract_metadata($1);\n+\t\t\t($c->{url}, $c->{r}, undef) = extract_metadata($1);\n \t\t} elsif (s/^    //) {\n \t\t\tpush @{$c->{l}}, $_;\n \t\t}\n@@ -850,7 +856,8 @@ sub git_svn_log_cmd {\n \tmy ($r_min, $r_max) = @_;\n \tmy @cmd = (qw/git-log --abbrev-commit --pretty=raw\n \t\t\t--default/, \"refs/remotes/$GIT_SVN\");\n-\tpush @cmd, '--summary' if $_verbose;\n+\tpush @cmd, '-r' unless $_non_recursive;\n+\tpush @cmd, qw/--raw --name-status/ if $_verbose;\n \treturn @cmd unless defined $r_max;\n \tif ($r_max == $r_min) {\n \t\tpush @cmd, '--max-count=1';\n@@ -861,7 +868,7 @@ sub git_svn_log_cmd {\n \t\tmy ($c_min, $c_max);\n \t\t$c_max = revdb_get($REVDB, $r_max);\n \t\t$c_min = revdb_get($REVDB, $r_min);\n-\t\tif ($c_min && $c_max) {\n+\t\tif (defined $c_min && defined $c_max) {\n \t\t\tif ($r_max > $r_max) {\n \t\t\t\tpush @cmd, \"$c_min..$c_max\";\n \t\t\t} else {\n@@ -2561,6 +2568,12 @@ sub show_commit {\n \t}\n }\n \n+sub show_commit_changed_paths {\n+\tmy ($c) = @_;\n+\treturn unless $c->{changed};\n+\tprint \"Changed paths:\\n\", @{$c->{changed}};\n+}\n+\n sub show_commit_normal {\n \tmy ($c) = @_;\n \tprint '-' x72, \"\\nr$c->{r} | \";\n@@ -2570,7 +2583,8 @@ sub show_commit_normal {\n \tmy $nr_line = 0;\n \n \tif (my $l = $c->{l}) {\n-\t\twhile ($l->[$#$l] eq \"\\n\" && $l->[($#$l - 1)] eq \"\\n\") {\n+\t\twhile ($l->[$#$l] eq \"\\n\" && $#$l > 0\n+\t\t                          && $l->[($#$l - 1)] eq \"\\n\") {\n \t\t\tpop @$l;\n \t\t}\n \t\t$nr_line = scalar @$l;\n@@ -2582,11 +2596,15 @@ sub show_commit_normal {\n \t\t\t} else {\n \t\t\t\t$nr_line .= ' lines';\n \t\t\t}\n-\t\t\tprint $nr_line, \"\\n\\n\";\n+\t\t\tprint $nr_line, \"\\n\";\n+\t\t\tshow_commit_changed_paths($c);\n+\t\t\tprint \"\\n\";\n \t\t\tprint $_ foreach @$l;\n \t\t}\n \t} else {\n-\t\tprint \"1 line\\n\\n\";\n+\t\tprint \"1 line\\n\";\n+\t\tshow_commit_changed_paths($c);\n+\t\tprint \"\\n\";\n \n \t}\n \tforeach my $x (qw/raw diff/) {\n-- \n1.4.2.3.gc5a8\n"}]}