git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: reject "backwards" merges

From
David Kastrup <dak@gnu.org>
Date
Dec 13, 2014, 09:47 UTC
Message-ID
<877fxvdgpa.fsf@fencepost.gnu.org>
In-Reply-To
<CACh33FqHindeksHv7wcgu983oBSbm5G0ZswrQdTAz5tqgZdgjQ@mail.gmail.com>
Patrick Donnelly <batrick@batbytes.com> writes:
Show 8 quoted lines
> Is there a way to reject pushes that change the history of
> first-parents, caused by a "backwards" merge? To clarify by example
> (using branches instead of separate repositories):
>
> Here the desired first parent (HEAD^) would be commit
> 9cb303e2578af305d688abf62570ef31f3f113da. Unfortunately, the incorrect
> merge reversed the line of parents. Is there a way to prevent this
> from happening (via git-config) other than fixing the human?

You'd have to do this in a push hook. Before pushing, Git does not really have a way to figure out which kind of branch a merge will land on.

Most "reversed merges" probably come into being by having a fast-forward in a series of zig-zagged merges. Naturally the history before the fast-forward can only be "the right way round" for one of the two branches.

-- 
David Kastrup
Previous: Patrick Donnelly
Message 2 of 2 in “reject "backwards" merges”
  1. Patrick DonnellyDec 12, 2014
  2. David KastrupDec 13, 2014

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.