magit-rev and magit-diff-visit-file: edit the file in HEAD

37 Aufrufe
Direkt zur ersten ungelesenen Nachricht

Daniel Dehennin

ungelesen,
17.07.2015, 12:44:5817.07.15
an ma...@googlegroups.com
Hello,

Thanks for this great Emacs mode, even better with the new version.

When reviewing a list of commit, I may need to edit a file quickly and
commit a fixup.

After reviewing the commits, I do an autosquash rebase.

My problem is that I can not find a quick way to open the files from
magit-rev buffer or after viewing a file with magit-diff-visit-file.

Is there a way to make “C-u magit-diff-visit-file” open the file at
current HEAD?

Should I submit an issue?

Regards.
--
Daniel Dehennin
Récupérer ma clef GPG: gpg --recv-keys 0xCC1E9E5B7A6FE2DF
Fingerprint: 3E69 014E 5C23 50E8 9ED6 2AAD CC1E 9E5B 7A6F E2DF
signature.asc

Kyle Meyer

ungelesen,
17.07.2015, 15:33:0917.07.15
an ma...@googlegroups.com
Daniel Dehennin <daniel....@baby-gnu.org> wrote:
[...]
> My problem is that I can not find a quick way to open the files from
> magit-rev buffer or after viewing a file with magit-diff-visit-file.
>
> Is there a way to make “C-u magit-diff-visit-file” open the file at
> current HEAD?

Just to be clear: from the buffer visiting a file for a particular
revision, you want to visit the working tree version (which may or may
not be HEAD's version), right? If so, you can use a command like this:

(defun magit-find-current-file-from-rev ()
(interactive)
(find-file (or magit-buffer-file-name
(user-error "Not in a revision buffer"))))

This doesn't attempt to restore point but will get you to the file of
the same name in the working tree. I use something similar as part of a
larger command and find it useful.

(If you really want to visit HEAD's version, magit-find-file will give
good defaults from the revision file buffer. I think HEAD will usually
be the second choice for a revision and the default file name should
correspond to the one you're visiting.)

> Should I submit an issue?

I think it's nice to be able to jump from a revision file to the working
tree version, so I'd say yes, but perhaps I missing some other obvious
way to do this or am overestimating its usefulness to other people. The
command above could try to put point in a similar position (and its
docstring could give the same warning as
magit-diff-visit-file-worktree's that point is more likely to be a badly
placed the older the version is).

--
Kyle

Robin Green

ungelesen,
25.09.2015, 10:11:3425.09.15
an magit
On Friday, 17 July 2015 20:33:09 UTC+1, Kyle Meyer wrote:
> Daniel Dehennin <daniel....@baby-gnu.org> wrote:
> [...]
> > My problem is that I can not find a quick way to open the files from
> > magit-rev buffer or after viewing a file with magit-diff-visit-file.
> >
> > Is there a way to make “C-u magit-diff-visit-file” open the file at
> > current HEAD?
>
> Just to be clear: from the buffer visiting a file for a particular
> revision, you want to visit the working tree version (which may or may
> not be HEAD's version), right?

What about from a magit-rev special buffer, which was the other thing he asked about? The answer you gave below doesn't work for a magit-rev buffer.

Kyle Meyer

ungelesen,
25.09.2015, 11:03:5325.09.15
an Robin Green, magit
Robin Green <gre...@gmail.com> writes:

> On Friday, 17 July 2015 20:33:09 UTC+1, Kyle Meyer wrote:
>> Daniel Dehennin <daniel....@baby-gnu.org> wrote:
>> [...]
>> > My problem is that I can not find a quick way to open the files from
>> > magit-rev buffer or after viewing a file with magit-diff-visit-file.
>> >
>> > Is there a way to make “C-u magit-diff-visit-file” open the file at
>> > current HEAD?
>>
>> Just to be clear: from the buffer visiting a file for a particular
>> revision, you want to visit the working tree version (which may or may
>> not be HEAD's version), right?
>
> What about from a magit-rev special buffer, which was the other thing
> he asked about? The answer you gave below doesn't work for a magit-rev
> buffer.

I may not have understood the original question. Doesn't
magit-diff-visit-file-worktree do what you're asking?

--
Kyle

Robin Green

ungelesen,
25.09.2015, 11:43:1825.09.15
an Kyle Meyer, magit
Ah yes, it does, thanks! For some reason that doesn't appear in C-h m.
-- 
Robin
Allen antworten
Antwort an Autor
Weiterleiten
0 neue Nachrichten