From aad741f8cc9c580a4f4258f2a6296b2f30f69e4c Mon Sep 17 00:00:00 2001 From: Sven Weidauer Date: Mon, 6 Jun 2022 11:40:40 +0200 Subject: [PATCH] Only check for staged changes if writing output --- lib/format-staged/job.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/format-staged/job.rb b/lib/format-staged/job.rb index bc6acd9..e061fec 100644 --- a/lib/format-staged/job.rb +++ b/lib/format-staged/job.rb @@ -39,7 +39,7 @@ module FormatStaged return false unless formatted.size == files.size quiet = @verbose ? [] : ['--quiet'] - return get_status('git', 'diff-index', '--cached', '--exit-code', *quiet, 'HEAD') != 0 + return !write || get_status('git', 'diff-index', '--cached', '--exit-code', *quiet, 'HEAD') != 0 end def repo_root