如何在Git中显示两个引用之间的路径图?(How to show graph of path between two refs in Git?)

编程入门 行业动态 更新时间:2024-10-26 21:23:26
如何在Git中显示两个引用之间的路径图?(How to show graph of path between two refs in Git?)

我正在使用Git v2.6.1。 我在两个分支上运行以下命令:

$ git log --drecorate --oneline --graph origin/release/6.0.0.10...origin/master --ancestry-path

分支release/6.0.0.10是由master创建的。 但是,生成的图形不会显示其合并基础。 它们在结果视图中没有“连接”:

* c62ea9b (origin/release/6.0.0.10) |\ | * 43922fe |/ * 6bb6187 * ff01d1e * 3e949a9 * af6a5a8 * 6adff8d * 4896edc * bbebbf1 * 54c12e7 * 0b198c5 (origin/master) * 33b1f9d * 0e6c2a0 * 86371fe * 3e341f4 * 3bbb8f4 * 05c3987 * 6688d10 * 2d6c270 * 18c36f3

请注意 ,合并基础不是 origin/master的提示,但它以这种方式显示。 我希望看到另一条垂直线,可能在底部,将2个参考线连接在一起,这表明它们的合并基础。 如何更改上面显示的log命令的调用以获得我正在寻找的结果?

I'm using Git v2.6.1. I run the following command on two branches:

$ git log --drecorate --oneline --graph origin/release/6.0.0.10...origin/master --ancestry-path

The branch release/6.0.0.10 was created off of master. However, the resulting graph does not show their merge base. They are not "connected" in the resulting view:

* c62ea9b (origin/release/6.0.0.10) |\ | * 43922fe |/ * 6bb6187 * ff01d1e * 3e949a9 * af6a5a8 * 6adff8d * 4896edc * bbebbf1 * 54c12e7 * 0b198c5 (origin/master) * 33b1f9d * 0e6c2a0 * 86371fe * 3e341f4 * 3bbb8f4 * 05c3987 * 6688d10 * 2d6c270 * 18c36f3

Note that the merge base is not the tip of origin/master, yet it displays it that way. I expect to see one more vertical line, probably at the bottom, connecting the 2 refs together which would indicate their merge base. How can I change my invocation of the log command shown above to get the results I'm looking for?

最满意答案

三点语法选择可从任一端点访问的修订, 不包括两个端点可到达的提交。 也就是说,它抛弃了合并基础和任何早期的点。 显然,您需要包含合并基础以绘制图形线。

两个明显的选择是:

从合并库中备份一步。 这不能直接在三点语法中完成; 你必须找到实际的合并基础提交。 1由于A ... B “表示” 2 A B --not $(git merge-base A B )你可以这样做:

base=$(git merge-base A B) git log A B --not ${base}^

得到那种效果。

使用--boundary选项git rev-list 3强制它包含它通常排除的边界提交,在这种情况下将包括merge-base。

我不完全确定--boundary会如何与--ancestry-path进行交互,在这种情况下(测试git repo本身给了我两个边界提交,我尝试了DAG的部分)。 不过,我在不同的repo上使用的--simplify-by-decoration选项工作正常。


1或者几个中的一个,如果有多个合并基础(在这种情况下你可能想要包括所有这些,但可能在这里你可以确定只有一个)。

2更准确地说, AB ^$(git merge-base AB ) ,或AB --not $(git merge-base AB ) --not 。 额外的 - 或者使用前缀^在这种情况下无关紧要,因为没有更多的修订名称 - 不是反转。

3 log,rev-list,几乎都是相同的命令。 :-)你可以从git rev-list获取图形。

The three-dot syntax selects revisions that are reachable from either endpoint, excluding commits reachable from both endpoints. That is, it throws away the merge-base and any earlier points. Clearly you'll need to include the merge base to get the graph line drawn.

Two obvious options are:

Back up one step from the merge-base. This can't be done directly within the three-dot syntax; you'd have to find the actual merge-base commit.1 Since A...B "means"2 A B --not $(git merge-base A B) you could do:

base=$(git merge-base A B) git log A B --not ${base}^

to get that effect.

Use the --boundary option to git rev-list3 to force it to include the boundary commits it normally excludes, which in this case will include the merge-base.

I'm not entirely sure how --boundary will interact with --ancestry-path, in this case (testing on the git repo itself gave me two boundary commits for the pieces of the DAG I tried). It works fine with the --simplify-by-decoration option I used on a different repo, though.


1Or one of several, if there are multiple merge-bases (in such cases you might want to include all of them, but presumably here you can be sure there's just the one).

2More precisely, A B ^$(git merge-base A B), or A B --not $(git merge-base A B) --not. The extra --not, or using the prefix ^, don't matter in this case, since there are no more revision names for --not to invert.

3log, rev-list, all pretty much the same command. :-) You can get the graph out of git rev-list for instance.

更多推荐

本文发布于:2023-07-16 03:57:00,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1123413.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:路径   两个   如何在   Git   refs

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!