aboutsummaryrefslogtreecommitdiff
path: root/lisp/magit-files.el
AgeCommit message (Collapse)Author
2026-04-09magit-blob-mode: Also toggle buffer-read-only accordinglyJonas Bernoulli
Do this so we can remap `read-only-mode' to `magit-blob-mode' when the latter is enabled, to disable both modes together. The latter shadows bindings for `self-insert-command'.
2026-04-09Preserve read-only-mode in blob-visiting buffersJonas Bernoulli
Only make blob-visiting buffers read-only when they are first visited. Previously `buffer-read-only' was set to t whenever such a buffer was reverted (via `magit--blob-normal-mode'). Additionally set `read-only-mode--state' to the same value; otherwise `revert-buffer' would not actually restore `buffer-read-only' (via `revert-buffer-restore-read-only' on `revert-buffer-restore-functions'). Set `read-only-mode--state' manually because calling `read-only-mode' does not only set these two variables, it could also enable `view-mode', which would shadow all the bindings in `magit-blob-mode-map'. Beside `magit-find-file-noselect', `magit-ediff-stage' also has to set both variables if it needs to make the buffer temporarily editable.
2026-04-08magit-list-files: Never limit to subdirectoryJonas Bernoulli
Never limit the list of files to those in `default-directory' and always return paths relative to the top-level. This affects other `magit-*-files' functions and their callers. Some callers of these functions explicitly used `magit-with-toplevel' and we can stop doing that now. Other callers did not use that macro but should have done so. Among those, many were always called from the top-level, so this bug was theoretical in those cases. Others are more likely to be called from a subdirectory. There are no callers that actually need just the files from a subdirectory.
2026-03-30Support visiting anonymous blobsJonas Bernoulli
I.e., support visiting a blob via its blob oid without knowing a commit and tree path in which it can be found.
2026-03-29Use Cond-Let's when$Jonas Bernoulli
2026-03-29Make Cond-Let's when$ availableJonas Bernoulli
2026-03-28Fix typos in manual and docstringsJonas Bernoulli
2026-03-26magit-find-blob-hook: Add magit-blob-mode within definitionJonas Bernoulli
2026-03-26magit--get-blob-buffer: Use buffer-enable-undoJonas Bernoulli
2026-03-26magit--get-blob-buffer: Enable undo when creating bufferJonas Bernoulli
In non-hidden file-visiting buffers undo is enabled, even if they are read-only. Do the same for our volatile blob-visiting buffers. Re #5543.
2026-03-25magit--blob-normal-mode: Fix the new font-lock kludgeJonas Bernoulli
Turns out `font-lock-mode' is called twice for the volatile blob buffer we are dealing with here. Both calls need the `buffer-name' kludge, as implemented by the advice we add here, else the second call turns `font-lock-mode' off again. Both calls to `font-lock-mode' are both triggered by `normal-mode'; via `after-change-major-mode-hook' and `set-auto-mode'. Change the advice to no longer remove itself, once it dealt with the buffer, for which it was added. Instead only remove the advice using `unwind-protect' (that was already in place, but until now only intended to clean up in case of an error). Re #5543.
2026-03-25magit--abbrev-if-oid: Renamed functionJonas Bernoulli
2026-03-25magit--refresh-blob-buffer: Avoid magit--blob-normal-mode callsJonas Bernoulli
Only call `magit--blob-normal-mode' if the blob oid changed or the refresh is forced.
2026-03-25magit--blob-normal-mode: Ensure font-lock is enabled for hidden buffersJonas Bernoulli
`font-lock-mode' contains a hardcoded condition that prevents it from being enabled in hidden buffers. Use a fake `buffer-name' to trick it into believing the buffer is not hidden. Closes #5543.
2026-03-19Add syntax highlighting to diffsJonas Bernoulli
2026-03-19Eventually remove volatile blob buffersJonas Bernoulli
2026-03-19magit-buffer--volatile: Make permanently buffer-localJonas Bernoulli
2026-02-12magit-bury{,-or-kill-}buffer: Offer to quit related Ediff sessionJonas Bernoulli
Killing a buffer, which is used by an Ediff session, renders that unusable, so we prevent that. We could just refuse to kill the buffer and be done with it, but since the user indicated that they want to quit something, instead offer to quit the whole Ediff session. Do not first check whether the buffer would only be buried as that would also make little sense in an Ediff context. (And if the user really wants to bury the buffer, they can use `bury-buffer'.)
2026-02-12magit--get-blob-buffer: New functionJonas Bernoulli
2026-02-11magit-find-file-index-noselect: DeprecateJonas Bernoulli
2026-02-11magit-find-file-noselect: Avoid misleading error messageJonas Bernoulli
Until the previous commit, using nil as REV would have resulted in an error "FILE is not inside a Git repository", regardless of whether that was actually true or not. Add a fall-through "Unexpected error" in case some other unexpected issue manifests itself.
2026-02-11magit-find-file-noselect: Accept nil as synonym for "{worktree}"Jonas Bernoulli
Eventually we should instead explicitly signal an error.
2026-02-11magit-find-file-noselect: Tweak error messagesJonas Bernoulli
2026-02-11magit-find-file-noselect: Trigger point restoration from hereJonas Bernoulli
Commands, which previously called `magit-find-file--internal' to do this, can now use `magit-find-file-noselect' directly. Deprecate the former.
2026-02-11magit-find-file--restore-position: Fix and refactorJonas Bernoulli
- Limit arguments to those identifying the old position and make them mandatory. - Add `magit-find-file--position' to be used by callers to determine these position arguments. - The buffer in which the position is to be restored now has to be current. - Checking whether the old position is actually from another version of the same file, is only necessary for one of the callers, so make it do that itself. - Implement all the revision pairings explicitly. This fixes some bugs concerning combinations that were previously not handled. - Support restoring the position from one index blob in another index blob. This uses "git diff-pairs", which `magit-diff-visit--offset' learned to handle in the previous commit. This command was added in Git v2.50.0, for older versions this just returns the LINE argument verbatim.
2026-02-11magit-diff-visit--offset: Improve function signatureJonas Bernoulli
2026-02-11magit-find-file--restore-position: Remove unnecessary checkJonas Bernoulli
`line' is always non-nil.
2026-02-11magit--revert-blob-buffer: Do not set local variablesJonas Bernoulli
Leave it to `magit--revert-blob-buffer', which was the plan all along, but then I forgot about it, when cleaning this up before committing.
2026-02-04magit--revert-blob-buffer: Do not error on "{index}"Jonas Bernoulli
(Refresh avoidance and position restoration still need work.)
2026-02-04magit-find-file-noselect: Fix typoJonas Bernoulli
2026-02-04magit-find-file-read-args: CosmeticsJonas Bernoulli
2026-02-03Restore position after reverting blob bufferJonas Bernoulli
2026-02-03Set new magit-blob-oid in blob buffers and only refresh if necessaryJonas Bernoulli
2026-02-03Set magit-buffer-revision-oid in blob buffersJonas Bernoulli
Take advantage of that to potentially avoid some unnecessary work when restoring point in such a buffer.
2026-02-03magit-find-file--restore-position: Spin out new functionJonas Bernoulli
2026-02-03magit--refresh-blob-buffer: Spin out new functionJonas Bernoulli
2026-02-03magit--blob-normal-mode: Run magit-find-blob-hookJonas Bernoulli
I.e., run both when first finding the file and when reverting, as is done for regular files too (see `after-find-file').
2026-02-03magit--blob-normal-mode: Spin out new functionJonas Bernoulli
2026-02-03magit--insert-blob-contents: Spin out new functionJonas Bernoulli
2026-02-03Unconditionally revert blob buffers for nowJonas Bernoulli
The next step will be to automatically revert when necessary and not revert when not necessary. Deciding which it is should neither be the job of the user nor of the callers (which didn't do a good job, which is why this commit first resets the behavior to a reasonable baseline).
2026-02-03magit--revert-blob-buffer: CosmeticsJonas Bernoulli
2026-02-03magit--revert-blob-buffer: Use magit-file-relative-nameJonas Bernoulli
2026-02-03magit--revert-blob-buffer: Renamed functionJonas Bernoulli
2026-02-03magit-find-file-noselect: Pivot to file if index has multiple stagesJonas Bernoulli
2026-02-03magit-find-file-noselect: Assert file is in repositoryJonas Bernoulli
Also no longer claim that FILE must be a relative to the repository top-level. That stopped being the case a while ago. While the file still usually is given as a relative path, that is no longer required. Also update docstring of `magit-find-file-index-noselect' accordingly.
2026-02-03magit-find-blob-hook: New hookJonas Bernoulli
Replaces `magit-find-file-hook' and `magit-find-index-hook', which are now obsolete aliases. If a hook function really only is suitable in when visiting a blob from the index or a blob from a commit, then one can check whether `magit-buffer-revision' is "{index}" or not.
2026-02-03magit-blob-mode-map: Bind revert-bufferJonas Bernoulli
2026-01-30magit-find-file-noselect: Fix regressionJonas Bernoulli
This continues the fix in [1: fe0c43b6f5]. Visiting the actual file needs the same handling as when we visit a blob; such relative paths are also relative to the top-level, not `default-directory'. Closes #5512. 1: 2026-01-16 fe0c43b6f5b3b20fce9ed30d203bf1267831b14f magit-find-file-noselect: Fix regression
2026-01-16magit-find-file-noselect: Fix regressionJonas Bernoulli
Closes #5506.
2026-01-11magit-buffer-refname: Convert to alias for magit-buffer-revisionJonas Bernoulli