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

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

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

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:36

Jakub Narebski [off-list ref] writes:
Junio C Hamano wrote:
quoted
Jakub Narebski [off-list ref] writes:
quoted
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.

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

From: Jakub Narebski <hidden>
Date: 2016-06-15 22:42:36

Junio C Hamano wrote:
Jakub Narebski [off-list ref] 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
quoted
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
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help