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

Re: git-diff between /dev/null and blob

From
Jakub Narebski <jnareb@gmail.com>
Date
Aug 6, 2006, 21:02 UTC
Message-ID
<eb5ld6$36k$1@sea.gmane.org>
In-Reply-To
<7vmzaq9sjs.fsf@assigned-by-dhcp.cox.net>
Junio C Hamano wrote:
Show 10 quoted lines
> Jakub Narebski <jnareb@gmail.com> writes:
> 
>> Currently, due to artifact of git-diff argument parsing you can get diff 
>> of two arbitrary blobs given by their sha1 id, e.g.
>>   git diff ab8050ceb4e43522e858768cc2c02fcb91839370 fd05278808d458602587bb024a48726018d30926
> 
> Just FYI, it is pretty much by design not artifact to allow
> something like this:
> 
>       git diff master:Makefile next:Makefile
Which we could get using
        git diff master next -- Makefile
Currently ('next' branch) git-diff manpage talks only about comparing trees.
* When  no  <ent>  is given, the working tree and the index file is compared,
  using git-diff-files.
* When one <ent> is given, the working tree and the named tree  is  compared,
  using git-diff-index. The option --cached can be given to compare the index
  file and the named tree.
* When  two  <ent>s  are  given,  these  two   trees   are   compared   using
  git-diff-tree.

And the only way to compare blobs is by giving directly or indirectly (like above) sha1 of the blobs, i.e. only the third case is supported.

git-diff doesn't understand :<stage>:<filename> and :<filename> for accessing index version of blob (git-cat-file for example understands it). Note: <filename> in <revision>:<filename> and <stage>:<filename> must be wrt GIT_DIR.

It is also no way to specify working tree version of file (blob). We could use ::<filename> for that, I think...

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git
Previous: Junio C HamanoNext: Junio C Hamano
Message 3 of 5 in “git-diff between /dev/null and blob”
  1. Jakub NarebskiJul 31, 2006
  2. Junio C HamanoJul 31, 2006
  3. Jakub NarebskiAug 6, 2006
  4. Junio C HamanoAug 6, 2006
  5. Jakub NarebskiAug 7, 2006

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.