emacs-orgmode
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[O] Bug: org-git-link.el fails for file in $HOME but not under Git [9.0.


From: Chunyang Xu
Subject: [O] Bug: org-git-link.el fails for file in $HOME but not under Git [9.0.7 (release_9.0.7-493-g82a503 @ /Users/xcy/src/org-mode/lisp/)]
Date: Mon, 29 May 2017 17:27:32 +0800

Hi,

After loading org-git-link.el, 'C-c l' ('org-store-link') fails for file
in $HOME but not under Git, such as "~/foo.c". The following is contents
of the *Backtrace* buffer while the error happens. I have attached a
patch to fix this issue.

    Debugger entered--Lisp error: (wrong-type-argument stringp nil)
      directory-file-name(nil)
      (file-name-directory (directory-file-name dirpath))
      (let ((dirname (file-name-directory (directory-file-name dirpath))) 
(basename (file-name-nondirectory (directory-file-name dirpath)))) (list 
dirname basename))
      org-git-split-dirpath(nil)
      (let ((dirlist (org-git-split-dirpath dir))) (if (string= (nth 1 dirlist) 
"") (progn (throw (quote toplevel) nil))) (setq dir (nth 0 dirlist) relpath 
(concat (file-name-as-directory (nth 1 dirlist)) relpath)))
      (while (not (file-exists-p (expand-file-name ".git" dir))) (let ((dirlist 
(org-git-split-dirpath dir))) (if (string= (nth 1 dirlist) "") (progn (throw 
(quote toplevel) nil))) (setq dir (nth 0 dirlist) relpath (concat 
(file-name-as-directory (nth 1 dirlist)) relpath))))
      (catch (quote toplevel) (while (not (file-exists-p (expand-file-name 
".git" dir))) (let ((dirlist (org-git-split-dirpath dir))) (if (string= (nth 1 
dirlist) "") (progn (throw (quote toplevel) nil))) (setq dir (nth 0 dirlist) 
relpath (concat (file-name-as-directory (nth 1 dirlist)) relpath)))) (list 
(expand-file-name ".git" dir) relpath))
      (let ((dir (file-name-directory path)) (relpath (file-name-nondirectory 
path))) (catch (quote toplevel) (while (not (file-exists-p (expand-file-name 
".git" dir))) (let ((dirlist (org-git-split-dirpath dir))) (if (string= (nth 1 
dirlist) "") (progn (throw (quote toplevel) nil))) (setq dir (nth 0 dirlist) 
relpath (concat (file-name-as-directory (nth 1 dirlist)) relpath)))) (list 
(expand-file-name ".git" dir) relpath)))
      org-git-gitrepos-p("~/foo.c")
      (if (org-git-gitrepos-p file) (progn (org-store-link-props :type "git" 
:link (org-git-create-git-link file line))))
      (let ((file (abbreviate-file-name (buffer-file-name))) (line 
(line-number-at-pos))) (if (org-git-gitrepos-p file) (progn 
(org-store-link-props :type "git" :link (org-git-create-git-link file line)))))
      (progn (let ((file (abbreviate-file-name (buffer-file-name))) (line 
(line-number-at-pos))) (if (org-git-gitrepos-p file) (progn 
(org-store-link-props :type "git" :link (org-git-create-git-link file line))))))
      (if (buffer-file-name) (progn (let ((file (abbreviate-file-name 
(buffer-file-name))) (line (line-number-at-pos))) (if (org-git-gitrepos-p file) 
(progn (org-store-link-props :type "git" :link (org-git-create-git-link file 
line)))))))
      org-git-store-link()
      #[257 "\300. \205\f..B\211\262.\207" [nil] 4 "\n\n(fn 
F)"](org-git-store-link)
      mapcar(#[257 "\300. \205\f..B\211\262.\207" [nil] 4 "\n\n(fn F)"] 
(org-git-store-link org-rmail-store-link org-mhe-store-link org-irc-store-link 
org-info-store-link org-gnus-store-link org-docview-store-link 
org-bibtex-store-link org-bbdb-store-link org-w3m-store-link 
org-notmuch-search-store-link org-notmuch-store-link org-eww-store-link 
org-man-store-link))
      org-store-link(nil)
      funcall-interactively(org-store-link nil)
      call-interactively(org-store-link nil nil)
      command-execute(org-store-link)

Emacs  : GNU Emacs 25.2.1 (x86_64-apple-darwin16.4.0, Carbon Version 157 AppKit 
1504.81)
 of 2017-04-26
Package: Org mode version 9.0.7 (release_9.0.7-493-g82a503 @ 
/Users/xcy/src/org-mode/lisp/)

>From 15a25f5dba882aa913b12ae42fa89874b3cd8a0d Mon Sep 17 00:00:00 2001
From: Chunyang Xu <address@hidden>
Date: Mon, 29 May 2017 17:03:24 +0800
Subject: [PATCH] org-git-link.el: Fix `org-git-find-gitdir'

* contrib/lisp/org-git-link.el (org-git-find-gitdir): Expand
abbreviated directory name.
---
 contrib/lisp/org-git-link.el | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/contrib/lisp/org-git-link.el b/contrib/lisp/org-git-link.el
index 65f25b294..0028daf9b 100644
--- a/contrib/lisp/org-git-link.el
+++ b/contrib/lisp/org-git-link.el
@@ -126,7 +126,7 @@
   the path. Example: (org-git-find-gitdir
   \"~/gitrepos/foo/bar.txt\") returns
   '(\"/home/user/gitrepos/.git\" \"foo/bar.txt\"). When not in a git 
repository, return nil."
-  (let ((dir (file-name-directory path))
+  (let ((dir (expand-file-name (file-name-directory path)))
         (relpath (file-name-nondirectory path)))
     (catch 'toplevel
       (while (not (file-exists-p (expand-file-name ".git" dir)))
-- 
2.13.0


reply via email to

[Prev in Thread] Current Thread [Next in Thread]