threads / discuss / 34674

How can I automatically create a GIT branch that represents a sequence of tags?

Subject: How can I automatically create a GIT branch that represents a sequence of tags?

## tl;dr

9 messages between Aug 10, 2013 and Aug 11, 2013.

replies: 8people: 6as markdown or json

Kristian Freed· Aug 10, 2013, 22:29 UTC · lore

In our current setup, we have automatic tagging in git of all successful release builds. This makes it easy to go back to stable points in history and compare functionality, check when bugs were introduced etc.

To help with this process further, it would be useful to be able to use git bisect, but as these are just a sequence of tags, not commits on a branch, git bisect will not work as is.

Is there any tooling for automatically recreating a branch from a sequence of tags, where each generated commit is the calculated delta between each two neighbouring tags?

Thanks, Kristian

Fredrik Gustafsson· Aug 10, 2013, 23:20 UTC · re: Kristian Freed · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

On Sat, Aug 10, 2013 at 11:29:45PM +0100, Kristian Freed wrote:
Show 12 quoted lines
> In our current setup, we have automatic tagging in git of all
> successful release builds. This makes it easy to go back to stable
> points in history and compare functionality, check when bugs were
> introduced etc.
> 
> To help with this process further, it would be useful to be able to
> use git bisect, but as these are just a sequence of tags, not commits
> on a branch, git bisect will not work as is.
> 
> Is there any tooling for automatically recreating a branch from a
> sequence of tags, where each generated commit is the calculated delta
> between each two neighbouring tags?

I don't understand, why is it better to find between which tags a error was found and not in what commit. It's much easier to find a bug introduced in a commit than in a tag/release. It sounds like you're doing the bug hunting harder. Could you explain this further?

It would be very hard to do a tool such as you describe, the reason is that there's no sane way to order your tags. Git today show tags alphabetically, all versions does not have a alphabtic order. You could argue that it should be in the order of the tagged commits commit date, however the commits are not ordered by date, an older commit can have a younger commit as a parent. You could say that the tag order is the order you find the tags if you go from a branch and backwards in the history, however how do you then choose which path to take when you find a merge?

