Meta/cook: grab the initial topic description from merges to seen
Junio C Hamano committed
Mar 20, 2026 at 15:02 UTC
cee488dff5d9851fd0135ca0540011b06e075e2d
1 file changed
+33
cook
+33
@@ -54,6 +54,35 @@ sub describe_relation {
54
return "(this branch " . join("; ", @desc) . ".)";
55
}
56
57
+sub desc_from_merge {
58
+ my ($topic) = @_;
59
+ my ($fh, $accum);
60
+ open($fh, '-|',
61
+ qw(git cat-file commit), "seen^{/^Merge branch '$topic' into }")
62
+ or return undef;
63
+ $accum = undef;
64
+
65
+ while (<$fh>) {
66
+ if (!defined $accum) {
67
+ $accum = "" if (/^Merge branch '$topic' into /);
68
+ next;
69
+ }
70
+ last if (/^\* /);
71
+ next if ($accum eq "" && /^\s*$/);
72
+ $accum .= " $_";
73
+ }
74
+ for ($accum) {
75
+ s/^\s+//s;
76
+ s/\s*$//s;
77
+ if ($accum eq "") {
78
+ $_ = undef;
79
+ } else {
80
+ $_ = "\n $_";
81
+ }
82
+ }
83
+ return $accum;
84
+}
85
+
86
sub forks_from {
87
my ($topic, $fork, $forkee, @overlap) = @_;
88
my %ovl = map { $_ => 1 } (@overlap, @{$topic->{$forkee}{'log'}});
@@ -779,6 +808,10 @@ sub merge_cooking {
808
push @new_topic, $topic;
809
# lazily find the source for a new topic.
810
$current->{$topic}{'src'} = join("\n", get_source($topic));
811
+ my $summary = desc_from_merge($topic);
812
+ if (defined $summary) {
813
+ $current->{$topic}{'desc'} .= "\n$summary";
814
+ }
815
}
816
next;
817
}