From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Toon Claes <toon@iotcl.com>,
Johannes Schindelin <johannes.schindelin@gmx.de>,
Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH] last-modified: support sparse checkouts
Date: Sat, 29 Nov 2025 13:43:46 +0000 [thread overview]
Message-ID: <pull.2013.git.1764423826908.gitgitgadget@gmail.com> (raw)
From: Johannes Schindelin <johannes.schindelin@gmx.de>
In a sparse checkout, a user might want to run `last-modified` on a
directory outside the worktree.
And even in non-sparse checkouts, a user might need to run that command
on a directory that does not exist in the worktree.
These use cases should be supported via the `--` separator between
revision and file arguments, which is even advertised in the
documentation. This patch fixes a tiny bug that prevents that from
working.
This fixes https://github.com/git-for-windows/git/issues/5978
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
last-modified: support sparse checkouts
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-2013%2Fdscho%2Flast-modified-vs-sparse-checkouts-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-2013/dscho/last-modified-vs-sparse-checkouts-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/2013
builtin/last-modified.c | 3 ++-
t/t8020-last-modified.sh | 8 ++++++++
2 files changed, 10 insertions(+), 1 deletion(-)
diff --git a/builtin/last-modified.c b/builtin/last-modified.c
index b0ecbdc540..dc1e229f4d 100644
--- a/builtin/last-modified.c
+++ b/builtin/last-modified.c
@@ -525,7 +525,8 @@ int cmd_last_modified(int argc, const char **argv, const char *prefix,
argc = parse_options(argc, argv, prefix, last_modified_options,
last_modified_usage,
- PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT);
+ PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT |
+ PARSE_OPT_KEEP_DASHDASH);
repo_config(repo, git_default_config, NULL);
diff --git a/t/t8020-last-modified.sh b/t/t8020-last-modified.sh
index a4c1114ee2..50f4312f71 100755
--- a/t/t8020-last-modified.sh
+++ b/t/t8020-last-modified.sh
@@ -78,6 +78,14 @@ test_expect_success 'last-modified subdir' '
EOF
'
+test_expect_success 'last-modified in sparse checkout' '
+ test_when_finished "git sparse-checkout disable" &&
+ git sparse-checkout set b &&
+ check_last_modified -- a <<-\EOF
+ 3 a
+ EOF
+'
+
test_expect_success 'last-modified subdir recursive' '
check_last_modified -r a <<-\EOF
3 a/b/file
base-commit: 9a2fb147f2c61d0cab52c883e7e26f5b7948e3ed
--
gitgitgadget
next reply other threads:[~2025-11-29 13:43 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-11-29 13:43 Johannes Schindelin via GitGitGadget [this message]
2025-11-30 20:00 ` [PATCH] last-modified: support sparse checkouts Derrick Stolee
2025-12-03 11:11 ` Toon Claes
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=pull.2013.git.1764423826908.gitgitgadget@gmail.com \
--to=gitgitgadget@gmail.com \
--cc=git@vger.kernel.org \
--cc=johannes.schindelin@gmx.de \
--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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.