Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Make sure diff always uses the default diff driver whencreate_patch=True#1832

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged
Byron merged 2 commits intogitpython-developers:mainfromcan-taslicukur:can.1828
Feb 28, 2024
Merged
Show file tree
Hide file tree
Changes fromall 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 deletionsgit/diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -155,6 +155,7 @@ def diff(

if create_patch:
args.append("-p")
args.append("--no-ext-diff")
else:
args.append("--raw")
args.append("-z")
Expand Down
42 changes: 42 additions & 0 deletionstest/test_diff.py
View file
Open in desktop
Original file line numberDiff line numberDiff line change
Expand Up@@ -473,3 +473,45 @@ def test_rename_override(self, rw_dir):
self.assertEqual(True, diff.renamed_file)
self.assertEqual("file_a.txt", diff.rename_from)
self.assertEqual("file_b.txt", diff.rename_to)

@with_rw_directory
def test_diff_patch_with_external_engine(self, rw_dir):
repo = Repo.init(rw_dir)
gitignore = osp.join(rw_dir, ".gitignore")

# First commit
with open(gitignore, "w") as f:
f.write("first_line\n")
repo.git.add(".gitignore")
repo.index.commit("first commit")

# Adding second line and committing
with open(gitignore, "a") as f:
f.write("second_line\n")
repo.git.add(".gitignore")
repo.index.commit("second commit")

# Adding third line and staging
with open(gitignore, "a") as f:
f.write("third_line\n")
repo.git.add(".gitignore")

# Adding fourth line
with open(gitignore, "a") as f:
f.write("fourth_line\n")

# Set the external diff engine
with repo.config_writer(config_level="repository") as writer:
writer.set_value("diff", "external", "bogus_diff_engine")

head_against_head = repo.head.commit.diff("HEAD^", create_patch=True)
self.assertEqual(len(head_against_head), 1)
head_against_index = repo.head.commit.diff(create_patch=True)
self.assertEqual(len(head_against_index), 1)
head_against_working_tree = repo.head.commit.diff(None, create_patch=True)
self.assertEqual(len(head_against_working_tree), 1)

index_against_head = repo.index.diff("HEAD", create_patch=True)
self.assertEqual(len(index_against_head), 1)
index_against_working_tree = repo.index.diff(None, create_patch=True)
self.assertEqual(len(index_against_working_tree), 1)

[8]ページ先頭

©2009-2025 Movatter.jp