{"thread":{"id":"4339","subject":"[PATCH] Make git-diff-tree indicate when it flushes","startedAt":"2006-05-29T12:24:35Z","lastAt":"2006-05-29T22:32:32Z","messageCount":7,"participants":["Paul Mackerras","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"20887","messageId":"17530.59395.5611.931858@cargo.ozlabs.ibm.com","threadId":"4339","inReplyTo":null,"subject":"[PATCH] Make git-diff-tree indicate when it flushes","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-05-29T12:24:35Z","receivedAt":"2006-05-29T12:24:35Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"There are times when gitk needs to know that the commits it has sent\nto git-diff-tree --stdin did not match, and it needs to know in a\ntimely fashion even if none of them match.  At the moment,\ngit-diff-tree outputs nothing for non-matching commits, so it is\nimpossible for gitk to distinguish between git-diff-tree being slow\nand git-diff-tree saying no.\n\nThis makes git-diff-tree output a blank line in response to a blank\nline in its input (which already causes git-diff-tree to flush its\noutput buffers).  Gitk, or other users of git-diff-tree --stdin, can\nuse the blank line to indicate that git-diff-tree has processed all\nthe commits on its input up to the input blank line, and any commits\nthat have not been output do not match.\n\nSigned-off-by: Paul Mackerras <paulus@samba.org>\n---\ndiff --git a/builtin-diff-tree.c b/builtin-diff-tree.c\nindex cc53b81..dbe5737 100644\n--- a/builtin-diff-tree.c\n+++ b/builtin-diff-tree.c\n@@ -139,9 +139,10 @@ int cmd_diff_tree(int argc, const char *\n \t\topt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |\n \t\t\t\t       DIFF_SETUP_USE_CACHE);\n \twhile (fgets(line, sizeof(line), stdin))\n-\t\tif (line[0] == '\\n')\n+\t\tif (line[0] == '\\n') {\n+\t\t\tputchar('\\n');\n \t\t\tfflush(stdout);\n-\t\telse\n+\t\t} else\n \t\t\tdiff_tree_stdin(line);\n \n \treturn 0;\n"},{"id":"20896","messageId":"7vejyc8ymw.fsf@assigned-by-dhcp.cox.net","threadId":"4339","inReplyTo":"17530.59395.5611.931858@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] Make git-diff-tree indicate when it flushes","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-29T18:38:31Z","receivedAt":"2006-05-29T18:38:31Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Mackerras <paulus@samba.org> writes:\n\n> There are times when gitk needs to know that the commits it has sent\n> to git-diff-tree --stdin did not match, and it needs to know in a\n> timely fashion even if none of them match.  At the moment,\n> git-diff-tree outputs nothing for non-matching commits, so it is\n> impossible for gitk to distinguish between git-diff-tree being slow\n> and git-diff-tree saying no.\n\nWouldn't this help?\n\n\t$ git-diff-tree --stdin --always\n"},{"id":"20925","messageId":"17531.28529.215905.856397@cargo.ozlabs.ibm.com","threadId":"4339","inReplyTo":"7vejyc8ymw.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Make git-diff-tree indicate when it flushes","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-05-29T22:02:25Z","receivedAt":"2006-05-29T22:02:25Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Junio C Hamano writes:\n\n> Paul Mackerras <paulus@samba.org> writes:\n> \n> > There are times when gitk needs to know that the commits it has sent\n> > to git-diff-tree --stdin did not match, and it needs to know in a\n> > timely fashion even if none of them match.  At the moment,\n> > git-diff-tree outputs nothing for non-matching commits, so it is\n> > impossible for gitk to distinguish between git-diff-tree being slow\n> > and git-diff-tree saying no.\n> \n> Wouldn't this help?\n> \n> \t$ git-diff-tree --stdin --always\n\nOn the git.git tree:\n\n$ cat revs\n65aadb92a1ce9605fa2f412b51de91781a3ef3d6\ncc189c2ca2c725c430f100f61e7c4a6849f93163\n$ git diff-tree -r -s --stdin -- apply.c <revs\n65aadb92a1ce9605fa2f412b51de91781a3ef3d6\n$ git diff-tree -r -s --stdin --always -- apply.c <revs\n65aadb92a1ce9605fa2f412b51de91781a3ef3d6\ncc189c2ca2c725c430f100f61e7c4a6849f93163\n$\n\nWith --always, how do I tell that 65aadb affects apply.c and cc189c\ndoesn't?\n\nPaul.\n"},{"id":"20926","messageId":"7vzmh07a9k.fsf@assigned-by-dhcp.cox.net","threadId":"4339","inReplyTo":"17531.28529.215905.856397@cargo.ozlabs.ibm.com","subject":"Re: [PATCH] Make git-diff-tree indicate when it flushes","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-29T22:10:15Z","receivedAt":"2006-05-29T22:10:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Paul Mackerras <paulus@samba.org> writes:\n\n>> Wouldn't this help?\n>> \n>> \t$ git-diff-tree --stdin --always\n>\n> On the git.git tree:\n>\n> $ cat revs\n> 65aadb92a1ce9605fa2f412b51de91781a3ef3d6\n> cc189c2ca2c725c430f100f61e7c4a6849f93163\n> $ git diff-tree -r -s --stdin -- apply.c <revs\n> 65aadb92a1ce9605fa2f412b51de91781a3ef3d6\n> $ git diff-tree -r -s --stdin --always -- apply.c <revs\n> 65aadb92a1ce9605fa2f412b51de91781a3ef3d6\n> cc189c2ca2c725c430f100f61e7c4a6849f93163\n> $\n>\n> With --always, how do I tell that 65aadb affects apply.c and cc189c\n> doesn't?\n\nI am not quite sure exactly what you are trying to achieve, but\none trivial way is not giving -s perhaps?\n"},{"id":"20929","messageId":"7vr72c79wm.fsf@assigned-by-dhcp.cox.net","threadId":"4339","inReplyTo":"7vzmh07a9k.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Make git-diff-tree indicate when it flushes","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2006-05-29T22:18:01Z","receivedAt":"2006-05-29T22:18:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <junkio@cox.net> writes:\n\n> Paul Mackerras <paulus@samba.org> writes:\n>\n>> With --always, how do I tell that 65aadb affects apply.c and cc189c\n>> doesn't?\n>\n> I am not quite sure exactly what you are trying to achieve, but\n> one trivial way is not giving -s perhaps?\n\nHaving said that, I suspect this might be a better way.\nWhatever you throw at it from stdin that are not a validly\nlooking object name, you will get them back, so you can use your\nfavorite markers.\n\ndiff --git a/builtin-diff-tree.c b/builtin-diff-tree.c\nindex cc53b81..7208c48 100644\n--- a/builtin-diff-tree.c\n+++ b/builtin-diff-tree.c\n@@ -138,11 +138,15 @@ int cmd_diff_tree(int argc, const char *\n \tif (opt->diffopt.detect_rename)\n \t\topt->diffopt.setup |= (DIFF_SETUP_USE_SIZE_CACHE |\n \t\t\t\t       DIFF_SETUP_USE_CACHE);\n-\twhile (fgets(line, sizeof(line), stdin))\n-\t\tif (line[0] == '\\n')\n+\twhile (fgets(line, sizeof(line), stdin)) {\n+\t\tunsigned char sha1[20];\n+\n+\t\tif (get_sha1_hex(line, sha1)) {\n+\t\t\tfputs(line);\n \t\t\tfflush(stdout);\n+\t\t}\n \t\telse\n \t\t\tdiff_tree_stdin(line);\n-\n+\t}\n \treturn 0;\n }\n"},{"id":"20931","messageId":"17531.30254.890940.553395@cargo.ozlabs.ibm.com","threadId":"4339","inReplyTo":"7vzmh07a9k.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Make git-diff-tree indicate when it flushes","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-05-29T22:31:10Z","receivedAt":"2006-05-29T22:31:10Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Junio C Hamano writes:\n\n> I am not quite sure exactly what you are trying to achieve, but\n> one trivial way is not giving -s perhaps?\n\nI'm asking git-diff-tree which of a given set of commits affect any of\na set of paths, so that gitk can highlight the ones that do.\nFurthermore I want to be able to use the git-diff-tree process for\nmultiple sets of commit IDs.\n\nIf I don't use -s, then I will get lines starting with a \":\" after the\ncommit IDs of the commits that do affect the set of paths I specified.\nThat means I get a definite indication for all except the last commit\nI send.  For the last commit I still don't know whether the absence of\nany \":\" lines means that the commit doesn't affect the set of paths,\nor that git-diff-tree is being slow.  So I still need something like\nthe patch I sent.\n\nI could get the indication I want (with or without -s) if I close the\npipe going to the git-diff-tree process.  But then the process will\nexit, and I want it to stay around so that I don't have to pay the\nfork/exec and startup time of git-diff-tree next time (which will be\nwhen the user scrolls the commit list window or asks to move to the\nnext highlighted commit).\n\nThus, --always (with or without -s) doesn't quite do what I need.\n\nPaul.\n"},{"id":"20934","messageId":"17531.30336.459889.347540@cargo.ozlabs.ibm.com","threadId":"4339","inReplyTo":"7vr72c79wm.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] Make git-diff-tree indicate when it flushes","fromName":"Paul Mackerras","fromEmail":"paulus@samba.org","sentAt":"2006-05-29T22:32:32Z","receivedAt":"2006-05-29T22:32:32Z","isPatch":true,"sender":{"key":"paulus@samba.org","avatar":"https://avatars.githubusercontent.com/u/1606439?v=4"},"body":"Junio C Hamano writes:\n\n> Having said that, I suspect this might be a better way.\n> Whatever you throw at it from stdin that are not a validly\n> looking object name, you will get them back, so you can use your\n> favorite markers.\n\nThat would be fine.\n\nThanks,\nPaul.\n"}]}