{"thread":{"id":"43295","subject":"[PATCH 2/3] git-svn: correctly handle revision 0 in SVN repositories","startedAt":"2006-11-23T22:54:03Z","lastAt":"2006-11-23T22:54:05Z","messageCount":3,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"298613","messageId":"1164322445180-git-send-email-normalperson@yhbt.net","threadId":"43295","inReplyTo":null,"subject":"[PATCH 1/3] git-svn: error out from dcommit on a parent-less commit","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-11-23T22:54:03Z","receivedAt":"2006-11-23T22:54:03Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"dcommit would unconditionally append \"~1\" to a commit in order\nto generate a diff.  Now we generate a meaningful error message\nif we try to generate an impossible diff.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |    7 +++++++\n 1 files changed, 7 insertions(+), 0 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 80b7b87..f0db4af 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -589,6 +589,13 @@ sub dcommit {\n \tchomp(my @refs = safe_qx(qw/git-rev-list --no-merges/, \"$gs..HEAD\"));\n \tmy $last_rev;\n \tforeach my $d (reverse @refs) {\n+\t\tif (quiet_run('git-rev-parse','--verify',\"$d~1\") != 0) {\n+\t\t\tdie \"Commit $d\\n\",\n+\t\t\t    \"has no parent commit, and therefore \",\n+\t\t\t    \"nothing to diff against.\\n\",\n+\t\t\t    \"You should be working from a repository \",\n+\t\t\t    \"originally created by git-svn\\n\";\n+\t\t}\n \t\tunless (defined $last_rev) {\n \t\t\t(undef, $last_rev, undef) = cmt_metadata(\"$d~1\");\n \t\t\tunless (defined $last_rev) {\n-- \n1.4.4.1.g22a08\n"},{"id":"294257","messageId":"1164322446983-git-send-email-normalperson@yhbt.net","threadId":"43295","inReplyTo":"1164322445180-git-send-email-normalperson@yhbt.net","subject":"[PATCH 2/3] git-svn: correctly handle revision 0 in SVN repositories","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-11-23T22:54:04Z","receivedAt":"2006-11-23T22:54:04Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"some SVN repositories have a revision 0 (committed by no author\nand no date) when created; so when we need to ensure that we\ncheck any revision variables are defined, and not just\nnon-zero.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   14 ++++++++++----\n 1 files changed, 10 insertions(+), 4 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex f0db4af..6feae56 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -232,7 +232,7 @@ sub rebuild {\n \t\tmy @commit = grep(/^git-svn-id: /,`git-cat-file commit $c`);\n \t\tnext if (!@commit); # skip merges\n \t\tmy ($url, $rev, $uuid) = extract_metadata($commit[$#commit]);\n-\t\tif (!$rev || !$uuid) {\n+\t\tif (!defined $rev || !$uuid) {\n \t\t\tcroak \"Unable to extract revision or UUID from \",\n \t\t\t\t\"$c, $commit[$#commit]\\n\";\n \t\t}\n@@ -832,8 +832,14 @@ sub commit_diff {\n \t\tprint STDERR \"Needed URL or usable git-svn id command-line\\n\";\n \t\tcommit_diff_usage();\n \t}\n-\tmy $r = shift || $_revision;\n-\tdie \"-r|--revision is a required argument\\n\" unless (defined $r);\n+\tmy $r = shift;\n+\tunless (defined $r) {\n+\t\tif (defined $_revision) {\n+\t\t\t$r = $_revision\n+\t\t} else {\n+\t\t\tdie \"-r|--revision is a required argument\\n\";\n+\t\t}\n+\t}\n \tif (defined $_message && defined $_file) {\n \t\tprint STDERR \"Both --message/-m and --file/-F specified \",\n \t\t\t\t\"for the commit message.\\n\",\n@@ -2493,7 +2499,7 @@ sub extract_metadata {\n \tmy $id = shift or return (undef, undef, undef);\n \tmy ($url, $rev, $uuid) = ($id =~ /^git-svn-id:\\s(\\S+?)\\@(\\d+)\n \t\t\t\t\t\t\t\\s([a-f\\d\\-]+)$/x);\n-\tif (!$rev || !$uuid || !$url) {\n+\tif (!defined $rev || !$uuid || !$url) {\n \t\t# some of the original repositories I made had\n \t\t# identifiers like this:\n \t\t($rev, $uuid) = ($id =~/^git-svn-id:\\s(\\d+)\\@([a-f\\d\\-]+)/);\n-- \n1.4.4.1.g22a08\n"},{"id":"296594","messageId":"11643224483832-git-send-email-normalperson@yhbt.net","threadId":"43295","inReplyTo":"1164322445180-git-send-email-normalperson@yhbt.net","subject":"[PATCH 3/3] git-svn: preserve uncommitted changes after dcommit","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2006-11-23T22:54:05Z","receivedAt":"2006-11-23T22:54:05Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Using dcommit could cause the user to lose uncommitted changes\nduring the reset --hard operation, so change it to reset --mixed.\n\nIf dcommit chooses the rebase path, then git-rebase will already\nerror out when local changes are made.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 6feae56..bb8935a 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -623,7 +623,7 @@ sub dcommit {\n \t} else {\n \t\tprint \"No changes between current HEAD and $gs\\n\",\n \t\t      \"Hard resetting to the latest $gs\\n\";\n-\t\t@finish = qw/reset --hard/;\n+\t\t@finish = qw/reset --mixed/;\n \t}\n \tsys('git', @finish, $gs);\n }\n-- \n1.4.4.1.g22a08\n"}]}