threads / discuss / 6988

Replacement for cvs2cl, for generating ChangeLog

Subject: Replacement for cvs2cl, for generating ChangeLog

## tl;dr

19 messages between Feb 27, 2007 and Feb 28, 2007.

replies: 18people: 7as markdown or json

Simon Josefsson· Feb 27, 2007, 11:41 UTC · lore

Hi! I'm considering switching to git for my projects (shishi, gsasl, gnutls, libtasn1, opencdk, ...) and I have some questions:

* How do I discard all locally modified or added files?  'cvs upd -C'
  does some of that, but I've been using a tool 'cvsco' which quickly
  restore a CVS checkout into a pristine state.
* Is there a tool that produce ChangeLog files in the GNU format,
  based on the git logs?  Similar to the 'cvs2cl' tool.  The output
  should look like:
2007-02-22  Simon Josefsson <simon@josefsson.org>
	* link-warning.h, gl/getaddrinfo.c, gl/gnulib.mk, gl/string_.h,
	gl/m4/gnulib-comp.m4, gl/m4/string_h.m4, lgl/Makefile.am,
	lgl/snprintf.c, lgl/snprintf.h, lgl/stdio_.h, lgl/string_.h,
	lgl/unistd_.h, lgl/m4/gnulib-comp.m4, lgl/m4/intdiv0.m4,
	lgl/m4/snprintf.m4, lgl/m4/stdio_h.m4, lgl/m4/string_h.m4,
	lgl/m4/unistd_h.m4: Update.

Thanks, Simon

Junio C Hamano· Feb 27, 2007, 12:23 UTC · re: Simon Josefsson · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Simon Josefsson <simon@josefsson.org> writes:
Show 6 quoted lines
> Hi!  I'm considering switching to git for my projects (shishi, gsasl,
> gnutls, libtasn1, opencdk, ...) and I have some questions:
>
> * How do I discard all locally modified or added files?  'cvs upd -C'
>   does some of that, but I've been using a tool 'cvsco' which quickly
>   restore a CVS checkout into a pristine state.
"git reset --hard" (RTFM).
> * Is there a tool that produce ChangeLog files in the GNU format,
>   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
>   should look like:

No, but that should probably be trivial. I would suggest you postprocess "git log --pretty --numstat --summary" output, which is probably the most parsable.

Johannes Schindelin· Feb 27, 2007, 12:37 UTC · re: Simon Josefsson · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Simon Josefsson wrote:
Show 6 quoted lines
> Hi!  I'm considering switching to git for my projects (shishi, gsasl,
> gnutls, libtasn1, opencdk, ...) and I have some questions:
> 
> * How do I discard all locally modified or added files?  'cvs upd -C'
>   does some of that, but I've been using a tool 'cvsco' which quickly
>   restore a CVS checkout into a pristine state.
The command in git is called "git reset --hard". Beware: this really, 
really loses _all_ local changes. And no need to worry when it completes 
much faster than you expected it to... See "git status" to see that it 
worked, indeed.
 
Show 12 quoted lines
> * Is there a tool that produce ChangeLog files in the GNU format,
>   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
>   should look like:
> 
> 2007-02-22  Simon Josefsson <simon@josefsson.org>
> 
> 	* link-warning.h, gl/getaddrinfo.c, gl/gnulib.mk, gl/string_.h,
> 	gl/m4/gnulib-comp.m4, gl/m4/string_h.m4, lgl/Makefile.am,
> 	lgl/snprintf.c, lgl/snprintf.h, lgl/stdio_.h, lgl/string_.h,
> 	lgl/unistd_.h, lgl/m4/gnulib-comp.m4, lgl/m4/intdiv0.m4,
> 	lgl/m4/snprintf.m4, lgl/m4/stdio_h.m4, lgl/m4/string_h.m4,
> 	lgl/m4/unistd_h.m4: Update.
Let me hack something.

Ciao, Dscho

