@@ -473,3 +473,45 @@ def test_rename_override(self, rw_dir):
473473self .assertEqual (True ,diff .renamed_file )
474474self .assertEqual ("file_a.txt" ,diff .rename_from )
475475self .assertEqual ("file_b.txt" ,diff .rename_to )
476+
477+ @with_rw_directory
478+ def test_diff_patch_with_external_engine (self ,rw_dir ):
479+ repo = Repo .init (rw_dir )
480+ gitignore = osp .join (rw_dir ,".gitignore" )
481+
482+ # First commit
483+ with open (gitignore ,"w" )as f :
484+ f .write ("first_line\n " )
485+ repo .git .add (".gitignore" )
486+ repo .index .commit ("first commit" )
487+
488+ # Adding second line and committing
489+ with open (gitignore ,"a" )as f :
490+ f .write ("second_line\n " )
491+ repo .git .add (".gitignore" )
492+ repo .index .commit ("second commit" )
493+
494+ # Adding third line and staging
495+ with open (gitignore ,"a" )as f :
496+ f .write ("third_line\n " )
497+ repo .git .add (".gitignore" )
498+
499+ # Adding fourth line
500+ with open (gitignore ,"a" )as f :
501+ f .write ("fourth_line\n " )
502+
503+ # Set the external diff engine
504+ with repo .config_writer (config_level = "repository" )as writer :
505+ writer .set_value ("diff" ,"external" ,"bogus_diff_engine" )
506+
507+ head_against_head = repo .head .commit .diff ("HEAD^" ,create_patch = True )
508+ self .assertEqual (len (head_against_head ),1 )
509+ head_against_index = repo .head .commit .diff (create_patch = True )
510+ self .assertEqual (len (head_against_index ),1 )
511+ head_against_working_tree = repo .head .commit .diff (None ,create_patch = True )
512+ self .assertEqual (len (head_against_working_tree ),1 )
513+
514+ index_against_head = repo .index .diff ("HEAD" ,create_patch = True )
515+ self .assertEqual (len (index_against_head ),1 )
516+ index_against_working_tree = repo .index .diff (None ,create_patch = True )
517+ self .assertEqual (len (index_against_working_tree ),1 )