From: Junio C Hamano Date: Mon, 12 Mar 2012 17:36:13 +0000 (-0700) Subject: Meta/Reintegrate: propagate branch description from whats-cooking.txt X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=052051e5b11181e32ccd4122efa4b0bada642866;p=thirdparty%2Fgit.git Meta/Reintegrate: propagate branch description from whats-cooking.txt --- diff --git a/Reintegrate b/Reintegrate index bcacea62b1..f56214fc43 100755 --- a/Reintegrate +++ b/Reintegrate @@ -18,6 +18,51 @@ do shift done +annotate_merge () { + test -f Meta/whats-cooking.txt || return 0 + + perl -e ' + my ($branch) = $ARGV[0]; + my ($in_section) = 0; + my @msg = (); + while () { + if (/^\* $branch /) { + $in_section = 1; + next; + } + if (/^[-*\[]/) { + last if $in_section; + } + next unless $in_section; + next if (/^ /); + push @msg, $_; + } + + if ($in_section && @msg) { + open(my $fh, "-|", qw(git cat-file commit HEAD)); + my @original = (<$fh>); + my @final; + $in_section = 0; + for (@original) { + if (!$in_section) { + $in_section = 1 if (/^$/); + next; + } + push @final, $_; + if (/^$/ && $in_section == 1) { + push @final, @msg; + push @final, "\n"; + $in_section = 2; + } + } + close $fh; + open($fh, "|-", qw(git commit --amend -F -)); + print $fh @final; + close $fh; + } + ' &2 "* $branch" + save=$(git rev-parse --verify HEAD) + tip=$(git rev-parse --verify "$branch^0") + mb=$(git merge-base "$tip" "$save") + test "$mb" = "$tip" && continue - echo >&2 "* $branch" git merge $accept_rerere --no-edit "$branch" || accept_rerere || exit + annotate_merge "$branch" || exit + this=$(git rev-parse --verify HEAD) if test "$this" = "$save" then