git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Michael J Gruber <git@drmicha.warpmail.net>
To: josh@joshtriplett.org, Jeff King <peff@peff.net>
Cc: git@vger.kernel.org
Subject: Re: Pretty format specifier for commit count?
Date: Thu, 22 Jan 2015 11:10:42 +0100	[thread overview]
Message-ID: <54C0CCA2.3060307@drmicha.warpmail.net> (raw)
In-Reply-To: <20150120231110.GC14475@cloud>

josh@joshtriplett.org schrieb am 21.01.2015 um 00:11:
> On Tue, Jan 20, 2015 at 04:49:53PM -0500, Jeff King wrote:
>> On Mon, Jan 19, 2015 at 05:17:25PM -0800, Josh Triplett wrote:
>>
>>>> Can you be a bit more specific about the type count that you are after?
>>>> "git describe" counts commits since the most recent tag (possibly within
>>>> a specific subset of all tags). Is that your desired format?
>>>
>>> That might work, since the repository in question has no tags; I'd
>>> actually like "commits since root commit".
>>
>> That's basically a generation number. But I'm not sure if that's really
>> what you want; in a non-linear history it's not unique (two children of
>> commit X are both X+1).
> 
> That would actually be perfectly fine.  If I need to distinguish
> branches, I can either use branch/tag names, or append a commit hash.  I
> don't mind the following:
> 
>  /-B-\
> A     D
>  \-C-/
> 
> A=1
> B=C=2
> D=3
> 
> I could (and probably should) append "+hash" to the version number for
> uniqueness, and if I care what order B and C sort in, I can use tags,
> branches, or some other more clever mechanism.
> 
>> It sounds like you really just want commits
>> counting up from the root, and with side branches to have their own
>> unique numbers. So something like:
>>
>>        C
>>       /
>>   A--B--D
>>
>>   A=1
>>   B=2
>>   C=3
>>   D=4
>>
>> except the last two are assigned arbitrarily. You need some rules for
>> linearizing the commits.
> 
> I don't care about the numbers assigned to anything not reachable from
> the committish I start from.
> 
>> But that's not deterministic as you add more starting points (either new
>> ref tips, or just new merges we have to cross). For example, imagine
>> this:
>>
>>          G--H
>>         /    \
>>        C--E   \
>>       /    \   \
>>   A--B--D---F---I
>>
>> If we start at I, then we might visit H and G first, meaning we learn
>> about C much earlier than we otherwise would. Then we hit F, and get to
>> C from there. But now it it may be in a different position with respect
>> to D!
> 
> Right, the numbers need to always stay the same as you add more commits
> over time.  If walking a given graph assigns a given set of generation
> numbers, walking any subgraph should assign all the same generation
> numbers to the common nodes.
> 
>> I suspect your problem statement may simply assume a linear history,
>> which makes this all much simpler. But we are not likely to add a
>> feature to git that will break badly once you have a non-linear history. :)
> 
> Not assuming a linear history, but assuming a linear changelog file. :)
> 
>> I think in the linear case that a generation number _would_ be correct,
>> and it is a useful concept by itself. So that may be the best thing to
>> add.
> 
> Sounds good to me.
> 
> - Josh Triplett

We do have a linear history when we walk with --first-parent :)

So, for the changelog for commits "on a branch", where "on a branch" is
not the git concept but defined by "git rev-list --first-parent" (more
like hg branches), the count from root would be deterministic and the
right concept given the appropriate branch workflow.

Generation numbers are monotonous but may increase by steps greater than
1 on that "branch" if I remember them correctly. I.e., merge commits are
"weighted" by the number of commits that get merged in.

Michael

  reply	other threads:[~2015-01-22 10:10 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-01-19  1:29 Pretty format specifier for commit count? Josh Triplett
2015-01-19 13:54 ` Michael J Gruber
2015-01-20  1:17   ` Josh Triplett
2015-01-20 21:49     ` Jeff King
2015-01-20 23:11       ` josh
2015-01-22 10:10         ` Michael J Gruber [this message]
2015-01-22 12:52           ` Jeff King

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

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

  git send-email \
    --in-reply-to=54C0CCA2.3060307@drmicha.warpmail.net \
    --to=git@drmicha.warpmail.net \
    --cc=git@vger.kernel.org \
    --cc=josh@joshtriplett.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.
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 NNTP newsgroup(s).