@@ -4196,37 +4196,39 @@ static timestamp_t comparison_date(const struct rev_info *revs,
41964196 commit -> date ;
41974197}
41984198
4199- enum commit_action get_commit_action (struct rev_info * revs , struct commit * commit )
4199+ /*
4200+ * Whether the commit is ignored by the cheap checks that read only its
4201+ * traversal flags and pack membership (e.g. already shown, or marked
4202+ * uninteresting), before any check that examines the commit's date,
4203+ * parents, message, or diff.
4204+ */
4205+ static int commit_early_ignore (struct rev_info * revs , struct commit * commit )
42004206{
42014207 if (commit -> object .flags & SHOWN )
4202- return commit_ignore ;
4208+ return 1 ;
42034209 if (revs -> maximal_only && (commit -> object .flags & CHILD_VISITED ))
4204- return commit_ignore ;
4210+ return 1 ;
42054211 if (revs -> unpacked && has_object_pack (revs -> repo , & commit -> object .oid ))
4206- return commit_ignore ;
4207- if (revs -> no_kept_objects ) {
4208- if (has_object_kept_pack (revs -> repo , & commit -> object .oid ,
4209- revs -> keep_pack_cache_flags ))
4210- return commit_ignore ;
4211- }
4212+ return 1 ;
4213+ if (revs -> no_kept_objects &&
4214+ has_object_kept_pack (revs -> repo , & commit -> object .oid ,
4215+ revs -> keep_pack_cache_flags ))
4216+ return 1 ;
42124217 if (commit -> object .flags & UNINTERESTING )
4218+ return 1 ;
4219+ return 0 ;
4220+ }
4221+
4222+ /*
4223+ * Decide whether this commit is shown or ignored. Keep it a pure
4224+ * predicate: callers such as the commit graph depend on it having no
4225+ * side effects, so per-commit mutations (such as -L range tracking)
4226+ * belong in the caller, simplify_commit(), not here.
4227+ */
4228+ enum commit_action get_commit_action (struct rev_info * revs , struct commit * commit )
4229+ {
4230+ if (commit_early_ignore (revs , commit ))
42134231 return commit_ignore ;
4214- if (revs -> line_level_traverse && !want_ancestry (revs )) {
4215- /*
4216- * In case of line-level log with parent rewriting
4217- * prepare_revision_walk() already took care of all line-level
4218- * log filtering, and there is nothing left to do here.
4219- *
4220- * If parent rewriting was not requested, then this is the
4221- * place to perform the line-level log filtering. Notably,
4222- * this check, though expensive, must come before the other,
4223- * cheaper filtering conditions, because the tracked line
4224- * ranges must be adjusted even when the commit will end up
4225- * being ignored based on other conditions.
4226- */
4227- if (!line_log_process_ranges_arbitrary_commit (revs , commit ))
4228- return commit_ignore ;
4229- }
42304232 if (revs -> min_age != -1 &&
42314233 comparison_date (revs , commit ) > revs -> min_age )
42324234 return commit_ignore ;
@@ -4335,7 +4337,23 @@ struct commit_list *get_saved_parents(struct rev_info *revs, const struct commit
43354337
43364338enum commit_action simplify_commit (struct rev_info * revs , struct commit * commit )
43374339{
4338- enum commit_action action = get_commit_action (revs , commit );
4340+ enum commit_action action ;
4341+
4342+ /*
4343+ * For a line-level log without parent rewriting, fold each commit's
4344+ * ranges as the walk reaches it (parent rewriting does this eagerly in
4345+ * prepare_revision_walk()). Fold before get_commit_action() so the
4346+ * ranges carry across a commit that a later, cheaper check ignores;
4347+ * the commit_early_ignore() guard skips a commit get_commit_action()
4348+ * would ignore outright.
4349+ */
4350+ if (revs -> line_level_traverse && !want_ancestry (revs ) &&
4351+ !commit_early_ignore (revs , commit )) {
4352+ if (!line_log_process_ranges_arbitrary_commit (revs , commit ))
4353+ return commit_ignore ;
4354+ }
4355+
4356+ action = get_commit_action (revs , commit );
43394357
43404358 if (action == commit_show &&
43414359 revs -> prune && revs -> dense && want_ancestry (revs )) {
0 commit comments