Fixing rebase rather than avoiding it

Teemu Likonen tlikonen at iki.fi
Sat Mar 6 08:15:40 GMT 2010


* 2010-03-05 15:40 (+0100), Óscar Fuentes wrote:

> AFAIK, in git "merge & push" from a feature branch to master is as
> valid as "merge" on master from the feature branch, [...]

Yes, definitely. Nobody knows what names and meanings you give to your
local branches. When pushing, the source is an arbitrary reference to a
commit object, that is, a point in the DAG. Push source is not a place.
This also means that the remote end does not know anything but the point
in the DAG it should update the asked branch to. (Well, it knows the old
point of the branch too.)

> [...] so it is expected to see twisted DAGs where the distinction of
> left and right parts of the DAG makes little sense. Bazaar has a
> switch that forbids such DAG twisting.

You probably mean branch option append_revisions_only in Bazaar? I tried
different things with it and then reproduced the behaviour in Git with
this hook:


    #!/bin/sh
    # This is "hooks/update" file on the remote or central repository.

    old=$2      # We have this commit already.
    new=$3      # We were asked to update to this commit.

    git rev-list --first-parent "$new" | fgrep -q "$old"
    if [ $? -ne 0 ]; then
            # Give user a friendly error message.
            echo "Push failed because [reason]."
            exit 1
    fi
    exit 0      # Let's update.


As far as I can see Bazaar with append_revisions_only and Git with the
above hook script allow a push if the new first-parent line leads to the
last commit that is already on the remote branch. They prevent the push
if it doesn't.



More information about the bazaar mailing list