From mboxrd@z Thu Jan 1 00:00:00 1970 From: Chunyang Xu Subject: 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 Message-ID: Mime-Version: 1.0 Content-Type: multipart/mixed; boundary="=-=-=" Return-path: Received: from eggs.gnu.org ([2001:4830:134:3::10]:43427) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1dFGxs-0005fU-0Y for emacs-orgmode@gnu.org; Mon, 29 May 2017 05:27:53 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1dFGxo-0005Or-Pg for emacs-orgmode@gnu.org; Mon, 29 May 2017 05:27:51 -0400 Received: from smtpbgsg2.qq.com ([54.254.200.128]:41141) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1dFGxo-0005KE-45 for emacs-orgmode@gnu.org; Mon, 29 May 2017 05:27:48 -0400 Received: from Chunyangs-MacBook-Air.local (unknown [114.236.192.129]) by esmtp4.qq.com (ESMTP) with SMTP id 0 for ; Mon, 29 May 2017 17:27:31 +0800 (CST) List-Id: "General discussions about Org-mode." List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: emacs-orgmode-bounces+geo-emacs-orgmode=m.gmane.org@gnu.org Sender: "Emacs-orgmode" To: emacs-orgmode@gnu.org --=-=-= Content-Type: text/plain Content-Transfer-Encoding: 8bit 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/) --=-=-= Content-Type: text/x-patch Content-Disposition: inline; filename=0001-org-git-link.el-Fix-org-git-find-gitdir.patch >From 15a25f5dba882aa913b12ae42fa89874b3cd8a0d Mon Sep 17 00:00:00 2001 From: Chunyang Xu 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 --=-=-=--