From: Junio C Hamano Date: Wed, 01 Mar 2006 09:01:38 GMT Subject: Re: Quick question: end of lines Message-ID: <7vwtfelerx.fsf@assigned-by-dhcp.cox.net> In-Reply-To: <46a038f90603010031g31f8bc33xd3f45f2e19950c78@mail.gmail.com> "Martin Langhoff" writes: > On 3/1/06, Emmanuel Guerin wrote: >> What I begin to realize is that the only possibility probably lies in >> using a tool that converts the modified files "on the fly" before >> commits. I just want to make sure that no other solution was found by >> others facing a similar problem. > > Perhaps a pre-commit hook? Read the documentation (and search the list > archives). I'm pretty sure you can do newline cleanup before commit or > at least newline checks before commits. > > There's always the option of filing a bug in MS's bugzilla ;-) You can use .git/hooks/pre-commit hook in the repository the editor that munges line-termination, to fix things up. The hook is called with GIT_INDEX_FILE set to the appropriate index file, so you could "git-diff-index --cached --name-only HEAD" to obtain the list of files being committed, sanitize the working tree files and update-index them again before returning true from the hook. This is a silly example to standardize on uppercase. git-diff-index --cached --name-only HEAD | xargs sh -c ' while case "$#" in 0) break ;; esac do perl -p -i -e "\$_ = uc(\$_)" "$1" git-update-index "$1" shift done ' dummy exit 0