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>
This commit is contained in:
parent
fe61935007
commit
521b53e5c7
@ -8,8 +8,8 @@ git-reset - Reset current HEAD to the specified state
|
|||||||
SYNOPSIS
|
SYNOPSIS
|
||||||
--------
|
--------
|
||||||
[verse]
|
[verse]
|
||||||
'git-reset' [--mixed | --soft | --hard] [<commit>]
|
'git-reset' [--mixed | --soft | --hard] [-q] [<commit>]
|
||||||
'git-reset' [--mixed] <commit> [--] <paths>...
|
'git-reset' [--mixed] [-q] <commit> [--] <paths>...
|
||||||
|
|
||||||
DESCRIPTION
|
DESCRIPTION
|
||||||
-----------
|
-----------
|
||||||
@ -45,6 +45,9 @@ OPTIONS
|
|||||||
switched to. Any changes to tracked files in the working tree
|
switched to. Any changes to tracked files in the working tree
|
||||||
since <commit> are lost.
|
since <commit> are lost.
|
||||||
|
|
||||||
|
-q::
|
||||||
|
Be quiet, only report errors.
|
||||||
|
|
||||||
<commit>::
|
<commit>::
|
||||||
Commit to make the current HEAD.
|
Commit to make the current HEAD.
|
||||||
|
|
||||||
|
@ -18,7 +18,7 @@
|
|||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
|
||||||
static const char builtin_reset_usage[] =
|
static const char builtin_reset_usage[] =
|
||||||
"git-reset [--mixed | --soft | --hard] [<commit-ish>] [ [--] <paths>...]";
|
"git-reset [--mixed | --soft | --hard] [-q] [<commit-ish>] [ [--] <paths>...]";
|
||||||
|
|
||||||
static char *args_to_str(const char **argv)
|
static char *args_to_str(const char **argv)
|
||||||
{
|
{
|
||||||
@ -185,7 +185,7 @@ static const char *reset_type_names[] = { "mixed", "soft", "hard", NULL };
|
|||||||
|
|
||||||
int cmd_reset(int argc, const char **argv, const char *prefix)
|
int cmd_reset(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int i = 1, reset_type = NONE, update_ref_status = 0;
|
int i = 1, reset_type = NONE, update_ref_status = 0, quiet = 0;
|
||||||
const char *rev = "HEAD";
|
const char *rev = "HEAD";
|
||||||
unsigned char sha1[20], *orig = NULL, sha1_orig[20],
|
unsigned char sha1[20], *orig = NULL, sha1_orig[20],
|
||||||
*old_orig = NULL, sha1_old_orig[20];
|
*old_orig = NULL, sha1_old_orig[20];
|
||||||
@ -197,7 +197,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
|||||||
reflog_action = args_to_str(argv);
|
reflog_action = args_to_str(argv);
|
||||||
setenv("GIT_REFLOG_ACTION", reflog_action, 0);
|
setenv("GIT_REFLOG_ACTION", reflog_action, 0);
|
||||||
|
|
||||||
if (i < argc) {
|
while (i < argc) {
|
||||||
if (!strcmp(argv[i], "--mixed")) {
|
if (!strcmp(argv[i], "--mixed")) {
|
||||||
reset_type = MIXED;
|
reset_type = MIXED;
|
||||||
i++;
|
i++;
|
||||||
@ -210,6 +210,12 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
|||||||
reset_type = HARD;
|
reset_type = HARD;
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
else if (!strcmp(argv[i], "-q")) {
|
||||||
|
quiet = 1;
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (i < argc && argv[i][0] != '-')
|
if (i < argc && argv[i][0] != '-')
|
||||||
@ -270,7 +276,7 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
switch (reset_type) {
|
switch (reset_type) {
|
||||||
case HARD:
|
case HARD:
|
||||||
if (!update_ref_status)
|
if (!update_ref_status && !quiet)
|
||||||
print_new_head_line(commit);
|
print_new_head_line(commit);
|
||||||
break;
|
break;
|
||||||
case SOFT: /* Nothing else to do. */
|
case SOFT: /* Nothing else to do. */
|
||||||
|
Loading…
Reference in New Issue
Block a user