Closed owengriffin closed 9 years ago
Hey, thanks a lot for this PR.
I will certainly merge this, but I also have some questions.
You are basically cd
-ing into the buffer's default-directory
and then committing. Doesn't the Windows Emacs setup default-directory
correctly? And if not, doesn't the following accomplish the same, or does that not work on Windows?:
(let ((default-directory (file-name-directory filename)))
(shell-command
(concat "git add " ...)))
And if it does, shouldn't it be enough to call convert-standard-filename
on filename
to get the proper path for Windows? I don't use Windows myself, so it's difficult to test these things.
Yes, you're right - it is possible to use default-directory
.
It does need file-name-nondirectory
because on Windows the buffer-file-name
contains C:\path\to\file
- but the git command does not accept this as a filename.
Annoyingly I've found that the shell-quote-command
doesn't appear to correctly handle spaces in Windows. cmd.exe doesn't let you use spaces in filenames even if they are quoted. For example:
C:\test-repo>git add "Odd file name.org" && git commit -m 'Odd file name.org'
error: pathspec 'file' did not match any file(s) known to git.
error: pathspec 'name.org'' did not match any file(s) known to git.
Actually - after writing the above, I've discovered that it's actually the commit message which cmd.exe thinks is a path. This part needs to be quoted with double-quotes.
I'm not used to Windows - I'm doing this entirely so I can work on my work laptop with org-mode. I'll submit another pull request in a moment, but I won't have a chance to test it on Linux until the late tomorrow.
Ok, interesting, so doesn't that mean that wrapping the commit-msg
in a shell-quote-argument
should fix the commit message as well?
Yes. :-) Friday afternoon / evening head.
Thanks a lot. I've tested it some with my usual workflow and on a file with some spaces in it, everything seems to be going smoothly on my Archlinux installation. I wasn't aware of the shell-quote-argument
or convert-standard-filename
procedures, so thanks for bringing those to my attention.
I've made some changes to gac-commit
that I think make it a little cleaner, it shouldn't affect the workings of the procedure, but please let me know if I did break your code accidentally.
As long as I don't run into any trouble before then, I'll tag and upload a new version to Marmalade later today.