{"thread":{"id":"14682","subject":"[PATCH] git-reset: Let -q hush \"locally modified\" messages","startedAt":"2008-07-25T20:49:08Z","lastAt":"2008-07-26T02:34:27Z","messageCount":5,"participants":["Stephan Beyer","Junio C Hamano","Johannes Schindelin"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"84946","messageId":"1217018948-32475-1-git-send-email-s-beyer@gmx.net","threadId":"14682","inReplyTo":null,"subject":"[PATCH] git-reset: Let -q hush \"locally modified\" messages","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-25T20:49:08Z","receivedAt":"2008-07-25T20:49:08Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"git reset -q makes reset more quiet, but \"locally modified\" messages are\nstill shown.  This patch makes them disappear, too.\n\nSigned-off-by: Stephan Beyer <s-beyer@gmx.net>\n---\n\nHi,\n\nI don't know if this was actually a bug or a feature.\nI considered this a bug, so here's a patch.\n\nRegards,\n  Stephan\n\n\n builtin-reset.c |   15 +++++++++------\n 1 files changed, 9 insertions(+), 6 deletions(-)\n\ndiff --git a/builtin-reset.c b/builtin-reset.c\nindex 4d246c3..c24c219 100644\n--- a/builtin-reset.c\n+++ b/builtin-reset.c\n@@ -85,7 +85,7 @@ static void print_new_head_line(struct commit *commit)\n \t\tprintf(\"\\n\");\n }\n \n-static int update_index_refresh(int fd, struct lock_file *index_lock)\n+static int update_index_refresh(int fd, struct lock_file *index_lock, int flags)\n {\n \tint result;\n \n@@ -96,7 +96,8 @@ static int update_index_refresh(int fd, struct lock_file *index_lock)\n \n \tif (read_cache() < 0)\n \t\treturn error(\"Could not read index\");\n-\tresult = refresh_cache(REFRESH_SAY_CHANGED) ? 1 : 0;\n+\n+\tresult = refresh_cache(flags) ? 1 : 0;\n \tif (write_cache(fd, active_cache, active_nr) ||\n \t\t\tcommit_locked_index(index_lock))\n \t\treturn error (\"Could not refresh index\");\n@@ -128,7 +129,7 @@ static void update_index_from_diff(struct diff_queue_struct *q,\n }\n \n static int read_from_tree(const char *prefix, const char **argv,\n-\t\tunsigned char *tree_sha1)\n+\t\tunsigned char *tree_sha1, int refresh_flags)\n {\n \tstruct lock_file *lock = xcalloc(1, sizeof(struct lock_file));\n \tint index_fd, index_was_discarded = 0;\n@@ -152,7 +153,7 @@ static int read_from_tree(const char *prefix, const char **argv,\n \tif (!index_was_discarded)\n \t\t/* The index is still clobbered from do_diff_cache() */\n \t\tdiscard_cache();\n-\treturn update_index_refresh(index_fd, lock);\n+\treturn update_index_refresh(index_fd, lock, refresh_flags);\n }\n \n static void prepend_reflog_action(const char *action, char *buf, size_t size)\n@@ -246,7 +247,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\telse if (reset_type != NONE)\n \t\t\tdie(\"Cannot do %s reset with paths.\",\n \t\t\t\t\treset_type_names[reset_type]);\n-\t\treturn read_from_tree(prefix, argv + i, sha1);\n+\t\treturn read_from_tree(prefix, argv + i, sha1,\n+\t\t\t\tquiet ? REFRESH_QUIET : REFRESH_SAY_CHANGED);\n \t}\n \tif (reset_type == NONE)\n \t\treset_type = MIXED; /* by default */\n@@ -286,7 +288,8 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \tcase SOFT: /* Nothing else to do. */\n \t\tbreak;\n \tcase MIXED: /* Report what has not been updated. */\n-\t\tupdate_index_refresh(0, NULL);\n+\t\tupdate_index_refresh(0, NULL,\n+\t\t\t\tquiet ? REFRESH_QUIET : REFRESH_SAY_CHANGED);\n \t\tbreak;\n \t}\n \n-- \n1.6.0.rc0.49.g3d2ce\n"},{"id":"84950","messageId":"7vwsj9r722.fsf@gitster.siamese.dyndns.org","threadId":"14682","inReplyTo":"1217018948-32475-1-git-send-email-s-beyer@gmx.net","subject":"Re: [PATCH] git-reset: Let -q hush \"locally modified\" messages","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-25T21:24:21Z","receivedAt":"2008-07-25T21:24:21Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephan Beyer <s-beyer@gmx.net> writes:\n\n> git reset -q makes reset more quiet, but \"locally modified\" messages are\n> still shown.  This patch makes them disappear, too.\n\nFiles being \"locally modified\" is not and error, so I think it is in line\nwith the spirit of what -q is meant to do.\n\nIt is an interface change, though.\n"},{"id":"84953","messageId":"20080725213853.GD13539@leksak.fem-net","threadId":"14682","inReplyTo":"7vwsj9r722.fsf@gitster.siamese.dyndns.org","subject":"Re: [PATCH] git-reset: Let -q hush \"locally modified\" messages","fromName":"Stephan Beyer","fromEmail":"s-beyer@gmx.net","sentAt":"2008-07-25T21:38:53Z","receivedAt":"2008-07-25T21:38:53Z","isPatch":true,"sender":{"key":"s-beyer@gmx.net","avatar":"https://avatars.githubusercontent.com/u/143889?v=4"},"body":"Hi,\n\nJunio C Hamano wrote:\n> Stephan Beyer <s-beyer@gmx.net> writes:\n> \n> > git reset -q makes reset more quiet, but \"locally modified\" messages are\n> > still shown.  This patch makes them disappear, too.\n> \n> Files being \"locally modified\" is not and error, so I think it is in line\n> with the spirit of what -q is meant to do.\n> \n> It is an interface change, though.\n\nYes, as \"needs update\" -> \"locally modified\" was.\n\nHowever, scripts, that rely on filenames when doing -q (whyever),\nwill break.\n\nSo should I stick to \"git reset -q foo >/dev/null\" if I want it quiet,\nor is there some chance of inclusion?\n\nRegards,\n  Stephan\n\n-- \nStephan Beyer <s-beyer@gmx.net>, PGP 0x6EDDD207FCC5040F\n"},{"id":"84962","messageId":"7vej5hr521.fsf@gitster.siamese.dyndns.org","threadId":"14682","inReplyTo":"20080725213853.GD13539@leksak.fem-net","subject":"Re: [PATCH] git-reset: Let -q hush \"locally modified\" messages","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-25T22:07:34Z","receivedAt":"2008-07-25T22:07:34Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Stephan Beyer <s-beyer@gmx.net> writes:\n\n> Junio C Hamano wrote:\n> ...\n>> Files being \"locally modified\" is not and error, so I think it is in line\n>> with the spirit of what -q is meant to do.\n>> \n>> It is an interface change, though.\n>\n> Yes, as \"needs update\" -> \"locally modified\" was.\n>\n> However, scripts, that rely on filenames when doing -q (whyever),\n> will break.\n\nI was not worried about scripts.  \"reset\" is a Porcelain, and it is Ok for\nthe scripts to use it and rely on what it does (e.g. \"git reset HEAD^\"\nwill move the HEAD one commit back and match your index to it), but they\nshould not be depending on its output to be parsable.  Perhaps it is Ok\nfor them to detect if there is any change by observing if it spits out\nanything, but that is about it.  So the earlier change to use \"locall\nmodified\" does not really matter in that sense, but squelching the output\naltogether is a change with bigger impact.  With your patch, we declare\nthat the scripts should not assume anything about its output.\n\nI was more worried about expectation from human users.  We used to get a\nreminder of the paths that are different from the HEAD/index, even with\nthe \"-q\" option, in the form of human-readable list of paths.  Your patch\nchanges that.\n\nHaving said all that (the only reason I said the above is not because I\nthink this particular interface change is a big deal, but because I wanted\nto explain what kind of interface change I do and do _not_ care about when\nwe talk about Porcelain), when the user explicitly gives \"-q\" to the\ncommand, I think it is Ok to assume that the user does not want to hear\nanything back.  I do not see any fundamental problem with your patch in\nthat sense.\n\nIt still is an interface change, though ;-)\n"},{"id":"84985","messageId":"alpine.DEB.1.00.0807260433250.11976@eeepc-johanness","threadId":"14682","inReplyTo":"20080725213853.GD13539@leksak.fem-net","subject":"Re: [PATCH] git-reset: Let -q hush \"locally modified\" messages","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-26T02:34:27Z","receivedAt":"2008-07-26T02:34:27Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Fri, 25 Jul 2008, Stephan Beyer wrote:\n\n> Junio C Hamano wrote:\n> > Stephan Beyer <s-beyer@gmx.net> writes:\n> > \n> > > git reset -q makes reset more quiet, but \"locally modified\" messages \n> > > are still shown.  This patch makes them disappear, too.\n> > \n> > Files being \"locally modified\" is not and error, so I think it is in \n> > line with the spirit of what -q is meant to do.\n> > \n> > It is an interface change, though.\n> \n> Yes, as \"needs update\" -> \"locally modified\" was.\n\nBut that is not about scripts.  Scripts have no business calling pure \nporcelain, so they still get \"needs update\" if done properly.\n\nHth,\nDscho\n"}]}