diff options
author | Damien Robert <damien.olivier.robert+git@gmail.com> | 2019-04-16 14:16:46 +0200 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-04-18 09:17:41 +0900 |
commit | c646d0934ec2056d816ad1ecc23f6620aba2c6da (patch) | |
tree | f1ceb4ff5a2864487bfaa35e35a3173d0a267ca3 /ref-filter.c | |
parent | mingw: allow building with an MSYS2 runtime v3.x (diff) | |
download | tgif-c646d0934ec2056d816ad1ecc23f6620aba2c6da.tar.xz |
ref-filter: use correct branch for %(push:track)
In ref-filter.c, when processing the atom %(push:track), the
ahead/behind values are computed using `stat_tracking_info` which refers
to the upstream branch.
Fix that by introducing a new flag `for_push` in `stat_tracking_info`
in remote.c, which does the same thing but for the push branch.
Update the few callers of `stat_tracking_info` to handle this flag. This
ensure that whenever we use this function in the future, we are careful
to specify is this should apply to the upstream or the push branch.
This bug was not detected in t/t6300-for-each-ref.sh because in the test
for push:track, both the upstream and the push branches were behind by 1
from the local branch. Change the test so that the upstream branch is
behind by 1 while the push branch is ahead by 1. This allows us to test
that %(push:track) refers to the correct branch.
This changes the expected value of some following tests (by introducing
new references), so update them too.
Signed-off-by: Damien Robert <damien.olivier.robert+git@gmail.com>
Reviewed-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'ref-filter.c')
-rw-r--r-- | ref-filter.c | 6 |
1 files changed, 4 insertions, 2 deletions
diff --git a/ref-filter.c b/ref-filter.c index 422a9c9ae3..cadafec283 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -1388,7 +1388,8 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname, *s = show_ref(&atom->u.remote_ref.refname, refname); else if (atom->u.remote_ref.option == RR_TRACK) { if (stat_tracking_info(branch, &num_ours, &num_theirs, - NULL, AHEAD_BEHIND_FULL) < 0) { + NULL, atom->u.remote_ref.push, + AHEAD_BEHIND_FULL) < 0) { *s = xstrdup(msgs.gone); } else if (!num_ours && !num_theirs) *s = xstrdup(""); @@ -1406,7 +1407,8 @@ static void fill_remote_ref_details(struct used_atom *atom, const char *refname, } } else if (atom->u.remote_ref.option == RR_TRACKSHORT) { if (stat_tracking_info(branch, &num_ours, &num_theirs, - NULL, AHEAD_BEHIND_FULL) < 0) { + NULL, atom->u.remote_ref.push, + AHEAD_BEHIND_FULL) < 0) { *s = xstrdup(""); return; } |