# Re: branch description

3 messages from 2008-04-22 to 2008-04-22. Participants: Michael Dressel, Johan Herland, Jakub Narebski.
Thread: https://gitlist.dev/t/13219

## Michael Dressel, 2008-04-22 17:57

Subject: Re: branch description
Message-ID: <alpine.DEB.1.10.0804221945060.3452@pollux.milkiway.cos>
URL: https://gitlist.dev/e/alpine.DEB.1.10.0804221945060.3452%40pollux.milkiway.cos

```

On Friday 18 April 2008, Jakub Narebski wrote:
> Let me sum up here proposals where to put branch description:

what's the opinion of having a new branch object? Actually the tag object 
probably already does the job? This would spoil the elegant light weight 
current branch references. But tags are not that heavy.

In this approach the tags would not reference commits but tags. And tags 
have annotation. The difference to the normal tags would be that these 
tags are referenced from refs/heads/<branch> instead of refs/tags.

I have no clue how involved this change would become and if the benefit 
would justify the effort. I guess using proper objects for branches 
would only be justified if additional advantages could be achieved.

Cheers,
 	Michael

```

## Johan Herland, 2008-04-22 18:46

Subject: Re: branch description
Message-ID: <200804222046.05175.johan@herland.net>
URL: https://gitlist.dev/e/200804222046.05175.johan%40herland.net
In-Reply-To: <alpine.DEB.1.10.0804221945060.3452@pollux.milkiway.cos>

```
On Tuesday 22 April 2008, Michael Dressel wrote:
> On Friday 18 April 2008, Jakub Narebski wrote:
> > Let me sum up here proposals where to put branch description:
>
> what's the opinion of having a new branch object? Actually the tag
> object probably already does the job? This would spoil the elegant
> light weight current branch references. But tags are not that heavy.
>
> In this approach the tags would not reference commits but tags. And
> tags have annotation. The difference to the normal tags would be that
> these tags are referenced from refs/heads/<branch> instead of
> refs/tags.
>
> I have no clue how involved this change would become and if the
> benefit would justify the effort. I guess using proper objects for
> branches would only be justified if additional advantages could be
> achieved.
>
> Cheers,
>  	Michael

Nice idea, but it won't work, simply because branches are moving
targets, whereas tags are not.

To illustrate, here's how things are structured between the refs
(tags/branches) and the object DB:


refs/tags/lighweight  -------------------------> [commit object]

refs/tags/annotated   -----> [tag object] -----> [commit object]

refs/heads/branchname -------------------------> [commit object]


The annotated tag ref holds the SHA1 of the tag object which in turn
holds the SHA1 of the commit object, while the two other ref types
point directly at a commit object. The tag object works on the
assumption that the commit object pointed to by the tag never changes.
That's after all the whole point of a tag.

A branch - on the other hand - is _supposed_ to change. It changes by
adding a new commit on top of the current commit, and updating the
branch ref to point to the new commit. If we kept the branch description
in a tag object, and stuck this between the branch ref and the commit
object, we would suddenly have to rewrite the tag object every time we
added another commit on the branch. This would make commits much more
expensive, not to mention that for every commit you would drop the
tag object pointing to the previous commit, in effect generating one
garbage object per commit. This is clearly not what we want.


...Johan

-- 
Johan Herland, <johan@herland.net>
www.herland.net

```

## Jakub Narebski, 2008-04-22 18:59

Subject: Re: branch description
Message-ID: <m33apdra0w.fsf@localhost.localdomain>
URL: https://gitlist.dev/e/m33apdra0w.fsf%40localhost.localdomain
In-Reply-To: <alpine.DEB.1.10.0804221945060.3452@pollux.milkiway.cos>

```
Michael Dressel <MichaelTiloDressel@t-online.de> writes:

> On Friday 18 April 2008, Jakub Narebski wrote:

> > Let me sum up here proposals where to put branch description:
> >
> > [...]
> 
> what's the opinion of having a new branch object? Actually the tag
> object probably already does the job? This would spoil the elegant
> light weight current branch references. But tags are not that heavy.
> 
> In this approach the tags would not reference commits but tags. And
> tags have annotation. The difference to the normal tags would be that
> these tags are referenced from refs/heads/<branch> instead of
> refs/tags.
> 
> I have no clue how involved this change would become and if the
> benefit would justify the effort. I guess using proper objects for
> branches would only be justified if additional advantages could be
> achieved.

This won't work.  With described (annotated) branches, there are two
pieces of data associated with a branch:
 * commit it points to (branch head)
 * description of a branch

Branch head changes frequently (commit, reset, bisect, rebase), while
description should change rarely.  Those two pieces of data are
independent.  Tag object would unnecessary join/fuse those two
together.


Also, for exach commit on a branch, or for each moving of branch ref
(reset, amend, bisect), you would have to create tag object, which
would accumulate only to be garbage collected some time in the
future...

-- 
Jakub Narebski
Poland
ShadeHawk on #git

```
