git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH] git-svn: fix log with single revision against a non-HEAD branch
@ 2007-08-15 16:55 Eric Wong
  2007-08-15 20:42 ` Junio C Hamano
  0 siblings, 1 reply; 2+ messages in thread
From: Eric Wong @ 2007-08-15 16:55 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

Running git-svn log <ref> -r<rev> against a <ref> other than the
current HEAD did not work if the <rev> was exclusive to the
other branch.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl           |   24 +++++++++++++++---------
 t/t9116-git-svn-log.sh |   48 ++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 63 insertions(+), 9 deletions(-)
 create mode 100755 t/t9116-git-svn-log.sh

diff --git a/git-svn.perl b/git-svn.perl
index ee7ef69..d162114 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -3501,11 +3501,17 @@ sub log_use_color {
 sub git_svn_log_cmd {
 	my ($r_min, $r_max, @args) = @_;
 	my $head = 'HEAD';
+	my (@files, @log_opts);
 	foreach my $x (@args) {
-		last if $x eq '--';
-		next unless ::verify_ref("$x^0");
-		$head = $x;
-		last;
+		if ($x eq '--' || @files) {
+			push @files, $x;
+		} else {
+			if (::verify_ref("$x^0")) {
+				$head = $x;
+			} else {
+				push @log_opts, $x;
+			}
+		}
 	}
 
 	my ($url, $rev, $uuid, $gs) = ::working_head_info($head);
@@ -3515,13 +3521,13 @@ sub git_svn_log_cmd {
 	push @cmd, '-r' unless $non_recursive;
 	push @cmd, qw/--raw --name-status/ if $verbose;
 	push @cmd, '--color' if log_use_color();
-	return @cmd unless defined $r_max;
-	if ($r_max == $r_min) {
+	push @cmd, @log_opts;
+	if (defined $r_max && $r_max == $r_min) {
 		push @cmd, '--max-count=1';
 		if (my $c = $gs->rev_db_get($r_max)) {
 			push @cmd, $c;
 		}
-	} else {
+	} elsif (defined $r_max) {
 		my ($c_min, $c_max);
 		$c_max = $gs->rev_db_get($r_max);
 		$c_min = $gs->rev_db_get($r_min);
@@ -3537,7 +3543,7 @@ sub git_svn_log_cmd {
 			push @cmd, $c_min;
 		}
 	}
-	return @cmd;
+	return (@cmd, @files);
 }
 
 # adapted from pager.c
@@ -3702,7 +3708,7 @@ sub cmd_show_log {
 	}
 
 	config_pager();
-	@args = (git_svn_log_cmd($r_min, $r_max, @args), @args);
+	@args = git_svn_log_cmd($r_min, $r_max, @args);
 	my $log = command_output_pipe(@args);
 	run_pager();
 	my (@k, $c, $d, $stat);
diff --git a/t/t9116-git-svn-log.sh b/t/t9116-git-svn-log.sh
new file mode 100755
index 0000000..0d4e6b3
--- /dev/null
+++ b/t/t9116-git-svn-log.sh
@@ -0,0 +1,48 @@
+#!/bin/sh
+#
+# Copyright (c) 2007 Eric Wong
+#
+
+test_description='git-svn log tests'
+. ./lib-git-svn.sh
+
+test_expect_success 'setup repository and import' "
+	mkdir import &&
+	cd import &&
+		for i in trunk branches/a branches/b \
+		         tags/0.1 tags/0.2 tags/0.3; do
+			mkdir -p \$i && \
+			echo hello >> \$i/README || exit 1
+		done && \
+		svn import -m test . $svnrepo
+		cd .. &&
+	git-svn init $svnrepo -T trunk -b branches -t tags &&
+	git-svn fetch &&
+	git reset --hard trunk &&
+	echo bye >> README &&
+	git commit -a -m bye &&
+	git svn dcommit &&
+	git reset --hard a &&
+	echo why >> FEEDME &&
+	git update-index --add FEEDME &&
+	git commit -m feedme &&
+	git svn dcommit &&
+	git reset --hard trunk &&
+	echo aye >> README &&
+	git commit -a -m aye &&
+	git svn dcommit
+	"
+
+test_expect_success 'run log' "
+	git reset --hard a &&
+	git svn log -r2 trunk | grep ^r2 &&
+	git svn log -r4 trunk | grep ^r4 &&
+	git svn log -r3 | grep ^r3
+	"
+
+test_expect_success 'run log against a from trunk' "
+	git reset --hard trunk &&
+	git svn log -r3 a | grep ^r3
+	"
+
+test_done
-- 
1.5.3.rc5.1.gb318

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] git-svn: fix log with single revision against a non-HEAD branch
  2007-08-15 16:55 [PATCH] git-svn: fix log with single revision against a non-HEAD branch Eric Wong
@ 2007-08-15 20:42 ` Junio C Hamano
  0 siblings, 0 replies; 2+ messages in thread
From: Junio C Hamano @ 2007-08-15 20:42 UTC (permalink / raw)
  To: Eric Wong; +Cc: git

Thanks.

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2007-08-15 20:42 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2007-08-15 16:55 [PATCH] git-svn: fix log with single revision against a non-HEAD branch Eric Wong
2007-08-15 20:42 ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).