Subject: Re: [PATCH] stash: disable literal treatment when passing top pathspec

From: Kyle Meyer <[email-masked]>
Date: Sat, 09 Apr 2022 00:10:32 -0400

Junio C Hamano writes:

> Kyle Meyer <[email-masked]> writes:
[...]
>>  * the 'git clean' call, triggered by --include-untracked, does not
>>    remove untracked files from the working tree
>>
>>  * the 'git checkout' call, triggered by --keep-index, fails with a
>>    message about ":/" not matching any known files, and the main
>>    command exits with a non-zero status
>>
>> Fix both of these spots by passing --no-literal-pathspecs to the
>> subprocess commands.
>
> Yuck (to the original problem, not to the proposed solution).
>
> I wonder if stopping to use ":/" (or using "." instead, if we need
> to give _some_ pathspec) is a better approach.  Don't we move to the
> top of the working tree by the time cmd_stash() is called and whatever
> subprocess we spawn via run_command() interface will start at the
> top anyway, no?

For the --keep-index/checkout case, yes, it looks like the command
starts from the top-level.  Passing "." as the pathspec to checkout
works fine, as far as I can tell.

However, for --include-untracked/clean case, the subprocess directory is
set to startup_info->original_cwd since 0fce211ccc (stash: do not
attempt to remove startup_info->original_cwd, 2021-12-09).