diff options
author | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-08-21 16:09:46 +0200 |
---|---|---|
committer | Stefan Monnier <monnier@iro.umontreal.ca> | 2010-08-21 16:09:46 +0200 |
commit | 537ffaf3c900034f9ff6ffc3cd70bf806e531066 (patch) | |
tree | 7f1e91b89f65471a40f94e1a9fad32f15e393f28 /lisp/vc | |
parent | 0deaf02ae1a4d8b0b69e1b3303424dfff4c3f8d1 (diff) | |
download | emacs-537ffaf3c900034f9ff6ffc3cd70bf806e531066.tar.gz emacs-537ffaf3c900034f9ff6ffc3cd70bf806e531066.tar.bz2 emacs-537ffaf3c900034f9ff6ffc3cd70bf806e531066.zip |
* lisp/vc/add-log.el (add-log-file-name): Don't get confused by symlinks.
Diffstat (limited to 'lisp/vc')
-rw-r--r-- | lisp/vc/add-log.el | 12 |
1 files changed, 11 insertions, 1 deletions
diff --git a/lisp/vc/add-log.el b/lisp/vc/add-log.el index cf391b2f9ac..23f1e33f181 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. |