This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(defun auto-stage-untracked-file () | |
"Add an empty version of the currently-visited file to the index | |
iff it is in a git repo, but untracked." | |
(when (and (magit-git-dir) | |
(not (magit-file-tracked-p (buffer-file-name))) | |
this-command ; nil for auto-save | |
(y-or-n-p "Add (intent-to-add) file to git index?")) | |
(magit-run-git "add" "--intent-to-add" "--" (buffer-file-name)))) | |
(add-hook 'after-save-hook 'auto-stage-untracked-file) |