{"thread":{"id":"7566","subject":"[PATCH] git-svn: dcommit/rebase confused by patches with git-svn-id: lines","startedAt":"2007-04-08T07:59:19Z","lastAt":"2007-04-08T07:59:19Z","messageCount":1,"participants":["Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"38877","messageId":"11760191593408-git-send-email-normalperson@yhbt.net","threadId":"7566","inReplyTo":null,"subject":"[PATCH] git-svn: dcommit/rebase confused by patches with git-svn-id: lines","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2007-04-08T07:59:19Z","receivedAt":"2007-04-08T07:59:19Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"When patches are merged from another git-svn managed branch,\nthey will have the git-svn-id: metadata line in them (generated\nby git-format-patch).\n\nWhen doing rebase or dcommit via git-svn, this would cause\ngit-svn to find the wrong upstream branch.  We now verify\nthat the commit is consistent with the value in the .rev_db\nfile.\n\nSigned-off-by: Eric Wong <normalperson@yhbt.net>\n---\n git-svn.perl |   41 +++++++++++++++++++++--------------------\n 1 files changed, 21 insertions(+), 20 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 6216cad..e4079fb 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -363,13 +363,12 @@ sub cmd_dcommit {\n \tmy $head = shift;\n \t$head ||= 'HEAD';\n \tmy @refs;\n-\tmy ($url, $rev, $uuid) = working_head_info($head, \\@refs);\n-\tmy $c = $refs[-1];\n-\tunless (defined $url && defined $rev && defined $uuid) {\n+\tmy ($url, $rev, $uuid, $gs) = working_head_info($head, \\@refs);\n+\tunless ($gs) {\n \t\tdie \"Unable to determine upstream SVN information from \",\n \t\t    \"$head history\\n\";\n \t}\n-\tmy $gs = Git::SVN->find_by_url($url);\n+\tmy $c = $refs[-1];\n \tmy $last_rev;\n \tforeach my $d (@refs) {\n \t\tif (!verify_ref(\"$d~1\")) {\n@@ -431,16 +430,11 @@ sub cmd_dcommit {\n \n sub cmd_rebase {\n \tcommand_noisy(qw/update-index --refresh/);\n-\tmy $url = (working_head_info('HEAD'))[0];\n-\tif (!defined $url) {\n+\tmy ($url, $rev, $uuid, $gs) = working_head_info('HEAD');\n+\tunless ($gs) {\n \t\tdie \"Unable to determine upstream SVN information from \",\n \t\t    \"working tree history\\n\";\n \t}\n-\n-\tmy $gs = Git::SVN->find_by_url($url);\n-\tunless ($gs) {\n-\t\tdie \"Unable to determine remote information from URL: $url\\n\";\n-\t}\n \tif (command(qw/diff-index HEAD --/)) {\n \t\tprint STDERR \"Cannot rebase with uncommited changes:\\n\";\n \t\tcommand_noisy('status');\n@@ -453,8 +447,8 @@ sub cmd_rebase {\n }\n \n sub cmd_show_ignore {\n-\tmy $url = (::working_head_info('HEAD'))[0];\n-\tmy $gs = Git::SVN->find_by_url($url) || Git::SVN->new;\n+\tmy ($url, $rev, $uuid, $gs) = working_head_info('HEAD');\n+\t$gs ||= Git::SVN->new;\n \tmy $r = (defined $_revision ? $_revision : $gs->ra->get_latest_revnum);\n \t$gs->traverse_ignore(\\*STDOUT, $gs->{path}, $r);\n }\n@@ -776,16 +770,23 @@ sub cmt_metadata {\n \n sub working_head_info {\n \tmy ($head, $refs) = @_;\n-\tmy ($url, $rev, $uuid);\n \tmy ($fh, $ctx) = command_output_pipe('rev-list', $head);\n \twhile (<$fh>) {\n \t\tchomp;\n-\t\t($url, $rev, $uuid) = cmt_metadata($_);\n-\t\tlast if (defined $url && defined $rev && defined $uuid);\n+\t\tmy ($url, $rev, $uuid) = cmt_metadata($_);\n+\t\tif (defined $url && defined $rev) {\n+\t\t\tif (my $gs = Git::SVN->find_by_url($url)) {\n+\t\t\t\tmy $c = $gs->rev_db_get($rev);\n+\t\t\t\tif ($c && $c eq $_) {\n+\t\t\t\t\tclose $fh; # break the pipe\n+\t\t\t\t\treturn ($url, $rev, $uuid, $gs);\n+\t\t\t\t}\n+\t\t\t}\n+\t\t}\n \t\tunshift @$refs, $_ if $refs;\n \t}\n-\tclose $fh; # break the pipe\n-\t($url, $rev, $uuid);\n+\tcommand_close_pipe($fh, $ctx);\n+\t(undef, undef, undef, undef);\n }\n \n package Git::SVN;\n@@ -3321,8 +3322,8 @@ sub git_svn_log_cmd {\n \t\tlast;\n \t}\n \n-\tmy $url = (::working_head_info($head))[0];\n-\tmy $gs = Git::SVN->find_by_url($url) || Git::SVN->_new;\n+\tmy ($url, $rev, $uuid, $gs) = ::working_head_info($head);\n+\t$gs ||= Git::SVN->_new;\n \tmy @cmd = (qw/log --abbrev-commit --pretty=raw --default/,\n \t           $gs->refname);\n \tpush @cmd, '-r' unless $non_recursive;\n-- \n1.5.1.82.g8c65-dirty\n"}]}