git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: Jeff King <peff@peff.net>
Cc: Ernesto Maserati <ernesto.2.maserati@gmail.com>, git@vger.kernel.org
Subject: Re: How to generate feature branch statistics?
Date: Wed, 20 Jul 2016 11:49:20 -0700	[thread overview]
Message-ID: <xmqqd1m8du1b.fsf@gitster.mtv.corp.google.com> (raw)
In-Reply-To: <20160720131424.GC17469@sigill.intra.peff.net> (Jeff King's message of "Wed, 20 Jul 2016 07:14:24 -0600")

Jeff King <peff@peff.net> writes:

> In a workflow that merges feature branches to master, you can generally
> recognize them by looking for merges along the first-parent chain of
> commits:
>
>   git log --first-parent --merges master
>
> (Depending on your workflow, some feature branches may be fast-forwards
> with no merge commit, so this is just a sampling. Some workflows use
> "git merge --no-ff" to merge in feature branches, so this would see all
> of them).
> And then for each merge, you can get the set of commits that were merged
> in (it is the commits in the second parent that are not in the first).
> The bottom-most one is the "start" of the branch (or close to it; of
> course the author started writing code before they made a commit), and
> the "end" is the merge itself.

A few things to keep in mind are

 * A feature branch may be merged to the master multiple times,
   when the feature branch is properly managed.

   E.g. It may have been once thought to be complete with 3 commits,
   get merged to 'master', then a bug is discovered and gain its
   fourth commits to fix the bug and merged to 'master' again,
   resulting in a topology like this:

         A---B---C-----------D (feature)
        /         \           \
    ---o---o---o---1---o---o---2---o (master)

   "git log --first-parent --merges master" will first find commit
   '2' that merged the feature for the second time, bringing in
   commit 'D', and then it will find commit '1' that merged the
   feature previously, bringing in commit 'A', 'B' and 'C'.

 * A feature branch that depends on other feature may have merges on
   their own.  You may start a feature X that depends on another
   features Y and Z that are not yet in 'master', in addition to
   depending on things in 'master' that have been added since Y and
   Z forked from it.  In such a case, your feature X may look like
   this:

                 .-------------------1----------2--------x---x (feature X)
                /                   /          /
       y---y---y (feature Y)       /          /
      /                           /          /
  ---o---o---o---o---o---o---o---0 (master) /
          \                                /
           z---z (feature Z)              /
                \                        /
                 .----------------------.

   where '1' and '2' are merges of feature Y and then Z into the tip
   of 'master' when you start working on feature X.

   And then feature Y and feature Z may graduate to 'master' before
   your feature X is ready to do so, resulting in something like:

                 .-------------------1----------2--------x---x (feature X)
                /                   /          /
       y---y---y (feature Y) ----  / -------  /  --.
      /                           /          /      \
  ---o---o---o---o---o---o---o---o---o---o---o---o---Y---Z (master)
          \                                /            /
           z---z (feature Z) ----------   /  ----------.
                \                        /
                 .----------------------.

   where 'Y' and 'Z' are merges of features Y and Z to 'master'.
   After that, feature X may become ready to be merged, resulting in:

                 .-------------------1----------2--------x---x (feature X)
                /                   /          /              \    
       y---y---y (feature Y) ----  / -------  /  --.           \
      /                           /          /      \           \
  ---o---o---o---o---o---o---o---o---o---o---o---o---Y---Z---o---X (master)
          \                                /            /
           z---z (feature Z) ----------   /  ----------.
                \                        /
                 .----------------------.

  When "git log --first-parent --merges master" finds X, it would
  notice that it pulled in commits '1', '2' and two 'x'.  The "tool"
  to inspect the history needs to be careful deciding if '1' and '2'
  are the part of feature X.  There are variants that make it tricky
  (e.g. 'Y' may not have yet been merged to 'master' when 'X' is
  merged, in which case you may end up pulling both 'x' and 'y' into
  'master' with a single merge), which should be avoided if feature
  branches are managed carefully, but not everybody is careful when
  managing their history.

Coming back to the introduction of the original message:

>> I assume that feature branches are not frequently enough merged into
>> master. Because of that we discover bugs later than we could with a more
>> continuous code integration. I don't want to discuss here whether feature
>> branches are good or bad.

For our own history and workflow, the duration between the inception
of a topic branch and the time it gets merged to 'master' is not all
that interesting.  More interesting numbers are:

 * The duration between the time a topic hits 'next' and the time it
   gets merged to 'master'.  This is the time the developers and
   testers are using the new feature in their own work to make sure
   it does not have any ill effect.

 * The percetage of topics that is merged to 'master' with some
   follow-up changes since it hits 'next'.  This is an approximate
   for the number of bugs that are caught by developers and testers
   before a new feature goes to the general public.

  reply	other threads:[~2016-07-20 18:49 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-07-20  8:05 How to generate feature branch statistics? Ernesto Maserati
2016-07-20 13:14 ` Jeff King
2016-07-20 18:49   ` Junio C Hamano [this message]
2016-07-20 23:10     ` Jakub Narębski
2016-07-20 23:31       ` Junio C Hamano
2016-07-20 13:56 ` Jakub Narębski
2016-07-20 18:10   ` Jakub Narębski

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=xmqqd1m8du1b.fsf@gitster.mtv.corp.google.com \
    --to=gitster@pobox.com \
    --cc=ernesto.2.maserati@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=peff@peff.net \
    /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).