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

Re: Checkout file without changing index?

From
Junio C Hamano <gitster@pobox.com>
Date
Apr 25, 2019, 04:02 UTC
Message-ID
<xmqqv9z2ybob.fsf@gitster-ct.c.googlers.com>
In-Reply-To
<005b0aed-2c20-0c91-e4ad-98b0ec39359d@gmail.com>
Sitaram Chamarty <sitaramc@gmail.com> writes:
Show 6 quoted lines
> I'm not in a position to use either of those on at least some of my
> systems, but meanwhile, I thought I'd ask this: what is the difference
> between this and "git show REF:PATH > PATH", in terms of side-effects.
>
> (I.e., any differences other than looking cleaner, not having to repeat
> "PATH" etc.)
For that matter, what's the difference between these two and
	git cat-file --filters REF:PATH >PATH
;-)

I think the major difference is that checkout and restore are facing an end-user who is typing the command to the terminal interactively, so it does not make it easy to deposit the contents to an arbitrary path while taking pathspecs to allow multiple files to be checked out. On the other hand, these "get content for a single path out of the odb and then write it out to wherever I want to" may be more suited for scripting.

Between the two that are for the-content-at-a-single-path, I would further expect "git show REF:PATH" output would be less reliable over time, as we reserve the right to add frills to the output from the command to make it a more pleasant experience to humans (e.g. it is not totally inconceivable for the command to notice "ah, this is a JavaScript source file, so let's pass it through a syntax-aware highligher), as opposed to placing more emphasis on the byte for byte fidelity, which is desired for components used in scripts. Those who would want the latter should be using the plumbing cat-file.

Previous: Sitaram Chamarty
Message 6 of 6 in “Checkout file without changing index?”
  1. Piotr KrukowieckiApr 24, 2019
  2. Junio C HamanoApr 24, 2019
  3. Piotr KrukowieckiApr 24, 2019
  4. Philip OakleyApr 24, 2019
  5. Sitaram ChamartyApr 25, 2019
  6. Junio C HamanoApr 25, 2019

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.