@matheusbsbs / matheus-bagliano / commits / defc649229
Fork 0

git-svn: ensure fetch always works chronologically.

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> Signed-off-by: Junio C Hamano <junkio@cox.net>

Eric Wong committed Feb 16, 2006 at 18:13 UTC defc649229eef2461ad1c2fea53985b8c10fd3db
1 file changed +4 -3
contrib/git-svn/git-svn
+4 -3
@@ -168,14 +168,15 @@ sub fetch {
168 my (@parents) = @_;
169 $SVN_URL ||= file_to_s("$GIT_DIR/$GIT_SVN/info/url");
170 my @log_args = -d $SVN_WC ? ($SVN_WC) : ($SVN_URL);
171 - if (-d $SVN_WC && !$_revision) {
172 - $_revision = 'BASE:HEAD';
171 + unless ($_revision) {
172 + $_revision = -d $SVN_WC ? 'BASE:HEAD' : '0:HEAD';
173 }
174 - push @log_args, "-r$_revision" if $_revision;
174 + push @log_args, "-r$_revision";
175 push @log_args, '--stop-on-copy' unless $_no_stop_copy;
176
177 eval { require XML::Simple or croak $! };
178 my $svn_log = $@ ? svn_log_raw(@log_args) : svn_log_xml(@log_args);
179 + @$svn_log = sort { $a->{revision} <=> $b->{revision} } @$svn_log;
180
181 my $base = shift @$svn_log or croak "No base revision!\n";
182 my $last_commit = undef;