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

Re: checkout extra files

From
Junio C Hamano <gitster@pobox.com>
Date
Sep 4, 2012, 16:15 UTC
Message-ID
<7v8vcpdat2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vpq61dfn9.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 23 quoted lines
> Now we have f1 and f2 in the working tree.
>
>> $ git checkout e6f9 -- *
>
> That is the same as "git checkout e6f935e -- f1 f2", as the shell
> expanded "*" into "f1" and "f2".
>
>> error: pathspec 'f2' did not match any file(s) known to git.
>>
>> Note the error.
>
> Yes?
>
>> It is clear that the set of file names that git checkout is taking is
>> the union of the ones that
>> match the specified path ('*') in the work directory (gittest) with
>> the ones that match the
>> path in the specified commit (e6f9).
>
> The command tells git to check out "f1" and "f2" out of the tree of
> e6f935e, and git found "f1" but did not find "f2" and reported an
> error.  I do not see a room or need for "union" to come into the
> picture to explain what we see in the above transcript.

Actually, I "kind of sort of" can see where that "union" is coming from, if I squint my eyes hard enough.

Yes, it makes it look like the path affected has some relationship between two sets of paths:

 - set W, which consists of f1 and f2, that is the result of
   matching '*' against working tree files; and
 - set T, which consists of f1 (but not f2), that is the result of
   matching '*' against the tree contained in e6f935e
and the intersection of W and T (i.e. f1) is what is checked out.

But that is not what is happening at all. What goes on is far simpler than that.

 - the shell sees '*', matches it against working tree files, to
   obtain "f1" and "f2";
 - the shell tells "git" to "checkout e6f935e -- f1 f2";
 - "git" looks into the tree of e6f935e to find paths that match
   "f1" and "f2".

When "git" is run by the shell in the last step, it has _no_ clue that the end user typed "*" from the shell. It only sees "f1" and "f2" on the command line. There is no "set T" to be intersected with "set W", so stop thinking in those terms, and you will be fine.

Now the question is, _you_ will be fine, but can the documentation be updated in such a way so that it will help _others_ to also stop thinking about "intersection between set W and set T"? I do not have a good answer to that.

Previous: Junio C HamanoNext: Junio C Hamano
Message 10 of 36 in “checkout extra files”
  1. Angelo BorsottiSep 3, 2012
  2. Carlos Martín NietoSep 3, 2012
  3. Nguyen Thai Ngoc DuySep 3, 2012
  4. Junio C HamanoSep 3, 2012
  5. Nguyen Thai Ngoc DuySep 4, 2012
  6. Junio C HamanoSep 4, 2012
  7. Angelo BorsottiSep 4, 2012
  8. Junio C HamanoSep 4, 2012
  9. Junio C HamanoSep 4, 2012
  10. Junio C HamanoSep 4, 2012
  11. Junio C HamanoSep 7, 2012
  12. Philip OakleySep 8, 2012
  13. Junio C HamanoSep 9, 2012
  14. Matthieu MoySep 9, 2012
  15. Junio C HamanoSep 9, 2012
  16. Philip OakleySep 9, 2012
  17. Jeff KingSep 10, 2012
  18. Junio C HamanoSep 10, 2012
  19. Jeff KingSep 10, 2012
  20. Junio C HamanoSep 10, 2012
  21. 1/2 gitcli: formatting fixJunio C Hamano, Sep 10, 2012
  22. 2/2 gitcli: contrast wildcard given to shell and to gitJunio C Hamano, Sep 10, 2012
  23. Jeff KingSep 10, 2012
  24. Junio C HamanoSep 10, 2012
  25. Nguyen Thai Ngoc DuySep 4, 2012
  26. Junio C HamanoSep 4, 2012
  27. Carlos Martín NietoSep 3, 2012
  28. Carlos Martín NietoSep 4, 2012
  29. Angelo BorsottiSep 4, 2012
  30. Junio C HamanoSep 4, 2012
  31. Angelo BorsottiSep 4, 2012
  32. Junio C HamanoSep 4, 2012
  33. Philip OakleySep 4, 2012
  34. Junio C HamanoSep 4, 2012
  35. Junio C HamanoSep 8, 2012
  36. Junio C HamanoSep 10, 2012

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.