Next: , Previous: , Up: Diffing   [Contents][Index]


5.4.2 Diff Buffer

These commands are available in diff buffers.

RET     (magit-diff-visit-file)

From a diff, visit the corresponding file at the appropriate position.

If the diff shows changes in the worktree, the index, or HEAD, then visit the actual file. Otherwise, when the diff is about an older commit or a range, then visit the appropriate blob.

If point is on a removed line, then visit the blob for the first parent of the commit which removed that line, i.e. the last commit where that line still existed. Otherwise visit the blob for the commit whose changes are being shown.

Interactively, when the file or blob to be displayed is already being displayed in another window of the same frame, then just select that window and adjust point. Otherwise, or with a prefix argument, display the buffer in another window. The meaning of the prefix argument can be inverted or further modified using the option magit-display-file-buffer-function.

Non-interactively the optional OTHER-WINDOW argument is taken literally. DISPLAY-FN can be used to specify the display function explicitly, in which case OTHER-WINDOW is ignored.

The optional FORCE-WORKTREE means to force visiting the worktree version of the file. To do this interactively use the command magit-diff-visit-file-worktree instead.

User Option: magit-diff-visit-previous-blob

This option controls whether magit-diff-visit-file may visit the previous blob. When this is t and point is on a removed line in a diff for a committed change, then magit-diff-visit-file visits the blob from the last revision which still had that line.

Currently this is only supported for committed changes, for staged and unstaged changes magit-diff-visit-file always visits the file in the working tree.

C-<return>     (magit-diff-visit-file-worktree)

From a diff, visit the corresponding file at the appropriate position.

When the file is already being displayed in another window of the same frame, then just select that window and adjust point. With a prefix argument also display in another window.

The actual file in the worktree is visited. The positions in the hunk headers get less useful the "older" the changes are, and as a result, jumping to the appropriate position gets less reliable.

Also see magit-diff-visit-file, which visits the respective blob, unless the diff shows changes in the worktree, the index, or HEAD.

Command: magit-diff-visit-file-other-window

From a diff, visit the corresponding file at the appropriate position in another window.

C-c C-t     (magit-diff-trace-definition)

From a diff, show log for the definition at point.

C-c C-e     (magit-diff-edit-hunk-commit)

From a hunk, edit the respective commit and visit the file.

First visit the file being modified by the hunk at the correct location using magit-diff-visit-file. This actually visits a blob. When point is on a diff header, not within an individual hunk, then this visits the blob the first hunk is about.

Then invoke magit-edit-line-commit, which uses an interactive rebase to make the commit editable, or if that is not possible because the commit is not reachable from HEAD by checking out that commit directly. This also causes the actual worktree file to be visited.

Neither the blob nor the file buffer are killed when finishing the rebase. If that is undesirable, then it might be better to use magit-rebase-edit-command instead of this command.

j     (magit-jump-to-diffstat-or-diff)

Jump to the diffstat or diff. When point is on a file inside the diffstat section, then jump to the respective diff section. Otherwise, jump to the diffstat section or a child thereof.

SPC     (scroll-up)

Scroll text upward.

DEL     (scroll-down)

Scroll text downward.


Next: , Previous: , Up: Diffing   [Contents][Index]