@@ -133,7 +133,7 @@ def _get_commit_output(
133133 home = home or tempdir_factory .get ()
134134 env = dict (env_base , PRE_COMMIT_HOME = home )
135135 return cmd_output (
136- 'git' , 'commit' , '-m ' , 'Commit!' , '--allow-empty' ,
136+ 'git' , 'commit' , '-am ' , 'Commit!' , '--allow-empty' ,
137137 # git commit puts pre-commit to stderr
138138 stderr = subprocess .STDOUT ,
139139 env = env ,
@@ -175,7 +175,7 @@ def test_install_in_submodule_and_run(tempdir_factory):
175175 parent_path = git_dir (tempdir_factory )
176176 with cwd (parent_path ):
177177 cmd_output ('git' , 'submodule' , 'add' , src_path , 'sub' )
178- cmd_output ('git' , 'commit' , '-am ' , 'foo' )
178+ cmd_output ('git' , 'commit' , '-m ' , 'foo' )
179179
180180 sub_pth = os .path .join (parent_path , 'sub' )
181181 with cwd (sub_pth ):
@@ -185,6 +185,23 @@ def test_install_in_submodule_and_run(tempdir_factory):
185185 assert NORMAL_PRE_COMMIT_RUN .match (output )
186186
187187
188+ def test_commit_am (tempdir_factory ):
189+ """Regression test for #322."""
190+ path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
191+ with cwd (path ):
192+ # Make an unstaged change
193+ open ('unstaged' , 'w' ).close ()
194+ cmd_output ('git' , 'add' , '.' )
195+ cmd_output ('git' , 'commit' , '-m' , 'foo' )
196+ with io .open ('unstaged' , 'w' ) as foo_file :
197+ foo_file .write ('Oh hai' )
198+
199+ assert install (Runner (path )) == 0
200+
201+ ret , output = _get_commit_output (tempdir_factory )
202+ assert ret == 0
203+
204+
188205def test_install_idempotent (tempdir_factory ):
189206 path = make_consuming_repo (tempdir_factory , 'script_hooks_repo' )
190207 with cwd (path ):
0 commit comments