Browse Source

Update

master
10sr 6 years ago
parent
commit
c01a06944f
Signed by: 10sr GPG Key ID: 7BEC428194130EB2
1 changed files with 13 additions and 30 deletions
  1. +13
    -30
      emacs.el

+ 13
- 30
emacs.el View File

@@ -2366,8 +2366,12 @@ It also copy text overlays."
(cl-assert (member type (cl-assert (member type
'("commit" "tree"))) '("commit" "tree")))
(with-current-buffer buf (with-current-buffer buf
(unless (string= treeish
git-walktree-object-id)
(unless (and (string= treeish
git-walktree-object-id)
(or (string= committish
git-walktree-current-committish)
(eq committish
git-walktree-current-committish)))
(buffer-disable-undo) (buffer-disable-undo)
;; For running git command go back to repository root ;; For running git command go back to repository root
(cd git-walktree-repository-root) (cd git-walktree-repository-root)
@@ -2480,7 +2484,6 @@ Result will be inserted into current buffer."
)) ))
buf)) buf))


;; TODO: Fix name
(defun git-walktree--open-noselect-safe-path (committish &optional path) (defun git-walktree--open-noselect-safe-path (committish &optional path)
"Open git object of COMMITTISH:PATH. "Open git object of COMMITTISH:PATH.
If PATH not found in COMMITTISH tree, go up path and try again until found. If PATH not found in COMMITTISH tree, go up path and try again until found.
@@ -2499,7 +2502,7 @@ When PATH is omitted or nil, it is calculated from current file or directory."
(cl-assert (not (string-match "\\`/" path))) (cl-assert (not (string-match "\\`/" path)))
(cl-assert (not (string-match "/\\'" path))) (cl-assert (not (string-match "/\\'" path)))


(let ((obj nil))
(let ((obj (git-walktree--resolve-object committish path)))
(while (not obj) (while (not obj)
(setq path (setq path
(git-walktree--parent-directory path)) (git-walktree--parent-directory path))
@@ -2510,7 +2513,6 @@ When PATH is omitted or nil, it is calculated from current file or directory."
obj))) obj)))


;; TODO: Store view history ;; TODO: Store view history
;; TODO: Open current file or directory if available
(defun git-walktree--open-noselect (committish path object) (defun git-walktree--open-noselect (committish path object)
"Open git tree buffer of COMMITTISH. "Open git tree buffer of COMMITTISH.
When PATH was given and non-nil open that, otherwise open root tree. When PATH was given and non-nil open that, otherwise open root tree.
@@ -2568,8 +2570,6 @@ When PATH was given and non-nil open that, otherwise open root tree.
When OBJECT was given and non-nil, assume that is the object of COMMITTISH:PATH without When OBJECT was given and non-nil, assume that is the object of COMMITTISH:PATH without
checking it." checking it."
(interactive (list (magit-read-branch-or-commit "Revision: "))) (interactive (list (magit-read-branch-or-commit "Revision: ")))
;; (setq path (or path
;; (git-walktree--path-in-repository (directory-file-name default-directory))))
(switch-to-buffer (git-walktree--open-noselect committish path object))) (switch-to-buffer (git-walktree--open-noselect committish path object)))
(defalias 'git-walktree 'git-walktree-open) (defalias 'git-walktree 'git-walktree-open)


@@ -2659,7 +2659,6 @@ Returns property list like (:mode MODE :type TYPE :object OBJECT :file FILE)."
(interactive) (interactive)
(let ((info (git-walktree--parse-lstree-line (buffer-substring-no-properties (point-at-bol) (let ((info (git-walktree--parse-lstree-line (buffer-substring-no-properties (point-at-bol)
(point-at-eol))))) (point-at-eol)))))
;; TODO: Open committish when currently on committish like symbol
(if info (if info
(switch-to-buffer (switch-to-buffer
(if (string= (plist-get info (if (string= (plist-get info
@@ -2796,7 +2795,6 @@ When collection has just one element, return the first element without asking."
nil nil
t))) t)))


;; TODO: Fix to work on subdirectory
(defun git-walktree-parent-revision () (defun git-walktree-parent-revision ()
"Open parent revision of current path. "Open parent revision of current path.
If current path was not found in the parent revision try to go up path." If current path was not found in the parent revision try to go up path."
@@ -2813,18 +2811,10 @@ If current path was not found in the parent revision try to go up path."
(message "This revision has no parent revision") (message "This revision has no parent revision")
(let* ((parent (git-walktree--choose-committish "This revision has multiple parents. Which to open? (%s) " (let* ((parent (git-walktree--choose-committish "This revision has multiple parents. Which to open? (%s) "
parents)) parents))
(path git-walktree-current-path)
(obj (git-walktree--resolve-object parent path)))
(path git-walktree-current-path))
(cl-assert path) (cl-assert path)
(while (not obj)
(setq path
(git-walktree--parent-directory path))
(setq obj
(git-walktree--resolve-object parent path)))
(switch-to-buffer (git-walktree--open-noselect parent
path
obj))
))))
(switch-to-buffer (git-walktree--open-noselect-safe-path parent
path))))))


(defun git-walktree--parent-commitid (committish) (defun git-walktree--parent-commitid (committish)
"Return list of parent commits of COMMITTISH in sha1 string." "Return list of parent commits of COMMITTISH in sha1 string."
@@ -2851,17 +2841,10 @@ If current path was not found in the parent revision try to go up path."
(message "There are no known child revision") (message "There are no known child revision")
(let* ((child (git-walktree--choose-committish "There are multiple known childrens. Which to open? (%s)" (let* ((child (git-walktree--choose-committish "There are multiple known childrens. Which to open? (%s)"
children)) children))
(path git-walktree-current-path)
(obj (git-walktree--resolve-object child path)))
(path git-walktree-current-path))
(cl-assert path) (cl-assert path)
(while (not obj)
(setq path
(git-walktree--parent-directory path))
(setq obj
(git-walktree--resolve-object child path)))
(switch-to-buffer (git-walktree--open-noselect child
path
obj))))))
(switch-to-buffer (git-walktree--open-noselect-safe-path child
path))))))


(defvar git-walktree-mode-map (defvar git-walktree-mode-map
(let ((map (make-sparse-keymap))) (let ((map (make-sparse-keymap)))


Loading…
Cancel
Save