mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
tag: add --column
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
b27004eb32
commit
d96e3c150f
@ -870,6 +870,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
|
||||
|
@ -13,6 +13,7 @@ SYNOPSIS
|
||||
<tagname> [<commit> | <object>]
|
||||
'git tag' -d <tagname>...
|
||||
'git tag' [-n[<num>]] -l [--contains <commit>] [--points-at <object>]
|
||||
[--column[=<options>] | --no-column] [<pattern>...]
|
||||
[<pattern>...]
|
||||
'git tag' -v <tagname>...
|
||||
|
||||
@ -84,6 +85,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.
|
||||
|
||||
|
2
Makefile
2
Makefile
@ -2168,7 +2168,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
|
||||
|
||||
|
@ -16,6 +16,7 @@
|
||||
#include "revision.h"
|
||||
#include "gpg-interface.h"
|
||||
#include "sha1-array.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>]",
|
||||
@ -33,6 +34,7 @@ struct tag_filter {
|
||||
};
|
||||
|
||||
static struct sha1_array points_at;
|
||||
static unsigned int colopts;
|
||||
|
||||
static int match_pattern(const char **patterns, const char *ref)
|
||||
{
|
||||
@ -263,6 +265,8 @@ 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;
|
||||
if (!prefixcmp(var, "column."))
|
||||
return git_column_config(var, value, "tag", &colopts);
|
||||
return git_default_config(var, value, cb);
|
||||
}
|
||||
|
||||
@ -459,6 +463,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"),
|
||||
{
|
||||
@ -495,9 +500,25 @@ 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);
|
||||
finalize_colopts(&colopts, -1);
|
||||
if (list && lines != -1) {
|
||||
if (explicitly_enable_column(colopts))
|
||||
die(_("--column and -n are incompatible"));
|
||||
colopts = 0;
|
||||
}
|
||||
if (list) {
|
||||
int ret;
|
||||
if (column_active(colopts)) {
|
||||
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 (column_active(colopts))
|
||||
stop_column_filter();
|
||||
return ret;
|
||||
}
|
||||
if (lines != -1)
|
||||
die(_("-n option is only allowed with -l."));
|
||||
if (with_commit)
|
||||
|
@ -263,6 +263,50 @@ test_expect_success 'tag -l can accept multiple patterns' '
|
||||
test_cmp expect actual
|
||||
'
|
||||
|
||||
test_expect_success 'listing tags in column' '
|
||||
COLUMNS=40 git tag -l --column=row >actual &&
|
||||
cat >expected <<\EOF &&
|
||||
a1 aa1 cba t210 t211
|
||||
v0.2.1 v1.0 v1.0.1 v1.1.3
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'listing tags in column with column.*' '
|
||||
git config column.tag row &&
|
||||
git config column.ui dense &&
|
||||
COLUMNS=40 git tag -l >actual &&
|
||||
git config --unset column.ui &&
|
||||
git config --unset column.tag &&
|
||||
cat >expected <<\EOF &&
|
||||
a1 aa1 cba t210 t211
|
||||
v0.2.1 v1.0 v1.0.1 v1.1.3
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
test_expect_success 'listing tag with -n --column should fail' '
|
||||
test_must_fail git tag --column -n
|
||||
'
|
||||
|
||||
test_expect_success 'listing tags -n in column with column.ui ignored' '
|
||||
git config column.ui "row dense" &&
|
||||
COLUMNS=40 git tag -l -n >actual &&
|
||||
git config --unset column.ui &&
|
||||
cat >expected <<\EOF &&
|
||||
a1 Foo
|
||||
aa1 Foo
|
||||
cba Foo
|
||||
t210 Foo
|
||||
t211 Foo
|
||||
v0.2.1 Foo
|
||||
v1.0 Foo
|
||||
v1.0.1 Foo
|
||||
v1.1.3 Foo
|
||||
EOF
|
||||
test_cmp expected actual
|
||||
'
|
||||
|
||||
# creating and verifying lightweight tags:
|
||||
|
||||
test_expect_success \
|
||||
|
Loading…
Reference in New Issue
Block a user