My suggestion if you want to do this, is to have your buildtool to checkout a special branch (let's call it tag_branch) do a git reset to get the worktree from the newly tagged commit and commit on that branch once for each tag it's creating, when it creates the tag.

It would be quite easy to make a script that create such branch for you, if you only can sort the tags somehow.

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iveqy@iveqy.com
Michael Haggerty· Aug 11, 2013, 05:16 UTC · re: Fredrik Gustafsson · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

On 08/11/2013 01:20 AM, Fredrik Gustafsson wrote:
Show 6 quoted lines
> [...]
> It would be very hard to do a tool such as you describe, the reason is
> that there's no sane way to order your tags. Git today show tags
> alphabetically, all versions does not have a alphabtic order. [...]
> It would be quite easy to make a script that create such branch for you,
> if you only can sort the tags somehow.
GNU sort has a nice option that can sort this way:
  -V, --version-sort
     Sort by version name and number.  It behaves like a standard sort,
     except that each sequence of decimal digits is treated numerically
     as an index/version number.
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Fredrik Gustafsson· Aug 11, 2013, 06:20 UTC · re: Michael Haggerty · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

On Sun, Aug 11, 2013 at 07:16:30AM +0200, Michael Haggerty wrote:
Show 14 quoted lines
> On 08/11/2013 01:20 AM, Fredrik Gustafsson wrote:
> > [...]
> > It would be very hard to do a tool such as you describe, the reason is
> > that there's no sane way to order your tags. Git today show tags
> > alphabetically, all versions does not have a alphabtic order. [...]
> > It would be quite easy to make a script that create such branch for you,
> > if you only can sort the tags somehow.
> 
> GNU sort has a nice option that can sort this way:
> 
>   -V, --version-sort
>      Sort by version name and number.  It behaves like a standard sort,
>      except that each sequence of decimal digits is treated numerically
>      as an index/version number.

That's a nice feature, I remember we had that one as a feature request for git tag just a few days ago. It works well with git.git version numbers but won't be usefull in this case for git.git since git.git has other tags too (like the gitgui version tags). However if you've a nice namespace for the tags where you only tags versions, it might be an alternative.

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iveqy@iveqy.com
Philip Oakley· Aug 11, 2013, 07:49 UTC · re: Fredrik Gustafsson · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

From: "Fredrik Gustafsson" <iveqy@iveqy.com>
Show 9 quoted lines
> On Sat, Aug 10, 2013 at 11:29:45PM +0100, Kristian Freed wrote:
>> In our current setup, we have automatic tagging in git of all
>> successful release builds. This makes it easy to go back to stable
>> points in history and compare functionality, check when bugs were
>> introduced etc.
>>
>> To help with this process further, it would be useful to be able to
>> use git bisect, but as these are just a sequence of tags, not commits
>> on a branch, git bisect will not work as is.

I was going to say simply use `git describe --contains <sha1>` and check the result is <tag>^0 first and then either skip the commit (git bisect skip) or test it.

Unfortunately I think it will conflict with the binary search style (i.e. a too sparse history with good tags). In such case it may be useful to have an alternate search style but that would be a code update.

Show 11 quoted lines
>>
>> Is there any tooling for automatically recreating a branch from a
>> sequence of tags, where each generated commit is the calculated delta
>> between each two neighbouring tags?
>
> I don't understand, why is it better to find between which tags a 
> error
> was found and not in what commit. It's much easier to find a bug
> introduced in a commit than in a tag/release. It sounds like you're
> doing the bug hunting harder. Could you explain this further?
>

I can see that in many commercial environments that this would be considered "best practice" (which actually equates to common practice, rather than good practice). Obviously in a FOSS environment the developers are willing to use the 'rebase until ready' approaches until their patches are acceptable. In a large corporate it can be that the fixes are locally good but globally bad, hence the extra tagging step.

Show 27 quoted lines
> It would be very hard to do a tool such as you describe, the reason is
> that there's no sane way to order your tags. Git today show tags
> alphabetically, all versions does not have a alphabtic order. You 
> could
> argue that it should be in the order of the tagged commits commit 
> date,
> however the commits are not ordered by date, an older commit can have 
> a
> younger commit as a parent. You could say that the tag order is the
> order you find the tags if you go from a branch and backwards in the
> history, however how do you then choose which path to take when you 
> find
> a merge?
>
> My suggestion if you want to do this, is to have your buildtool to
> checkout a special branch (let's call it tag_branch) do a git reset
> to get the worktree from the newly tagged commit and commit on that
> branch once for each tag it's creating, when it creates the tag.
>
> It would be quite easy to make a script that create such branch for 
> you,
> if you only can sort the tags somehow.
>
> -- 
> Med vänliga hälsningar
> Fredrik Gustafsson
>

-- Philip

Kristian Freed· Aug 11, 2013, 11:13 UTC · re: Fredrik Gustafsson · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

On Sun, Aug 11, 2013 at 12:20 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> I don't understand, why is it better to find between which tags a error
> was found and not in what commit. It's much easier to find a bug
> introduced in a commit than in a tag/release. It sounds like you're
> doing the bug hunting harder. Could you explain this further?
For better or worse, the current state includes a lot of noisy "fixing
tests" type commits which I
would like to automatically skip over when hunting bugs. This is not
great and is being addressed,
but I am trying to make the most of the historical data we have today
- which does contain tags
for all builds that passed automated testing etc but does not have
only good commits on the related
branch.
> My suggestion if you want to do this, is to have your buildtool to
> checkout a special branch (let's call it tag_branch) do a git reset
> to get the worktree from the newly tagged commit and commit on that
> branch once for each tag it's creating, when it creates the tag.

I can see how this would work, but only for future builds. I would need something like it but loop over all existing tags as this is a problem with historical data. Could you please be more specific as to the steps required to automatically form a commit that represents the change between two commits (i.e. tags)?

Thanks, Kristian

Fredrik Gustafsson· Aug 11, 2013, 12:23 UTC · re: Kristian Freed · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

On Sun, Aug 11, 2013 at 12:13:18PM +0100, Kristian Freed wrote:
Show 15 quoted lines
> On Sun, Aug 11, 2013 at 12:20 AM, Fredrik Gustafsson <iveqy@iveqy.com> wrote:
> > I don't understand, why is it better to find between which tags a error
> > was found and not in what commit. It's much easier to find a bug
> > introduced in a commit than in a tag/release. It sounds like you're
> > doing the bug hunting harder. Could you explain this further?
> 
> For better or worse, the current state includes a lot of noisy "fixing
> tests" type commits which I
> would like to automatically skip over when hunting bugs. This is not
> great and is being addressed,
> but I am trying to make the most of the historical data we have today
> - which does contain tags
> for all builds that passed automated testing etc but does not have
> only good commits on the related
> branch.

Thank you, that make sense (even if it's really sad to have such history).

Show 14 quoted lines
> 
> > My suggestion if you want to do this, is to have your buildtool to
> > checkout a special branch (let's call it tag_branch) do a git reset
> > to get the worktree from the newly tagged commit and commit on that
> > branch once for each tag it's creating, when it creates the tag.
> 
> I can see how this would work, but only for future builds. I would
> need something like it but loop
> over all existing tags as this is a problem with historical data.
> Could you please be more specific
> as to the steps required to automatically form a commit that
> represents the change between
> two commits (i.e. tags)?
> 

Create an orphan branch: git checkout --orphan tag_branch

Now for every tag, t: git checkout t git reset --soft tag_branch git add . git commit -m "t"

-- 
Med vänliga hälsningar
Fredrik Gustafsson

tel: 0733-608274
e-post: iveqy@iveqy.com
Andreas Schwab· Aug 11, 2013, 09:36 UTC · re: Kristian Freed · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

Kristian Freed <kristian.freed@gmail.com> writes:
> To help with this process further, it would be useful to be able to
> use git bisect, but as these are just a sequence of tags, not commits
> on a branch, git bisect will not work as is.

git bisect takes arbitrary revisions, there is no restriction on using tags as bounds.

Andreas.
-- 
Andreas Schwab, schwab@linux-m68k.org
GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5
"And now for something completely different."
Felipe Contreras· Aug 11, 2013, 10:16 UTC · re: Kristian Freed · lore

Re: How can I automatically create a GIT branch that represents a sequence of tags?

On Sat, Aug 10, 2013 at 5:29 PM, Kristian Freed <kristian.freed@gmail.com> wrote:

Show 8 quoted lines
> In our current setup, we have automatic tagging in git of all
> successful release builds. This makes it easy to go back to stable
> points in history and compare functionality, check when bugs were
> introduced etc.
>
> To help with this process further, it would be useful to be able to
> use git bisect, but as these are just a sequence of tags, not commits
> on a branch, git bisect will not work as is.
Why don't you just do 'git bisect skip' if the commit doesn't have a tag?
> Is there any tooling for automatically recreating a branch from a
> sequence of tags, where each generated commit is the calculated delta
> between each two neighbouring tags?
That would probably involve listing the wanted tags:
% git log --topo-order --simplify-by-decoration --decorate --oneline
And then generating the commits:

% git cat-file -p v1.8.3 > commit # modify commit's parent % git hash-object -w < commit

-- 
Felipe Contreras

← back to recent threads