Skip to content

Conversation

@dscho
Copy link
Member

@dschodscho commented Nov 29, 2025

Cc: Toon Claes [email protected]
cc: Derrick Stolee [email protected]

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 fixesgit-for-windows#5978 Signed-off-by: Johannes Schindelin <[email protected]>
@dschodschoforce-pushed the last-modified-vs-sparse-checkouts branch from a430cf4 to 7040ae9CompareNovember 29, 2025 10:00
@dscho
Copy link
MemberAuthor

/submit

@gitgitgadget
Copy link

Submitted as [email protected]

To fetch this version into FETCH_HEAD:

git fetch https://github.com/gitgitgadget/git/ pr-2013/dscho/last-modified-vs-sparse-checkouts-v1 

To fetch this version to local tag pr-2013/dscho/last-modified-vs-sparse-checkouts-v1:

git fetch --no-tags https://github.com/gitgitgadget/git/ tag pr-2013/dscho/last-modified-vs-sparse-checkouts-v1 

@gitgitgadget
Copy link

On the Git mailing list, Derrick Stolee wrote (reply to this):

On 11/29/2025 8:43 AM, Johannes Schindelin via GitGitGadget wrote: > From: Johannes Schindelin <[email protected]>>> 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.> 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); I'm intrigued that this is the only fix that was required. > +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 Would we expect this to work without the '--'? Should it fail for a directory that exists at HEAD but is outside of the sparse-checkout? Thanks, -Stolee 

@gitgitgadget
Copy link

User Derrick Stolee <[email protected]> has been added to the cc: list.

@gitgitgadget
Copy link

On the Git mailing list, Toon Claes wrote (reply to this):

Derrick Stolee <[email protected]> writes: > On 11/29/2025 8:43 AM, Johannes Schindelin via GitGitGadget wrote:>> From: Johannes Schindelin <[email protected]>>> >> 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.>>> 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);>> I'm intrigued that this is the only fix that was required. I like it! >> +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>> Would we expect this to work without the '--'? Should it> fail for a directory that exists at HEAD but is outside of> the sparse-checkout? I don't think we need to complicate things that much. Arguments after the '--' are handled as pathspecs. If no paths match that pathspec, the output is simply nothing. Just to demonstrate: On 'master': $ git last-modified a fatal: ambiguous argument 'a': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' $ git last-modified -- a fatal: ambiguous argument 'a': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' With this patch applied: $ git last-modified a fatal: ambiguous argument 'a': unknown revision or path not in the working tree. Use '--' to separate paths from revisions, like this: 'git <command> [<revision>...] -- [<file>...]' $ git last-modified -- a $ echo $? 0 I agree this behavior is better. Thanks for this fix. I approve. --  Cheers, Toon

@gitgitgadget
Copy link

This branch is now known as js/last-modified-with-sparse-checkouts.

@gitgitgadget
Copy link

This patch series was integrated into seen via git@4401d0d.

@gitgitgadget
Copy link

This patch series was integrated into next via git@f1d5abd.

@gitgitgadget
Copy link

There was a status update in the "New Topics" section about the branch js/last-modified-with-sparse-checkouts on the Git mailing list:

"git last-modified" used to mishandle "--" to mark the beginning of pathspec, which has been corrected. Will merge to 'master'. source: <[email protected]> 

@gitgitgadget
Copy link

This patch series was integrated into seen via git@f46a05b.

@gitgitgadget
Copy link

There was a status update in the "Cooking" section about the branch js/last-modified-with-sparse-checkouts on the Git mailing list:

"git last-modified" used to mishandle "--" to mark the beginning of pathspec, which has been corrected. Will merge to 'master'. source: <[email protected]> 

@gitgitgadget
Copy link

This patch series was integrated into seen via git@5bb758a.

@gitgitgadget
Copy link

This patch series was integrated into seen via git@b61aed6.

@gitgitgadget
Copy link

This patch series was integrated into seen via git@9d302ab.

@gitgitgadget
Copy link

There was a status update in the "Cooking" section about the branch js/last-modified-with-sparse-checkouts on the Git mailing list:

"git last-modified" used to mishandle "--" to mark the beginning of pathspec, which has been corrected. Will merge to 'master'. source: <[email protected]> 

@gitgitgadget
Copy link

This patch series was integrated into seen via git@2178707.

Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant

@dscho