Merge branch 'maint'

This commit is contained in:
Kyle Meyer 2017-05-20 19:00:45 -04:00
commit cca6e0dbc3
1 changed files with 16 additions and 12 deletions

View File

@ -73,8 +73,8 @@
(defun org-gitbare-open (str) (defun org-gitbare-open (str)
(let* ((strlist (org-git-split-string str)) (let* ((strlist (org-git-split-string str))
(gitdir (first strlist)) (gitdir (nth 0 strlist))
(object (second strlist))) (object (nth 1 strlist)))
(org-git-open-file-internal gitdir object))) (org-git-open-file-internal gitdir object)))
@ -96,14 +96,18 @@
(defun org-git-open (str) (defun org-git-open (str)
(let* ((strlist (org-git-split-string str)) (let* ((strlist (org-git-split-string str))
(filepath (first strlist)) (filepath (nth 0 strlist))
(commit (second strlist)) (commit (nth 1 strlist))
(line (third strlist)) (line (nth 2 strlist))
(dirlist (org-git-find-gitdir (file-truename filepath))) (dirlist (org-git-find-gitdir (file-truename filepath)))
(gitdir (first dirlist)) (gitdir (nth 0 dirlist))
(relpath (second dirlist))) (relpath (nth 1 dirlist)))
(org-git-open-file-internal gitdir (concat commit ":" relpath)) (org-git-open-file-internal gitdir (concat commit ":" relpath))
(when line (goto-line (string-to-int line))))) (when line
(save-restriction
(widen)
(goto-char (point-min))
(forward-line (1- (string-to-number line)))))))
;; Utility functions (file names etc) ;; Utility functions (file names etc)
@ -127,10 +131,10 @@
(catch 'toplevel (catch 'toplevel
(while (not (file-exists-p (expand-file-name ".git" dir))) (while (not (file-exists-p (expand-file-name ".git" dir)))
(let ((dirlist (org-git-split-dirpath dir))) (let ((dirlist (org-git-split-dirpath dir)))
(when (string= (second dirlist) "") ; at top level (when (string= (nth 1 dirlist) "") ; at top level
(throw 'toplevel nil)) (throw 'toplevel nil))
(setq dir (first dirlist) (setq dir (nth 0 dirlist)
relpath (concat (file-name-as-directory (second dirlist)) relpath)))) relpath (concat (file-name-as-directory (nth 1 dirlist)) relpath))))
(list (expand-file-name ".git" dir) relpath)))) (list (expand-file-name ".git" dir) relpath))))
@ -174,7 +178,7 @@ than two double colons, str2 and/or str3 may be set the empty string."
(defun org-git-create-git-link (file &optional line) (defun org-git-create-git-link (file &optional line)
"Create git link part to file at specific time" "Create git link part to file at specific time"
(interactive "FFile: ") (interactive "FFile: ")
(let* ((gitdir (first (org-git-find-gitdir (file-truename file)))) (let* ((gitdir (nth 0 (org-git-find-gitdir (file-truename file))))
(branchname (org-git-get-current-branch gitdir)) (branchname (org-git-get-current-branch gitdir))
(timestring (format-time-string "%Y-%m-%d" (current-time)))) (timestring (format-time-string "%Y-%m-%d" (current-time))))
(concat "git:" file "::" (org-git-create-searchstring branchname timestring) (concat "git:" file "::" (org-git-create-searchstring branchname timestring)