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

[PATCH v3 4/5] push: flag updates that require force

From
Chris Rorvick <chris@rorvick.com>
Date
Nov 12, 2012, 04:08 UTC
Message-ID
<1352693288-7396-5-git-send-email-chris@rorvick.com>
In-Reply-To
<1352693288-7396-1-git-send-email-chris@rorvick.com>

Add a flag for indicating an update to a reference requires force. Currently the nonfastforward flag of a ref is used for this when generating status the status message. A separate flag insulates the status logic from the details of set_ref_status_for_push().

Signed-off-by: Chris Rorvick <chris@rorvick.com>
---
 cache.h     |  4 +++-
 remote.c    | 11 ++++++++---
 transport.c |  2 +-
 3 files changed, 12 insertions(+), 5 deletions(-)
diff --git a/cache.h b/cache.h
index 9712d1b..e61dca3 100644
--- a/cache.h
+++ b/cache.h
@@ -999,7 +999,9 @@ struct ref {
 	unsigned char old_sha1[20];
 	unsigned char new_sha1[20];
 	char *symref;
-	unsigned int force:1,
+	unsigned int
+		force:1,
+		requires_force:1,
 		merge:1,
 		nonfastforward:1,
 		forwardable:1,
diff --git a/remote.c b/remote.c
index 7fa9db6..82ba5ed 100644
--- a/remote.c
+++ b/remote.c
@@ -1285,6 +1285,8 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 	struct ref *ref;
 
 	for (ref = remote_refs; ref; ref = ref->next) {
+		int force_ref_update = ref->force || force_update;
+
 		if (ref->peer_ref)
 			hashcpy(ref->new_sha1, ref->peer_ref->new_sha1);
 		else if (!send_mirror)
@@ -1332,9 +1334,12 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror,
 				!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;
+			if (ref->nonfastforward) {
+				ref->requires_force = 1;
+				if (!force_ref_update) {
+					ref->status = REF_STATUS_REJECT_NONFASTFORWARD;
+					continue;
+				}
 			}
 		}
 	}
diff --git a/transport.c b/transport.c
index 1657798..632f8b0 100644
--- a/transport.c
+++ b/transport.c
@@ -659,7 +659,7 @@ static void print_ok_ref_status(struct ref *ref, int porcelain)
 		const char *msg;
 
 		strcpy(quickref, status_abbrev(ref->old_sha1));
-		if (ref->nonfastforward) {
+		if (ref->requires_force) {
 			strcat(quickref, "...");
 			type = '+';
 			msg = "forced update";
-- 
1.8.0
Previous: Chris RorvickNext: Chris Rorvick
Message 5 of 17 in “push: update remote tags only with force”
  1. 0/5 push: update remote tags only with forceChris Rorvick, Nov 12, 2012
  2. 1/5 push: return reject reasons via a maskChris Rorvick, Nov 12, 2012
  3. 2/5 push: add advice for rejected tag referenceChris Rorvick, Nov 12, 2012
  4. 3/5 push: flag updatesChris Rorvick, Nov 12, 2012
  5. 4/5 push: flag updates that require forceChris Rorvick, Nov 12, 2012
  6. 5/5 push: update remote tags only with forceChris Rorvick, Nov 12, 2012
  7. Junio C HamanoNov 13, 2012
  8. Drew NorthupNov 13, 2012
  9. Chris RorvickNov 14, 2012
  10. Kacper KornetNov 14, 2012
  11. Junio C HamanoNov 14, 2012
  12. Angelo BorsottiNov 14, 2012
  13. Junio C HamanoNov 14, 2012
  14. Angelo BorsottiNov 14, 2012
  15. Junio C HamanoNov 15, 2012
  16. Angelo BorsottiNov 15, 2012
  17. Junio C HamanoNov 15, 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.