Sergey Vlasov· Feb 27, 2007, 14:40 UTC · re: Johannes Schindelin · lore

Re: Replacement for cvs2cl, for generating ChangeLog

On Tue, 27 Feb 2007 13:37:23 +0100 (CET) Johannes Schindelin wrote:
Show 13 quoted lines
> On Tue, 27 Feb 2007, Simon Josefsson wrote:
>
> > Hi!  I'm considering switching to git for my projects (shishi, gsasl,
> > gnutls, libtasn1, opencdk, ...) and I have some questions:
> >
> > * How do I discard all locally modified or added files?  'cvs upd -C'
> >   does some of that, but I've been using a tool 'cvsco' which quickly
> >   restore a CVS checkout into a pristine state.
>
> The command in git is called "git reset --hard". Beware: this really,
> really loses _all_ local changes. And no need to worry when it completes
> much faster than you expected it to... See "git status" to see that it
> worked, indeed.

But "git reset --hard" won't touch untracked files (this command is similar to "cvs update -C", but does not save old contents anywhere). If what is really needed is to clean out build products, editor backups and other files which are not tracked by git, "git clean -d -x" will do it (but this command will keep local changes to tracked files - an additional "git reset --hard" is needed to restore them to the last committed state).

Simon Josefsson· Feb 28, 2007, 14:08 UTC · re: Sergey Vlasov · lore

gitco - replacement for cvsco

Sergey Vlasov <vsu@altlinux.ru> writes:
Show 23 quoted lines
> On Tue, 27 Feb 2007 13:37:23 +0100 (CET) Johannes Schindelin wrote:
>
>> On Tue, 27 Feb 2007, Simon Josefsson wrote:
>>
>> > Hi!  I'm considering switching to git for my projects (shishi, gsasl,
>> > gnutls, libtasn1, opencdk, ...) and I have some questions:
>> >
>> > * How do I discard all locally modified or added files?  'cvs upd -C'
>> >   does some of that, but I've been using a tool 'cvsco' which quickly
>> >   restore a CVS checkout into a pristine state.
>>
>> The command in git is called "git reset --hard". Beware: this really,
>> really loses _all_ local changes. And no need to worry when it completes
>> much faster than you expected it to... See "git status" to see that it
>> worked, indeed.
>
> But "git reset --hard" won't touch untracked files (this command is
> similar to "cvs update -C", but does not save old contents anywhere).
> If what is really needed is to clean out build products, editor backups
> and other files which are not tracked by git, "git clean -d -x" will do
> it (but this command will keep local changes to tracked files - an
> additional "git reset --hard" is needed to restore them to the last
> committed state).
Thanks!  This script solve my original question:

#!/bin/sh # gitco - cruel checkout. Discards everything that has not been # committed, and checkout missing files. git-clean -d -x git-reset --hard

However, one problem with that, compared to 'cvsco', is that 'git-reset --hard' does not tell me tell me which files were deleted and which file were restored. May I suggest a --verbose or similar?

Here is how to use "gitco":

jas@mocca:~/src/libtasn1$ sha1sum foo Makefile.am gendocs.sh sha1sum: foo: No such file or directory e14704b0c3fe4a07e86e4f66df7c6888f619e7dc Makefile.am ea44aed92044fdafffae08a8ec4191ed357e4321 gendocs.sh

# Ok, so we have two files, one which doesn't exists.

jas@mocca:~/src/libtasn1$ echo hej > foo; echo hej >> Makefile.am ; rm gendocs.sh jas@mocca:~/src/libtasn1$ sha1sum foo Makefile.am gendocs.sh 32a0617aab4c9fe725f1b5bc441291180ad25b73 foo e83aa94eb841a329289395f9a88bd5f89a725535 Makefile.am sha1sum: gendocs.sh: No such file or directory

# Ok, one file deleted, one new created, and one modified.

jas@mocca:~/src/libtasn1$ gitco Removing foo

# It isn't that informative...

jas@mocca:~/src/libtasn1$ sha1sum foo Makefile.am gendocs.sh sha1sum: foo: No such file or directory e14704b0c3fe4a07e86e4f66df7c6888f619e7dc Makefile.am ea44aed92044fdafffae08a8ec4191ed357e4321 gendocs.sh

# Ok, back to where we started.

Regards, Simon

Yann Dirson· Feb 28, 2007, 19:55 UTC · re: Simon Josefsson · lore

Re: gitco - replacement for cvsco

As a big fan of cvsco and friends, I admit I often miss that one in git repos.

On Wed, Feb 28, 2007 at 03:08:02PM +0100, Simon Josefsson wrote:
> However, one problem with that, compared to 'cvsco', is that
> 'git-reset --hard' does not tell me tell me which files were deleted
> and which file were restored.  May I suggest a --verbose or similar?

Here is a small change to your script that does just that. It is far from perfect:

- uses cogito and not plain git.  Not sure how to achieve the same
compact layout with plain git - both cogito and stgit forge this type
of output themselves.  Would be great to get it directly from git
itself...
- not very efficient, and not very secure, since we scan the tree once
for reporting and then once for deleting the files, leaving a window
where files could be created by another program after the cg-status
call, and then removed by git-reset.
You've been warned :)

#!/bin/sh # gitco - cruel checkout. Discards everything that has not been # committed, and checkout missing files. git clean -d -x cg status -w git reset --hard

Simon Josefsson· Feb 28, 2007, 21:31 UTC · re: Yann Dirson · lore

Re: gitco - replacement for cvsco

Yann Dirson <ydirson@altern.org> writes:
Show 29 quoted lines
> As a big fan of cvsco and friends, I admit I often miss that one in
> git repos.
>
> On Wed, Feb 28, 2007 at 03:08:02PM +0100, Simon Josefsson wrote:
>> However, one problem with that, compared to 'cvsco', is that
>> 'git-reset --hard' does not tell me tell me which files were deleted
>> and which file were restored.  May I suggest a --verbose or similar?
>
> Here is a small change to your script that does just that.  It is far
> from perfect:
>
> - uses cogito and not plain git.  Not sure how to achieve the same
> compact layout with plain git - both cogito and stgit forge this type
> of output themselves.  Would be great to get it directly from git
> itself...
>
> - not very efficient, and not very secure, since we scan the tree once
> for reporting and then once for deleting the files, leaving a window
> where files could be created by another program after the cg-status
> call, and then removed by git-reset.
>
> You've been warned :)
>
> #!/bin/sh
> # gitco - cruel checkout.  Discards everything that has not been
> # committed, and checkout missing files.
> git clean -d -x
> cg status -w
> git reset --hard

jas@mocca:~/src/libtasn1$ gitco Removing foo M Makefile.am ! gendocs.sh jas@mocca:~/src/libtasn1$

Perfect!

Thanks, Simon

Johannes Schindelin· Feb 27, 2007, 15:19 UTC · re: Johannes Schindelin · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Johannes Schindelin wrote:
Show 16 quoted lines
> On Tue, 27 Feb 2007, Simon Josefsson wrote:
> 
> > * Is there a tool that produce ChangeLog files in the GNU format,
> >   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
> >   should look like:
> > 
> > 2007-02-22  Simon Josefsson <simon@josefsson.org>
> > 
> > 	* link-warning.h, gl/getaddrinfo.c, gl/gnulib.mk, gl/string_.h,
> > 	gl/m4/gnulib-comp.m4, gl/m4/string_h.m4, lgl/Makefile.am,
> > 	lgl/snprintf.c, lgl/snprintf.h, lgl/stdio_.h, lgl/string_.h,
> > 	lgl/unistd_.h, lgl/m4/gnulib-comp.m4, lgl/m4/intdiv0.m4,
> > 	lgl/m4/snprintf.m4, lgl/m4/stdio_h.m4, lgl/m4/string_h.m4,
> > 	lgl/m4/unistd_h.m4: Update.
> 
> Let me hack something.

