| FazBrowse GitHub Viewer | Trending | | Home |
| Tools: [Download Repo ZIP] [Original HTTPS Page] |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -284,7 +284,10 @@ def diff( | |||
| 284 | 284 | # END paths handling | |
| 285 | 285 | ||
| 286 | 286 | kwargs["as_process"] = True | |
| 287 | - proc = diff_cmd(*self._process_diff_args(args), **kwargs) | ||
| 287 | + args = self._process_diff_args(args) | ||
| 288 | + if create_patch: | ||
| 289 | + self.repo.git(c="diff.mnemonicPrefix=false") | ||
| 290 | + proc = diff_cmd(*args, **kwargs) | ||
| 288 | 291 | ||
| 289 | 292 | diff_method = Diff._index_from_patch_format if create_patch else Diff._index_from_raw_format | |
| 290 | 293 | index = diff_method(self.repo, proc) | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -1547,6 +1547,8 @@ def diff( | |||
| 1547 | 1547 | args.extend(paths) | |
| 1548 | 1548 | ||
| 1549 | 1549 | kwargs["as_process"] = True | |
| 1550 | + if create_patch: | ||
| 1551 | + self.repo.git(c="diff.mnemonicPrefix=false") | ||
| 1550 | 1552 | proc = self.repo.git.diff(*args, **kwargs) | |
| 1551 | 1553 | ||
| 1552 | 1554 | diff_method = ( | |
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
@@ -92,6 +92,26 @@ def test_diff_with_staged_file(self, rw_dir): | |||
| 92 | 92 | "This should work, but doesn't right now ... it's OK", | |
| 93 | 93 | ) | |
| 94 | 94 | ||
| 95 | + @with_rw_directory | ||
| 96 | + def test_patch_diff_ignores_mnemonic_prefix(self, rw_dir): | ||
| 97 | + repo = Repo.init(rw_dir) | ||
| 98 | + filepath = osp.join(rw_dir, "file.txt") | ||
| 99 | + with open(filepath, "w") as stream: | ||
| 100 | + stream.write("initial\n") | ||
| 101 | + repo.index.add([filepath]) | ||
| 102 | + repo.index.commit("initial") | ||
| 103 | + | ||
| 104 | + with open(filepath, "w") as stream: | ||
| 105 | + stream.write("changed\n") | ||
| 106 | + repo.git.config("diff.mnemonicPrefix", "true") | ||
| 107 | + | ||
| 108 | + self.assertEqual(len(repo.head.commit.diff(None, create_patch=True)), 1) | ||
| 109 | + self.assertEqual(len(repo.index.diff(None, create_patch=True)), 1) | ||
| 110 | + | ||
| 111 | + repo.index.add([filepath]) | ||
| 112 | + self.assertEqual(len(repo.index.diff(NULL_TREE, create_patch=True)), 1) | ||
| 113 | + self.assertEqual(repo.git.config("--get", "diff.mnemonicPrefix"), "true") | ||
| 114 | + | ||
| 95 | 115 | def test_list_from_string_new_mode(self): | |
| 96 | 116 | output = StringProcessAdapter(fixture("diff_new_mode")) | |
| 97 | 117 | diffs = Diff._index_from_patch_format(self.rorepo, output) | |
| Back | FazBrowse Home | New Git URL |
0 commit comments