Subject: Re: bug#64055: [WIP Patch] Enable editing commit messages - vc-git-modify-change-comment

From: Dmitry Gutov <[email-masked]>
Date: Sun, 20 Oct 2024 01:16:25 +0100

On 18/10/2024 07:50, Sean Whitton wrote:
>> So if we determined that its output could be used for editing, perhaps after
>> some massaging (e.g. reindenting and keeping only a subset of the headers),
>> that could be a minor win -- fewer methods is better in general. I haven't
>> tried to code it, so there could be pitfalls.
> I thought about it and realised that, for the git case, variables like
> vc-git-log-switches and vc-git-shortlog-switches can affect the output,
> and could make us misparse it.  And ultimately the benefits of avoiding
> a new backend method didn't seem to outweigh having parsing code that
> could turn out to be fragile.

IIUC vc-git-expanded-log-entry is only affected by the former var. We 
could bind it to nil (that could even be done generically, by looking 
for all vars called vc-BACKEND-log-switches).

But I agree fragility could be a problem. It could also be a win to have 
one of the methods to be implemented in terms of the other.

>> The new vc-git-get-change-comment seems good in terms of functionality. I was
>> thinking that the headers such as Author, No-Verify and Sign-Off, might be
>> good to show as well, but as long as their values are intact after the edit,
>> that's optional.
> I thought that it would be nice to include Author, in particular, as you
> might need to amend the value.  That would require adding additional
> arguments to the modify-change-comment action, though, so I left it for
> later if someone wants to implement it.

I think you're parsing out all the headers from the COMMENT argument in 
the posted patch, so this paragraph seems to be moot. Like you say in 
the patch though, it seems changing Author is not supported.

To do that, apparently we'd either need to rebase with a pause (with 
'git amend' in the middle), or use 'git rebase --exec' like in 
https://stackoverflow.com/a/79068024/615245. The latter seems like it 
would apply to all commits in the range, so it might require the same 
dance as 'amend'.

(I can comment on the patch itself tomorrow.)