Subject: Re: [PATCH] git-filter-branch: Add an example on how to remove empty commits

From: Pierre Habouzit <[email-masked]>
Date: Thu, 30 Oct 2008 14:26:23 +0100

On Thu, Oct 30, 2008 at 12:33:53AM +0000, Petr Baudis wrote:
> From: Sverre Rabbelier <[email-masked]>
> 
> Signed-off-by: Sverre Rabbelier <[email-masked]>
> Signed-off-by: Petr Baudis <[email-masked]>
> ---
>  Documentation/git-filter-branch.txt |   15 +++++++++++++++
>  1 files changed, 15 insertions(+), 0 deletions(-)
> 
> diff --git a/Documentation/git-filter-branch.txt b/Documentation/git-filter-branch.txt
> index fed6de6..2565244 100644
> --- a/Documentation/git-filter-branch.txt
> +++ b/Documentation/git-filter-branch.txt
> @@ -246,6 +246,21 @@ git filter-branch --commit-filter '
>  	fi' HEAD
>  ------------------------------------------------------------------------------
>  
> +To remove commits that are empty (do not introduce any change):
> +
> +------------------------------------------------------------------------------
> +git rev-list HEAD | while read c; do [ -n "$(git diff-tree --root $c)" ] || echo $c; done > revs
> +
> +git filter-branch --commit-filter '
> +  if grep -q "$GIT_COMMIT" '"$(pwd)/"revs';
> +  then
> +    skip_commit "$@";
> +  else
> +    git commit-tree "$@";
> +  fi' HEAD
> +
> +------------------------------------------------------------------------------

Why not add an option to filter-branch that removes a commit if it's
empty ? It's quite useful, it helps the user concentrating on just
keeping what matches *his* criteriums, and not caring about the minor
details of cleansing the result.
-- 
·O·  Pierre Habouzit
··O                                                [email-masked]
OOO                                                http://www.madism.org