{"thread":{"id":"1527","subject":"Mergeback patch - (was: Switching heads and head vs branch after CVS import)","startedAt":"2005-08-15T20:50:04Z","lastAt":"2005-08-15T20:50:04Z","messageCount":1,"participants":["Martin Langhoff"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"7315","messageId":"46a038f90508151350675527e7@mail.gmail.com","threadId":"1527","inReplyTo":"20050815204511.B6D793300AD@ng.eduforge.org","subject":"Mergeback patch - (was: Switching heads and head vs branch after CVS import)","fromName":"Martin Langhoff","fromEmail":"martin.langhoff@gmail.com","sentAt":"2005-08-15T20:50:04Z","receivedAt":"2005-08-15T20:50:04Z","isPatch":false,"sender":{"key":"martin.langhoff@gmail.com","avatar":"https://gravatar.com/avatar/1e3f311b6c4c15836501901ca58f8c0b0667246488084ba524d8bc9867e22fd9?d=mp&s=160"},"body":"Just a work-in-progress sample. I've done a pretty successful import\nof a small tree with this patch. It is showing the merges /almost/ in\nthe right place. The almost is due to bad cvs practices, and not this\ncode.\n\nDefinitely doable, though it'll never be \"nice\" -- CVS doesn't have\nthe right data for this. I want to make the regexes configurable, and\nhave a more decent way of extracting the parent sha. B\n\ndiff --git a/git-cvsimport-script b/git-cvsimport-script\n--- a/git-cvsimport-script\n+++ b/git-cvsimport-script\n@@ -542,6 +542,24 @@ my $commit = sub {\n\n                my @par = ();\n                @par = (\"-p\",$parent) if $parent;\n+\n+               # detect additional branches\n+               my @rx = ( qr/Merged from (\\w+)/i , qr/merge of (\\w+)/i );\n+               foreach my $rx (@rx) {\n+                   if ($logmsg =~ $rx) {\n+                       my $parent = $1;\n+                       if ($parent eq 'HEAD') { $parent = 'origin'};\n+                       if ( -e \"$git_dir/refs/heads/$parent\") {\n+                           warn \"grabbing $parent\";\n+                           $parent = `cat $git_dir/refs/heads/$parent`;\n+                           chomp $parent;\n+                           warn \"grabbed $parent\";\n+                           push @par, '-p', $parent;\n+                       }\n+                   }\n+               }\n+               # %seen_branches\n+\n                exec(\"env\",\n                        \"GIT_AUTHOR_NAME=$author\",\n                        \"GIT_AUTHOR_EMAIL=$author\",\n"}]}