{"thread":{"id":"7245","subject":"[PATCH 1/2] diff --quick","startedAt":"2007-03-14T18:24:01Z","lastAt":"2007-03-16T00:16:15Z","messageCount":23,"participants":["Junio C Hamano","Alex Riesen","Linus Torvalds","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":2},"messages":[{"id":"37097","messageId":"7vwt1j8z0e.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":null,"subject":"[PATCH 1/2] diff --quick","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T18:24:01Z","receivedAt":"2007-03-14T18:24:01Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This adds the command line option 'quick' to tell 'git diff-*' that\nwe are not interested in the actual diff contents but only if there\nis any change.  This option automatically turns --exit-code on, and\nturns off output formatting, as it does not make much sense to show\nthe first hit we happened to have found.\n\nThe backends have not been taught about the option with this patch.\nThat is a topic for later rounds.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n\n * Obviously this comes on top of Alex's --exit-code.\n\n diff.c |   28 ++++++++++++++++++++++++++--\n diff.h |    4 ++--\n 2 files changed, 28 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 7d938c1..99f5802 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1958,6 +1958,23 @@ int diff_setup_done(struct diff_options *options)\n \tif (options->abbrev <= 0 || 40 < options->abbrev)\n \t\toptions->abbrev = 40; /* full */\n \n+\t/*\n+\t * It does not make sense to show the first hit we happened\n+\t * to have found.  It does not make sense not to return with\n+\t * exit code in such a case either.\n+\t */\n+\tif (options->quick) {\n+\t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n+\t\toptions->exit_with_status = 1;\n+\t}\n+\n+\t/*\n+\t * If we postprocess in diffcore, we cannot simply return\n+\t * upon the first hit.  We need to run diff as usual.\n+\t */\n+\tif (options->pickaxe || options->filter)\n+\t\toptions->quick = 0;\n+\n \treturn 0;\n }\n \n@@ -2136,6 +2153,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--exit-code\"))\n \t\toptions->exit_with_status = 1;\n+\telse if (!strcmp(arg, \"--quick\"))\n+\t\toptions->quick = 1;\n \telse\n \t\treturn 0;\n \treturn 1;\n@@ -2900,6 +2919,11 @@ static void diffcore_apply_filter(const char *filter)\n \n void diffcore_std(struct diff_options *options)\n {\n+\tif (options->quick) {\n+\t\toptions->has_changes = !!diff_queued_diff.nr;\n+\t\treturn;\n+\t}\n+\n \tif (options->break_opt != -1)\n \t\tdiffcore_break(options->break_opt);\n \tif (options->detect_rename)\n@@ -2912,8 +2936,8 @@ void diffcore_std(struct diff_options *options)\n \t\tdiffcore_order(options->orderfile);\n \tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options->filter);\n-\tif (options->exit_with_status)\n-\t\toptions->has_changes = !!diff_queued_diff.nr;\n+\n+\toptions->has_changes = !!diff_queued_diff.nr;\n }\n \n \ndiff --git a/diff.h b/diff.h\nindex 81fa265..2555120 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -57,6 +57,8 @@ struct diff_options {\n \t\t find_copies_harder:1,\n \t\t color_diff:1,\n \t\t color_diff_words:1,\n+\t\t has_changes:1,\n+\t\t quick:1,\n \t\t exit_with_status:1;\n \tint context;\n \tint break_opt;\n@@ -72,8 +74,6 @@ struct diff_options {\n \tconst char *msg_sep;\n \tconst char *stat_sep;\n \tlong xdl_opts;\n-\t/* 0 - no differences; only meaningful if exit_with_status set */\n-\tint has_changes;\n \n \tint stat_width;\n \tint stat_name_width;\n-- \n1.5.0.3.1036.g6baf1\n"},{"id":"37111","messageId":"7vtzwn7bzb.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"7vwt1j8z0e.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 1/5] Remove unused diffcore_std_no_resolve","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T21:26:48Z","receivedAt":"2007-03-14T21:26:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This was only used by diff-tree-helper program, whose purpose\nwas to translate a raw diff to a patch.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n * These are re-spin of the earlier 2 patch series, go directly\n   on top of Alex's --exit-code.\n\n diff.c |   11 -----------\n diff.h |    2 --\n 2 files changed, 0 insertions(+), 13 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex cc81801..7d938c1 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -2917,17 +2917,6 @@ void diffcore_std(struct diff_options *options)\n }\n \n \n-void diffcore_std_no_resolve(struct diff_options *options)\n-{\n-\tif (options->pickaxe)\n-\t\tdiffcore_pickaxe(options->pickaxe, options->pickaxe_opts);\n-\tif (options->orderfile)\n-\t\tdiffcore_order(options->orderfile);\n-\tdiffcore_apply_filter(options->filter);\n-\tif (options->exit_with_status)\n-\t\toptions->has_changes = !!diff_queued_diff.nr;\n-}\n-\n void diff_addremove(struct diff_options *options,\n \t\t    int addremove, unsigned mode,\n \t\t    const unsigned char *sha1,\ndiff --git a/diff.h b/diff.h\nindex d13fc89..81fa265 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -173,8 +173,6 @@ extern int diff_setup_done(struct diff_options *);\n \n extern void diffcore_std(struct diff_options *);\n \n-extern void diffcore_std_no_resolve(struct diff_options *);\n-\n #define COMMON_DIFF_OPTIONS_HELP \\\n \"\\ncommon diff options:\\n\" \\\n \"  -z            output diff-raw with lines terminated with NUL.\\n\" \\\n-- \n1.5.0.3.1036.g6baf1\n"},{"id":"37110","messageId":"7vodmv7bza.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"7vwt1j8z0e.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 2/5] diff --quiet","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T21:26:49Z","receivedAt":"2007-03-14T21:26:49Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This adds the command line option 'quiet' to tell 'git diff-*'\nthat we are not interested in the actual diff contents but only\nwant to know if there is any change.  This option automatically\nturns --exit-code on, and turns off output formatting, as it\ndoes not make much sense to show the first hit we happened to\nhave found.\n\nThe --quiet option is silently turned off (but --exit-code is\nstill in effect, so is silent output) if postprocessing filters\nsuch as pickaxe and diff-filter are used.  For all practical\npurposes I do not think of a reason to want to use these filters\nand not viewing the diff output.\n\nThe backends have not been taught about the option with this patch.\nThat is a topic for later rounds.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n diff.c |   27 +++++++++++++++++++++++++--\n diff.h |    4 ++--\n 2 files changed, 27 insertions(+), 4 deletions(-)\n\ndiff --git a/diff.c b/diff.c\nindex 7d938c1..d8f9242 100644\n--- a/diff.c\n+++ b/diff.c\n@@ -1958,6 +1958,23 @@ int diff_setup_done(struct diff_options *options)\n \tif (options->abbrev <= 0 || 40 < options->abbrev)\n \t\toptions->abbrev = 40; /* full */\n \n+\t/*\n+\t * It does not make sense to show the first hit we happened\n+\t * to have found.  It does not make sense not to return with\n+\t * exit code in such a case either.\n+\t */\n+\tif (options->quiet) {\n+\t\toptions->output_format = DIFF_FORMAT_NO_OUTPUT;\n+\t\toptions->exit_with_status = 1;\n+\t}\n+\n+\t/*\n+\t * If we postprocess in diffcore, we cannot simply return\n+\t * upon the first hit.  We need to run diff as usual.\n+\t */\n+\tif (options->pickaxe || options->filter)\n+\t\toptions->quiet = 0;\n+\n \treturn 0;\n }\n \n@@ -2136,6 +2153,8 @@ int diff_opt_parse(struct diff_options *options, const char **av, int ac)\n \t\toptions->detect_rename = 0;\n \telse if (!strcmp(arg, \"--exit-code\"))\n \t\toptions->exit_with_status = 1;\n+\telse if (!strcmp(arg, \"--quiet\"))\n+\t\toptions->quiet = 1;\n \telse\n \t\treturn 0;\n \treturn 1;\n@@ -2900,6 +2919,8 @@ static void diffcore_apply_filter(const char *filter)\n \n void diffcore_std(struct diff_options *options)\n {\n+\tif (options->quiet)\n+\t\treturn;\n \tif (options->break_opt != -1)\n \t\tdiffcore_break(options->break_opt);\n \tif (options->detect_rename)\n@@ -2912,8 +2933,8 @@ void diffcore_std(struct diff_options *options)\n \t\tdiffcore_order(options->orderfile);\n \tdiff_resolve_rename_copy();\n \tdiffcore_apply_filter(options->filter);\n-\tif (options->exit_with_status)\n-\t\toptions->has_changes = !!diff_queued_diff.nr;\n+\n+\toptions->has_changes = !!diff_queued_diff.nr;\n }\n \n \n@@ -2952,6 +2973,7 @@ void diff_addremove(struct diff_options *options,\n \t\tfill_filespec(two, sha1, mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n+\toptions->has_changes = 1;\n }\n \n void diff_change(struct diff_options *options,\n@@ -2977,6 +2999,7 @@ void diff_change(struct diff_options *options,\n \tfill_filespec(two, new_sha1, new_mode);\n \n \tdiff_queue(&diff_queued_diff, one, two);\n+\toptions->has_changes = 1;\n }\n \n void diff_unmerge(struct diff_options *options,\ndiff --git a/diff.h b/diff.h\nindex 81fa265..a0d2ce1 100644\n--- a/diff.h\n+++ b/diff.h\n@@ -57,6 +57,8 @@ struct diff_options {\n \t\t find_copies_harder:1,\n \t\t color_diff:1,\n \t\t color_diff_words:1,\n+\t\t has_changes:1,\n+\t\t quiet:1,\n \t\t exit_with_status:1;\n \tint context;\n \tint break_opt;\n@@ -72,8 +74,6 @@ struct diff_options {\n \tconst char *msg_sep;\n \tconst char *stat_sep;\n \tlong xdl_opts;\n-\t/* 0 - no differences; only meaningful if exit_with_status set */\n-\tint has_changes;\n \n \tint stat_width;\n \tint stat_name_width;\n-- \n1.5.0.3.1036.g6baf1\n"},{"id":"37114","messageId":"7vird37bz9.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"7vwt1j8z0e.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 3/5] Teach --quiet to diff backends.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T21:26:50Z","receivedAt":"2007-03-14T21:26:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This teaches git-diff-files, git-diff-index and git-diff-tree\nbackends to exit early under --quiet option.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n diff-lib.c  |    6 ++++++\n tree-diff.c |    2 ++\n 2 files changed, 8 insertions(+), 0 deletions(-)\n\ndiff --git a/diff-lib.c b/diff-lib.c\nindex f9a1a10..5c5b05b 100644\n--- a/diff-lib.c\n+++ b/diff-lib.c\n@@ -324,6 +324,9 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)\n \t\tstruct cache_entry *ce = active_cache[i];\n \t\tint changed;\n \n+\t\tif (revs->diffopt.quiet && revs->diffopt.has_changes)\n+\t\t\tbreak;\n+\n \t\tif (!ce_path_match(ce, revs->prune_data))\n \t\t\tcontinue;\n \n@@ -565,6 +568,9 @@ static int diff_cache(struct rev_info *revs,\n \t\tstruct cache_entry *ce = *ac;\n \t\tint same = (entries > 1) && ce_same_name(ce, ac[1]);\n \n+\t\tif (revs->diffopt.quiet && revs->diffopt.has_changes)\n+\t\t\tbreak;\n+\n \t\tif (!ce_path_match(ce, pathspec))\n \t\t\tgoto skip_entry;\n \ndiff --git a/tree-diff.c b/tree-diff.c\nindex c827582..44cde74 100644\n--- a/tree-diff.c\n+++ b/tree-diff.c\n@@ -161,6 +161,8 @@ static void show_entry(struct diff_options *opt, const char *prefix, struct tree\n int diff_tree(struct tree_desc *t1, struct tree_desc *t2, const char *base, struct diff_options *opt)\n {\n \twhile (t1->size | t2->size) {\n+\t\tif (opt->quiet && opt->has_changes)\n+\t\t\tbreak;\n \t\tif (opt->nr_paths && t1->size && !interesting(t1, base, opt)) {\n \t\t\tupdate_tree_entry(t1);\n \t\t\tcontinue;\n-- \n1.5.0.3.1036.g6baf1\n"},{"id":"37112","messageId":"7vd53b7bz8.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"7vwt1j8z0e.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 4/5] revision.c: explain what tree_difference does","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T21:26:51Z","receivedAt":"2007-03-14T21:26:51Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This explains how tree_difference variable is used, and updates two\nplaces where the code knows symbolic constant REV_TREE_SAME is 0.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n revision.c |   11 +++++++++--\n 1 files changed, 9 insertions(+), 2 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 3c2eb12..129d197 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -213,6 +213,13 @@ static int everybody_uninteresting(struct commit_list *orig)\n \treturn 1;\n }\n \n+/*\n+ * The goal is to get REV_TREE_NEW as the result only if the\n+ * diff consists of all '+' (and no other changes), and\n+ * REV_TREE_DIFFERENT otherwise (of course if the trees are\n+ * the same we want REV_TREE_SAME).  That means that once we\n+ * get to REV_TREE_DIFFERENT, we do not have to look any further.\n+ */\n static int tree_difference = REV_TREE_SAME;\n \n static void file_add_remove(struct diff_options *options,\n@@ -277,11 +284,11 @@ int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)\n \tempty.buf = \"\";\n \tempty.size = 0;\n \n-\ttree_difference = 0;\n+\ttree_difference = REV_TREE_SAME;\n \tretval = diff_tree(&empty, &real, \"\", &revs->pruning);\n \tfree(tree);\n \n-\treturn retval >= 0 && !tree_difference;\n+\treturn retval >= 0 && (tree_difference == REV_TREE_SAME);\n }\n \n static void try_to_simplify_commit(struct rev_info *revs, struct commit *commit)\n-- \n1.5.0.3.1036.g6baf1\n"},{"id":"37113","messageId":"7v7itj7bz7.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"7vwt1j8z0e.fsf@assigned-by-dhcp.cox.net","subject":"[PATCH 5/5] try-to-simplify-commit: use diff-tree --quiet machinery.","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T21:26:52Z","receivedAt":"2007-03-14T21:26:52Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This uses diff-tree --quiet machinery to terminate the internal\ndiff-tree between a commit and its parents via revs.pruning (not\nrevs.diffopt) as soon as we find enough about the tree change.\n\nWith respect to the optionally given pathspec, we are interested\nif the tree of commit is identical to the parent's, only adds\nnew paths to the parent's, or there are other differences.  As\nsoon as we find out that there is one such other kind of\ndifference, we do not have to compare the rest of the tree.\n\nBecause we do not call standard diff_addremove/diff_change, we\ninstruct the diff-tree machinery to stop early by setting\nhas_changes when we say we found the trees to be different.\n\nSigned-off-by: Junio C Hamano <junkio@cox.net>\n---\n revision.c |    6 ++++++\n 1 files changed, 6 insertions(+), 0 deletions(-)\n\ndiff --git a/revision.c b/revision.c\nindex 129d197..bcdb6a1 100644\n--- a/revision.c\n+++ b/revision.c\n@@ -243,6 +243,8 @@ static void file_add_remove(struct diff_options *options,\n \t\tdiff = REV_TREE_NEW;\n \t}\n \ttree_difference = diff;\n+\tif (tree_difference == REV_TREE_DIFFERENT)\n+\t\toptions->has_changes = 1;\n }\n \n static void file_change(struct diff_options *options,\n@@ -252,6 +254,7 @@ static void file_change(struct diff_options *options,\n \t\t const char *base, const char *path)\n {\n \ttree_difference = REV_TREE_DIFFERENT;\n+\toptions->has_changes = 1;\n }\n \n int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)\n@@ -261,6 +264,7 @@ int rev_compare_tree(struct rev_info *revs, struct tree *t1, struct tree *t2)\n \tif (!t2)\n \t\treturn REV_TREE_DIFFERENT;\n \ttree_difference = REV_TREE_SAME;\n+\trevs->pruning.has_changes = 0;\n \tif (diff_tree_sha1(t1->object.sha1, t2->object.sha1, \"\",\n \t\t\t   &revs->pruning) < 0)\n \t\treturn REV_TREE_DIFFERENT;\n@@ -285,6 +289,7 @@ int rev_same_tree_as_empty(struct rev_info *revs, struct tree *t1)\n \tempty.size = 0;\n \n \ttree_difference = REV_TREE_SAME;\n+\trevs->pruning.has_changes = 0;\n \tretval = diff_tree(&empty, &real, \"\", &revs->pruning);\n \tfree(tree);\n \n@@ -552,6 +557,7 @@ void init_revisions(struct rev_info *revs, const char *prefix)\n \trevs->ignore_merges = 1;\n \trevs->simplify_history = 1;\n \trevs->pruning.recursive = 1;\n+\trevs->pruning.quiet = 1;\n \trevs->pruning.add_remove = file_add_remove;\n \trevs->pruning.change = file_change;\n \trevs->lifo = 1;\n-- \n1.5.0.3.1036.g6baf1\n"},{"id":"37121","messageId":"81b0412b0703141533q4e71e67aqaa83de45fa9e3988@mail.gmail.com","threadId":"7245","inReplyTo":"7vodmv7bza.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-14T22:33:14Z","receivedAt":"2007-03-14T22:33:14Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/14/07, Junio C Hamano <junkio@cox.net> wrote:\n> The --quiet option is silently turned off (but --exit-code is\n> still in effect, so is silent output) if postprocessing filters\n> such as pickaxe and diff-filter are used.  For all practical\n> purposes I do not think of a reason to want to use these filters\n> and not viewing the diff output.\n\npickaxe filter can be useful in hooks to enforce policy\non use of some constructs. I can well imagine (do not\neven have to imagine) a stupid company policy forbidding\ncommits with \"\\<printf\\>\" in them. Have no idea for\ndiff-filter though.\n"},{"id":"37122","messageId":"81b0412b0703141554r524346d0kf73a5d43b49ed99a@mail.gmail.com","threadId":"7245","inReplyTo":"81b0412b0703141533q4e71e67aqaa83de45fa9e3988@mail.gmail.com","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-14T22:54:45Z","receivedAt":"2007-03-14T22:54:45Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/14/07, Alex Riesen <raa.lkml@gmail.com> wrote:\n> On 3/14/07, Junio C Hamano <junkio@cox.net> wrote:\n> > The --quiet option is silently turned off (but --exit-code is\n> > still in effect, so is silent output) if postprocessing filters\n> > such as pickaxe and diff-filter are used.  For all practical\n> > purposes I do not think of a reason to want to use these filters\n> > and not viewing the diff output.\n>\n> pickaxe filter can be useful in hooks to enforce policy\n\nActually, I find it a bit strange to leave the output silent,\nif --quiet is turned off. For all the user sees, it is still quiet\nand exit-coded, just slow. Suggest either restore the\noutput format when turning the option off or not turning\nit off at all (if possible. Is it?)\n"},{"id":"37127","messageId":"81b0412b0703141614m70f4a565qc001e06e60b0ffd5@mail.gmail.com","threadId":"7245","inReplyTo":"7vodmv7bza.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-14T23:14:55Z","receivedAt":"2007-03-14T23:14:55Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/14/07, Junio C Hamano <junkio@cox.net> wrote:\n> This adds the command line option 'quiet' to tell 'git diff-*'\n> that we are not interested in the actual diff contents but only\n> want to know if there is any change.  This option automatically\n> turns --exit-code on, and turns off output formatting, as it\n> does not make much sense to show the first hit we happened to\n> have found.\n\nNow I'm happy :)\n\n~/linux$ time git diff-tree -r -s v2.6.16 v2.6.20\n\nreal    0m0.137s\nuser    0m0.117s\nsys     0m0.020s\n~/linux$ time ~/projects/git-diff/git-diff-tree -r --quiet v2.6.16 v2.6.20\n\nreal    0m0.006s\nuser    0m0.000s\nsys     0m0.007s\n"},{"id":"37130","messageId":"7vlkhz5rd6.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"81b0412b0703141554r524346d0kf73a5d43b49ed99a@mail.gmail.com","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T23:37:25Z","receivedAt":"2007-03-14T23:37:25Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> Actually, I find it a bit strange to leave the output silent,\n> if --quiet is turned off. For all the user sees, it is still quiet\n> and exit-coded\n\nFor that exact reason, for all the user cares, it is better to\nleave the output turned off and result given back with exit\nstatus.  --quiet is really for scripted use, in other words.\n\nI wonder if we should perhaps turn off the PAGER when --exit-code\nor --quiet is given.\n"},{"id":"37132","messageId":"7v8xdz5qn0.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"81b0412b0703141614m70f4a565qc001e06e60b0ffd5@mail.gmail.com","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-14T23:53:07Z","receivedAt":"2007-03-14T23:53:07Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Alex Riesen\" <raa.lkml@gmail.com> writes:\n\n> Now I'm happy :)\n>\n> ~/linux$ time git diff-tree -r -s v2.6.16 v2.6.20\n>\n> real    0m0.137s\n> user    0m0.117s\n> sys     0m0.020s\n> ~/linux$ time ~/projects/git-diff/git-diff-tree -r --quiet v2.6.16 v2.6.20\n>\n> real    0m0.006s\n> user    0m0.000s\n> sys     0m0.007s\n\nYou do not need diff-tree --quiet to do that!\n\n\t$ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n"},{"id":"37145","messageId":"Pine.LNX.4.64.0703141728350.9690@woody.linux-foundation.org","threadId":"7245","inReplyTo":"7v8xdz5qn0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-03-15T00:33:25Z","receivedAt":"2007-03-15T00:33:25Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 14 Mar 2007, Junio C Hamano wrote:\n\n> \"Alex Riesen\" <raa.lkml@gmail.com> writes:\n> \n> > Now I'm happy :)\n> >\n> > ~/linux$ time git diff-tree -r -s v2.6.16 v2.6.20\n> >\n> > real    0m0.137s\n> > user    0m0.117s\n> > sys     0m0.020s\n> > ~/linux$ time ~/projects/git-diff/git-diff-tree -r --quiet v2.6.16 v2.6.20\n> >\n> > real    0m0.006s\n> > user    0m0.000s\n> > sys     0m0.007s\n> \n> You do not need diff-tree --quiet to do that!\n> \n> \t$ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n\nWell, if you have a path-spec, it can certainly matter.\n\nPersonally, I think it's more interesting if this can make a difference \nfor something like\n\n\tgit log v2.6.12.. -- drivers/ > /dev/null\n\nbut that would require that we actually understand that we can stop early \nif we ever get to REV_TREE_DIFFERENT. I didn't check if you actually did \nthat optimization.\n\n\t\tLinus\n"},{"id":"37147","messageId":"7v4pon5mg3.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"Pine.LNX.4.64.0703141728350.9690@woody.linux-foundation.org","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-15T01:23:40Z","receivedAt":"2007-03-15T01:23:40Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Linus Torvalds <torvalds@linux-foundation.org> writes:\n\n> On Wed, 14 Mar 2007, Junio C Hamano wrote:\n>\n>> \"Alex Riesen\" <raa.lkml@gmail.com> writes:\n>> \n>> > Now I'm happy :)\n>> >\n>> > ~/linux$ time git diff-tree -r -s v2.6.16 v2.6.20\n>> >\n>> > real    0m0.137s\n>> > user    0m0.117s\n>> > sys     0m0.020s\n>> > ~/linux$ time ~/projects/git-diff/git-diff-tree -r --quiet v2.6.16 v2.6.20\n>> >\n>> > real    0m0.006s\n>> > user    0m0.000s\n>> > sys     0m0.007s\n>> \n>> You do not need diff-tree --quiet to do that!\n>> \n>> \t$ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n>\n> Well, if you have a path-spec, it can certainly matter.\n>\n> Personally, I think it's more interesting if this can make a difference \n> for something like\n>\n> \tgit log v2.6.12.. -- drivers/ > /dev/null\n>\n> but that would require that we actually understand that we can stop early \n> if we ever get to REV_TREE_DIFFERENT. I didn't check if you actually did \n> that optimization.\n\nThe code is supposed to be there, but I haven't benched.\n"},{"id":"37150","messageId":"7vy7lz3svl.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"7v4pon5mg3.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-15T06:47:42Z","receivedAt":"2007-03-15T06:47:42Z","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> Linus Torvalds <torvalds@linux-foundation.org> writes:\n>\n>> Personally, I think it's more interesting if this can make a difference \n>> for something like\n>>\n>> \tgit log v2.6.12.. -- drivers/ > /dev/null\n>>\n>> but that would require that we actually understand that we can stop early \n>> if we ever get to REV_TREE_DIFFERENT. I didn't check if you actually did \n>> that optimization.\n>\n> The code is supposed to be there, but I haven't benched.\n\nNow I have.\n\nIn the kernel repository, I ran this with 'master' version and 'next'\nversion.  The latter uses the --quick mechanism in try_to_simplify.\n\n$ /usr/bin/time git log -r --raw v2.6.19..master -- drivers/ | wc -l\n\nThree runs on a reasonably quiescent machine (hot cache).\n\n* next (i.e. with the --quick)\n\n5.50user 0.10system 0:05.61elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k\n0inputs+0outputs (0major+15191minor)pagefaults 0swaps\n\n5.50user 0.08system 0:05.58elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k\n0inputs+0outputs (0major+15191minor)pagefaults 0swaps\n\n5.42user 0.07system 0:05.49elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k\n0inputs+0outputs (0major+15192minor)pagefaults 0swaps\n\n* master (without)\n\n7.50user 0.08system 0:07.59elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k\n0inputs+0outputs (0major+15487minor)pagefaults 0swaps\n\n7.70user 0.06system 0:07.77elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k\n0inputs+0outputs (0major+15487minor)pagefaults 0swaps\n\n7.51user 0.08system 0:07.60elapsed 99%CPU (0avgtext+0avgdata 0maxresident)k\n0inputs+0outputs (0major+15487minor)pagefaults 0swaps\n"},{"id":"37151","messageId":"81b0412b0703150119l705eefb6h6af44b9452db83e2@mail.gmail.com","threadId":"7245","inReplyTo":"7v8xdz5qn0.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-15T08:19:19Z","receivedAt":"2007-03-15T08:19:19Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/15/07, Junio C Hamano <junkio@cox.net> wrote:\n> > Now I'm happy :)\n> >\n> > ~/linux$ time git diff-tree -r -s v2.6.16 v2.6.20\n> >\n> > real    0m0.137s\n> > user    0m0.117s\n> > sys     0m0.020s\n> > ~/linux$ time ~/projects/git-diff/git-diff-tree -r --quiet v2.6.16 v2.6.20\n> >\n> > real    0m0.006s\n> > user    0m0.000s\n> > sys     0m0.007s\n>\n> You do not need diff-tree --quiet to do that!\n>\n>         $ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n>\n\nWhy would I want to benchmark --quiet with rev-parse?\n"},{"id":"37152","messageId":"81b0412b0703150122k5a0f1d7u2d2c86e32ff8bbbd@mail.gmail.com","threadId":"7245","inReplyTo":"7vlkhz5rd6.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-15T08:22:13Z","receivedAt":"2007-03-15T08:22:13Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/15/07, Junio C Hamano <junkio@cox.net> wrote:\n> \"Alex Riesen\" <raa.lkml@gmail.com> writes:\n>\n> > Actually, I find it a bit strange to leave the output silent,\n> > if --quiet is turned off. For all the user sees, it is still quiet\n> > and exit-coded\n>\n> For that exact reason, for all the user cares, it is better to\n> leave the output turned off and result given back with exit\n> status.  --quiet is really for scripted use, in other words.\n\nOf course! That's also were the performance matters.\nCan diff quit early if -Ssomething given?\n\n> I wonder if we should perhaps turn off the PAGER when --exit-code\n> or --quiet is given.\n>\n\nSecond that.Even is just to be on safe side. But again, it is not obvious\nin case of --exit-code.\n"},{"id":"37156","messageId":"Pine.LNX.4.63.0703151136470.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"7245","inReplyTo":"81b0412b0703150119l705eefb6h6af44b9452db83e2@mail.gmail.com","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-03-15T10:37:52Z","receivedAt":"2007-03-15T10:37:52Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Mar 2007, Alex Riesen wrote:\n\n> On 3/15/07, Junio C Hamano <junkio@cox.net> wrote:\n> > > Now I'm happy :)\n> > >\n> > > ~/linux$ time git diff-tree -r -s v2.6.16 v2.6.20\n> > >\n> > > real    0m0.137s\n> > > user    0m0.117s\n> > > sys     0m0.020s\n> > > ~/linux$ time ~/projects/git-diff/git-diff-tree -r --quiet v2.6.16\n> > v2.6.20\n> > >\n> > > real    0m0.006s\n> > > user    0m0.000s\n> > > sys     0m0.007s\n> > \n> > You do not need diff-tree --quiet to do that!\n> > \n> >         $ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n> > \n> \n> Why would I want to benchmark --quiet with rev-parse?\n\nIt is not benchmarking, but it is a faster solution: you can see if two \ntrees are different by comparing their SHA-1s.\n\n(That, however, works only if you do not want something like \"git diff \n-w\"...)\n\nCiao,\nDscho\n"},{"id":"37158","messageId":"81b0412b0703150655y3d2a71d3t8db6e334ecf23ca1@mail.gmail.com","threadId":"7245","inReplyTo":"Pine.LNX.4.63.0703151136470.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-15T13:55:01Z","receivedAt":"2007-03-15T13:55:01Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/15/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > >         $ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n> > >\n> >\n> > Why would I want to benchmark --quiet with rev-parse?\n>\n> It is not benchmarking, but it is a faster solution: you can see if two\n> trees are different by comparing their SHA-1s.\n\nCan the same be done for index? (index-tree comparison)\n\n> (That, however, works only if you do not want something like \"git diff\n> -w\"...)\n\nWhy? Can't \"git diff -w\" quit early?\n"},{"id":"37169","messageId":"Pine.LNX.4.64.0703150900020.3816@woody.linux-foundation.org","threadId":"7245","inReplyTo":"7vy7lz3svl.fsf@assigned-by-dhcp.cox.net","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Linus Torvalds","fromEmail":"torvalds@linux-foundation.org","sentAt":"2007-03-15T16:08:02Z","receivedAt":"2007-03-15T16:08:02Z","isPatch":true,"sender":{"key":"torvalds@linux-foundation.org","avatar":"https://avatars.githubusercontent.com/u/1024025?v=4"},"body":"\n\nOn Wed, 14 Mar 2007, Junio C Hamano wrote:\n> >\n> > The code is supposed to be there, but I haven't benched.\n> \n> Now I have.\n\nYou da man!\n\n> In the kernel repository, I ran this with 'master' version and 'next'\n> version.  The latter uses the --quick mechanism in try_to_simplify.\n> \n> $ /usr/bin/time git log -r --raw v2.6.19..master -- drivers/ | wc -l\n\n> Three runs on a reasonably quiescent machine (hot cache).\n\nImpressive, although not entirely surprising. \"try_to_simplify()\" is \nreally the most performance-sensitive part of git.\n\nI get a similar reduction for that load: 0:04.63 to 0:03.43 elapsed.\n\nGood job.\n\n\t\tLinus\n"},{"id":"37174","messageId":"Pine.LNX.4.63.0703151841180.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"7245","inReplyTo":"81b0412b0703150655y3d2a71d3t8db6e334ecf23ca1@mail.gmail.com","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-03-15T17:43:02Z","receivedAt":"2007-03-15T17:43:02Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Mar 2007, Alex Riesen wrote:\n\n> On 3/15/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > >         $ git-rev-parse v2.6.16^{tree} v2.6.20^{tree}\n> > > >\n> > >\n> > > Why would I want to benchmark --quiet with rev-parse?\n> > \n> > It is not benchmarking, but it is a faster solution: you can see if two\n> > trees are different by comparing their SHA-1s.\n> \n> Can the same be done for index? (index-tree comparison)\n\nTheoretically, yes. Only that Junio did not accept my short-cut \":dir/\" \nnotation to mean \"take the cache-tree from the index, or if it is dirty, \nconstruct it\". However, in the latter case, it would not be a speed \nimprovement, but the opposite.\n\n> > (That, however, works only if you do not want something like \"git diff\n> > -w\"...)\n> \n> Why? Can't \"git diff -w\" quit early?\n\nNo, but \"-w\" means \"ignore white space\", which means that blobs can be \ndeemed equal, even if they differ at the byte-per-byte level.\n\nCiao,\nDscho\n"},{"id":"37178","messageId":"81b0412b0703151408v5e6245f4l95fb7cc801e1b568@mail.gmail.com","threadId":"7245","inReplyTo":"Pine.LNX.4.63.0703151841180.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Alex Riesen","fromEmail":"raa.lkml@gmail.com","sentAt":"2007-03-15T21:08:18Z","receivedAt":"2007-03-15T21:08:18Z","isPatch":true,"sender":{"key":"raa.lkml@gmail.com","avatar":"https://avatars.githubusercontent.com/u/324101?v=4"},"body":"On 3/15/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > (That, however, works only if you do not want something like \"git diff\n> > > -w\"...)\n> >\n> > Why? Can't \"git diff -w\" quit early?\n>\n> No, but \"-w\" means \"ignore white space\", which means that blobs can be\n> deemed equal, even if they differ at the byte-per-byte level.\n>\n\nSo it can leave early as soon as it found a difference on byte level\nand the difference is not white space, can't it?\n"},{"id":"37179","messageId":"Pine.LNX.4.63.0703152211050.22628@wbgn013.biozentrum.uni-wuerzburg.de","threadId":"7245","inReplyTo":"81b0412b0703151408v5e6245f4l95fb7cc801e1b568@mail.gmail.com","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2007-03-15T21:12:19Z","receivedAt":"2007-03-15T21:12:19Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Thu, 15 Mar 2007, Alex Riesen wrote:\n\n> On 3/15/07, Johannes Schindelin <Johannes.Schindelin@gmx.de> wrote:\n> > > > (That, however, works only if you do not want something like \"git diff\n> > > > -w\"...)\n> > >\n> > > Why? Can't \"git diff -w\" quit early?\n> > \n> > No, but \"-w\" means \"ignore white space\", which means that blobs can be\n\n> > deemed equal, even if they differ at the byte-per-byte level.\n> \n> So it can leave early as soon as it found a difference on byte level\n> and the difference is not white space, can't it?\n\nYes.\n\nThe point I tried to make: without \"-w\" or \"-b\", you can compare at the \ntree level. No need for a --quiet option. (Of course, you showed me that \nyou'd need it for index-tree comparisons anyway.)\n\nCiao,\nDscho\n"},{"id":"37182","messageId":"7v3b4611rk.fsf@assigned-by-dhcp.cox.net","threadId":"7245","inReplyTo":"Pine.LNX.4.63.0703152211050.22628@wbgn013.biozentrum.uni-wuerzburg.de","subject":"Re: [PATCH 2/5] diff --quiet","fromName":"Junio C Hamano","fromEmail":"junkio@cox.net","sentAt":"2007-03-16T00:16:15Z","receivedAt":"2007-03-16T00:16:15Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:\n\n> The point I tried to make: without \"-w\" or \"-b\", you can compare at the \n> tree level. No need for a --quiet option.\n\nThat's not true.  The --quiet option is not about comparing at\nthe tree level vs looking inside the blobs.  It helps to\noptimize the tree level comparison as well.  The difference\nLinus was happy about comes from exactly the early exit from\ntree comparison.\n\nThe current --quiet will report if they are different at the\ntree level and does not take filtering done at the later phases\ninto account at all, and that is a conscious design decision so\nthat we can use it for optimizing try_to_simplify_commit().  So\nfor example, if you have any change that a plain \"git diff-*\"\nsays there are differences, the option reports there indeed are\ndifferences, like this:\n\n\t$ git reset --hard ;# start from the clean state\n        $ touch Makefile\n        $ git diff-files -p\n        diff --git a/Makefile b/Makefile\n        $ git diff-files --quiet; echo $?\n\t1\n\nI didn't consider -w nor -b when I made the design decision that\nleads to the above behaviour, but I think the filtering done at\nthe textual patch generation phase falls into the same category.\nIf you do the following, the answer would be \"they are\ndifferent\":\n\n\t$ sed -e 's/$/ /' <Makefile >Makefile+\n        $ cat Makefile+ >Makefile\n        $ rm Makefile+\n        $ git update-index --refresh\n        $ git diff-files -b -p\n        diff --git a/Makefile b/Makefile\n        index dc024d4..1c328be 100644\n        $ git diff-files -b -p --quiet; echo $?\n        1\n\nOptions like -w and -b are only about not showing the lines; you\nstill get the diff header that reports they are different.  So\nin that sense the output from the last command above is correct.\n\nI am however wondering if we want to have (and if it would be\nworth the trouble to add) an option to have the command say if\nthere will be textual difference output without producing it.  I\ndo not see much value in it right now, but it might turn out to\nbe handy.  I do suspect that would be a rather intrusive and\nerror prone change, though.\n\nA good news is that such an option needs to work at a different\nlevel than the existing --quiet, which works in diffcore_std().\nThe new option would probably need to work inside diff_flush()\nwhich is a later phase.  So no matter how you screw up, it would\nhopefully not break revision traversal too much.\n\nWe might want to rename the existing one --quick and name that\nnew option --quiet, though, if we go that route.\n"}]}