git-svn: detect and fail gracefully when dcommitting to a void
The command git svn clone (URL of an empty SVN repo here) works, creates an empty git repository. I can perform the initial commit there, but then, "git svn dcommit" says : Use of uninitialized value in concatenation (.) or string at .../git-svn line 414. Committing to ... Unable to determine upstream SVN information from HEAD history I guess a correct management of the initial commit in git-svn would be hard to implement, but at least, the error message can be improved. First step is something like the patch below, and better would be for "git svn clone" to warn that it won't be able to do much with the cloned repo. Acked-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Matthieu Moy committed
Apr 24, 2008 at 20:06 UTC
59b0c24daaac3c2203dd8ac2de4dfcad909481a5
2 files changed
+7
-2
diff-lib.c
+3
@@ -264,6 +264,9 @@ int setup_diff_no_index(struct rev_info *revs,
264
DIFF_OPT_SET(&revs->diffopt, EXIT_WITH_STATUS);
265
break;
266
}
267
+ if (nongit && argc != i + 2)
268
+ die("git diff [--no-index] takes two paths");
269
+
270
if (argc != i + 2 || (!is_outside_repo(argv[i + 1], nongit, prefix) &&
271
!is_outside_repo(argv[i], nongit, prefix)))
272
return -1;
git-svn.perl
+4
-2
@@ -410,10 +410,12 @@ sub cmd_dcommit {
410
$head ||= 'HEAD';
411
my @refs;
412
my ($url, $rev, $uuid, $gs) = working_head_info($head, \@refs);
413
- print "Committing to $url ...\n";
413
+ if ($url) {
414
+ print "Committing to $url ...\n";
415
+ }
416
unless ($gs) {
417
die "Unable to determine upstream SVN information from ",
416
- "$head history\n";
418
+ "$head history.\nPerhaps the repository is empty.";
419
}
420
my $last_rev;
421
my ($linear_refs, $parents) = linearize_history($gs, \@refs);