git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* Tracking parent branches in Git
@ 2019-07-01 18:50 Eric Kulcyk
  2019-07-01 19:34 ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Eric Kulcyk @ 2019-07-01 18:50 UTC (permalink / raw)
  To: git@vger.kernel.org

Hello,

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.  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?

Thanks,
Eric

:(){:|:&};:

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 18:50 Tracking parent branches in Git Eric Kulcyk
@ 2019-07-01 19:34 ` Junio C Hamano
  2019-07-01 19:48   ` Bryan Turner
  0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2019-07-01 19:34 UTC (permalink / raw)
  To: Eric Kulcyk; +Cc: git@vger.kernel.org

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?  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.

Thanks.


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 19:34 ` Junio C Hamano
@ 2019-07-01 19:48   ` Bryan Turner
  2019-07-01 20:12     ` rsbecker
                       ` (2 more replies)
  0 siblings, 3 replies; 13+ messages in thread
From: Bryan Turner @ 2019-07-01 19:48 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Eric Kulcyk, git@vger.kernel.org

On Mon, Jul 1, 2019 at 12:35 PM Junio C Hamano <gitster@pobox.com> wrote:
>
> 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

>
> 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.
>
> Thanks.
>

^ permalink raw reply	[flat|nested] 13+ messages in thread

* RE: Tracking parent branches in Git
  2019-07-01 19:48   ` Bryan Turner
@ 2019-07-01 20:12     ` rsbecker
  2019-07-02  9:23       ` Philip Oakley
  2019-07-01 20:40     ` Eckhard Maaß
  2019-07-02  6:42     ` Andreas Krey
  2 siblings, 1 reply; 13+ messages in thread
From: rsbecker @ 2019-07-01 20:12 UTC (permalink / raw)
  To: 'Bryan Turner', 'Junio C Hamano'
  Cc: 'Eric Kulcyk', git

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:
>
> 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

>
> 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


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 19:48   ` Bryan Turner
  2019-07-01 20:12     ` rsbecker
@ 2019-07-01 20:40     ` Eckhard Maaß
  2019-07-01 20:58       ` Eric Kulcyk
  2019-07-02  6:42     ` Andreas Krey
  2 siblings, 1 reply; 13+ messages in thread
From: Eckhard Maaß @ 2019-07-01 20:40 UTC (permalink / raw)
  To: Bryan Turner; +Cc: Junio C Hamano, Eric Kulcyk, git@vger.kernel.org

On Mon, Jul 01, 2019 at 12:48:16PM -0700, Bryan Turner wrote:
> 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).

You can right now give meta data of your choice with --push-option to
the push command. The Gerrit system makes use of that already. However,
this would not be intrinsic to Git, but the serve needs to react on
those options. And it should be in good company with suitable client
tools.

