Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit7299778

Browse files
committed
Improve git_changelog's handling of inconsistent commit orderings.
Use the CommitDate not the AuthorDate, as the former is representative ofthe order in which things went into the main repository, and the latterisn't very; we now have instances where the AuthorDate is as much as amonth before the patch really went in. Also, get rid of the "commit orderinversions" heuristic, which turns out not to do anything very desirable.Instead we just print commits in strict timestamp order, interpreting the"timestamp" of a merged commit as its timestamp on the newest branch itappears in. This fixes some cases where very ancient commits were beingprinted relatively early in the report.
1 parent0f39d50 commit7299778

File tree

1 file changed

+7
-25
lines changed

1 file changed

+7
-25
lines changed

‎src/tools/git_changelog

Lines changed: 7 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -17,14 +17,9 @@
1717
# Most of the time, matchable commits occur in the same order on all branches,
1818
# and we print them out in that order. However, if commit A occurs before
1919
# commit B on branch X and commit B occurs before commit A on branch Y, then
20-
# there's no ordering which is consistent with both branches.
21-
#
22-
# When we encounter a situation where there's no single "best" commit to
23-
# print next, we print the one that involves the least distortion of the
24-
# commit order, summed across all branches. In the event of a tie on the
25-
# distortion measure (which is actually the common case: normally, the
26-
# distortion is zero), we choose the commit with latest timestamp. If
27-
# that's a tie too, the commit from the newer branch prints first.
20+
# there's no ordering which is consistent with both branches. In such cases
21+
# we sort a merged commit according to its timestamp on the newest branch
22+
# it appears in.
2823
#
2924

3025
use strict;
@@ -51,7 +46,7 @@ Getopt::Long::GetOptions('post-date' => \$post_date,
5146
'since=s'=> \$since) || usage();
5247
usage()if@ARGV;
5348

54-
my@git =qw(git log --date=iso);
49+
my@git =qw(git log --format=fuller --date=iso);
5550
push@git,'--since=' .$sinceifdefined$since;
5651

5752
# Collect the release tag data
@@ -117,7 +112,7 @@ for my $branch (@BRANCHES) {
117112
elsif ($line =~/^Author:\s+(.*)/) {
118113
$commit{'author'} =$1;
119114
}
120-
elsif ($line =~/^Date:\s+(.*)/) {
115+
elsif ($line =~/^CommitDate:\s+(.*)/) {
121116
$commit{'date'} =$1;
122117
}
123118
elsif ($line =~/^\s\s/) {
@@ -171,24 +166,13 @@ for my $branch (@BRANCHES) {
171166

172167
while (1) {
173168
my$best_branch;
174-
my$best_inversions;
175169
my$best_timestamp;
176170
formy$branch (@BRANCHES) {
177171
my$leader =$all_commits_by_branch{$branch}->[$position{$branch}];
178172
nextif !defined$leader;
179-
my$inversions = 0;
180-
formy$branch2 (@BRANCHES) {
181-
if (defined$leader->{'branch_position'}{$branch2}) {
182-
$inversions +=$leader->{'branch_position'}{$branch2}
183-
-$position{$branch2};
184-
}
185-
}
186-
if (!defined$best_inversions ||
187-
$inversions <$best_inversions ||
188-
($inversions ==$best_inversions &&
189-
$leader->{'timestamp'} >$best_timestamp)) {
173+
if (!defined$best_branch ||
174+
$leader->{'timestamp'} >$best_timestamp) {
190175
$best_branch =$branch;
191-
$best_inversions =$inversions;
192176
$best_timestamp =$leader->{'timestamp'};
193177
}
194178
}
@@ -203,8 +187,6 @@ while (1) {
203187
}
204188
printf" [%s]%s\n",substr($c->{'commit'}, 0, 9),$c->{'date'};
205189
}
206-
print"Commit-Order-Inversions:$best_inversions\n"
207-
if$best_inversions != 0;
208190
print"\n";
209191
print$winner->{'message'};
210192
print"\n";

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp