简体   繁体   English

为什么不git add --patch使用git add -N的二进制文件?

[英]Why doesn't git add --patch work with git add -N of a binary file?

git add --patch doesn't work with binary files added with git add -N . git add --patch不适用于使用git add -N添加的二进制文件。 Does anyone know why? 有谁知道为什么? In the following example you can see that git add --patch picks up the text file a but not the binary file 0 . 在下面的示例中,您可以看到git add --patch拾取文本文件a而不是二进制文件0

echo a > a
echo '\0' > 0
git add -N 0
git add -N a

git add --patch
diff --git a/a b/a
index e69de29..7898192 100644
--- a/a
+++ b/a
@@ -0,0 +1 @@
+a
Stage this hunk [y,n,q,a,d,/,e,?]? y 

The implementation explicitly excludes binary files. 该实现明确排除了二进制文件。 See line 7: 见第7行:

 1  sub patch_update_cmd {
 2    my @all_mods = list_modified($patch_mode_flavour{FILTER});
 3    error_msg sprintf(__("ignoring unmerged: %s\n"), $_->{VALUE})
 4      for grep { $_->{UNMERGED} } @all_mods;
 5    @all_mods = grep { !$_->{UNMERGED} } @all_mods;
 6
 7    my @mods = grep { !($_->{BINARY}) } @all_mods;
 8    my @them;
 9
10    if (!@mods) {
11      if (@all_mods) {
12        print STDERR __("Only binary files changed.\n");
13      } else {
14        print STDERR __("No changes.\n");
15      }
16      return 0;
17    }
18    if ($patch_mode_only) {
19      @them = @mods;
20    }
21    else {
22      @them = list_and_choose({ PROMPT => __('Patch update'),
23              HEADER => $status_head, },
24            @mods);
25    }
26    for (@them) {
27      return 0 if patch_update_file($_->{VALUE});
28    }
29  }

git-add--interactive.perl#L1310-L1338 混帐相加- interactive.perl#L1310-L1338

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM