git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Orgad Shaneh <orgads@gmail.com>
Cc: git <git@vger.kernel.org>
Subject: Re: Getting first tag per branch for a commit
Date: Sun, 25 Jun 2017 14:54:43 -0700	[thread overview]
Message-ID: <xmqqy3sf7mxo.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <CAGHpTBLP9MiYr2ZoUOaGjGMC+aO_EKYO6SwNLfAu6QFSRnPatQ@mail.gmail.com> (Orgad Shaneh's message of "Sun, 25 Jun 2017 17:06:41 +0300")

Orgad Shaneh <orgads@gmail.com> 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".



  reply	other threads:[~2017-06-25 21:54 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-06-25 14:06 Getting first tag per branch for a commit Orgad Shaneh
2017-06-25 21:54 ` Junio C Hamano [this message]
2017-06-25 22:22   ` Junio C Hamano
2017-06-26  9:37   ` Orgad Shaneh

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqy3sf7mxo.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=orgads@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).