* [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
* Re: [PATCH/RFC] improve no-op push output 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 0 siblings, 2 replies; 6+ messages in thread From: Junio C Hamano @ 2012-05-30 17:52 UTC (permalink / raw) To: Jeff King; +Cc: git, Matthieu Moy Jeff King <peff@peff.net> writes: > 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. I think a more interesting case is to do this in the child: git checkout other git -c push.default=matching push after the above sequence. It will try to push master to master (and the most important part is 'other' is not involved in this push at all) and would give you the same updated message, which would make it more clear that 'other' is not involved. Although it by itself is good, but unless you are paying attention, you may not catch that your current branch is *not* listed in the output, so it might not help people that much, even if they weren't on a detached HEAD. Somebody who is unaware that she has been working on detached HEAD is by definition very unlikely to notice that the 'master' in the output is different from her current branch, as she is not paying attention to what branch she is working on. It might be a better approach to check if the set of pushed refs include the current branch and rephrase the message only in that case, perhaps Everything up-to-date (the current branch not pushed) or something. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC] improve no-op push output 2012-05-30 17:52 ` Junio C Hamano @ 2012-05-31 6:10 ` Matthieu Moy 2012-06-04 12:51 ` Jeff King 1 sibling, 0 replies; 6+ messages in thread From: Matthieu Moy @ 2012-05-31 6:10 UTC (permalink / raw) To: Junio C Hamano; +Cc: Jeff King, git Junio C Hamano <gitster@pobox.com> writes: >> would just print: >> >> Everything up-to-date >> >> and now you get: >> >> To /tmp/push-message/parent >> = [up to date] master -> master > [...] > > Everything up-to-date (the current branch not pushed) I like both. They don't really take more screen space (1 more line for Jeff, which is acceptable IMHO), and do add information. I'd add the number of branches pushed in case it's not one, so it could say one of: To /tmp/push-message/parent = [up to date] master -> master or Everything up-to-date (X branches pushed, including the current) or Everything up-to-date (X branches pushed, not including the current) It would give a clue to a user having created many local branches that his local branches were not pushed, and vice-versa, may help people who did not understand that "push.default=matching" was pushing multiple branches. -- Matthieu Moy http://www-verimag.imag.fr/~moy/ ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC] improve no-op push output 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 1 sibling, 1 reply; 6+ messages in thread From: Jeff King @ 2012-06-04 12:51 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Matthieu Moy On Wed, May 30, 2012 at 10:52:28AM -0700, Junio C Hamano wrote: > > 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. > > I think a more interesting case is to do this in the child: > > git checkout other > git -c push.default=matching push > > after the above sequence. It will try to push master to master (and > the most important part is 'other' is not involved in this push at > all) and would give you the same updated message, which would make > it more clear that 'other' is not involved. Thanks for a good example. Part of the reason my patch was RFC was that I had a feeling there was a more general problem to be solved, and I couldn't quite put my finger on it. Taking a step back, the real issue is not that "everything up to date" is not accurate for single-branch pushes. It is that users sometimes expect a thing to have been pushed, and it is not (because the configuration is different than they expect, or because they are on a different branch than they expect). Sometimes that is masked by saying "Everything up-to-date" (because the user thinks "everything" included what they wanted, even though it did not). But sometimes it is because things _do_ get pushed, but they fail to notice that the thing they expected was not in the list. So I think in general, the solution is for "git push" to be more specific about what happened. But there are some complications, as I'll get to below. > Although it by itself is good, but unless you are paying attention, > you may not catch that your current branch is *not* listed in the > output, so it might not help people that much, even if they weren't on > a detached HEAD. > > Somebody who is unaware that she has been working on detached HEAD is > by definition very unlikely to notice that the 'master' in the output > is different from her current branch, as she is not paying attention > to what branch she is working on. > > It might be a better approach to check if the set of pushed refs > include the current branch and rephrase the message only in that case, > perhaps > > Everything up-to-date (the current branch not pushed) > > or something. Hmm. I like that approach, because it is directly responding to a specific thing that might be confusing the user. But I'm not sure it is complete. For one thing, it only helps for the case of "push.default is matching, and my HEAD was not pushed" (detached or not). Another one I'd expect is "push.default is not matching, and I expected all of my work to be pushed". And you mentioned above "push.default is matching, and I expected 'foo' to be pushed, but forgot that upstream does not yet have it). Secondly, it helps the detached HEAD case for "matching", but should do nothing for the other cases, all of which should error out (because there is by definition no defined upstream for "upstream" or "simple", nor would we know what to call the remote side for "current"). So I think we would really need to break down each potentially confusing case, and come up with a solution for each. I think we can divide the push configuration into three cases: matching, single (which includes "upstream", "simple", and "current"), or custom refspecs. Let's ignore the final one for now. It's relatively rare, and probably the most common use is mirroring (in which case we know we pushed everything, anyway). And then we have a few potential confusing situations: 1. We are on a detached HEAD; the user expects their current work to be pushed, but it is not. With the "single" cases, we should already error out. For the "matching" case, we don't want to error out, but it might be worth printing a warning to say "by the way, your HEAD is detached", whether everything is up-to-date or not. Maybe that would be annoying, though. I guess it could be configurable with an advice.*. Or maybe it's not worth caring about, since we are pushing new people towards the "single" case anyway. 2. We are on a branch; the user expects it to be pushed, but it is not. This can't happen with the "single" cases, since they always push HEAD (or fail). For matching, again, a solution might be "by the way, your HEAD was not pushed", with the same caveats as above. 3. We are on a branch; the user expects some other branch X to be pushed, but it is not. For the "single" cases, they will either get a single-line status table (mentioning HEAD), or they will get "Everything up-to-date". In the former case, it is hopefully obvious that their branch is not mentioned. In the latter case, I think the "everything" is potentially misleading (and the fact that we never say _which_ branch is pushed. So if they thought they were on X, but were on Y, they might be confused). So I think the right solution is to just be more specific; say "X is up-to-date", or just show the single-line status table. For the "matching" case, it's much harder. If we show them the whole description of what happened and hoping they notice that their branch is not included. When something actually gets pushed, we show the status table already, and they may or may not look through it to find the branch in question (indeed, they may not even be trying to push X at the time, but rather may later say "Hey, I thought I pushed everything; why is X not here?). If nothing gets pushed (i.e., "Everything up-to-date"), we are not much better off. We don't currently show the list of what we attempted (without "-v"), but showing it would not be much better. It is potentially long, and the user has no reason to scan through it checking to make sure each branch is there. So it would really depend on us noting that the branch is exceptional for some reason in not being pushed. In case (2) above, we noted that the branch is HEAD, which makes us think maybe they wanted to push it, and we should give it special mention. We could also potentially show the list of branches that _weren't_ pushed. Depending on your workflow, that may be a small list, and an exceptional circumstance. But it may also be quite large. Sorry, that explanation ended up long. As you can see, I'm still talking out what the actual problem is. By the analysis above, there are basically two features I'd consider: 1. For a single-ref push, always mention the ref name, even if it is up-to-date. My previous patch showed the status table, but we could also just tweak the "Everything up-to-date" to say "Ref X is up-to-date". We could also consider doing it not just in the single-ref case, but when there are fewer than N refs. The single-ref one is the most interesting, though, because it hits the newer push.default settings. 2. Introduce a "push.warnMatch" config option, which can be set to one of: - "none"; the current behavior - "branches"; mention all unmatched refs which are in refs/heads - "head"; mention the current HEAD if it is unmatched -Peff ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC] improve no-op push output 2012-06-04 12:51 ` Jeff King @ 2012-06-04 16:35 ` Junio C Hamano 2012-06-05 10:10 ` Jeff King 0 siblings, 1 reply; 6+ messages in thread From: Junio C Hamano @ 2012-06-04 16:35 UTC (permalink / raw) To: Jeff King; +Cc: git, Matthieu Moy Jeff King <peff@peff.net> writes: > So I think we would really need to break down each potentially confusing > case, and come up with a solution for each. I think we can divide the > push configuration into three cases: matching, single (which includes > "upstream", "simple", and "current"), or custom refspecs. Let's ignore > the final one for now. It's relatively rare, and probably the most > common use is mirroring (in which case we know we pushed everything, > anyway). And then we have a few potential confusing situations: Does "single" include "upstream", "simple" and "current", or does it consists of these three and nothing else? I think it is the latter, and I mean the latter in the remainder of my response. Specifically, I would exclude the case where you have remote.$there.push that only pushes one ref from "single". > 1. We are on a detached HEAD; the user expects their current work to > be pushed, but it is not. With the "single" cases, we should > already error out. All the "single" cases should error out when run on a detached HEAD (otherwise they should be fixed). I have a feeling that it is not the best approach to classify the "detached HEAD" as a special failure mode for "single". If you view "single" as "push the curent branch out, but the name of the destination ref may be different depending on the mode", the detached HEAD case is just a natural extension of the error case "nothing is specified to be updated from this state, hence we error out". > For the "matching" case, we don't want to error > out, but it might be worth printing a warning to say "by the way, > your HEAD is detached", whether everything is up-to-date or not. Both "matching" and "specific remote.$there.push" cases are "it does not matter what branch happens to be checked out; I am giving you the set of refs I want to push out by default", so even though you said you ignore the specific refspec case, they fall into the same category here. I find the above an unnecessarily roundabout way to help people who expect the current branch to always be involved in an unnamed push to say "your HEAD is detached"; it requires them to be intelligent enough to connect "HEAD detached", "no current branch" and "hence nothing pushed". A more direct way "detached HEAD not pushed" may be better. > 2. We are on a branch; the user expects it to be pushed, but it is > not. This can't happen with the "single" cases, since they always > push HEAD (or fail). For matching, again, a solution might be "by > the way, your HEAD was not pushed", with the same caveats as above. Yes, "by the way, your current branch was not pushed" is much better than "HEAD is detached" you wrote in 1. > 3. We are on a branch; the user expects some other branch X to be > pushed, but it is not. > ... So I think the right solution is to just > be more specific; say "X is up-to-date", or just show the > single-line status table. OK. > For the "matching" case, it's much harder. > > If we show them the whole description of what happened and hoping > they notice that their branch is not included. When something > actually gets pushed, we show the status table already, and they > may or may not look through it to find the branch in question > (indeed, they may not even be trying to push X at the time, but > rather may later say "Hey, I thought I pushed everything; why is X > not here?). We can cover both the "here are the list" and the "everything up-to-date" cases with "(current branch not pushed)" (or "detached HEAD not pushed)". > 1. For a single-ref push, always mention the ref name, even if it is > up-to-date. My previous patch showed the status table, but we could > also just tweak the "Everything up-to-date" to say "Ref X is > up-to-date". I think this is a sane thing to do in any case. > 2. Introduce a "push.warnMatch" config option, which can be set to one > of: > > - "none"; the current behavior > > - "branches"; mention all unmatched refs which are in refs/heads Doesn't this assume that among many existing branches, what are not pushed are minority (hence it is easier to spot the presense of the interesting branch in the output, than to spot the absense of the list of updated ones)? I am not convinced if that is the case, and I doubt it would be very useful. An alternative might be to show the usual list of refs with [up to date] marks even when we currently say "Everything up-to-date", like "push -v" does. I.e. instead of: $ git push ko Everything up-to-date we can say $ git push ko To: kernel.org:/pub/scm/git/git.git = [up to date] maint -> maint = [up to date] master -> master = [up to date] next -> next = [up to date] pu -> pu omitting "Pushing to $where" at the beginning and "Everything up-to-date" at the end of the "push -v" output. > - "head"; mention the current HEAD if it is unmatched This might be a sane thing to do unconditionally, especially if it can be done without taking too much screen real estate. ^ permalink raw reply [flat|nested] 6+ messages in thread
* Re: [PATCH/RFC] improve no-op push output 2012-06-04 16:35 ` Junio C Hamano @ 2012-06-05 10:10 ` Jeff King 0 siblings, 0 replies; 6+ messages in thread From: Jeff King @ 2012-06-05 10:10 UTC (permalink / raw) To: Junio C Hamano; +Cc: git, Matthieu Moy On Mon, Jun 04, 2012 at 09:35:30AM -0700, Junio C Hamano wrote: > Jeff King <peff@peff.net> writes: > > > So I think we would really need to break down each potentially confusing > > case, and come up with a solution for each. I think we can divide the > > push configuration into three cases: matching, single (which includes > > "upstream", "simple", and "current"), or custom refspecs. Let's ignore > > the final one for now. It's relatively rare, and probably the most > > common use is mirroring (in which case we know we pushed everything, > > anyway). And then we have a few potential confusing situations: > > Does "single" include "upstream", "simple" and "current", or does it > consists of these three and nothing else? I think it is the latter, > and I mean the latter in the remainder of my response. Specifically, > I would exclude the case where you have remote.$there.push that only > pushes one ref from "single". Yes, I think it is just those cases in my analysis (which is different from my original patch). We can probably assume that somebody specifying a refspec on the command line, or one with configured push refspecs, would know what they are doing. > > 1. We are on a detached HEAD; the user expects their current work to > > be pushed, but it is not. With the "single" cases, we should > > already error out. > > All the "single" cases should error out when run on a detached HEAD > (otherwise they should be fixed). They do (I just checked). However, "current" only fails because the right-hand-side HEAD is not fully qualified, and thus the message is somewhat daunting: error: unable to push to unqualified destination: HEAD The destination refspec neither matches an existing ref on the remote nor begins with refs/, and we are unable to guess a prefix based on the source ref. error: failed to push some refs to ... whereas the simple/upstream case says: fatal: You are not currently on a branch. To push the history leading to the current (detached HEAD) state now, use git push github HEAD:<name-of-remote-branch> It might be nicer for "current" to print the same message (the advice should be identical in both cases). > > For the "matching" case, we don't want to error > > out, but it might be worth printing a warning to say "by the way, > > your HEAD is detached", whether everything is up-to-date or not. > > Both "matching" and "specific remote.$there.push" cases are "it does > not matter what branch happens to be checked out; I am giving you > the set of refs I want to push out by default", so even though you > said you ignore the specific refspec case, they fall into the same > category here. Yes, I think they do collapse to the same case. I omitted custom refspecs out of simplicity in my analysis. But if they fall into the same slots, then all the better. > I find the above an unnecessarily roundabout way to help people who > expect the current branch to always be involved in an unnamed push > to say "your HEAD is detached"; it requires them to be intelligent > enough to connect "HEAD detached", "no current branch" and "hence > nothing pushed". A more direct way "detached HEAD not pushed" may > be better. Agreed. That is what I intended, but I obviously didn't say it very well. > > 3. We are on a branch; the user expects some other branch X to be > > pushed, but it is not. > > ... So I think the right solution is to just > > be more specific; say "X is up-to-date", or just show the > > single-line status table. > [...] > > For the "matching" case, it's much harder. > > > > If we show them the whole description of what happened and hoping > > they notice that their branch is not included. When something > > actually gets pushed, we show the status table already, and they > > may or may not look through it to find the branch in question > > (indeed, they may not even be trying to push X at the time, but > > rather may later say "Hey, I thought I pushed everything; why is X > > not here?). > > We can cover both the "here are the list" and the "everything > up-to-date" cases with "(current branch not pushed)" (or "detached > HEAD not pushed)". That helps with only the current branch. The point of this scenario is that it is some random branch. Like: git checkout topic hack hack hack git checkout master hack hack hack git -c push.default=matching push Git really has no way of knowing that it's interesting to you that "topic" didn't get pushed. The right answer might be to simply discount this scenario. I think it's probably less common than the "I thought I was pushing my current HEAD" confusion which comes up. > > 1. For a single-ref push, always mention the ref name, even if it is > > up-to-date. My previous patch showed the status table, but we could > > also just tweak the "Everything up-to-date" to say "Ref X is > > up-to-date". > > I think this is a sane thing to do in any case. Here, do you mean when there is a single ref attempted, or do you really mean "when we invoked current, simple, or upstream push.default?" > > 2. Introduce a "push.warnMatch" config option, which can be set to one > > of: > > > > - "none"; the current behavior > > > > - "branches"; mention all unmatched refs which are in refs/heads > > Doesn't this assume that among many existing branches, what are not > pushed are minority (hence it is easier to spot the presense of the > interesting branch in the output, than to spot the absense of the > list of updated ones)? I am not convinced if that is the case, and I > doubt it would be very useful. Yes, which is why it is configurable. For some workflows, you will push most of your branches, and hold back only a few as private. In that case, warning on unmatched branches would be helpful. For somebody like you, pushing to ko would look awful, because you hold back all of the topic branches (even though you push them elsewhere, it is not relevant to the ko "matching" push). So I would certainly never make "branches" the default. I am somewhat lukewarm on it as a concept anyway; these possible directions were not "we should definitely do this" but just "here is an initial sketch of some ideas I had". > An alternative might be to show the usual list of refs with [up to date] > marks even when we currently say "Everything up-to-date", like "push -v" > does. I.e. instead of: > > $ git push ko > Everything up-to-date > > we can say > > $ git push ko > To: kernel.org:/pub/scm/git/git.git > = [up to date] maint -> maint > = [up to date] master -> master > = [up to date] next -> next > = [up to date] pu -> pu > > omitting "Pushing to $where" at the beginning and "Everything up-to-date" > at the end of the "push -v" output. But that has the opposite verbosity problem as above. If you have a lot of branches, most of which have not been updated, then we will print a lot of useless noise, hiding the actual interesting ref updates. If you are proposing to do it only when everything is up-to-date, that is slightly better. In that case, you are not hiding real ref updates amidst the noise. But it is still very noisy. And it does not really accomplish much, if your point is to show the user that the thing they might have wanted to push was omitted. > > - "head"; mention the current HEAD if it is unmatched > > This might be a sane thing to do unconditionally, especially if it > can be done without taking too much screen real estate. Yeah. Of the three values, I would probably suggest "head" as the default. With "none" for people who want to say "shut up git, I am fully aware of how matching works", and "branches" for people who want to be verbosely informed. But if we drop the "branches" setting, and the message is unobtrusive, it may not be worth having it configurable at all. -Peff ^ permalink raw reply [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).