Hi Steve, Steve Cotton wrote:
> "git commit" will give no warning when committing a file that includes > trailing whitespace. > > However, "git rebase" will complain when applying a commit with trailing > whitespace. Sorry for the long silence. Here are some quick thoughts: 1. "git commit" can be used in a variety of ways, and so it makes sense to me that it would not assume that an ugly commit is a mistake. For example, some people like to work like this: ... hack hack hack ... git commit -a; # save partial work ... hack hack hack ... git commit -a; # another roundup ... hack ... git commit -a; # done! make test ... fix ... git commit -a; # okay, really done. git rebase -i origin; # now make all that easier to review. Even worse is if some script starts to emit mysterious messages about whitespace errors. So although these warnings are helpful, I think it is right not to turn them on by default. 2. The original purpose of "git rebase" was to adapt a patch series to a more recent upstream codebase before mailing it out. It is about cleaning up. 3. Okay, so if the defaults make sense, how do I override them? This is where things get ugly. To add new pre-commit checks, one can use a pre-commit hook, as you mentioned: mv .git/hooks/pre-commit.sample .git/hooks/pre-commit What if I want to enable that for all new repositories? No problem. cp -R /usr/share/git-core/templates $HOME/.config/git-templates echo '[init] templatedir = ~/.config/git-templates' >>$HOME/.gitconfig mv $HOME/.config/git-templates/hooks/pre-commit.sample \ $HOME/.config/git-templates/hooks/pre-commit What if I want to be able to change that setting in the future? Then "template" is not the right paradigm; I would use a single, shared hook directory instead. mv $HOME/.config/git-templates/hooks $HOME/.config/git-hooks ln -s $HOME/.config/git-hooks $HOME/.config/git-templates/hooks What about changing existing repositories retroactively? cat <<-\EOF >>$HOME/.gitconfig [alias] set-hooks = !"sh -c 'rm -fr .git/hooks && ln -s $1 .git/hooks' -" EOF for i in repo1 repo2 repo3 do (cd $i && git set-hooks $HOME/.config/git-hooks) done What about overriding hook scripts for a single repository? The shared hooks can handle that themselves. hook=$(basename "$0") if test -e "$GIT_DIR/local-hooks/$hook.disable" then exit 0 fi if test -e "$GIT_DIR/local-hooks/$hook" then exec "$GIT_DIR/local-hooks/$hook" fi ... What about overriding the warning from "git rebase"? That is easier. echo '[apply] whitespace = fix' >>$HOME/.gitconfig You can use "nowarn" instead of "fix" if you do not want the errors to be silently fixed up. All that said, I imagine we could be more friendly, e.g. by documenting some of this or making messages clearer. Ideas? Thanks, Jonathan based on http://thread.gmane.org/gmane.comp.version-control.git/150141/focus=150150 -- To UNSUBSCRIBE, email to debian-bugs-dist-requ...@lists.debian.org with a subject of "unsubscribe". Trouble? Contact listmas...@lists.debian.org