Re: [question] how can i verify whether a local branch is tracking a remote branch?
- From
Jeff King <peff@peff.net>
- Date
- Apr 6, 2009, 21:29 UTC
- Message-ID
- <20090406212935.GB882@coredump.intra.peff.net>
- In-Reply-To
- <49D9EEE2.3000607@drmicha.warpmail.net>
On Mon, Apr 06, 2009 at 02:00:34PM +0200, Michael J Gruber wrote:
Show 13 quoted lines
> > + if (!strcmp(name, "tracking")) {
> > + struct branch *branch;
> > + if (prefixcmp(ref->refname, "refs/heads/"))
> > + continue;
> > + branch = branch_get(ref->refname + 11);
> > + if (branch && branch->merge && branch->merge[0] &&
> > + branch->merge[0]->dst)
> > + v->s = branch->merge[0]->dst;
>
> Isn't that missing out on those cases where you --track (i.e. follow) a
> local (upstream) branch? See
> 5e6e2b4 (Make local branches behave like remote branches when --tracked,
> 2009-04-01)I thought the logic was in branch_get to handle it. And indeed:
$ git checkout --track -b new master Branch new set up to track local branch master. Switched to a new branch "new" $ git for-each-ref --format='%(refname) %(tracking)' refs/heads/master refs/heads/new refs/heads/master
So it will point either to something in refs/remotes or in refs/heads, as applicable.
> If we hook it up into git-branch there would be to useful directions:
The difference being that git-branch is porcelain and git-for-each-ref is plumbing. So they really serve different purposes.
> - "git branch --follows foo" could list all branches which follow foo, > analogous to --contains. It gives you all your feature work on top of > foo, all branches affected by rebasing foo etc.
Sure, that would probably be useful.
> - "git branch --whatever foo" could list the branch whoch foo follows. > > I just notices that "git branch -v foo" does not give me the "-v" output > for foo... Improving that would open up the possibility to go for -vv foo.
See the "-vv" patch I just posted elsewhere in the thread.
-Peff