all messages for Emacs-related lists mirrored at yhetil.org
 help / color / mirror / code / Atom feed
From: Justin Bogner <mail@justinbogner.com>
To: emacs-devel@gnu.org
Subject: Re: [patch] vc-find-root with invert
Date: Mon, 21 Jul 2008 10:27:40 -0600	[thread overview]
Message-ID: <4884B8FC.9040301@justinbogner.com> (raw)
In-Reply-To: <20080705072126.GA936@tomas>

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

tomas@tuxteam.de wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> On Fri, Jul 04, 2008 at 03:52:48PM -0400, Stefan Monnier wrote:
>>>>> Here's a patch that fixes a bug I've noticed in vc-find-root. When called
>
> [...]
>
>>> I believe that it's for systems like CVS, where each subdirectory under
>>> version control has its own CVS directory.
>> Sorry, but that doesn't help me ;-(
>> Anyone has a more complete explanation?
>
> Reading the docstring, my guess would be: vc-find-root walks the dir
> tree up _until_ it finds WITNESS (as an evidence for the VC tree's root
> dir). Unless we have CVS or SVN or similar, where every subdir has
> WITNESS, so the root would be the last up-tree directory having WITNESS.
>
> But I might be off-by-one ;-)
>
> Regards
> - -- tomás
>

This is exactly correct, though in the current trunk there is a bug
such that the function does not behave like this. The patch causes it
to work as documented.

The changes are actually quite small, to demonstrate, the same patch
ignoring whitespace is attached, though the original should be applied
so that the indentation is correct.

[-- Attachment #2: findroot-ignorews.patch --]
[-- Type: text/x-diff, Size: 1723 bytes --]

diff --git a/lisp/ChangeLog b/lisp/ChangeLog
index cf0472e..aebc149 100644
--- a/lisp/ChangeLog
+++ b/lisp/ChangeLog
@@ -384,6 +384,11 @@
 	* textmodes/sgml-mode.el (sgml-font-lock-syntactic-keywords):
 	Use syntax-ppss on a position *before* the char we want to change.
 
+2008-07-04  Justin Bogner  <mail@justinbogner.com>
+
+	* vc-hooks.el (vc-find-root):
+	Find the directory when using invert, not the file itself.
+
 2008-07-04  Dan Nicolaescu  <dann@ics.uci.edu>
 
 	* vc-dir.el (vc-dir-query-replace-regexp): New function.
diff --git a/lisp/vc-hooks.el b/lisp/vc-hooks.el
index 2ccbdcc..0662961 100644
--- a/lisp/vc-hooks.el
+++ b/lisp/vc-hooks.el
@@ -327,6 +327,13 @@ The function walks up the directory tree from FILE looking for WITNESS.
 If WITNESS if not found, return nil, otherwise return the root.
 Optional arg INVERT non-nil reverses the sense of the check;
 the root is the last directory for which WITNESS *is* found."
+  (when (not (file-directory-p file))
+    (setq file (file-name-directory file)))
+  ;; In the invert case, we should return nil if WITNESS doesn't exist
+  ;; in the first place.
+  (if (and invert
+           (not (file-exists-p (expand-file-name witness file))))
+      nil
   ;; Represent /home/luser/foo as ~/foo so that we don't try to look for
   ;; witnesses in /home or in /.
   (setq file (abbreviate-file-name file))
@@ -359,7 +366,7 @@ the root is the last directory for which WITNESS *is* found."
     ;; (This occurs, for example, when placing dotfiles under RCS.)
     (when (and (not root) invert prev-file)
       (setq root prev-file))
-    root))
+      root)))
 
 ;; Access functions to file properties
 ;; (Properties should be _set_ using vc-file-setprop, but

  reply	other threads:[~2008-07-21 16:27 UTC|newest]

Thread overview: 15+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2008-07-04 17:24 [patch] vc-find-root with invert Justin Bogner
2008-07-04 18:02 ` Stefan Monnier
2008-07-04 18:06   ` Justin Bogner
2008-07-04 19:52     ` Stefan Monnier
2008-07-05  7:21       ` tomas
2008-07-21 16:27         ` Justin Bogner [this message]
2008-07-21 18:32           ` Stefan Monnier
2008-07-21 21:33             ` Justin Bogner
2008-07-21 22:00               ` David Kastrup
2008-07-21 22:23                 ` Justin Bogner
2008-07-21 23:02                   ` David Kastrup
2008-07-23  4:35                     ` Justin Bogner
2008-07-23 19:35                       ` Stefan Monnier
2008-07-22  2:56               ` Stefan Monnier
  -- strict thread matches above, loose matches on Subject: below --
2008-07-04 17:47 Justin Bogner

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=4884B8FC.9040301@justinbogner.com \
    --to=mail@justinbogner.com \
    --cc=emacs-devel@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this external index

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

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.