threads / discuss / 5891

cg-commit does not run pre-commit hook?

Subject: cg-commit does not run pre-commit hook?

## tl;dr

8 messages between Oct 11, 2006 and Oct 12, 2006.

replies: 7people: 5as markdown or json

Wolfgang Denk· Oct 11, 2006, 20:30 UTC · lore
Hi,

I noticed that cg-commit does not run the pre-commit hook. Is this intentional, or am I doing anyhting wrong? When I use git-coimmit instead the hook is run just fine. This is with git-1.4.2.1 and cogito-0.18 of FC4 / FC5 systems.

Best regards,
Wolfgang Denk
-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
There are bugs and then there are bugs.  And then there are bugs.
                                                    - Karl Lehenbauer
Petr Baudis· Oct 12, 2006, 01:15 UTC · re: Wolfgang Denk · lore

Re: cg-commit does not run pre-commit hook?

  Hi,

Dear diary, on Wed, Oct 11, 2006 at 10:30:54PM CEST, I got a letter where Wolfgang Denk <wd@denx.de> said that...

> I noticed that cg-commit does not run the pre-commit  hook.  Is  this
> intentional,  or  am  I  doing anyhting wrong? When I use git-coimmit
> instead the hook is run just  fine.  This  is  with  git-1.4.2.1  and
> cogito-0.18 of FC4 / FC5 systems.
  historically, Git and Cogito use a different set of hooks (Cogito got
hooks first but Git picked own names and usage and now is prevalent).
I have plans for making Cogito support Git hooks and slowly deprecate
those own ones for which Git has counterparts, but didn't get to it yet.
I might do today during the more boring lectures... ;-)
-- 
				Petr "Pasky" Baudis
Stuff: http://pasky.or.cz/
#!/bin/perl -sp0777i<X+d*lMLa^*lN%0]dsXx++lMlN/dsM0<j]dsj
$/=unpack('H*',$_);$_=`echo 16dio\U$k"SK$/SM$n\EsN0p[lN*1
lK[d2%Sa2/d0$^Ixp"|dc`;s/\W//g;$_=pack('H*',/((..)*)$/)
Wolfgang Denk· Oct 12, 2006, 14:27 UTC · re: Petr Baudis · lore

Re: cg-commit does not run pre-commit hook?

Dear Petr,
in message <20061012011548.GT20017@pasky.or.cz> you wrote:
> 
>   historically, Git and Cogito use a different set of hooks (Cogito got
> hooks first but Git picked own names and usage and now is prevalent).

I see. And current versions of cogito don't support any pre-commit script, right?

> I have plans for making Cogito support Git hooks and slowly deprecate
> those own ones for which Git has counterparts, but didn't get to it yet.
> I might do today during the more boring lectures... ;-)
Keeping my fingers crossed :-)

I'm looking for a way to register the commit message into some changelog file which gets checked in with the same commit. Or is there another way to do this?

Best regards,
Wolfgang Denk
-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
The goal of science is to build better mousetraps. The goal of nature
is to build better mice.
Andreas Ericsson· Oct 12, 2006, 14:42 UTC · re: Wolfgang Denk · lore

Re: cg-commit does not run pre-commit hook?

Wolfgang Denk wrote:
Show 19 quoted lines
> Dear Petr,
> 
> in message <20061012011548.GT20017@pasky.or.cz> you wrote:
>>   historically, Git and Cogito use a different set of hooks (Cogito got
>> hooks first but Git picked own names and usage and now is prevalent).
> 
> I see. And current versions of cogito don't support any pre-commit
> script, right?
> 
>> I have plans for making Cogito support Git hooks and slowly deprecate
>> those own ones for which Git has counterparts, but didn't get to it yet.
>> I might do today during the more boring lectures... ;-)
> 
> Keeping my fingers crossed :-)
> 
> I'm looking for a way  to  register  the  commit  message  into  some
> changelog  file  which  gets  checked  in with the same commit. Or is
> there another way to do this? 
> 
git log

The commit message is already saved and git (and cogito, I presume) provide tools to fetch those messages in the relevant different orders (although ordering by date is flakey sometimes; see list-archives for discussion).

One part of why a proper SCM is so good to use is that you shouldn't have to maintain a separate changelog. The SCM should create one for you when you ask it, based on the comments you've entered when actually making the changes.

That aside, for actual releases, I generally write a short, gisted "what's new" thingie inside the tag, based on the shortlog output and my own memory. This comes in handy when management wants to have their version of the shortlog, and developers can pretty easily find new features by just sifting through the tag-messages.

-- 
Andreas Ericsson                   andreas.ericsson@op5.se
OP5 AB                             www.op5.se
Tel: +46 8-230225                  Fax: +46 8-230231
Wolfgang Denk· Oct 12, 2006, 15:54 UTC · re: Andreas Ericsson · lore

Re: cg-commit does not run pre-commit hook?

Dear Andreas,
in message <452E545F.6060406@op5.se> you wrote:
Show 6 quoted lines
>
> > I'm looking for a way  to  register  the  commit  message  into  some
> > changelog  file  which  gets  checked  in with the same commit. Or is
> > there another way to do this? 
> 
> git log

