git-merge输出正确吗?

如何解决git-merge输出正确吗?

我正在尝试分析Github(https://github.com/antlr/antlr4)的ANTLR4存储库中的合并历史。但是,当我尝试重播合并fe1d61d9dba9f202982da85606cbb7493ce7bae8时,没有对我来说有意义的输出。所以我想知道是否有人可以帮助我。

合并fe1d61d9dba9f202982da85606cbb7493ce7bae8有两个父对象:103dc662c和31d21ff4d。因此,要重放合并,我执行以下步骤:

  1. git checkout 103dc662c;和
  2. git merge 31d21ff4d。

在这种情况下,有一些冲突的文件。但是,文件“存储库路径” /runtime/Go/src/antlr/ErrorStrategy.go显示以下冲突:

// @param recognizer the parser instance
// @param e the recognition exception
//
<<<<<<< HEAD:runtime/Go/src/antlr/ErrorStrategy.go
func (d *DefaultErrorStrategy) ReportInputMisMatch(recognizer Parser,e *InputMisMatchException) {
        var msg = "mismatched input " + d.GetTokenErrorDisplay(e.offendingToken) +
=======
func (this *DefaultErrorStrategy) ReportInputMisMatch(recognizer Parser,e *InputMisMatchException) {
        var msg = "mismatched input " + this.GetTokenErrorDisplay(e.offendingToken) +
>>>>>>> 31d21ff:runtime/Go/src/antlr4/ErrorStrategy.go
                " expecting " + e.getExpectedTokens().StringVerbose(recognizer.GetLiteralNames(),recognizer.GetSymbolicNames(),false)
        recognizer.NotifyErrorListeners(msg,e.offendingToken,e)
} 

当我尝试打开父级版本的原始文件时,左侧版本(103dc662c)中的文件 存在,但正确版本(31d21ff4d)中的文件不存在>>>>>>> 31d21ff:runtime / Go / src / antlr4 / ErrorStrategy.go 。经过调查,我发现正确版本的文件也位于runtime / Go / src / antlr / ErrorStrategy.go路径中。

我误解了吗?

预先感谢, Gleiph

解决方法

让我们重复设置:

$ git clone https://github.com/antlr/antlr4
Cloning into 'antlr4'...
remote: Enumerating objects: 2,done.
remote: Counting objects: 100% (2/2),done.
remote: Compressing objects: 100% (2/2),done.
^Rceiving objects:  21% (24258/115511),16.64 MiB | 3.15 MiB/s    /s   
remote: Total 115511 (delta 0),reused 0 (delta 0),pack-reused 115509
Receiving objects: 100% (115511/115511),61.89 MiB | 3.13 MiB/s,done.
Resolving deltas: 100% (67916/67916),done.
$ git checkout -b tmp 103dc662c

到目前为止一切正常。现在,我们将获得合并冲突以及许多我们应注意的消息:

$ git merge 31d21ff4d
Auto-merging tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
CONFLICT (content): Merge conflict in tool/resources/org/antlr/v4/tool/templates/codegen/Go/Go.stg
Auto-merging runtime/Go/src/antlr/Utils.go
Auto-merging runtime/Go/src/antlr/Trees.go
Auto-merging runtime/Go/src/antlr/Tree.go
Auto-merging runtime/Go/src/antlr/Transition.go
CONFLICT (rename/delete): runtime/Go/src/antlr4/TraceListener.go deleted in HEAD and renamed to runtime/Go/src/antlr/TraceListener.go in 31d21ff4d. Version 31d21ff4d of runtime/Go/src/antlr/TraceListener.go left in tree.
Auto-merging runtime/Go/src/antlr/TokenStream.go
Auto-merging runtime/Go/src/antlr/TokenSource.go
Auto-merging runtime/Go/src/antlr/Token.go
Auto-merging runtime/Go/src/antlr/SemanticContext.go
Auto-merging runtime/Go/src/antlr/RuleContext.go
Auto-merging runtime/Go/src/antlr/Recognizer.go
Auto-merging runtime/Go/src/antlr/PredictionMode.go
Auto-merging runtime/Go/src/antlr/PredictionContext.go
Auto-merging runtime/Go/src/antlr/ParserRuleContext.go
Auto-merging runtime/Go/src/antlr/ParserATNSimulator.go
Auto-merging runtime/Go/src/antlr/Parser.go
Auto-merging runtime/Go/src/antlr/LexerActionExecutor.go
Auto-merging runtime/Go/src/antlr/LexerAction.go
Auto-merging runtime/Go/src/antlr/LexerATNSimulator.go
Auto-merging runtime/Go/src/antlr/Lexer.go
Auto-merging runtime/Go/src/antlr/LL1Analyzer.go
Auto-merging runtime/Go/src/antlr/IntervalSet.go
Auto-merging runtime/Go/src/antlr/IntStream.go
Auto-merging runtime/Go/src/antlr/InputStream.go
Auto-merging runtime/Go/src/antlr/FileStream.go
Auto-merging runtime/Go/src/antlr/Errors.go
Auto-merging runtime/Go/src/antlr/ErrorStrategy.go
CONFLICT (content): Merge conflict in runtime/Go/src/antlr/ErrorStrategy.go
Auto-merging runtime/Go/src/antlr/ErrorListener.go
Auto-merging runtime/Go/src/antlr/DiagnosticErrorListener.go
Auto-merging runtime/Go/src/antlr/DFAState.go
Auto-merging runtime/Go/src/antlr/DFASerializer.go
Auto-merging runtime/Go/src/antlr/DFA.go
Auto-merging runtime/Go/src/antlr/CommonTokenStream.go
Auto-merging runtime/Go/src/antlr/CommonTokenFactory.go
Auto-merging runtime/Go/src/antlr/CharStream.go
Auto-merging runtime/Go/src/antlr/ATNType.go
Auto-merging runtime/Go/src/antlr/ATNState.go
Auto-merging runtime/Go/src/antlr/ATNSimulator.go
Auto-merging runtime/Go/src/antlr/ATNDeserializer.go
Auto-merging runtime/Go/src/antlr/ATNDeserializationOptions.go
Auto-merging runtime/Go/src/antlr/ATNConfigSet.go
Auto-merging runtime/Go/src/antlr/ATNConfig.go
Auto-merging runtime/Go/src/antlr/ATN.go
Removing pb/src/parser/T.g4
Removing pb/src/parser/T.g
Removing pb/src/parser/S.g4
Removing pb/src/parser/M.g4
Removing pb/src/parser/JSON.g4
Removing pb/src/parser/Expr.g4
Removing pb/src/parser/Arithmetic.g4
Removing pb/src/parser/.gitignore
Removing pb/src/input
Removing pb/src/Test.go
Removing antlr.go
Automatic merge failed; fix conflicts and then commit the result.

请注意前面提到的重命名/删除冲突:

CONFLICT (rename/delete): runtime/Go/src/antlr4/TraceListener.go deleted in HEAD
and renamed to runtime/Go/src/antlr/TraceListener.go in 31d21ff4d. Version
31d21ff4d of runtime/Go/src/antlr/TraceListener.go left in tree.

(我添加了换行符)。

当我尝试打开父版本中的原始文件时,存在左侧版本中的文件...

很好,但是很明显,至少一侧至少重命名了 some 个文件,所以我们应该期望这些文件在三个输入提交中可能具有不同的名称。

...正确版本的文件...位于路径runtime / Go / src / antlr / ErrorStrategy.go中。

我在runtime/Go/src/antlr/ErrorStrategy.goMERGE_HEAD又名31d21ff4db8ddcf76bae1b865cd568621bfd5b4d中找到了这个。

但是,在合并基础中提交:

$ git merge-base --all HEAD MERGE_HEAD
3406acabe51e89c57fc26aca02aeb7cbc30119bd

存储库在runtime/Go/src/antlr4/ErrorStrategy.go中有存储库:

git ls-tree -r 3406acabe51e89c57fc26aca02aeb7cbc30119bd | grep ErrorStrategy.go
100644 blob aed0ef94b5409f8035897496610446a5cbb52ef2    runtime/Go/src/antlr4/ErrorStrategy.go

换句话说,似乎两个合并输入提交都遵循相同的重命名模式。从合并库到HEAD的差异以及从合并库到31d21ff4d的差异都将antl4子目录重命名为antlr

这完全正常。如果您要进行手动合并解析,将merge.conflictStyle设置为diff3可能会有所帮助。如果您希望Git为您找到文件,请考虑使用git mergetool提取输入文件:应该会自动为您找到merge-base文件,HEAD文件和MERGE_HEAD文件。

,

Torek

非常感谢。但是,在Git合并文档(https://git-scm.com/docs/git-merge)中,有以下示例:

Here are lines that are either unchanged from the common
ancestor,or cleanly resolved because only one side changed.
<<<<<<< yours:sample.txt
Conflict resolution is hard;
let's go shopping.
=======
Git makes conflict resolution easy.
>>>>>>> theirs:sample.txt
And here is another line that is cleanly resolved or unmodified.

所以我期望像这样:

// @param recognizer the parser instance
// @param e the recognition exception
//
<<<<<<< HEAD:runtime/Go/src/antlr/ErrorStrategy.go
func (d *DefaultErrorStrategy) ReportInputMisMatch(recognizer Parser,e *InputMisMatchException) {
        var msg = "mismatched input " + d.GetTokenErrorDisplay(e.offendingToken) +
=======
func (this *DefaultErrorStrategy) ReportInputMisMatch(recognizer Parser,e *InputMisMatchException) {
        var msg = "mismatched input " + this.GetTokenErrorDisplay(e.offendingToken) +
>>>>>>> 31d21ff:runtime/Go/src/antlr/ErrorStrategy.go
                " expecting " + e.getExpectedTokens().StringVerbose(recognizer.GetLiteralNames(),recognizer.GetSymbolicNames(),false)
        recognizer.NotifyErrorListeners(msg,e.offendingToken,e)
} 

在这种情况下,两个分支都被重命名。但是,行>>>>>>> 31d21ff:runtime / Go / src / antlr / ErrorStrategy.go >>>>>>> 31d21ff:runtime / Go / src /实际示例中为antlr4 / ErrorStrategy.go 。对您有意义吗?

谢谢, Gleiph

版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。

相关推荐


依赖报错 idea导入项目后依赖报错,解决方案:https://blog.csdn.net/weixin_42420249/article/details/81191861 依赖版本报错:更换其他版本 无法下载依赖可参考:https://blog.csdn.net/weixin_42628809/a
错误1:代码生成器依赖和mybatis依赖冲突 启动项目时报错如下 2021-12-03 13:33:33.927 ERROR 7228 [ main] o.s.b.d.LoggingFailureAnalysisReporter : *************************** APPL
错误1:gradle项目控制台输出为乱码 # 解决方案:https://blog.csdn.net/weixin_43501566/article/details/112482302 # 在gradle-wrapper.properties 添加以下内容 org.gradle.jvmargs=-Df
错误还原:在查询的过程中,传入的workType为0时,该条件不起作用 &lt;select id=&quot;xxx&quot;&gt; SELECT di.id, di.name, di.work_type, di.updated... &lt;where&gt; &lt;if test=&qu
报错如下,gcc版本太低 ^ server.c:5346:31: 错误:‘struct redisServer’没有名为‘server_cpulist’的成员 redisSetCpuAffinity(server.server_cpulist); ^ server.c: 在函数‘hasActiveC
解决方案1 1、改项目中.idea/workspace.xml配置文件,增加dynamic.classpath参数 2、搜索PropertiesComponent,添加如下 &lt;property name=&quot;dynamic.classpath&quot; value=&quot;tru
删除根组件app.vue中的默认代码后报错:Module Error (from ./node_modules/eslint-loader/index.js): 解决方案:关闭ESlint代码检测,在项目根目录创建vue.config.js,在文件中添加 module.exports = { lin
查看spark默认的python版本 [root@master day27]# pyspark /home/software/spark-2.3.4-bin-hadoop2.7/conf/spark-env.sh: line 2: /usr/local/hadoop/bin/hadoop: No s
使用本地python环境可以成功执行 import pandas as pd import matplotlib.pyplot as plt # 设置字体 plt.rcParams[&#39;font.sans-serif&#39;] = [&#39;SimHei&#39;] # 能正确显示负号 p
错误1:Request method ‘DELETE‘ not supported 错误还原:controller层有一个接口,访问该接口时报错:Request method ‘DELETE‘ not supported 错误原因:没有接收到前端传入的参数,修改为如下 参考 错误2:cannot r
错误1:启动docker镜像时报错:Error response from daemon: driver failed programming external connectivity on endpoint quirky_allen 解决方法:重启docker -&gt; systemctl r
错误1:private field ‘xxx‘ is never assigned 按Altʾnter快捷键,选择第2项 参考:https://blog.csdn.net/shi_hong_fei_hei/article/details/88814070 错误2:启动时报错,不能找到主启动类 #
报错如下,通过源不能下载,最后警告pip需升级版本 Requirement already satisfied: pip in c:\users\ychen\appdata\local\programs\python\python310\lib\site-packages (22.0.4) Coll
错误1:maven打包报错 错误还原:使用maven打包项目时报错如下 [ERROR] Failed to execute goal org.apache.maven.plugins:maven-resources-plugin:3.2.0:resources (default-resources)
错误1:服务调用时报错 服务消费者模块assess通过openFeign调用服务提供者模块hires 如下为服务提供者模块hires的控制层接口 @RestController @RequestMapping(&quot;/hires&quot;) public class FeignControl
错误1:运行项目后报如下错误 解决方案 报错2:Failed to execute goal org.apache.maven.plugins:maven-compiler-plugin:3.8.1:compile (default-compile) on project sb 解决方案:在pom.
参考 错误原因 过滤器或拦截器在生效时,redisTemplate还没有注入 解决方案:在注入容器时就生效 @Component //项目运行时就注入Spring容器 public class RedisBean { @Resource private RedisTemplate&lt;String
使用vite构建项目报错 C:\Users\ychen\work&gt;npm init @vitejs/app @vitejs/create-app is deprecated, use npm init vite instead C:\Users\ychen\AppData\Local\npm-