Re: Pretty format specifier for commit count?

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

 



On Mon, Jan 19, 2015 at 02:54:13PM +0100, Michael J Gruber wrote:
> Josh Triplett schrieb am 19.01.2015 um 02:29:
> > I'd like to use git-log to generate a Debian changelog file (with one
> > entry per commit), which has entries like this:
> > 
> > package-name (version-number) unstable; urgency=low
> > 
> >  * ...
> > 
> >  -- Example Person <person@xxxxxxxxxxx>  RFC822-date
> > 
> > Since I'm intentionally generating one entry per commit, I can generate
> > *almost* all of this with git log:
> > 
> > git log --pretty='format:packagename (FIXME) unstable; urgency=low%n%n  * %s%n%w(0,4,4)%+b%w(0,0,0)%n -- %an <%ae>  %aD%n'
> > 
> > This produces entries like this:
> > 
> > packagename (FIXME) unstable; urgency=low
> > 
> >   * Example change
> > 
> >     Long description of example change.
> > 
> >  -- Josh Triplett <josh@xxxxxxxxxxxxxxxx>  Thu, 8 Jan 2015 16:36:52 -0800
> > 
> > packagename (FIXME) unstable; urgency=low
> > 
> >   * Initial version
> > 
> >  -- Josh Triplett <josh@xxxxxxxxxxxxxxxx>  Thu, 8 Jan 2015 16:36:51 -0800
> > 
> > Would it be possible to add a format specifier producing a commit count,
> > similar to that provided by git-describe?  Such a specifier would allow
> > filling in the version number in the format above (replacing the FIXME).
> > (Note that the version numbers need to monotonically increase; otherwise
> > I would just use the commit hash as the version numer.)
> > 
> > - Josh Triplett
> > 
> 
> 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".

I could imagine scenarios in which both "most recent tag" and "commits
since most recent tag" would be useful format specifiers; however, for
this use case, I'm looking for "commits since root commit".

> (I won't suggest scripting around rev-list, describe and log -1 because
> you know that already...)

Right.  Though as far as I can tell, git describe doesn't actually do
what I'm looking for.  rev-list --count $commit does (though that'd be
N**2), as would something like rev-list --reverse HEAD | nl | while read
count hash ; do ..., but I'd like to do better than that.

- Josh Triplett
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[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]