{"thread":{"id":"10635","subject":"[PATCH] git-reset: add -q option to operate quietly","startedAt":"2007-11-04T09:37:20Z","lastAt":"2007-11-04T09:37:20Z","messageCount":1,"participants":["Gerrit Pape"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"58234","messageId":"20071104093720.6950.qmail@e7d9732ff18748.315fe32.mid.smarden.org","threadId":"10635","inReplyTo":null,"subject":"[PATCH] git-reset: add -q option to operate quietly","fromName":"Gerrit Pape","fromEmail":"pape@smarden.org","sentAt":"2007-11-04T09:37:20Z","receivedAt":"2007-11-04T09:37:20Z","isPatch":true,"sender":{"key":"pape@smarden.org","avatar":"https://avatars.githubusercontent.com/u/143170252?v=4"},"body":"Many git commands have a -q option to suppress output to stdout, let's\nhave it for git-reset too.\n\nThis was asked for by Joey Hess through\n http://bugs.debian.org/444933\n\nSigned-off-by: Gerrit Pape <pape@smarden.org>\n---\n Documentation/git-reset.txt |    7 +++++--\n builtin-reset.c             |   14 ++++++++++----\n 2 files changed, 15 insertions(+), 6 deletions(-)\n\ndiff --git a/Documentation/git-reset.txt b/Documentation/git-reset.txt\nindex 87afa6f..050e4ea 100644\n--- a/Documentation/git-reset.txt\n+++ b/Documentation/git-reset.txt\n@@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state\n SYNOPSIS\n --------\n [verse]\n-'git-reset' [--mixed | --soft | --hard] [<commit>]\n-'git-reset' [--mixed] <commit> [--] <paths>...\n+'git-reset' [--mixed | --soft | --hard] [-q] [<commit>]\n+'git-reset' [--mixed] [-q] <commit> [--] <paths>...\n \n DESCRIPTION\n -----------\n@@ -45,6 +45,9 @@ OPTIONS\n \tswitched to. Any changes to tracked files in the working tree\n \tsince <commit> are lost.\n \n+-q::\n+\tBe quiet, only report errors.\n+\n <commit>::\n \tCommit to make the current HEAD.\n \ndiff --git a/builtin-reset.c b/builtin-reset.c\nindex e1dc31e..dd301df 100644\n--- a/builtin-reset.c\n+++ b/builtin-reset.c\n@@ -18,7 +18,7 @@\n #include \"tree.h\"\n \n static const char builtin_reset_usage[] =\n-\"git-reset [--mixed | --soft | --hard]  [<commit-ish>] [ [--] <paths>...]\";\n+\"git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]\";\n \n static char *args_to_str(const char **argv)\n {\n@@ -173,7 +173,7 @@ static const char *reset_type_names[] = { \"mixed\", \"soft\", \"hard\", NULL };\n \n int cmd_reset(int argc, const char **argv, const char *prefix)\n {\n-\tint i = 1, reset_type = NONE, update_ref_status = 0;\n+\tint i = 1, reset_type = NONE, update_ref_status = 0, quiet = 0;\n \tconst char *rev = \"HEAD\";\n \tunsigned char sha1[20], *orig = NULL, sha1_orig[20],\n \t\t\t\t*old_orig = NULL, sha1_old_orig[20];\n@@ -185,7 +185,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \treflog_action = args_to_str(argv);\n \tsetenv(\"GIT_REFLOG_ACTION\", reflog_action, 0);\n \n-\tif (i < argc) {\n+\twhile (i < argc) {\n \t\tif (!strcmp(argv[i], \"--mixed\")) {\n \t\t\treset_type = MIXED;\n \t\t\ti++;\n@@ -198,6 +198,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \t\t\treset_type = HARD;\n \t\t\ti++;\n \t\t}\n+\t\telse if (!strcmp(argv[i], \"-q\")) {\n+\t\t\tquiet = 1;\n+\t\t\ti++;\n+\t\t}\n+\t\telse\n+\t\t\tbreak;\n \t}\n \n \tif (i < argc && argv[i][0] != '-')\n@@ -258,7 +264,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)\n \n \tswitch (reset_type) {\n \tcase HARD:\n-\t\tif (!update_ref_status)\n+\t\tif (!update_ref_status && !quiet)\n \t\t\tprint_new_head_line(commit);\n \t\tbreak;\n \tcase SOFT: /* Nothing else to do. */\n-- \n1.5.3.5\n"}]}