Skip to content

Commit 8473b7f

Browse files
committed
Add a --non-master-only option to git_changelog.
This has the inverse effect of --master-only. It's needed to help find cases where a commit should not be described in major release notes because it was back-patched into older branches, though not at the same time as the HEAD commit.
1 parent 6376a16 commit 8473b7f

File tree

1 file changed

+29
-7
lines changed

1 file changed

+29
-7
lines changed

src/tools/git_changelog

Lines changed: 29 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,14 @@
3737
# git show $(git merge-base REL9_5_STABLE master)
3838
# where the branch to mention is the previously forked-off branch. This
3939
# shows the last commit before that branch was made.
40+
#
41+
# Note that --master-only is an imperfect filter, since it will not detect
42+
# cases where a HEAD patch was back-patched awhile later or with a slightly
43+
# different commit message. To find such cases, it's a good idea to look
44+
# through the output of
45+
# git_changelog --non-master-only --oldest-first --since='start-date'
46+
# and then remove anything from the --master-only output that would be
47+
# duplicative.
4048

4149

4250
use strict;
@@ -62,6 +70,7 @@ my $brief = 0;
6270
my $details_after = 0;
6371
my $post_date = 0;
6472
my $master_only = 0;
73+
my $non_master_only = 0;
6574
my $oldest_first = 0;
6675
my $since;
6776
my @output_buffer;
@@ -71,6 +80,7 @@ Getopt::Long::GetOptions(
7180
'brief' => \$brief,
7281
'details-after' => \$details_after,
7382
'master-only' => \$master_only,
83+
'non-master-only' => \$non_master_only,
7484
'post-date' => \$post_date,
7585
'oldest-first' => \$oldest_first,
7686
'since=s' => \$since) || usage();
@@ -236,10 +246,21 @@ while (1)
236246
my $winner =
237247
$all_commits_by_branch{$best_branch}->[ $position{$best_branch} ];
238248

239-
# check for master-only
240-
if (!$master_only
241-
|| ($winner->{'commits'}[0]->{'branch'} eq 'master'
242-
&& @{ $winner->{'commits'} } == 1))
249+
my $print_it = 1;
250+
if ($master_only)
251+
{
252+
$print_it = (@{ $winner->{'commits'} } == 1)
253+
&& ($winner->{'commits'}[0]->{'branch'} eq 'master');
254+
}
255+
elsif ($non_master_only)
256+
{
257+
foreach my $c (@{ $winner->{'commits'} })
258+
{
259+
$print_it = 0 if ($c->{'branch'} eq 'master');
260+
}
261+
}
262+
263+
if ($print_it)
243264
{
244265
output_details($winner) if (!$details_after);
245266
output_str("%s", $winner->{'message'} . "\n");
@@ -375,13 +396,14 @@ sub output_details
375396
sub usage
376397
{
377398
print STDERR <<EOM;
378-
Usage: git_changelog [--brief/-b] [--details-after/-d] [--master-only/-m] [--oldest-first/-o] [--post-date/-p] [--since=SINCE]
399+
Usage: git_changelog [--brief/-b] [--details-after/-d] [--master-only/-m] [--non-master-only/-n] [--oldest-first/-o] [--post-date/-p] [--since=SINCE]
379400
--brief Shorten commit descriptions, omitting branch identification
380401
--details-after Show branch and author info after the commit description
381-
--master-only Show commits made exclusively to the master branch
402+
--master-only Show only commits made just in the master branch
403+
--non-master-only Show only commits made just in back branches
382404
--oldest-first Show oldest commits first
383405
--post-date Show branches made after a commit occurred
384-
--since Print only commits dated since SINCE
406+
--since Show only commits dated since SINCE
385407
EOM
386408
exit 1;
387409
}

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy