unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
* bug#13866: [VC] ‘vc-git-root’ is too lax
@ 2013-03-04  9:50 Ludovic Courtès
  2013-03-04 10:56 ` Andreas Schwab
  2013-03-04 14:58 ` Stefan Monnier
  0 siblings, 2 replies; 6+ messages in thread
From: Ludovic Courtès @ 2013-03-04  9:50 UTC (permalink / raw)
  To: 13866

[-- Attachment #1: Type: text/plain, Size: 267 bytes --]

Hello,

‘vc-git-root’ as found in Emacs 24.2.1 is too lax: when called from a
non-Git directory under $HOME, it ends up returning ~/ because users
normally have a ~/.git directory holding a config file.

A better definition would be something like this:


[-- Attachment #2: Type: application/emacs-lisp, Size: 144 bytes --]

[-- Attachment #3: Type: text/plain, Size: 21 bytes --]


Thanks,
Ludo’.

^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#13866: [VC] ‘vc-git-root’ is too lax
  2013-03-04  9:50 bug#13866: [VC] ‘vc-git-root’ is too lax Ludovic Courtès
@ 2013-03-04 10:56 ` Andreas Schwab
  2013-03-04 13:16   ` Ludovic Courtès
  2013-03-04 14:58 ` Stefan Monnier
  1 sibling, 1 reply; 6+ messages in thread
From: Andreas Schwab @ 2013-03-04 10:56 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 13866

ludo@gnu.org (Ludovic Courtès) writes:

> ‘vc-git-root’ as found in Emacs 24.2.1 is too lax: when called from a
> non-Git directory under $HOME, it ends up returning ~/ because users
> normally have a ~/.git directory holding a config file.

Do they?  Who created it?

Andreas.

-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#13866: [VC] ‘vc-git-root’ is too lax
  2013-03-04 10:56 ` Andreas Schwab
@ 2013-03-04 13:16   ` Ludovic Courtès
  0 siblings, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2013-03-04 13:16 UTC (permalink / raw)
  To: Andreas Schwab; +Cc: 13866-done

Andreas Schwab <schwab@linux-m68k.org> skribis:

> ludo@gnu.org (Ludovic Courtès) writes:
>
>> ‘vc-git-root’ as found in Emacs 24.2.1 is too lax: when called from a
>> non-Git directory under $HOME, it ends up returning ~/ because users
>> normally have a ~/.git directory holding a config file.
>
> Do they?  Who created it?

I did, but now I realize that ~/.gitconfig is what matters nowadays (or
maybe ~/.git/config never mattered, even.)

Sorry for the noise.

Ludo’.





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#13866: [VC] ‘vc-git-root’ is too lax
  2013-03-04  9:50 bug#13866: [VC] ‘vc-git-root’ is too lax Ludovic Courtès
  2013-03-04 10:56 ` Andreas Schwab
@ 2013-03-04 14:58 ` Stefan Monnier
  2013-03-04 15:11   ` Christopher Schmidt
  2013-03-04 16:00   ` Ludovic Courtès
  1 sibling, 2 replies; 6+ messages in thread
From: Stefan Monnier @ 2013-03-04 14:58 UTC (permalink / raw)
  To: Ludovic Courtès; +Cc: 13866

> A better definition would be something like this:
> (defun vc-git-root (file)
>   (lexical-let ((root (vc-find-root file ".git")))
>     (and (file-in-directory-p root "objects")
>          root)))

Beside the fact that ~/.git is not the config directory, the above code
has some problems:

vc-git.el uses lexical-binding, so using lexical-let in it is a bad idea.
file-in-directory-p sounds completely wrong here.  You want to use
(file-directory-p (expand-file-name "objects" root)) instead.

And of course you could have used simply (vc-find-root file ".git/objects").


        Stefan





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#13866: [VC] ‘vc-git-root’ is too lax
  2013-03-04 14:58 ` Stefan Monnier
@ 2013-03-04 15:11   ` Christopher Schmidt
  2013-03-04 16:00   ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Christopher Schmidt @ 2013-03-04 15:11 UTC (permalink / raw)
  To: 13866

Stefan Monnier <monnier@iro.umontreal.ca> writes:
> And of course you could have used simply (vc-find-root file
> ".git/objects").

That is not right.  .git in a git root directory might be a regular
file.

        Christopher





^ permalink raw reply	[flat|nested] 6+ messages in thread

* bug#13866: [VC] ‘vc-git-root’ is too lax
  2013-03-04 14:58 ` Stefan Monnier
  2013-03-04 15:11   ` Christopher Schmidt
@ 2013-03-04 16:00   ` Ludovic Courtès
  1 sibling, 0 replies; 6+ messages in thread
From: Ludovic Courtès @ 2013-03-04 16:00 UTC (permalink / raw)
  To: Stefan Monnier; +Cc: 13866

Stefan Monnier <monnier@iro.umontreal.ca> skribis:

>> A better definition would be something like this:
>> (defun vc-git-root (file)
>>   (lexical-let ((root (vc-find-root file ".git")))
>>     (and (file-in-directory-p root "objects")
>>          root)))
>
> Beside the fact that ~/.git is not the config directory, the above code
> has some problems:
>
> vc-git.el uses lexical-binding, so using lexical-let in it is a bad idea.
> file-in-directory-p sounds completely wrong here.  You want to use
> (file-directory-p (expand-file-name "objects" root)) instead.
>
> And of course you could have used simply (vc-find-root file ".git/objects").

Indeed, point taken!

Ludo’.





^ permalink raw reply	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2013-03-04 16:00 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2013-03-04  9:50 bug#13866: [VC] ‘vc-git-root’ is too lax Ludovic Courtès
2013-03-04 10:56 ` Andreas Schwab
2013-03-04 13:16   ` Ludovic Courtès
2013-03-04 14:58 ` Stefan Monnier
2013-03-04 15:11   ` Christopher Schmidt
2013-03-04 16:00   ` Ludovic Courtès

Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).