Skip to content

Commit a430cf4

Browse files
committed
last-modified: support sparse checkouts
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 git-for-windows#5978 Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 9a2fb14 commit a430cf4

File tree

2 files changed

+10
-1
lines changed

2 files changed

+10
-1
lines changed

builtin/last-modified.c

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -525,7 +525,8 @@ int cmd_last_modified(int argc, const char **argv, const char *prefix,
525525

526526
argc = parse_options(argc, argv, prefix, last_modified_options,
527527
last_modified_usage,
528-
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT);
528+
PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT |
529+
PARSE_OPT_KEEP_DASHDASH);
529530

530531
repo_config(repo, git_default_config, NULL);
531532

t/t8020-last-modified.sh

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -227,4 +227,12 @@ test_expect_success 'last-modified complains about unknown arguments' '
227227
grep "unknown last-modified argument: --foo" err
228228
'
229229

230+
test_expect_success 'last-modified in sparse checkout' '
231+
test_when_finished "git sparse-checkout disable" &&
232+
git sparse-checkout set b &&
233+
check_last_modified -- a <<-\EOF
234+
3 a
235+
EOF
236+
'
237+
230238
test_done

0 commit comments

Comments
 (0)