git/list[1] front-page[2] threads[3] people[4] search[5] about
 

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
Previous: René ScharfeNext: René Scharfe
Message 8 of 11 in “Possible bug with git restore”
  1. Sergii ShkarnikovAug 12, 2020
  2. Eric SunshineAug 14, 2020
  3. Sergii ShkarnikovAug 20, 2020
  4. Jeff KingAug 20, 2020
  5. René ScharfeAug 20, 2020
  6. Jeff KingAug 20, 2020
  7. checkout, restore: make pathspec recursiveRené Scharfe, Aug 22, 2020
  8. Jeff KingAug 24, 2020
  9. René ScharfeAug 22, 2020
  10. Jeff KingAug 24, 2020
  11. Junio C HamanoAug 22, 2020

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.