]> mj.ucw.cz Git - git-tools.git/commitdiff
Update2: Recognize merges this->another in addition to another->this
authorMartin Mares <mj@ucw.cz>
Mon, 16 Jul 2012 18:07:35 +0000 (20:07 +0200)
committerMartin Mares <mj@ucw.cz>
Mon, 16 Jul 2012 18:07:35 +0000 (20:07 +0200)
This is useful whenever somebody merges two branches and pushes the
result to both of them.

However, both branches must be local. When "git pull" merges with
a remote tracking branch, the commit message includes the name
of the remote, so our test does not trigger (intentionally).

update2

diff --git a/update2 b/update2
index 093919fe270224adc2f989d593d0a3731e9ea8da..52124108b8cd9fd1b3e3af77e648fef531f86ccb 100755 (executable)
--- a/update2
+++ b/update2
@@ -112,10 +112,10 @@ if ($old =~ /^0+$/) {
                my $n0 = $nonmerges[0];
                my $c0p = $c0->{parents};
                if (@{$c0p} == 2 &&
                my $n0 = $nonmerges[0];
                my $c0p = $c0->{parents};
                if (@{$c0p} == 2 &&
-                   $c0->{subject} =~ m{^\s*Merge branch '([^']*)'} &&
-                   $1 ne $ref &&
-                   ($c0p->[0] eq $old || $c0p->[1] eq $old)) {
-                       # Pushed a merge of a foreign branch to the current one
+                   ($c0p->[0] eq $old || $c0p->[1] eq $old) &&
+                   $c0->{subject} =~ m{^\s*Merge branch '([^']*)' into (\S+)} &&
+                   (($1 eq $ref) != ($2 eq $ref))) {
+                       # Pushed a merge of the current branch with another local branch
                        $subj .= ' ' . $c0->{subject};
                } elsif ($n0) {
                        # Otherwise take the subject of the first non-merge commit
                        $subj .= ' ' . $c0->{subject};
                } elsif ($n0) {
                        # Otherwise take the subject of the first non-merge commit