Use default-directory for git commit

- Uses double-quotes for commit message to support filenames with spaces
  on Windows
- file-name-nondirectory is necessary for Windows support, otherwise the
  drive name (C:\) is included in the path
This commit is contained in:
Owen Griffin 2015-04-02 21:20:34 +01:00
parent ca96589764
commit 344667ee75

View file

@ -104,10 +104,11 @@ Default to FILENAME."
(defun gac-commit () (defun gac-commit ()
"Commit the current buffer's file to git." "Commit the current buffer's file to git."
(let* ((filename (buffer-file-name)) (let* ((filename (file-name-nondirectory (buffer-file-name)))
(commit-msg (gac--commit-msg filename))) (commit-msg (gac--commit-msg (buffer-file-name)))
(default-directory (file-name-directory (buffer-file-name))))
(shell-command (shell-command
(concat "cd " (shell-quote-argument (convert-standard-filename (file-name-directory (buffer-file-name)))) " && git add " (shell-quote-argument (convert-standard-filename (file-name-nondirectory filename))) " && git commit -m '" commit-msg "'")))) (concat "git add " (shell-quote-argument (convert-standard-filename filename)) " && git commit -m \"" commit-msg "\""))))
(defun gac-push () (defun gac-push ()
"Push commits to the current upstream. "Push commits to the current upstream.