| Age | Commit message (Collapse) | Author |
|
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'.
|
|
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.
|
|
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.
|
|
I.e., support visiting a blob via its blob oid without
knowing a commit and tree path in which it can be found.
|
|
|
|
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
Only call `magit--blob-normal-mode' if the blob oid changed or
the refresh is forced.
|
|
`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.
|
|
|
|
|
|
|
|
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'.)
|
|
|
|
|
|
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.
|
|
Eventually we should instead explicitly signal an error.
|
|
|
|
Commands, which previously called `magit-find-file--internal'
to do this, can now use `magit-find-file-noselect' directly.
Deprecate the former.
|
|
- 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.
|
|
|
|
`line' is always non-nil.
|
|
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.
|
|
(Refresh avoidance and position restoration still need work.)
|
|
|
|
|
|
|
|
|
|
Take advantage of that to potentially avoid some unnecessary work
when restoring point in such a buffer.
|
|
|
|
|
|
I.e., run both when first finding the file and when reverting,
as is done for regular files too (see `after-find-file').
|
|
|
|
|
|
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).
|
|
|
|
|
|
|
|
|
|
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.
|
|
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.
|
|
|
|
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
|
|
Closes #5506.
|
|
|