unofficial mirror of bug-gnu-emacs@gnu.org 
 help / color / mirror / code / Atom feed
From: Spencer Baugh <sbaugh@janestreet.com>
To: 64088@debbugs.gnu.org
Subject: bug#64088: [PATCH] Make project-root for vc projects return an absolute path
Date: Thu, 15 Jun 2023 16:48:05 -0400	[thread overview]
Message-ID: <ierttv8fo56.fsf@janestreet.com> (raw)

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

Tags: patch


Before this, if a vc project was in the user's home directory,
project-root would be "~/some/path".  This violates the spec of
project-root, which requires an absolute path.  One concrete bug
caused by this is that (project-forget-project "~/some/path") would
work but (project-forget-project "/home/user/some/path") would not.

I ran into this while trying to use file-notify to automatically
discover and forget projects.  file-notify returns truly absolute paths,
so I ran into the aforementioned concrete bug.

In GNU Emacs 29.0.90 (build 8, x86_64-pc-linux-gnu, X toolkit, cairo
 version 1.15.12, Xaw scroll bars) of 2023-06-04 built on
 igm-qws-u22796a
Repository revision: 11d76029db5f0d9e016f247aac24dd430b729c2a
Repository branch: emacs-29
Windowing system distributor 'The X.Org Foundation', version 11.0.12011000
System Description: CentOS Linux 7 (Core)

Configured using:
 'configure --with-x-toolkit=lucid --with-gif=ifavailable'


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-Make-project-root-for-vc-projects-return-an-absolute.patch --]
[-- Type: text/patch, Size: 1356 bytes --]

From 2c3ed85f857759458130a7b707d9b6f4d2c1ef20 Mon Sep 17 00:00:00 2001
From: Spencer Baugh <sbaugh@janestreet.com>
Date: Thu, 15 Jun 2023 16:45:48 -0400
Subject: [PATCH] Make project-root for vc projects return an absolute path

Before this, if a vc project was in the user's home directory,
project-root would be "~/some/path".  This violates the spec of
project-root, which requires an absolute path.  One concrete bug
caused by this is that (project-forget-project "~/some/path") would
work but (project-forget-project "/home/user/some/path") would not.

* lisp/progmodes/project.el (project-try-vc): Expand root directory
before returning project.
---
 lisp/progmodes/project.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lisp/progmodes/project.el b/lisp/progmodes/project.el
index 2cffc1c0669..72cdb94bce4 100644
--- a/lisp/progmodes/project.el
+++ b/lisp/progmodes/project.el
@@ -689,7 +689,7 @@ project-try-vc
           (let* ((parent (file-name-directory (directory-file-name root))))
             (setq root (vc-call-backend 'Git 'root parent))))
         (when root
-          (setq project (list 'vc backend root))
+          (setq project (list 'vc backend (expand-file-name root)))
           ;; FIXME: Cache for a shorter time.
           (vc-file-setprop dir 'project-vc project)
           project))))
-- 
2.39.3


             reply	other threads:[~2023-06-15 20:48 UTC|newest]

Thread overview: 13+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-06-15 20:48 Spencer Baugh [this message]
2023-06-16  5:52 ` bug#64088: [PATCH] Make project-root for vc projects return an absolute path Eli Zaretskii
2023-06-17  2:43   ` Dmitry Gutov
2023-06-17  6:25     ` Eli Zaretskii
2023-06-18  0:43       ` Dmitry Gutov
2023-06-17  2:47 ` Dmitry Gutov
2023-06-27 20:01   ` Spencer Baugh
2023-07-10  2:17     ` Dmitry Gutov
2023-07-10 23:45       ` Spencer Baugh
2023-08-12  0:45         ` Dmitry Gutov
2023-08-19 12:31           ` sbaugh
2023-08-19 12:57             ` sbaugh
2023-08-23  0:24               ` Dmitry Gutov

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

  List information: https://www.gnu.org/software/emacs/

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

  git send-email \
    --in-reply-to=ierttv8fo56.fsf@janestreet.com \
    --to=sbaugh@janestreet.com \
    --cc=64088@debbugs.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 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).