为什么git-describe在提交ID前加字母'g'? [英] Why does git-describe prefix the commit ID with the letter 'g'?

查看:95
本文介绍了为什么git-describe在提交ID前加字母'g'?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

git-describe 的典型输出看起来像

  some- tag-32-gf31f980 

其中 some-tag 是标记名称, 32 表示在提交该标记后描述的提交是32次提交,而 gf31f980 意味着提交ID是唯一缩写为 f31f980



我的问题是关于 g gf31f980 中。为什么在那里?我的第一个想法是插入它来消除对 git-describe 的输出的解析。但是我想不出有什么实际上有助于实现它的情况。例如, 32 组件可能被省略,并且无法知道上面的输出描述了提交32在 some-标记,而不是标记 some-tag-32 处的提交。但是 g 对此没有帮助。



只提取提交ID的正则表达式匹配可以搜索 / - 克([0-9A-F] +)$ / 。没有简单的方法来简化这一点;例如,你不能做 / - g(。*)$ / ,因为这可能会错误地匹配 g in标签名称。如果没有 g ,您仍然可以做 / - ([0-9a-f] +)$ / ,所以 g 在这方面没有帮助。非正则表达式解析过程的行为将类似。



明确生成 g ;相关的源代码( builtin / describe.c 的第240行)是: prettyprint-override> static void show_suffix(int depth,const unsigned char * sha1)
{
printf( - %dg%s,depth,find_unique_abbrev(sha1,abbrev ));

$ / code>

很难搜索有关这方面的信息,因为相关术语 g 是一个停用词。



什么是 g

解决方案

Jesse Luehrs马上指出在Twitter上,这个问题在 <$ c
$ b


g前缀表示git-describe 手册页 git,并且
用于允许描述软件的版本,具体取决于软件是用
管理的SCM。



Typical output of git-describe looks like

some-tag-32-gf31f980

where some-tag is a tag name, 32 means that the described commit is 32 commits after the commit with that tag, and gf31f980 means that the commit ID is uniquely abbreviated to f31f980.

My question is about the g in gf31f980. Why is it there? My first thought was that it is inserted to disambiguate parsing of the output of git-describe. But I can't think of any case in which it actually helps to have it. For example, the 32 component might be omitted, and there is no way to know that the output above describes a commit 32 commits after the tag some-tag, rather than the commit at the tag some-tag-32. But the g doesn't help with this.

A regex match to extract just the commit ID can search for /-g([0-9a-f]+)$/. There is no easy way to simplify this; you can't do /-g(.*)$/ for example because that might erroneously match a g in the tag name. Without the g you could still do /-([0-9a-f]+)$/, so the g isn't helping you there. Non-regex parsing processes will behave similarly.

The g is generated explicitly; the relevant source code (around line 240 of builtin/describe.c) is:

static void show_suffix(int depth, const unsigned char *sha1)
{
        printf("-%d-g%s", depth, find_unique_abbrev(sha1, abbrev));
}

It's hard to search for information about this, because the relevant term, g, is a stopword.

What's the g for?

解决方案

Jesse Luehrs immediately pointed out on Twitter that this question is answered in the git-describe man page:

The "g" prefix stands for "git" and is used to allow describing the version of a software depending on the SCM the software is managed with.

这篇关于为什么git-describe在提交ID前加字母'g'?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