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

[ BUG ] push --force-with-lease status output signals a "fast-fowarded" push when the ref is force-updated

From
Andrew Wheeler <awheeler@motorola.com>
Date
Jan 22, 2016, 21:47 UTC
Message-ID
<CAE=k0mv_Ouq=GbB-qWyRn9Js406Y0XwntyCp95JfOq3NGy+JzQ@mail.gmail.com>

When using push --force the output reports if the reference(s) was force-updated:

$ git push --force origin origin/master^:master
Total 0 (delta 0), reused 0 (delta 0)
To /home/thf876/gittest/m
 + cc44495...8302fcb origin/master^ -> master (forced update)

But when using push --force-with-lease the output reports that the reference was "fast-forward" updated, even if the branch was force-updated:

$ git push --force-with-lease origin origin/master^:master
Total 0 (delta 0), reused 0 (delta 0)
To /home/thf876/gittest/m
   a454b7f..cc44495  origin/master^ -> master

The main problem seems to be that ref.forced_update is never set in remote.c. I have a patch below that works-around the problem, but it may be not the right approach.

commit 81d8b713ee83161dbd7eb3dafd22718d1fa992a1
Author: Andrew Wheeler <awheeler@motorola.com>
Date:   Tue Jan 19 15:23:32 2016 -0600
    push --force-with-lease: Fix ref status reporting
    The --force--with-lease push option leads to less
    detailed status information than --force. In particular,
    the output indicates that a reference was fast-forwarded,
    even when it was force-updated.
    Modify the --force-with-lease ref status logic to leverage
    the --force ref status logic when the "lease" conditions
    are met.
    Signed-off-by: Andrew Wheeler <awheeler@motorola.com>
diff --git a/remote.c b/remote.c
index 9d34b5a..bad6213 100644
--- a/remote.c
+++ b/remote.c
@@ -1545,11 +1545,8 @@ void set_ref_status_for_push(struct ref
*remote_refs, int send_mirror,
                }

                /*
-                * Bypass the usual "must fast-forward" check but
-                * replace it with a weaker "the old value must be
-                * this value we observed".  If the remote ref has
-                * moved and is now different from what we expect,
-                * reject any push.
+                * If the remote ref has moved and is now different
+                * from what we expect, reject any push.
                 *
                 * It also is an error if the user told us to check
                 * with the remote-tracking branch to find the value
@@ -1560,10 +1557,14 @@ void set_ref_status_for_push(struct ref
*remote_refs, int send_mirror,
                        if (ref->expect_old_no_trackback ||
                            oidcmp(&ref->old_oid, &ref->old_oid_expect))
                                reject_reason = REF_STATUS_REJECT_STALE;
+                       else
+                               /* If the ref isn't stale then force
the update. */
+                               force_ref_update = 1;
                }

                /*
-                * The usual "must fast-forward" rules.
+                * If the update isn't already rejected then check
+                * the usual "must fast-forward" rules.
                 *
                 * Decide whether an individual refspec A:B can be
                 * pushed.  The push will succeed if any of the
@@ -1580,9 +1581,10 @@ void set_ref_status_for_push(struct ref
*remote_refs, int send_mirror,
                 *
                 * (4) it is forced using the +A:B notation, or by
                 *     passing the --force argument
+                *
                 */

-               else if (!ref->deletion && !is_null_oid(&ref->old_oid)) {
+               if (!reject_reason && !ref->deletion &&
!is_null_oid(&ref->old_oid)) {
                        if (starts_with(ref->name, "refs/tags/"))
                                reject_reason =
REF_STATUS_REJECT_ALREADY_EXISTS;
                        else if (!has_object_file(&ref->old_oid))
thf876@slug:~/git$
Message 1 of 1 in “[ BUG ] push --force-with-lease status output signals a "fast-fowarded" push when the ref is force-updated”
  1. Andrew WheelerJan 22, 2016

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.