# [PATCH] Make filter-branch work with many branches

3 messages from 2011-07-19 to 2011-07-20. Participants: Dave Zarzycki, Johannes Sixt.
Thread: https://gitlist.dev/t/27854

## Dave Zarzycki, 2011-07-19 16:29

Subject: [PATCH] Make filter-branch work with many branches
Message-ID: <E186982C-71AE-4C08-B857-A67BDCD21E3D@apple.com>
URL: https://gitlist.dev/e/E186982C-71AE-4C08-B857-A67BDCD21E3D%40apple.com

```
When there are many branches, we can overflow the maximum number of
arguments to exec*().

Signed-off-by: Dave Zarzycki <zarzycki@apple.com>
---
 git-filter-branch.sh |    6 ++----
 1 files changed, 2 insertions(+), 4 deletions(-)

diff --git a/git-filter-branch.sh b/git-filter-branch.sh
index 962a93b..0c03db0 100755
--- a/git-filter-branch.sh
+++ b/git-filter-branch.sh
@@ -274,8 +274,6 @@ else
 	remap_to_ancestor=t
 fi
 
-rev_args=$(git rev-parse --revs-only "$@")
-
 case "$filter_subdir" in
 "")
 	eval set -- "$(git rev-parse --sq --no-revs "$@")"
@@ -286,8 +284,8 @@ case "$filter_subdir" in
 	;;
 esac
 
-git rev-list --reverse --topo-order --default HEAD \
-	--parents --simplify-merges $rev_args "$@" > ../revs ||
+git rev-parse --revs-only "$@" | git rev-list --stdin --reverse --topo-order \
+	--default HEAD --parents --simplify-merges "$@" > ../revs ||
 	die "Could not get the commits"
 commits=$(wc -l <../revs | tr -d " ")
 
-- 
1.7.6.135.g8cdba

```

## Johannes Sixt, 2011-07-19 18:06

Subject: Re: [PATCH] Make filter-branch work with many branches
Message-ID: <4E25C78A.1090600@kdbg.org>
URL: https://gitlist.dev/e/4E25C78A.1090600%40kdbg.org
In-Reply-To: <E186982C-71AE-4C08-B857-A67BDCD21E3D@apple.com>

```
Am 19.07.2011 18:29, schrieb Dave Zarzycki:
> -rev_args=$(git rev-parse --revs-only "$@")
> -
>  case "$filter_subdir" in
>  "")
>  	eval set -- "$(git rev-parse --sq --no-revs "$@")"

This line in the hunk context changes what "$@" will produce. Therefore,
the "$@" that you removed above will not produce the same thing...

> @@ -286,8 +284,8 @@ case "$filter_subdir" in
>  	;;
>  esac
>  
> -git rev-list --reverse --topo-order --default HEAD \
> -	--parents --simplify-merges $rev_args "$@" > ../revs ||
> +git rev-parse --revs-only "$@" | git rev-list --stdin --reverse --topo-order \
> +	--default HEAD --parents --simplify-merges "$@" > ../revs ||

... that you insert here. How can the result ever have worked for you?

Perhaps store the list of revs in a temporary file?

-- Hannes

```

## Dave Zarzycki, 2011-07-20 13:34

Subject: Re: [PATCH] Make filter-branch work with many branches
Message-ID: <E7EC8C9A-DB1C-4C75-A860-7132E36C9369@apple.com>
URL: https://gitlist.dev/e/E7EC8C9A-DB1C-4C75-A860-7132E36C9369%40apple.com
In-Reply-To: <4E25C78A.1090600@kdbg.org>

```

On Jul 19, 2011, at 11:06 AM, Johannes Sixt wrote:

> Am 19.07.2011 18:29, schrieb Dave Zarzycki:
>> -rev_args=$(git rev-parse --revs-only "$@")
>> -
>> case "$filter_subdir" in
>> "")
>> 	eval set -- "$(git rev-parse --sq --no-revs "$@")"
> 
> This line in the hunk context changes what "$@" will produce. Therefore,
> the "$@" that you removed above will not produce the same thing...

Thanks. My shell scripting is rather rusty these days. I'll send a new patch.

davez

```
