Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx> --- Documentation/config.txt | 4 ++++ Documentation/git-tag.txt | 11 ++++++++++- Makefile | 2 +- builtin/tag.c | 25 ++++++++++++++++++++++--- 4 files changed, 37 insertions(+), 5 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index ebb210c..145336a 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -855,6 +855,10 @@ column.status:: Specify whether to output untracked files in `git status` in columns. See `column.ui` for details. +column.tag:: + Specify whether to output tag listing in `git tag` in columns. + See `column.ui` for details. + commit.status:: A boolean to enable/disable inclusion of status information in the commit message template when using an editor to prepare the commit diff --git a/Documentation/git-tag.txt b/Documentation/git-tag.txt index 53ff5f6..5ead91e 100644 --- a/Documentation/git-tag.txt +++ b/Documentation/git-tag.txt @@ -12,7 +12,8 @@ SYNOPSIS 'git tag' [-a | -s | -u <key-id>] [-f] [-m <msg> | -F <file>] <tagname> [<commit> | <object>] 'git tag' -d <tagname>... -'git tag' [-n[<num>]] -l [--contains <commit>] [<pattern>...] +'git tag' [-n[<num>]] -l [--contains <commit>] + [--column[=<options>] | --no-column] [<pattern>...] 'git tag' -v <tagname>... DESCRIPTION @@ -83,6 +84,14 @@ OPTIONS using fnmatch(3)). Multiple patterns may be given; if any of them matches, the tag is shown. +--column[=<options>]:: +--no-column:: + Display tag listing in columns. See configuration variable + column.tag for option syntax.`--column` and `--no-column` + without options are equivalent to 'always' and 'never' respectively. ++ +This option is only applicable when listing tags without annotation lines. + --contains <commit>:: Only list tags which contain the specified commit. diff --git a/Makefile b/Makefile index b2644bc..eb7b6fc 100644 --- a/Makefile +++ b/Makefile @@ -2116,7 +2116,7 @@ builtin/prune.o builtin/reflog.o reachable.o: reachable.h builtin/commit.o builtin/revert.o wt-status.o: wt-status.h builtin/tar-tree.o archive-tar.o: tar.h connect.o transport.o url.o http-backend.o: url.h -builtin/branch.o builtin/commit.o column.o help.o pager.o: column.h +builtin/branch.o builtin/commit.o builtin/tag.o column.o help.o pager.o: column.h http-fetch.o http-walker.o remote-curl.o transport.o walker.o: walker.h http.o http-walker.o http-push.o http-fetch.o remote-curl.o: http.h url.h diff --git a/builtin/tag.c b/builtin/tag.c index 31f02e8..cecbe5c 100644 --- a/builtin/tag.c +++ b/builtin/tag.c @@ -15,6 +15,7 @@ #include "diff.h" #include "revision.h" #include "gpg-interface.h" +#include "column.h" static const char * const git_tag_usage[] = { "git tag [-a|-s|-u <key-id>] [-f] [-m <msg>|-F <file>] <tagname> [<head>]", @@ -30,6 +31,8 @@ struct tag_filter { struct commit_list *with_commit; }; +static int colopts; + static int match_pattern(const char **patterns, const char *ref) { /* no pattern means match everything */ @@ -230,6 +233,9 @@ static int git_tag_config(const char *var, const char *value, void *cb) int status = git_gpg_config(var, value, cb); if (status) return status; + status = git_column_config(var, value, "tag", &colopts); + if (status <= 0) + return status; return git_default_config(var, value, cb); } @@ -409,6 +415,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix) OPT_STRING('u', "local-user", &keyid, "key-id", "use another key to sign the tag"), OPT__FORCE(&force, "replace the tag if exists"), + OPT_COLUMN(0, "column", &colopts, "show tag list in columns" ), OPT_GROUP("Tag listing options"), { @@ -421,6 +428,8 @@ int cmd_tag(int argc, const char **argv, const char *prefix) }; git_config(git_tag_config, NULL); + if (!colopts) + colopts = git_colopts; memset(&opt, 0, sizeof(opt)); @@ -441,9 +450,19 @@ int cmd_tag(int argc, const char **argv, const char *prefix) if (list + delete + verify > 1) usage_with_options(git_tag_usage, options); - if (list) - return list_tags(argv, lines == -1 ? 0 : lines, - with_commit); + if (list) { + int ret; + if (lines == -1) { + struct column_options copts; + memset(&copts, 0, sizeof(copts)); + copts.padding = 2; + run_column_filter(colopts, &copts); + } + ret = list_tags(argv, lines == -1 ? 0 : lines, with_commit); + if (lines == -1) + stop_column_filter(); + return ret; + } if (lines != -1) die(_("-n option is only allowed with -l.")); if (with_commit) -- 1.7.8.36.g69ee2 -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html