@@ -58,6 +58,7 @@ def _get_opts(
5858 source = '' ,
5959 allow_unstaged_config = False ,
6060 hook_stage = 'commit' ,
61+ show_diff_on_failure = False ,
6162):
6263 # These are mutually exclusive
6364 assert not (all_files and files )
@@ -67,11 +68,12 @@ def _get_opts(
6768 color = color ,
6869 verbose = verbose ,
6970 hook = hook ,
70- hook_stage = hook_stage ,
7171 no_stash = no_stash ,
7272 origin = origin ,
7373 source = source ,
7474 allow_unstaged_config = allow_unstaged_config ,
75+ hook_stage = hook_stage ,
76+ show_diff_on_failure = show_diff_on_failure ,
7577 )
7678
7779
@@ -151,6 +153,23 @@ def test_hook_that_modifies_but_returns_zero(
151153 )
152154
153155
156+ def test_show_diff_on_failure (
157+ capfd , cap_out , tempdir_factory , mock_out_store_directory ,
158+ ):
159+ git_path = make_consuming_repo (
160+ tempdir_factory , 'modified_file_returns_zero_repo' ,
161+ )
162+ with cwd (git_path ):
163+ stage_a_file ('bar.py' )
164+ _test_run (
165+ cap_out , git_path , {'show_diff_on_failure' : True },
166+ # we're only testing the output after running
167+ (), 1 , True ,
168+ )
169+ out , _ = capfd .readouterr ()
170+ assert 'diff --git' in out
171+
172+
154173@pytest .mark .parametrize (
155174 ('options' , 'outputs' , 'expected_ret' , 'stage' ),
156175 (
0 commit comments