{"thread":{"id":"67","subject":"[PATCH] Do not run useless show-diff on unmerged paths repeatedly.","startedAt":"2005-04-17T02:18:02Z","lastAt":"2005-04-17T02:18:02Z","messageCount":1,"participants":["Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"418","messageId":"7vis2m2lk5.fsf@assigned-by-dhcp.cox.net","threadId":"67","inReplyTo":null,"subject":"[PATCH] Do not run useless show-diff on unmerged paths repeatedly.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2005-04-17T02:18:02Z","receivedAt":"2005-04-17T02:18:02Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"When run on unmerged dircache, show-diff compares the working\nfile with each non-empty stage for that path.  Two out of three\ntimes, this is not very helpful.  This patch makes it report the\nunmergedness only once per each path and avoids running the\nactual diff.\n\nUpper layer SCMs like Cogito are expected to find out mode/SHA1\nfor each stage by using \"show-files --stage\" and run the diff\nitself.  This would result in more sensible diffs.\n\nTo be applied on top of my previous patches:\n\n    [PATCH] Optionally tell show-diff to show only named files.\n    [PATCH] show-diff -z option for machine readable output.\n    [PATCH] show-diff shell safety.\n    [PATCH] (take 2) Rename confusing variable in show-diff.\n    [PATCH] show-diff style fix.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n ++show-diff.c |   13 +++++++++++++\n 1 files changed, 13 insertions(+)\n\n--- ./show-diff.c\t2005-04-16 19:01:28.000000000 -0700\n+++ ./++show-diff.c\t2005-04-16 18:57:55.000000000 -0700\n@@ -167,6 +167,19 @@\n \t\t    ! matches_pathspec(ce, argv+1, argc-1))\n \t\t\tcontinue;\n \n+\t\tif (ce_stage(ce)) {\n+\t\t\tif (machine_readable)\n+\t\t\t\tprintf(\"U %s%c\", ce->name, 0);\n+\t\t\telse\n+\t\t\t\tprintf(\"%s: Unmerged\\n\",\n+\t\t\t\t       ce->name);\n+\t\t\twhile (i < entries &&\n+\t\t\t       !strcmp(ce->name, active_cache[i]->name))\n+\t\t\t\ti++;\n+\t\t\ti--; /* compensate for loop control increments */\n+\t\t\tcontinue;\n+\t\t}\n+ \n \t\tif (stat(ce->name, &st) < 0) {\n \t\t\tif (errno == ENOENT && silent_on_nonexisting_files)\n \t\t\t\tcontinue;\n\n"}]}