Re: [PATCH] checkout, restore: make pathspec recursive
- From
Jeff King <peff@peff.net>
- Date
- Aug 24, 2020, 20:21 UTC
- Message-ID
- <20200824202111.GA709709@coredump.intra.peff.net>
- In-Reply-To
- <7c5144d8-24cd-0d50-a7c6-ff77160d503d@web.de>
On Sat, Aug 22, 2020 at 10:57:59AM +0200, René Scharfe wrote:
Show 14 quoted lines
> The pathspec given to git checkout and git restore is used with both > tree_entry_interesting (via read_tree_recursive) and match_pathspec > (via ce_path_match). The latter effectively only supports recursive > matching regardless of the value of the pathspec flag "recursive", > which is unset here. > > That causes different match results for pathspecs with wildcards, and > can lead checkout and restore in no-overlay mode to remove entries > instead of modifying them. Enable recursive matching for both checkout > and restore to make matching consistent. > > Setting the flag in checkout_main() technically also affects git switch, > but since that command doesn't accept pathspecs at all this has no > actual consequence.
Thanks, I think this is the thing to do (and the code change looks obviously correct ;) ).
This may cause a user-visible behavior change even in overlay mode (because we'll now match some tree entries that we wouldn't before). But I think it's an improvement, because it makes:
git checkout <tree> -- <paths>
consistent with:
git checkout -- <paths>
I don't know if you want to call that out more directly in the commit message.
-Peff