[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Using different default-directory and relative paths in VC, Was: Re: bug
Using different default-directory and relative paths in VC, Was: Re: bug#21383
Mon, 7 Sep 2015 23:55:24 +0300
Mozilla/5.0 (X11; Linux x86_64; rv:40.0) Gecko/20100101 Thunderbird/40.0
On 09/07/2015 01:29 AM, Stefan Monnier wrote:
Does vc-status get a relative file name as input?
Currently, I don't think so. But that could be changed if needed.
b) how are you going to enforce it?.
By checking all callers?
That's an odd thing to do for an API. What if diff-hl calls vc-state
with an absolute path? Will it get a slap on the wrist?
(*) If we try to eliminate this duplication of info, we introduce
duplication of effort inside VC. Seems to be pointless complexity.
Clearly it's easy to get back the absolute file name with just
(expand-file-name <FILE>), and I don't see where we'd obviously get
duplication of efforts. So I'm not sure why you think it'd add complexity.
I was thinking that due to assuming that default-directory will have to
be bound to the root. But indeed, simply using the parent directory of
the file in question should work well enough. Although when a command is
passed a list of files, determining their common parent will require
What I do see as a problem is that it would require a careful
study&adjustment of the whole VC code. I'm not sure if the result would
be more complex or simpler, admittedly. I think it'd be about the same,
just with cleaner semantics.
Something like the below might work, but it'll need to be done in every
command, and some of them take a list of files; other ones take a
directory and a set of files too.
And we'll have to be on the lookout for commands that output relative
paths when passed relative paths as input (like 'find' does).
Note that if FILE is a relative name, (file-name-directory file) returns
an unsuitable value.
diff --git a/lisp/vc/vc-hooks.el b/lisp/vc/vc-hooks.el
index 3e6d2a9..e273c6d 100644
@@ -475,10 +475,12 @@ status of this file. Otherwise, the value
returned is one of:
;; FIXME: New (sub)states needed (?):
;; - `copied' and `moved' (might be handled by `removed' and `added')
(or (vc-file-getprop file 'vc-state)
- (when (> (length file) 0) ;Why?? --Stef
- (setq backend (or backend (vc-responsible-backend file)))
- (when backend
- (vc-state-refresh file backend)))))
+ (let ((default-directory (file-name-directory file))
+ (file (file-relative-name file)))
+ (when (> (length file) 0) ;Why?? --Stef
+ (setq backend (or backend (vc-responsible-backend file)))
+ (when backend
+ (vc-state-refresh file backend))))))
(defun vc-state-refresh (file backend)
"Quickly recompute the `state' of FILE."
- Using different default-directory and relative paths in VC, Was: Re: bug#21383,
Dmitry Gutov <=