See my next three posts. This patch series is on top of "next" (it does not apply cleanly to "master", since the format "format:" conflicts...).

Ciao, Dscho

Simon Josefsson· Feb 28, 2007, 14:12 UTC · re: Johannes Schindelin · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> Let me hack something.
>
> See my next three posts. This patch series is on top of "next" (it does 
> not apply cleanly to "master", since the format "format:" conflicts...).

Wow, that was quick! Thanks. I haven't built my own git yet, so testing this may take some time...

Generally, I can sympathise with those who think this feature should not be in the core git. That would correspond to the cvs2cl tool, it is an external tool that uses cvs internally. However, having it be included in core would be simpler for me. I don't care strongly which approach is chosen (external tool vs included in core), but I can't switch to git for my projects until this is resolved.

/Simon
Junio C Hamano· Feb 27, 2007, 19:27 UTC · re: Johannes Schindelin · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 7 quoted lines
> On Tue, 27 Feb 2007, Simon Josefsson wrote:
>
>> * Is there a tool that produce ChangeLog files in the GNU format,
>>   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
>>   should look like:
>> ...
> Let me hack something.

I do not know why you want to pile something like this into builtin-log. It would add maintenance burden and I do not see a gain from it.

One beauty of git is being scriptable. When somebody new asks for something like this, I think it is much more productive to demonstrate the power of scriptability than piling random crap in the core.

Johannes Schindelin· Feb 27, 2007, 19:45 UTC · re: Junio C Hamano · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Junio C Hamano wrote:
Show 16 quoted lines
> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> 
> > On Tue, 27 Feb 2007, Simon Josefsson wrote:
> >
> >> * Is there a tool that produce ChangeLog files in the GNU format,
> >>   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
> >>   should look like:
> >> ...
> > Let me hack something.
> 
> I do not know why you want to pile something like this into builtin-log.  
> It would add maintenance burden and I do not see a gain from it.
> 
> One beauty of git is being scriptable.  When somebody new asks for 
> something like this, I think it is much more productive to demonstrate 
> the power of scriptability than piling random crap in the core.

Well, I briefly considered writing a little Perl script using the output of "git log --stat".

BUT. GNU ChangeLog is a really often asked-for feature. And before risking some Haskell script producing GNU ChangeLog output in git.git, which I have to rewrite as plugin eventually anyway, I thought that I include it right away.

Demonstrating the ease of Git's core, and hacking on Git was a benefit from it.

As were the first two patches: I think print_wrapped_text() only now got usable. And show_date() with an enum should be an improvement, too.

Anyway, it was the third time I read about such a request, and I had a go at it. If you don't like it, don't take it. I have no problems with that.

Ciao, Dscho

Johannes Schindelin· Feb 27, 2007, 20:54 UTC · re: Johannes Schindelin · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Johannes Schindelin wrote:
Show 22 quoted lines
> On Tue, 27 Feb 2007, Junio C Hamano wrote:
> 
> > Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> > 
> > > On Tue, 27 Feb 2007, Simon Josefsson wrote:
> > >
> > >> * Is there a tool that produce ChangeLog files in the GNU format,
> > >>   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
> > >>   should look like:
> > >> ...
> > > Let me hack something.
> > 
> > I do not know why you want to pile something like this into 
> > builtin-log.  It would add maintenance burden and I do not see a gain 
> > from it.
> > 
> > One beauty of git is being scriptable.  When somebody new asks for 
> > something like this, I think it is much more productive to demonstrate 
> > the power of scriptability than piling random crap in the core.
> 
> Well, I briefly considered writing a little Perl script using the output 
> of "git log --stat".

Side note. I am not a good enough Perl/Shell/Python hacker to know how to wrap text correctly to reflect GNU ChangeLog format. That is why I wrote print_wrapped_text() in the first place.

