This is the mail archive of the
libc-alpha@sourceware.org
mailing list for the glibc project.
Re: glibc.git: hook to prohibit pushing "bad-merge" commits
- From: Jim Meyering <jim at meyering dot net>
- To: "GNU C. Library" <libc-alpha at sourceware dot org>
- Date: Thu, 04 Jun 2009 09:05:50 +0200
- Subject: Re: glibc.git: hook to prohibit pushing "bad-merge" commits
- References: <8763fpkzp4.fsf@meyering.net>
Jim Meyering wrote:
> I'm about to add a hook that will prohibit useless merge commits.
>
> That means if you accidentally create a merge commit, e.g., by
> pulling new changes from master onto your just-modified master,
> and then try to push the result (which contains a merge commit),
> the hook will reject it.
>
> This will not affect you if you follow these guidelines:
> (may sound slightly involved if you're new to git, but it's not bad at
> all once you get used to it):
>
> Develop exclusively on topic branches and pull the result to master
> only seconds before the actual push-to-public, and only seconds after
> updating your pristine "master" branch from the public repository.
> Of course, if the update-from-public pulled in new changes, you must
> rebase your topic branch to be relative to the new tip of "master",
> probably recompile to be sure everything is still ok, etc.
> That way, the window for accidental merge commit is minimized.
>
> By default, that hook script has an independent setting to prohibit
> pushing a commit that adds trailing blanks. If committers don't want
> that, let me know and I'll turn it off. However, I suggest that you
> leave it enabled and, if necessary, add '.gitattributes' entries to allow
> whatever violations you deem appropriate.
>
> Barring objections, I'll enable it tomorrow.
It's actually been a week now, and no one commented,
so I have just enabled this hook.
FYI, I noticed that it would have blocked the "push" of at least
one recent commit, since it contained trailing blanks.
I highly recommend enabling the sample pre-commit hook you'll
find in any git repository you have. To do that, run this command:
mv .git/hooks/pre-commit.sample .git/hooks/pre-commit
However, if you created the repository using an aging version of git,
that will fail, and you will have to do it like this instead:
chmod a+x .git/hooks/pre-commit
Once you do that, your config-specifiable trailing whitespace policy
will be honored by that pre-commit hook. I.e., by default, if you try
to commit a change that adds (or modifies and leaves) trailing blanks, it
will make the commit fail. Note however that this is a local-only hook.
It can be skipped via commit -f and is independent of the server-side
hook I installed above. It helps you avoid committing things that the
server-side hook would reject when you attempt to push to the public
repository.