[go: up one dir, main page]

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

Add a new --remerge-diff-only capability to show & log #1151

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

newren
Copy link
@newren newren commented Feb 17, 2022

== Overview ==

Add a new flag --remerge-diff-only which is very similar to the recently added --remerge-diff, which allows people to find cherry-picks/reverts with suboptimal resolutions or additional changes inserted.

--remerge-diff-only behaves the same as --remerge-diff for merge commits. For non-merge commits, it attempt to detect if the commit is a cherry-pick (currently can only be done if the user used -x when creating it) or a revert (which have the "This is a revert of " message). After detection:

  • If it is not a cherry-pick or revert, do not show a diff; just show a warning that we could not find cherry-pick or revert information
  • If it is a cherry-pick or revert, redo the cherry-pick/revert and diff against that commit instead of diffing against the first parent.

== Examples ==

You can see this in action on the linux.git repository with the following command:

$ git log --no-walk --remerge-diff-only 219d54332a09 a0184d71163a 2f216a850715

which provides a demonstration of each of the three non-merge-commit cases: not-a-pick-or-revert, a revert, and a cherry-pick.

LilMomma2024

This comment was marked as off-topic.

We want some functions to check if commits are cherry-picks or reverts,
based on information recorded in the commit message.  Namely, substrings
of the form
  This reverts commit ... [reversing\nchanges made to ...]
  cherry picked from commit ...
When these strings are found, get_message_pick() can return that the
specified commit is a cherry-pick or revert and what other commit the
specified commit is a cherry-pick or revert of.

We will use this later to implement --remerge-diff-only, where normal
non-merge commits that are not cherry-picks or reverts are omitted from
log/show output, and cherry-picks or reverts are shown as a diff against
an automatic re-pick/re-revert.  Thus, the new flag will be a way to see
what changes the creator of the commit made in order to complete the
cherry-pick or revert, such as removing conflict markers.

Signed-off-by: Elijah Newren <newren@gmail.com>
--remerge-diff-only is similar to --remerge-diff and implies its
behavior, but additionally will also change how all single-parent
commits are displayed.

If a single parent commit cannot be determined to be either a
cherry-pick or a revert (based on its commit message), then: (a) for
`git log`, the commit will simply be skipped, (b) for `git show`, a
warning that we could not find cherry-pick or revert information for the
commit will be shown.

If a single parent commit can be determined to be a cherry pick or a
revert (and the commit it is a cherry pick or revert of can be found in
the commit message), then --remerge-diff-only will cause that commit to
be automatically reverted or cherry-picked again (but only creating a
new tree, not a new commit), and then the commit will be diffed against
the automatic revert or cherry-pick tree.

Signed-off-by: Elijah Newren <newren@gmail.com>
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 this pull request may close these issues.

2 participants