From 6074f4796659f099167539047528edaebe883fb1 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20Ta=C5=9Fl=C4=B1=C3=A7ukur?= Date: Mon, 19 Feb 2024 22:25:10 +0300 Subject: [PATCH 1/2] feat: :sparkles: added "--no-ext-diff" flag when create_patch=True to diff --- git/diff.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/git/diff.py b/git/diff.py index aba1a1080..ae85e77ae 100644 --- a/git/diff.py +++ b/git/diff.py @@ -155,6 +155,8 @@ def diff( if create_patch: args.append("-p") + # we expect the default diff driver + args.append("--no-ext-diff") else: args.append("--raw") args.append("-z") From 5d6c86a47cb72d7ca80d122bc0bb899eb0637b19 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Can=20Ta=C5=9Fl=C4=B1=C3=A7ukur?= Date: Wed, 28 Feb 2024 00:24:59 +0300 Subject: [PATCH 2/2] test: :white_check_mark: Added test for external diff engine and removed comment --- git/diff.py | 1 - test/test_diff.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 42 insertions(+), 1 deletion(-) diff --git a/git/diff.py b/git/diff.py index ae85e77ae..6d4474d3e 100644 --- a/git/diff.py +++ b/git/diff.py @@ -155,7 +155,6 @@ def diff( if create_patch: args.append("-p") - # we expect the default diff driver args.append("--no-ext-diff") else: args.append("--raw") diff --git a/test/test_diff.py b/test/test_diff.py index 87f92f5d1..e3d0b8e5c 100644 --- a/test/test_diff.py +++ b/test/test_diff.py @@ -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) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy