Re: [PATCH 2/3] branch: suggest how to undo a --set-upstream when given one branch
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:54:14
Jonathan Nieder [off-list ref] writes:
Message should go on stderr and be guarded with an advice option (see
advice.c).
Like this:
const char *arg;
...
if (argc != 1 || !advice_old_fashioned_set_upstream)
return 0; /* ok. */
arg = argv[0];
advise("If you wanted to make '%s' track '%s', do this:",
head, arg);
if (branch_existed)
advise(" $ git branch --set-upstream-to='%s' '%s'",
old_upstream, arg);
else
advise(" $ git branch -d '%s'", arg);
advise(" $ git branch --set-upstream-to='%s'", arg);
If an argument contains single-quotes, the quoting will be wrong, but
that's probably not worth worrying about.In principle, I would agree that this is a kind of thing that falls into the "advice" categiry, but with the fact that we plan to deprecate "--set-upstream", combined with the fact that [PATCH 1/3] introduced the new option --set-upstream-to together with a short and sweet -u synonym already at this point in the series, I think it is better to leave them emitted unconditionally to the standard error stream, in order to train users away from using the old option that has its arguments wrong (the option does not take an argument it should, and makes the command line to look as if it takes two branch arguments in the wrong order). Actually, we should probably add the deprecation warning in this commit.