Skip to content

Commit

Permalink
Merge branch 'jb/initial-lock' [#2651]
Browse files Browse the repository at this point in the history
  • Loading branch information
tarsius committed May 12, 2016
2 parents db98d61 + 1942582 commit b2b1a18
Show file tree
Hide file tree
Showing 7 changed files with 225 additions and 59 deletions.
10 changes: 10 additions & 0 deletions Documentation/RelNotes/2.7.0.txt
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,16 @@ Changes since v2.6.2
displayed directly in the `magit-branch-popup', instead the subpopup
`magit-branch-config-popup' has to be used.

* Added new popup command `magit-log-buffer-file-popup'.

* Added new command `magit-diff-buffer-file' and new option
`magit-diff-buffer-file-locked'. The the value of the option is
non-nil, the default, then the command uses a dedicated buffer.

* Added new option `magit-log-buffer-file-locked'. When its value is
non-nil, the default, then `magit-log-buffer-file' uses a dedicated
buffer.

* Added new commands `magit-worktree-checkout',
`magit-worktree-branch', `magit-worktree-delete',
and `magit-worktree-status'.
Expand Down
35 changes: 33 additions & 2 deletions Documentation/magit.org
Original file line number Diff line number Diff line change
Expand Up @@ -1762,6 +1762,10 @@ The following related commands are not available from the popup.

Show log for the file visited in the current buffer.

Two additional commands that show the log for the file or blob that is
being visited in the current buffer exists, see [[*Minor mode for
buffers visiting files]].

*** Refreshing logs

The prefix command ~magit-log-refresh-popup~, on ~L~, can be used to
Expand Down Expand Up @@ -1989,6 +1993,10 @@ another buffer:

Show all diffs of a stash in a buffer.

Two additional commands that show the diff for the file or blob that
is being visited in the current buffer exists, see [[*Minor mode for
buffers visiting files]].

*** Refreshing diffs

The prefix command ~magit-diff-refresh-popup~, on ~D~, can be used to
Expand Down Expand Up @@ -4795,7 +4803,7 @@ buffers belonging to a Git repository. It should be enabled globally
using ~global-magit-file-mode~. Currently this mode only establishes a
few key bindings, but this might be extended in the future.

- User Option: global-magit-file-mode
- User Option: magit-file-mode

Whether to establish certain Magit key bindings in all file-visiting
buffers belonging to a Git repository. This establishes the
Expand All @@ -4820,19 +4828,42 @@ few key bindings, but this might be extended in the future.
This prefix command shows suffix commands along with the appropriate
infix arguments in a popup buffer. See [[*Initiating a commit]].

- Key: C-c M-g d, magit-diff-buffer-file-popup
- Key: C-c M-g D, magit-diff-buffer-file-popup

This prefix command shows the same suffix commands and infix
arguments in a popup buffer as ~magit-diff-popup~. But this variant
has to be called from a file-visiting buffer and the visited file
is automatically used in the popup to limit the diff to that file.

- Key: C-c M-g d, magit-diff-buffer-file

This command shows the diff for the file of blob that the current
buffer visits. Renames are followed when a prefix argument is used
or when ~--follow~ is part of ~magit-diff-arguments~.

- User Option: magit-diff-buffer-file-locked

This option controls whether ~magit-diff-buffer-file~ uses a decicated
buffer. See [[*Modes and Buffers]].

- Key: C-c M-g L, magit-log-buffer-file-popup

This prefix command shows the same suffix commands and infix
arguments in a popup buffer as ~magit-log-popup~. But this variant
has to be called from a file-visiting buffer and the visited file
is automatically used in the popup to limit the log to that file.

- Key: C-c M-g l, magit-log-buffer-file

This command shows the log for the file of blob that the current
buffer visits. Renames are followed when a prefix argument is used
or when ~--follow~ is part of ~magit-log-arguments~.

- User Option: magit-log-buffer-file-locked

This option controls whether ~magit-log-buffer-file~ uses a decicated
buffer. See [[*Modes and Buffers]].

- Key: C-c M-g b, magit-blame-popup

This prefix command shows the ~magit-blame~ suffix command along with
Expand Down
47 changes: 44 additions & 3 deletions Documentation/magit.texi
Original file line number Diff line number Diff line change
Expand Up @@ -2384,6 +2384,9 @@ Show commits in a branch that are not merged in the upstream branch.
Show log for the file visited in the current buffer.
@end table

Two additional commands that show the log for the file or blob that is
being visited in the current buffer exists, see @ref{Minor mode for buffers visiting files,Minor mode for buffers visiting files}.

@menu
* Refreshing logs::
* Log Buffer::
Expand Down Expand Up @@ -2718,6 +2721,9 @@ prefix argument, prompt for a commit.
Show all diffs of a stash in a buffer.
@end table

Two additional commands that show the diff for the file or blob that
is being visited in the current buffer exists, see @ref{Minor mode for buffers visiting files,Minor mode for buffers visiting files}.

@menu
* Refreshing diffs::
* Diff buffer::
Expand Down Expand Up @@ -6677,7 +6683,7 @@ buffers belonging to a Git repository. It should be enabled globally
using @code{global-magit-file-mode}. Currently this mode only establishes a
few key bindings, but this might be extended in the future.

@defopt global-magit-file-mode
@defopt magit-file-mode

Whether to establish certain Magit key bindings in all file-visiting
buffers belonging to a Git repository. This establishes the
Expand Down Expand Up @@ -6712,15 +6718,41 @@ Unstage all changes to the file being visited in the current buffer.
This prefix command shows suffix commands along with the appropriate
infix arguments in a popup buffer. See @ref{Initiating a commit,Initiating a commit}.

@kindex C-c M-g d
@kindex C-c M-g D
@cindex magit-diff-buffer-file-popup
@item @kbd{C-c M-g d} @tie{}@tie{}@tie{}@tie{}(@code{magit-diff-buffer-file-popup})
@item @kbd{C-c M-g D} @tie{}@tie{}@tie{}@tie{}(@code{magit-diff-buffer-file-popup})

This prefix command shows the same suffix commands and infix
arguments in a popup buffer as @code{magit-diff-popup}. But this variant
has to be called from a file-visiting buffer and the visited file
is automatically used in the popup to limit the diff to that file.

@kindex C-c M-g d
@cindex magit-diff-buffer-file
@item @kbd{C-c M-g d} @tie{}@tie{}@tie{}@tie{}(@code{magit-diff-buffer-file})

This command shows the diff for the file of blob that the current
buffer visits. Renames are followed when a prefix argument is used
or when @code{--follow} is part of @code{magit-diff-arguments}.

@end table

@defopt magit-diff-buffer-file-locked

This option controls whether @code{magit-diff-buffer-file} uses a decicated
buffer. See @ref{Modes and Buffers,Modes and Buffers}.
@end defopt

@table @asis
@kindex C-c M-g L
@cindex magit-log-buffer-file-popup
@item @kbd{C-c M-g L} @tie{}@tie{}@tie{}@tie{}(@code{magit-log-buffer-file-popup})

This prefix command shows the same suffix commands and infix
arguments in a popup buffer as @code{magit-log-popup}. But this variant
has to be called from a file-visiting buffer and the visited file
is automatically used in the popup to limit the log to that file.

@kindex C-c M-g l
@cindex magit-log-buffer-file
@item @kbd{C-c M-g l} @tie{}@tie{}@tie{}@tie{}(@code{magit-log-buffer-file})
Expand All @@ -6729,6 +6761,15 @@ This command shows the log for the file of blob that the current
buffer visits. Renames are followed when a prefix argument is used
or when @code{--follow} is part of @code{magit-log-arguments}.

@end table

@defopt magit-log-buffer-file-locked

This option controls whether @code{magit-log-buffer-file} uses a decicated
buffer. See @ref{Modes and Buffers,Modes and Buffers}.
@end defopt

@table @asis
@kindex C-c M-g b
@cindex magit-blame-popup
@item @kbd{C-c M-g b} @tie{}@tie{}@tie{}@tie{}(@code{magit-blame-popup})
Expand Down
34 changes: 29 additions & 5 deletions lisp/magit-diff.el
Original file line number Diff line number Diff line change
Expand Up @@ -171,6 +171,15 @@ many spaces. Otherwise, highlight neither."
:group 'magit-diff
:type 'boolean)

;;;; File Diff

(defcustom magit-diff-buffer-file-locked t
"Whether `magit-diff-buffer-file' uses a decicated buffer."
:package-version '(magit . "2.7.0")
:group 'magit-commands
:group 'magit-diff
:type 'boolean)

;;;; Revision Mode

(defgroup magit-revision nil
Expand Down Expand Up @@ -565,22 +574,22 @@ and https://debbugs.gnu.org/cgi/bugreport.cgi?bug=7847."
(magit-invoke-popup 'magit-diff-popup nil arg)))

;;;###autoload
(defun magit-diff-buffer-file-popup (arg)
"Popup console for diff commans.
(defun magit-diff-buffer-file-popup ()
"Popup console for diff commands.
This is a variant of `magit-diff-popup' which shows the same popup
but which limits the diff to the file being visited in the current
buffer."
(interactive "P")
(interactive)
(-if-let (file (magit-file-relative-name))
(let ((magit-diff-arguments
(magit-popup-import-file-args
(-if-let (buffer (magit-mode-get-buffer 'magit-diff-mode))
(with-current-buffer buffer
(nth 2 magit-refresh-args))
(nth 3 magit-refresh-args))
(default-value 'magit-diff-arguments))
(list file))))
(magit-invoke-popup 'magit-diff-popup nil arg))
(magit-invoke-popup 'magit-diff-popup nil nil))
(user-error "Buffer isn't visiting a file")))

(defun magit-diff-refresh-popup (arg)
Expand Down Expand Up @@ -778,6 +787,21 @@ be committed."
(defun magit-diff-while-amending (&optional args files)
(magit-diff-setup "HEAD^" (list "--cached") args files))

;;;###autoload
(defun magit-diff-buffer-file ()
"Show diff for the blob or file visited in the current buffer."
(interactive)
(-if-let (file (magit-file-relative-name))
(magit-mode-setup-internal #'magit-diff-mode
(list (or magit-buffer-refname
(magit-get-current-branch)
"HEAD")
nil
(cadr (magit-diff-arguments))
(list file))
magit-diff-buffer-file-locked)
(user-error "Buffer isn't visiting a file")))

;;;###autoload
(defun magit-diff-paths (a b)
"Show changes between any two files on disk."
Expand Down
57 changes: 44 additions & 13 deletions lisp/magit-log.el
Original file line number Diff line number Diff line change
Expand Up @@ -172,6 +172,15 @@ This is useful if you use really long branch names."
"Face for the date part of the log output."
:group 'magit-faces)

;;;; File Log

(defcustom magit-log-buffer-file-locked t
"Whether `magit-log-buffer-file' uses a decicated buffer."
:package-version '(magit . "2.7.0")
:group 'magit-commands
:group 'magit-log
:type 'boolean)

;;;; Select Mode

(defcustom magit-log-select-arguments '("-n256" "--decorate")
Expand Down Expand Up @@ -405,6 +414,25 @@ the upstream isn't ahead of the current branch) show."
(default-value 'magit-log-arguments))))
(magit-invoke-popup 'magit-log-popup nil arg)))

;;;###autoload
(defun magit-log-buffer-file-popup ()
"Popup console for log commands.
This is a variant of `magit-log-popup' which shows the same popup
but which limits the log to the file being visited in the current
buffer."
(interactive)
(-if-let (file (magit-file-relative-name))
(let ((magit-log-arguments
(magit-popup-import-file-args
(-if-let (buffer (magit-mode-get-buffer 'magit-log-mode))
(with-current-buffer buffer
(nth 2 magit-refresh-args))
(default-value 'magit-log-arguments))
(list file))))
(magit-invoke-popup 'magit-log-popup nil nil))
(user-error "Buffer isn't visiting a file")))

(defun magit-log-refresh-popup (arg)
"Popup console for changing log arguments in the current buffer."
(interactive "P")
Expand Down Expand Up @@ -573,19 +601,22 @@ With a prefix argument or when `--follow' is part of
(1- (line-number-at-pos (region-end))))
(list current-prefix-arg)))
(-if-let (file (magit-file-relative-name))
(magit-mode-setup #'magit-log-mode
(list (or magit-buffer-refname
(magit-get-current-branch) "HEAD"))
(let ((args (car (magit-log-arguments))))
(when (and follow (not (member "--follow" args)))
(push "--follow" args))
(when (and beg end)
(setq args (cons (format "-L%s,%s:%s" beg end file)
(cl-delete "-L" args :test
'string-prefix-p)))
(setq file nil))
args)
(and file (list file)))
(magit-mode-setup-internal
#'magit-log-mode
(list (list (or magit-buffer-refname
(magit-get-current-branch)
"HEAD"))
(let ((args (car (magit-log-arguments))))
(when (and follow (not (member "--follow" args)))
(push "--follow" args))
(when (and beg end)
(setq args (cons (format "-L%s,%s:%s" beg end file)
(cl-delete "-L" args :test
'string-prefix-p)))
(setq file nil))
args)
(and file (list file)))
magit-log-buffer-file-locked)
(user-error "Buffer isn't visiting a file"))
(magit-log-goto-same-commit))

Expand Down
Loading

0 comments on commit b2b1a18

Please sign in to comment.