git-fetch: Fix "argument list too long"
If $ls_remote_result was too long, git-fetch--tool -s pick-rref "$rref" "$ls_remote_result" in git-fetch will fail with "argument list too long". This patch fixes git-fetch--tool and git-fetch by passing $ls_remote_result via stdin. Signed-off-by: OGAWA Hirofumi <hirofumi@mail.parknet.co.jp> Signed-off-by: Junio C Hamano <junkio@cox.net>
OGAWA Hirofumi committed
Apr 24, 2007 at 04:26 UTC
afb5f39e24eadc5933b34cfd17c1089e482d6a6b
2 files changed
+11
-6
builtin-fetch--tool.c
+5
-1
@@ -571,9 +571,13 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
571
return parse_reflist(reflist);
572
}
573
if (!strcmp("pick-rref", argv[1])) {
574
+ const char *ls_remote_result;
575
if (argc != 4)
576
return error("pick-rref takes 2 args");
576
- return pick_rref(sopt, argv[2], argv[3]);
577
+ ls_remote_result = argv[3];
578
+ if (!strcmp(ls_remote_result, "-"))
579
+ ls_remote_result = get_stdin();
580
+ return pick_rref(sopt, argv[2], ls_remote_result);
581
}
582
if (!strcmp("expand-refs-wildcard", argv[1])) {
583
const char *reflist;
git-fetch.sh
+6
-5
@@ -189,8 +189,8 @@ fetch_all_at_once () {
189
# See if all of what we are going to fetch are
190
# connected to our repository's tips, in which
191
# case we do not have to do any fetch.
192
- theirs=$(git-fetch--tool -s pick-rref \
193
- "$rref" "$ls_remote_result") &&
192
+ theirs=$(echo "$ls_remote_result" | \
193
+ git-fetch--tool -s pick-rref "$rref" "-") &&
194
195
# This will barf when $theirs reach an object that
196
# we do not have in our repository. Otherwise,
@@ -198,7 +198,8 @@ fetch_all_at_once () {
198
git-rev-list --objects $theirs --not --all \
199
>/dev/null 2>/dev/null
200
then
201
- git-fetch--tool pick-rref "$rref" "$ls_remote_result"
201
+ echo "$ls_remote_result" | \
202
+ git-fetch--tool pick-rref "$rref" "-"
203
else
204
git-fetch-pack --thin $exec $keep $shallow_depth \
205
$quiet $no_progress "$remote" $rref ||
@@ -263,8 +264,8 @@ fetch_per_ref () {
264
fi
265
266
# Find $remote_name from ls-remote output.
266
- head=$(git-fetch--tool -s pick-rref \
267
- "$remote_name" "$ls_remote_result")
267
+ head=$(echo "$ls_remote_result" | \
268
+ git-fetch--tool -s pick-rref "$remote_name" "-")
269
expr "z$head" : "z$_x40\$" >/dev/null ||
270
die "No such ref $remote_name at $remote"
271
echo >&2 "Fetching $remote_name from $remote using $proto"