Package: emacs;
Reported by: Sean Whitton <spwhitton <at> spwhitton.name>
Date: Mon, 8 Sep 2025 11:28:02 UTC
Severity: normal
Found in version 31.0.50
To reply to this bug, email your comments to 79408 AT debbugs.gnu.org.
Toggle the display of automated, internal messages from the tracker.
View this report as an mbox folder, status mbox, maintainer mbox
eliz <at> gnu.org, sbaugh <at> janestreet.com, dmitry <at> gutov.dev, juri <at> linkov.net, bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Mon, 08 Sep 2025 11:28:02 GMT) Full text and rfc822 format available.Sean Whitton <spwhitton <at> spwhitton.name>
:eliz <at> gnu.org, sbaugh <at> janestreet.com, dmitry <at> gutov.dev, juri <at> linkov.net, bug-gnu-emacs <at> gnu.org
.
(Mon, 08 Sep 2025 11:28:02 GMT) Full text and rfc822 format available.Message #5 received at submit <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: bug-gnu-emacs <at> gnu.org Subject: 31.0.50; VC commands for cherry-picking Date: Mon, 08 Sep 2025 12:27:02 +0100
X-debbugs-cc: eliz <at> gnu.org, sbaugh <at> janestreet.com, dmitry <at> gutov.dev, juri <at> linkov.net Hello, I'd like to add VC commands to cherry-pick changes. These are my proposed additions to the VC API: ;; - cherry-pick (files comment rev reverse) ;; ;; Copy a REV's changes, log message, author and author timestamp as a ;; new commit on the current branch. If REVERSE, reverse REV's changes. ;; FILES is for forward-compatibility; existing implementations aren't ;; able to limit the changes copied from REV to those made to FILES. ;; ;; - cherry-apply (files rev reverse) ;; ;; Copy REV's changes to FILES to this working directory. If REVERSE, ;; reverse REV's changes. (When REVERSE is nil, typically REV will be ;; a revision from another branch.) ;; ;; - cherry-pick-comment (files rev reverse) ;; ;; Return a string to be appended to the log message when ;; cherry-picking REV onto another branch. This is Git's "(cherry ;; picked from commit ...)" and Mercurial's "(grafted from ...)", ;; or if REVERSE, Git's "This reverts commit ...". ;; FILES is for forward-compatibility; existing implementations care ;; only about REV. These are my proposed commands: vc-cherry-pick: - Gets the log message for REV with get-change-comment API function. - Gets the string to append with cherry-pick-comment API function. - Puts these together, starts a Log Edit session for the user to amend the message (e.g. for Git, doing C-c C-s to add a sign-off). - On C-c C-c, calls the cherry-pick API function for the backend to do the cherry-pick. Examples: vc-git-cherry-pick would invoke 'git cherry-pick' or 'git revert' depending on whether REVERT. vc-hg-cherry-pick would invoke 'hg graft' or 'hg backout'. Will have vc-checkin's COMMENT, INITIAL-CONTENTS arguments so calling from Lisp can skip the Log Edit session. A prefix argument might toggle whether to append the cherry-pick comment. We'll be expecting the user to invoke this from Log View mode. If multiple commits are marked, then I think we have to skip the Log Edit session, for now, because we don't have a nice way to prompt for multiple messages. vc-undo-revision (vc-revert is taken): Same as vc-cherry-pick, except passes REVERSE non-nil at the appropriate points. No prefix argument. vc-cherry-apply: The advantage of having a backend API function for this is that the backend can use its full merging logic. A generic vc-default-cherry-apply can be implementated similarly to vc-apply-to-other-working-tree. vc-undo-apply: Like vc-cherry-apply except passes REVERSE non-nil at the appropriate point. Similarly there can be a vc-default-reverse-cherry-apply. I think this is a good way to divide up the functionality on the frontend, but I'm open to suggestions. Thanks! -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Mon, 08 Sep 2025 18:41:02 GMT) Full text and rfc822 format available.Message #8 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Juri Linkov <juri <at> linkov.net> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, sbaugh <at> janestreet.com, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Mon, 08 Sep 2025 21:34:19 +0300
> These are my proposed commands: > > vc-cherry-pick: > - Gets the log message for REV with get-change-comment API function. > - Gets the string to append with cherry-pick-comment API function. > - Puts these together, starts a Log Edit session for the user to amend > the message (e.g. for Git, doing C-c C-s to add a sign-off). Will 'C-c C-d' be supported to show diff from the Log Edit buffer? > We'll be expecting the user to invoke this from Log View mode. I guess the basic workflow would be to view a branch log with e.g. 'C-x v b l', then after marking the required commits invoke the new commands. > If multiple commits are marked, then I think we have to skip the Log Edit > session, for now, because we don't have a nice way to prompt for > multiple messages. Maybe even for the single commit 'vc-cherry-pick' could ask for confirmation (maybe with a multiple choice), and optionally commit straight away without showing a Log Edit buffer. > vc-cherry-apply: > The advantage of having a backend API function for this is that the > backend can use its full merging logic. > A generic vc-default-cherry-apply can be implementated similarly to > vc-apply-to-other-working-tree. > > vc-undo-apply: > Like vc-cherry-apply except passes REVERSE non-nil at the appropriate > point. Similarly there can be a vc-default-reverse-cherry-apply. Are the last two commands equivalent to showing diff and invoking 'C-c RET a' on it, with or without the prefix argument REVERSE?
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Mon, 08 Sep 2025 18:57:02 GMT) Full text and rfc822 format available.Message #11 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Spencer Baugh <sbaugh <at> janestreet.com> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, juri <at> linkov.net, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Mon, 08 Sep 2025 14:56:34 -0400
Sean Whitton <spwhitton <at> spwhitton.name> writes: > X-debbugs-cc: eliz <at> gnu.org, sbaugh <at> janestreet.com, dmitry <at> gutov.dev, juri <at> linkov.net > > Hello, > > I'd like to add VC commands to cherry-pick changes. Exciting! > These are my proposed additions to the VC API: > > ;; - cherry-pick (files comment rev reverse) > ;; > ;; Copy a REV's changes, log message, author and author timestamp as a > ;; new commit on the current branch. If REVERSE, reverse REV's changes. > ;; FILES is for forward-compatibility; existing implementations aren't > ;; able to limit the changes copied from REV to those made to FILES. > > ;; - cherry-apply (files rev reverse) > ;; > ;; Copy REV's changes to FILES to this working directory. If REVERSE, > ;; reverse REV's changes. (When REVERSE is nil, typically REV will be > ;; a revision from another branch.) This reminded me of how we don't have a way to do format-patch using vc; that's somewhat related, and would be nice to support. In fact, I wonder if perhaps: - a new format-patch backend function - a new apply-patch backend function (to take advantage of better backend-specific merging) - maybe a fancier checkin-patch backend function Could replace the need for these specialized backend functions? (I think git-cherry-pick used to be implemented as format-patch + apply under the hood, years ago) > ;; - cherry-pick-comment (files rev reverse) > ;; > ;; Return a string to be appended to the log message when > ;; cherry-picking REV onto another branch. This is Git's "(cherry > ;; picked from commit ...)" and Mercurial's "(grafted from ...)", > ;; or if REVERSE, Git's "This reverts commit ...". > ;; FILES is for forward-compatibility; existing implementations care > ;; only about REV. > > These are my proposed commands: > > vc-cherry-pick: > - Gets the log message for REV with get-change-comment API function. > - Gets the string to append with cherry-pick-comment API function. > - Puts these together, starts a Log Edit session for the user to amend > the message (e.g. for Git, doing C-c C-s to add a sign-off). > - On C-c C-c, calls the cherry-pick API function for the backend to do > the cherry-pick. > Examples: vc-git-cherry-pick would invoke 'git cherry-pick' or > 'git revert' depending on whether REVERT. > vc-hg-cherry-pick would invoke 'hg graft' or 'hg backout'. > > Will have vc-checkin's COMMENT, INITIAL-CONTENTS arguments so calling > from Lisp can skip the Log Edit session. > > A prefix argument might toggle whether to append the cherry-pick > comment. That sounds like a bit of a waste of the prefix argument, since the user could always just delete that comment. I think we'd be better off just not having the prefix argument do anything for now, and maybe we'll find a better use in the future. > We'll be expecting the user to invoke this from Log View mode. If > multiple commits are marked, then I think we have to skip the Log Edit > session, for now, because we don't have a nice way to prompt for > multiple messages. This sounds reasonable. I personally rarely care about editing the commit message, but it's not hard for me to just hit C-c C-c. > vc-undo-revision (vc-revert is taken): > Same as vc-cherry-pick, except passes REVERSE non-nil at the > appropriate points. No prefix argument. Maybe we could name it vc-revert-revision? Actually maybe we should name the commands something like: vc-revision-cherry-pick vc-revision-cherry-pick-apply vc-revision-revert vc-revision-revert-apply To display more directly how they're closely related and symmetric. > vc-cherry-apply: > The advantage of having a backend API function for this is that the > backend can use its full merging logic. > A generic vc-default-cherry-apply can be implementated similarly to > vc-apply-to-other-working-tree. Right. I assume that generic implementation would use the 'diff backend function. And the sole disadvantage of such a generic implementation is that it would have less smart merging. I wonder, could we enhance diff-mode's ability to do conflict resolution? Maybe it can talk to vc for this, maybe using an apply-patch backend function like I suggested above? > vc-undo-apply: > Like vc-cherry-apply except passes REVERSE non-nil at the appropriate > point. Similarly there can be a vc-default-reverse-cherry-apply. That sounds good, but... I wonder if we even need to support vc-cherry-apply and vc-undo-apply? At least right now. Two very different reasons why we might not want those: - Those seem primarily useful when you want to actually edit the diff before committing. But, it seems to me that using diff-mode for such an operation is already pretty natural, and should be encouraged. The way I do those two operations today in hg is: - Open up vc-print-log starting at some revision - Find the revision I want to revert or cherry-apply - Hit d or D to open up the diff - Use diff-mode to do the editing Perhaps that is sufficient? - In a completely different direction: what if we only supported cherry-pick, but also added support for git reset --soft? In git, I often do cherry-apply by just cherry-picking and then resetting. This is a bit weird, but it might save us some complexity if we want to support git reset --soft anyway?
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Tue, 09 Sep 2025 09:58:01 GMT) Full text and rfc822 format available.Message #14 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Juri Linkov <juri <at> linkov.net> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, sbaugh <at> janestreet.com Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Tue, 09 Sep 2025 10:57:16 +0100
Hello, On Mon 08 Sep 2025 at 09:34pm +03, Juri Linkov wrote: >> These are my proposed commands: >> >> vc-cherry-pick: >> - Gets the log message for REV with get-change-comment API function. >> - Gets the string to append with cherry-pick-comment API function. >> - Puts these together, starts a Log Edit session for the user to amend >> the message (e.g. for Git, doing C-c C-s to add a sign-off). > > Will 'C-c C-d' be supported to show diff from the Log Edit buffer? Yes, it should be no problem to support that. >> We'll be expecting the user to invoke this from Log View mode. > > I guess the basic workflow would be to view a branch log > with e.g. 'C-x v b l', then after marking the required commits > invoke the new commands. Right. >> If multiple commits are marked, then I think we have to skip the Log Edit >> session, for now, because we don't have a nice way to prompt for >> multiple messages. > > Maybe even for the single commit 'vc-cherry-pick' could ask > for confirmation (maybe with a multiple choice), and optionally > commit straight away without showing a Log Edit buffer. I would say that is a bit complex, because just typing C-c C-c immediately is not a lot of effort. >> vc-cherry-apply: >> The advantage of having a backend API function for this is that the >> backend can use its full merging logic. >> A generic vc-default-cherry-apply can be implementated similarly to >> vc-apply-to-other-working-tree. >> >> vc-undo-apply: >> Like vc-cherry-apply except passes REVERSE non-nil at the appropriate >> point. Similarly there can be a vc-default-reverse-cherry-apply. > > Are the last two commands equivalent to showing diff and invoking > 'C-c RET a' on it, with or without the prefix argument REVERSE? Yes, except that using 'C-c RET a' uses Emacs's merging logic, which may be less sophisticated than the backend's. Hmm. Maybe I should skip those commands for now. What do you think? -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Tue, 09 Sep 2025 11:09:01 GMT) Full text and rfc822 format available.Message #17 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Spencer Baugh <sbaugh <at> janestreet.com> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, juri <at> linkov.net Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Tue, 09 Sep 2025 12:08:40 +0100
Hello, On Mon 08 Sep 2025 at 02:56pm -04, Spencer Baugh wrote: > This reminded me of how we don't have a way to do format-patch using vc; > that's somewhat related, and would be nice to support. We do! 'M-x vc-prepare-patch' is the interactive entry point. > In fact, I wonder if perhaps: > > - a new format-patch backend function > > - a new apply-patch backend function (to take advantage of better > backend-specific merging) > > - maybe a fancier checkin-patch backend function > > Could replace the need for these specialized backend functions? > > (I think git-cherry-pick used to be implemented as format-patch + apply > under the hood, years ago) So, the generic code would be responsible for invoking format-patch, then apply-patch, then checkin-patch, in that order, right? A couple of tricky things: - We would need a way to extract authorship information and then pass that into the improved checkin-patch. An author's name and e-mail address is generic enough, but the representation of dates might be something highly backend-specific. It's another couple of API functions. - There might be conflicts, in both the sense of ordinary diff application conflicts, and for Git, issues with the staging area. (There is a whole pile of logic in vc-git-checkin for dealing with the staging area with a comment summarising some of the issues, and there are still broken edge cases, I think.) I'm thinking that if the underlying VCS is responsible for handling the whole operation, it will manage to complete the cherry-pick anyway in more situations than our generic code will be able to do. It will also be faster, which might matter when cherry-picking a big chunk of a branch. Thinking about these sorts of issues, I am inclined to prefer cherry-pick-specific API functions. They're not hard for a backend author to implement, and I don't think they preclude adding an apply-patch and a fancier checkin-patch too for other purposes. (In particular, your apply-patch is very interesting, I agree that might be a nice addition for diff-mode. Then 'C-c RET a' would call into the VCS, sometimes. That's probably a separate bug though.) >> These are my proposed commands: >> >> vc-cherry-pick: >> - Gets the log message for REV with get-change-comment API function. >> - Gets the string to append with cherry-pick-comment API function. >> - Puts these together, starts a Log Edit session for the user to amend >> the message (e.g. for Git, doing C-c C-s to add a sign-off). >> - On C-c C-c, calls the cherry-pick API function for the backend to do >> the cherry-pick. >> Examples: vc-git-cherry-pick would invoke 'git cherry-pick' or >> 'git revert' depending on whether REVERT. >> vc-hg-cherry-pick would invoke 'hg graft' or 'hg backout'. >> >> Will have vc-checkin's COMMENT, INITIAL-CONTENTS arguments so calling >> from Lisp can skip the Log Edit session. >> >> A prefix argument might toggle whether to append the cherry-pick >> comment. > > That sounds like a bit of a waste of the prefix argument, since the user > could always just delete that comment. I think we'd be better off just > not having the prefix argument do anything for now, and maybe we'll find > a better use in the future. That works fine when cherry-picking a single commit, but if cherry-picking multiple commits, we're thinking there'll no opportunity to edit the commit message. In my experience cherry-picking, I want the cherry-pick comment often, but definitely not always. Git changed their default for this at one point; -x used to be implicit, now you have to specify it. So unfortunately I think we do have to give up the prefix arg to this. >> vc-undo-revision (vc-revert is taken): >> Same as vc-cherry-pick, except passes REVERSE non-nil at the >> appropriate points. No prefix argument. > > Maybe we could name it vc-revert-revision? > > Actually maybe we should name the commands something like: > > vc-revision-cherry-pick > vc-revision-cherry-pick-apply > vc-revision-revert > vc-revision-revert-apply > > To display more directly how they're closely related and symmetric. Yes, those are much better, thank you. (I would just say vc-revision-cherry-apply over vc-revision-cherry-pick-apply, though.) >> vc-cherry-apply: >> The advantage of having a backend API function for this is that the >> backend can use its full merging logic. >> A generic vc-default-cherry-apply can be implementated similarly to >> vc-apply-to-other-working-tree. > > Right. I assume that generic implementation would use the 'diff backend > function. And the sole disadvantage of such a generic implementation is > that it would have less smart merging. It would also be slower, probably, but for cherry-applying instead of cherry-picking, that's less important, because you are probably applying changes from fewer revisions. >> vc-undo-apply: >> Like vc-cherry-apply except passes REVERSE non-nil at the appropriate >> point. Similarly there can be a vc-default-reverse-cherry-apply. > > That sounds good, but... > > I wonder if we even need to support vc-cherry-apply and vc-undo-apply? > At least right now. > > Two very different reasons why we might not want those: > > - Those seem primarily useful when you want to actually edit the diff > before committing. But, it seems to me that using diff-mode for such > an operation is already pretty natural, and should be encouraged. > > The way I do those two operations today in hg is: > - Open up vc-print-log starting at some revision > - Find the revision I want to revert or cherry-apply > - Hit d or D to open up the diff > - Use diff-mode to do the editing > > Perhaps that is sufficient? I think you're right. Let's leave those two out for now. > - In a completely different direction: what if we only supported > cherry-pick, but also added support for git reset --soft? In git, I > often do cherry-apply by just cherry-picking and then resetting. This > is a bit weird, but it might save us some complexity if we want to > support git reset --soft anyway? There are a number of convenient workflows that I've used, and seen people discuss, which rely on creative uses of 'git reset --soft'. So I think it would be a very welcome addition. It also means one could immediately use these workflows and tricks with other VCS without learning about what the equivalent operation is, because Emacs would know. In generic VC terms, we could have an operation that deletes revisions from the end of the branch, and a version of that operation that deletes the revisions without removing the changes. The former would be 'git reset --hard' and the latter would be 'git reset --soft'. We already have vc-allow-rewriting-published-history which we can use to protect the user from getting themselves into an inconsistent state by means of these operations. I think we want to bake in the end-of-current-branch part. Here is what I mean. If we call it "vc-delete-revision", then it invites the question as to whether you can delete revisions that are not at the end of the branch. But that's a completely different operation: it's a rebase, not merely a reset. It's much less VCS-generic how such a thing could work. So I propose to exclude it. So I think we could call this something like - vc-delete-back-to-revision - vc-undo-checkins - vc-undo-checkins-back-to - vc-strip-revisions-back-to ? -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Tue, 09 Sep 2025 15:08:01 GMT) Full text and rfc822 format available.Message #20 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Spencer Baugh <sbaugh <at> janestreet.com> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, juri <at> linkov.net, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Tue, 09 Sep 2025 11:07:21 -0400
Sean Whitton <spwhitton <at> spwhitton.name> writes: > On Mon 08 Sep 2025 at 02:56pm -04, Spencer Baugh wrote: > >> This reminded me of how we don't have a way to do format-patch using vc; >> that's somewhat related, and would be nice to support. > > We do! 'M-x vc-prepare-patch' is the interactive entry point. Ah, right. I never use that because I always interact with Emacs development via Gnus, mostly via debbugs.el, and I just manually attach patches to my emails. (debbugs.el also has some way to format a patch but I've never gotten it to work) >> In fact, I wonder if perhaps: >> >> - a new format-patch backend function >> >> - a new apply-patch backend function (to take advantage of better >> backend-specific merging) >> >> - maybe a fancier checkin-patch backend function >> >> Could replace the need for these specialized backend functions? >> >> (I think git-cherry-pick used to be implemented as format-patch + apply >> under the hood, years ago) > > So, the generic code would be responsible for invoking format-patch, > then apply-patch, then checkin-patch, in that order, right? No. It would be format-patch followed by either apply-patch or checkin-patch. format-patch would be "git format-patch" apply-patch would be "git apply" (a new version of) checkin-patch would be "git am" > A couple of tricky things: > > - We would need a way to extract authorship information and then pass > that into the improved checkin-patch. An author's name and e-mail > address is generic enough, but the representation of dates might be > something highly backend-specific. It's another couple of API > functions. Actually, I don't think we would need that. The date and author information are both included in headers in the files produced by "git format-patch", and that information is used by "git am". Likewise, "hg export" produces patch files which contain the date and author, and "hg import" uses that information. The exact format of the patch is backend-specific, but I think we could reasonably rely on backends having some way to export a commit in the form of some header followed by a diff, which can then be imported again by another backend function. > - There might be conflicts, in both the sense of ordinary diff > application conflicts, and for Git, issues with the staging area. > (There is a whole pile of logic in vc-git-checkin for dealing with the > staging area with a comment summarising some of the issues, and there > are still broken edge cases, I think.) > I'm thinking that if the underlying VCS is responsible for handling > the whole operation, it will manage to complete the cherry-pick anyway > in more situations than our generic code will be able to do. > It will also be faster, which might matter when cherry-picking a big > chunk of a branch. > > Thinking about these sorts of issues, I am inclined to prefer > cherry-pick-specific API functions. They're not hard for a backend > author to implement, and I don't think they preclude adding an > apply-patch and a fancier checkin-patch too for other purposes. The VCS would still be (basically) handling the whole thing. I'm suggesting that we basically just run: git format-patch | git am or: hg import | hg export Which (I think) is how cherry-picking works under the hood historically in git anyway. > (In particular, your apply-patch is very interesting, I agree that might > be a nice addition for diff-mode. Then 'C-c RET a' would call into the > VCS, sometimes. That's probably a separate bug though.) Right. And if we're leaving out support for cherry-apply-without-commit for now, then we don't need to consider apply-patch right now anyway. >>> These are my proposed commands: >>> >>> vc-cherry-pick: >>> - Gets the log message for REV with get-change-comment API function. >>> - Gets the string to append with cherry-pick-comment API function. >>> - Puts these together, starts a Log Edit session for the user to amend >>> the message (e.g. for Git, doing C-c C-s to add a sign-off). >>> - On C-c C-c, calls the cherry-pick API function for the backend to do >>> the cherry-pick. >>> Examples: vc-git-cherry-pick would invoke 'git cherry-pick' or >>> 'git revert' depending on whether REVERT. >>> vc-hg-cherry-pick would invoke 'hg graft' or 'hg backout'. >>> >>> Will have vc-checkin's COMMENT, INITIAL-CONTENTS arguments so calling >>> from Lisp can skip the Log Edit session. >>> >>> A prefix argument might toggle whether to append the cherry-pick >>> comment. >> >> That sounds like a bit of a waste of the prefix argument, since the user >> could always just delete that comment. I think we'd be better off just >> not having the prefix argument do anything for now, and maybe we'll find >> a better use in the future. > > That works fine when cherry-picking a single commit, but if > cherry-picking multiple commits, we're thinking there'll no opportunity > to edit the commit message. In my experience cherry-picking, I want the > cherry-pick comment often, but definitely not always. > > Git changed their default for this at one point; -x used to be implicit, > now you have to specify it. Ah, right... Maybe we could prompt with Log Edit for each commit, even when cherry-picking multiple commits? I guess that would make cherry-picking multiple commits quite annoying... Oh, what if before opening any Log Edit buffers, we prompt the user whether they want to edit the commit messages for the commits being cherry-picked? We could give them several options: - don't manually edit messages but add cherry-pick message to each of them - don't manually edit messages and don't add cherry-pick message - manually edit all the messages This would give the user the ability to choose to edit commit messages even when cherry-picking multiple commits, which might be nice. Or... an even more radical idea would be to let them pick and choose which commit messages they want to edit, and even allow them to stop and edit individual commits in a series. Similar to git rebase -i. Actually, don't we need to be able to stop in the middle of cherry-picking a series of commits anyway, since we need to be able to resolve conflicts? I think that implies a substantially more rich UI then we've been talking about so far... >>> vc-undo-revision (vc-revert is taken): >>> Same as vc-cherry-pick, except passes REVERSE non-nil at the >>> appropriate points. No prefix argument. >> >> Maybe we could name it vc-revert-revision? >> >> Actually maybe we should name the commands something like: >> >> vc-revision-cherry-pick >> vc-revision-cherry-pick-apply >> vc-revision-revert >> vc-revision-revert-apply >> >> To display more directly how they're closely related and symmetric. > > Yes, those are much better, thank you. > > (I would just say vc-revision-cherry-apply over > vc-revision-cherry-pick-apply, though.) Reasonable. >> - In a completely different direction: what if we only supported >> cherry-pick, but also added support for git reset --soft? In git, I >> often do cherry-apply by just cherry-picking and then resetting. This >> is a bit weird, but it might save us some complexity if we want to >> support git reset --soft anyway? > > There are a number of convenient workflows that I've used, and seen > people discuss, which rely on creative uses of 'git reset --soft'. > So I think it would be a very welcome addition. It also means one could > immediately use these workflows and tricks with other VCS without > learning about what the equivalent operation is, because Emacs would > know. Indeed. > In generic VC terms, we could have an operation that deletes revisions > from the end of the branch, and a version of that operation that deletes > the revisions without removing the changes. The former would be > 'git reset --hard' and the latter would be 'git reset --soft'. Makes sense. > We already have vc-allow-rewriting-published-history which we can use to > protect the user from getting themselves into an inconsistent state by > means of these operations. Hm, I guess you're saying we would allow resetting commits which haven't been pushed, but not (with nil vc-allow-rewriting-published-history) resetting commits which have been pushed? That seems reasonable. > I think we want to bake in the end-of-current-branch part. > Here is what I mean. If we call it "vc-delete-revision", then it > invites the question as to whether you can delete revisions that are not > at the end of the branch. But that's a completely different operation: > it's a rebase, not merely a reset. It's much less VCS-generic how such > a thing could work. So I propose to exclude it. I agree that we should only operate on HEAD/tip, and the name should connote this. > So I think we could call this something like > > - vc-delete-back-to-revision > - vc-undo-checkins > - vc-undo-checkins-back-to > - vc-strip-revisions-back-to > > ? vc-undo-checkins might be confusing because actually this command can also be used on revisions which weren't created locally by vc-checkin. The "back-to" names feel a bit verbose/clumsy to me. What about mentioning tip in the name? For example: - vc-delete-tip-revisions - vc-strip-tip-revisions - vc-reset-tip-revisions Or maybe just vc-reset-revisions on its own would work as a name? "git reset" already only operates on tip, so there's prior art. I guess if we're going with the "vc-revision-cherry-pick" scheme, we might want to match that convention, with e.g. "vc-revision-reset".
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Tue, 09 Sep 2025 18:05:03 GMT) Full text and rfc822 format available.Message #23 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Juri Linkov <juri <at> linkov.net> To: Spencer Baugh <sbaugh <at> janestreet.com> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, Sean Whitton <spwhitton <at> spwhitton.name> Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Tue, 09 Sep 2025 21:01:36 +0300
>>> This reminded me of how we don't have a way to do format-patch using vc; >>> that's somewhat related, and would be nice to support. >> >> We do! 'M-x vc-prepare-patch' is the interactive entry point. > > Ah, right. I never use that because I always interact with Emacs > development via Gnus, mostly via debbugs.el, and I just manually attach > patches to my emails. (debbugs.el also has some way to format a patch > but I've never gotten it to work) We still miss the command with a name like 'vc-attach-patch' that would attach a marked revision to the current message. >>> In fact, I wonder if perhaps: >>> >>> - a new format-patch backend function The existing backend function 'prepare-patch' already uses format-patch in 'vc-git-prepare-patch'. > The VCS would still be (basically) handling the whole thing. I'm > suggesting that we basically just run: > > git format-patch | git am > > or: > > hg import | hg export > > Which (I think) is how cherry-picking works under the hood historically > in git anyway. Using backend commands to do the work would be more reliable. Then as post-processing we need to update already visited buffers.
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Tue, 09 Sep 2025 18:23:01 GMT) Full text and rfc822 format available.Message #26 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Juri Linkov <juri <at> linkov.net> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, sbaugh <at> janestreet.com Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Tue, 09 Sep 2025 21:15:19 +0300
>> I guess the basic workflow would be to view a branch log >> with e.g. 'C-x v b l', then after marking the required commits >> invoke the new commands. > > Right. We could also try to use the same UI as in e.g. Dired: - in a *vc-change-log* buffer use 'm' to mark revisions; - type 'C' to copy or 'M' to move (actually 'R' in Dired); - select a branch name in the minibuffer with completion. >> Are the last two commands equivalent to showing diff and invoking >> 'C-c RET a' on it, with or without the prefix argument REVERSE? > > Yes, except that using 'C-c RET a' uses Emacs's merging logic, which may > be less sophisticated than the backend's. Hmm. Maybe I should skip > those commands for now. What do you think? I think it makes sense to implement these commands only when they use backend commands. Because using diff commands is already easy with 'C-c RET a'. These new commands could provide an alternative way by relying on backend commands.
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Wed, 10 Sep 2025 09:54:01 GMT) Full text and rfc822 format available.Message #29 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Juri Linkov <juri <at> linkov.net> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, sbaugh <at> janestreet.com, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Wed, 10 Sep 2025 10:53:14 +0100
Hello, On Tue 09 Sep 2025 at 09:15pm +03, Juri Linkov wrote: > We could also try to use the same UI as in e.g. Dired: > > - in a *vc-change-log* buffer use 'm' to mark revisions; Right, this is what I was thinking already. > - type 'C' to copy or 'M' to move (actually 'R' in Dired); Yes, let's use 'C' to cherry-pick. Currently I'm not planning something for moving revisions between branches, but we could use 'R' for that if we decide to add it later. > - select a branch name in the minibuffer with completion. 'git cherry-pick' and 'hg graft' work only for applying commits onto a branch that's currently checked out. So we would have to implement our own complex thing, for each backend, if we wanted to be able to cherry-pick onto arbitrary branches. I'm also not sure how useful it would be to be able to do that, to be honest. On the other hand, if there are other working trees, prompting which working tree to cherry-pick onto could be implemented in generic code and would be an alternative to using C-x v w w to switch the working directory or invoke C-x v b l from the other working tree. So I'll implement that. C RET will always mean to cherry-pick to the current working tree's branch. -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Wed, 10 Sep 2025 09:55:02 GMT) Full text and rfc822 format available.Message #32 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Juri Linkov <juri <at> linkov.net> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, dmitry <at> gutov.dev Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Wed, 10 Sep 2025 10:54:25 +0100
Hello, On Tue 09 Sep 2025 at 09:01pm +03, Juri Linkov wrote: >>>> This reminded me of how we don't have a way to do format-patch using vc; >>>> that's somewhat related, and would be nice to support. >>> >>> We do! 'M-x vc-prepare-patch' is the interactive entry point. >> >> Ah, right. I never use that because I always interact with Emacs >> development via Gnus, mostly via debbugs.el, and I just manually attach >> patches to my emails. (debbugs.el also has some way to format a patch >> but I've never gotten it to work) > > We still miss the command with a name like 'vc-attach-patch' > that would attach a marked revision to the current message. I have something like this in mailscripts.el, an external package of mine. We have all the pieces to do it in core, though, and it would be useful indeed to be able to do it by marking a revision. -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Thu, 11 Sep 2025 06:57:02 GMT) Full text and rfc822 format available.Message #35 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Juri Linkov <juri <at> linkov.net> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, sbaugh <at> janestreet.com, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Thu, 11 Sep 2025 09:55:37 +0300
>> We could also try to use the same UI as in e.g. Dired: >> >> - in a *vc-change-log* buffer use 'm' to mark revisions; > > Right, this is what I was thinking already. > >> - type 'C' to copy or 'M' to move (actually 'R' in Dired); > > Yes, let's use 'C' to cherry-pick. Currently I'm not planning something > for moving revisions between branches, but we could use 'R' for that if > we decide to add it later. > >> - select a branch name in the minibuffer with completion. > > 'git cherry-pick' and 'hg graft' work only for applying commits onto a > branch that's currently checked out. So we would have to implement our > own complex thing, for each backend, if we wanted to be able to > cherry-pick onto arbitrary branches. I'm also not sure how useful it > would be to be able to do that, to be honest. Agreed, no need to use exactly the same analogy as copying files in Dired. > On the other hand, if there are other working trees, prompting which > working tree to cherry-pick onto could be implemented in generic code > and would be an alternative to using C-x v w w to switch the working > directory or invoke C-x v b l from the other working tree. So I'll > implement that. C RET will always mean to cherry-pick to the current > working tree's branch. I guess this means two commands: one generic command that reads a branch name and a commit, and another command specific to log-view that uses the marked commits without prompting.
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Thu, 11 Sep 2025 10:23:01 GMT) Full text and rfc822 format available.Message #38 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Spencer Baugh <sbaugh <at> janestreet.com> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, juri <at> linkov.net Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Thu, 11 Sep 2025 11:22:35 +0100
Hello, On Tue 09 Sep 2025 at 11:07am -04, Spencer Baugh wrote: > No. It would be format-patch followed by either apply-patch or > checkin-patch. > > format-patch would be "git format-patch" > apply-patch would be "git apply" > (a new version of) checkin-patch would be "git am" > [...] > The VCS would still be (basically) handling the whole thing. I'm > suggesting that we basically just run: > > git format-patch | git am > > or: > > hg import | hg export > > Which (I think) is how cherry-picking works under the hood historically > in git anyway. Ah, got it. Nice! I think this is a better API indeed. (It would also allow me to reimplement some other useful things from mailscripts.el in VC, such as applying patches attached to an e-mail, if we assume those are in a VCS-specific format, as they tend to be these days.) > Maybe we could prompt with Log Edit for each commit, even when > cherry-picking multiple commits? I guess that would make cherry-picking > multiple commits quite annoying... > > Oh, what if before opening any Log Edit buffers, we prompt the user > whether they want to edit the commit messages for the commits being > cherry-picked? We could give them several options: > > - don't manually edit messages but add cherry-pick message to each of them > - don't manually edit messages and don't add cherry-pick message > - manually edit all the messages > > This would give the user the ability to choose to edit commit messages > even when cherry-picking multiple commits, which might be nice. > > Or... an even more radical idea would be to let them pick and choose > which commit messages they want to edit, and even allow them to stop and > edit individual commits in a series. Similar to git rebase -i. > > Actually, don't we need to be able to stop in the middle of > cherry-picking a series of commits anyway, since we need to be able to > resolve conflicts? I think that implies a substantially more rich UI > then we've been talking about so far... I've been thinking that if there are conflicts we go into a merge conflict state for the failed cherry-pick, and abandon all subsequent cherry-picks. After the user has resolved that conflict they can execute another cherry-pick operation to grab the remaining commits. (We could unmark the commits that were successfully cherry-picked.) That means we can implement a useful multiple cherry-pick without blocking on doing a large amount of new UI design, and indeed UI implementation, up front. But yeah, certainly, the eventual desiderata would be for some way to edit commit messages for multiple commits. Regarding invoking Log Edit multiple times, that's natural to us as experienced Git users, for sure, and I thought about it too. It's fairly clunky though -- for example, there isn't a natural way to go back a few steps a edit a previous message again -- and I wonder if we can come up with something nicer. ISTM that a single buffer in which all the commit messages were available to edit, somehow, would be more useful, and also minimise UI confusion, because it would be just like our existing commit UI for VC where there is a single *vc-log* buffer and then the operation is atomic. I guess we would want some sort of major mode that could separate the buffer into portions? Or do we want custom.el-style text fields? WDYT? >> We already have vc-allow-rewriting-published-history which we can use to >> protect the user from getting themselves into an inconsistent state by >> means of these operations. > > Hm, I guess you're saying we would allow resetting commits which haven't > been pushed, but not (with nil vc-allow-rewriting-published-history) > resetting commits which have been pushed? That seems reasonable. Right. >> So I think we could call this something like >> >> - vc-delete-back-to-revision >> - vc-undo-checkins >> - vc-undo-checkins-back-to >> - vc-strip-revisions-back-to >> >> ? > > vc-undo-checkins might be confusing because actually this command can > also be used on revisions which weren't created locally by vc-checkin. > > The "back-to" names feel a bit verbose/clumsy to me. Fair. > What about mentioning tip in the name? For example: > > - vc-delete-tip-revisions > - vc-strip-tip-revisions > - vc-reset-tip-revisions > > Or maybe just vc-reset-revisions on its own would work as a name? "git > reset" already only operates on tip, so there's prior art. > > I guess if we're going with the "vc-revision-cherry-pick" scheme, we > might want to match that convention, with e.g. "vc-revision-reset". I would like to see if we can avoid "reset" because even in Git it means several different things (most fundamentally, clearing the staging area, which isn't a thing we recognise in VC anyway). I think "strip" is the right verb to use. Also it kind of implies that you can only strip from the end of the branch, to me, at least. I'm a bit hesitant about "tip" because it actually appears in the VC UI with Mercurial, but doesn't always mean the commit that's checked out, and from which we would strip. For example if you fetch without updating your working tree, the tip label will be beyond what you have and can delete commits from. In the recent new Info nodes I wrote I talked about the "end" of the branch, so I would suggest one of these: - vc-strip-revisions - vc-strip-end-revisions - vc-strip-branch-end-revisions - vc-strip-revisions-at-end - vc-strip-revisions-from-end I think I like vc-strip-revisions-from-end most. -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Thu, 11 Sep 2025 10:24:02 GMT) Full text and rfc822 format available.Message #41 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Juri Linkov <juri <at> linkov.net> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, sbaugh <at> janestreet.com Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Thu, 11 Sep 2025 11:23:26 +0100
Hello, On Thu 11 Sep 2025 at 09:55am +03, Juri Linkov wrote: > I guess this means two commands: one generic command that reads > a branch name and a commit, and another command specific to log-view > that uses the marked commits without prompting. Yes, I think so. -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Thu, 11 Sep 2025 17:23:02 GMT) Full text and rfc822 format available.Message #44 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Juri Linkov <juri <at> linkov.net> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: Spencer Baugh <sbaugh <at> janestreet.com>, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, dmitry <at> gutov.dev Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Thu, 11 Sep 2025 20:18:44 +0300
> (It would also allow me to reimplement some other useful things from > mailscripts.el in VC, such as applying patches attached to an e-mail, if > we assume those are in a VCS-specific format, as they tend to be these > days.) Such command would be nice to have. Currently applying a patch is quite cumbersome, e.g. need to select a region on the patch, then invoke M-| (M-x shell-command-on-region) cd ~/src/emacs/...; git apply RET > But yeah, certainly, the eventual desiderata would be for some way to > edit commit messages for multiple commits. Regarding invoking Log Edit > multiple times, that's natural to us as experienced Git users, for sure, > and I thought about it too. It's fairly clunky though -- for example, > there isn't a natural way to go back a few steps a edit a previous > message again -- and I wonder if we can come up with something nicer. It's possible to create multiple buffers with unique names like *vc-log*<2>, *vc-log*<3>, ... After 'C-c C-c' in one buffer the next buffer appears in the same window automatically when the previous buffer goes away. > ISTM that a single buffer in which all the commit messages were > available to edit, somehow, would be more useful, and also minimise UI > confusion, because it would be just like our existing commit UI for VC > where there is a single *vc-log* buffer and then the operation is > atomic. The current *vc-log* buffer is modeled after a mail message buffer with multiple header fields. So a single multi-commit buffer would be as heavy as having a multi-message mails buffer. > I'm a bit hesitant about "tip" because it actually appears in the VC UI > with Mercurial, but doesn't always mean the commit that's checked out, > and from which we would strip. For example if you fetch without > updating your working tree, the tip label will be beyond what you have > and can delete commits from. Then maybe 'vc-pop-revision' like from the top of the stack.
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Thu, 11 Sep 2025 18:16:01 GMT) Full text and rfc822 format available.Message #47 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Spencer Baugh <sbaugh <at> janestreet.com> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, juri <at> linkov.net, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Thu, 11 Sep 2025 14:14:52 -0400
Sean Whitton <spwhitton <at> spwhitton.name> writes: > Hello, > > On Tue 09 Sep 2025 at 11:07am -04, Spencer Baugh wrote: > >> No. It would be format-patch followed by either apply-patch or >> checkin-patch. >> >> format-patch would be "git format-patch" >> apply-patch would be "git apply" >> (a new version of) checkin-patch would be "git am" >> [...] >> The VCS would still be (basically) handling the whole thing. I'm >> suggesting that we basically just run: >> >> git format-patch | git am >> >> or: >> >> hg import | hg export >> >> Which (I think) is how cherry-picking works under the hood historically >> in git anyway. > > Ah, got it. Nice! I think this is a better API indeed. > > (It would also allow me to reimplement some other useful things from > mailscripts.el in VC, such as applying patches attached to an e-mail, if > we assume those are in a VCS-specific format, as they tend to be these > days.) That would be nice indeed. >> Maybe we could prompt with Log Edit for each commit, even when >> cherry-picking multiple commits? I guess that would make cherry-picking >> multiple commits quite annoying... >> >> Oh, what if before opening any Log Edit buffers, we prompt the user >> whether they want to edit the commit messages for the commits being >> cherry-picked? We could give them several options: >> >> - don't manually edit messages but add cherry-pick message to each of them >> - don't manually edit messages and don't add cherry-pick message >> - manually edit all the messages >> >> This would give the user the ability to choose to edit commit messages >> even when cherry-picking multiple commits, which might be nice. >> >> Or... an even more radical idea would be to let them pick and choose >> which commit messages they want to edit, and even allow them to stop and >> edit individual commits in a series. Similar to git rebase -i. >> >> Actually, don't we need to be able to stop in the middle of >> cherry-picking a series of commits anyway, since we need to be able to >> resolve conflicts? I think that implies a substantially more rich UI >> then we've been talking about so far... > > I've been thinking that if there are conflicts we go into a merge > conflict state for the failed cherry-pick, and abandon all subsequent > cherry-picks. After the user has resolved that conflict they can > execute another cherry-pick operation to grab the remaining commits. > (We could unmark the commits that were successfully cherry-picked.) > > That means we can implement a useful multiple cherry-pick without > blocking on doing a large amount of new UI design, and indeed UI > implementation, up front. Reasonable. Though I feel like "don't support multiple cherry-pick in the first version" is becoming more attractive, since even single cherry-pick will be very useful, and avoids having to deal with these issues now. > But yeah, certainly, the eventual desiderata would be for some way to > edit commit messages for multiple commits. Regarding invoking Log Edit > multiple times, that's natural to us as experienced Git users, for sure, > and I thought about it too. It's fairly clunky though -- for example, > there isn't a natural way to go back a few steps a edit a previous > message again -- and I wonder if we can come up with something nicer. True, it is clunky. Though I guess... one could imagine supporting log-view-modify-change-comment via clever use of git rebase. Maybe that would make it easy enough to modify old messages that it wouldn't matter? Or maybe that's even easy enough that editing the commit message isn't necessary in the first place. > ISTM that a single buffer in which all the commit messages were > available to edit, somehow, would be more useful, and also minimise UI > confusion, because it would be just like our existing commit UI for VC > where there is a single *vc-log* buffer and then the operation is > atomic. > > I guess we would want some sort of major mode that could separate the > buffer into portions? Or do we want custom.el-style text fields? WDYT? Interesting idea. That same kind of UI could also be useful for interactive rebase, I guess. Personally I think custom.el-style text fields are also pretty clumsy, so I'd avoid those. >> What about mentioning tip in the name? For example: >> >> - vc-delete-tip-revisions >> - vc-strip-tip-revisions >> - vc-reset-tip-revisions >> >> Or maybe just vc-reset-revisions on its own would work as a name? "git >> reset" already only operates on tip, so there's prior art. >> >> I guess if we're going with the "vc-revision-cherry-pick" scheme, we >> might want to match that convention, with e.g. "vc-revision-reset". > > I would like to see if we can avoid "reset" because even in Git it means > several different things (most fundamentally, clearing the staging area, > which isn't a thing we recognise in VC anyway). Good point, that's a strong reason to avoid reset. > I think "strip" is the right verb to use. Also it kind of implies that > you can only strip from the end of the branch, to me, at least. Yes, I like "strip". > I'm a bit hesitant about "tip" because it actually appears in the VC UI > with Mercurial, but doesn't always mean the commit that's checked out, > and from which we would strip. For example if you fetch without > updating your working tree, the tip label will be beyond what you have > and can delete commits from. Oh right. Ugh. That is indeed a pretty good reason not to use "tip". > In the recent new Info nodes I wrote I talked about the "end" of the > branch, so I would suggest one of these: > > - vc-strip-revisions > - vc-strip-end-revisions > - vc-strip-branch-end-revisions > - vc-strip-revisions-at-end > - vc-strip-revisions-from-end > > I think I like vc-strip-revisions-from-end most. Agreed, I like vc-strip-revisions-from-end best also. Though maybe vc-revisions-strip-from-end is better, if we're going with vc-revisions-cherry-pick and vc-revisions-revert? Or vc-revision-* (singular "revision" instead of plural "revisions") for all of those?
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Fri, 12 Sep 2025 09:58:02 GMT) Full text and rfc822 format available.Message #50 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Juri Linkov <juri <at> linkov.net> Cc: dmitry <at> gutov.dev, Spencer Baugh <sbaugh <at> janestreet.com>, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Fri, 12 Sep 2025 10:57:33 +0100
Hello, On Thu 11 Sep 2025 at 08:18pm +03, Juri Linkov wrote: >> (It would also allow me to reimplement some other useful things from >> mailscripts.el in VC, such as applying patches attached to an e-mail, if >> we assume those are in a VCS-specific format, as they tend to be these >> days.) > > Such command would be nice to have. Currently applying a patch is > quite cumbersome, e.g. need to select a region on the patch, then invoke > > M-| (M-x shell-command-on-region) cd ~/src/emacs/...; git apply RET Yes, exactly. >> But yeah, certainly, the eventual desiderata would be for some way to >> edit commit messages for multiple commits. Regarding invoking Log Edit >> multiple times, that's natural to us as experienced Git users, for sure, >> and I thought about it too. It's fairly clunky though -- for example, >> there isn't a natural way to go back a few steps a edit a previous >> message again -- and I wonder if we can come up with something nicer. > > It's possible to create multiple buffers with unique names like > *vc-log*<2>, *vc-log*<3>, ... After 'C-c C-c' in one buffer > the next buffer appears in the same window automatically > when the previous buffer goes away. To my mind, this still has the undesirable properties of Git's own repeated invocations of EDITOR, but it could work. >> I'm a bit hesitant about "tip" because it actually appears in the VC UI >> with Mercurial, but doesn't always mean the commit that's checked out, >> and from which we would strip. For example if you fetch without >> updating your working tree, the tip label will be beyond what you have >> and can delete commits from. > > Then maybe 'vc-pop-revision' like from the top of the stack. I like this name a lot. On the other hand, I think 'strip' is a bit more informative than 'pop', because 'pop' implies you get the revision back in your hand in some way, instead of just discarding it. -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Fri, 12 Sep 2025 12:56:02 GMT) Full text and rfc822 format available.Message #53 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Spencer Baugh <sbaugh <at> janestreet.com> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, juri <at> linkov.net Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Fri, 12 Sep 2025 13:55:07 +0100
Hello, On Thu 11 Sep 2025 at 02:14pm -04, Spencer Baugh via "Bug reports for GNU Emacs, the Swiss army knife of text editors" wrote: > Though I guess... one could imagine supporting > log-view-modify-change-comment via clever use of git rebase. Maybe that > would make it easy enough to modify old messages that it wouldn't > matter? > > Or maybe that's even easy enough that editing the commit message isn't > necessary in the first place. It's already supported for Git, actually, on master. You make an interesting point. At the end of a multiple commit cherry-pick, we could display a non-shortlog Log View buffer with just the result of the cherry-pick, and display a message saying "You can use \\[log-view-modify-change-comment] to modify any of these messages". That might be perfectly adequate and also means that when you don't need to make any edits, you're already done. > Interesting idea. That same kind of UI could also be useful for > interactive rebase, I guess. Potentially, though I think full interactive rebases are probably out-of-scope for VC because they're highly VCS-specific. > Personally I think custom.el-style text fields are also pretty clumsy, > so I'd avoid those. Yeah, especially when one is used to a full Log Edit buffer for editing commit messages most of the time. >> - vc-strip-revisions >> - vc-strip-end-revisions >> - vc-strip-branch-end-revisions >> - vc-strip-revisions-at-end >> - vc-strip-revisions-from-end >> >> I think I like vc-strip-revisions-from-end most. > > Agreed, I like vc-strip-revisions-from-end best also. > > Though maybe vc-revisions-strip-from-end is better, if we're going with > vc-revisions-cherry-pick and vc-revisions-revert? Or vc-revision-* > (singular "revision" instead of plural "revisions") for all of those? Yes, I agree, vc-revision- for all of them. -- Sean Whitton
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Fri, 12 Sep 2025 16:21:05 GMT) Full text and rfc822 format available.Message #56 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Juri Linkov <juri <at> linkov.net> To: Sean Whitton <spwhitton <at> spwhitton.name> Cc: dmitry <at> gutov.dev, Spencer Baugh <sbaugh <at> janestreet.com>, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Fri, 12 Sep 2025 19:03:29 +0300
>> Then maybe 'vc-pop-revision' like from the top of the stack. > > I like this name a lot. On the other hand, I think 'strip' is a bit > more informative than 'pop', because 'pop' implies you get the revision > back in your hand in some way, instead of just discarding it. Another possible variant: 'rollback' - that name is also used elsewhere to revert git-based deployed releases.
bug-gnu-emacs <at> gnu.org
:bug#79408
; Package emacs
.
(Sat, 13 Sep 2025 11:47:02 GMT) Full text and rfc822 format available.Message #59 received at 79408 <at> debbugs.gnu.org (full text, mbox):
From: Sean Whitton <spwhitton <at> spwhitton.name> To: Juri Linkov <juri <at> linkov.net> Cc: dmitry <at> gutov.dev, eliz <at> gnu.org, 79408 <at> debbugs.gnu.org, Spencer Baugh <sbaugh <at> janestreet.com> Subject: Re: bug#79408: 31.0.50; VC commands for cherry-picking Date: Sat, 13 Sep 2025 12:46:04 +0100
Hello, On Fri 12 Sep 2025 at 07:03pm +03, Juri Linkov wrote: >>> Then maybe 'vc-pop-revision' like from the top of the stack. >> >> I like this name a lot. On the other hand, I think 'strip' is a bit >> more informative than 'pop', because 'pop' implies you get the revision >> back in your hand in some way, instead of just discarding it. > > Another possible variant: 'rollback' - that name is also used elsewhere > to revert git-based deployed releases. I had a thought about this just now. Maybe "pop" for stripping commits without stripping their changes, 'git reset --soft', and "strip" for stripping commits and their changes, 'git reset --hard'. -- Sean Whitton
GNU bug tracking system
Copyright (C) 1999 Darren O. Benham,
1997,2003 nCipher Corporation Ltd,
1994-97 Ian Jackson.