revision: move -L setup before output_format-to-diff derivation

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>

Michael Montalbo committed May 28, 2026 at 20:47 UTC 558057cf4f43ea3b28c5e0b1b2250cab362f1a6a
1 file changed +8 -8
revision.c
+8 -8
@@ -3112,6 +3112,14 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
3112 object_context_release(&oc);
3113 }
3114
3115 + if (revs->line_level_traverse) {
3116 + if (want_ancestry(revs))
3117 + revs->limited = 1;
3118 + revs->topo_order = 1;
3119 + if (!revs->diffopt.output_format)
3120 + revs->diffopt.output_format = DIFF_FORMAT_PATCH;
3121 + }
3122 +
3123 /* Did the user ask for any diff output? Run the diff! */
3124 if (revs->diffopt.output_format & ~DIFF_FORMAT_NO_OUTPUT)
3125 revs->diff = 1;
@@ -3125,14 +3133,6 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s
3133 if (revs->diffopt.objfind)
3134 revs->simplify_history = 0;
3135
3128 - if (revs->line_level_traverse) {
3129 - if (want_ancestry(revs))
3130 - revs->limited = 1;
3131 - revs->topo_order = 1;
3132 - if (!revs->diffopt.output_format)
3133 - revs->diffopt.output_format = DIFF_FORMAT_PATCH;
3134 - }
3135 -
3136 if (revs->topo_order && !generation_numbers_enabled(the_repository))
3137 revs->limited = 1;
3138