"git branch -v -v" (and "git status") did not distinguish among a
branch that does not build on any other branch, a branch that is in
sync with the branch it builds on, and a branch that is configured
to build on some other branch that no longer exists.
* jx/branch-vv-always-compare-with-upstream:
status: always show tracking branch even no change
branch: report invalid tracking branch as gone
* Return true if there is anything to report, otherwise false.
* Compare a branch with its upstream, and save their differences (number
* of commits) in *num_ours and *num_theirs.
*
* Return 0 if branch has no upstream (no base), -1 if upstream is missing
* (with "gone" base), otherwise 1 (with base).
*/
int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
{
@ -1740,34 +1744,30 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
@@ -1740,34 +1744,30 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
const char *rev_argv[10], *base;
int rev_argc;
/*
* Nothing to report unless we are marked to build on top of
* somebody else.
*/
/* Cannot stat unless we are marked to build on top of somebody else. */
* If what we used to build on no longer exists, there is
* nothing to report.
*/
/* Cannot stat if what we used to build on no longer exists */
base = branch->merge[0]->dst;
if (read_ref(base, sha1))
return 0;
return -1;
theirs = lookup_commit_reference(sha1);
if (!theirs)
return 0;
return -1;
if (read_ref(branch->refname, sha1))
return 0;
return -1;
ours = lookup_commit_reference(sha1);
if (!ours)
return 0;
return -1;
/* are we the same? */
if (theirs == ours)
return 0;
if (theirs == ours) {
*num_theirs = *num_ours = 0;
return 1;
}
/* Run "rev-list --left-right ours...theirs" internally... */
rev_argc = 0;
@ -1809,31 +1809,53 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
@@ -1809,31 +1809,53 @@ int stat_tracking_info(struct branch *branch, int *num_ours, int *num_theirs)
*/
int format_tracking_info(struct branch *branch, struct strbuf *sb)
{
int num_ours, num_theirs;
int ours, theirs;
const char *base;
int upstream_is_gone = 0;
if (!stat_tracking_info(branch, &num_ours, &num_theirs))