{"thread":{"id":"27647","subject":"[PATCH 0/3] git-svn: Handle git root commits in mergeinfo ranges","startedAt":"2011-06-18T06:47:57Z","lastAt":"2011-06-28T03:37:32Z","messageCount":5,"participants":["Michael Haggerty","Eric Wong"],"isPatch":true,"patchVersion":1,"patchTotal":3},"messages":[{"id":"170194","messageId":"1308379680-17188-1-git-send-email-mhagger@alum.mit.edu","threadId":"27647","inReplyTo":null,"subject":"[PATCH 0/3] git-svn: Handle git root commits in mergeinfo ranges","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-06-18T06:47:57Z","receivedAt":"2011-06-18T06:47:57Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"The maint version of git-svn fails if there is a svn:mergeinfo range\nthat includes a commit that has no parent; for example, \"/trunk:1-59\".\nSimilar problems have been discussed before [1,2].\n\nThe problem in this case is that git-svn tries to obtain the list of\ngit revisions brought into the branch by this range by running\n\n    git rev-list \"$bottom_commit^..$top_commit\"\n\nwhere $bottom_commit is the SHA1 of the git commit corresponding to\nthe first commit in the mergeinfo range.  But $bottom_commit is a root\ncommit and does not have a parent.\n\nAs noted in [3], the obvious solution,\n\n    git rev-list \"$bottom_commit^!\" \"$top_commit\"\n\n, causes breakage in test 5 of t9151-svn-mergeinfo.sh.  The problem is\nthat it is important to exclude only those commits reachable from the\n*first* parent of $bottom_commit, not *all* parents.\n\nInstead, this patch simply uses \"git rev-parse\" to determine whether\n$bottom_commit has any parents at all.  If not, then the following\ncommand is used instead:\n\n    git rev-list \"$top_commit\"\n\nI don't believe the extra \"git rev-parse\" invocation to be a\nperformance problem, but I am not familiar enough with the code to be\ncertain.\n\nMichael\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/146255\n[2] http://thread.gmane.org/gmane.comp.version-control.git/171248\n[3] http://article.gmane.org/gmane.comp.version-control.git/150416\n\nMichael Haggerty (3):\n  git-svn: Demonstrate a bug with root commits in mergeinfo ranges\n  git-svn: Disambiguate rev-list arguments to improve error message\n  git-svn: Correctly handle root commits in mergeinfo ranges\n\n git-svn.perl                           |   11 ++++++---\n t/t9159-git-svn-no-parent-mergeinfo.sh |   33 ++++++++++++++++++++++++++++++++\n 2 files changed, 40 insertions(+), 4 deletions(-)\n create mode 100755 t/t9159-git-svn-no-parent-mergeinfo.sh\n\n-- \n1.7.5.4\n"},{"id":"170195","messageId":"1308379680-17188-2-git-send-email-mhagger@alum.mit.edu","threadId":"27647","inReplyTo":"1308379680-17188-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 1/3] git-svn: Demonstrate a bug with root commits in mergeinfo ranges","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-06-18T06:47:58Z","receivedAt":"2011-06-18T06:47:58Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"If a svn:mergeinfo range starts at a commit that was converted as a\ngit root commit (e.g., r1 or a branch that was created out of thin\nair), then there is an error when git-svn tries to run\n\n    git rev-list \"$bottom_commit^..$top_commit\"\n\nbecause $bottom_commit (the git commit corresponding to r1) has no\nparent.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n t/t9159-git-svn-no-parent-mergeinfo.sh |   33 ++++++++++++++++++++++++++++++++\n 1 files changed, 33 insertions(+), 0 deletions(-)\n create mode 100755 t/t9159-git-svn-no-parent-mergeinfo.sh\n\ndiff --git a/t/t9159-git-svn-no-parent-mergeinfo.sh b/t/t9159-git-svn-no-parent-mergeinfo.sh\nnew file mode 100755\nindex 0000000..9472de3\n--- /dev/null\n+++ b/t/t9159-git-svn-no-parent-mergeinfo.sh\n@@ -0,0 +1,33 @@\n+#!/bin/sh\n+test_description='git svn handling of root commits in merge ranges'\n+. ./lib-git-svn.sh\n+\n+test_expect_failure 'test handling of root commits in merge ranges' '\n+\tmkdir -p init/trunk init/branches init/tags &&\n+\techo \"r1\" > init/trunk/file.txt &&\n+\tsvn_cmd import -m \"initial import\" init \"$svnrepo\" &&\n+\tsvn_cmd co \"$svnrepo\" tmp &&\n+\t(\n+\t\tcd tmp &&\n+\t\techo \"r2\" > trunk/file.txt &&\n+\t\tsvn_cmd commit -m \"Modify file.txt on trunk\" &&\n+\t\tsvn_cmd cp trunk@1 branches/a &&\n+\t\tsvn_cmd commit -m \"Create branch a from trunk r1\" &&\n+\t\tsvn_cmd propset svn:mergeinfo /trunk:1-2 branches/a &&\n+\t\tsvn_cmd commit -m \"Fake merge of trunk r2 into branch a\" &&\n+\t\tmkdir branches/b &&\n+\t\techo \"r5\" > branches/b/file2.txt &&\n+\t\tsvn_cmd add branches/b &&\n+\t\tsvn_cmd commit -m \"Create branch b from thin air\" &&\n+\t\techo \"r6\" > branches/b/file2.txt &&\n+\t\tsvn_cmd commit -m \"Modify file2.txt on branch b\" &&\n+\t\tsvn_cmd cp branches/b@5 branches/c &&\n+\t\tsvn_cmd commit -m \"Create branch c from branch b r5\" &&\n+\t\tsvn_cmd propset svn:mergeinfo /branches/b:5-6 branches/c &&\n+\t\tsvn_cmd commit -m \"Fake merge of branch b r6 into branch c\"\n+\t) &&\n+\tgit svn init -s \"$svnrepo\" &&\n+\tgit svn fetch\n+\t'\n+\n+test_done\n-- \n1.7.5.4\n"},{"id":"170196","messageId":"1308379680-17188-3-git-send-email-mhagger@alum.mit.edu","threadId":"27647","inReplyTo":"1308379680-17188-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 2/3] git-svn: Disambiguate rev-list arguments to improve error message","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-06-18T06:47:59Z","receivedAt":"2011-06-18T06:47:59Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"Add \"--\" in the \"git rev-list\" command line so that if there is a bug\nand the revisions cannot be found, the error message is a bit less\ncryptic.\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n git-svn.perl |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex da3fea8..2cc9242 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3141,9 +3141,9 @@ sub check_cherry_pick {\n \tmy $parents = shift;\n \tmy @ranges = @_;\n \tmy %commits = map { $_ => 1 }\n-\t\t_rev_list(\"--no-merges\", $tip, \"--not\", $base, @$parents);\n+\t\t_rev_list(\"--no-merges\", $tip, \"--not\", $base, @$parents, \"--\");\n \tfor my $range ( @ranges ) {\n-\t\tdelete @commits{_rev_list($range)};\n+\t\tdelete @commits{_rev_list($range, \"--\")};\n \t}\n \tfor my $commit (keys %commits) {\n \t\tif (has_no_changes($commit)) {\n-- \n1.7.5.4\n"},{"id":"170197","messageId":"1308379680-17188-4-git-send-email-mhagger@alum.mit.edu","threadId":"27647","inReplyTo":"1308379680-17188-1-git-send-email-mhagger@alum.mit.edu","subject":"[PATCH 3/3] git-svn: Correctly handle root commits in mergeinfo ranges","fromName":"Michael Haggerty","fromEmail":"mhagger@alum.mit.edu","sentAt":"2011-06-18T06:48:00Z","receivedAt":"2011-06-18T06:48:00Z","isPatch":true,"sender":{"key":"mhagger@alum.mit.edu","avatar":"https://avatars.githubusercontent.com/u/119718?v=4"},"body":"If the bottom of a mergeinfo range is a commit that maps to a git root\ncommit, then it doesn't have a parent.  In such a case, use git commit\nrange \"$top_commit\" rather than \"$bottom_commit^..$top_commit\".\n\nSigned-off-by: Michael Haggerty <mhagger@alum.mit.edu>\n---\n git-svn.perl                           |    7 +++++--\n t/t9159-git-svn-no-parent-mergeinfo.sh |    2 +-\n 2 files changed, 6 insertions(+), 3 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 2cc9242..7e121ae 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -3111,8 +3111,11 @@ sub lookup_svn_merge {\n \t\t\tnext;\n \t\t}\n \n-\t\tpush @merged_commit_ranges,\n-\t\t\t\"$bottom_commit^..$top_commit\";\n+\t\tif (scalar(command('rev-parse', \"$bottom_commit^@\"))) {\n+\t\t\tpush @merged_commit_ranges, \"$bottom_commit^..$top_commit\";\n+\t\t} else {\n+\t\t\tpush @merged_commit_ranges, \"$top_commit\";\n+\t\t}\n \n \t\tif ( !defined $tip or $top > $tip ) {\n \t\t\t$tip = $top;\ndiff --git a/t/t9159-git-svn-no-parent-mergeinfo.sh b/t/t9159-git-svn-no-parent-mergeinfo.sh\nindex 9472de3..85120b7 100755\n--- a/t/t9159-git-svn-no-parent-mergeinfo.sh\n+++ b/t/t9159-git-svn-no-parent-mergeinfo.sh\n@@ -2,7 +2,7 @@\n test_description='git svn handling of root commits in merge ranges'\n . ./lib-git-svn.sh\n \n-test_expect_failure 'test handling of root commits in merge ranges' '\n+test_expect_success 'test handling of root commits in merge ranges' '\n \tmkdir -p init/trunk init/branches init/tags &&\n \techo \"r1\" > init/trunk/file.txt &&\n \tsvn_cmd import -m \"initial import\" init \"$svnrepo\" &&\n-- \n1.7.5.4\n"},{"id":"170604","messageId":"20110628033732.GA14132@dcvr.yhbt.net","threadId":"27647","inReplyTo":"1308379680-17188-1-git-send-email-mhagger@alum.mit.edu","subject":"Re: [PATCH 0/3] git-svn: Handle git root commits in mergeinfo ranges","fromName":"Eric Wong","fromEmail":"normalperson@yhbt.net","sentAt":"2011-06-28T03:37:32Z","receivedAt":"2011-06-28T03:37:32Z","isPatch":true,"sender":{"key":"e@80x24.org","avatar":null},"body":"Michael Haggerty <mhagger@alum.mit.edu> wrote:\n> I don't believe the extra \"git rev-parse\" invocation to be a\n> performance problem, but I am not familiar enough with the code to be\n> certain.\n\nIt shouldn't be a problem.  Sam Vilain did all the merge tracking code,\nbut this looks entirely reasonable.\n\n> Michael Haggerty (3):\n>   git-svn: Demonstrate a bug with root commits in mergeinfo ranges\n>   git-svn: Disambiguate rev-list arguments to improve error message\n>   git-svn: Correctly handle root commits in mergeinfo ranges\n\nThanks Michael.\n\nAll acked and pushed to \"master\" for Junio at git://bogomips.org/git-svn\nThese should go to maint, too.\n\n-- \nEric Wong\n"}]}