Don't add hooks in buffers without corresponding files

Magit tries to hack the directory-local variables into its status window
despite not having a corresponding file. This is the most expedient way
to ensure GAC doesn't run in these scenarios.
This commit is contained in:
Robert Irelan 2019-04-11 14:29:33 -07:00 committed by Robert Irelan
parent 666ee4350a
commit b1f38c1c4d

View file

@ -377,10 +377,11 @@ When `gac-automatically-push-p' is non-nil also push."
mode turned on and optionally push them too." mode turned on and optionally push them too."
:lighter " ga" :lighter " ga"
(cond (git-auto-commit-mode (cond (git-auto-commit-mode
(unless (null (buffer-file-name))
(gac--load-current-commit) (gac--load-current-commit)
(add-hook 'find-file-hook 'gac-find-file-func t t) (add-hook 'find-file-hook 'gac-find-file-func t t)
(add-hook 'before-save-hook 'gac-before-save-func t t) (add-hook 'before-save-hook 'gac-before-save-func t t)
(add-hook 'after-save-hook 'gac-after-save-func t t)) (add-hook 'after-save-hook 'gac-after-save-func t t)))
(t (t
(remove-hook 'find-file-hook 'gac-find-file-func t) (remove-hook 'find-file-hook 'gac-find-file-func t)
(remove-hook 'before-save-hook 'gac-before-save-func t) (remove-hook 'before-save-hook 'gac-before-save-func t)