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

Commit amend loses multiline format in commit message #40295

Closed
joaomoreno opened this issue Dec 15, 2017 · 49 comments
Closed

Commit amend loses multiline format in commit message #40295

joaomoreno opened this issue Dec 15, 2017 · 49 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Milestone

Comments

@joaomoreno
Copy link
Member

No description provided.

@joaomoreno joaomoreno added bug Issue identified by VS Code Team member as probable bug git GIT issues labels Dec 15, 2017
@joaomoreno joaomoreno added this to the Backlog milestone Dec 15, 2017
@joaomoreno joaomoreno self-assigned this Dec 15, 2017
@pmiossec
Copy link

I think that when this issue will be addressed, some more work must me done to improve "amend" feature ergonomy.

I think we should be able, with vscode, to amend only the commit message. At the moment, we must commit changes in the same time.

I also think that we should not use the command palette to edit the commit message like it's done at the moment...

I propose that:

  • we first decide that we will amend the commit
  • then, if the commit message field is empty, it is filled with the commit message of the commit that will be amended. (I don't exactly know what to do If there is already something entered. Perhaps we could have an option to do either "nothing", or appened the previous commit message on a new line)
  • the user is then able to change the commit message (this solve this issue because you can enter a multiline commit message 😄 )
  • when commiting, the commit is amended

PS: we could add an option somewhere to "stop" amending the commit if the user decide not to do it in the end....

@cavehill
Copy link

Any idea when this fix will be implemented?

Thanks!

@dantman
Copy link

dantman commented Apr 2, 2018

If you need a workaround, this works beautifully in the integrated terminal:

EDITOR="code -w" git commit --amend

I actually put this in my ~/.bash_profile:

if [ ! -z "$VSCODE_IPC_HOOK" ]; then
	# Use vscode as the editor for things like Git when run from within vscode's integrated terminal
	export EDITOR="code -w"
fi

Now every time I do git things like git commit --amend from within the integrated terminal vscode itself is used as the editor for commit messages. I can edit within vscode with all the syntax highlighting and special functionality. Then just save and close the tab to finish the commit.

@joaomoreno joaomoreno changed the title Commit (Amend) loses multiline format in commit message Commit amend loses multiline format in commit message Sep 18, 2018
@segevfiner
Copy link
Contributor

Atom's implementation of this is quite nice. It has an amend checkbox which brings the "commit to be amended" commit message, and files, into the UI. This allows you to remove files from the commit by "unstaging" (Not sure what this does in the underlying Git repository) them in the UI, and you can edit the commit message using the same UI as a normal commit. Avoiding a problem like this.

@danielo515
Copy link

Still an issue in 2019. I miss some input from the VSCode team...

@LenzGr
Copy link

LenzGr commented Feb 27, 2019

Just stumbled over this one myself several times now. Any update/feedback on this one? It's cumbersome having to switch to a shell to run git commit --amend to maintain the formatting...

@Wiz1999
Copy link

Wiz1999 commented Apr 29, 2019

Any update?

@coffenbacher
Copy link

This pretty much breaks amend functionality for my team, it would be really great if this gets fixed eventually.

@ADIX7
Copy link

ADIX7 commented Jul 17, 2019

Any info on this?

@pmiossec
Copy link

pmiossec commented Jul 19, 2019

I just see that the GitPod service which use the theia editor (which is based on VSCode) is doing it very well!

The PR bringing the fix: eclipse-theia/theia#1726

If that inspired someone to do it...And perhaps even get some code from the project...

@joaomoreno joaomoreno modified the milestones: July 2019, Backlog Jul 26, 2019
@gabeschine
Copy link

I am also running into this bug. Would really appreciate un-breaking the amend flow!

@shaun-cox
Copy link

Another vote that this get fixed. I ammend my commit all the time until merge and I hate losing the newlines in my commit message.

@jorhett
Copy link

jorhett commented Oct 17, 2019

It appears that @joaomoreno will spend hours identifying reports from all the other people annoyed by this, but nobody will spend an hour to fix it

@jrial
Copy link

jrial commented Oct 18, 2019

It appears that @joaomoreno will spend hours identifying reports from all the other people annoyed by this, but nobody will spend an hour to fix it

There's no need for that. While the bug is indeed annoying, there are almost 4000 issues demanding attention, apart from the work that's already on the roadmap. Your particular pet issue does not get priority simply by virtue that it annoys you.

Reasons why this might not be a priority:

  1. It's not a common operation. Sure, some people use it all the time, but we're a minority.
  2. There's a perfectly good workaround: the git CLI, or another graphical git frontend.
  3. There is no data loss involved, and reverting the negative effects of this bug is trivial.
  4. This part of the code may be scheduled for a redesign/rewrite, so fixing the bug in the current implementation would be a waste of effort.
    ...?

If it doesn't bother you enough for you to fix it yourself and open a pull request, it probably shouldn't bother you enough to lash out at the hard working developers who bring us a great product that measurably improves month by month, as evidenced by the changelog.

@danielo515
Copy link

I think that a good workaround would be to add another amend option to VSCode that uses --no-edit. Most of the time, I don't want to edit the commit message and this will preserve the line breaks.

@heartacker
Copy link
Contributor

Close to 3 years,......
I think that it will be better that user click amend that vscode copy the last-commit message to the commit-input-box. that user can edit again or just click cmomit continue.

@heartacker
Copy link
Contributor

heartacker commented Aug 7, 2020

here is another way is that add those code you want -amend and the using cli to execute git commit --amend ,then git-scm.exe will open the last commit-msg with vscode(git config --global core.editor "code --wait"),then edit,save,close.
if using gerrit. remind that do not delete the chang-id before. otherwise they will generate a new id
image

@orgads
Copy link
Contributor

orgads commented Aug 7, 2020

You should not delete Change-Id. This is how gerrit associates your commit with the change entity.

@heartacker
Copy link
Contributor

You should not delete Change-Id. This is how gerrit associates your commit with the change entity.

seem that every commit will generate a new chang-id. if not there are two changeids in the commit-msg. To seek the answers to authority

@orgads
Copy link
Contributor

orgads commented Aug 7, 2020

If this happens to you, something is wrong with your commit-msg hook...

@heartacker
Copy link
Contributor

If this happens to you, something is wrong with your commit-msg hook...

Do you mean that I don't need to delete the change-ID, It will keep the ID after Amend? thank for you remind

@orgads
Copy link
Contributor

orgads commented Aug 7, 2020

Exactly

@heartacker
Copy link
Contributor

Close to 3 years,......
I think that it will be better that user click amend that vscode copy the last-commit message to the commit-input-box. that user can edit again or just click cmomit continue.

perfect example in Visual Studio Code
amend_vs

@bit7

This comment has been minimized.

@Aure77

This comment has been minimized.

@msftwindowslinux
Copy link
Contributor

I've got a scrappy PR to add a git.amendNoEdit option that enables --no-edit when amending (and also skips the prompt for a commit message).

It would be great to get some direction on if/how something like this could be deemed an acceptable solution, because I think this is much needed for gerrit users as the current behavior clobbers the Change-Ids every time.

@jerivas
Copy link

jerivas commented Nov 4, 2020

What a horrible comment. Mentioning people just to dump sarcasm and vitriol on them. This is not the way to motivate the maintainers to look into this issue.

@hboshnak
Copy link

hboshnak commented Nov 5, 2020 via email

@joaomoreno
Copy link
Member Author

When running Commit (Amend) there are two cases:

  • Commit input box is empty: old message is preserved
  • Commit input box has value: that value is used as an amend commit message

If you'd like to edit the old commit message, you can always run Undo Last Commit and do it. For any other use cases, this will help: #95266

@alexrussell
Copy link

  • Commit input box is empty: old message is preserved

Aha, right, so for my use-case (doing a --no-edit style amend), I have to stage the files, run Commit (Amend) and then delete the auto-populated text from the single-line input (thus appearing to commit with an empty message) and then it'll do what I want. (I have just confirmed this, it seems to do it.)

Bit of an odd user experience, but I'm just happy I can do this 👍

@joaomoreno
Copy link
Member Author

joaomoreno commented Nov 10, 2020

@alexrussell With the changes I just pushed, you don't need to delete any auto populated text, since you won't even be prompted for any input at all. Running Commit (Amend) will just complete without asking you anything.

This will be released in the next insiders.

@mix3d
Copy link

mix3d commented Nov 10, 2020

But what if you WANT to amend the commit message? I do this sometimes to fix typos, add something about the file I forgot to add to the commit, etc.

@mix3d
Copy link

mix3d commented Nov 10, 2020

Also, of the original request items:

I think we should be able, with vscode, to amend only the commit message. At the moment, we must commit changes in the same time.

@alexrussell
Copy link

@alexrussell With the changes I just pushed, you don't need to delete any auto populated text, since you won't even be prompted for any input at all. Running Commit (Amend) will just complete without asking you anything.

This will be released in the next insiders.

Ahh cool. And yeah, I said I confirmed that it worked but actually I think I was mistaken. So that tallies up with you saying it wasn't released yet! I look forward to my next insiders build then. Thanks @joaomoreno!

@joaomoreno
Copy link
Member Author

But what if you WANT to amend the commit message? I do this sometimes to fix typos, add something about the file I forgot to add to the commit, etc.

As I said: run Git: Undo Last Commit. This will put your last message in the commit input box, properly formatted. Then, just commit again.

I think we should be able, with vscode, to amend only the commit message. At the moment, we must commit changes in the same time.

The same applies, simply run Git: Undo Last Commit, edit your message and commit again.

@grigorig
Copy link

Cool. This sounds like a good compromise. Thanks for the change. The messed up commit message formatting on amend hit me more than once.

@meganrogge meganrogge added the verified Verification succeeded label Dec 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 25, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug git GIT issues insiders-released Patch has been released in VS Code Insiders verified Verification succeeded
Projects
None yet