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

Re: [PATCH v3] push: Provide situational hints for non-fast-forward errors

From
Christopher Tiwald <christiwald@gmail.com>
Date
Mar 26, 2012, 19:20 UTC
Message-ID
<20120326192001.GB32387@gmail.com>
In-Reply-To
<20120323214114.GB18198@sigill.intra.peff.net>
On Fri, Mar 23, 2012 at 05:41:14PM -0400, Jeff King wrote:
Show 5 quoted lines
> The only time we use the enum values is via the "int nonfastforward"
> passed to transport_push.  I think it would be a lot clearer to leave
> nonfastforward as a single bit in the ref, and then define the enum
> elsewhere (or even just use #define if we are not going to use the enum
> type).

I used the REF_STATUS_* enum as a template for what I wanted to accomplish when authoring v1, but did notice there was no other place my new options made much sense (Junio helped me remove one other call between v1 and v2). I like the readability fixup, but it won't compile as both push.c and transport.c need to see these. Would something like the following work? It simply moves the define statements to cache.h, so that both push and transport can use them.

diff --git a/cache.h b/cache.h
index 427b600..cb960c6 100644
--- a/cache.h
+++ b/cache.h
@@ -1009,6 +1009,7 @@ struct ref {
 	char *symref;
 	unsigned int force:1,
 		merge:1,
+		nonfastforward:1,
 		deletion:1;
 	enum {
 		REF_STATUS_NONE = 0,
@@ -1019,15 +1020,14 @@ struct ref {
 		REF_STATUS_REMOTE_REJECT,
 		REF_STATUS_EXPECTING_REPORT
 	} status;
-	enum {
-		NON_FF_HEAD = 1,
-		NON_FF_OTHER
-	} nonfastforward;
 	char *remote_status;
 	struct ref *peer_ref; /* when renaming */
 	char name[FLEX_ARRAY]; /* more */
 };
 
+#define NON_FF_HEAD  1
+#define NON_FF_OTHER 2
+
 #define REF_NORMAL	(1u << 0)
 #define REF_HEADS	(1u << 1)
 #define REF_TAGS	(1u << 2)


It tests fine locally for me using the same test cases I've been using
all along.

--
Christopher Tiwald
Previous: Jeff KingNext: Jeff King
Message 4 of 9 in “push: Provide situational hints for non-fast-forward errors”
  1. push: Provide situational hints for non-fast-forward errorsChristopher Tiwald, Mar 20, 2012
  2. Junio C HamanoMar 20, 2012
  3. Jeff KingMar 23, 2012
  4. Christopher TiwaldMar 26, 2012
  5. Jeff KingMar 26, 2012
  6. Christopher TiwaldMar 26, 2012
  7. Jeff KingMar 26, 2012
  8. Junio C HamanoMar 26, 2012
  9. Jeff KingMar 26, 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.