aboutsummaryrefslogtreecommitdiffstats
path: root/lisp/vc/add-log.el
diff options
context:
space:
mode:
authorStefan Monnier <[email protected]>2010-08-21 16:09:46 +0200
committerStefan Monnier <[email protected]>2010-08-21 16:09:46 +0200
commit537ffaf3c900034f9ff6ffc3cd70bf806e531066 (patch)
tree7f1e91b89f65471a40f94e1a9fad32f15e393f28 /lisp/vc/add-log.el
parent0deaf02ae1a4d8b0b69e1b3303424dfff4c3f8d1 (diff)
* lisp/vc/add-log.el (add-log-file-name): Don't get confused by symlinks.
Diffstat (limited to 'lisp/vc/add-log.el')
-rw-r--r--lisp/vc/add-log.el12
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el
index cf391b2f9a..23f1e33f18 100644
--- a/lisp/vc/add-log.el
+++ b/lisp/vc/add-log.el
@@ -755,7 +755,17 @@ Optional arg BUFFER-FILE overrides `buffer-file-name'."
(if add-log-file-name-function
(funcall add-log-file-name-function buffer-file)
(setq buffer-file
- (file-relative-name buffer-file (file-name-directory log-file)))
+ (let* ((dir (file-name-directory log-file))
+ (rel (file-relative-name buffer-file dir)))
+ ;; Sometimes with symlinks, the two buffers may have names that
+ ;; appear to belong to different directory trees. So check the
+ ;; file-truenames, to see if we get a better result.
+ (if (not (string-match "\\`\\.\\./" rel))
+ rel
+ (let ((new (file-relative-name (file-truename buffer-file)
+ (file-truename dir))))
+ (if (< (length new) (length rel))
+ new rel)))))
;; If we have a backup file, it's presumably because we're
;; comparing old and new versions (e.g. for deleted
;; functions) and we'll want to use the original name.