3 ms·
Note that this will allow someone to push a history where you have a deeply nested merge mess of some sort all based off the current upstream master. That's no
by avar 8y ago
Note that this will allow someone to push a history where you have a deeply nested merge mess of some sort all based off the current upstream master.
That's not very likely, but in the interest of sanity and avoiding history complexity (which is the whole point) perhaps it's better to check:
1. That what's being pushed has either zero or one merge commit. Use "git rev-list --min-parents=2". If it's zero you don't need to check anything else (I'm assuming you're checking non-fast-forwards already).
2. If that one merge commit is there, unpack its parents and check that one side of it is strictly ahead of the current master. You can do this with "git merge-base --is-ancestor A B".
3. For consistency, validate that the LHS or RHS of the merge is the existing master, depending on your taste. Usually you'd want it to be the LHS.
Only this way will you guarantee that you have a history without nesting in "git log --oneline --graph", if that's what you're after, which I suspect people who'd like a hook like this actually want, not what you've outlined.