[Ovirt-devel] coming soon: prohibition on pushing bad-whitespace-adding changes

mark wagner mwagner at redhat.com
Tue Jul 29 18:11:43 UTC 2008


Jim

Will this only impact a push that adds bad whitespace or will it
also impact a file that may already have bad whitespace but I
only touch a line that doesn't have "bad" whitespace ?


I guess I'm trying to determine if we just need to go through
and clean all the files now.  If we the check is only for files
that add new bad whitespace, then we are living with the existing
bad whitespace already in the code...

-mark

Jim Meyering wrote:
> In the next couple of days, I expect to enable a git hook on the server
> that will deny any attempt to push a change that adds "bad" whitespace.
> In the mean time, you who will be pushing or posting changes should be
> sure to enable commit-time checks for white space:
> 
>   Run "chmod a+x .git/hooks/update" (if you already have the file,
>   .git/hooks/update) or "cd .git/hooks && cp -a update.sample update"
>   if you have one named update.sample.
> 
> That will help you by making your local commits fail whenever
> a change adds bad (e.g. trailing) whitespace.  If that happens,
> it tells you which file/line-number are affected, and you just
> edit those lines and retry the commit.
> 
> If you forget and commit (locally) changes that add trailing blanks,
> you'll have to edit those change sets e.g., via "git rebase -i next",
> before you can push them.
> 
> FYI, I've included below the patch I'll apply to the server-side
> .git/hooks/update script.
> 
> For reference, to disable it, you would do this on the server:
> 
>     git --git-dir=/var/www/git/ovirt.git/hooks \
>       config hooks.allowbadwhitespace false
> 
>>From 1660659d0d38e1138ca402e486b62292e018d8fd Mon Sep 17 00:00:00 2001
> From: Jim Meyering <meyering at redhat.com>
> Date: Tue, 29 Jul 2008 18:16:50 +0200
> Subject: [PATCH] Reject any attempt to push a change that adds "bad" whitespace.
> 
> Override with this:
> 	git config hooks.allowbadwhitespace true
> 
> ---
>  templates/hooks--update.sample |   10 ++++++++++
>  1 files changed, 10 insertions(+), 0 deletions(-)
> 
> diff --git a/templates/hooks--update.sample b/templates/hooks--update.sample
> index 93c6055..fa372c3 100755
> --- a/templates/hooks--update.sample
> +++ b/templates/hooks--update.sample
> @@ -56,6 +56,7 @@ else
>  	newrev_type=$(git-cat-file -t $newrev)
>  fi
> 
> +check_diff=no
>  case "$refname","$newrev_type" in
>  	refs/tags/*,commit)
>  		# un-annotated tag
> @@ -78,6 +79,7 @@ case "$refname","$newrev_type" in
>  		;;
>  	refs/heads/*,commit)
>  		# branch
> +		check_diff=yes
>  		;;
>  	refs/heads/*,delete)
>  		# delete branch
> @@ -88,6 +90,7 @@ case "$refname","$newrev_type" in
>  		;;
>  	refs/remotes/*,commit)
>  		# tracking branch
> +		check_diff=yes
>  		;;
>  	refs/remotes/*,delete)
>  		# delete tracking branch
> @@ -103,5 +106,12 @@ case "$refname","$newrev_type" in
>  		;;
>  esac
> 
> +if [ $check_diff = yes ]; then
> +	allow_bad_whitespace=$(git config --bool hooks.allowbadwhitespace)
> +	if [ "$allow_bad_whitespace" != "true" ]; then
> +		exec git diff --check $oldrev $newrev --
> +	fi
> +fi
> +
>  # --- Finished
>  exit 0
> --
> 1.5.6.4.435.g780ea
> 
> _______________________________________________
> Ovirt-devel mailing list
> Ovirt-devel at redhat.com
> https://www.redhat.com/mailman/listinfo/ovirt-devel




More information about the ovirt-devel mailing list