]> git.ipfire.org Git - thirdparty/git.git/blobdiff - builtin/branch.c
replace {pre,suf}fixcmp() with {starts,ends}_with()
[thirdparty/git.git] / builtin / branch.c
index ad0f86de540dc394199f71c03665d0cd76371c35..c5953e56154a989dfa218bdc3acc66ec371ffaef 100644 (file)
@@ -81,13 +81,13 @@ static int parse_branch_color_slot(const char *var, int ofs)
 
 static int git_branch_config(const char *var, const char *value, void *cb)
 {
-       if (!prefixcmp(var, "column."))
+       if (starts_with(var, "column."))
                return git_column_config(var, value, "branch", &colopts);
        if (!strcmp(var, "color.branch")) {
                branch_use_color = git_config_colorbool(var, value);
                return 0;
        }
-       if (!prefixcmp(var, "color.branch.")) {
+       if (starts_with(var, "color.branch.")) {
                int slot = parse_branch_color_slot(var, 13);
                if (slot < 0)
                        return 0;
@@ -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);
 }
 
@@ -862,7 +868,7 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
        if (!strcmp(head, "HEAD")) {
                detached = 1;
        } else {
-               if (prefixcmp(head, "refs/heads/"))
+               if (!starts_with(head, "refs/heads/"))
                        die(_("HEAD not found below refs/heads!"));
                head += 11;
        }
@@ -975,9 +981,8 @@ int cmd_branch(int argc, const char **argv, const char *prefix)
                        die(_("no such branch '%s'"), argv[0]);
                }
 
-               if (!branch_has_merge_config(branch)) {
+               if (!branch_has_merge_config(branch))
                        die(_("Branch '%s' has no upstream information"), branch->name);
-               }
 
                strbuf_addf(&buf, "branch.%s.remote", branch->name);
                git_config_set_multivar(buf.buf, NULL, NULL, 1);