- r - 以节省内存的方式增长 data.frame
- ruby-on-rails - ruby/ruby on rails 内存泄漏检测
- android - 无法解析导入android.support.v7.app
- UNIX 域套接字与共享内存(映射文件)
我对图形 git log 的输出很困惑。
我确实理解每个 *
都意味着一次提交,无论它是发散提交、普通提交还是 merge 提交。我明白管道意味着分支。
让我们看一个简单的图形日志:
首先,红色管道(最左撇子)代表哪个分支?我不认为这是我所在的当前分支,因为在我 checkout 到其他分支后,图表看起来是一样的。此外,它也不代表主分支。
其次,如果最左手的分支代表单个分支,为什么在提交“0e5b5”后它会改变颜色?
我搜索了有关如何阅读 git 日志图的教程,不幸的是,我一无所获。如果有关于此主题的精彩教程,请随时分享。
最佳答案
在 Git 2.25(2020 年第一季度)中,重构了“git log --graph
”的实现,然后简化了它的输出。
这反过来又可以在某些情况下修复颜色。
下图说明了如何使用 git log --graph
管理颜色和边缘。
参见 commit d784d97 的 Denton Liu (Denton-L
)(2019 年 11 月 12 日)。
参见 commit bbb13e8、commit 92beecc、commit 479db18、commit 0195285、commit d62893e、commit 0f0f389、commit 458152c、commit ee7abb5、commit 46ba2ab、commit a551fd5、commit 9157a2a、commit 210179a、commit fbccf25(2019 年 10 月 15 日)作者 James Coglan (jcoglan
)。
(由 Junio C Hamano -- gitster
-- merge 到 commit 0be5caf ,2019 年 12 月 1 日)
graph
: fix coloring of octopus dashesSigned-off-by: James Coglan
In 04005834ed ("
log
: fix coloring of certain octopus merge shapes", 2018-09-01, Git v2.20.0-rc0 -- merge listed in batch #6), there is a fix for the coloring of dashes following an octopus merge.
It makes a distinction between the case where all parents introduce a new column, versus the case where the first parent collapses into an existing column:| *-. | *-.
| |\ \ | |\ \
| | | | |/ / /The latter case means that the columns for the merge parents begin one place to the left in the
new_columns
array compared to the former case.However, the implementation only works if the commit's parents are kept in order as they map onto the visual columns, as we get the colors by iterating over
new_columns
as we print the dashes.
In general, the commit's parents can arbitrarily merge with existing columns, and change their ordering in the process.For example, in the following diagram, the number of each column indicates which commit parent appears in each column.
| | *---.
| | |\ \ \
| | |/ / /
| |/| | /
| |_|_|/
|/| | |
3 1 0 2If the columns are colored (red, green, yellow, blue), then the dashes will currently be colored yellow and blue, whereas they should be blue and red.
To fix this, we need to look up each column in the
mapping
array, which before theGRAPH_COLLAPSING
state indicates which logical column is displayed in each visual column.
This implementation is simpler as it doesn't have any edge cases, and it also handles how left-skewed first parents are now displayed:| *-.
|/|\ \
| | | |
0 1 2 3The color of the first dashes is always the color found in
mapping
two columns to the right of the commit symbol. Because commits are displayed after all edges have been collapsed together and the visual columns match the logical ones, we can find the visual offset of the commit symbol usingcommit_index
.
关于边缘(仍然使用 Git 2.25,2020 年第一季度):
graph
: smooth appearance of collapsing edges on commit linesSigned-off-by: James Coglan
When a graph contains edges that are in the process of collapsing to the left, but those edges cross a commit line, the effect is that the edges have a jagged appearance:
*
|\
| *
| \
*-. \
|\ \ \
| | * |
| * | |
| |/ /
* | |
|/ /
* |
|/
*We already takes steps to smooth edges like this when they're expanding; when an edge appears to the right of a merge commit marker on a
GRAPH_COMMIT
line immediately following aGRAPH_POST_MERGE
line, we render it as a\
:* \
|\ \
| * \
| |\ \We can make a similar improvement to collapsing edges, making them easier to follow and giving the overall graph a feeling of increased symmetry:
*
|\
| *
| \
*-. \
|\ \ \
| | * |
| * | |
| |/ /
* / /
|/ /
* /
|/
*To do this, we introduce a new special case for edges on
GRAPH_COMMIT
lines that immediately follow aGRAPH_COLLAPSING
line.
By retaining a copy of themapping
array used to render theGRAPH_COLLAPSING
line in theold_mapping
array, we can determine that an edge is collapsing through theGRAPH_COMMIT
line and should be smoothed.
更一般地说:
graph
: commit and post-merge lines for left-skewed mergesSigned-off-by: James Coglan
Following the introduction of "left-skewed" merges, which are merges whose first parent fuses with another edge to its left, we have some more edge cases to deal with in the display of commit and post-merge lines.
The current graph code handles the following cases for edges appearing to the right of the commit (
*
) on commit lines.A 2-way merge is usually followed by vertical lines:
| | |
| * |
| |\ \An octopus merge (more than two parents) is always followed by edges sloping to the right:
| | \ | | \
| *-. \ | *---. \
| |\ \ \ | |\ \ \ \A 2-way merge is followed by a right-sloping edge if the commit line immediately follows a post-merge line for a commit that appears in the same column as the current commit, or any column to the left of that:
| * | * |
| |\ | |\ \
| * \ | | * \
| |\ \ | | |\ \This commit introduces the following new cases for commit lines. If a 2-way merge skews to the left, then the edges to its right are always vertical lines, even if the commit follows a post-merge line:
| | | | |\
| * | | * |
|/| | |/| |A commit with 3 parents that skews left is followed by vertical edges:
| | |
| * |
|/|\ \If a 3-way left-skewed merge commit appears immediately after a post-merge line, then it may be followed the right-sloping edges, just like a 2-way merge that is not skewed.
| |\
| * \
|/|\ \Octopus merges with 4 or more parents that skew to the left will always be followed by right-sloping edges, because the existing columns need to expand around the merge.
| | \
| *-. \
|/|\ \ \On post-merge lines, usually all edges following the current commit slope to the right:
| * | |
| |\ \ \However, if the commit is a left-skewed 2-way merge, the edges to its right remain vertical.
We also need to display a space after the vertical line descending from the commit marker, whereas this line would normally be followed by a backslash.| * | |
|/| | |If a left-skewed merge has more than 2 parents, then the edges to its right are still sloped as they bend around the edges introduced by the merge.
| * | |
|/|\ \ \To handle these new cases, we need to know not just how many parents each commit has, but how many new columns it adds to the display; this quantity is recorded in the
edges_added
field for the current commit, andprev_edges_added
field for the previous commit.Here, "column" refers to visual columns, not the logical columns of the
columns
array.
This is because even if all the commit's parents end up fusing with existing edges, they initially introduce distinct edges in the commit and post-merge lines before those edges collapse.For example, a 3-way merge whose 2nd and 3rd parents fuse with existing edges still introduces 2 visual columns that affect the display of edges to their right.
| | | \
| | *-. \
| | |\ \ \
| |_|/ / /
|/| | / /
| | |/ /
| |/| |
| | | |This merge does not introduce any logical columns; there are 4 edges before and after this commit once all edges have collapsed. But it does initially introduce 2 new edges that need to be accommodated by the edges to their right.
经典输出已被简化:
graph
: example of graph output that can be simplifiedSigned-off-by: James Coglan
The commits following this one introduce a series of improvements to the layout of graphs, tidying up a few edge cases, namely:
- merge whose first parent fuses with an existing column to the left
- merge whose last parent fuses with its immediate neighbor on the right
- edges that collapse to the left above and below a commit line
This test case exemplifies these cases and provides a motivating example of the kind of history I'm aiming to clear up.
The first parent of merge E is the same as the parent of H, so those edges fuse together.
* H
|
| *-. E
| |\ \
|/ / /
|
* BWe can "skew" the display of this merge so that it doesn't introduce additional columns that immediately collapse:
* H
|
| * E
|/|\
|
* BThe last parent of E is D, the same as the parent of F which is the edge to the right of the merge.
* F
|
\
. \ E
\ \
/ /
| /
|/
* DThe two edges leading to D could be fused sooner: rather than expanding the F edge around the merge and then letting the edges collapse, the F edge could fuse with the E edge in the post-merge line:
* F
|
\
. | E
\|
/
|
* DIf this is combined with the "skew" effect above, we get a much cleaner graph display for these edges:
* F
|
| E
|
|
* DFinally, the edge leading from C to A appears jagged as it passes through the commit line for B:
| * | C
| |/
* | B
|/
* AThis can be smoothed out so that such edges are easier to read:
| * | C
| |/
* / B
|/
* A
自从最近对日志图渲染代码进行更新后,绘制某些 merge 开始在不再成立的条件下触发断言,这已通过 Git 2.25(2020 年第一季度)得到纠正。
参见 commit a1087c9 和 commit 0d251c3(2020 年 1 月 7 日),作者 Derrick Stolee (derrickstolee
)。
(由 Junio C Hamano -- gitster
-- merge 到 commit 1f5f3ff ,2020 年 1 月 8 日)
graph
: drop assert() for merge with two collapsing parentsHelped-by: Jeff King
Reported-by: Bradley Smith
Signed-off-by: Derrick StoleeWhen "
git log --graph
" shows a merge commit that has two collapsing lines, like:| | | | *
| |_|_|/|
|/| | |/
| | |/|
| |/| |
| * | |
* | | |we trigger an assert():
graph.c:1228: graph_output_collapsing_line: Assertion
`graph->mapping[i - 3] == target' failed.The assert was introduced by eaf158f8 ("graph API: Use horizontal lines for more compact graphs", 2009-04-21, Git v1.6.4-rc0 -- merge), which is quite old.
This assert is trying to say that when we complete a horizontal line with a single slash, it is because we have reached our target.It is actually the
_second
_ collapsing line that hits this assert.
The reason we are in this code path is because we are collapsing the first line, and in that case we are hitting our target now that the horizontal line is complete.
However, the second line cannot be a horizontal line, so it will collapse without horizontal lines. In this case, it is inappropriate to assert that we have reached our target, as we need to continue for another column before reaching the target.
Dropping the assert is safe here.The new behavior in 0f0f389f12 ("
graph
: tidy up display of left-skewed merges", 2019-10-15, Git v2.25.0-rc0 -- merge listed in batch #2) caused the behavior change that made this assertion failure possible.
In addition to making the assert possible, it also changed how multiple edges collapse.In a larger example, the current code will output a collapse as follows:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | | | |/| /
| | | |/| |/
| | |/| |/|
| |/| |/| |
| | |/| | |
| | * | | |However, the intended collapse should allow multiple horizontal lines as follows:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | |_|_|/| /
| |/| | | |/
| | | |_|/|
| | |/| | |
| | * | | |This behavior is not corrected by this change, but is noted for a later update.
通过“git log --graph
”呈现导致 merge 提交的祖先行在最近的更新中变得次优以浪费垂直空间,已使用 Git 2.26 (Q1) 更正2020 年)。
参见 commit c958d3b 和 commit 8588932(2020 年 1 月 8 日),作者 Derrick Stolee (derrickstolee
)。
(由 Junio C Hamano -- gitster
-- merge 到 commit d52adee ,2020 年 1 月 30 日)
graph
: fix collapse of multiple edgesSigned-off-by: Derrick Stolee
This fix resolves the previously-added
test_expect_failure
int4215-log-skewed-merges.sh
.The issue lies in the "
else
" condition while updating the mapping insidegraph_output_collapsing_line()
.
In 0f0f389f ("graph
: tidy up display of left-skewed merges", 2019-10-15, Git v2.25.0-rc0 -- merge listed in batch #2), the output of left-skewed merges was changed to allow an immediate horizontal edge in the first parent, output bygraph_output_post_merge_line()
instead of bygraph_output_collapsing_line()
.
This condensed the first line behavior as follows:Before 0f0f389f:
| | | | | | *-.
| | | | | | |\ \
| |_|_|_|_|/ | |
|/| | | | | / /After 0f0f389f:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | | | |/| /However, a very subtle issue arose when the second and third parent edges are collapsed in later steps. The second parent edge is now immediately adjacent to a vertical edge. This means that the condition
} else if (graph->mapping[i - 1] < 0) {
in
graph_output_collapsing_line()
evaluates as false. The block for this condition was the only place where we connected the target column with the current position with horizontal edge markers.In this case, the final "
else
" block is run, and the edge is marked as horizontal, but did not back-fill the blank columns between the target and the current edge.
Since the second parent edge is marked as horizontal, the third parent edge is not marked as horizontal.
This causes the output to continue as follows:Before this change:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | | | |/| /
| | | |/| |/
| | |/| |/|
| |/| |/| |
| | |/| | |By adding the logic for "filling" a horizontal edge between the target column and the current column, we are able to resolve the issue.
After this change:
| | | | | | *
| |_|_|_|_|/|\
|/| | | | |/ /
| | |_|_|/| /
| |/| | | |/
| | | |_|/|
| | |/| | |This output properly matches the expected blend of the edge behavior before 0f0f389f and the merge commit rendering from 0f0f389f.
关于git - 如何理解 git log --graph,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20200226/
我时不时地输入“git”,然后想到别的东西,然后输入例如“git checkout master”。当然,这给我留下了 $ git git checkout master git: 'git' is
我做到了 git 克隆 git://foo.git 光盘富 ...编辑文件.. 现在我想重新开始。我不在乎我已经做出的任何改变,但我不想再次克隆整个巨型 foo.git,只是丢失我所有的更改。我怎
我在我的电脑上开发代码,我的计算节点很少。 为了让我的程序保持同步,我决定使用 git。以前,我以一种单向模式使用它来“下推”从 PC 到计算节点的更改。但是时不时遇到计算节点特有的小bug,现场修复
虽然它似乎什么也没做,但它没有给出任何警告或错误消息。有什么想法吗? 最佳答案 来自 Git 源的注释: /* * Read a directory tree. We currently ignor
我知道如何为这样的 HTTPS 请求提供用户名和密码: git clone https://username:password@remote 但我想知道如何像这样向 Remote 提供用户名和密码:
Git GUI、Git Bash 和 Git CMD 之间有什么区别?我是初学者,为了进行安装,我发现自己通常同时使用 git bash 和 git CMD 最佳答案 Git CMD 就像使用 git
有人能告诉我git中文件索引被删除是什么意思吗?这些文件在我的 VS Code 中标记为红色,但我仍然可以修改文件并将更改推送到将反射(reflect)这些更改的远程存储库。我认为这一切都是在我使用命
我通过 git 子树将 GLFV 库添加到项目中,但出现此警告“看起来您的 git 安装或您的 git-subtree 安装已损坏”。还描述了几个原因,为什么这可能是: 如 git --exec-pa
我有需要外部 git 项目的 repo,但我不想使用子模块,因为我想在 github 上存档所有文件,所以我认为我只是将具有 git repo 的整个目录添加到 git 但它不t 添加里面的 .git
我有需要外部 git 项目的 repo,但我不想使用子模块,因为我想在 github 上存档所有文件,所以我认为我只是将具有 git repo 的整个目录添加到 git 但它不t 添加里面的 .git
我一直在阅读一篇文章,作者在其中指示:在现有存储库中创建一个新存储库,并想知道这是否是他忽略的错误。稍后我会与他核实。 这些是我要检查的条件: 将现有目录制作成仓库的条件,并且已经 checkin 主
我确实在不同的计算机上处理相同的项目,我想知道是否有一种方法可以跟踪该 .git 文件夹,这样我就不必在所有本地文件中重新配置配置文件。 我将所有工作推送到 bitbucket。 最佳答案 不,没
这个问题在这里已经有了答案: How does git store files? (3 个答案) 关闭 9 年前。 我为我的许多项目创建了一个远程存储库,所以它是我的push 的目的地。与 git
应该如何在 git 中查看文件内容的完整历史记录? 一个文件在 git 中的历史很短,存储库通过 git-svn 同步,但在 svn 中的历史很长。 git 中的历史记录到达文件移动的位置。要查看历史
我是confused here ... 如何对修改后的文件进行git commit,以及如何对新文件进行git commit? 还有,你如何在git中单独提交文件? 最佳答案 git 提交过程分为两个
正在搜索 throw SO 来寻找答案。遇到这个似乎没有给出任何答案的旧线程。重新触发此线程,希望有人知道! 有人能告诉我 git subtree 和 git filter-branch 的区别吗?为
我想知道是否有一种方法可以避免在每个 Git 命令的开头键入单词 git。 如果有一种方法可以在打开命令提示符进入 “Git 模式” 后只使用一次 git 命令就好了。 例如: git> 之后,我们键
当您修改工作目录中的文件时,git 会告诉您使用“git add”暂存。 当您向工作目录添加新文件时,git 会告诉您使用“git add”开始跟踪。 我对这两个概念有点困惑,因为我假设跟踪文件的更改
为什么 git://有效 $ git clone git://github.com/schacon/grit.git Cloning into 'grit'... ... Checking conne
我在以下沙箱中练习 git:https://learngitbranching.js.org/?NODEMO 我在两个单独的 session 中运行了两组命令。第一组命令顺序如下: git clone
我是一名优秀的程序员,十分优秀!