]> git.ipfire.org Git - thirdparty/git.git/commitdiff
revision: move -L setup before output_format-to-diff derivation
authorMichael Montalbo <mmontalbo@gmail.com>
Mon, 25 May 2026 19:40:56 +0000 (19:40 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 25 May 2026 22:57:49 +0000 (07:57 +0900)
The line_level_traverse block sets a default DIFF_FORMAT_PATCH when
no output format has been explicitly requested.  This default must
be visible to the "Did the user ask for any diff output?" check
that derives revs->diff from revs->diffopt.output_format.

Currently the -L block runs after that derivation, so revs->diff
stays 0 when no explicit format is given.  This does not matter yet
because log_tree_commit() short-circuits into line_log_print()
before consulting revs->diff, but the next commit will route -L
through the normal log_tree_diff() path, which checks revs->diff.

Move the block above the derivation so the default DIFF_FORMAT_PATCH
is in place when revs->diff is computed.  No behavior change on its
own.

Signed-off-by: Michael Montalbo <mmontalbo@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
revision.c

index 599b3a66c369ca3b0099311250cf758788fdf6ce..4a8e24bc38d572aa2b9e47baa0f25194341c3a29 100644 (file)
@@ -3112,6 +3112,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
                object_context_release(&oc);
        }
 
+       if (revs->line_level_traverse) {
+               if (want_ancestry(revs))
+                       revs->limited = 1;
+               revs->topo_order = 1;
+               if (!revs->diffopt.output_format)
+                       revs->diffopt.output_format = DIFF_FORMAT_PATCH;
+       }
+
        /* Did the user ask for any diff output? Run the diff! */
        if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
                revs->diff = 1;
@@ -3125,14 +3133,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
        if (revs->diffopt.objfind)
                revs->simplify_history = 0;
 
-       if (revs->line_level_traverse) {
-               if (want_ancestry(revs))
-                       revs->limited = 1;
-               revs->topo_order = 1;
-               if (!revs->diffopt.output_format)
-                       revs->diffopt.output_format = DIFF_FORMAT_PATCH;
-       }
-
        if (revs->topo_order && !generation_numbers_enabled(the_repository))
                revs->limited = 1;