{"thread":{"id":"9528","subject":"[PATCH] diff: squelch empty diffs even more","startedAt":"2007-08-14T21:09:57Z","lastAt":"2007-08-15T14:47:23Z","messageCount":5,"participants":["René Scharfe","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"50728","messageId":"46C21A25.2040304@lsrfire.ath.cx","threadId":"9528","inReplyTo":null,"subject":"[PATCH] diff: squelch empty diffs even more","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2007-08-14T21:09:57Z","receivedAt":"2007-08-14T21:09:57Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"When we compare two non-tracked files or explicitly specify\n--no-index then the suggestion to run git-status is not helpful.\nmax_count is set to -2 in these cases; don't print the warning\nthen.\n\nSigned-off-by: Rene Scharfe <rene.scharfe@lsfire.ath.cx>\n---\n\n builtin-diff.c |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/builtin-diff.c b/builtin-diff.c\nindex 6ed7b68..b2fd8c8 100644\n--- a/builtin-diff.c\n+++ b/builtin-diff.c\n@@ -346,8 +346,8 @@ int cmd_diff(int argc, const char **argv, const char *prefix)\n \tif (rev.diffopt.exit_with_status)\n \t\tresult = rev.diffopt.has_changes;\n \n-\tif ((rev.diffopt.output_format & DIFF_FORMAT_PATCH)\n-\t    && (1 < rev.diffopt.skip_stat_unmatch))\n+\tif ((rev.diffopt.output_format & DIFF_FORMAT_PATCH) &&\n+\t    1 < rev.diffopt.skip_stat_unmatch && rev.max_count != -2)\n \t\tprintf(\"Warning: %d path%s touched but unmodified. \"\n \t\t       \"Consider running git-status.\\n\",\n \t\t       rev.diffopt.skip_stat_unmatch - 1,\n"},{"id":"50729","messageId":"7v643hbyao.fsf@assigned-by-dhcp.cox.net","threadId":"9528","inReplyTo":"46C21A25.2040304@lsrfire.ath.cx","subject":"Re: [PATCH] diff: squelch empty diffs even more","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-14T21:29:03Z","receivedAt":"2007-08-14T21:29:03Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> When we compare two non-tracked files or explicitly specify\n> --no-index then the suggestion to run git-status is not helpful.\n\nThat observation is correct but how does skip_stat_unmatch count\nup in such a case?  Shouldn't diffcore_skip_stat_unmatch()\nfunction be taught about such a \"fake\" filepair that did not\ncome from git, and ignore the stat differences?\n"},{"id":"50732","messageId":"46C22F7C.1000502@lsrfire.ath.cx","threadId":"9528","inReplyTo":"7v643hbyao.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff: squelch empty diffs even more","fromName":"René Scharfe","fromEmail":"rene.scharfe@lsrfire.ath.cx","sentAt":"2007-08-14T22:41:00Z","receivedAt":"2007-08-14T22:41:00Z","isPatch":true,"sender":{"key":"l.s.r@web.de","avatar":"https://avatars.githubusercontent.com/u/26122331?v=4"},"body":"Junio C Hamano schrieb:\n> René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n> \n>> When we compare two non-tracked files or explicitly specify\n>> --no-index then the suggestion to run git-status is not helpful.\n> \n> That observation is correct but how does skip_stat_unmatch count\n> up in such a case?  Shouldn't diffcore_skip_stat_unmatch()\n> function be taught about such a \"fake\" filepair that did not\n> come from git, and ignore the stat differences?\n\nHmm.  Like this?\n\nThe patch adds a new diff_options bitfield member, no_index, that\nis used instead of the special value of -2 of the rev_info field\nmax_count to indicate that the index is not to be used.  This makes\nit possible to pass that flag down to diffcore_skip_stat_unmatch(),\nwhich only has one diff_options parameter.\n\nThis could even become a cleanup if we removed all assignments of\nmax_count to a value of -2 (viz. replacement of a magic value with\na self-documenting field name) but I didn't dare to do that so late\nin the rc game..\n\nThe no_index bit, if set, then tells diffcore_skip_stat_unmatch()\nto not account for any skipped stat-mismatches, which avoids the\nsuggestion to run git-status.\n\nRené\n---\n\n diff-lib.c |    8 ++++++--\n diff.c     |    3 ++-\n diff.h     |    1 +\n 3 files changed, 9 insertions(+), 3 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex 92c0e39..f5568c3 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -189,6 +189,7 @@ static int handle_diff_files_args(struct rev_info *revs,\n \t\t\t\t!strcmp(argv[1], \"--no-index\")) {\n \t\t\trevs->max_count = -2;\n \t\t\trevs->diffopt.exit_with_status = 1;\n+\t\t\trevs->diffopt.no_index = 1;\n \t\t}\n \t\telse if (!strcmp(argv[1], \"-q\"))\n \t\t\t*silent = 1;\n@@ -204,8 +205,10 @@ static int handle_diff_files_args(struct rev_info *revs,\n \t\t */\n \t\tread_cache();\n \t\tif (!is_in_index(revs->diffopt.paths[0]) ||\n-\t\t\t\t\t!is_in_index(revs->diffopt.paths[1]))\n+\t\t\t\t\t!is_in_index(revs->diffopt.paths[1])) {\n \t\t\trevs->max_count = -2;\n+\t\t\trevs->diffopt.no_index = 1;\n+\t\t}\n \t}\n \n \t/*\n@@ -293,6 +296,7 @@ int setup_diff_no_index(struct rev_info *revs,\n \telse\n \t\trevs->diffopt.paths = argv + argc - 2;\n \trevs->diffopt.nr_paths = 2;\n+\trevs->diffopt.no_index = 1;\n \trevs->max_count = -2;\n \treturn 0;\n }\n@@ -304,7 +308,7 @@ int run_diff_files_cmd(struct rev_info *revs, int argc, const char **argv)\n \tif (handle_diff_files_args(revs, argc, argv, &silent_on_removed))\n \t\treturn -1;\n \n-\tif (revs->max_count == -2) {\n+\tif (revs->diffopt.no_index) {\n \t\tif (revs->diffopt.nr_paths != 2)\n \t\t\treturn error(\"need two files/directories with --no-index\");\n \t\tif (queue_diff(&revs->diffopt, revs->diffopt.paths[0],\ndiff --git a/diff.c b/diff.c\nindex f884de7..97cc5bc 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -3185,7 +3185,8 @@ static void diffcore_skip_stat_unmatch(struct diff_options *diffopt)\n \t\t\t * to determine how many paths were dirty only\n \t\t\t * due to stat info mismatch.\n \t\t\t */\n-\t\t\tdiffopt->skip_stat_unmatch++;\n+\t\t\tif (!diffopt->no_index)\n+\t\t\t\tdiffopt->skip_stat_unmatch++;\n \t\t\tdiff_free_filepair(p);\n \t\t}\n \t}\ndiff --git a/diff.h b/diff.h\nindex de21f8e..4546aad 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -60,6 +60,7 @@ struct diff_options {\n \t\t color_diff_words:1,\n \t\t has_changes:1,\n \t\t quiet:1,\n+\t\t no_index:1,\n \t\t allow_external:1,\n \t\t exit_with_status:1;\n \tint context;\n"},{"id":"50735","messageId":"7vvebhad3k.fsf@assigned-by-dhcp.cox.net","threadId":"9528","inReplyTo":"46C22F7C.1000502@lsrfire.ath.cx","subject":"Re: [PATCH] diff: squelch empty diffs even more","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2007-08-14T23:52:15Z","receivedAt":"2007-08-14T23:52:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"René Scharfe <rene.scharfe@lsrfire.ath.cx> writes:\n\n> Hmm.  Like this?\n>\n> The patch adds a new diff_options bitfield member, no_index, that\n> is used instead of the special value of -2 of the rev_info field\n> max_count to indicate that the index is not to be used.  This makes\n> it possible to pass that flag down to diffcore_skip_stat_unmatch(),\n> which only has one diff_options parameter.\n>\n> This could even become a cleanup if we removed all assignments of\n> max_count to a value of -2 (viz. replacement of a magic value with\n> a self-documenting field name) but I didn't dare to do that so late\n> in the rc game..\n>\n> The no_index bit, if set, then tells diffcore_skip_stat_unmatch()\n> to not account for any skipped stat-mismatches, which avoids the\n> suggestion to run git-status.\n\nYeah, I've always hated that -2 magic hack, and I think this is\nthe right way to go.  Dscho?\n"},{"id":"50779","messageId":"Pine.LNX.4.64.0708151646250.19222@wbgn129.biozentrum.uni-wuerzburg.de","threadId":"9528","inReplyTo":"7vvebhad3k.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH] diff: squelch empty diffs even more","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-08-15T14:47:23Z","receivedAt":"2007-08-15T14:47:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 14 Aug 2007, Junio C Hamano wrote:\n\n> Yeah, I've always hated that -2 magic hack, and I think this is the \n> right way to go.  Dscho?\n\nRight.  It is how I should have done it to begin with.  If I find the time \n(and nobody beats be to it), I'll try to find the rest of the places \ntomorrow, and send a fix.\n\nCiao,\nDscho\n"}]}