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

Revert commit message is inconsistent with c-git #117

Open
parasharjoshi opened this issue Dec 5, 2024 · 2 comments
Open

Revert commit message is inconsistent with c-git #117

parasharjoshi opened this issue Dec 5, 2024 · 2 comments
Assignees

Comments

@parasharjoshi
Copy link

parasharjoshi commented Dec 5, 2024

Version

6.7.0

Operating System

Linux/Unix, Windows

Bug description

The Revert commit message of Jgit is not consistent with the command line git revert operation.

Jgit uses the full commit message in revert commit message where as the command line git uses just the first line of commit message.

While reverting a following commit with message

This is a multi-line commit message to test revert on Jgit & c-Git.
With some text on line 2.
And some more text on line 3.

Jgit revert commit message is

commit 3142ef1f3345084fde2c23111208f2760e618244 (HEAD -> jGitRevert)
Author: Parashar Joshi <[email protected]>
Date:   Thu Dec 5 13:09:15 2024 +0530

    Revert "This is a multi-line commit message to test revert on Jgit & c-Git. With some text on line 2. And some more text on line 3."

    This reverts commit 1286a7ea850f01a47c63b09e42912f9643214f92.

Command line revert message is

commit f9c16b9368f9da50e820cc6f2355b487859f5182 (HEAD -> cGitRevert)
Author: Parashar Joshi <[email protected]>
Date:   Thu Dec 5 13:06:21 2024 +0530

    Revert "This is a multi-line commit message to test revert on Jgit & c-Git."

    This reverts commit 1286a7ea850f01a47c63b09e42912f9643214f92.

Actual behavior

Revert commit message of Jgit & c-git are not the same

Expected behavior

Revert commit message of Jgit & c-git are same

Relevant log output

No response

Other information

No response

@tomaswolf
Copy link
Contributor

Agreed; C git uses only the first line of the commit subject (i.e., the first line of the commit message). JGit uses the first paragraph (everything up to the first empty line (two \ns), with line feeds inside that paragraph replaced by spaces. That's the usual format, used also in git log --oneline.

But the C git sequencer (which executes the revert) trims that to the first line only. See https://github.com/git/git/blob/23692e08c638/sequencer.c#L496-L498 . find_commit_subject extracts that first paragraph into &subject, and returns the position of the first line feed.

@tomaswolf
Copy link
Contributor

Gerrit change 1205612 fixes this.

@tomaswolf tomaswolf self-assigned this Dec 11, 2024
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

No branches or pull requests

2 participants