Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions git/index/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -1665,6 +1665,7 @@ def diff(
self.repo._empty_tree_hexsha,
"--no-abbrev",
"--full-index",
"--no-textconv",
]

if not any(x in kwargs for x in ("find_renames", "no_renames", "M")):
Expand Down
13 changes: 12 additions & 1 deletion test/test_cli_safety.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@
from gitdb import IStream
from gitdb.db import LooseObjectDB

from git import Git, Repo
from git import NULL_TREE, Git, Repo
from git.diff import NULL_TREE_SHA
from git.exc import GitCommandError, UnsafeOptionError, UnsupportedOperation
from test.lib.fixtures import fixture_repo, writable_fixture

Expand Down Expand Up @@ -118,6 +119,16 @@ def test_managed_commands_disable_implicit_execution(plain_repo):
assert execute.call_args.kwargs["env"]["GIT_NO_LAZY_FETCH"] == "1"


@pytest.mark.parametrize("other", [NULL_TREE, NULL_TREE_SHA])
@pytest.mark.parametrize("create_patch", [False, True])
def test_index_diff_against_empty_tree_disables_textconv(plain_repo, other, create_patch):
with patch.object(Git, "_call_process_safe", autospec=True, side_effect=Git._call_process_safe) as run:
assert plain_repo.index.diff(other, create_patch=create_patch) == []

assert run.call_args.args[1] == "diff"
assert "--no-textconv" in run.call_args.args[2:]


def test_blame_and_archive_do_not_run_configured_commands(repo):
marker = Path(repo.working_tree_dir) / "executed"
commit = repo.head.commit
Expand Down
Loading