git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH/RFC] improve no-op push output
@ 2012-05-30 12:08 Jeff King
  2012-05-30 17:52 ` Junio C Hamano
  0 siblings, 1 reply; 6+ messages in thread
From: Jeff King @ 2012-05-30 12:08 UTC (permalink / raw)
  To: git; +Cc: Matthieu Moy

I noticed the mention of the "Everything up-to-date" message in a nearby
thread. This patch doesn't help with the case there, but it made me
think about how vague that message is.

-- >8 --
When a push is a no-op because all refs are up-to-date, we print
"Everything up-to-date". That is reasonable when push.default is
"matching" (or when a wildcard refspec is given), because "Everything"
pretty obviously means "everything you asked git to push".

But when one of the single-ref push.default modes is used, the
"Everything" is slightly misleading; we only tried to push one thing,
and we should not give the user the impression that the remote is
completely in sync with what is in their local repo.

Instead, let's detect the case that we attempted to push a single ref,
and if so, just show the verbose status table (which includes the
up-to-date ref). We don't want to show it if we tried to push many refs,
because it could be quite long (e.g., in the case of "matching").

---
So before, running:

  git init -q --bare parent &&
  git clone -q parent child 2>/dev/null &&
  cd child &&
  echo one >one && git add one && git commit -q -m one &&
  git branch other &&
  git -c push.default=simple push

would just print:

  Everything up-to-date

and now you get:

  To /tmp/push-message/parent
   = [up to date]      master -> master

which is much more informative. And this could naturally extend to
printing the whole table when n < 5, or something similar. I don't think
it would help the case that David reported, though, since it sounds like
his problem was being on a detached HEAD without realizing it (and even
if we did print a status table, he would be similarly confused).

diff --git a/transport.c b/transport.c
index 1811b50..4dc09da 100644
--- a/transport.c
+++ b/transport.c
@@ -1033,6 +1033,15 @@ static void die_with_unpushed_submodules(struct string_list *needs_pushing)
 	die("Aborting.");
 }
 
+static int num_uptodate(struct ref *ref)
+{
+	int n = 0;
+	for (; ref; ref = ref->next)
+		if (ref->status == REF_STATUS_UPTODATE)
+			n++;
+	return n;
+}
+
 int transport_push(struct transport *transport,
 		   int refspec_nr, const char **refspec, int flags,
 		   int *nonfastforward)
@@ -1116,8 +1125,15 @@ int transport_push(struct transport *transport,
 
 		if (porcelain && !push_ret)
 			puts("Done");
-		else if (!quiet && !ret && !transport_refs_pushed(remote_refs))
-			fprintf(stderr, "Everything up-to-date\n");
+		else if (!quiet && !ret && !transport_refs_pushed(remote_refs)) {
+			if (verbose)
+				; /* already showed the up-to-date entries */
+			else if (num_uptodate(remote_refs) == 1)
+				transport_print_push_status(transport->url,
+				    remote_refs, 1, 0, nonfastforward);
+			else
+				fprintf(stderr, "Everything up-to-date\n");
+		}
 
 		return ret;
 	}

^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2012-06-05 10:10 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2012-05-30 12:08 [PATCH/RFC] improve no-op push output Jeff King
2012-05-30 17:52 ` Junio C Hamano
2012-05-31  6:10   ` Matthieu Moy
2012-06-04 12:51   ` Jeff King
2012-06-04 16:35     ` Junio C Hamano
2012-06-05 10:10       ` Jeff King

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).