chiark / gitweb /
Test suite: tartree-edit: gitfetchinfo: Remerge on fetch
authorIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2016 10:34:03 +0000 (11:34 +0100)
committerIan Jackson <ijackson@chiark.greenend.org.uk>
Sat, 2 Jul 2016 10:35:35 +0000 (11:35 +0100)
When we unmerged some old A+B merged refs, make a note to merge them
again.  This saves the user calling gitfetchinfo-merge again.

tests/tartree-edit

index cdaade3..9fe06e6 100755 (executable)
@@ -129,6 +129,7 @@ tryat_gitfetchinfo () {
 
        git for-each-ref --format='%(refname)' refs/remotes >$play/l
        perl -w -ne '
+           our %remerge;
            use strict;
            chomp;
            next unless m#^refs/remotes/([^/]+)/#;
@@ -141,7 +142,12 @@ tryat_gitfetchinfo () {
            $remerge{"@ab"} = 1;
            print "update refs/remotes/$_/$rhs $old\n" or die $! foreach @ab;
            print "delete $old\n" or die $!;
-       ' <$play/l >$play/unmerge
+           END {
+               open REMERGE, ">&3" or die $!;
+               print REMERGE "$_\n" or die $! foreach sort keys %remerge;
+               close REMERGE or die $!;
+           }
+       ' <$play/l >$play/unmerge 3>$play/remerge
        git update-ref --stdin <$play/unmerge
 
        git remote remove "$remote" 2>/dev/null ||:
@@ -160,6 +166,15 @@ tryat_gitfetchinfo () {
        git fetch --no-tags "$remote" --refmap \
                +"refs/*:refs/remotes/$remote/*" \
                +"refs/*:refs/remotes/$remote/*"
+
+       exec 3<$play/remerge
+       # $play will be destroyed by what follows, but we have
+       # an fd open onto remerge, so this will work
+       while read <&3 a b; do
+             echo "Updating gitfetchinfo-merge $a $b"
+             "$0" gitfetchinfo-merge $a $b
+       done
+
        exit 0
 }