** 'prefix=<value>': Shown before the list of ref names. Defaults to "{nbsp}`(`".
** 'suffix=<value>': Shown after the list of ref names. Defaults to "`)`".
** 'separator=<value>': Shown between ref names. Defaults to "`,`{nbsp}".
+** 'pointer=<value>': Shown between HEAD and the branch it points to, if any.
+ Defaults to "{nbsp}`->`{nbsp}".
+** 'tag=<value>': Shown before tag names. Defaults to "`tag:`{nbsp}".
+
++
+For example, to produce decorations with no wrapping
+or tag annotations, and spaces as separators:
++
+`%(decorate:prefix=,suffix=,tag=,separator= )`
'%(describe[:<options>])'::
human-readable name, like linkgit:git-describe[1]; empty string for
const char *prefix = " (";
const char *suffix = ")";
const char *separator = ", ";
+ const char *pointer = " -> ";
+ const char *tag = "tag: ";
decoration = get_name_decoration(&commit->object);
if (!decoration)
suffix = opts->suffix;
if (opts->separator)
separator = opts->separator;
+ if (opts->pointer)
+ pointer = opts->pointer;
+ if (opts->tag)
+ tag = opts->tag;
}
color_commit = diff_get_color(use_color, DIFF_COMMIT);
strbuf_addstr(sb, color_reset);
}
- if (decoration->type == DECORATION_REF_TAG) {
+ if (*tag && decoration->type == DECORATION_REF_TAG) {
strbuf_addstr(sb, color);
- strbuf_addstr(sb, "tag: ");
+ strbuf_addstr(sb, tag);
strbuf_addstr(sb, color_reset);
}
if (current_and_HEAD &&
decoration->type == DECORATION_REF_HEAD) {
strbuf_addstr(sb, color);
- strbuf_addstr(sb, " -> ");
+ strbuf_addstr(sb, pointer);
strbuf_addstr(sb, color_reset);
strbuf_addstr(sb, decorate_get_color(use_color, current_and_HEAD->type));
show_name(sb, current_and_HEAD);
char *prefix;
char *suffix;
char *separator;
+ char *pointer;
+ char *tag;
};
int parse_decorate_color_config(const char *var, const char *slot_name, const char *value);
{
while (parse_decoration_option(arg, "prefix", &opts->prefix) ||
parse_decoration_option(arg, "suffix", &opts->suffix) ||
- parse_decoration_option(arg, "separator", &opts->separator))
+ parse_decoration_option(arg, "separator", &opts->separator) ||
+ parse_decoration_option(arg, "pointer", &opts->pointer) ||
+ parse_decoration_option(arg, "tag", &opts->tag))
;
}
free(opts->prefix);
free(opts->suffix);
free(opts->separator);
+ free(opts->pointer);
+ free(opts->tag);
}
static size_t format_commit_one(struct strbuf *sb, /* in UTF-8 */
echo "%(decorate:prefix=[ ,suffix= ],separater=; )" >expect4 &&
git log --format="%(decorate:prefix=[ ,suffix= ],separater=%x3B )" \
-1 >actual4 &&
- test_cmp expect4 actual4
+ test_cmp expect4 actual4 &&
+
+ echo "HEAD->foo bar qux" >expect5 &&
+ git log --format="%(decorate:prefix=,suffix=,separator= ,tag=,pointer=->)" \
+ -1 >actual5 &&
+ test_cmp expect5 actual5
'
cat >trailers <<EOF