0

I am looking at a repository to which I contribute, going through the commit history manually, and I see "open" (unmerged) branches. For example, the branch my-branch is "unmerged" because this command:

$ git log $(git merge-base origin/master origin/my-branch)..origin/my-branch

reveals the commits on my-branch that are not merged. So I was treating this as an unmerged branch. Another contributor said, "no, it's been merged, using squash." Sure enough, if I look at the branch list (it's hosted at Bitbucket), it does not show up in the list. It doesn't show up in the "Active" list and it doesn't show up in the "Merged" list either.

So it has been merged, or closed, or something, according to Bitbucket. (But it's still in the clones coming from Bitbucket.) Is that a Bitbucket feature -- that's somehow keeping track of squash merges done through its interface? Is it a git feature, the concept of "active?" What does it mean?

Update: According to Bitbucket's blog entry about the squash feature, the feature is not available for Mercurial because in Mercurial it requires "obsolescence markers" (presumably to mark the squashed commits as obsolete?). Does git have its own version of whatever this is?

David P. Caldwell
  • 3,394
  • 1
  • 19
  • 32
  • `git merge squash` is a [GIT feature.](https://stackoverflow.com/questions/5308816/how-to-use-git-merge-squash) – Liam Aug 24 '18 at 14:48
  • Right, that's a `git` feature. But how does Bitbucket know the squashed merge is not "active?" And does `git` also know that? – David P. Caldwell Aug 24 '18 at 14:49
  • I don't know what "active" means. I'm guessing this is some bitbucket hoodo?! In GIT a branch is a branch. Squashed branches don't get merged the commits just get cherry picked across. I'm not really sure what your asking? – Liam Aug 24 '18 at 14:52
  • Here's an explanation on squash https://blog.github.com/2016-04-01-squash-your-commits/ – Liam Aug 24 '18 at 14:52
  • Cool, thank you. Yeah, I understand what squashing is. (But maybe other readers don't!) I'll be surprised if there's some sort of Bitbucket magic here, but maybe you're right! (That's why I asked.) I think the other possibility is that there's some kind of `git` branch state you and I don't know about, and Bitbucket is marking the branch that way when someone does a squash through its interface. – David P. Caldwell Aug 24 '18 at 14:56
  • Branches 100% do not have "state" in GIT. Can you show this "Active" whatever it is? – Liam Aug 24 '18 at 15:10
  • See, e.g., https://bitbucket.org/atlassian/log4j1/branches/ – David P. Caldwell Aug 24 '18 at 16:12
  • 2
    Git does not have obsolescence markers (those are a Mercurial Evolve extension feature). Bitbucket *defines* "active"/"not-active" so they get to make up what it means and you probably should ignore it entirely. :-) If it's like GitHub's definition of "active" it just means "the tip commit is not all that old" which is only a slightly-useful measure. – torek Aug 24 '18 at 16:27

1 Answers1

0

If a branch has commits that are not also part of the main branch, then that branch is listed as "active". If a branch does not have any commits that aren't also on the main branch, then that branch is listed as "merged". If a branch is not listed at all, then it either hasn't been pushed to Bitbucket yet or it was deleted in the Bitbucket UI.

The branch list doesn't really care whether there was squashing or fast-forwarding or not when a given branch was merged. It only cares that the branch was or wasn't deleted, and that the head or tip of the branch has commits that aren't on the main branch.

Jim Redmond
  • 4,139
  • 1
  • 14
  • 18