]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Meta/cook: grab the initial topic description from merges to seen
authorJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2026 22:02:49 +0000 (15:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Mar 2026 22:02:49 +0000 (15:02 -0700)
cook

diff --git a/cook b/cook
index fd7181b8f702a455ba5aa09eff6442630ebb099a..61dfc7a8273e2b9d32446a432a52da5559946633 100755 (executable)
--- a/cook
+++ b/cook
@@ -54,6 +54,35 @@ sub describe_relation {
        return "(this branch " . join("; ", @desc) . ".)";
 }
 
+sub desc_from_merge {
+       my ($topic) = @_;
+       my ($fh, $accum);
+       open($fh, '-|',
+            qw(git cat-file commit), "seen^{/^Merge branch '$topic' into }")
+           or return undef;
+       $accum = undef;
+
+       while (<$fh>) {
+               if (!defined $accum) {
+                       $accum = "" if (/^Merge branch '$topic' into /);
+                       next;
+               }
+               last if (/^\* /);
+               next if ($accum eq "" && /^\s*$/);
+               $accum .= " $_";
+       }
+       for ($accum) {
+               s/^\s+//s;
+               s/\s*$//s;
+               if ($accum eq "") {
+                       $_ = undef;
+               } else {
+                       $_ = "\n $_";
+               }
+       }
+       return $accum;
+}
+
 sub forks_from {
        my ($topic, $fork, $forkee, @overlap) = @_;
        my %ovl = map { $_ => 1 } (@overlap, @{$topic->{$forkee}{'log'}});
@@ -779,6 +808,10 @@ sub merge_cooking {
                                push @new_topic, $topic;
                                # lazily find the source for a new topic.
                                $current->{$topic}{'src'} = join("\n", get_source($topic));
+                               my $summary = desc_from_merge($topic);
+                               if (defined $summary) {
+                                       $current->{$topic}{'desc'} .= "\n$summary";
+                               }
                        }
                        next;
                }