Thread (1 message) 1 message, 1 author, 2016-06-15

Mergeback patch - (was: Switching heads and head vs branch after CVS import)

From: Martin Langhoff <hidden>
Date: 2016-06-15 22:42:04
Subsystem: the rest · Maintainer: Linus Torvalds

Just a work-in-progress sample. I've done a pretty successful import
of a small tree with this patch. It is showing the merges /almost/ in
the right place. The almost is due to bad cvs practices, and not this
code.

Definitely doable, though it'll never be "nice" -- CVS doesn't have
the right data for this. I want to make the regexes configurable, and
have a more decent way of extracting the parent sha. B
diff --git a/git-cvsimport-script b/git-cvsimport-script
--- a/git-cvsimport-script
+++ b/git-cvsimport-script
@@ -542,6 +542,24 @@ my $commit = sub {

                my @par = ();
                @par = ("-p",$parent) if $parent;
+
+               # detect additional branches
+               my @rx = ( qr/Merged from (\w+)/i , qr/merge of (\w+)/i );
+               foreach my $rx (@rx) {
+                   if ($logmsg =~ $rx) {
+                       my $parent = $1;
+                       if ($parent eq 'HEAD') { $parent = 'origin'};
+                       if ( -e "$git_dir/refs/heads/$parent") {
+                           warn "grabbing $parent";
+                           $parent = `cat $git_dir/refs/heads/$parent`;
+                           chomp $parent;
+                           warn "grabbed $parent";
+                           push @par, '-p', $parent;
+                       }
+                   }
+               }
+               # %seen_branches
+
                exec("env",
                        "GIT_AUTHOR_NAME=$author",
                        "GIT_AUTHOR_EMAIL=$author",
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help