git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH] filter-branch: add git_commit_non_empty_tree and --prune-empty.

From
Pierre Habouzit <madcoder@debian.org>
Date
Nov 3, 2008, 09:27 UTC
Message-ID
<20081103092729.GE13930@artemis.corp>
In-Reply-To
<7viqr5wgl7.fsf@gitster.siamese.dyndns.org>
On Mon, Nov 03, 2008 at 04:58:44AM +0000, Junio C Hamano wrote:
Show 31 quoted lines
> Pierre Habouzit <madcoder@debian.org> writes:
> 
> > +case "$prune_empty,$filter_commit" in
> > +',')
> > +	filter_commit='git commit-tree "$@"';;
> > +'t,')
> > +	filter_commit="$functions;"' git_commit_non_empty_tree "$@"';;
> > +','*)
> > +	;;
> > +*)
> > +	die "Cannot set --prune-empty and --filter-commit at the same time"
> > +esac
> 
> This is only style issue, but I find the above extremely difficult to
> read.  If it were either:
> 
> 	case ... in
>         ,) do "neither set case" ;;
>         t,) do "prune but not filter case" ;;
>         *) do "both set case" ;;
>         esac
> 
> or (rather amateurish but conveys what it wants to do more clearly):
>         
> 	case ... in
>         '','') do "neither set case" ;;
>         t,'') do "prune but not filter case" ;;
>         t,t) do "both set case" ;;
>         esac
> 
> I wouldn't have to wonder which sq pairs with which one.
agreed.
Show 16 quoted lines
> > diff --git a/t/t7003-filter-branch.sh b/t/t7003-filter-branch.sh
> > index b0a9d7d..352b56b 100755
> > --- a/t/t7003-filter-branch.sh
> > +++ b/t/t7003-filter-branch.sh
> > @@ -262,4 +262,12 @@ test_expect_success 'Tag name filtering allows slashes in tag names' '
> >  	test_cmp expect actual
> >  '
> >  
> > +test_expect_success 'Prune empty commits' '
> > +	make_commit to_remove &&
> > +	(git rev-list HEAD | grep -v $(git rev-parse HEAD)) > expect &&
> 
> I am not sure what this one is doing.
> 
>  - Isn't this the same as "git rev-list HEAD^"?
>  - Do you need a subshell?

The filter-branch is supposed to prune the last commit done (current HEAD) from the revision list. So I build the rev-list we're supposed to have in the end, and remove the matching ref from it. I don't see how to avoid the subshell though, but if someone knows better please do :)

-- 
·O·  Pierre Habouzit
··O                                                madcoder@debian.org
OOO                                                http://www.madism.org
Previous: Junio C HamanoNext: Pierre Habouzit
Message 15 of 25 in “git-filter-branch: Add an example on how to remove empty commits”
  1. git-filter-branch: Add an example on how to remove empty commitsPetr Baudis, Oct 30, 2008
  2. Sam VilainOct 30, 2008
  3. Johannes SchindelinOct 30, 2008
  4. Pierre HabouzitOct 30, 2008
  5. Deskin MillerOct 30, 2008
  6. Pierre HabouzitOct 30, 2008
  7. filter-branch enhancementsPierre Habouzit, Oct 30, 2008
  8. make git-filter-branch use parse-options.Pierre Habouzit, Oct 30, 2008
  9. implement --prune-empty switch for filter-branchPierre Habouzit, Oct 30, 2008
  10. Pierre HabouzitOct 31, 2008
  11. filter-branch: add git_commit_non_empty_tree and --prune-empty.Pierre Habouzit, Oct 31, 2008
  12. Johannes SchindelinOct 31, 2008
  13. Pierre HabouzitOct 31, 2008
  14. Junio C HamanoNov 3, 2008
  15. Pierre HabouzitNov 3, 2008
  16. Pierre HabouzitNov 3, 2008
  17. Jay SoffianJan 9, 2009
  18. Pierre HabouzitJan 11, 2009
  19. Johannes SchindelinJan 11, 2009
  20. Pierre HabouzitJan 11, 2009
  21. Sverre RabbelierJan 11, 2009
  22. Pierre HabouzitJan 11, 2009
  23. Sverre RabbelierJan 11, 2009
  24. Junio C HamanoJan 11, 2009
  25. Johannes SchindelinJan 11, 2009

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.