Merge branch 'lc/filter-branch-too-many-refs'
authorJunio C Hamano <gitster@pobox.com>
Thu, 17 Oct 2013 22:55:12 +0000 (15:55 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 17 Oct 2013 22:55:12 +0000 (15:55 -0700)
"git filter-branch" in a repository with many refs blew limit of
command line length.

* lc/filter-branch-too-many-refs:
Allow git-filter-branch to process large repositories with lots of branches.

1  2 
git-filter-branch.sh
diff --combined git-filter-branch.sh
index 98e8fe43d2fdde1b76e8f10f4c9473e23c8f347c,ca3d53919ad3b9b07a7147c31b7719c6ccca6232..86d6994619151fb63327848e6763b07971017ad7
@@@ -255,7 -255,7 +255,7 @@@ els
        remap_to_ancestor=t
  fi
  
- rev_args=$(git rev-parse --revs-only "$@")
+ git rev-parse --revs-only "$@" >../parse
  
  case "$filter_subdir" in
  "")
  esac
  
  git rev-list --reverse --topo-order --default HEAD \
-       --parents --simplify-merges $rev_args "$@" > ../revs ||
+       --parents --simplify-merges --stdin "$@" <../parse >../revs ||
        die "Could not get the commits"
  commits=$(wc -l <../revs | tr -d " ")
  
@@@ -283,12 -283,11 +283,12 @@@ while read commit parents; d
  
        case "$filter_subdir" in
        "")
 -              git read-tree -i -m $commit
 +              GIT_ALLOW_NULL_SHA1=1 git read-tree -i -m $commit
                ;;
        *)
                # The commit may not have the subdirectory at all
 -              err=$(git read-tree -i -m $commit:"$filter_subdir" 2>&1) || {
 +              err=$(GIT_ALLOW_NULL_SHA1=1 \
 +                    git read-tree -i -m $commit:"$filter_subdir" 2>&1) || {
                        if ! git rev-parse -q --verify $commit:"$filter_subdir"
                        then
                                rm -f "$GIT_INDEX_FILE"