Re: [PATCH v6 2/3] branch: report invalid tracking branch as broken
From: Junio C Hamano <hidden>
Date: 2016-06-15 22:58:25
Jiang Xin [off-list ref] writes:
If a branch has been set to track a upstream, but the upstream branch
is missing or invalid, the tracking info is silently ignored in the
output of some commands such as "git branch -vv" and "git status",
as if there were no such tracking settings.
Junio suggested broken upstream should be reported [1]. E.g.
$ git branch -v -v
master e67ac84 initial
* topic 3fc0f2a [topicbase: broken] topicI'd assume this is s/broken/gone/ to match what the rest of the log message says?
$ git status
# On branch topic
# Your branch is based on a broken ref 'topicbase'.
# (use "git branch --unset-upstream" to fixup)
...
$ git status -b -s
## topic...topicbase [broken]
...
In order to do like that, we need to distinguish these three cases
(i.e. no tracking, with configured but no longer valid tracking, and
with tracking) in function stat_tracking_info(). So the refactored
function stat_tracking_info() has three return values: -1 (with "gone"
base), 0 (no base), and 1 (with base).