tags:

views:

432

answers:

3

I'm currently trying to use Magit with Emacs 23.1 on Win7 64-bit but Magit does not recognise my git repositories. Please bear in mind I'm a complete Emacs newbie.

I run the magit-status command and it asks for a directory containing the repo, which I obviously type in and then it just says every time I try: "There is no Git repository in "e:/path/to/directory". Create one? (y or n)" when there definitely is a repository in there.

Has anybody else encountered this? I've read that it could possibly be that the actual git.exe can't be found and I've tried messing around with my Path variable but nothing I do is allowing Magit to recognise my repositories. Any ideas?

A: 

(quickly, off top of head) this wouldn't be anything to do with the dot before the repo name, would it?

Dave Everitt
+3  A: 

Hi,

magit runs the following command to find the .git directory:

git rev-parse --git-dir

I would first try if Emacs really sees your git binary. To do this, please open any file in your git repository in emacs. Next do M-x: shell-command and type the above git command in the prompt: git rev-parse --git-dir.

As output you should get something like .git. If you get 'git' is not recognized as an internal or external command, ..., then you need to make sure emacs/magit can find git. You do this by either customizing magit-git-executable (M-x: customize-variable) and point it to the absolute path or by making sure the git directory is in the Windows PATH (if you use msysgit you have been asked during installation).

Hope this helps!

Cheers, Daniel

danielpoe
Thanks for your help, the git shell command works fine, it finds the correct directory but still magit-status still won't recognise there is a repository! I'll just have to use the command line methinks.
KnackeredCoder
A: 

Found out the problem, it's the magit-escape-for-shell function that escape the executable which Windows can't handle. After checking the code of my previous installation, it's clear they've altered the code without changing the version, BAD! Here's a patch that should fix that bug:

--- magit.el.orig       2010-02-19 16:48:43.671875000 -0500
+++ magit.el    2010-02-19 16:49:30.078125000 -0500
@@ -320,7 +320,9 @@
                     prop val))

 (defun magit-escape-for-shell (str)
-  (concat "'" (replace-regexp-in-string "'" "'\\''" str) "'"))
+  (if (not (equal system-type 'windows-nt))
+      (concat "'" (replace-regexp-in-string "'" "'\\''" str) "'")
+    str))

 (defun magit-format-commit (commit format)
   (magit-git-string "log --max-count=1 --pretty=format:%s %s" format commit))
Nicolas Buduroi
I've checked their Gitorious repository and it is clean, so it's the ELPA version that have this issue.
Nicolas Buduroi