{"thread":{"id":"9539","subject":"[PATCH] git-svn: fix log with single revision against a non-HEAD branch","startedAt":"2007-08-15T16:55:18Z","lastAt":"2007-08-15T20:42:21Z","messageCount":2,"participants":["Eric Wong","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50795","messageId":"1187196918619-git-send-email-normalperson@yhbt.net","threadId":"9539","inReplyTo":null,"subject":"[PATCH] git-svn: fix log with single revision against a non-HEAD branch","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-08-15T16:55:18Z","receivedAt":"2007-08-15T16:55:18Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Running git-svn log <ref> -r<rev> against a <ref> other than the\ncurrent HEAD did not work if the <rev> was exclusive to the\nother branch.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl           |   24 +++++++++++++++---------\n t/t9116-git-svn-log.sh |   48 ++++++++++++++++++++++++++++++++++++++++++++++++\n 2 files changed, 63 insertions(+), 9 deletions(-)\n create mode 100755 t/t9116-git-svn-log.sh\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex ee7ef69..d162114 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3501,11 +3501,17 @@ sub log_use_color {\n sub git_svn_log_cmd {\n \tmy ($r_min, $r_max, @args) = @_;\n \tmy $head = 'HEAD';\n+\tmy (@files, @log_opts);\n \tforeach my $x (@args) {\n-\t\tlast if $x eq '--';\n-\t\tnext unless ::verify_ref(\"$x^0\");\n-\t\t$head = $x;\n-\t\tlast;\n+\t\tif ($x eq '--' || @files) {\n+\t\t\tpush @files, $x;\n+\t\t} else {\n+\t\t\tif (::verify_ref(\"$x^0\")) {\n+\t\t\t\t$head = $x;\n+\t\t\t} else {\n+\t\t\t\tpush @log_opts, $x;\n+\t\t\t}\n+\t\t}\n \t}\n \n \tmy ($url, $rev, $uuid, $gs) = ::working_head_info($head);\n@@ -3515,13 +3521,13 @@ sub git_svn_log_cmd {\n \tpush @cmd, '-r' unless $non_recursive;\n \tpush @cmd, qw/--raw --name-status/ if $verbose;\n \tpush @cmd, '--color' if log_use_color();\n-\treturn @cmd unless defined $r_max;\n-\tif ($r_max == $r_min) {\n+\tpush @cmd, @log_opts;\n+\tif (defined $r_max && $r_max == $r_min) {\n \t\tpush @cmd, '--max-count=1';\n \t\tif (my $c = $gs->rev_db_get($r_max)) {\n \t\t\tpush @cmd, $c;\n \t\t}\n-\t} else {\n+\t} elsif (defined $r_max) {\n \t\tmy ($c_min, $c_max);\n \t\t$c_max = $gs->rev_db_get($r_max);\n \t\t$c_min = $gs->rev_db_get($r_min);\n@@ -3537,7 +3543,7 @@ sub git_svn_log_cmd {\n \t\t\tpush @cmd, $c_min;\n \t\t}\n \t}\n-\treturn @cmd;\n+\treturn (@cmd, @files);\n }\n \n # adapted from pager.c\n@@ -3702,7 +3708,7 @@ sub cmd_show_log {\n \t}\n \n \tconfig_pager();\n-\t@args = (git_svn_log_cmd($r_min, $r_max, @args), @args);\n+\t@args = git_svn_log_cmd($r_min, $r_max, @args);\n \tmy $log = command_output_pipe(@args);\n \trun_pager();\n \tmy (@k, $c, $d, $stat);\ndiff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh\nnew file mode 100755\nindex 0000000..0d4e6b3\n--- /dev/null\n+++ b/t/t9116-git-svn-log.sh\n@@ -0,0 +1,48 @@\n+#!/bin/sh\n+#\n+# Copyright (c) 2007 Eric Wong\n+#\n+\n+test_description='git-svn log tests'\n+. ./lib-git-svn.sh\n+\n+test_expect_success 'setup repository and import' \"\n+\tmkdir import &&\n+\tcd import &&\n+\t\tfor i in trunk branches/a branches/b \\\n+\t\t         tags/0.1 tags/0.2 tags/0.3; do\n+\t\t\tmkdir -p \\$i && \\\n+\t\t\techo hello >> \\$i/README || exit 1\n+\t\tdone && \\\n+\t\tsvn import -m test . $svnrepo\n+\t\tcd .. &&\n+\tgit-svn init $svnrepo -T trunk -b branches -t tags &&\n+\tgit-svn fetch &&\n+\tgit reset --hard trunk &&\n+\techo bye >> README &&\n+\tgit commit -a -m bye &&\n+\tgit svn dcommit &&\n+\tgit reset --hard a &&\n+\techo why >> FEEDME &&\n+\tgit update-index --add FEEDME &&\n+\tgit commit -m feedme &&\n+\tgit svn dcommit &&\n+\tgit reset --hard trunk &&\n+\techo aye >> README &&\n+\tgit commit -a -m aye &&\n+\tgit svn dcommit\n+\t\"\n+\n+test_expect_success 'run log' \"\n+\tgit reset --hard a &&\n+\tgit svn log -r2 trunk | grep ^r2 &&\n+\tgit svn log -r4 trunk | grep ^r4 &&\n+\tgit svn log -r3 | grep ^r3\n+\t\"\n+\n+test_expect_success 'run log against a from trunk' \"\n+\tgit reset --hard trunk &&\n+\tgit svn log -r3 a | grep ^r3\n+\t\"\n+\n+test_done\n-- \n1.5.3.rc5.1.gb318\n"},{"id":"50815","messageId":"7vd4xopm1e.fsf@gitster.siamese.dyndns.org","threadId":"9539","inReplyTo":"1187196918619-git-send-email-normalperson@yhbt.net","subject":"Re: [PATCH] git-svn: fix log with single revision against a non-HEAD branch","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-15T20:42:21Z","receivedAt":"2007-08-15T20:42:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Thanks.\n"}]}