On 08/07/2021 19:33, Felipe Contreras wrote:
The only reason I mentioned @{tail} (or @{base}) is to have a better
mental model of what a branch is.
1. A branch is whatever is inside `branch@{base}..branch`
For this part "branch" = some series of commits.
Then this is what I would say is a common misunderstanding.
Yet that may be the difference between what people want the branch to
be, and what it (afaik) technically is.
People indeed tend to thing, I branched at X, so anything before is not
part of the branch.
"--contains" says otherwise.
Thinking of it.
If I look at a feature branch, then my feature starts where I created
the branch. I want my feature branch to represent this.
But if I look at my local master branch (or any tracking branch), I like
to believe that it contains the same as the remote branch.
And well, if we just set the base for the local tracking branch to be
the same as the base for the remote branch that would be fine.
But if (after diverging, due to changes pulled from remote) then, I run
git rebase @{base} @{remote}
then rebase has to skip all the shared commits.
And since rebase also repoints the "base", my local branch then no
longer contains the same as the remote.
So limiting the branch to branch@{base}..branch only works for feature
branches.
So yes, what is a branch? More exactly what does it contain.
Two examples, that to me suggest two answers.
Also if branch@{base}..branch then there is a problem.
- branch@{base} is then correctly not part of the branch
- So immediately after "git switch -c branch" the branch is empty => ok
But if so, then what is the branch head at that time?
The Pointer would point the @{base}, but @base is outside the branch. So
the pointer of the branch points outside the branch?
2. `branch` is the branch head (`branch@{head}`), but it's not the
branch itself
Well technically "branch" is the "pointer" to the head.
Assuming we want "head" to be a commit?
Or do we want head, to be the "branch end" after the last commit? But
then still "branch is the pointer"
The only problem is:
branch is too often used for "the commits contained in the branch". That
is way to common to even try to stop it.
Yet, if branch is used for the content, then we do not have a good term
for the pointer.
For all intents and purposes on the git documentation the branch, the
branch name, and the branch head are used interchangeably, but
semantically speaking they are not the same thing.
I have not proof read all the docs for this....
But I think that "branch name" and "branch head" should or could be used
in a clear single meaning fashion each...
When you change the branch head you are effectively changing the branch.
Well if branch is the pointer, then you change the branch, and head is
being changed.
If branch is the content, then you change the head, and yes the content
changes.