{"thread":{"id":"5054","subject":"git-diff between /dev/null and blob","startedAt":"2006-07-31T01:07:51Z","lastAt":"2006-08-07T12:52:50Z","messageCount":5,"participants":["Jakub Narebski","Junio C Hamano"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"24400","messageId":"eajl4r$b7o$1@sea.gmane.org","threadId":"5054","inReplyTo":null,"subject":"git-diff between /dev/null and blob","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-07-31T01:07:51Z","receivedAt":"2006-07-31T01:07:51Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Currently, due to artifact of git-diff argument parsing you can get diff \nof two arbitrary blobs given by their sha1 id, e.g.\n  git diff ab8050ceb4e43522e858768cc2c02fcb91839370 fd05278808d458602587bb024a48726018d30926\nbut you cannot use git-diff to create diff between two files, or a file\nand blob. \n\nIn particular, I couldn't make \"creation\" patch, i.e. patch between \n/dev/null and specified blob. If it would be possible, we could lose\ngitweb.cgi dependency on diff.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24408","messageId":"7vmzaq9sjs.fsf@assigned-by-dhcp.cox.net","threadId":"5054","inReplyTo":"eajl4r$b7o$1@sea.gmane.org","subject":"Re: git-diff between /dev/null and blob","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-07-31T06:50:31Z","receivedAt":"2006-07-31T06:50:31Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Currently, due to artifact of git-diff argument parsing you can get diff \n> of two arbitrary blobs given by their sha1 id, e.g.\n>   git diff ab8050ceb4e43522e858768cc2c02fcb91839370 fd05278808d458602587bb024a48726018d30926\n\nJust FYI, it is pretty much by design not artifact to allow\nsomething like this:\n\n\tgit diff master:Makefile next:Makefile\n"},{"id":"24901","messageId":"eb5ld6$36k$1@sea.gmane.org","threadId":"5054","inReplyTo":"7vmzaq9sjs.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-diff between /dev/null and blob","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-06T21:02:33Z","receivedAt":"2006-08-06T21:02:33Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes:\n> \n>> Currently, due to artifact of git-diff argument parsing you can get diff \n>> of two arbitrary blobs given by their sha1 id, e.g.\n>>   git diff ab8050ceb4e43522e858768cc2c02fcb91839370 fd05278808d458602587bb024a48726018d30926\n> \n> Just FYI, it is pretty much by design not artifact to allow\n> something like this:\n> \n>       git diff master:Makefile next:Makefile\n\nWhich we could get using\n\n        git diff master next -- Makefile\n\nCurrently ('next' branch) git-diff manpage talks only about comparing trees.\n\n* When  no  <ent>  is given, the working tree and the index file is compared,\n  using git-diff-files.\n\n* When one <ent> is given, the working tree and the named tree  is  compared,\n  using git-diff-index. The option --cached can be given to compare the index\n  file and the named tree.\n\n* When  two  <ent>s  are  given,  these  two   trees   are   compared   using\n  git-diff-tree.\n\nAnd the only way to compare blobs is by giving directly or indirectly \n(like above) sha1 of the blobs, i.e. only the third case is supported. \n\ngit-diff doesn't understand :<stage>:<filename> and :<filename> for\naccessing index version of blob (git-cat-file for example understands\nit). Note: <filename> in <revision>:<filename> and <stage>:<filename>\nmust be wrt GIT_DIR.\n\nIt is also no way to specify working tree version of file (blob). We \ncould use ::<filename> for that, I think...\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"},{"id":"24902","messageId":"7vejvt8s24.fsf@assigned-by-dhcp.cox.net","threadId":"5054","inReplyTo":"eb5ld6$36k$1@sea.gmane.org","subject":"Re: git-diff between /dev/null and blob","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-08-06T21:36:51Z","receivedAt":"2006-08-06T21:36:51Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jakub Narebski <jnareb@gmail.com> writes:\n\n> Junio C Hamano wrote:\n>\n>> Jakub Narebski <jnareb@gmail.com> writes:\n>> \n>>> Currently, due to artifact of git-diff argument parsing you can get diff \n>>> of two arbitrary blobs given by their sha1 id, e.g.\n>>>   git diff ab8050ceb4e43522e858768cc2c02fcb91839370 fd05278808d458602587bb024a48726018d30926\n>> \n>> Just FYI, it is pretty much by design not artifact to allow\n>> something like this:\n>> \n>>       git diff master:Makefile next:Makefile\n>\n> Which we could get using\n>\n>         git diff master next -- Makefile\n\nEh, that comment completely misses the point, because the\nexample did not show its true strength.  Arbitrary two blob sha1\nlets you do something like this:\n\n\tgit diff v0.99:merge-cache.c master:merge-index.c\n\tgit diff v0.99:pull.h fetch.h\n\n        echo extra >>Makefile && git diff :0:Makefile HEAD^^:Makefile\n\n        H=`(cat Makefile; echo extra) | git hash-object -w --stdin`\n\techo \"100644 $H 2\tfoobar\" | git update-index --add --index-info\n\tgit diff :2:foobar :Makefile\n\n> git-diff doesn't understand :<stage>:<filename> and :<filename> for\n> accessing index version of blob (git-cat-file for example understands\n> it).\n\nYou probably got this impression from a botched experiment or\nsomething, but this statement is wrong as demonstrated above.\n"},{"id":"24921","messageId":"eb7d2s$cq2$1@sea.gmane.org","threadId":"5054","inReplyTo":"7vejvt8s24.fsf@assigned-by-dhcp.cox.net","subject":"Re: git-diff between /dev/null and blob","fromName":"Jakub Narebski","fromEmail":"jnareb@gmail.com","sentAt":"2006-08-07T12:52:50Z","receivedAt":"2006-08-07T12:52:50Z","isPatch":false,"sender":{"key":"jnareb@gmail.com","avatar":"https://avatars.githubusercontent.com/u/2706?v=4"},"body":"Junio C Hamano wrote:\n\n> Jakub Narebski <jnareb@gmail.com> writes: \n\n>        git diff v0.99:pull.h fetch.h\n>\n>         echo extra >>Makefile && git diff :0:Makefile HEAD^^:Makefile\n> \n>         H=`(cat Makefile; echo extra) | git hash-object -w --stdin`\n>       echo \"100644 $H 2       foobar\" | git update-index --add --index-info\n>       git diff :2:foobar :Makefile\n> \n>> git-diff doesn't understand :<stage>:<filename> and :<filename> for\n>> accessing index version of blob (git-cat-file for example understands\n>> it).\n> \n> You probably got this impression from a botched experiment or\n> something, but this statement is wrong as demonstrated above.\n\nRight, sorry.\n\nAnd you can write ./<filename> to distinguish it from revision name, so\nproposed ::<filename> extension is not needed.\n\n-- \nJakub Narebski\nWarsaw, Poland\nShadeHawk on #git\n"}]}