Merge branch 'aw/push-force-with-lease-reporting'
authorJunio C Hamano <gitster@pobox.com>
Wed, 10 Feb 2016 22:20:08 +0000 (14:20 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 10 Feb 2016 22:20:08 +0000 (14:20 -0800)
"git push --force-with-lease" has been taught to report if the push
needed to force (or fast-forwarded).

* aw/push-force-with-lease-reporting:
push: fix ref status reporting for --force-with-lease

1  2 
remote.c
diff --combined remote.c
index 35940a5602807542eeae12a45bb845e73a99339c,3ceac07620cef06810c8f92adec735cc5baef832..02e698a5e05a02f8905ec511851eea15e86d746f
+++ b/remote.c
@@@ -256,7 -256,7 +256,7 @@@ static void read_remotes_file(struct re
        if (!f)
                return;
        remote->origin = REMOTE_REMOTES;
 -      while (strbuf_getline(&buf, f, '\n') != EOF) {
 +      while (strbuf_getline(&buf, f) != EOF) {
                const char *v;
  
                strbuf_rtrim(&buf);
@@@ -281,7 -281,7 +281,7 @@@ static void read_branches_file(struct r
        if (!f)
                return;
  
 -      strbuf_getline(&buf, f, '\n');
 +      strbuf_getline_lf(&buf, f);
        fclose(f);
        strbuf_trim(&buf);
        if (!buf.len) {
@@@ -428,9 -428,6 +428,9 @@@ static int handle_config(const char *ke
        } else if (!strcmp(subkey, ".proxy")) {
                return git_config_string((const char **)&remote->http_proxy,
                                         key, value);
 +      } else if (!strcmp(subkey, ".proxyauthmethod")) {
 +              return git_config_string((const char **)&remote->http_proxy_authmethod,
 +                                       key, value);
        } else if (!strcmp(subkey, ".vcs")) {
                return git_config_string(&remote->foreign_vcs, key, value);
        }
@@@ -1548,11 -1545,8 +1548,8 @@@ void set_ref_status_for_push(struct re
                }
  
                /*
-                * 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
                        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
                 *     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))