Merge branch 'nv/parseopt-opt-arg'
[gitweb.git] / builtin / branch.c
index 5696cf0ef79cd8242e0a384a058d5bd565ec5be3..636a16ea4e3af71aef80ba42639f0933c286f485 100644 (file)
@@ -424,6 +424,7 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
        struct branch *branch = branch_get(branch_name);
        struct strbuf fancy = STRBUF_INIT;
        int upstream_is_gone = 0;
+       int added_decoration = 1;
 
        switch (stat_tracking_info(branch, &ours, &theirs)) {
        case 0:
@@ -451,9 +452,13 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
        if (upstream_is_gone) {
                if (show_upstream_ref)
                        strbuf_addf(stat, _("[%s: gone]"), fancy.buf);
+               else
+                       added_decoration = 0;
        } else if (!ours && !theirs) {
                if (show_upstream_ref)
                        strbuf_addf(stat, _("[%s]"), fancy.buf);
+               else
+                       added_decoration = 0;
        } else if (!ours) {
                if (show_upstream_ref)
                        strbuf_addf(stat, _("[%s: behind %d]"), fancy.buf, theirs);
@@ -474,7 +479,8 @@ static void fill_tracking_info(struct strbuf *stat, const char *branch_name,
                                    ours, theirs);
        }
        strbuf_release(&fancy);
-       strbuf_addch(stat, ' ');
+       if (added_decoration)
+               strbuf_addch(stat, ' ');
        free(ref);
 }
 
@@ -496,7 +502,7 @@ static void add_verbose_info(struct strbuf *out, struct ref_item *item,
        const char *sub = _(" **** invalid ref ****");
        struct commit *commit = item->commit;
 
-       if (commit && !parse_commit(commit)) {
+       if (!parse_commit(commit)) {
                pp_commit_easy(CMIT_FMT_ONELINE, commit, &subject);
                sub = subject.buf;
        }