git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] git-svn: error out from dcommit on a parent-less commit
@ 2006-11-23 22:54 Eric Wong
  2006-11-23 22:54 ` [PATCH 2/3] git-svn: correctly handle revision 0 in SVN repositories Eric Wong
  2006-11-23 22:54 ` [PATCH 3/3] git-svn: preserve uncommitted changes after dcommit Eric Wong
  0 siblings, 2 replies; 3+ messages in thread
From: Eric Wong @ 2006-11-23 22:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

dcommit would unconditionally append "~1" to a commit in order
to generate a diff.  Now we generate a meaningful error message
if we try to generate an impossible diff.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    7 +++++++
 1 files changed, 7 insertions(+), 0 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 80b7b87..f0db4af 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -589,6 +589,13 @@ sub dcommit {
 	chomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, "$gs..HEAD"));
 	my $last_rev;
 	foreach my $d (reverse @refs) {
+		if (quiet_run('git-rev-parse','--verify',"$d~1") != 0) {
+			die "Commit $d\n",
+			    "has no parent commit, and therefore ",
+			    "nothing to diff against.\n",
+			    "You should be working from a repository ",
+			    "originally created by git-svn\n";
+		}
 		unless (defined $last_rev) {
 			(undef, $last_rev, undef) = cmt_metadata("$d~1");
 			unless (defined $last_rev) {
-- 
1.4.4.1.g22a08

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

* [PATCH 2/3] git-svn: correctly handle revision 0 in SVN repositories
  2006-11-23 22:54 [PATCH 1/3] git-svn: error out from dcommit on a parent-less commit Eric Wong
@ 2006-11-23 22:54 ` Eric Wong
  2006-11-23 22:54 ` [PATCH 3/3] git-svn: preserve uncommitted changes after dcommit Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2006-11-23 22:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

some SVN repositories have a revision 0 (committed by no author
and no date) when created; so when we need to ensure that we
check any revision variables are defined, and not just
non-zero.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |   14 ++++++++++----
 1 files changed, 10 insertions(+), 4 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index f0db4af..6feae56 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -232,7 +232,7 @@ sub rebuild {
 		my @commit = grep(/^git-svn-id: /,`git-cat-file commit $c`);
 		next if (!@commit); # skip merges
 		my ($url, $rev, $uuid) = extract_metadata($commit[$#commit]);
-		if (!$rev || !$uuid) {
+		if (!defined $rev || !$uuid) {
 			croak "Unable to extract revision or UUID from ",
 				"$c, $commit[$#commit]\n";
 		}
@@ -832,8 +832,14 @@ sub commit_diff {
 		print STDERR "Needed URL or usable git-svn id command-line\n";
 		commit_diff_usage();
 	}
-	my $r = shift || $_revision;
-	die "-r|--revision is a required argument\n" unless (defined $r);
+	my $r = shift;
+	unless (defined $r) {
+		if (defined $_revision) {
+			$r = $_revision
+		} else {
+			die "-r|--revision is a required argument\n";
+		}
+	}
 	if (defined $_message && defined $_file) {
 		print STDERR "Both --message/-m and --file/-F specified ",
 				"for the commit message.\n",
@@ -2493,7 +2499,7 @@ sub extract_metadata {
 	my $id = shift or return (undef, undef, undef);
 	my ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\s(\S+?)\@(\d+)
 							\s([a-f\d\-]+)$/x);
-	if (!$rev || !$uuid || !$url) {
+	if (!defined $rev || !$uuid || !$url) {
 		# some of the original repositories I made had
 		# identifiers like this:
 		($rev, $uuid) = ($id =~/^git-svn-id:\s(\d+)\@([a-f\d\-]+)/);
-- 
1.4.4.1.g22a08

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

* [PATCH 3/3] git-svn: preserve uncommitted changes after dcommit
  2006-11-23 22:54 [PATCH 1/3] git-svn: error out from dcommit on a parent-less commit Eric Wong
  2006-11-23 22:54 ` [PATCH 2/3] git-svn: correctly handle revision 0 in SVN repositories Eric Wong
@ 2006-11-23 22:54 ` Eric Wong
  1 sibling, 0 replies; 3+ messages in thread
From: Eric Wong @ 2006-11-23 22:54 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: git, Eric Wong

Using dcommit could cause the user to lose uncommitted changes
during the reset --hard operation, so change it to reset --mixed.

If dcommit chooses the rebase path, then git-rebase will already
error out when local changes are made.

Signed-off-by: Eric Wong <normalperson@yhbt.net>
---
 git-svn.perl |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-svn.perl b/git-svn.perl
index 6feae56..bb8935a 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -623,7 +623,7 @@ sub dcommit {
 	} else {
 		print "No changes between current HEAD and $gs\n",
 		      "Hard resetting to the latest $gs\n";
-		@finish = qw/reset --hard/;
+		@finish = qw/reset --mixed/;
 	}
 	sys('git', @finish, $gs);
 }
-- 
1.4.4.1.g22a08

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

end of thread, other threads:[~2006-11-23 22:54 UTC | newest]

Thread overview: 3+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-11-23 22:54 [PATCH 1/3] git-svn: error out from dcommit on a parent-less commit Eric Wong
2006-11-23 22:54 ` [PATCH 2/3] git-svn: correctly handle revision 0 in SVN repositories Eric Wong
2006-11-23 22:54 ` [PATCH 3/3] git-svn: preserve uncommitted changes after dcommit Eric Wong

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).