Take care,
Eckhard

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 20:40     ` Eckhard Maaß
@ 2019-07-01 20:58       ` Eric Kulcyk
  2019-07-01 21:04         ` Eric Kulcyk
  0 siblings, 1 reply; 13+ messages in thread
From: Eric Kulcyk @ 2019-07-01 20:58 UTC (permalink / raw)
  To: Eckhard Maaß, Bryan Turner; +Cc: gitster@pobox.com, git@vger.kernel.org

> > [Overly long lines are not appreciated around here.]

Thanks for the feedback, is there an email client or tool
that can format the lines correctly?
> >
> > > 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.

Yes, this is what I meant.
>
> 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).
>
> You can right now give meta data of your choice with --push-option to
> the push command. The Gerrit system makes use of that already. However,
> this would not be intrinsic to Git, but the serve needs to react on
> those options. And it should be in good company with suitable client
> tools.

@Eckhard, is that documented somewhere?  I don't see it on
https://git-scm.com/docs/git-push/1.6.4.1

>
> Take care,
> Eckhard
>
> Best regards,
> Bryan Turner
>
> [1] https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjira.atlassian.com%2Fbrowse%2FBSERV-7116&amp;data=02%7C01%7CEric.kulcyk%40microsoft.com%7Ca780a740f5894ba5ce6508d6fe607317%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636976088301830933&amp;sdata=1KrFM%2BLcKoa3FCc1F86jIVZBrIUGi%2B6ad7CuA8ekAUY%3D&amp;reserved=0
>
> >
> > 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.

I wanted to get a some thoughts before I worked out the details.
The feature is of little use if no one is using the version of git with it
since most everyone uses standard distros of git.
>
> 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.

Multiple branches can have the same commit, but only one branch can
be checked out at once, right?  Then the parent branch would be the
branch you were on when you ran checkout -b.  That branch might change
and no longer be of use, but it seems like in practice that is not the case.
New features are usually created off of a local branch and then PR'd
back to the upstream version of that branch.

Thanks!
Eric

________________________________________
From: Eckhard Maaß <eckhard.s.maass@googlemail.com>
Sent: Monday, July 1, 2019 1:40 PM
To: Bryan Turner
Cc: gitster@pobox.com; Eric Kulcyk; git@vger.kernel.org
Subject: Re: Tracking parent branches in Git

On Mon, Jul 01, 2019 at 12:48:16PM -0700, Bryan Turner wrote:
> 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).

You can right now give meta data of your choice with --push-option to
the push command. The Gerrit system makes use of that already. However,
this would not be intrinsic to Git, but the serve needs to react on
those options. And it should be in good company with suitable client
tools.

Take care,
Eckhard

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 20:58       ` Eric Kulcyk
@ 2019-07-01 21:04         ` Eric Kulcyk
  0 siblings, 0 replies; 13+ messages in thread
From: Eric Kulcyk @ 2019-07-01 21:04 UTC (permalink / raw)
  To: Eckhard Maaß, Bryan Turner; +Cc: gitster@pobox.com, git@vger.kernel.org


> > You can right now give meta data of your choice with --push-option to
> > the push command. The Gerrit system makes use of that already. However,
> > this would not be intrinsic to Git, but the serve needs to react on
> > those options. And it should be in good company with suitable client
> > tools.

> @Eckhard, is that documented somewhere?  I don't see it on 
> https://git-scm.com/docs/git-push/1.6.4.1

Interestingly a Google search for git --push-option turns up old documentation first,
I found the newer docs.  Don't you still need a way to store this data locally?
For instance, a wrapper around git checkout could record the branch.
However, you would be unable to use vanilla git check out if you want to do rely upon the data.










From: Eric Kulcyk

Sent: Monday, July 1, 2019 1:58 PM

To: Eckhard Maaß; Bryan Turner

Cc: gitster@pobox.com; git@vger.kernel.org

Subject: Re: Tracking parent branches in Git

 


> > [Overly long lines are not appreciated around here.]



Thanks for the feedback, is there an email client or tool

that can format the lines correctly?

> >

> > > 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.



Yes, this is what I meant.

>

> 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).

>

> You can right now give meta data of your choice with --push-option to

> the push command. The Gerrit system makes use of that already. However,

> this would not be intrinsic to Git, but the serve needs to react on

> those options. And it should be in good company with suitable client

> tools.



@Eckhard, is that documented somewhere?  I don't see it on

https://git-scm.com/docs/git-push/1.6.4.1



>

> Take care,

> Eckhard

>

> Best regards,

> Bryan Turner

>

> [1] 
https://nam06.safelinks.protection.outlook.com/?url=https%3A%2F%2Fjira.atlassian.com%2Fbrowse%2FBSERV-7116&amp;data=02%7C01%7CEric.kulcyk%40microsoft.com%7Ca780a740f5894ba5ce6508d6fe607317%7C72f988bf86f141af91ab2d7cd011db47%7C1%7C0%7C636976088301830933&amp;sdata=1KrFM%2BLcKoa3FCc1F86jIVZBrIUGi%2B6ad7CuA8ekAUY%3D&amp;reserved=0

>

> >

> > 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.



I wanted to get a some thoughts before I worked out the details.

The feature is of little use if no one is using the version of git with it

since most everyone uses standard distros of git.

>

> 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.



Multiple branches can have the same commit, but only one branch can

be checked out at once, right?  Then the parent branch would be the

branch you were on when you ran checkout -b.  That branch might change

and no longer be of use, but it seems like in practice that is not the case.

New features are usually created off of a local branch and then PR'd

back to the upstream version of that branch.



Thanks!

Eric



________________________________________

From: Eckhard Maaß <eckhard.s.maass@googlemail.com>

Sent: Monday, July 1, 2019 1:40 PM

To: Bryan Turner

Cc: gitster@pobox.com; Eric Kulcyk; git@vger.kernel.org

Subject: Re: Tracking parent branches in Git



On Mon, Jul 01, 2019 at 12:48:16PM -0700, Bryan Turner wrote:

> 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).



You can right now give meta data of your choice with --push-option to

the push command. The Gerrit system makes use of that already. However,

this would not be intrinsic to Git, but the serve needs to react on

those options. And it should be in good company with suitable client

tools.



Take care,

Eckhard


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 19:48   ` Bryan Turner
  2019-07-01 20:12     ` rsbecker
  2019-07-01 20:40     ` Eckhard Maaß
