emacs-orgmode@gnu.org archives
 help / color / mirror / code / Atom feed
From: Chunyang Xu <mail@xuchunyang.me>
To: emacs-orgmode@gnu.org
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	[thread overview]
Message-ID: <m2k2509fnf.fsf@xuchunyang.me> (raw)

[-- Attachment #1: Type: text/plain, Size: 3527 bytes --]

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.\x01.B\211\262.\207" [nil] 4 "\n\n(fn F)"](org-git-store-link)
      mapcar(#[257 "\300. \205\f.\x01.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/)


[-- Warning: decoded text below may be mangled, UTF-8 assumed --]
[-- Attachment #2: 0001-org-git-link.el-Fix-org-git-find-gitdir.patch --]
[-- Type: text/x-patch, Size: 1014 bytes --]

From 15a25f5dba882aa913b12ae42fa89874b3cd8a0d Mon Sep 17 00:00:00 2001
From: Chunyang Xu <mail@xuchunyang.me>
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	other threads:[~2017-05-29  9:27 UTC|newest]

Thread overview: 2+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-05-29  9:27 Chunyang Xu [this message]
2017-05-29 12:49 ` 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/)] Kyle Meyer

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: https://www.orgmode.org/

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=m2k2509fnf.fsf@xuchunyang.me \
    --to=mail@xuchunyang.me \
    --cc=emacs-orgmode@gnu.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.savannah.gnu.org/cgit/emacs/org-mode.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).