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
@@ -18,6 +18,51 @@ do
18
shift
19
done
20
21
+annotate_merge () {
22
+ test -f Meta/whats-cooking.txt || return 0
23
+
24
+ perl -e '
25
+ my ($branch) = $ARGV[0];
26
+ my ($in_section) = 0;
27
+ my @msg = ();
28
+ while (<STDIN>) {
29
+ if (/^\* $branch /) {
30
+ $in_section = 1;
31
+ next;
32
+ }
33
+ if (/^[-*\[]/) {
34
+ last if $in_section;
35
+ }
36
+ next unless $in_section;
37
+ next if (/^ /);
38
+ push @msg, $_;
39
+ }
40
+
41
+ if ($in_section && @msg) {
42
+ open(my $fh, "-|", qw(git cat-file commit HEAD));
43
+ my @original = (<$fh>);
44
+ my @final;
45
+ $in_section = 0;
46
+ for (@original) {
47
+ if (!$in_section) {
48
+ $in_section = 1 if (/^$/);
49
+ next;
50
+ }
51
+ push @final, $_;
52
+ if (/^$/ && $in_section == 1) {
53
+ push @final, @msg;
54
+ push @final, "\n";
55
+ $in_section = 2;
56
+ }
57
+ }
58
+ close $fh;
59
+ open($fh, "|-", qw(git commit --amend -F -));
60
+ print $fh @final;
61
+ close $fh;
62
+ }
63
+ ' <Meta/whats-cooking.txt "$1"
64
+}
65
+
66
case "$generate" in
67
no)
68
accept_rerere () {
@@ -37,13 +82,19 @@ no)
82
case "$branch" in '#'* | '') continue ;; esac
83
case "$eh" in
84
"" | "#"*)
85
+ echo >&2 "* $branch"
86
+
87
save=$(git rev-parse --verify HEAD)
88
+ tip=$(git rev-parse --verify "$branch^0")
89
+ mb=$(git merge-base "$tip" "$save")
90
+ test "$mb" = "$tip" && continue
91
42
- echo >&2 "* $branch"
92
git merge $accept_rerere --no-edit "$branch" ||
93
accept_rerere ||
94
exit
95
96
+ annotate_merge "$branch" || exit
97
+
98
this=$(git rev-parse --verify HEAD)
99
if test "$this" = "$save"
100
then