为什么git-for-each-ref不能正确地对标签进行排序? [英] Why does git-for-each-ref fail to sort tags correctly?

查看:241
本文介绍了为什么git-for-each-ref不能正确地对标签进行排序?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我的存储库中同时包含轻量标签和带注释的标签时,git-for-each-ref似乎只能对其中一组进行排序.我想修改对for-each-ref的调用,以获取输出,该输出对所有标记进行排序并将它们混合在输出中.

When I have a repository with both lightweight and annotated tags, git-for-each-ref only seems to sort one of the sets. I would like to modify my call to for-each-ref to get output which sorts all the tags and intermixes them in the output.

例如:



bash-3.2$ git tag | 
> xargs -I T git log -n 1 --format='%at T' T |
> sort -rn | 
> awk '{print $2}'
lwt3
at3
lwt2
at2
lwt1
at1
bash-3.2$ git for-each-ref --sort=-authordate refs/tags | awk '{print $3}'
refs/tags/lwt3
refs/tags/lwt2
refs/tags/lwt1
refs/tags/at1
refs/tags/at2
refs/tags/at3
bash-3.2$ git --version
git version 1.6.6.80.g2df32

使用-committerdate-taggerdate会生成类似的输出,并且标记永远不会正确排序.使用-*authordate-*committerdate时,被排序的组是倒置的,而-*taggerdate则不进行任何排序.

Using -committerdate or -taggerdate generates similar output, and the tags are never correctly sorted. When using -*authordate, or -*committerdate, the group which is sorted is inverted, while -*taggerdate sorts nothing.

我不知道还有其他选择吗?这是正确的行为吗?我可以看到为什么committerdate或taggerdate只能分别对提交或标签进行排序,但是似乎authordate应该可以完成我想要的事情.

Is there some other option of which I am unaware? And is this correct behavior? I can see why committerdate or taggerdate would only sort the commits or the tags, respectively, but it seems like authordate ought to do what I want.

推荐答案

好的,继续并验证我在评论中所说的内容:

Okay, went ahead and verified what I said in my comment:

只有带注释的标签会在存储库中创建一个tab对象,其中包含您要在此处进行排序的taggerdate字段.您的标签很可能是轻量级标签,因此不包含此类信息.

Only annotated tags create a tab object in the repository, which contains among other things the taggerdate field you're trying to sort on here. Your tags are most likely lightweight tags, and therefore contain no such information.

对于另一半,对我来说,committerdate和authordate在标签上似乎可以正常工作-它们只是对标签指向的提交进行排序,因为没有有关何时创建标签的信息. (而且只有当您在前面加-时,它们才会反转排序顺序)

And for the other half, committerdate and authordate appear to work correctly for me on tags - they're just sorting the commit the tag points to, since there's no information about when the tag itself was created. (And they reverse the sort if and only if you put a - in front)

这篇关于为什么git-for-each-ref不能正确地对标签进行排序?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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