public inbox for git@vger.kernel.org
 help / color / mirror / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Toon Claes <toon@iotcl.com>
Cc: git@vger.kernel.org,
	 Kristoffer Haugsbakk <kristofferhaugsbakk@fastmail.com>,
	 Gusted <gusted@codeberg.org>
Subject: Re: [PATCH v2 5/5] last-modified: change default max-depth to 0
Date: Fri, 16 Jan 2026 10:55:22 -0800	[thread overview]
Message-ID: <xmqq1pjp8k11.fsf@gitster.g> (raw)
In-Reply-To: <20260116-toon-last-modified-zzzz-v2-5-79e44f2806fe@iotcl.com> (Toon Claes's message of "Fri, 16 Jan 2026 14:22:53 +0100")

Toon Claes <toon@iotcl.com> writes:

> diff --git a/Documentation/git-last-modified.adoc b/Documentation/git-last-modified.adoc
> index a3992db3f2..57136baf3b 100644
> --- a/Documentation/git-last-modified.adoc
> +++ b/Documentation/git-last-modified.adoc
> @@ -27,6 +27,7 @@ OPTIONS
>  `--recursive`::
>  	Instead of showing tree entries, step into subtrees and show all entries
>  	inside them recursively.
> +	This is identical as setting `--max-depth=-1`.

When I heard that the default value of max-depth will be 0, the
first thing I wondered was "how would I spell unlimited in the new
world order?", and the documentation for "--max-depth", not
"--recursive", would have been the place I expected to fish for
necessary information.

Over there, there is "A negative value means no limit", so saying
"identical as setting --max-depth to a negative value" here would
match the description over there better, or the user will be left
wonderign if "-1" is merely an example that is negative, or if it is
more special than other negative values and if so in what way.

> @@ -36,7 +37,7 @@ OPTIONS
>  `--max-depth=<depth>`::
>  	For each pathspec given on the command line, descend at most `<depth>`
>  	levels of directories. A negative value means no limit.
> -	Setting a positive value implies `--recursive`.
> +	The default depth is 0.
>  	Cannot be combined with wildcards in the pathspec.

> diff --git a/builtin/last-modified.c b/builtin/last-modified.c
> index 842700bc6a..a10e711beb 100644
> --- a/builtin/last-modified.c
> +++ b/builtin/last-modified.c
> @@ -481,14 +481,10 @@ static int last_modified_init(struct last_modified *lm, struct repository *r,
>  	lm->rev.no_commit_id = 1;
>  	lm->rev.diff = 1;
>  	lm->rev.diffopt.flags.no_recursive_diff_tree_combined = 1;
> -	lm->rev.diffopt.flags.recursive = lm->recursive;
> +	lm->rev.diffopt.flags.recursive = 1;

Hmph, so this will always be recursive?

>  	lm->rev.diffopt.flags.tree_in_recursive = lm->show_trees;
> +	lm->rev.diffopt.max_depth = lm->max_depth;
> +	lm->rev.diffopt.max_depth_valid = !lm->recursive && lm->max_depth >= 0;

Not saying --recursive would keep lm->recursive==0 and non-negative
value of --max-depth will flip max_depth_valid on.  Saying
"--recursive" or giving a negative "--max-value" would make
max_depth_valid false, and it allows traversal all the way down to
leaves.

It may be correct, but feels quite convoluted.  I wonder if we can
get rid of lm->recursive altogether now as a clean-up, and have
"--recursive" truly do what the documentation claimed is equivalent
earlier, i.e. OPT_SET_INT(0, "recursive", &lm.max_depth, -1).  Would
that simplify the logic a bit and make it easier to reason about the
logic around here, I wonder?


  reply	other threads:[~2026-01-16 18:55 UTC|newest]

Thread overview: 36+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-11-26  6:09 [PATCH 0/3] Expand and enhance git-last-modified(1) documentation Toon Claes
2025-11-26  6:09 ` [PATCH 1/3] last-modified: handle and document NUL termination Toon Claes
2025-11-26 13:03   ` Karthik Nayak
2025-11-26 16:57   ` Junio C Hamano
2025-11-28 18:50     ` Toon Claes
2025-12-01 10:32       ` Patrick Steinhardt
2025-11-26  6:09 ` [PATCH 2/3] last-modified: document option --max-depth Toon Claes
2025-11-26 13:31   ` Karthik Nayak
2026-01-16 12:13     ` Toon Claes
2025-11-26 19:49   ` Junio C Hamano
2025-11-28 18:51     ` Toon Claes
2025-11-26  6:09 ` [PATCH 3/3] last-modified: better document how depth in handled Toon Claes
2025-11-26 17:38   ` Eric Sunshine
2025-12-01 10:32   ` Patrick Steinhardt
2025-12-02 11:01     ` Toon Claes
2025-12-02 17:14       ` Patrick Steinhardt
2026-01-16 13:22 ` [PATCH v2 0/5] Change git-last-modified(1) default behavior and add documentation Toon Claes
2026-01-16 13:22   ` [PATCH v2 1/5] last-modified: document NUL termination Toon Claes
2026-01-16 13:22   ` [PATCH v2 2/5] last-modified: add option '-z' to help output Toon Claes
2026-01-16 18:31     ` Junio C Hamano
2026-01-16 13:22   ` [PATCH v2 3/5] last-modified: document option --max-depth Toon Claes
2026-01-16 13:22   ` [PATCH v2 4/5] last-modified: add option '--max-depth' to help output Toon Claes
2026-01-16 18:42     ` Junio C Hamano
2026-01-16 13:22   ` [PATCH v2 5/5] last-modified: change default max-depth to 0 Toon Claes
2026-01-16 18:55     ` Junio C Hamano [this message]
2026-01-16 13:34   ` [PATCH v2 0/5] Change git-last-modified(1) default behavior and add documentation Kristoffer Haugsbakk
2026-01-20 10:44     ` Toon Claes
2026-01-20 21:47   ` [PATCH v3 0/4] " Toon Claes
2026-01-20 21:47     ` [PATCH v3 1/4] last-modified: clarify in the docs the command takes a pathspec Toon Claes
2026-01-20 21:47     ` [PATCH v3 2/4] last-modified: document option '-z' Toon Claes
2026-01-20 21:47     ` [PATCH v3 3/4] last-modified: document option '--max-depth' Toon Claes
2026-01-20 21:47     ` [PATCH v3 4/4] last-modified: change default max-depth to 0 Toon Claes
2026-01-25 11:24       ` Kristoffer Haugsbakk
2026-01-21 18:40     ` [PATCH v3 0/4] Change git-last-modified(1) default behavior and add documentation Junio C Hamano
2026-02-03  9:58       ` Karthik Nayak
2026-02-03 17:42         ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqq1pjp8k11.fsf@gitster.g \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gusted@codeberg.org \
    --cc=kristofferhaugsbakk@fastmail.com \
    --cc=toon@iotcl.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox