|
9 | 9 | from gitdb import IStream |
10 | 10 | from gitdb.db import LooseObjectDB |
11 | 11 |
|
12 | | -from git import Git, Repo |
| 12 | +from git import NULL_TREE, Git, Repo |
| 13 | +from git.diff import NULL_TREE_SHA |
13 | 14 | from git.exc import GitCommandError, UnsafeOptionError, UnsupportedOperation |
14 | 15 | from test.lib.fixtures import fixture_repo, writable_fixture |
15 | 16 |
|
@@ -118,6 +119,16 @@ def test_managed_commands_disable_implicit_execution(plain_repo): |
118 | 119 | assert execute.call_args.kwargs["env"]["GIT_NO_LAZY_FETCH"] == "1" |
119 | 120 |
|
120 | 121 |
|
| 122 | +@pytest.mark.parametrize("other", [NULL_TREE, NULL_TREE_SHA]) |
| 123 | +@pytest.mark.parametrize("create_patch", [False, True]) |
| 124 | +def test_index_diff_against_empty_tree_disables_textconv(plain_repo, other, create_patch): |
| 125 | + with patch.object(Git, "_call_process_safe", autospec=True, side_effect=Git._call_process_safe) as run: |
| 126 | + assert plain_repo.index.diff(other, create_patch=create_patch) == [] |
| 127 | + |
| 128 | + assert run.call_args.args[1] == "diff" |
| 129 | + assert "--no-textconv" in run.call_args.args[2:] |
| 130 | + |
| 131 | + |
121 | 132 | def test_blame_and_archive_do_not_run_configured_commands(repo): |
122 | 133 | marker = Path(repo.working_tree_dir) / "executed" |
123 | 134 | commit = repo.head.commit |
|
0 commit comments