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

Re: [PATCH 1/2] send-pack: cluster ref status reporting

From
Jeff King <peff@peff.net>
Date
Nov 21, 2007, 07:37 UTC
Message-ID
<20071121073700.GA10742@sigill.intra.peff.net>
In-Reply-To
<20071121073332.GA10244@sigill.intra.peff.net>
On Wed, Nov 21, 2007 at 02:33:32AM -0500, Jeff King wrote:
Show 9 quoted lines
> > > +	case REF_STATUS_REMOTE_REJECT:
> > > +		print_ref_status('!', "[remote rejected]", ref,
> > > +				ref->deletion ? ref->peer_ref : NULL,
> > > +				ref->remote_status);
> > > +		break;
> 
> Gah, sorry. This crept in because I based it on the previous, broken
> version of the other patch series which had the same problem (and
> obviously this chunk is just a pure code move + reindent).

You will also find that it doesn't apply cleanly to 'next', since it attempts to remove the bogus version of the lines (while you correctly fixed them up when you applied to 'next').

Below is a fixed version of the patch for convenience.

-- >8 -- send-pack: cluster ref status reporting

Instead of intermingling success and failure, we now print:
  1. all uptodate refs (if args.verbose is enabled)
  2. successfully pushed refs
  3. failed refs
with the assumption that the user is most likely to see the
ones at the end, and therefore we order them from "least
interesting" to "most interesting."
---
 builtin-send-pack.c |   93 +++++++++++++++++++++++++++++----------------------
 1 files changed, 53 insertions(+), 40 deletions(-)
diff --git a/builtin-send-pack.c b/builtin-send-pack.c
index 3aab89c..25ae1fe 100644
--- a/builtin-send-pack.c
+++ b/builtin-send-pack.c
@@ -298,52 +298,65 @@ static void print_ok_ref_status(struct ref *ref)
 	}
 }
 
+static int print_one_push_status(struct ref *ref, const char *dest, int count)
+{
+	if (!count)
+		fprintf(stderr, "To %s\n", dest);
+
+	switch(ref->status) {
+	case REF_STATUS_NONE:
+		print_ref_status('X', "[no match]", ref, NULL, NULL);
+		break;
+	case REF_STATUS_REJECT_NODELETE:
+		print_ref_status('!', "[rejected]", ref, NULL,
+				"remote does not support deleting refs");
+		break;
+	case REF_STATUS_UPTODATE:
+		print_ref_status('=', "[up to date]", ref,
+				ref->peer_ref, NULL);
+		break;
+	case REF_STATUS_REJECT_NONFASTFORWARD:
+		print_ref_status('!', "[rejected]", ref, ref->peer_ref,
+				"non-fast forward");
+		break;
+	case REF_STATUS_REMOTE_REJECT:
+		print_ref_status('!', "[remote rejected]", ref,
+				ref->deletion ? NULL : ref->peer_ref,
+				ref->remote_status);
+		break;
+	case REF_STATUS_EXPECTING_REPORT:
+		print_ref_status('!', "[remote failure]", ref,
+				ref->deletion ? NULL : ref->peer_ref,
+				"remote failed to report status");
+		break;
+	case REF_STATUS_OK:
+		print_ok_ref_status(ref);
+		break;
+	}
+
+	return 1;
+}
+
 static void print_push_status(const char *dest, struct ref *refs)
 {
 	struct ref *ref;
-	int shown_dest = 0;
+	int n = 0;
 
-	for (ref = refs; ref; ref = ref->next) {
-		if (!ref->status)
-			continue;
-		if (ref->status == REF_STATUS_UPTODATE && !args.verbose)
-			continue;
+	if (args.verbose) {
+		for (ref = refs; ref; ref = ref->next)
+			if (ref->status == REF_STATUS_UPTODATE)
+				n += print_one_push_status(ref, dest, n);
+	}
 
-		if (!shown_dest) {
-			fprintf(stderr, "To %s\n", dest);
-			shown_dest = 1;
-		}
+	for (ref = refs; ref; ref = ref->next)
+		if (ref->status == REF_STATUS_OK)
+			n += print_one_push_status(ref, dest, n);
 
-		switch(ref->status) {
-		case REF_STATUS_NONE:
-			print_ref_status('X', "[no match]", ref, NULL, NULL);
-			break;
-		case REF_STATUS_REJECT_NODELETE:
-			print_ref_status('!', "[rejected]", ref, NULL,
-					"remote does not support deleting refs");
-			break;
-		case REF_STATUS_UPTODATE:
-			print_ref_status('=', "[up to date]", ref,
-					ref->peer_ref, NULL);
-			break;
-		case REF_STATUS_REJECT_NONFASTFORWARD:
-			print_ref_status('!', "[rejected]", ref, ref->peer_ref,
-					"non-fast forward");
-			break;
-		case REF_STATUS_REMOTE_REJECT:
-			print_ref_status('!', "[remote rejected]", ref,
-					ref->deletion ? NULL : ref->peer_ref,
-					ref->remote_status);
-			break;
-		case REF_STATUS_EXPECTING_REPORT:
-			print_ref_status('!', "[remote failure]", ref,
-					ref->deletion ? NULL : ref->peer_ref,
-					"remote failed to report status");
-			break;
-		case REF_STATUS_OK:
-			print_ok_ref_status(ref);
-			break;
-		}
+	for (ref = refs; ref; ref = ref->next) {
+		if (ref->status != REF_STATUS_NONE &&
+		    ref->status != REF_STATUS_UPTODATE &&
+		    ref->status != REF_STATUS_OK)
+			n += print_one_push_status(ref, dest, n);
 	}
 }
 
-- 
1.5.3.6.1786.g2e199
Previous: Jeff KingNext: Jeff King
Message 17 of 19 in “! [rejected] master -> master (non-fast forward)”
  1. Jon SmirlNov 18, 2007
  2. Junio C HamanoNov 18, 2007
  3. Jon SmirlNov 18, 2007
  4. Catalin MarinasNov 19, 2007
  5. Jon SmirlNov 19, 2007
  6. Daniel BarkalowNov 20, 2007
  7. Alex RiesenNov 18, 2007
  8. Jeff KingNov 20, 2007
  9. Alex RiesenNov 20, 2007
  10. Jeff KingNov 20, 2007
  11. 1/2 send-pack: cluster ref status reportingJeff King, Nov 20, 2007
  12. Alex RiesenNov 20, 2007
  13. Junio C HamanoNov 21, 2007
  14. Jeff KingNov 21, 2007
  15. Junio C HamanoNov 21, 2007
  16. Jeff KingNov 21, 2007
  17. Jeff KingNov 21, 2007
  18. 2/2 send-pack: print "maybe you need to pull" hintJeff King, Nov 20, 2007
  19. Alex RiesenNov 20, 2007

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.