Skip to contentSkip to conversation

Replacement for cvs2cl, for generating ChangeLog

DISCUSSION Simon Josefsson 7 participants 19 messages Jun 15, 2016

lore
Share & tools
lore
#0 lore raw

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

	* 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

#1 lore raw
Quoted 6 lines · Simon Josefsson

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).

Quoted 3 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:

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

#2 lore raw
In reply to Simon Josefsson

Hi,

Quoted 6 lines · Simon Josefsson

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.

Quoted 4 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:

Quoted 8 lines

2007-02-22 Simon Josefsson <[email protected]>

	* 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

#3 lore raw
Quoted 5 lines · On Tue, 27 Feb 2007 13:37:23 +0100 (CET) Johannes Schindelin wrote:
Quoted 3 lines · Simon Josefsson

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

Quoted 8 lines
Quoted 3 lines

* 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).

#4 lore raw

gitco - replacement for cvsco

Quoted 16 lines · Sergey Vlasov
Quoted 5 lines · On Tue, 27 Feb 2007 13:37:23 +0100 (CET) Johannes Schindelin wrote:
Quoted 3 lines · Simon Josefsson

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

Quoted 8 lines
Quoted 3 lines

* 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.

Quoted 7 lines

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

#5 lore raw

Re: gitco - replacement for cvsco

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

Quoted 3 lines · Simon Josefsson

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
#6 lore raw

Re: gitco - replacement for cvsco

Quoted 21 lines · Yann Dirson

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

Quoted 3 lines · Simon Josefsson

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.

Quoted 8 lines

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

#7 lore raw
In reply to Johannes Schindelin
Quoted 7 lines · Johannes Schindelin
Quoted 4 lines · Simon Josefsson

* 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.

#8 lore raw

Hi,

Quoted 8 lines · Junio C Hamano
Quoted 6 lines · Johannes Schindelin
Quoted 4 lines · Simon Josefsson

* 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:
...

Quoted 8 lines
Quoted 1 line

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

#9 lore raw

Hi,

Quoted 16 lines · Johannes Schindelin
Quoted 14 lines · Junio C Hamano
Quoted 7 lines · Johannes Schindelin
Quoted 4 lines · Simon Josefsson

* 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.

Quoted 6 lines
Quoted 3 lines

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

#10 lore raw
In reply to Johannes Schindelin

Hi,

Quoted 8 lines · Johannes Schindelin
Quoted 6 lines · Simon Josefsson

* 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 <[email protected]>

Quoted 8 lines
Quoted 6 lines
	* 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

#11 lore raw
Quoted 4 lines · Johannes Schindelin
Quoted 1 line

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

#12 lore raw
In reply to Simon Josefsson
Quoted 3 lines · Simon Josefsson

* 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 :-)

Quoted 3 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:

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

Signature · 2 lines
Dr Andy Parkins, M Eng (hons), MIET
[email protected]
#13 lore raw

tisdag 27 februari 2007 13:57 skrev Andy Parkins:

Quoted 6 lines · Simon Josefsson
Quoted 4 lines

* 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.

Quoted 6 lines

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

#14 lore raw
Quoted 11 lines · Robin Rosenberg

tisdag 27 februari 2007 13:57 skrev Andy Parkins:

Quoted 10 lines · Simon Josefsson
Quoted 4 lines

* 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

Quoted 6 lines
Quoted 2 lines

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.

#15 lore raw

Hi,

Quoted 5 lines · Junio C Hamano

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.

Quoted 7 lines

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

Quoted 2 lines

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

#16 lore raw
In reply to Robin Rosenberg

Hi,

Quoted 6 lines · Robin Rosenberg

tisdag 27 februari 2007 13:57 skrev Andy Parkins:

Quoted 4 lines

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

Quoted 6 lines
Quoted 2 lines

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

#18 lore raw
In reply to Andy Parkins

Hi,

Quoted 5 lines · Andy Parkins

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