Imported Upstream version 2.4.0
[platform/upstream/git.git] / builtin / show-branch.c
index 808225c..f3fb5fb 100644 (file)
@@ -6,11 +6,11 @@
 #include "parse-options.h"
 
 static const char* show_branch_usage[] = {
-    N_("git show-branch [-a|--all] [-r|--remotes] [--topo-order | --date-order]\n"
+    N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n"
        "               [--current] [--color[=<when>] | --no-color] [--sparse]\n"
        "               [--more=<n> | --list | --independent | --merge-base]\n"
        "               [--no-name | --sha1-name] [--topics] [(<rev> | <glob>)...]"),
-    N_("git show-branch (-g|--reflog)[=<n>[,<base>]] [--list] [<ref>]"),
+    N_("git show-branch (-g | --reflog)[=<n>[,<base>]] [--list] [<ref>]"),
     NULL
 };
 
@@ -723,6 +723,7 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 
        if (reflog) {
                unsigned char sha1[20];
+               char nth_desc[256];
                char *ref;
                int base = 0;
                unsigned int flags = 0;
@@ -761,7 +762,6 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
 
                for (i = 0; i < reflog; i++) {
                        char *logmsg;
-                       char *nth_desc;
                        const char *msg;
                        unsigned long timestamp;
                        int tz;
@@ -780,10 +780,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix)
                                                show_date(timestamp, tz, 1),
                                                msg);
                        free(logmsg);
-
-                       nth_desc = xstrfmt("%s@{%d}", *av, base+i);
+                       sprintf(nth_desc, "%s@{%d}", *av, base+i);
                        append_ref(nth_desc, sha1, 1);
-                       free(nth_desc);
                }
                free(ref);
        }