All of lore.kernel.org
 help / color / mirror / Atom feed
* reject "backwards" merges
@ 2014-12-12 18:40 Patrick Donnelly
  2014-12-13  9:47 ` David Kastrup
  0 siblings, 1 reply; 2+ messages in thread
From: Patrick Donnelly @ 2014-12-12 18:40 UTC (permalink / raw)
  To: Git

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):

$ git init
Initialized empty Git repository in /tmp/tmp.O0efpRrV4p/.git/
$ touch foo
$ git add foo
$ git commit -m initial
[master (root-commit) c4890b9] initial
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 foo
$ git branch b1
$ touch bar
$ git add bar
$ git commit -m bar
[master 9cb303e] bar
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bar
$ git checkout b1
Switched to branch 'b1'
$ touch baz
$ git add baz
$ git commit -m baz
[b1 4c618bc] baz
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 baz
$ git merge master
Merge made by the 'recursive' strategy.
 bar | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 bar
$ git checkout master
Switched to branch 'master'
$ git merge b1
Updating 9cb303e..1b0a9d4
Fast-forward
 baz | 0
 1 file changed, 0 insertions(+), 0 deletions(-)
 create mode 100644 baz
$ git log --graph
*   commit 1b0a9d4a011cd7e36c8c58b190aed0b450f06ca1
|\  Merge: 4c618bc 9cb303e
| | Author: Patrick Donnelly <>
| | Date:   Fri Dec 12 13:32:51 2014 -0500
| |
| |     Merge branch 'master' into b1
| |
| * commit 9cb303e2578af305d688abf62570ef31f3f113da
| | Author: Patrick Donnelly <>
| | Date:   Fri Dec 12 13:32:23 2014 -0500
| |
| |     bar
| |
* | commit 4c618bc094e82d9a5126a1c3fbc59921e41bd7b5
|/  Author: Patrick Donnelly <>
|   Date:   Fri Dec 12 13:32:46 2014 -0500
|
|       baz
|
* commit c4890b9bd590b34a9eb955d50e6e736729509a7c
  Author: Patrick Donnelly <>
  Date:   Fri Dec 12 13:31:46 2014 -0500

      initial

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?

-- 
Patrick Donnelly

^ permalink raw reply	[flat|nested] 2+ messages in thread

* Re: reject "backwards" merges
  2014-12-12 18:40 reject "backwards" merges Patrick Donnelly
@ 2014-12-13  9:47 ` David Kastrup
  0 siblings, 0 replies; 2+ messages in thread
From: David Kastrup @ 2014-12-13  9:47 UTC (permalink / raw)
  To: Patrick Donnelly; +Cc: Git

Patrick Donnelly <batrick@batbytes.com> writes:

> 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

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2014-12-13 10:45 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2014-12-12 18:40 reject "backwards" merges Patrick Donnelly
2014-12-13  9:47 ` David Kastrup

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.