Sorry, this does not work, as I can access the commit message only *after* the commit completed, and then it's too late to get it into a file that shall be included with the very same commit.

> The commit message is already saved and git (and cogito, I presume) 
> provide tools to fetch those messages in the relevant different orders 

Yes, but only *after* doing the job. That's why I'm looking for a pre-commit hook.

> One part of why a proper SCM is so good to use is that you shouldn't 
> have to maintain a separate changelog. The SCM should create one for you 
> when you ask it, based on the comments you've entered when actually 
> making the changes.

True, as long as you can work within the SCM. The changelog file I'm talking about is mostly for people who just work with exported trees (for example, when they download a tarball).

Best regards,
Wolfgang Denk
-- 
Software Engineering:  Embedded and Realtime Systems,  Embedded Linux
Phone: (+49)-8142-66989-10 Fax: (+49)-8142-66989-80 Email: wd@denx.de
Everyting looks interesting until you do it. Then you find it's  just
another job.                     - Terry Pratchett, _Moving Pictures_
Linus Torvalds· Oct 12, 2006, 16:59 UTC · re: Wolfgang Denk · lore

Re: cg-commit does not run pre-commit hook?

On Thu, 12 Oct 2006, Wolfgang Denk wrote:
Show 6 quoted lines
> > 
> > git log
> 
> Sorry, this does not work, as I can access the  commit  message  only
> *after* the commit completed, and then it's too late to get it into a
> file that shall be included with the very same commit.
Why? That's just stupid.

If you want to have a ChangeLog file, it's _much_ better to just auto-generate it after the fact. When you cut a tar-file, just have the script autogenerate the changelog then and there. Why do it inside the SCM that keeps track of the data _anyway_.

> True, as long as you can work within the SCM. The changelog file  I'm
> talking  about is mostly for people who just work with exported trees
> (for example, when they download a tarball).
Right - but it's easy enough to add it to the tar-ball, so..
		Linus
Linus Torvalds· Oct 12, 2006, 17:20 UTC · re: Linus Torvalds · lore

Re: cg-commit does not run pre-commit hook?

On Thu, 12 Oct 2006, Linus Torvalds wrote:
> 
> Why? That's just stupid.

Btw, let me explain that strong statement, because it _is_ a strong statement, but it's true.

The problem with trying to generate a changelog entry at commit time is that it is fundamentally a broken concept in a distributed environment.

What happens at a merge event? Sure, you can have special merge magic to try to sort out the mess, but it _is_ a mess. You can make things "work", but you can never actually make the result really make _sense_. The changelog is fundamentally a serialization of something that wasn't serial.

Now, the same serialization problem obviously exists when you auto-generate the changelog file when doing a release tar-ball or something like that, but at that point you basically "fix" it in time, so at that point the changelog actually makes sense.

It also turns out that in many situations, you can sort the result in other ways: the shortlog format, for example, is often superior to the default "git log" ordering, just because sorting things by person tends to actually result in a better view of what changed (it tells you something new: clumping by author not onyl tends to clump similar commits together and thus tell more of a "story", but it also has the added advantage of telling people who does what).

Generating things after-the-fact would also allow ordering things by what files (or subdirectories) they touch, although we've never done such a script. I do that quite often privately by just restricting the log to certain subsystems, though, and it's a damn useful thing to have. I would not be surprised at all if it might make sense to actually do a "tar-ball" changelog that way for certain projects - especially if they have clearly separated sub-components.

[ Btw, this whole "do things by pathname" has been so successful, that 
  I've come to realize that I would probably never accept an SCM that 
  doesn't allow something like that. Being able to do
	gitk some/random/set of/directories and/files
  is just _incredibly_ useful. Maybe others don't do it as much as I do, 
  but as a top-level maintainer, being able to look at history from the 
  viewpoint of just a random subset of the tree is incredibly powerful.
  I very strongly suspect that doing logs that way is often a good idea 
  too. ]
		Linus
Josef Weidendorfer· Oct 12, 2006, 17:02 UTC · re: Wolfgang Denk · lore

Re: cg-commit does not run pre-commit hook?

On Thursday 12 October 2006 17:54, Wolfgang Denk wrote:
> Yes, but only *after* doing the job. That's why  I'm  looking  for  a
> pre-commit hook.

pre-commit is not good either, as it runs *before* the editor pops up. So it can not access the commit message. You ask for a "pre-commit-post-edit" hook, which AFAIK currently is not available in git.

> True, as long as you can work within the SCM. The changelog file  I'm
> talking  about is mostly for people who just work with exported trees
> (for example, when they download a tarball).

Can't you create the Changelog directly before preparing such an tarball?

Usually when making a release/snapshot for a typical project, you can not directly take the newest tree from the SCM, but need to generate some files (like configure with automake/autoconf).

Josef
Show 6 quoted lines
> 
> 
> Best regards,
> 
> Wolfgang Denk
> 

← back to recent threads