From: Jeff King <peff@peff.net>
To: Raphael Kubo da Costa <raphael.kubo.da.costa@intel.com>
Cc: git@vger.kernel.org
Subject: Re: [PATCH v3] for-each-ref: Always check stat_tracking_info()'s return value.
Date: Sat, 3 Jan 2015 06:41:13 -0500 [thread overview]
Message-ID: <20150103114113.GC27793@peff.net> (raw)
In-Reply-To: <1420232513-13867-1-git-send-email-raphael.kubo.da.costa@intel.com>
On Fri, Jan 02, 2015 at 11:01:53PM +0200, Raphael Kubo da Costa wrote:
> In this case, num_ours and num_theirs had undefined values and a call to
> `git for-each-ref --format="%(upstream:track)"` could print spurious
> values such as
>
> [behind -111794512]
> [ahead 38881640, behind 5103867]
>
> even for repositories with one single commit.
>
> We now properly verify stat_tracking_info()'s return value and do not
> print anything if it returns -1. This behavior also matches the
> documentation ("has no effect if the ref does not have tracking
> information associated with it").
Thanks, this iteration looks good to me, and this is definitely a bug
worth fixing.
> +test_expect_success 'Check that :track[short] works when upstream is gone' '
> + git branch --track to_delete master &&
> + git branch --track parent_gone to_delete &&
> + test_when_finished "git branch -D parent_gone" &&
> + git branch -D to_delete &&
> + git for-each-ref --format="%(upstream:track)" refs/heads/parent_gone >actual &&
> + git for-each-ref --format="%(upstream:trackshort)" refs/heads/parent_gone >>actual &&
> + test_cmp expected actual
> +'
I think you could minimize this quite a bit as:
diff --git a/t/t6300-for-each-ref.sh b/t/t6300-for-each-ref.sh
index cba3454..f259c22 100755
--- a/t/t6300-for-each-ref.sh
+++ b/t/t6300-for-each-ref.sh
@@ -340,12 +340,11 @@ cat >expected <<EOF
EOF
test_expect_success 'Check that :track[short] works when upstream is gone' '
- git branch --track to_delete master &&
- git branch --track parent_gone to_delete &&
- test_when_finished "git branch -D parent_gone" &&
- git branch -D to_delete &&
- git for-each-ref --format="%(upstream:track)" refs/heads/parent_gone >actual &&
- git for-each-ref --format="%(upstream:trackshort)" refs/heads/parent_gone >>actual &&
+ test_when_finished "git config branch.master.merge refs/heads/master" &&
+ git config branch.master.merge refs/heads/does-not-exist &&
+ git for-each-ref \
+ --format="%(upstream:track)$LF%(upstream:trackshort)" \
+ refs/heads/master >actual &&
test_cmp expected actual
'
which IMHO makes it a little more obvious what the setup is doing. But I
am OK with it either way.
-Peff
next prev parent reply other threads:[~2015-01-03 11:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2015-01-02 21:01 [PATCH v3] for-each-ref: Always check stat_tracking_info()'s return value Raphael Kubo da Costa
2015-01-03 11:41 ` Jeff King [this message]
2015-01-03 19:19 ` Raphael Kubo da Costa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20150103114113.GC27793@peff.net \
--to=peff@peff.net \
--cc=git@vger.kernel.org \
--cc=raphael.kubo.da.costa@intel.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).