threads / patch / 32166

patchemacs: make 'git-status' work with separate git dirs

Subject: [PATCH] emacs: make 'git-status' work with separate git dirs

## tl;dr

4 messages between Nov 22, 2012 and Nov 26, 2012. Diffs are folded; open one to read it.

replies: 3people: 3as markdown or json

Enrico Scholz· Nov 22, 2012, 15:58 UTC · lore

when trying 'M-x git-status' in a submodule created with recent (1.7.5+) git, the command fails with

| ... is not a git working tree

This is caused by creating submodules with '--separate-git-dir' but still checking for a working tree by testing for a '.git' directory.

The patch fixes this by relaxing the existing detection a little bit.
Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
---
 contrib/emacs/git.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
Show changes to contrib/emacs/git.el +1 −1
diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
index 65c95d9..5ffc506 100644
--- a/contrib/emacs/git.el
+++ b/contrib/emacs/git.el
@@ -1671,7 +1671,7 @@ Commands:
   "Entry point into git-status mode."
   (interactive "DSelect directory: ")
   (setq dir (git-get-top-dir dir))
-  (if (file-directory-p (concat (file-name-as-directory dir) ".git"))
+  (if (file-exists-p (concat (file-name-as-directory dir) ".git"))
       (let ((buffer (or (and git-reuse-status-buffer (git-find-status-buffer dir))
                         (create-file-buffer (expand-file-name "*git-status*" dir)))))
         (switch-to-buffer buffer)
-- 
1.7.11.7
Junio C Hamano· Nov 25, 2012, 06:22 UTC · re: Enrico Scholz · lore

Re: [PATCH] emacs: make 'git-status' work with separate git dirs

Enrico Scholz <enrico.scholz@sigma-chemnitz.de> writes:
Show 12 quoted lines
> when trying 'M-x git-status' in a submodule created with recent (1.7.5+)
> git, the command fails with
>
> | ... is not a git working tree
>
> This is caused by creating submodules with '--separate-git-dir' but
> still checking for a working tree by testing for a '.git' directory.
>
> The patch fixes this by relaxing the existing detection a little bit.
>
> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
> ---

This script already relies on the assumption that nobody sane would create a directory named ".git" that is not a git repository, and this loosens the assumption that nobody would create a file named ".git", either. So I would think it is a sane thing to do, but just in case if the area expert has better ideas, I am forwarding it.

Ack?
Show 16 quoted lines
>  contrib/emacs/git.el | 2 +-
>  1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/contrib/emacs/git.el b/contrib/emacs/git.el
> index 65c95d9..5ffc506 100644
> --- a/contrib/emacs/git.el
> +++ b/contrib/emacs/git.el
> @@ -1671,7 +1671,7 @@ Commands:
>    "Entry point into git-status mode."
>    (interactive "DSelect directory: ")
>    (setq dir (git-get-top-dir dir))
> -  (if (file-directory-p (concat (file-name-as-directory dir) ".git"))
> +  (if (file-exists-p (concat (file-name-as-directory dir) ".git"))
>        (let ((buffer (or (and git-reuse-status-buffer (git-find-status-buffer dir))
>                          (create-file-buffer (expand-file-name "*git-status*" dir)))))
>          (switch-to-buffer buffer)
Alexandre Julliard· Nov 25, 2012, 09:06 UTC · re: Junio C Hamano · lore

Re: [PATCH] emacs: make 'git-status' work with separate git dirs

Junio C Hamano <gitster@pobox.com> writes:
Show 22 quoted lines
> Enrico Scholz <enrico.scholz@sigma-chemnitz.de> writes:
>
>> when trying 'M-x git-status' in a submodule created with recent (1.7.5+)
>> git, the command fails with
>>
>> | ... is not a git working tree
>>
>> This is caused by creating submodules with '--separate-git-dir' but
>> still checking for a working tree by testing for a '.git' directory.
>>
>> The patch fixes this by relaxing the existing detection a little bit.
>>
>> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
>> ---
>
> This script already relies on the assumption that nobody sane would
> create a directory named ".git" that is not a git repository, and
> this loosens the assumption that nobody would create a file named
> ".git", either.  So I would think it is a sane thing to do, but just
> in case if the area expert has better ideas, I am forwarding it.
>
> Ack?
Sure, that's fine.
-- 
Alexandre Julliard
julliard@winehq.org
Junio C Hamano· Nov 26, 2012, 23:30 UTC · re: Alexandre Julliard · lore

Re: [PATCH] emacs: make 'git-status' work with separate git dirs

Alexandre Julliard <julliard@winehq.org> writes:
Show 26 quoted lines
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Enrico Scholz <enrico.scholz@sigma-chemnitz.de> writes:
>>
>>> when trying 'M-x git-status' in a submodule created with recent (1.7.5+)
>>> git, the command fails with
>>>
>>> | ... is not a git working tree
>>>
>>> This is caused by creating submodules with '--separate-git-dir' but
>>> still checking for a working tree by testing for a '.git' directory.
>>>
>>> The patch fixes this by relaxing the existing detection a little bit.
>>>
>>> Signed-off-by: Enrico Scholz <enrico.scholz@sigma-chemnitz.de>
>>> ---
>>
>> This script already relies on the assumption that nobody sane would
>> create a directory named ".git" that is not a git repository, and
>> this loosens the assumption that nobody would create a file named
>> ".git", either.  So I would think it is a sane thing to do, but just
>> in case if the area expert has better ideas, I am forwarding it.
>>
>> Ack?
>
> Sure, that's fine.
Thanks, both.  Applied.

← back to recent threads