git-reset: add -q option to operate quietly
Many git commands have a -q option to suppress output to stdout, let's have it for git-reset too. This was asked for by Joey Hess through http://bugs.debian.org/444933 Signed-off-by: Gerrit Pape <pape@smarden.org> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Gerrit Pape committed
Nov 4, 2007 at 09:37 UTC
521b53e5c7ee23a137e903d99108f81d44cca5ec
2 files changed
+15
-6
Documentation/git-reset.txt
+5
-2
@@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state
8
SYNOPSIS
9
--------
10
[verse]
11
-'git-reset' [--mixed | --soft | --hard] [<commit>]
12
-'git-reset' [--mixed] <commit> [--] <paths>...
11
+'git-reset' [--mixed | --soft | --hard] [-q] [<commit>]
12
+'git-reset' [--mixed] [-q] <commit> [--] <paths>...
13
14
DESCRIPTION
15
-----------
@@ -45,6 +45,9 @@ OPTIONS
45
switched to. Any changes to tracked files in the working tree
46
since <commit> are lost.
47
48
+-q::
49
+ Be quiet, only report errors.
50
+
51
<commit>::
52
Commit to make the current HEAD.
53
builtin-reset.c
+10
-4
@@ -18,7 +18,7 @@
18
#include "tree.h"
19
20
static const char builtin_reset_usage[] =
21
-"git-reset [--mixed | --soft | --hard] [<commit-ish>] [ [--] <paths>...]";
21
+"git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]";
22
23
static char *args_to_str(const char **argv)
24
{
@@ -185,7 +185,7 @@ static const char *reset_type_names[] = { "mixed", "soft", "hard", NULL };
185
186
int cmd_reset(int argc, const char **argv, const char *prefix)
187
{
188
- int i = 1, reset_type = NONE, update_ref_status = 0;
188
+ int i = 1, reset_type = NONE, update_ref_status = 0, quiet = 0;
189
const char *rev = "HEAD";
190
unsigned char sha1[20], *orig = NULL, sha1_orig[20],
191
*old_orig = NULL, sha1_old_orig[20];
@@ -197,7 +197,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
197
reflog_action = args_to_str(argv);
198
setenv("GIT_REFLOG_ACTION", reflog_action, 0);
199
200
- if (i < argc) {
200
+ while (i < argc) {
201
if (!strcmp(argv[i], "--mixed")) {
202
reset_type = MIXED;
203
i++;
@@ -210,6 +210,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
210
reset_type = HARD;
211
i++;
212
}
213
+ else if (!strcmp(argv[i], "-q")) {
214
+ quiet = 1;
215
+ i++;
216
+ }
217
+ else
218
+ break;
219
}
220
221
if (i < argc && argv[i][0] != '-')
@@ -270,7 +276,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
276
277
switch (reset_type) {
278
case HARD:
273
- if (!update_ref_status)
279
+ if (!update_ref_status && !quiet)
280
print_new_head_line(commit);
281
break;
282
case SOFT: /* Nothing else to do. */