diff options
author | Junio C Hamano <gitster@pobox.com> | 2012-03-04 23:35:23 -0800 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2012-03-04 23:35:23 -0800 |
commit | b8b52907e386d064fb0303c08215d7b117d50ee9 (patch) | |
tree | 29548ce0a8bc72bdca63db8ae09fba077f64c3cc /builtin | |
parent | Merge branch 'jn/gitweb-hilite-regions' (diff) | |
parent | symbolic-ref --short: abbreviate the output unambiguously (diff) | |
download | tgif-b8b52907e386d064fb0303c08215d7b117d50ee9.tar.xz |
Merge branch 'jk/symbolic-ref-short'
* jk/symbolic-ref-short:
symbolic-ref --short: abbreviate the output unambiguously
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/symbolic-ref.c | 11 |
1 files changed, 8 insertions, 3 deletions
diff --git a/builtin/symbolic-ref.c b/builtin/symbolic-ref.c index 2ef5962386..801d62ece5 100644 --- a/builtin/symbolic-ref.c +++ b/builtin/symbolic-ref.c @@ -8,13 +8,15 @@ static const char * const git_symbolic_ref_usage[] = { NULL }; +static int shorten; + static void check_symref(const char *HEAD, int quiet) { unsigned char sha1[20]; int flag; - const char *refs_heads_master = resolve_ref_unsafe(HEAD, sha1, 0, &flag); + const char *refname = resolve_ref_unsafe(HEAD, sha1, 0, &flag); - if (!refs_heads_master) + if (!refname) die("No such ref: %s", HEAD); else if (!(flag & REF_ISSYMREF)) { if (!quiet) @@ -22,7 +24,9 @@ static void check_symref(const char *HEAD, int quiet) else exit(1); } - puts(refs_heads_master); + if (shorten) + refname = shorten_unambiguous_ref(refname, 0); + puts(refname); } int cmd_symbolic_ref(int argc, const char **argv, const char *prefix) @@ -32,6 +36,7 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix) struct option options[] = { OPT__QUIET(&quiet, "suppress error message for non-symbolic (detached) refs"), + OPT_BOOL(0, "short", &shorten, "shorten ref output"), OPT_STRING('m', NULL, &msg, "reason", "reason of the update"), OPT_END(), }; |