如何捕获 git decorate 应用的标签
How to capture the tags applied by git decorate
这是怎么回事?为什么两个输出不同?
$ git log --oneline -n1
7dbee6d (HEAD -> master, origin/master, origin/HEAD) some commit msg
$ git log --oneline -n1 | head
7dbee6d some commit msg
通往 'head' 的管道是我能找到的最简单的例子来说明问题。这个问题阻止了我,例如:
- 管道传输到包含 git 装饰的文件
- 管道连接到 "grep",例如grep 某些标签
系统:
- Ubuntu 18.04.1 LTS
- git 版本 2.17.1
- GNU bash,版本 4.4.19(1)-发布 (x86_64-pc-linux-gnu)
来自 log
联机帮助页:
--decorate[=short|full|auto|no]
Print out the ref names of any commits that are shown. If short is
specified, the ref name prefixes refs/heads/, refs/tags/ and
refs/remotes/ will not be printed. If full is specified, the full
ref name (including prefix) will be printed. If auto is specified,
then if the output is going to a terminal, the ref names are shown
as if short were given, otherwise no ref names are shown.
The default option is short.
因此,当使用 --decorate=auto
调用时,行为将根据 stdout 是否为终端而改变。如果你将 git log
输出到某处,stdout
将不是终端。
默认值为 short
,但您的 git 选项中可能有 auto
。
要在两种情况下获得相同的行为,请使用 --decorate=short
调用它
这是怎么回事?为什么两个输出不同?
$ git log --oneline -n1
7dbee6d (HEAD -> master, origin/master, origin/HEAD) some commit msg
$ git log --oneline -n1 | head
7dbee6d some commit msg
通往 'head' 的管道是我能找到的最简单的例子来说明问题。这个问题阻止了我,例如:
- 管道传输到包含 git 装饰的文件
- 管道连接到 "grep",例如grep 某些标签
系统:
- Ubuntu 18.04.1 LTS
- git 版本 2.17.1
- GNU bash,版本 4.4.19(1)-发布 (x86_64-pc-linux-gnu)
来自 log
联机帮助页:
--decorate[=short|full|auto|no] Print out the ref names of any commits that are shown. If short is specified, the ref name prefixes refs/heads/, refs/tags/ and refs/remotes/ will not be printed. If full is specified, the full ref name (including prefix) will be printed. If auto is specified, then if the output is going to a terminal, the ref names are shown as if short were given, otherwise no ref names are shown. The default option is short.
因此,当使用 --decorate=auto
调用时,行为将根据 stdout 是否为终端而改变。如果你将 git log
输出到某处,stdout
将不是终端。
默认值为 short
,但您的 git 选项中可能有 auto
。
要在两种情况下获得相同的行为,请使用 --decorate=short