]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Documentation/build-docdep.perl: generate sorted output
authorSZEDER Gábor <szeder.dev@gmail.com>
Fri, 21 Oct 2022 10:29:50 +0000 (12:29 +0200)
committerJunio C Hamano <gitster@pobox.com>
Fri, 21 Oct 2022 18:39:38 +0000 (11:39 -0700)
To make sure that our manpages are rebuilt when any of the included
source files change and only the affected manpages are rebuilt,
'build-docdep.perl' scans our documentation source files for include
directives, and outputs 'make' dependencies to be included by
'Documentation/Makefile'.  This script relies on Perl's hash data
structures, and generates its output while iterating over them, and
since hashes in Perl are very much unordered, the output varies
greatly from run to run, both the order of targets and the order of
dependencies of each target.

This lack of ordering doesn't matter for 'make', because it cares
neither about the order of targets in a Makefile nor about the order
of a target's dependencies.  However, it does matter to developers
looking into build issues potentially involving these generated
dependencies, as it's rather hard to tell whether there are any
relevant (i.e. not order-only) changes among the dependencies compared
to the previous run.

So let's make 'build-docdep.perl's output stable and ordered by
sorting the keys of the hashes before iterating over them.

Signed-off-by: SZEDER Gábor <szeder.dev@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/build-docdep.perl

index ba4205e0302a267a5da6bef504f3e69eb0c4aa6d..1b3ac8fdd95fa1d57afbdffb1a9743f36ed22fdd 100755 (executable)
@@ -38,9 +38,10 @@ while ($changed) {
     }
 }
 
-while (my ($text, $included) = each %include) {
+foreach my $text (sort keys %include) {
+    my $included = $include{$text};
     if (! exists $included{$text} &&
        (my $base = $text) =~ s/\.txt$//) {
-       print "$base.html $base.xml : ", join(" ", keys %$included), "\n";
+       print "$base.html $base.xml : ", join(" ", sort keys %$included), "\n";
     }
 }