Re: Quick question: end of lines
- From
Junio C Hamano <junkio@cox.net>
- Date
- Mar 1, 2006, 09:01 UTC
- Message-ID
- <7vwtfelerx.fsf@assigned-by-dhcp.cox.net>
- In-Reply-To
- <46a038f90603010031g31f8bc33xd3f45f2e19950c78@mail.gmail.com>
"Martin Langhoff" <martin.langhoff@gmail.com> writes:
Show 11 quoted lines
> On 3/1/06, Emmanuel Guerin <emmanuel@guerin.fr.eu.org> 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