git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* git-diff between /dev/null and blob
@ 2006-07-31  1:07 Jakub Narebski
  2006-07-31  6:50 ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2006-07-31  1:07 UTC (permalink / raw)
  To: git

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
but you cannot use git-diff to create diff between two files, or a file
and blob. 

In particular, I couldn't make "creation" patch, i.e. patch between 
/dev/null and specified blob. If it would be possible, we could lose
gitweb.cgi dependency on diff.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-diff between /dev/null and blob
  2006-07-31  1:07 git-diff between /dev/null and blob Jakub Narebski
@ 2006-07-31  6:50 ` Junio C Hamano
  2006-08-06 21:02   ` Jakub Narebski
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-07-31  6:50 UTC (permalink / raw)
  To: git; +Cc: jnareb

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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-diff between /dev/null and blob
  2006-07-31  6:50 ` Junio C Hamano
@ 2006-08-06 21:02   ` Jakub Narebski
  2006-08-06 21:36     ` Junio C Hamano
  0 siblings, 1 reply; 5+ messages in thread
From: Jakub Narebski @ 2006-08-06 21:02 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> 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

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-diff between /dev/null and blob
  2006-08-06 21:02   ` Jakub Narebski
@ 2006-08-06 21:36     ` Junio C Hamano
  2006-08-07 12:52       ` Jakub Narebski
  0 siblings, 1 reply; 5+ messages in thread
From: Junio C Hamano @ 2006-08-06 21:36 UTC (permalink / raw)
  To: Jakub Narebski; +Cc: git

Jakub Narebski <jnareb@gmail.com> writes:

> Junio C Hamano wrote:
>
>> 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

Eh, that comment completely misses the point, because the
example did not show its true strength.  Arbitrary two blob sha1
lets you do something like this:

	git diff v0.99:merge-cache.c master:merge-index.c
	git diff v0.99:pull.h fetch.h

        echo extra >>Makefile && git diff :0:Makefile HEAD^^:Makefile

        H=`(cat Makefile; echo extra) | git hash-object -w --stdin`
	echo "100644 $H 2	foobar" | git update-index --add --index-info
	git diff :2:foobar :Makefile

> git-diff doesn't understand :<stage>:<filename> and :<filename> for
> accessing index version of blob (git-cat-file for example understands
> it).

You probably got this impression from a botched experiment or
something, but this statement is wrong as demonstrated above.

^ permalink raw reply	[flat|nested] 5+ messages in thread

* Re: git-diff between /dev/null and blob
  2006-08-06 21:36     ` Junio C Hamano
@ 2006-08-07 12:52       ` Jakub Narebski
  0 siblings, 0 replies; 5+ messages in thread
From: Jakub Narebski @ 2006-08-07 12:52 UTC (permalink / raw)
  To: git

Junio C Hamano wrote:

> Jakub Narebski <jnareb@gmail.com> writes: 

>        git diff v0.99:pull.h fetch.h
>
>         echo extra >>Makefile && git diff :0:Makefile HEAD^^:Makefile
> 
>         H=`(cat Makefile; echo extra) | git hash-object -w --stdin`
>       echo "100644 $H 2       foobar" | git update-index --add --index-info
>       git diff :2:foobar :Makefile
> 
>> git-diff doesn't understand :<stage>:<filename> and :<filename> for
>> accessing index version of blob (git-cat-file for example understands
>> it).
> 
> You probably got this impression from a botched experiment or
> something, but this statement is wrong as demonstrated above.

Right, sorry.

And you can write ./<filename> to distinguish it from revision name, so
proposed ::<filename> extension is not needed.

-- 
Jakub Narebski
Warsaw, Poland
ShadeHawk on #git

^ permalink raw reply	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2006-08-07 12:53 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2006-07-31  1:07 git-diff between /dev/null and blob Jakub Narebski
2006-07-31  6:50 ` Junio C Hamano
2006-08-06 21:02   ` Jakub Narebski
2006-08-06 21:36     ` Junio C Hamano
2006-08-07 12:52       ` Jakub Narebski

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).