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

[PATCH v2 3/5] push: flag updates

From
Chris Rorvick <chris@rorvick.com>
Date
Nov 5, 2012, 03:08 UTC
Message-ID
<1352084908-32333-4-git-send-email-chris@rorvick.com>
In-Reply-To
<1352084908-32333-1-git-send-email-chris@rorvick.com>

If the reference exists on the remote and the the update is not a delete, then mark as an update. This is in preparation for handling tags and branches differently when pushing.

Signed-off-by: Chris Rorvick <chris@rorvick.com>
---
 cache.h  |    1 +
 remote.c |   19 ++++++++++++-------
 2 files changed, 13 insertions(+), 7 deletions(-)
diff --git a/cache.h b/cache.h
index bc2fc9a..1d10761 100644
--- a/cache.h
+++ b/cache.h
@@ -1003,6 +1003,7 @@ struct ref {
 		merge:1,
 		nonfastforward:1,
 		forwardable:1,
+		update:1,
 		deletion:1;
 	enum {
 		REF_STATUS_NONE = 0,
diff --git a/remote.c b/remote.c
index 5ecd58d..3d43bb5 100644
--- a/remote.c
+++ b/remote.c
@@ -1323,15 +1323,20 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 			  old->type == OBJ_COMMIT && new->type == OBJ_COMMIT);
 		}
 
-		ref->nonfastforward =
+		ref->update =
 			!ref->deletion &&
-			!is_null_sha1(ref->old_sha1) &&
-			(!has_sha1_file(ref->old_sha1)
-			  || !ref_newer(ref->new_sha1, ref->old_sha1));
+			!is_null_sha1(ref->old_sha1);
 
-		if (ref->nonfastforward && !ref->force && !force_update) {
-			ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
-			continue;
+		if (ref->update) {
+			ref->nonfastforward =
+				ref->update &&
+				(!has_sha1_file(ref->old_sha1)
+				  || !ref_newer(ref->new_sha1, ref->old_sha1));
+
+			if (ref->nonfastforward && !ref->force && !force_update) {
+				ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
+				continue;
+			}
 		}
 	}
 }
-- 
1.7.1
Previous: Chris RorvickNext: Chris Rorvick
Message 5 of 9 in “push: update remote tags only with force”
  1. 0/5 push: update remote tags only with forceChris Rorvick, Nov 5, 2012
  2. 1/5 push: return reject reasons via a maskChris Rorvick, Nov 5, 2012
  3. Jeff KingNov 9, 2012
  4. 2/5 push: add advice for rejected tag referenceChris Rorvick, Nov 5, 2012
  5. 3/5 push: flag updatesChris Rorvick, Nov 5, 2012
  6. 4/5 push: flag updates that require forceChris Rorvick, Nov 5, 2012
  7. 5/5 push: update remote tags only with forceChris Rorvick, Nov 5, 2012
  8. Jeff KingNov 9, 2012
  9. Chris RorvickNov 10, 2012

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.