From ca96589764439e550a528b936e94d9b41f2912c2 Mon Sep 17 00:00:00 2001 From: Owen Griffin Date: Wed, 1 Apr 2015 21:29:32 +0100 Subject: [PATCH 1/3] Support Windows paths - Changes the current directory before commit - Quotes the filename arguments using shell-quote-argument --- git-auto-commit-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index da6d01b..99ecd63 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -107,7 +107,7 @@ Default to FILENAME." (let* ((filename (buffer-file-name)) (commit-msg (gac--commit-msg filename))) (shell-command - (concat "git add '" filename "' && git commit -m '" commit-msg "'")))) + (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 "'")))) (defun gac-push () "Push commits to the current upstream. From 344667ee75446326207cfb6d4df335b0fe821d3b Mon Sep 17 00:00:00 2001 From: Owen Griffin Date: Thu, 2 Apr 2015 21:20:34 +0100 Subject: [PATCH 2/3] 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 --- git-auto-commit-mode.el | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 99ecd63..4675e29 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -104,10 +104,11 @@ Default to FILENAME." (defun gac-commit () "Commit the current buffer's file to git." - (let* ((filename (buffer-file-name)) - (commit-msg (gac--commit-msg filename))) + (let* ((filename (file-name-nondirectory (buffer-file-name))) + (commit-msg (gac--commit-msg (buffer-file-name))) + (default-directory (file-name-directory (buffer-file-name)))) (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 () "Push commits to the current upstream. From acf6a60578a5ac60f712d37b9055a676015c5a15 Mon Sep 17 00:00:00 2001 From: Owen Griffin Date: Thu, 2 Apr 2015 22:52:31 +0100 Subject: [PATCH 3/3] Wrap git commit message in shell-quote-argument --- git-auto-commit-mode.el | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/git-auto-commit-mode.el b/git-auto-commit-mode.el index 4675e29..6b41e69 100644 --- a/git-auto-commit-mode.el +++ b/git-auto-commit-mode.el @@ -108,7 +108,7 @@ Default to FILENAME." (commit-msg (gac--commit-msg (buffer-file-name))) (default-directory (file-name-directory (buffer-file-name)))) (shell-command - (concat "git add " (shell-quote-argument (convert-standard-filename filename)) " && git commit -m \"" commit-msg "\"")))) + (concat "git add " (shell-quote-argument (convert-standard-filename filename)) " && git commit -m " (shell-quote-argument commit-msg))))) (defun gac-push () "Push commits to the current upstream.