git/list[1] front-page[2] threads[3] people[4] search[5] about
 

RE: Tracking parent branches in Git

From
rsbecker@nexbridge.com <rsbecker@nexbridge.com>
Date
Jul 1, 2019, 20:12 UTC
Message-ID
<007d01d53049$4db5bec0$e9213c40$@nexbridge.com>
In-Reply-To
<CAGyf7-EBs_cRB5R7RyQhX0ZDNqLZWVJEYEtqkGRGJykRqKKTvA@mail.gmail.com>

On July 1, 2019 3:48 PM, Bryan Turner wrote: On Mon, Jul 1, 2019 at 12:35 PM Junio C Hamano <gitster@pobox.com> wrote:

Show 17 quoted lines
>
> Eric Kulcyk <Eric.kulcyk@microsoft.com> writes:
>
> [Overly long lines are not appreciated around here.]
>
> > We would like to track parent branches so that creating pull 
> > requests can automatically determine the correct branch to merge 
> > against.  I understand that this would require tracking more 
> > information than is currently available right now in git.  Also, it 
> > seems that if some cases, it is not possible to determine a parent 
> > branch, in which case it would just be empty/null.
>
> Do you mean by "parent branch" what people usually call "upstream 
> branch" (i.e. when that branch on the other side gains more commits 
> independent from what you have been working on, then you would want to 
> rebase your work on top of the updated state of that branch on the 
> other side) around here?
I suspect the question is in regards to "What branch did I create my local branch from?", especially given the pull request reference.

In other words, when I locally do: git checkout --no-track -b bturner-some-bugfix origin/release/5.16

release/5.16 is the "parent branch" of my bugfix branch and, when I push my branch and try to open a pull request, release/5.16 is a _likely_ target for where I'd want to merge it. There may be a remote in the name, a la "origin" in my example, or it might be created on top of some other local branch. It's a common feature request for Bitbucket Server[1], for example, to automatically select the "right" target branch for a new pull request based on the ancestry of the branch in question--except branches have no ancestry. (This sort of metadata could potentially offer some benefits for building commit graphs (referring to UI treatments for visualizing the DAG, rather than Git's "commit-graph" functionality), depending on how it was implemented, since it would make branch points more stable.)

Since branches are ephemeral names and have no intrinsic metadata of their own (unlike, say, annotated tags or commits), I suspect implementing something like this may be more complicated than it might initially appear, especially if said metadata needs to be communicated to remote repositories (which implies it might require changes to the wire protocol as well).

Best regards, Bryan Turner

[1] https://jira.atlassian.com/browse/BSERV-7116
Show 15 quoted lines
>
> Perhaps "git help glossary", look
> for "upstream branch" and start from there?  The entry mentions the 
> configuration variables used to keep track of that information, which 
> are described in "git help config", I think.
>
> > If I made a change to track the parent branch for each branch, would 
> > this feature be accepted/welcomed as part of git, even if it off by 
> > default?
>
> Regardless of what is being proposed, this is often not a very useful 
> question.  Something worth doing for yourself is worth doing whether 
> others also find it useful ;-)  And others usually do not have enough 
> information to judge if such a change is welcome until seeing it in a 
> bit more concrete form.
Was there not, at some point in recent history (2019), a discussion about storing extra arbitrary data associated with a branch or other objects? My thought for satisfying what Eric was originally proposing is to store the root commit associated with the original branch HEAD when checkout -b/branch was done to create the branch. Presumably another datum could store the branch that the branch HEAD was on, but that may not be unique - which is a root part of the problem with this request, although it might be something that the user could select/specify - not sure how - at branch creation. 
But aside from that both of the above are transient relative to the new branch and by the time you wanted to create a Pull Request, the information you originally wanted could irrelevant - at least to git. If I was the product manager on this, I would suggest going to GitLab, GitHub, or BitBucket and asking for some augmented capability of branch creation, that stores the data for future Pull Request management - instead of doing this in core git because of the transient nature of the relationship between a branch and a commit.

My $0.02. Randall

Previous: Bryan TurnerNext: Philip Oakley
Message 4 of 13 in “Tracking parent branches in Git”
  1. Eric KulcykJul 1, 2019
  2. Junio C HamanoJul 1, 2019
  3. Bryan TurnerJul 1, 2019
  4. rsbecker@nexbridge.comJul 1, 2019
  5. Philip OakleyJul 2, 2019
  6. Junio C HamanoJul 2, 2019
  7. Bryan TurnerJul 2, 2019
  8. Theodore Ts'oJul 2, 2019
  9. Philip OakleyJul 3, 2019
  10. Eckhard MaaßJul 1, 2019
  11. Eric KulcykJul 1, 2019
  12. Eric KulcykJul 1, 2019
  13. Andreas KreyJul 2, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.