Skip to content

Commit

Permalink
submodule: don't pass empty string arguments to submodule--helper clone
Browse files Browse the repository at this point in the history
When --reference or --depth are unused, the current git-submodule.sh
results in empty "" arguments appended to the end of the argv array
inside git submodule--helper clone. This is not caught because the argc
count is not checked today.

Fix git-submodule.sh to only pass an argument when --reference or
--depth are used, preventing the addition of two empty string arguments
on the tail of the argv array.

Signed-off-by: Jacob Keller <jacob.keller@gmail.com>
Reviewed-by: Stefan Beller <sbeller@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jacob Keller authored and Junio C Hamano committed Mar 1, 2016
1 parent 5922322 commit d10e3b4
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions git-submodule.sh
Original file line number Diff line number Diff line change
Expand Up @@ -347,7 +347,7 @@ Use -f if you really want to add it." >&2
echo "$(eval_gettext "Reactivating local git directory for submodule '\$sm_name'.")"
fi
fi
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" "$reference" "$depth" || exit
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$wt_prefix" --path "$sm_path" --name "$sm_name" --url "$realrepo" ${reference:+"$reference"} ${depth:+"$depth"} || exit
(
clear_local_git_env
cd "$sm_path" &&
Expand Down Expand Up @@ -709,7 +709,7 @@ Maybe you want to use 'update --init'?")"

if ! test -d "$sm_path"/.git && ! test -f "$sm_path"/.git
then
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" "$reference" "$depth" || exit
git submodule--helper clone ${GIT_QUIET:+--quiet} --prefix "$prefix" --path "$sm_path" --name "$name" --url "$url" ${reference:+"$reference"} ${depth:+"$depth"} || exit
cloned_modules="$cloned_modules;$name"
subsha1=
else
Expand Down

0 comments on commit d10e3b4

Please sign in to comment.