git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH] git-svn: ensure fetch always works chronologically.

From
EWEric Wong <normalperson@yhbt.net>
Date
Feb 17, 2006, 02:13 UTC
Message-ID
<20060217021332.GA11061@Muzzle>
In-Reply-To
<20060216194751.GB4446@Muzzle>

We run svn log against a URL without a working copy for the first fetch, so we end up a log that's sorted from highest to lowest. That's bad, we always want lowest to highest. Just default to --revision 0:HEAD now if -r isn't specified for the first fetch.

Also sort the revisions after we get them just in case somebody accidentally reverses the argument to --revision for whatever reason.

Thanks again to Emmanuel Guerin for helping me find this.
Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 contrib/git-svn/git-svn |    7 ++++---
 1 files changed, 4 insertions(+), 3 deletions(-)
2ec4f205eaa3914a64205ea224292b9e27e06cdf
diff --git a/contrib/git-svn/git-svn b/contrib/git-svn/git-svn
index ddd9579..2caf057 100755
--- a/contrib/git-svn/git-svn
+++ b/contrib/git-svn/git-svn
@@ -168,14 +168,15 @@ sub fetch {
 	my (@parents) = @_;
 	$SVN_URL ||= file_to_s("$GIT_DIR/$GIT_SVN/info/url");
 	my @log_args = -d $SVN_WC ? ($SVN_WC) : ($SVN_URL);
-	if (-d $SVN_WC && !$_revision) {
-		$_revision = 'BASE:HEAD';
+	unless ($_revision) {
+		$_revision = -d $SVN_WC ? 'BASE:HEAD' : '0:HEAD';
 	}
-	push @log_args, "-r$_revision" if $_revision;
+	push @log_args, "-r$_revision";
 	push @log_args, '--stop-on-copy' unless $_no_stop_copy;
 
 	eval { require XML::Simple or croak $! };
 	my $svn_log = $@ ? svn_log_raw(@log_args) : svn_log_xml(@log_args);
+	@$svn_log = sort { $a->{revision} <=> $b->{revision} } @$svn_log;
 
 	my $base = shift @$svn_log or croak "No base revision!\n";
 	my $last_commit = undef;
-- 
1.2.0.gdee6
Previous: Eric Wong
Message 15 of 15 in “[ANNOUNCE] git-svn - bidirection operations between svn and git”
  1. Eric WongFeb 16, 2006
  2. Junio C HamanoFeb 16, 2006
  3. Aneesh KumarFeb 16, 2006
  4. Junio C HamanoFeb 16, 2006
  5. Aneesh KumarFeb 16, 2006
  6. Junio C HamanoFeb 16, 2006
  7. Aneesh KumarFeb 16, 2006
  8. Petr BaudisFeb 16, 2006
  9. Aneesh KumarFeb 16, 2006
  10. Eric WongFeb 16, 2006
  11. Eduardo Pereira HabkostFeb 16, 2006
  12. Eric WongFeb 16, 2006
  13. git-svn: fix revision order when XML::Simple is not loadedEric Wong, Feb 16, 2006
  14. Eric WongFeb 16, 2006
  15. git-svn: ensure fetch always works chronologically.Eric Wong, Feb 17, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.