Change fetch_pack() and friends to take string_list arguments
[gitweb.git] / builtin / symbolic-ref.c
index 2ef5962386dcc21af94c680be5fd75fc96d4962f..9e92828b3ab02fb93c568eab03f0db9d398e8fa2 100644 (file)
@@ -4,17 +4,19 @@
 #include "parse-options.h"
 
 static const char * const git_symbolic_ref_usage[] = {
-       "git symbolic-ref [options] name [ref]",
+       N_("git symbolic-ref [options] name [ref]"),
        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)
@@ -31,8 +35,9 @@ int cmd_symbolic_ref(int argc, const char **argv, const char *prefix)
        const char *msg = NULL;
        struct option options[] = {
                OPT__QUIET(&quiet,
-                       "suppress error message for non-symbolic (detached) refs"),
-               OPT_STRING('m', NULL, &msg, "reason", "reason of the update"),
+                       N_("suppress error message for non-symbolic (detached) refs")),
+               OPT_BOOL(0, "short", &shorten, N_("shorten ref output")),
+               OPT_STRING('m', NULL, &msg, N_("reason"), N_("reason of the update")),
                OPT_END(),
        };