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

Re: [PATCH v4 1/2] filter-branch: stop special-casing $filter_subdir argument

From
Johannes Sixt <j.sixt@viscovery.net>
Date
Nov 11, 2009, 08:30 UTC
Message-ID
<4AFA7624.5040400@viscovery.net>
In-Reply-To
<0280836a32983c848bbb0e3b441be256d3c8f4fa.1257885121.git.trast@student.ethz.ch>
Thomas Rast schrieb:
Show 10 quoted lines
> Johannes Sixt wrote:
>> # we need "--" only if there are no path arguments in $@
>> nonrevs=$(git rev-parse --no-revs "$@") || exit
>> dashdash=${nonrevs+"--"}
>>
>> (including the comment; you can drop the dquotes in the dashdash
>> assignment if you think the result is still readable.)
> 
> Ok.  I was briefly scared that this was bash-specific syntax, but dash
> seems happy so I'll trust your advice.
You shouldn't. I'm wrong ;-)

In the snippet above, dashdash will always be set to "--" because a mere '+' in the variable expansion only tests whether the variable ('nonrevs') is unset, but it is always set. Even ${nonrevs:+"--"} is wrong, and your earlier 'test -z' invocation was the correct way to set dashdash.

But...

I did some testing, and now I have to wonder about the use-case that you present in the commit message:

Show 5 quoted lines
> Furthermore, the case for --subdirectory-filter supplies its own --,
> so the user cannot provide one himself, so the following was
> impossible:
>
>   git filter-branch --subdirectory-filter subdir -- --all -- subdir/file
If you try in git.git itself:
  $ git rev-list --simplify-merges --all -- \
	Documentation/git-commit.txt | wc -l
  84
  $ git rev-list --simplify-merges --all -- \
	Documentation/git-commit.txt Documentation | wc -l
  4624

I thought that the intention to give an extra path argument is to reduce the number of commits that remain in the rewritten history. But by giving --subdirectory-filter, the path filter actually loosened, and many more commits are rewritten.

Since your intention to write this patch is actually to implement --remap-to-ancestor, I suggest that we defer the question whether the above use-case makes sense, and only rewrite this particular paragraph in the commit message to point out the real bug:

----- Furthermore, --subdirectory-filter supplies its own '--', and if the user provided one himself, such as in

  git filter-branch --subdirectory-filter subdir -- --all -- subdir/file

an extra '--' was used as path filter in the call to git-rev-list that determines the commits that shall be rewritten. -----

I'll submit a replacement patch.
-- Hannes
Previous: Thomas RastNext: Johannes Sixt
Message 14 of 22 in “filter-branch: stop special-casing $filter_subdir argument”
  1. 1/2 filter-branch: stop special-casing $filter_subdir argumentThomas Rast, Oct 21, 2009
  2. 2/2 filter-branch: nearest-ancestor rewriting outside subdir filterThomas Rast, Oct 21, 2009
  3. 1/2 filter-branch: stop special-casing $filter_subdir argumentThomas Rast, Oct 21, 2009
  4. 2/2 filter-branch: nearest-ancestor rewriting outside subdir filterThomas Rast, Oct 21, 2009
  5. Johannes SixtOct 22, 2009
  6. Thomas RastOct 22, 2009
  7. Johannes SixtOct 22, 2009
  8. 1/2 filter-branch: stop special-casing $filter_subdir argumentThomas Rast, Oct 28, 2009
  9. 2/2 filter-branch: nearest-ancestor rewriting outside subdir filterThomas Rast, Oct 28, 2009
  10. Johannes SixtOct 29, 2009
  11. Johannes SixtOct 29, 2009
  12. 1/2 filter-branch: stop special-casing $filter_subdir argumentThomas Rast, Nov 10, 2009
  13. 2/2 filter-branch: nearest-ancestor rewriting outside subdir filterThomas Rast, Nov 10, 2009
  14. Johannes SixtNov 11, 2009
  15. 1/2 filter-branch: stop special-casing $filter_subdir argumentJohannes Sixt, Nov 11, 2009
  16. 2/2 filter-branch: nearest-ancestor rewriting outside subdir filterJohannes Sixt, Nov 11, 2009
  17. Junio C HamanoNov 11, 2009
  18. Thomas RastNov 11, 2009
  19. Johannes SixtNov 11, 2009
  20. Thomas RastNov 11, 2009
  21. Johannes SixtNov 11, 2009
  22. Junio C HamanoNov 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.