Skip to content

Commit

Permalink
git-fetch: Fix "argument list too long"
Browse files Browse the repository at this point in the history
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>
  • Loading branch information
OGAWA Hirofumi authored and Junio C Hamano committed Apr 24, 2007
1 parent 2122591 commit afb5f39
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 6 deletions.
6 changes: 5 additions & 1 deletion builtin-fetch--tool.c
Original file line number Diff line number Diff line change
Expand Up @@ -571,9 +571,13 @@ int cmd_fetch__tool(int argc, const char **argv, const char *prefix)
return parse_reflist(reflist);
}
if (!strcmp("pick-rref", argv[1])) {
const char *ls_remote_result;
if (argc != 4)
return error("pick-rref takes 2 args");
return pick_rref(sopt, argv[2], argv[3]);
ls_remote_result = argv[3];
if (!strcmp(ls_remote_result, "-"))
ls_remote_result = get_stdin();
return pick_rref(sopt, argv[2], ls_remote_result);
}
if (!strcmp("expand-refs-wildcard", argv[1])) {
const char *reflist;
Expand Down
11 changes: 6 additions & 5 deletions git-fetch.sh
Original file line number Diff line number Diff line change
Expand Up @@ -189,16 +189,17 @@ fetch_all_at_once () {
# See if all of what we are going to fetch are
# connected to our repository's tips, in which
# case we do not have to do any fetch.
theirs=$(git-fetch--tool -s pick-rref \
"$rref" "$ls_remote_result") &&
theirs=$(echo "$ls_remote_result" | \
git-fetch--tool -s pick-rref "$rref" "-") &&
# This will barf when $theirs reach an object that
# we do not have in our repository. Otherwise,
# we already have everything the fetch would bring in.
git-rev-list --objects $theirs --not --all \
>/dev/null 2>/dev/null
then
git-fetch--tool pick-rref "$rref" "$ls_remote_result"
echo "$ls_remote_result" | \
git-fetch--tool pick-rref "$rref" "-"
else
git-fetch-pack --thin $exec $keep $shallow_depth \
$quiet $no_progress "$remote" $rref ||
Expand Down Expand Up @@ -263,8 +264,8 @@ fetch_per_ref () {
fi
# Find $remote_name from ls-remote output.
head=$(git-fetch--tool -s pick-rref \
"$remote_name" "$ls_remote_result")
head=$(echo "$ls_remote_result" | \
git-fetch--tool -s pick-rref "$remote_name" "-")
expr "z$head" : "z$_x40\$" >/dev/null ||
die "No such ref $remote_name at $remote"
echo >&2 "Fetching $remote_name from $remote using $proto"
Expand Down

0 comments on commit afb5f39

Please sign in to comment.