(switch-to-stgit-buffer (git-get-top-dir dir))
(stgit-reload))
+(defun stgit-assert-mode ()
+ "Signal an error if not in an StGit buffer."
+ (assert (derived-mode-p 'stgit-mode) nil "Not an StGit buffer"))
+
(unless (fboundp 'git-get-top-dir)
(defun git-get-top-dir (dir)
"Retrieve the top-level directory of a git tree."
(defun stgit-reload ()
"Update the contents of the StGit buffer."
(interactive)
+ (stgit-assert-mode)
(let ((inhibit-read-only t)
(curline (line-number-at-pos))
(curpatch (stgit-patch-name-at-point))
Non-interactively, operate on PATCHES, and collapse instead of
expand if COLLAPSE is not nil."
(interactive (list (stgit-patches-marked-or-at-point)))
+ (stgit-assert-mode)
(let ((patches-diff (funcall (if collapse #'intersection #'set-difference)
patches stgit-expanded-patches)))
(setq stgit-expanded-patches
See also `stgit-expand'."
(interactive (list (stgit-patches-marked-or-at-point)))
+ (stgit-assert-mode)
(stgit-expand patches t))
(defun stgit-select-patch ()
With point on a file, open the associated file. Opens the target
file for (applied) copies and renames."
(interactive)
+ (stgit-assert-mode)
(case (get-text-property (point) 'entry-type)
('patch
(stgit-select-patch))
(defun stgit-find-file-other-window ()
"Open file at point in other window"
(interactive)
+ (stgit-assert-mode)
(stgit-find-file t))
(defun stgit-find-file-merge ()
"Open file at point and merge it using `smerge-ediff'."
(interactive)
+ (stgit-assert-mode)
(stgit-find-file t)
(smerge-ediff))
(defun stgit-quit ()
"Hide the stgit buffer."
(interactive)
+ (stgit-assert-mode)
(bury-buffer))
(defun stgit-git-status ()
"Show status using `git-status'."
(interactive)
+ (stgit-assert-mode)
(unless (fboundp 'git-status)
(error "The stgit-git-status command requires git-status"))
(let ((dir default-directory))
(defun stgit-next-line (&optional arg)
"Move cursor vertically down ARG lines"
(interactive "p")
+ (stgit-assert-mode)
(next-line arg)
(move-to-column (stgit-goal-column)))
(defun stgit-previous-line (&optional arg)
"Move cursor vertically up ARG lines"
(interactive "p")
+ (stgit-assert-mode)
(previous-line arg)
(move-to-column (stgit-goal-column)))
(defun stgit-next-patch (&optional arg)
"Move cursor down ARG patches."
(interactive "p")
+ (stgit-assert-mode)
(ewoc-goto-next stgit-ewoc (or arg 1))
(move-to-column goal-column))
(defun stgit-previous-patch (&optional arg)
"Move cursor up ARG patches."
(interactive "p")
+ (stgit-assert-mode)
(ewoc-goto-prev stgit-ewoc (or arg 1))
(move-to-column goal-column))
(defun stgit-init ()
"Run stg init."
(interactive)
+ (stgit-assert-mode)
(stgit-capture-output nil
(stgit-run "init"))
(stgit-reload))
(defun stgit-mark ()
"Mark the patch under point."
(interactive)
+ (stgit-assert-mode)
(let* ((node (ewoc-locate stgit-ewoc))
(patch (ewoc-data node))
(name (stgit-patch-name patch)))
(defun stgit-unmark-up ()
"Remove mark from the patch on the previous line."
(interactive)
+ (stgit-assert-mode)
(stgit-previous-patch)
(let* ((node (ewoc-locate stgit-ewoc))
(patch (ewoc-data node)))
(defun stgit-unmark-down ()
"Remove mark from the patch on the current line."
(interactive)
+ (stgit-assert-mode)
(let* ((node (ewoc-locate stgit-ewoc))
(patch (ewoc-data node)))
(stgit-remove-mark (stgit-patch-name patch))
(interactive (list
(read-string "Patch name: "
(symbol-name (stgit-patch-name-at-point t t)))))
+ (stgit-assert-mode)
(let ((old-patchsym (stgit-patch-name-at-point t t)))
(stgit-capture-output nil
(stgit-run "rename" old-patchsym name))
With a prefix argument, repair the StGit metadata if the branch
was modified with git commands (`stgit-repair')."
(interactive "P")
+ (stgit-assert-mode)
(if repair
(stgit-repair)
(stgit-reload)))
(defun stgit-repair ()
"Run stg repair."
(interactive)
+ (stgit-assert-mode)
(stgit-capture-output nil
(stgit-run "repair"))
(stgit-reload))
"Switch to branch BRANCH."
(interactive (list (completing-read "Switch to branch: "
(stgit-available-branches))))
+ (stgit-assert-mode)
(stgit-capture-output nil (stgit-run "branch" "--" branch))
(stgit-reload))
"Rebase to NEW-BASE."
(interactive (list (completing-read "Rebase to: "
(stgit-available-refs t))))
+ (stgit-assert-mode)
(stgit-capture-output nil (stgit-run "rebase" new-base))
(stgit-reload))
Interactively, the prefix argument is used as COUNT.
A negative COUNT will uncommit instead."
(interactive "p")
+ (stgit-assert-mode)
(if (< count 0)
(stgit-uncommit (- count))
(stgit-capture-output nil (stgit-run "commit" "-n" count))
Interactively, the prefix argument is used as COUNT.
A negative COUNT will commit instead."
(interactive "p")
+ (stgit-assert-mode)
(if (< count 0)
(stgit-commit (- count))
(stgit-capture-output nil (stgit-run "uncommit" "-n" count))
"Revert the file at point, which must be in the index or the
working tree."
(interactive)
+ (stgit-assert-mode)
(let* ((patched-file (or (stgit-patched-file-at-point)
(error "No file on the current line")))
(patch-name (stgit-patch-name-at-point))
"Revert the change at point, which must be the index, the work
tree, or a single change in either."
(interactive)
+ (stgit-assert-mode)
(let ((patched-file (stgit-patched-file-at-point)))
(if patched-file
(stgit-revert-file)
(defun stgit-resolve-file ()
"Resolve conflict in the file at point."
(interactive)
+ (stgit-assert-mode)
(let* ((patched-file (stgit-patched-file-at-point))
(patch (stgit-patch-at-point))
(patch-name (and patch (stgit-patch-name patch)))
"Push the first unapplied patch.
With numeric prefix argument, push that many patches."
(interactive "p")
+ (stgit-assert-mode)
(stgit-capture-output nil (stgit-run "push" "-n" npatches))
(stgit-reload)
(stgit-refresh-git-status))
"Pop the topmost applied patch.
With numeric prefix argument, pop that many patches."
(interactive "p")
+ (stgit-assert-mode)
(stgit-capture-output nil (stgit-run "pop" "-n" npatches))
(stgit-reload)
(stgit-refresh-git-status))
(defun stgit-push-or-pop ()
"Push or pop the patch on the current line."
(interactive)
+ (stgit-assert-mode)
(let ((patchsym (stgit-patch-name-at-point t t))
(applied (stgit-applied-at-point-p)))
(stgit-capture-output nil
(defun stgit-goto ()
"Go to the patch on the current line."
(interactive)
+ (stgit-assert-mode)
(let ((patchsym (stgit-patch-name-at-point t)))
(stgit-capture-output nil
(stgit-run "goto" patchsym))
"")
name)
(interactive "p")
+ (stgit-assert-mode)
(stgit-show-patch ,diff-arg ignore-whitespace)))
(stgit-define-diff stgit-diff
file ended up. You can then jump to the file with \
\\[exchange-point-and-mark]."
(interactive)
+ (stgit-assert-mode)
(let* ((patched-file (or (stgit-patched-file-at-point)
(error "No file on the current line")))
(patched-status (stgit-file-status patched-file)))
file ended up. You can then jump to the file with \
\\[exchange-point-and-mark]."
(interactive)
+ (stgit-assert-mode)
(if (stgit-patched-file-at-point)
(stgit-file-toggle-index)
(let ((patch-name (stgit-patch-name-at-point)))
(defun stgit-edit ()
"Edit the patch on the current line."
(interactive)
+ (stgit-assert-mode)
(let ((patchsym (stgit-patch-name-at-point t t))
(edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
With a prefix argument, include a \"Signed-off-by:\" line at the
end of the patch."
(interactive "P")
+ (stgit-assert-mode)
(let ((edit-buf (get-buffer-create "*StGit edit*"))
(dir default-directory))
(log-edit 'stgit-confirm-new t nil edit-buf)
This works just like running `stgit-new' followed by `stgit-refresh'."
(interactive "P")
+ (stgit-assert-mode)
(stgit-new add-sign t))
(defun stgit-create-patch-name (description)
the work tree and index."
(interactive (list (stgit-patches-marked-or-at-point)
current-prefix-arg))
+ (stgit-assert-mode)
(unless patchsyms
(error "No patches to delete"))
(when (memq :index patchsyms)
Interactively, move the marked patches to where the point is."
(interactive (list stgit-marked-patches
(stgit-move-patches-target)))
+ (stgit-assert-mode)
(unless patchsyms
(error "Need at least one patch to move"))
one patch, which will occupy the same spot in the series as the
deepest patch had before the squash."
(interactive (list stgit-marked-patches))
+ (stgit-assert-mode)
(when (< (length patchsyms) 2)
(error "Need at least two patches to squash"))
(let ((stgit-buffer (current-buffer))
See also `stgit-redo'."
(interactive "P")
+ (stgit-assert-mode)
(stgit-capture-output nil
(if arg
(stgit-run "undo" "--hard")
See also `stgit-undo'."
(interactive "P")
+ (stgit-assert-mode)
(stgit-capture-output nil
(if arg
(stgit-run "redo" "--hard")
With prefix argument, refresh the marked patch or the patch under point."
(interactive "P")
+ (stgit-assert-mode)
(let ((patchargs (if arg
(let ((patches (stgit-patches-marked-or-at-point)))
(cond ((null patches)
`stgit-show-worktree-mode' controls where on screen the index and
work tree will show up."
(interactive)
+ (stgit-assert-mode)
(setq stgit-show-worktree
(if (numberp arg)
(> arg 0)
Use \\[stgit-toggle-worktree] to show the work tree."
(interactive)
+ (stgit-assert-mode)
(setq stgit-show-ignored
(if (numberp arg)
(> arg 0)
Use \\[stgit-toggle-worktree] to show the work tree."
(interactive)
+ (stgit-assert-mode)
(setq stgit-show-unknown
(if (numberp arg)
(> arg 0)