Removing merge commits that could have been fast-forward #424
Unanswered
raphaelcoeffic
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Here is the setup:
filter-branch(and very slow)git-filter-repoto help me obtaining the exact same result (important for me)The script used for the last pass is listed here (the first 2 use regular
git-filter-repocommand line):The small issue here is that it seems I should not be using
metadata, as it seems to be part of the private API, and is thus not available when passing the function directly in the command line with--commit-callback(argument is generated as_do_not_use_this_varin_handle_arg_callbacks()/make_callback()).For reference here is that what I think would be better for me to use (which seems quite odd and risky for compatibility with future versions):
git filter-repo --preserve-commit-hashes --prune-degenerate always \ --prune-empty always --subdirectory-filter src \ --commit-callback ' if len(commit.parents) > 1: agraph = _do_not_use_this_var["ancestry_graph"] if agraph.is_ancestor(commit.parents[0], commit.parents[1]): commit.parents = [commit.parents[1]] commit.file_changes = None elif agraph.is_ancestor(commit.parents[1], commit.parents[0]): commit.parents = [commit.parents[0]] commit.file_changes = None 'So I guess the basic question is: how can I find out that one of the parents of a merge commit has a common ancestor with the other, and I shall thus evict this commit?
Edit: just found this (
git blameis cool :-)): 0b70b72It suggests I should continue to use my separate Python script rather than using vanilla command line, is that correct?
Beta Was this translation helpful? Give feedback.
All reactions