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

Re: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]

From
Daniel Barkalow <barkalow@iabervon.org>
Date
Dec 31, 2008, 05:21 UTC
Message-ID
<alpine.LNX.1.00.0812302356040.19665@iabervon.org>
In-Reply-To
<7v7i5hymp7.fsf@gitster.siamese.dyndns.org>
On Tue, 30 Dec 2008, Junio C Hamano wrote:
Show 21 quoted lines
> "Boyd Stephen Smith Jr." <bss@iguanasuicide.net> writes:
> 
> > On Tuesday 2008 December 30 20:30:46 Conor Rafferty wrote:
> >> MERCURIAL:
> >>
> >> Update
> >> hg update [-C] [-d DATE] [[-r] REV]
> >
> > Which is the role of "git checkout <branch>"
> >
> > "git checkout <branch> <paths>" is similar to "hg revert -r <branch> <paths>", 
> 
> No it is not.
> 
> The form of the command is makes this request:
> 
>     Please look into that named <tree-ish>, and check out the named
>     <paths> out of it to my work tree.  Because the reason I want them in
>     my work tree is so that I can include them as part of the next commit
>     I am preparing to create in the index, please update these paths in my
>     index while at it.

With that description, there's a bug: in addition to the above, it checks out from the index any path which does match the <paths> but isn't in <tree-ish>. I think the way to fix that would be to update the work tree from read_tree_some() instead of using the "if pathspec_match() ... checkout_entry()" loop over the index.

With the current code, you can have git check out a file that you've changed/deleted from a tree that doesn't contain it at all (and you get the index version). E.g.:

$ rm wt-status.c $ git checkout e83c5163316f89bfbde7d9ab23ca2e25604af290 wt-status.c $ ls wt-status.c wt-status.c

(instead, you should get an error if a <path> doesn't match anything in the <tree-ish> and only get those things that it matches in the <tree-ish>.)

I think I was too zealous sharing code back in February. I should have a patch by the weekend if nobody beats me to it. (And I still think that, if you hit this case, you must be confused, but git isn't helping by doing what it does.)

	-Daniel
*This .sig left intentionally blank*
Previous: Junio C HamanoNext: Junio C Hamano
Message 4 of 6 in “RE: for newbs = little exercise / tutorial / warmup for windows and other non-sophisticated new Git users :-) [Scanned]”
  1. Conor RaffertyDec 31, 2008
  2. Boyd Stephen Smith Jr.Dec 31, 2008
  3. Junio C HamanoDec 31, 2008
  4. Daniel BarkalowDec 31, 2008
  5. Junio C HamanoDec 31, 2008
  6. Boyd Stephen Smith Jr.Dec 31, 2008

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.