如何解决git add -p是否只检查一对一的对应关系,而不检查HunkHeader之后的句子?
我正在研究Git代码,但是,还有一个谜。
当我查看https://github.com/git/git/blob/master/add-patch.c#L440-L455时,我以为git add -p
比较下面的输入和输出。
# input
git diff-files -p --no-color
# output
git diff-files -p --color | {something you defined in interactive.diffFilter}
但是,似乎他们仅比较MetaHead(@@之前),而不比较HunkHeaders(@@和@@之后)。
# input
❯ git diff-files --no-color -p
diff --git a/src/options/set.rs b/src/options/set.rs
index a9ca6be..1a32706 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -196,7 +196,7 @@ pub fn set_options(
opt.commit_style = "raw".to_string();
opt.hunk_header_style = "raw".to_string();
opt.hunk_header_decoration_style = "none".to_string();
- }
+ } //aa
}
# output
❯ git diff-files --color -p | delta --color-only
diff --git a/src/options/set.rs b/src/options/set.rs
index a9ca6be..1a32706 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
@@ -196,7 @@ pub fn set_options( hogehogetest
196 ⋮196 │ opt.commit_style = "raw".to_string();
197 ⋮197 │ opt.hunk_header_style = "raw".to_string();
198 ⋮198 │ opt.hunk_header_decoration_style = "none".to_string();
199 ⋮ │- }
⋮199 │+ } //aa
200 ⋮200 │ }
如您所见,这是完全不同的,但是git -c 'interactive.diffFilter=delta --color-only' add -p
的工作原理。
如果我像这样编辑输出,
diff --git a/src/options/set.rs b/src/options/set.rs
index a9ca6be..1a32706 100644
--- a/src/options/set.rs
+++ b/src/options/set.rs
### <- insert break line
@@ -196,7 @@ pub fn set_options(
opt.commit_style = "raw".to_string();
opt.hunk_header_style = "raw".to_string();
opt.hunk_header_decoration_style = "none".to_string();
- }
+ } //aa
}
git add -p
现在出现了如下所示的错误。
fatal: mismatched output from interactive.diffFilter
hint: Your filter must maintain a one-to-one correspondence
hint: between its input and output lines.
我真的很好奇,为什么?我寻找的Git代码是错误的...?
解决方法
啊,不。
color_p和color_pend只是一个行数。 他们没有看里面,只是比较行数。
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。