summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 36c79d2)
raw | patch | inline | side by side (parent: 36c79d2)
author | Christian Couder <chriscool@tuxfamily.org> | |
Sat, 26 Apr 2008 11:57:23 +0000 (13:57 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 27 Apr 2008 06:22:17 +0000 (23:22 -0700) |
Currently "git rev-parse --verify <something>" is often used with
its error output redirected to /dev/null. This patch makes it
easier to do that.
The -q|--quiet option is designed to work the same way as it does
for "git symbolic-ref".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
its error output redirected to /dev/null. This patch makes it
easier to do that.
The -q|--quiet option is designed to work the same way as it does
for "git symbolic-ref".
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Documentation/git-rev-parse.txt | patch | blob | history | |
builtin-rev-parse.c | patch | blob | history |
index 6513c2efe17668d5fc25a21385ed117ec76b40b5..110e7ba71f48c54cb94f35e819583826e123a8b1 100644 (file)
The parameter given must be usable as a single, valid
object name. Otherwise barf and abort.
+-q, --quiet::
+ Only meaningful in `--verify` mode. Do not output an error
+ message if the first argument is not a valid object name;
+ instead exit with non-zero status silently.
+
--sq::
Usually the output is made one line per flag and
parameter. This option makes output a single line,
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 0351d54435b566d5030f3a83df57fb140fffc143..9384a991eec9e1d1d9395caf4a72d6babb288e89 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
return 0;
}
+static void die_no_single_rev(int quiet)
+{
+ if (quiet)
+ exit(1);
+ else
+ die("Needed a single revision");
+}
+
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
{
- int i, as_is = 0, verify = 0;
+ int i, as_is = 0, verify = 0, quiet = 0;
unsigned char sha1[20];
if (argc > 1 && !strcmp("--parseopt", argv[1]))
verify = 1;
continue;
}
+ if (!strcmp(arg, "--quiet") || !strcmp(arg, "-q")) {
+ quiet = 1;
+ continue;
+ }
if (!strcmp(arg, "--short") ||
!prefixcmp(arg, "--short=")) {
filter &= ~(DO_FLAGS|DO_NOREV);
continue;
}
if (show_flag(arg) && verify)
- die("Needed a single revision");
+ die_no_single_rev(quiet);
continue;
}
if (!show_file(arg))
continue;
if (verify)
- die("Needed a single revision");
+ die_no_single_rev(quiet);
verify_filename(prefix, arg);
}
show_default();
if (verify && revs_count != 1)
- die("Needed a single revision");
+ die_no_single_rev(quiet);
return 0;
}