@ 2019-07-02  6:42     ` Andreas Krey
  2 siblings, 0 replies; 13+ messages in thread
From: Andreas Krey @ 2019-07-02  6:42 UTC (permalink / raw)
  To: Bryan Turner; +Cc: Junio C Hamano, Eric Kulcyk, git@vger.kernel.org

On Mon, 01 Jul 2019 12:48:16 +0000, Bryan Turner wrote:
...
> 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.

We have simply conventionalized this - the parent relation is in
the branch names. Your bugfix branch would be release/5.16/bturner-some-bugfix
(in the central repo; we don't care how you name it locally), and, because
ref storage, the parent would be release/5.16/master.

You'd just do

  git create-br release/5.16/bturner-some-bugfix

and it would be branched off the corresponding /master, be checked
out, and tracking already been set up. Likewise we have a

  git update

which looks at the upstream name, deduces the parent, and pulls
that in, with a suitable commit message. Finally,

  git mkpullreq

creates a pull request from the current to the parent branch.

(I would like to have a way to make bitbucket server use the same
convention for the default pull request target.)

- Andreas

-- 
"Totally trivial. Famous last words."
From: Linus Torvalds <torvalds@*.org>
Date: Fri, 22 Jan 2010 07:29:21 -0800

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-01 20:12     ` rsbecker
@ 2019-07-02  9:23       ` Philip Oakley
  2019-07-02 17:36         ` Junio C Hamano
  0 siblings, 1 reply; 13+ messages in thread
From: Philip Oakley @ 2019-07-02  9:23 UTC (permalink / raw)
  To: rsbecker, 'Bryan Turner', 'Junio C Hamano'
  Cc: 'Eric Kulcyk', git

On 01/07/2019 21:12, rsbecker@nexbridge.com wrote:
> 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:
>> 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
>
>> 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
>
 From the Git side, maybe one could simply populate the branch 
description with the commit oid and branched-from name at the time of 
branch creation (no doubt set as a core.option).
The field is already there and almost never used - there's no easy way 
(via git command) to populate the description anyway. Plus its a local 
field, keeping Git distributed.
--
Philip

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-02  9:23       ` Philip Oakley
@ 2019-07-02 17:36         ` Junio C Hamano
  2019-07-02 18:52           ` Bryan Turner
  0 siblings, 1 reply; 13+ messages in thread
From: Junio C Hamano @ 2019-07-02 17:36 UTC (permalink / raw)
  To: Philip Oakley
  Cc: rsbecker, 'Bryan Turner', 'Eric Kulcyk', git

Philip Oakley <philipoakley@iee.org> writes:

>> 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...
>> ...
> From the Git side, maybe one could simply populate the branch
> description with the commit oid and branched-from name at the time of
> branch creation (no doubt set as a core.option).
> The field is already there and almost never used - there's no easy way
> (via git command) to populate the description anyway. Plus its a local
> field, keeping Git distributed.

I do not think you want branch.description to get mixed-up in this.

In this whole thread, I have been wondering if I am missing
something crucial, but now I am deeply puzzled why after many people
made comments, nobody raises a question about the "--no-track" thing
in the early message in the thread.

If you do not add that, i.e.

	$ git checout -t -b bturner-some-bugfix origin/release/5.16
        
(note that I added '-t' for illustration, but it should be on by
default when starting from origin/<whatever>), then you'd get in
your configuration file these recorded:

	$ git config --get-regexp 'branch\.bturner-some-bugfix\..*'
	branch.bturner-some-bugfix.remote origin
	branch.bturner-some-bugfix.merge refs/heads/release/5.16

You created 'bturner-some-bugfix' branch out of the 'release/5.16'
branch taken from the remote whose name is 'origin'.  

Is that different from the answer to the question being sought?
What am I missing???


^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-02 17:36         ` Junio C Hamano
@ 2019-07-02 18:52           ` Bryan Turner
  2019-07-02 19:24             ` Theodore Ts'o
  0 siblings, 1 reply; 13+ messages in thread
