{"thread":{"id":"34871","subject":"PATCH] Allow git-filter-branch to process large repositories with lots of branches.","startedAt":"2013-09-07T20:22:33Z","lastAt":"2013-09-07T20:37:54Z","messageCount":3,"participants":["Lee Carver","Andreas Schwab"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"227030","messageId":"CE50D917.191A5%lee.carver@corp.service-now.com","threadId":"34871","inReplyTo":null,"subject":"PATCH] Allow git-filter-branch to process large repositories with lots of branches.","fromName":"Lee Carver","fromEmail":"lee.carver@servicenow.com","sentAt":"2013-09-07T20:22:33Z","receivedAt":"2013-09-07T20:22:33Z","isPatch":false,"sender":{"key":"lee.carver@servicenow.com","avatar":null},"body":"As noted in several forums, a recommended way to move trees between\nrepositories is to use git-filter-branch to revise the history for a\nsingle tree \n(http://gbayer.com/development/moving-files-from-one-git-repository-to-anot\nher-preserving-history/,\nhttp://stackoverflow.com/questions/1365541/how-to-move-files-from-one-git-r\nepo-to-another-not-a-clone-preserving-history).\n\nHowever, this can lead to argument list too long errors when the original\nrepository has many retained branches (>6k)\n\n/usr/local/git/libexec/git-core/git-filter-branch: line 270:\n/usr/local/git/libexec/git-core/git: Argument list too long\nCould not get the commits\n\nPiping the output from git rev-parse directly into git rev-list avoids\nthis problem, since the rev-parse output is not processed as a command\nline argument.\n---\n git-filter-branch.sh | 5 ++---\n 1 file changed, 2 insertions(+), 3 deletions(-)\n\ndiff --git a/git-filter-branch.sh b/git-filter-branch.sh\nindex ac2a005..d7e0fae 100755\n--- a/git-filter-branch.sh\n+++ b/git-filter-branch.sh\n@@ -255,8 +255,6 @@ else\n \tremap_to_ancestor=t\n fi\n \n-rev_args=$(git rev-parse --revs-only \"$@\")\n-\n case \"$filter_subdir\" in\n \"\")\n \teval set -- \"$(git rev-parse --sq --no-revs \"$@\")\"\n@@ -267,8 +265,9 @@ case \"$filter_subdir\" in\n \t;;\n esac\n \n+git rev-parse --revs-only \"$@\" | \\\n git rev-list --reverse --topo-order --default HEAD \\\n-\t--parents --simplify-merges $rev_args \"$@\" > ../revs ||\n+\t--parents --simplify-merges --stdin \"$@\" > ../revs ||\n \tdie \"Could not get the commits\"\n commits=$(wc -l <../revs | tr -d \" \")\n \n-- \n1.8.3.2\n"},{"id":"227031","messageId":"87ppskgytz.fsf@igel.home","threadId":"34871","inReplyTo":"CE50D917.191A5%lee.carver@corp.service-now.com","subject":"Re: PATCH] Allow git-filter-branch to process large repositories with lots of branches.","fromName":"Andreas Schwab","fromEmail":"schwab@linux-m68k.org","sentAt":"2013-09-07T20:29:28Z","receivedAt":"2013-09-07T20:29:28Z","isPatch":false,"sender":{"key":"schwab@linux-m68k.org","avatar":"https://avatars.githubusercontent.com/u/2175493?v=4"},"body":"Lee Carver <Lee.Carver@servicenow.com> writes:\n\n> diff --git a/git-filter-branch.sh b/git-filter-branch.sh\n> index ac2a005..d7e0fae 100755\n> --- a/git-filter-branch.sh\n> +++ b/git-filter-branch.sh\n> @@ -255,8 +255,6 @@ else\n>  \tremap_to_ancestor=t\n>  fi\n>  \n> -rev_args=$(git rev-parse --revs-only \"$@\")\n> -\n>  case \"$filter_subdir\" in\n>  \"\")\n>  \teval set -- \"$(git rev-parse --sq --no-revs \"$@\")\"\n\nHere the arguments are reset.\n\n> @@ -267,8 +265,9 @@ case \"$filter_subdir\" in\n>  \t;;\n>  esac\n>  \n> +git rev-parse --revs-only \"$@\" | \\\n\nSo this is using a different argument list than before.\n\nAndreas.\n\n-- \nAndreas Schwab, schwab@linux-m68k.org\nGPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n\"And now for something completely different.\"\n"},{"id":"227032","messageId":"CE50DC35.191A8%lee.carver@corp.service-now.com","threadId":"34871","inReplyTo":"87ppskgytz.fsf@igel.home","subject":"Re: PATCH] Allow git-filter-branch to process large repositories with lots of branches.","fromName":"Lee Carver","fromEmail":"lee.carver@servicenow.com","sentAt":"2013-09-07T20:37:54Z","receivedAt":"2013-09-07T20:37:54Z","isPatch":false,"sender":{"key":"lee.carver@servicenow.com","avatar":null},"body":"Andreas -\n\nSo that's what the \"eval set -- \" does!\n\nWe actually got it to work with a temporary file Š I'll send that patch in\na minute.\n\nThanks\n   Lee\n\nOn 9/7/13 1:29 PM, \"Andreas Schwab\" <schwab@linux-m68k.org> wrote:\n\n>Lee Carver <Lee.Carver@servicenow.com> writes:\n>\n>> diff --git a/git-filter-branch.sh b/git-filter-branch.sh\n>> index ac2a005..d7e0fae 100755\n>> --- a/git-filter-branch.sh\n>> +++ b/git-filter-branch.sh\n>> @@ -255,8 +255,6 @@ else\n>>  \tremap_to_ancestor=t\n>>  fi\n>>  \n>> -rev_args=$(git rev-parse --revs-only \"$@\")\n>> -\n>>  case \"$filter_subdir\" in\n>>  \"\")\n>>  \teval set -- \"$(git rev-parse --sq --no-revs \"$@\")\"\n>\n>Here the arguments are reset.\n>\n>> @@ -267,8 +265,9 @@ case \"$filter_subdir\" in\n>>  \t;;\n>>  esac\n>>  \n>> +git rev-parse --revs-only \"$@\" | \\\n>\n>So this is using a different argument list than before.\n>\n>Andreas.\n>\n>-- \n>Andreas Schwab, schwab@linux-m68k.org\n>GPG Key fingerprint = 58CA 54C7 6D53 942B 1756  01D3 44D5 214B 8276 4ED5\n>\"And now for something completely different.\"\n"}]}