Re: Getting first tag per branch for a commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Orgad Shaneh <orgads@xxxxxxxxx> writes:

> What I'd like to have is a way to tell the first tag per branch (or
> per merge) that the commit appeared on.

> I think that this can be done by filtering out tags that are connected
> to already listed tags by first-parent link.

Yes.  When one tag can be reached by another tag, then the former is
definitely an earlier tag than the latter.

A trivial way to compute it would require O(n^2) invocations of "git
merge-base --is-ancestor".  Alternatively, I think you can perhaps
use "git merge-base --independent".

Having said that, one thing to keep in mind is that a single "first
tag" may not exist at all.

Consider this topology:

          o---X-------.                topic
         /     \       \
 ---o---o---o-------o---N---S---o---   maint
     \           \   \           \
      o---o---o---M---o---o---T---o--- master

where a topic branch was forked from the maintenance track, which is
periodically merged to the master branch.  That topic branch has the
commit of interest, X, which first gets merged to the master branch
at merge M, which eventually gets tagged as T (i.e. a new feature
release).  But (wall-clock-wise) after merge M is made and the
change is tested in the context of the master branch, but before the
release T happens, the topic may be merged down to the maintenance
track at merge N.  Then eventually the tip of the maintenance track
is tagged as S (i.e. a maintenance release).

Topologically, T and S cannot be compared and they both contain X,
so the question "what is the first tag on 'master' that has commit
X?" does not have a single unique answer.  Both S and T are eligible.

You could define various heuristics to tiebreak among these tags.
You may be tempted to compare timestamps of S and T.  If they were
equal, then you might want to compare timestamps of M and N.

But you'd need to accept that fundamentally there may not be a
single "first tag".





[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux