Re: get upstream branch

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



On Mon, Dec 08, 2008 at 09:35:08PM -0800, Junio C Hamano wrote:

> I do not think there is any plumbing facility to get that information, as
> such "upstream/parent" concept did not exist back then when building the
> whole Porcelain by scripting was the norm.

In one of my scripts I do something like this (actually this is not
straight from my script, as the operation there is "find all pairs of
local/remote branches" and this is "find the current upstream"):

  ref=`git symbolic-ref HEAD`
  head=${ref#refs/heads/}
  remote=`git config branch.$head.remote`
  branch=`git config branch.$head.merge`
  echo refs/remote/$remote/${branch#refs/heads/}

And obviously this is missing error checking for the detached HEAD
(symbolic-ref should fail) and no tracking branch ($remote and/or $branch
will be empty) cases.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux