Meta/Reintegrate: propagate branch description from whats-cooking.txt
Junio C Hamano committed
Mar 12, 2012 at 10:36 UTC
052051e5b11181e32ccd4122efa4b0bada642866
1 file changed
+52
-1
Reintegrate
+52
-1
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 (<STDIN>) {
+ 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;
+ }
+ ' <Meta/whats-cooking.txt "$1"
+}
+
case "$generate" in
no)
accept_rerere () {
@@ -37,13 +82,19 @@ no)
case "$branch" in '#'* | '') continue ;; esac
case "$eh" in
"" | "#"*)
+ echo >&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