Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature request: Add option to stg squash to preserve text below the --- line #71

Closed
neuschaefer opened this issue Sep 20, 2020 · 2 comments · Fixed by #116
Closed

Feature request: Add option to stg squash to preserve text below the --- line #71

neuschaefer opened this issue Sep 20, 2020 · 2 comments · Fixed by #116

Comments

@neuschaefer
Copy link

When using stg squash and editing the patch description, I'd like stg squash to preserve the text below the --- line, because I keep a list of changes between the patch's published revisions there.
Currently I need to replace --- with something else before I finish editing in stg squash and later change it back with stg edit, but it would be more convenient if I could pass an option to stg squash that would cause it to perserve the text.

@jpgrayson
Copy link
Collaborator

Hi @neuschaefer. Sorry for the extremely delayed reply. I'm thinking about how squash's behavior could be changed or improved to help with this use case.

I'm wondering whether it might help if StGit adopted strategy similar to git rebase -i w.r.t. the message presented when squashing. For example, here is what is presented by stg squash -n squashed -- p0 p1 p2:

foo 0


---
Everything following the line with "---" will be ignored

p1--------------------------------------------------------------------

foo 1


p2--------------------------------------------------------------------

foo 2

Whereas this is what is presented by git rebase -i when picking p0 and squashing p1 and p2:

# This is a combination of 3 commits.
# This is the 1st commit message:

foo 1

# This is the commit message #2:

foo 2

# This is the commit message #3:

foo 3

# Please enter the commit message for your changes. Lines starting
# with '#' will be ignored, and an empty message aborts the commit.
#
# Author:    A Ú Thor <author@example.com>
# Date:      Fri Jun 18 19:02:25 2021 +0000
#
# interactive rebase in progress; onto 2c3baa8
# Last commands done (3 commands done):
#    squash 0f8681c foo 2
#    squash 893b6f1 foo 3
# No commands remaining.
# You are currently rebasing branch 'master' on '2c3baa8'.
#
# Changes to be committed:
#	modified:   foo.txt
#
# Untracked files:
#	.local/
#

What I'm suggesting is that StGit could use leading # as discardable comments instead of using --- to separate the viable message at the top from the discardable material below.

It seems like this approach would solve the immediate problem of --- having a different meaning in your messages.

It also seems like this approach might StGit more familiar to those coming from vanilla git. I also think I personally might prefer to edit squash messages structured this way.

Thoughts?

@neuschaefer
Copy link
Author

Hello @jpgrayson.

Assuming that in your proposal, any --- line in a commit message will be ignored and preserved, rather than cut off, I think it would be fine for my use case.

I imagine that my use case is somewhat rare, and I don't need the default behavior of stg squash to change. If a solution involves an option that I would have to set in my git config in order to preserve the --- line, I'd be ok with that, too.

To elaborate my use case some more: I specifically want to be able to keep the last --- line and the text below it, because I send out patches by email, that use this section for semantically important information (the changelog between patch revisions, and sometimes other information). This is information that I want to maintain as part of the commit message and send out as part of the patch email, but due to the --- line it will be dropped once it is applied to git by the receiver.

topher200 added a commit to topher200/stgit that referenced this issue Jun 24, 2021
Resolves stacked-git#71.

This change makes stgit's squash behavior mirror git's behavior, which should
be nice for people coming from vanilla 'git'.

Breaking change(?): Users now need to manually remove undesired messages from
squashed patches.
jpgrayson pushed a commit that referenced this issue Jun 24, 2021
Resolves #71.

This change makes stgit's squash behavior mirror git's behavior, which should
be nice for people coming from vanilla 'git'.

Breaking change(?): Users now need to manually remove undesired messages from
squashed patches.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants