Thread (16 messages) flat view 16 messages, 4 authors, 2016-06-15

Re: [PATCH v6 0/8] push: update remote tags only with force

From: Jeff King <hidden>
Date: 2016-06-15 22:55:47

On Wed, Jan 16, 2013 at 02:32:03PM +0100, Max Horn wrote:
With git 1.8.1, I get this message:

 ! [rejected]        master -> master (non-fast-forward)
[...]
But with next, I get this:

 ! [rejected]        master -> master (already exists)
Thanks for the detailed report. I was able to reproduce easily here.

The problem is the logic in is_forwardable:

static inline int is_forwardable(struct ref* ref)
{
        struct object *o;

        if (!prefixcmp(ref->name, "refs/tags/"))
                return 0;

        /* old object must be a commit */
        o = parse_object(ref->old_sha1);
        if (!o || o->type != OBJ_COMMIT)
                return 0;

        /* new object must be commit-ish */
        o = deref_tag(parse_object(ref->new_sha1), NULL, 0);
        if (!o || o->type != OBJ_COMMIT)
                return 0;

        return 1;
}

The intent is to allow fast-forward only between objects that both point
to commits eventually. But we are doing this check on the client, which
does not necessarily have the object for ref->old_sha1 at all. So it
cannot know the type, and cannot enforce this condition accurately.

I.e., we trigger the "!o" branch after the parse_object in your example.

-Peff
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help