All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Randall S. Becker" <rsbecker@nexbridge.com>
To: "'Alexander Mills'" <alexander.d.mills@gmail.com>, <git@vger.kernel.org>
Subject: RE: check if one branch contains another branch
Date: Thu, 7 May 2020 19:31:40 -0400	[thread overview]
Message-ID: <06da01d624c7$acb17090$061451b0$@nexbridge.com> (raw)
In-Reply-To: <CA+KyZp7TELrswPjNgB99BXXHEXi5pRr5bO3g_wy7zBvv1R4Kww@mail.gmail.com>

On May 7, 2020 6:59 PM Alexander Mills, Wrote:
> To: git@vger.kernel.org
> Subject: check if one branch contains another branch
> 
> I am looking for a command:
> 
> 1>  if branch x contains branch y
> 
> right now all I can find is
> 
> 2> if current branch contains commit y
> 
> can someone please accomplish #1 ?
> Crazy hard to find an answer to #1 online.
> The user case is to delete old local branches by comparing them with the
> remote integration branch.
> 
> more info if needed:
> https://stackoverflow.com/questions/61669056/how-to-determine-if-
> integration-branch-contains-feature-branch

Looking at this slightly differently, if you try to delete a branch, git branch -d feature-branch, and the branch has not been merged, then the delete will fail. A simple way of looking at it is if the HEAD of the branch has no successor commits then it is not merged (not 100% decisive, but git branch -d is). It is not really that a branch has been merged, but that a commit has successors, meaning that it has been merged. However, unless you are using GitLab, a git merge --squash will not answer your question even if the branch was merged.

A better way of looking at this is in terms of Pull (GitHub, BitBucket) or Merge (GitLab) requests. Has there been a Pull Request for a branch and has the branch been closed? Meaning that when you do a git fetch --prune, your merged/deleted branches go away unless you are on that branch. Looking at the Pull Request history is much more useful in determining whether a branch has been integrated into a main development branch or production branch in a GitFlow process.

It is a different way of looking at the problem, but IMHO, a more representative way when taking developers and deployment into account.

Regards,
Randall


  parent reply	other threads:[~2020-05-07 23:31 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2020-05-07 22:59 check if one branch contains another branch Alexander Mills
2020-05-07 23:08 ` Junio C Hamano
2020-05-07 23:12   ` Alexander Mills
2020-05-07 23:15     ` Alexander Mills
2020-05-07 23:24     ` brian m. carlson
2020-05-07 23:28       ` Alexander Mills
2020-05-07 23:47         ` brian m. carlson
2020-05-07 23:31 ` Randall S. Becker [this message]
2020-05-07 23:37   ` Alexander Mills
2020-05-07 23:41     ` Junio C Hamano
2020-05-08  1:01     ` Alexander Mills
2020-05-08 12:07       ` Randall S. Becker

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='06da01d624c7$acb17090$061451b0$@nexbridge.com' \
    --to=rsbecker@nexbridge.com \
    --cc=alexander.d.mills@gmail.com \
    --cc=git@vger.kernel.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.