Ciao, Dscho

Andy Parkins· Feb 27, 2007, 12:57 UTC · re: Simon Josefsson · lore

Re: Replacement for cvs2cl, for generating ChangeLog

On Tuesday 2007 February 27 11:41, Simon Josefsson wrote:
> * How do I discard all locally modified or added files?  'cvs upd -C'
>   does some of that, but I've been using a tool 'cvsco' which quickly
>   restore a CVS checkout into a pristine state.

If I understand you correctly ("locally" has slightly ambiguous meaning when the repository is local as well), the following would restore a working directory to be identical to the current HEAD.

 git checkout -f HEAD
The "-f" means force - i.e. don't worry about discarding local changes :-)
> * Is there a tool that produce ChangeLog files in the GNU format,
>   based on the git logs?  Similar to the 'cvs2cl' tool.  The output
>   should look like:

Not that I know of, but git has some lovely log generation tools, so I'm sure it could be easily done with a snippet of perl - or perhaps a change to git's own log generator to support

 git-rev-list --pretty=gnucl
would be more appropriate.
Andy
-- 
Dr Andy Parkins, M Eng (hons), MIET
andyparkins@gmail.com
Johannes Schindelin· Feb 27, 2007, 15:56 UTC · re: Andy Parkins · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Andy Parkins wrote:
Show 5 quoted lines
> [...] perhaps a change to git's own log generator to support
> 
>  git-rev-list --pretty=gnucl
> 
> would be more appropriate.

I was already hacking on a builtin changelog command, because I was convinced that this breaks our model in builtin-log: We show the commit information first, and _then_ we call the diff machinery. And GNU ChangeLog format mixes these informations: the date and the author are commit information, but the files are tree information, and the oneline is commit information again.

However, your mail made me think again.

I now reused (AKA misused) the stats separator to take the oneline description, which is set in show_log() when revs->commit_format == CMIT_FMT_CHANGELOG, which is output by diff_flush() when the diff_options->output_format == DIFF_FORMAT_CHANGELOG.

BTW I already found a subtle bug. In finalize_changelog(), options->stat_sep can be NULL, if no oneline was found.

But AFAIK we do not allow empty commit messages, so this bug would never have been triggered.

Ciao, Dscho

Robin Rosenberg· Feb 27, 2007, 21:27 UTC · re: Andy Parkins · lore

Re: Replacement for cvs2cl, for generating ChangeLog

tisdag 27 februari 2007 13:57 skrev Andy Parkins:
Show 12 quoted lines
> On Tuesday 2007 February 27 11:41, Simon Josefsson wrote:
> 
> > * How do I discard all locally modified or added files?  'cvs upd -C'
> >   does some of that, but I've been using a tool 'cvsco' which quickly
> >   restore a CVS checkout into a pristine state.
> 
> Not that I know of, but git has some lovely log generation tools, so I'm sure 
> it could be easily done with a snippet of perl - or perhaps a change to git's 
> own log generator to support
> 
>  git-rev-list --pretty=gnucl
> 
gir-rev-list ??

Extend git-shortlog with --gnucl instead. What seems missing is the grouping of changes by date. git-shortlog only groups by author.

-- robin
Junio C Hamano· Feb 27, 2007, 21:50 UTC · re: Robin Rosenberg · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Robin Rosenberg <robin.rosenberg.lists@dewire.com> writes:
Show 17 quoted lines
> tisdag 27 februari 2007 13:57 skrev Andy Parkins:
>> On Tuesday 2007 February 27 11:41, Simon Josefsson wrote:
>> 
>> > * How do I discard all locally modified or added files?  'cvs upd -C'
>> >   does some of that, but I've been using a tool 'cvsco' which quickly
>> >   restore a CVS checkout into a pristine state.
>> 
>> Not that I know of, but git has some lovely log generation tools, so I'm sure 
>> it could be easily done with a snippet of perl - or perhaps a change to git's 
>> own log generator to support
>> 
>>  git-rev-list --pretty=gnucl
>> 
> gir-rev-list ??
>
> Extend git-shortlog with --gnucl instead. What seems missing is the grouping
> of changes by date. git-shortlog only groups by author.