From: Bryan Turner @ 2019-07-02 18:52 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Philip Oakley, rsbecker, Eric Kulcyk, Git Users

On Tue, Jul 2, 2019 at 10:36 AM Junio C Hamano <gitster@pobox.com> wrote:
>
> In this whole thread, I have been wondering if I am missing
> something crucial, but now I am deeply puzzled why after many people
> made comments, nobody raises a question about the "--no-track" thing
> in the early message in the thread.
>
> If you do not add that, i.e.
>
>         $ git checout -t -b bturner-some-bugfix origin/release/5.16
>
> (note that I added '-t' for illustration, but it should be on by
> default when starting from origin/<whatever>), then you'd get in
> your configuration file these recorded:
>
>         $ git config --get-regexp 'branch\.bturner-some-bugfix\..*'
>         branch.bturner-some-bugfix.remote origin
>         branch.bturner-some-bugfix.merge refs/heads/release/5.16
>
> You created 'bturner-some-bugfix' branch out of the 'release/5.16'
> branch taken from the remote whose name is 'origin'.
>
> Is that different from the answer to the question being sought?
> What am I missing???

Sorry, I should have clarified my "--no-track" in my original message
when I provided the example. I did "--no-track" because if I push
"bturner-some-bugfix" to a server, I'm likely going to do something
like "git push -u origin bturner-some-bugfix" so that my local
"bturner-some-bugfix" branch will track the remote version of itself.
At that point, the remote-tracking information would change from
"release/5.16" to "bturner-some-bugfix" (without any sort of warning,
for whatever that's worth), effectively "losing" the ancestry.

The other issue is that my local remote-tracking information doesn't
help the server I'm talking to; it's not shareable. Assuming I could
use remote-tracking to track ancestry, there's still no way to
communicate that to the server so that it could know, when I go to
create a pull request for "bturner-some-bugfix", that it's tracking
"release/5.16" in my local repository.

I could certainly be misunderstanding the request, but I think it's
asking for something less ephemeral--and more shareable--than
remote-tracking, and it seems logical to want to be able to retain
ancestry while still using remote-tracking setup such that local
branches still track the remote version of themselves, rather than
some other (albeit related) branch.

Best regards,
Bryan Turner

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-02 18:52           ` Bryan Turner
@ 2019-07-02 19:24             ` Theodore Ts'o
  2019-07-03 15:58               ` Philip Oakley
  0 siblings, 1 reply; 13+ messages in thread
From: Theodore Ts'o @ 2019-07-02 19:24 UTC (permalink / raw)
  To: Bryan Turner
  Cc: Junio C Hamano, Philip Oakley, rsbecker, Eric Kulcyk, Git Users

On Tue, Jul 02, 2019 at 11:52:35AM -0700, Bryan Turner wrote:
> Sorry, I should have clarified my "--no-track" in my original message
> when I provided the example. I did "--no-track" because if I push
> "bturner-some-bugfix" to a server, I'm likely going to do something
> like "git push -u origin bturner-some-bugfix" so that my local
> "bturner-some-bugfix" branch will track the remote version of itself.
> At that point, the remote-tracking information would change from
> "release/5.16" to "bturner-some-bugfix" (without any sort of warning,
> for whatever that's worth), effectively "losing" the ancestry.
> 
> The other issue is that my local remote-tracking information doesn't
> help the server I'm talking to; it's not shareable. Assuming I could
> use remote-tracking to track ancestry, there's still no way to
> communicate that to the server so that it could know, when I go to
> create a pull request for "bturner-some-bugfix", that it's tracking
> "release/5.16" in my local repository.

I think the real problem with all of this feature request is that it's
all presuming a particular workflow, and git is currently *not*
strongly opinionated about the workflow.

So for example, if I create a local branch against origin/release/5.16
with a series of fixes, and I'm pushing to a gerrit server for review,
I might need to do something like this:

  git push gerrit HEAD:refs/for/release/5.16%r=reviewer@example.com,%cc=kernel-reviewers@example.com

So the fact that we've recorded the information about the parent
branch when doing a "git checkout -b bugfix origin/release/5.16" is
part of the puzzle, but the other part of the puzzle is knowing what
the destination server is going to want or need.  Internally at $WORK
we have our own internal script that does this automatically, so I
just have to run something like "kdt mail -r reviewer@example.com",
but it's always going to be very workflow-independent.

> I could certainly be misunderstanding the request, but I think it's
> asking for something less ephemeral--and more shareable--than
> remote-tracking, and it seems logical to want to be able to retain
> ancestry while still using remote-tracking setup such that local
> branches still track the remote version of themselves, rather than
> some other (albeit related) branch.

In order for it to be shareable, we have to make some very strong
assumptions about workflow.  It gets worse when people pull from more
than one tree, or there is a series of subtrees.

For example, suppose the 2nd-level lieutenant has a "net" tree, and
the 3rd-level lieutenants have a "sctp" and a "ipsec" tree.  Now let's
assume that there is some common infrastructure branch that both
3rd-level lieutenants need to build off of that comes from some other
2nd-level tree, and so for that development cycle, they first pull
from the top-level tree, and then both 3rd level trees merge in a
branch from the "mm" tree, but then they will be both be sending pull
request emails to the "net" tree.

There will be a whole series of git pulls and git merges that will be
in flight, and just for yucks, let's suppose some trees are do patch
review via email, and some trees are doing patch review via gerrit,
and yet other trees have their maintainer do a quick cursory review at
"git pull" time after the tree sends a git pull request.

What sort of shareable context should git --- which is ignorant of all
of these arrangements --- be preserving?  And presenting to whom?  And
for what goal/purpose?

						- Ted

^ permalink raw reply	[flat|nested] 13+ messages in thread

* Re: Tracking parent branches in Git
  2019-07-02 19:24             ` Theodore Ts'o
@ 2019-07-03 15:58               ` Philip Oakley
  0 siblings, 0 replies; 13+ messages in thread
From: Philip Oakley @ 2019-07-03 15:58 UTC (permalink / raw)
  To: Theodore Ts'o, Bryan Turner
  Cc: Junio C Hamano, rsbecker, Eric Kulcyk, Git Users

On 02/07/2019 20:24, Theodore Ts'o wrote:
> I think the real problem with all of this feature request is that it's
> all presuming a particular workflow, and git is currently*not*
> strongly opinionated about the workflow.
I'd suggest that git does have a clear preference for a workflow that is 
based on the "upstream" view. (e.g. see 'rebase')

While Git tries to avoid being opinionated, it does develop a bias of 
avoiding various common workflows, to the point that they are not even 
well named.

In particular, we have a number of variants of the triangular workflow, 
such as having a personal github fork, and a then also a maintainer's 
repo to complete the triangle [which is even worse for those supporting 
Git-for-Windows because of two level maintenance cascade, with different 
compilation and OS requirements..]. Having three 'origins' is no fun.

There was an attempt to document a triangular flow a while back, but it 
wasn't actually that one. e.g. [1])

The other preference aspect is the tendency to expect users to 'support 
the machine' (e.g. the assume-unchanged file flag, which is commonly 
misunderstood), rather than having a clarity about when Git will support 
the user. Here we (they) are looking for the human readable name of the 
branch that they forked from (and is likely to have been extended 
since), rather than the oid hash of the fork point, though that is 
clearly useful and should be recorded with the branch name as it is 
immutable.

I am cautious about support for Gerrit on the basis that it could 
accidentally reinforce a centralised workflow (to the detriment of 
distributed operation), which should be avoided strongly as a deliberate 
bias.

However the desire to _locally_ record the branch name that the current 
branch was created from is something I would support (which is why I 
suggested the unused branch description...).

Philip

[1] 
https://public-inbox.org/git/5A8F8EE0162B49818813DAEFD68F61DA@PhilipOakley/

(sorry for any delays, I'm still in catch-up mode)

^ permalink raw reply	[flat|nested] 13+ messages in thread

end of thread, other threads:[~2019-07-03 15:58 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-01 18:50 Tracking parent branches in Git Eric Kulcyk
2019-07-01 19:34 ` Junio C Hamano
2019-07-01 19:48   ` Bryan Turner
2019-07-01 20:12     ` rsbecker
2019-07-02  9:23       ` Philip Oakley
2019-07-02 17:36         ` Junio C Hamano
2019-07-02 18:52           ` Bryan Turner
2019-07-02 19:24             ` Theodore Ts'o
2019-07-03 15:58               ` Philip Oakley
2019-07-01 20:40     ` Eckhard Maaß
2019-07-01 20:58       ` Eric Kulcyk
2019-07-01 21:04         ` Eric Kulcyk
2019-07-02  6:42     ` Andreas Krey

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).