summaryrefslogtreecommitdiff
path: root/builtin/tag.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/tag.c')
-rw-r--r--builtin/tag.c40
1 files changed, 22 insertions, 18 deletions
diff --git a/builtin/tag.c b/builtin/tag.c
index 6fe6467..134b3f1 100644
--- a/builtin/tag.c
+++ b/builtin/tag.c
@@ -178,7 +178,6 @@ static const char tag_template_nocleanup[] =
static int git_tag_config(const char *var, const char *value, void *cb)
{
int status;
- struct ref_sorting **sorting_tail = (struct ref_sorting **)cb;
if (!strcmp(var, "tag.gpgsign")) {
config_sign_tag = git_config_bool(var, value);
@@ -188,7 +187,7 @@ static int git_tag_config(const char *var, const char *value, void *cb)
if (!strcmp(var, "tag.sort")) {
if (!value)
return config_error_nonbool(var);
- parse_ref_sorting(sorting_tail, value);
+ string_list_append(cb, value);
return 0;
}
@@ -436,7 +435,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
struct ref_transaction *transaction;
struct strbuf err = STRBUF_INIT;
struct ref_filter filter;
- static struct ref_sorting *sorting = NULL, **sorting_tail = &sorting;
+ struct ref_sorting *sorting;
+ struct string_list sorting_options = STRING_LIST_INIT_DUP;
struct ref_format format = REF_FORMAT_INIT;
int icase = 0;
int edit_flag = 0;
@@ -470,7 +470,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
OPT_WITHOUT(&filter.no_commit, N_("print only tags that don't contain the commit")),
OPT_MERGED(&filter, N_("print only tags that are merged")),
OPT_NO_MERGED(&filter, N_("print only tags that are not merged")),
- OPT_REF_SORT(sorting_tail),
+ OPT_REF_SORT(&sorting_options),
{
OPTION_CALLBACK, 0, "points-at", &filter.points_at, N_("object"),
N_("print only tags of the object"), PARSE_OPT_LASTARG_DEFAULT,
@@ -483,10 +483,11 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
OPT_END()
};
int ret = 0;
+ const char *only_in_list = NULL;
setup_ref_filter_porcelain_msg();
- git_config(git_tag_config, sorting_tail);
+ git_config(git_tag_config, &sorting_options);
memset(&opt, 0, sizeof(opt));
memset(&filter, 0, sizeof(filter));
@@ -522,11 +523,10 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
finalize_colopts(&colopts, -1);
if (cmdmode == 'l' && filter.lines != -1) {
if (explicitly_enable_column(colopts))
- die(_("--column and -n are incompatible"));
+ die(_("options '%s' and '%s' cannot be used together"), "--column", "-n");
colopts = 0;
}
- if (!sorting)
- sorting = ref_default_sorting();
+ sorting = ref_sorting_options(&sorting_options);
ref_sorting_set_sort_flags_all(sorting, REF_SORTING_ICASE, icase);
filter.ignore_case = icase;
if (cmdmode == 'l') {
@@ -543,15 +543,19 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
goto cleanup;
}
if (filter.lines != -1)
- die(_("-n option is only allowed in list mode"));
- if (filter.with_commit)
- die(_("--contains option is only allowed in list mode"));
- if (filter.no_commit)
- die(_("--no-contains option is only allowed in list mode"));
- if (filter.points_at.nr)
- die(_("--points-at option is only allowed in list mode"));
- if (filter.reachable_from || filter.unreachable_from)
- die(_("--merged and --no-merged options are only allowed in list mode"));
+ only_in_list = "-n";
+ else if (filter.with_commit)
+ only_in_list = "--contains";
+ else if (filter.no_commit)
+ only_in_list = "--no-contains";
+ else if (filter.points_at.nr)
+ only_in_list = "--points-at";
+ else if (filter.reachable_from)
+ only_in_list = "--merged";
+ else if (filter.unreachable_from)
+ only_in_list = "--no-merged";
+ if (only_in_list)
+ die(_("the '%s' option is only allowed in list mode"), only_in_list);
if (cmdmode == 'd') {
ret = delete_tags(argv);
goto cleanup;
@@ -565,7 +569,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
if (msg.given || msgfile) {
if (msg.given && msgfile)
- die(_("only one -F or -m option is allowed."));
+ die(_("options '%s' and '%s' cannot be used together"), "-F", "-m");
if (msg.given)
strbuf_addbuf(&buf, &(msg.buf));
else {