在调用git diff时,提交hash后会做什么?(^!)? [英] What does caret bang (^!) after the commit hash do when calling git diff?

查看:238
本文介绍了在调用git diff时,提交hash后会做什么?(^!)?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

仔细查看括号-git 的源代码( Brackets ),我发现 ^!(插入符号)被添加到在调用 git diff 时提交哈希。请参阅 GitCli.js,第754行
$ b

  function getDiffOfFileFromCommit(hash,file){
return git([diff ,--no-ext-diff,--no-color,hash +^!, - ,file]);



$ b $ p
$ b

在命令行中转换为以下内容,使用相关文件作为例如:
$ b

  $ git diff --no-ext-diff --no-color 1f9ea6e ^! -  src / git / GitCli.js 

我知道 ^ 会引用提交的父代。 ^!做什么? 提交^!是一个范围说明符,意思是:这个提交,但没有其父母。
这相当于指定: commit ^ parent1 ^ parent2 ^ parentN



有意义(你只能比较两棵树)
通过测试,该命令似乎显示了父母和最后父母的合并基础之间的差异。我认为git(mis)解释类似于范围 A ... B 的参数,它将显示 merge-base AB code>和 B git diff parent1 ... parent2 会产生相同的差异)。不知道在章鱼合并的情况下会发生什么。



我可能是错的,但这些只是我从测试库中抽取的假设, git代码( builtin / diff.c )。


Looking through the source code for brackets-git (a git extension for Brackets), I see that ^! (caret bang) is being appended to the commit hash when calling git diff. See GitCli.js, line 754:

function getDiffOfFileFromCommit(hash, file) {
    return git(["diff", "--no-ext-diff", "--no-color", hash + "^!", "--", file]);
}

This translates to the following on the command line, using the file in question as an example:

$ git diff --no-ext-diff --no-color 1f9ea6e^! -- src/git/GitCli.js

I know that ^ would refer to the parent of the commit. What does ^! do?

解决方案

commit^! is a range specifier which means: this commit, but none of its parents. It's equivalent to specifying: commit ^parent1 ^parent2 ^parentN.

For diff this does not make sense (you can only compare two trees) From testing the command seems to show the differences between the merge base of the parents and the last parent. I think git (mis)interprets the parameters similar to the range A...B which will show the differences between the merge-base A B and B (git diff parent1...parent2 will produce the same diff). Not sure what will happen in the case of an octopus-merge.

I might be wrong though, these are just assumptions I drew from testing with a repository and looking into the git code (builtin/diff.c).

这篇关于在调用git diff时,提交hash后会做什么?(^!)?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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