If GNU changelog _were_ to have one entry per day, mixing changes from different commits together, that might be a good approach. I do not think GNU changelog guideline can be _THAT_ broken.

Listing of filenames of changed files in the log, followed by short description of the nature of the change (e.g. "Updated to do blah", "New File"), shows the CVS mentality "File matters", and that was what Simon's original example showed. It's been a while I looked at the coding guideline the last time, but I think GNU convention wants you to say "filename (function)" when applicable. Which I happen to think makes much more sense than the filename alone.

The information that would appear in "log -p --pretty" output needs to be condensed to obtain such a log entry. You _could_ still do that as a built-in if you really wanted to, but I tend to think that it is much better to implement such a specialized processing (for one thing, what a function is depends on the programming language you are reading from) as an external postprocessing filter that people can more easily tweak for their specific needs.

That's why I keep stressing that one good thing about git is it is easily scriptable.

Johannes Schindelin· Feb 27, 2007, 22:22 UTC · re: Junio C Hamano · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Junio C Hamano wrote:
Show 12 quoted lines
> It's been a while I looked at the coding guideline the last time, but I 
> think GNU convention wants you to say "filename (function)" when 
> applicable.  Which I happen to think makes much more sense than the 
> filename alone.
> 
> The information that would appear in "log -p --pretty" output needs to 
> be condensed to obtain such a log entry.  You _could_ still do that as a 
> built-in if you really wanted to, but I tend to think that it is much 
> better to implement such a specialized processing (for one thing, what a 
> function is depends on the programming language you are reading from) as 
> an external postprocessing filter that people can more easily tweak for 
> their specific needs.

It would be easy to write a consume() function (called with context == 0) which takes the information from the "@@" lines.

But the builtin -- as the script -- would suffer from the following problem:

-- snip -- +} + +static int new_function(void) -- snap --

> That's why I keep stressing that one good thing about git is it is 
> easily scriptable.

IMHO it is easier to get right as a builtin. But as I said, I am not feeling too strongly about it.

Ciao, Dscho

Johannes Schindelin· Feb 27, 2007, 22:12 UTC · re: Robin Rosenberg · lore

Re: Replacement for cvs2cl, for generating ChangeLog

Hi,
On Tue, 27 Feb 2007, Robin Rosenberg wrote:
Show 12 quoted lines
> tisdag 27 februari 2007 13:57 skrev Andy Parkins:
> 
> > Not that I know of, but git has some lovely log generation tools, so 
> > I'm sure it could be easily done with a snippet of perl - or perhaps a 
> > change to git's own log generator to support
> > 
> >  git-rev-list --pretty=gnucl
> > 
> gir-rev-list ??
> 
> Extend git-shortlog with --gnucl instead. What seems missing is the 
> grouping of changes by date. git-shortlog only groups by author.

No, the revision walker groups by commit (not by date, but you don't want that anyway). git-shortlog works _on top_ of the revision walker.

The sane thing _is_ to use the revision walker.

Given the amount of projects using cvs2cl (I personally saw a couple), I expect a couple of people to speak up in favour of including support for --pretty=cl or =changelog or =gnucl or whatever.

Ciao, Dscho

Simon Josefsson· Feb 28, 2007, 14:27 UTC · re: Johannes Schindelin · lore

Re: Replacement for cvs2cl, for generating ChangeLog

FYI, the GNU ChangeLog format is actually documented, see:
http://www.gnu.org/prep/standards/html_node/Change-Logs.html

And some parts of it (function names, CPP macro conditionals) are quite neat, although I'm not sure how much of it can be automatically generated, or if that is even something you'd want.

/Simon

← back to recent threads