aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKyle Meyer <kyle@kyleam.com>2022-07-21 23:45:16 -0400
committerKyle Meyer <kyle@kyleam.com>2022-07-21 23:45:57 -0400
commit281f0c3c377cc03f685f43c15e90be5a1fc09e75 (patch)
tree970b3cb37234bb4cbf19594fba66b4416ba38a5b
parent80cdadb08efcf3287f6af138608d2a71bd8d0a40 (diff)
magit-commit-diff-1: Fix recent regression in --all handling
As of 2dfeaa68 (magit-commit-diff-1: Use different heuristics, 2022-06-07), magit-commit-diff-1 uses magit-anything-unstaged-p when deciding what diff to show. However, $GIT_DIR is the default directory when magit-commit-diff-1 is called, so the 'git diff' command used by magit-anything-unstaged-p fails with an exit code of 128, leading to magit-anything-unstaged-p returning nil even when there are unstaged changes. Switch to the top-level of the working tree so that magit-anything-unstaged-p gives an accurate answer. Closes #4725.
-rw-r--r--lisp/magit-commit.el6
1 files changed, 5 insertions, 1 deletions
diff --git a/lisp/magit-commit.el b/lisp/magit-commit.el
index 79c9304..98f9764 100644
--- a/lisp/magit-commit.el
+++ b/lisp/magit-commit.el
@@ -567,7 +567,11 @@ See `magit-commit-absorb' for an alternative implementation."
(arg "--cached")
(command (magit-repository-local-get 'this-commit-command))
(staged (magit-anything-staged-p))
- (unstaged (magit-anything-unstaged-p))
+ (unstaged
+ ;; Escape $GIT_DIR because `magit-anything-unstaged-p'
+ ;; requires a working tree.
+ (magit-with-toplevel
+ (magit-anything-unstaged-p)))
(squash (let ((f (magit-git-dir "rebase-merge/rewritten-pending")))
(and (file-exists-p f) (length (magit-file-lines f)))))
(noalt nil))