Merge branch 'jk/submodule-subdirectory-ok'
Allow various subcommands of "git submodule" to be run not from the top of the working tree of the superproject. * jk/submodule-subdirectory-ok: submodule: drop the top-level requirement rev-parse: add --prefix option submodule: show full path in error message t7403: add missing && chaining t7403: modernize style t7401: make indentation consistent
This commit is contained in:
commit
d9857bfd4d
@ -59,6 +59,22 @@ OPTIONS
|
|||||||
If there is no parameter given by the user, use `<arg>`
|
If there is no parameter given by the user, use `<arg>`
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
|
--prefix <arg>::
|
||||||
|
Behave as if 'git rev-parse' was invoked from the `<arg>`
|
||||||
|
subdirectory of the working tree. Any relative filenames are
|
||||||
|
resolved as if they are prefixed by `<arg>` and will be printed
|
||||||
|
in that form.
|
||||||
|
+
|
||||||
|
This can be used to convert arguments to a command run in a subdirectory
|
||||||
|
so that they can still be used after moving to the top-level of the
|
||||||
|
repository. For example:
|
||||||
|
+
|
||||||
|
----
|
||||||
|
prefix=$(git rev-parse --show-prefix)
|
||||||
|
cd "$(git rev-parse --show-toplevel)"
|
||||||
|
eval "set -- $(git rev-parse --sq --prefix "$prefix" "$@")"
|
||||||
|
----
|
||||||
|
|
||||||
--verify::
|
--verify::
|
||||||
Verify that exactly one parameter is provided, and that it
|
Verify that exactly one parameter is provided, and that it
|
||||||
can be turned into a raw 20-byte SHA-1 that can be used to
|
can be turned into a raw 20-byte SHA-1 that can be used to
|
||||||
|
@ -212,11 +212,17 @@ static void show_datestring(const char *flag, const char *datestr)
|
|||||||
show(buffer);
|
show(buffer);
|
||||||
}
|
}
|
||||||
|
|
||||||
static int show_file(const char *arg)
|
static int show_file(const char *arg, int output_prefix)
|
||||||
{
|
{
|
||||||
show_default();
|
show_default();
|
||||||
if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
|
if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
|
||||||
show(arg);
|
if (output_prefix) {
|
||||||
|
const char *prefix = startup_info->prefix;
|
||||||
|
show(prefix_filename(prefix,
|
||||||
|
prefix ? strlen(prefix) : 0,
|
||||||
|
arg));
|
||||||
|
} else
|
||||||
|
show(arg);
|
||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
return 0;
|
return 0;
|
||||||
@ -470,6 +476,7 @@ N_("git rev-parse --parseopt [options] -- [<args>...]\n"
|
|||||||
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
||||||
{
|
{
|
||||||
int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
|
int i, as_is = 0, verify = 0, quiet = 0, revs_count = 0, type = 0;
|
||||||
|
int output_prefix = 0;
|
||||||
unsigned char sha1[20];
|
unsigned char sha1[20];
|
||||||
const char *name = NULL;
|
const char *name = NULL;
|
||||||
|
|
||||||
@ -503,7 +510,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
const char *arg = argv[i];
|
const char *arg = argv[i];
|
||||||
|
|
||||||
if (as_is) {
|
if (as_is) {
|
||||||
if (show_file(arg) && as_is < 2)
|
if (show_file(arg, output_prefix) && as_is < 2)
|
||||||
verify_filename(prefix, arg, 0);
|
verify_filename(prefix, arg, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -527,7 +534,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
as_is = 2;
|
as_is = 2;
|
||||||
/* Pass on the "--" if we show anything but files.. */
|
/* Pass on the "--" if we show anything but files.. */
|
||||||
if (filter & (DO_FLAGS | DO_REVS))
|
if (filter & (DO_FLAGS | DO_REVS))
|
||||||
show_file(arg);
|
show_file(arg, 0);
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
if (!strcmp(arg, "--default")) {
|
if (!strcmp(arg, "--default")) {
|
||||||
@ -535,6 +542,13 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
i++;
|
i++;
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (!strcmp(arg, "--prefix")) {
|
||||||
|
prefix = argv[i+1];
|
||||||
|
startup_info->prefix = prefix;
|
||||||
|
output_prefix = 1;
|
||||||
|
i++;
|
||||||
|
continue;
|
||||||
|
}
|
||||||
if (!strcmp(arg, "--revs-only")) {
|
if (!strcmp(arg, "--revs-only")) {
|
||||||
filter &= ~DO_NOREV;
|
filter &= ~DO_NOREV;
|
||||||
continue;
|
continue;
|
||||||
@ -754,7 +768,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
|
|||||||
if (verify)
|
if (verify)
|
||||||
die_no_single_rev(quiet);
|
die_no_single_rev(quiet);
|
||||||
as_is = 1;
|
as_is = 1;
|
||||||
if (!show_file(arg))
|
if (!show_file(arg, output_prefix))
|
||||||
continue;
|
continue;
|
||||||
verify_filename(prefix, arg, 1);
|
verify_filename(prefix, arg, 1);
|
||||||
}
|
}
|
||||||
|
135
git-submodule.sh
135
git-submodule.sh
@ -14,10 +14,13 @@ USAGE="[--quiet] add [-b <branch>] [-f|--force] [--name <name>] [--reference <re
|
|||||||
or: $dashless [--quiet] foreach [--recursive] <command>
|
or: $dashless [--quiet] foreach [--recursive] <command>
|
||||||
or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
|
or: $dashless [--quiet] sync [--recursive] [--] [<path>...]"
|
||||||
OPTIONS_SPEC=
|
OPTIONS_SPEC=
|
||||||
|
SUBDIRECTORY_OK=Yes
|
||||||
. git-sh-setup
|
. git-sh-setup
|
||||||
. git-sh-i18n
|
. git-sh-i18n
|
||||||
. git-parse-remote
|
. git-parse-remote
|
||||||
require_work_tree
|
require_work_tree
|
||||||
|
wt_prefix=$(git rev-parse --show-prefix)
|
||||||
|
cd_to_toplevel
|
||||||
|
|
||||||
command=
|
command=
|
||||||
branch=
|
branch=
|
||||||
@ -106,12 +109,48 @@ resolve_relative_url ()
|
|||||||
echo "${is_relative:+${up_path}}${remoteurl#./}"
|
echo "${is_relative:+${up_path}}${remoteurl#./}"
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# Resolve a path to be relative to another path. This is intended for
|
||||||
|
# converting submodule paths when git-submodule is run in a subdirectory
|
||||||
|
# and only handles paths where the directory separator is '/'.
|
||||||
|
#
|
||||||
|
# The output is the first argument as a path relative to the second argument,
|
||||||
|
# which defaults to $wt_prefix if it is omitted.
|
||||||
|
relative_path ()
|
||||||
|
{
|
||||||
|
local target curdir result
|
||||||
|
target=$1
|
||||||
|
curdir=${2-$wt_prefix}
|
||||||
|
curdir=${curdir%/}
|
||||||
|
result=
|
||||||
|
|
||||||
|
while test -n "$curdir"
|
||||||
|
do
|
||||||
|
case "$target" in
|
||||||
|
"$curdir/"*)
|
||||||
|
target=${target#"$curdir"/}
|
||||||
|
break
|
||||||
|
;;
|
||||||
|
esac
|
||||||
|
|
||||||
|
result="${result}../"
|
||||||
|
if test "$curdir" = "${curdir%/*}"
|
||||||
|
then
|
||||||
|
curdir=
|
||||||
|
else
|
||||||
|
curdir="${curdir%/*}"
|
||||||
|
fi
|
||||||
|
done
|
||||||
|
|
||||||
|
echo "$result$target"
|
||||||
|
}
|
||||||
|
|
||||||
#
|
#
|
||||||
# Get submodule info for registered submodules
|
# Get submodule info for registered submodules
|
||||||
# $@ = path to limit submodule list
|
# $@ = path to limit submodule list
|
||||||
#
|
#
|
||||||
module_list()
|
module_list()
|
||||||
{
|
{
|
||||||
|
eval "set $(git rev-parse --sq --prefix "$wt_prefix" -- "$@")"
|
||||||
(
|
(
|
||||||
git ls-files -z --error-unmatch --stage -- "$@" ||
|
git ls-files -z --error-unmatch --stage -- "$@" ||
|
||||||
echo "unmatched pathspec exists"
|
echo "unmatched pathspec exists"
|
||||||
@ -283,6 +322,7 @@ isnumber()
|
|||||||
cmd_add()
|
cmd_add()
|
||||||
{
|
{
|
||||||
# parse $args after "submodule ... add".
|
# parse $args after "submodule ... add".
|
||||||
|
reference_path=
|
||||||
while test $# -ne 0
|
while test $# -ne 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -299,11 +339,11 @@ cmd_add()
|
|||||||
;;
|
;;
|
||||||
--reference)
|
--reference)
|
||||||
case "$2" in '') usage ;; esac
|
case "$2" in '') usage ;; esac
|
||||||
reference="--reference=$2"
|
reference_path=$2
|
||||||
shift
|
shift
|
||||||
;;
|
;;
|
||||||
--reference=*)
|
--reference=*)
|
||||||
reference="$1"
|
reference_path="${1#--reference=}"
|
||||||
;;
|
;;
|
||||||
--name)
|
--name)
|
||||||
case "$2" in '') usage ;; esac
|
case "$2" in '') usage ;; esac
|
||||||
@ -324,6 +364,14 @@ cmd_add()
|
|||||||
shift
|
shift
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if test -n "$reference_path"
|
||||||
|
then
|
||||||
|
is_absolute_path "$reference_path" ||
|
||||||
|
reference_path="$wt_prefix$reference_path"
|
||||||
|
|
||||||
|
reference="--reference=$reference_path"
|
||||||
|
fi
|
||||||
|
|
||||||
repo=$1
|
repo=$1
|
||||||
sm_path=$2
|
sm_path=$2
|
||||||
|
|
||||||
@ -336,9 +384,14 @@ cmd_add()
|
|||||||
usage
|
usage
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
is_absolute_path "$sm_path" || sm_path="$wt_prefix$sm_path"
|
||||||
|
|
||||||
# assure repo is absolute or relative to parent
|
# assure repo is absolute or relative to parent
|
||||||
case "$repo" in
|
case "$repo" in
|
||||||
./*|../*)
|
./*|../*)
|
||||||
|
test -z "$wt_prefix" ||
|
||||||
|
die "$(gettext "Relative path can only be used from the toplevel of the working tree")"
|
||||||
|
|
||||||
# dereference source url relative to parent's url
|
# dereference source url relative to parent's url
|
||||||
realrepo=$(resolve_relative_url "$repo") || exit
|
realrepo=$(resolve_relative_url "$repo") || exit
|
||||||
;;
|
;;
|
||||||
@ -472,21 +525,23 @@ cmd_foreach()
|
|||||||
die_if_unmatched "$mode"
|
die_if_unmatched "$mode"
|
||||||
if test -e "$sm_path"/.git
|
if test -e "$sm_path"/.git
|
||||||
then
|
then
|
||||||
say "$(eval_gettext "Entering '\$prefix\$sm_path'")"
|
displaypath=$(relative_path "$sm_path")
|
||||||
|
say "$(eval_gettext "Entering '\$prefix\$displaypath'")"
|
||||||
name=$(module_name "$sm_path")
|
name=$(module_name "$sm_path")
|
||||||
(
|
(
|
||||||
prefix="$prefix$sm_path/"
|
prefix="$prefix$sm_path/"
|
||||||
clear_local_git_env
|
clear_local_git_env
|
||||||
# we make $path available to scripts ...
|
|
||||||
path=$sm_path
|
|
||||||
cd "$sm_path" &&
|
cd "$sm_path" &&
|
||||||
|
sm_path=$(relative_path "$sm_path") &&
|
||||||
|
# we make $path available to scripts ...
|
||||||
|
path=$sm_path &&
|
||||||
eval "$@" &&
|
eval "$@" &&
|
||||||
if test -n "$recursive"
|
if test -n "$recursive"
|
||||||
then
|
then
|
||||||
cmd_foreach "--recursive" "$@"
|
cmd_foreach "--recursive" "$@"
|
||||||
fi
|
fi
|
||||||
) <&3 3<&- ||
|
) <&3 3<&- ||
|
||||||
die "$(eval_gettext "Stopping at '\$sm_path'; script returned non-zero status.")"
|
die "$(eval_gettext "Stopping at '\$prefix\$displaypath'; script returned non-zero status.")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -525,12 +580,14 @@ cmd_init()
|
|||||||
die_if_unmatched "$mode"
|
die_if_unmatched "$mode"
|
||||||
name=$(module_name "$sm_path") || exit
|
name=$(module_name "$sm_path") || exit
|
||||||
|
|
||||||
|
displaypath=$(relative_path "$sm_path")
|
||||||
|
|
||||||
# Copy url setting when it is not set yet
|
# Copy url setting when it is not set yet
|
||||||
if test -z "$(git config "submodule.$name.url")"
|
if test -z "$(git config "submodule.$name.url")"
|
||||||
then
|
then
|
||||||
url=$(git config -f .gitmodules submodule."$name".url)
|
url=$(git config -f .gitmodules submodule."$name".url)
|
||||||
test -z "$url" &&
|
test -z "$url" &&
|
||||||
die "$(eval_gettext "No url found for submodule path '\$sm_path' in .gitmodules")"
|
die "$(eval_gettext "No url found for submodule path '\$displaypath' in .gitmodules")"
|
||||||
|
|
||||||
# Possibly a url relative to parent
|
# Possibly a url relative to parent
|
||||||
case "$url" in
|
case "$url" in
|
||||||
@ -539,9 +596,9 @@ cmd_init()
|
|||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
git config submodule."$name".url "$url" ||
|
git config submodule."$name".url "$url" ||
|
||||||
die "$(eval_gettext "Failed to register url for submodule path '\$sm_path'")"
|
die "$(eval_gettext "Failed to register url for submodule path '\$displaypath'")"
|
||||||
|
|
||||||
say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$sm_path'")"
|
say "$(eval_gettext "Submodule '\$name' (\$url) registered for path '\$displaypath'")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Copy "update" setting when it is not set yet
|
# Copy "update" setting when it is not set yet
|
||||||
@ -549,7 +606,7 @@ cmd_init()
|
|||||||
test -z "$upd" ||
|
test -z "$upd" ||
|
||||||
test -n "$(git config submodule."$name".update)" ||
|
test -n "$(git config submodule."$name".update)" ||
|
||||||
git config submodule."$name".update "$upd" ||
|
git config submodule."$name".update "$upd" ||
|
||||||
die "$(eval_gettext "Failed to register update mode for submodule path '\$sm_path'")"
|
die "$(eval_gettext "Failed to register update mode for submodule path '\$displaypath'")"
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -595,27 +652,29 @@ cmd_deinit()
|
|||||||
die_if_unmatched "$mode"
|
die_if_unmatched "$mode"
|
||||||
name=$(module_name "$sm_path") || exit
|
name=$(module_name "$sm_path") || exit
|
||||||
|
|
||||||
|
displaypath=$(relative_path "$sm_path")
|
||||||
|
|
||||||
# Remove the submodule work tree (unless the user already did it)
|
# Remove the submodule work tree (unless the user already did it)
|
||||||
if test -d "$sm_path"
|
if test -d "$sm_path"
|
||||||
then
|
then
|
||||||
# Protect submodules containing a .git directory
|
# Protect submodules containing a .git directory
|
||||||
if test -d "$sm_path/.git"
|
if test -d "$sm_path/.git"
|
||||||
then
|
then
|
||||||
echo >&2 "$(eval_gettext "Submodule work tree '\$sm_path' contains a .git directory")"
|
echo >&2 "$(eval_gettext "Submodule work tree '\$displaypath' contains a .git directory")"
|
||||||
die "$(eval_gettext "(use 'rm -rf' if you really want to remove it including all of its history)")"
|
die "$(eval_gettext "(use 'rm -rf' if you really want to remove it including all of its history)")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -z "$force"
|
if test -z "$force"
|
||||||
then
|
then
|
||||||
git rm -qn "$sm_path" ||
|
git rm -qn "$sm_path" ||
|
||||||
die "$(eval_gettext "Submodule work tree '\$sm_path' contains local modifications; use '-f' to discard them")"
|
die "$(eval_gettext "Submodule work tree '\$displaypath' contains local modifications; use '-f' to discard them")"
|
||||||
fi
|
fi
|
||||||
rm -rf "$sm_path" &&
|
rm -rf "$sm_path" &&
|
||||||
say "$(eval_gettext "Cleared directory '\$sm_path'")" ||
|
say "$(eval_gettext "Cleared directory '\$displaypath'")" ||
|
||||||
say "$(eval_gettext "Could not remove submodule work tree '\$sm_path'")"
|
say "$(eval_gettext "Could not remove submodule work tree '\$displaypath'")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
mkdir "$sm_path" || say "$(eval_gettext "Could not create empty submodule directory '\$sm_path'")"
|
mkdir "$sm_path" || say "$(eval_gettext "Could not create empty submodule directory '\$displaypath'")"
|
||||||
|
|
||||||
# Remove the .git/config entries (unless the user already did it)
|
# Remove the .git/config entries (unless the user already did it)
|
||||||
if test -n "$(git config --get-regexp submodule."$name\.")"
|
if test -n "$(git config --get-regexp submodule."$name\.")"
|
||||||
@ -624,7 +683,7 @@ cmd_deinit()
|
|||||||
# the user later decides to init this submodule again
|
# the user later decides to init this submodule again
|
||||||
url=$(git config submodule."$name".url)
|
url=$(git config submodule."$name".url)
|
||||||
git config --remove-section submodule."$name" 2>/dev/null &&
|
git config --remove-section submodule."$name" 2>/dev/null &&
|
||||||
say "$(eval_gettext "Submodule '\$name' (\$url) unregistered for path '\$sm_path'")"
|
say "$(eval_gettext "Submodule '\$name' (\$url) unregistered for path '\$displaypath'")"
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@ -718,9 +777,11 @@ cmd_update()
|
|||||||
update_module=$(git config submodule."$name".update)
|
update_module=$(git config submodule."$name".update)
|
||||||
fi
|
fi
|
||||||
|
|
||||||
|
displaypath=$(relative_path "$prefix$sm_path")
|
||||||
|
|
||||||
if test "$update_module" = "none"
|
if test "$update_module" = "none"
|
||||||
then
|
then
|
||||||
echo "Skipping submodule '$prefix$sm_path'"
|
echo "Skipping submodule '$displaypath'"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@ -729,7 +790,7 @@ cmd_update()
|
|||||||
# Only mention uninitialized submodules when its
|
# Only mention uninitialized submodules when its
|
||||||
# path have been specified
|
# path have been specified
|
||||||
test "$#" != "0" &&
|
test "$#" != "0" &&
|
||||||
say "$(eval_gettext "Submodule path '\$prefix\$sm_path' not initialized
|
say "$(eval_gettext "Submodule path '\$displaypath' not initialized
|
||||||
Maybe you want to use 'update --init'?")"
|
Maybe you want to use 'update --init'?")"
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
@ -742,7 +803,7 @@ Maybe you want to use 'update --init'?")"
|
|||||||
else
|
else
|
||||||
subsha1=$(clear_local_git_env; cd "$sm_path" &&
|
subsha1=$(clear_local_git_env; cd "$sm_path" &&
|
||||||
git rev-parse --verify HEAD) ||
|
git rev-parse --verify HEAD) ||
|
||||||
die "$(eval_gettext "Unable to find current revision in submodule path '\$prefix\$sm_path'")"
|
die "$(eval_gettext "Unable to find current revision in submodule path '\$displaypath'")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if test -n "$remote"
|
if test -n "$remote"
|
||||||
@ -775,7 +836,7 @@ Maybe you want to use 'update --init'?")"
|
|||||||
(clear_local_git_env; cd "$sm_path" &&
|
(clear_local_git_env; cd "$sm_path" &&
|
||||||
( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
|
( (rev=$(git rev-list -n 1 $sha1 --not --all 2>/dev/null) &&
|
||||||
test -z "$rev") || git-fetch)) ||
|
test -z "$rev") || git-fetch)) ||
|
||||||
die "$(eval_gettext "Unable to fetch in submodule path '\$prefix\$sm_path'")"
|
die "$(eval_gettext "Unable to fetch in submodule path '\$displaypath'")"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
# Is this something we just cloned?
|
# Is this something we just cloned?
|
||||||
@ -789,20 +850,20 @@ Maybe you want to use 'update --init'?")"
|
|||||||
case "$update_module" in
|
case "$update_module" in
|
||||||
rebase)
|
rebase)
|
||||||
command="git rebase"
|
command="git rebase"
|
||||||
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$prefix\$sm_path'")"
|
die_msg="$(eval_gettext "Unable to rebase '\$sha1' in submodule path '\$displaypath'")"
|
||||||
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': rebased into '\$sha1'")"
|
say_msg="$(eval_gettext "Submodule path '\$displaypath': rebased into '\$sha1'")"
|
||||||
must_die_on_failure=yes
|
must_die_on_failure=yes
|
||||||
;;
|
;;
|
||||||
merge)
|
merge)
|
||||||
command="git merge"
|
command="git merge"
|
||||||
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$prefix\$sm_path'")"
|
die_msg="$(eval_gettext "Unable to merge '\$sha1' in submodule path '\$displaypath'")"
|
||||||
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': merged in '\$sha1'")"
|
say_msg="$(eval_gettext "Submodule path '\$displaypath': merged in '\$sha1'")"
|
||||||
must_die_on_failure=yes
|
must_die_on_failure=yes
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
command="git checkout $subforce -q"
|
command="git checkout $subforce -q"
|
||||||
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$prefix\$sm_path'")"
|
die_msg="$(eval_gettext "Unable to checkout '\$sha1' in submodule path '\$displaypath'")"
|
||||||
say_msg="$(eval_gettext "Submodule path '\$prefix\$sm_path': checked out '\$sha1'")"
|
say_msg="$(eval_gettext "Submodule path '\$displaypath': checked out '\$sha1'")"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
|
|
||||||
@ -829,7 +890,7 @@ Maybe you want to use 'update --init'?")"
|
|||||||
res=$?
|
res=$?
|
||||||
if test $res -gt 0
|
if test $res -gt 0
|
||||||
then
|
then
|
||||||
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$prefix\$sm_path'")"
|
die_msg="$(eval_gettext "Failed to recurse into submodule path '\$displaypath'")"
|
||||||
if test $res -eq 1
|
if test $res -eq 1
|
||||||
then
|
then
|
||||||
err="${err};$die_msg"
|
err="${err};$die_msg"
|
||||||
@ -943,6 +1004,7 @@ cmd_summary() {
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cd_to_toplevel
|
cd_to_toplevel
|
||||||
|
eval "set $(git rev-parse --sq --prefix "$wt_prefix" -- "$@")"
|
||||||
# Get modified modules cared by user
|
# Get modified modules cared by user
|
||||||
modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" |
|
modules=$(git $diff_cmd $cached --ignore-submodules=dirty --raw $head -- "$@" |
|
||||||
sane_egrep '^:([0-7]* )?160000' |
|
sane_egrep '^:([0-7]* )?160000' |
|
||||||
@ -992,16 +1054,18 @@ cmd_summary() {
|
|||||||
! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 >/dev/null &&
|
! GIT_DIR="$name/.git" git-rev-parse -q --verify $sha1_dst^0 >/dev/null &&
|
||||||
missing_dst=t
|
missing_dst=t
|
||||||
|
|
||||||
|
display_name=$(relative_path "$name")
|
||||||
|
|
||||||
total_commits=
|
total_commits=
|
||||||
case "$missing_src,$missing_dst" in
|
case "$missing_src,$missing_dst" in
|
||||||
t,)
|
t,)
|
||||||
errmsg="$(eval_gettext " Warn: \$name doesn't contain commit \$sha1_src")"
|
errmsg="$(eval_gettext " Warn: \$display_name doesn't contain commit \$sha1_src")"
|
||||||
;;
|
;;
|
||||||
,t)
|
,t)
|
||||||
errmsg="$(eval_gettext " Warn: \$name doesn't contain commit \$sha1_dst")"
|
errmsg="$(eval_gettext " Warn: \$display_name doesn't contain commit \$sha1_dst")"
|
||||||
;;
|
;;
|
||||||
t,t)
|
t,t)
|
||||||
errmsg="$(eval_gettext " Warn: \$name doesn't contain commits \$sha1_src and \$sha1_dst")"
|
errmsg="$(eval_gettext " Warn: \$display_name doesn't contain commits \$sha1_src and \$sha1_dst")"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
errmsg=
|
errmsg=
|
||||||
@ -1030,12 +1094,12 @@ cmd_summary() {
|
|||||||
submodule="$(gettext "submodule")"
|
submodule="$(gettext "submodule")"
|
||||||
if test $mod_dst = 160000
|
if test $mod_dst = 160000
|
||||||
then
|
then
|
||||||
echo "* $name $sha1_abbr_src($blob)->$sha1_abbr_dst($submodule)$total_commits:"
|
echo "* $display_name $sha1_abbr_src($blob)->$sha1_abbr_dst($submodule)$total_commits:"
|
||||||
else
|
else
|
||||||
echo "* $name $sha1_abbr_src($submodule)->$sha1_abbr_dst($blob)$total_commits:"
|
echo "* $display_name $sha1_abbr_src($submodule)->$sha1_abbr_dst($blob)$total_commits:"
|
||||||
fi
|
fi
|
||||||
else
|
else
|
||||||
echo "* $name $sha1_abbr_src...$sha1_abbr_dst$total_commits:"
|
echo "* $display_name $sha1_abbr_src...$sha1_abbr_dst$total_commits:"
|
||||||
fi
|
fi
|
||||||
if test -n "$errmsg"
|
if test -n "$errmsg"
|
||||||
then
|
then
|
||||||
@ -1119,7 +1183,7 @@ cmd_status()
|
|||||||
die_if_unmatched "$mode"
|
die_if_unmatched "$mode"
|
||||||
name=$(module_name "$sm_path") || exit
|
name=$(module_name "$sm_path") || exit
|
||||||
url=$(git config submodule."$name".url)
|
url=$(git config submodule."$name".url)
|
||||||
displaypath="$prefix$sm_path"
|
displaypath=$(relative_path "$prefix$sm_path")
|
||||||
if test "$stage" = U
|
if test "$stage" = U
|
||||||
then
|
then
|
||||||
say "U$sha1 $displaypath"
|
say "U$sha1 $displaypath"
|
||||||
@ -1214,7 +1278,8 @@ cmd_sync()
|
|||||||
|
|
||||||
if git config "submodule.$name.url" >/dev/null 2>/dev/null
|
if git config "submodule.$name.url" >/dev/null 2>/dev/null
|
||||||
then
|
then
|
||||||
say "$(eval_gettext "Synchronizing submodule url for '\$prefix\$sm_path'")"
|
displaypath=$(relative_path "$prefix$sm_path")
|
||||||
|
say "$(eval_gettext "Synchronizing submodule url for '\$displaypath'")"
|
||||||
git config submodule."$name".url "$super_config_url"
|
git config submodule."$name".url "$super_config_url"
|
||||||
|
|
||||||
if test -e "$sm_path"/.git
|
if test -e "$sm_path"/.git
|
||||||
|
96
t/t1513-rev-parse-prefix.sh
Executable file
96
t/t1513-rev-parse-prefix.sh
Executable file
@ -0,0 +1,96 @@
|
|||||||
|
#!/bin/sh
|
||||||
|
|
||||||
|
test_description='Tests for rev-parse --prefix'
|
||||||
|
|
||||||
|
. ./test-lib.sh
|
||||||
|
|
||||||
|
test_expect_success 'setup' '
|
||||||
|
mkdir -p sub1/sub2 &&
|
||||||
|
echo top >top &&
|
||||||
|
echo file1 >sub1/file1 &&
|
||||||
|
echo file2 >sub1/sub2/file2 &&
|
||||||
|
git add top sub1/file1 sub1/sub2/file2 &&
|
||||||
|
git commit -m commit
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty prefix -- file' '
|
||||||
|
git rev-parse --prefix "" -- top sub1/file1 >actual &&
|
||||||
|
cat <<-\EOF >expected &&
|
||||||
|
--
|
||||||
|
top
|
||||||
|
sub1/file1
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'valid prefix -- file' '
|
||||||
|
git rev-parse --prefix sub1/ -- file1 sub2/file2 >actual &&
|
||||||
|
cat <<-\EOF >expected &&
|
||||||
|
--
|
||||||
|
sub1/file1
|
||||||
|
sub1/sub2/file2
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'valid prefix -- ../file' '
|
||||||
|
git rev-parse --prefix sub1/ -- ../top sub2/file2 >actual &&
|
||||||
|
cat <<-\EOF >expected &&
|
||||||
|
--
|
||||||
|
sub1/../top
|
||||||
|
sub1/sub2/file2
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'empty prefix HEAD:./path' '
|
||||||
|
git rev-parse --prefix "" HEAD:./top >actual &&
|
||||||
|
git rev-parse HEAD:top >expected &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'valid prefix HEAD:./path' '
|
||||||
|
git rev-parse --prefix sub1/ HEAD:./file1 >actual &&
|
||||||
|
git rev-parse HEAD:sub1/file1 >expected &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'valid prefix HEAD:../path' '
|
||||||
|
git rev-parse --prefix sub1/ HEAD:../top >actual &&
|
||||||
|
git rev-parse HEAD:top >expected &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'prefix ignored with HEAD:top' '
|
||||||
|
git rev-parse --prefix sub1/ HEAD:top >actual &&
|
||||||
|
git rev-parse HEAD:top >expected &&
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'disambiguate path with valid prefix' '
|
||||||
|
git rev-parse --prefix sub1/ file1 >actual &&
|
||||||
|
cat <<-\EOF >expected &&
|
||||||
|
sub1/file1
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'file and refs with prefix' '
|
||||||
|
git rev-parse --prefix sub1/ master file1 >actual &&
|
||||||
|
cat <<-EOF >expected &&
|
||||||
|
$(git rev-parse master)
|
||||||
|
sub1/file1
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'two-levels deep' '
|
||||||
|
git rev-parse --prefix sub1/sub2/ -- file2 >actual &&
|
||||||
|
cat <<-\EOF >expected &&
|
||||||
|
--
|
||||||
|
sub1/sub2/file2
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
'
|
||||||
|
|
||||||
|
test_done
|
@ -212,6 +212,32 @@ test_expect_success 'submodule add with ./, /.. and // in path' '
|
|||||||
test_cmp empty untracked
|
test_cmp empty untracked
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule add in subdirectory' '
|
||||||
|
echo "refs/heads/master" >expect &&
|
||||||
|
>empty &&
|
||||||
|
|
||||||
|
mkdir addtest/sub &&
|
||||||
|
(
|
||||||
|
cd addtest/sub &&
|
||||||
|
git submodule add "$submodurl" ../realsubmod3 &&
|
||||||
|
git submodule init
|
||||||
|
) &&
|
||||||
|
|
||||||
|
rm -f heads head untracked &&
|
||||||
|
inspect addtest/realsubmod3 ../.. &&
|
||||||
|
test_cmp expect heads &&
|
||||||
|
test_cmp expect head &&
|
||||||
|
test_cmp empty untracked
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule add in subdirectory with relative path should fail' '
|
||||||
|
(
|
||||||
|
cd addtest/sub &&
|
||||||
|
test_must_fail git submodule add ../../ submod3 2>../../output.err
|
||||||
|
) &&
|
||||||
|
test_i18ngrep toplevel output.err
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup - add an example entry to .gitmodules' '
|
test_expect_success 'setup - add an example entry to .gitmodules' '
|
||||||
GIT_CONFIG=.gitmodules \
|
GIT_CONFIG=.gitmodules \
|
||||||
git config submodule.example.url git://example.com/init.git
|
git config submodule.example.url git://example.com/init.git
|
||||||
@ -319,6 +345,26 @@ test_expect_success 'status should be "up-to-date" after update' '
|
|||||||
grep "^ $rev1" list
|
grep "^ $rev1" list
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status "up-to-date" from subdirectory' '
|
||||||
|
mkdir -p sub &&
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule status >../list
|
||||||
|
) &&
|
||||||
|
grep "^ $rev1" list &&
|
||||||
|
grep "\\.\\./init" list
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'status "up-to-date" from subdirectory with path' '
|
||||||
|
mkdir -p sub &&
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule status ../init >../list
|
||||||
|
) &&
|
||||||
|
grep "^ $rev1" list &&
|
||||||
|
grep "\\.\\./init" list
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'status should be "modified" after submodule commit' '
|
test_expect_success 'status should be "modified" after submodule commit' '
|
||||||
(
|
(
|
||||||
cd init &&
|
cd init &&
|
||||||
@ -399,6 +445,25 @@ test_expect_success 'update --init' '
|
|||||||
git rev-parse --resolve-git-dir init/.git
|
git rev-parse --resolve-git-dir init/.git
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'update --init from subdirectory' '
|
||||||
|
mv init init2 &&
|
||||||
|
git config -f .gitmodules submodule.example.url "$(pwd)/init2" &&
|
||||||
|
git config --remove-section submodule.example &&
|
||||||
|
test_must_fail git config submodule.example.url &&
|
||||||
|
|
||||||
|
mkdir -p sub &&
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule update ../init >update.out &&
|
||||||
|
cat update.out &&
|
||||||
|
test_i18ngrep "not initialized" update.out &&
|
||||||
|
test_must_fail git rev-parse --resolve-git-dir ../init/.git &&
|
||||||
|
|
||||||
|
git submodule update --init ../init
|
||||||
|
) &&
|
||||||
|
git rev-parse --resolve-git-dir init/.git
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'do not add files from a submodule' '
|
test_expect_success 'do not add files from a submodule' '
|
||||||
|
|
||||||
git reset --hard &&
|
git reset --hard &&
|
||||||
@ -772,6 +837,21 @@ test_expect_success 'submodule deinit should remove the whole submodule section
|
|||||||
rmdir init
|
rmdir init
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule deinit from subdirectory' '
|
||||||
|
git submodule update --init &&
|
||||||
|
git config submodule.example.foo bar &&
|
||||||
|
mkdir -p sub &&
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule deinit ../init >../output
|
||||||
|
) &&
|
||||||
|
grep "\\.\\./init" output &&
|
||||||
|
test -z "$(git config --get-regexp "submodule\.example\.")" &&
|
||||||
|
test -n "$(git config --get-regexp "submodule\.example2\.")" &&
|
||||||
|
test -f example2/.git &&
|
||||||
|
rmdir init
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'submodule deinit . deinits all initialized submodules' '
|
test_expect_success 'submodule deinit . deinits all initialized submodules' '
|
||||||
git submodule update --init &&
|
git submodule update --init &&
|
||||||
git config submodule.example.foo bar &&
|
git config submodule.example.foo bar &&
|
||||||
|
@ -45,6 +45,42 @@ EOF
|
|||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
|
test_expect_success 'added submodule (subdirectory)' "
|
||||||
|
mkdir sub &&
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule summary >../actual
|
||||||
|
) &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
|
* ../sm1 0000000...$head1 (2):
|
||||||
|
> Add foo2
|
||||||
|
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'added submodule (subdirectory only)' "
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule summary . >../actual
|
||||||
|
) &&
|
||||||
|
>expected &&
|
||||||
|
test_cmp expected actual
|
||||||
|
"
|
||||||
|
|
||||||
|
test_expect_success 'added submodule (subdirectory with explicit path)' "
|
||||||
|
(
|
||||||
|
cd sub &&
|
||||||
|
git submodule summary ../sm1 >../actual
|
||||||
|
) &&
|
||||||
|
cat >expected <<-EOF &&
|
||||||
|
* ../sm1 0000000...$head1 (2):
|
||||||
|
> Add foo2
|
||||||
|
|
||||||
|
EOF
|
||||||
|
test_cmp expected actual
|
||||||
|
"
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
head2=$(add_file sm1 foo3)
|
head2=$(add_file sm1 foo3)
|
||||||
|
|
||||||
@ -76,8 +112,8 @@ head3=$(
|
|||||||
)
|
)
|
||||||
|
|
||||||
test_expect_success 'modified submodule(backward)' "
|
test_expect_success 'modified submodule(backward)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head2...$head3 (2):
|
* sm1 $head2...$head3 (2):
|
||||||
< Add foo3
|
< Add foo3
|
||||||
< Add foo2
|
< Add foo2
|
||||||
@ -89,8 +125,8 @@ EOF
|
|||||||
head4=$(add_file sm1 foo4 foo5) &&
|
head4=$(add_file sm1 foo4 foo5) &&
|
||||||
head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
|
head4_full=$(GIT_DIR=sm1/.git git rev-parse --verify HEAD)
|
||||||
test_expect_success 'modified submodule(backward and forward)' "
|
test_expect_success 'modified submodule(backward and forward)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head2...$head4 (4):
|
* sm1 $head2...$head4 (4):
|
||||||
> Add foo5
|
> Add foo5
|
||||||
> Add foo4
|
> Add foo4
|
||||||
@ -102,15 +138,15 @@ EOF
|
|||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success '--summary-limit' "
|
test_expect_success '--summary-limit' "
|
||||||
git submodule summary -n 3 >actual &&
|
git submodule summary -n 3 >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head2...$head4 (4):
|
* sm1 $head2...$head4 (4):
|
||||||
> Add foo5
|
> Add foo5
|
||||||
> Add foo4
|
> Add foo4
|
||||||
< Add foo3
|
< Add foo3
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
@ -122,8 +158,8 @@ rm -f sm1 &&
|
|||||||
mv sm1-bak sm1
|
mv sm1-bak sm1
|
||||||
|
|
||||||
test_expect_success 'typechanged submodule(submodule->blob), --cached' "
|
test_expect_success 'typechanged submodule(submodule->blob), --cached' "
|
||||||
git submodule summary --cached >actual &&
|
git submodule summary --cached >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head4(submodule)->$head5(blob) (3):
|
* sm1 $head4(submodule)->$head5(blob) (3):
|
||||||
< Add foo5
|
< Add foo5
|
||||||
|
|
||||||
@ -132,59 +168,59 @@ EOF
|
|||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'typechanged submodule(submodule->blob), --files' "
|
test_expect_success 'typechanged submodule(submodule->blob), --files' "
|
||||||
git submodule summary --files >actual &&
|
git submodule summary --files >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head5(blob)->$head4(submodule) (3):
|
* sm1 $head5(blob)->$head4(submodule) (3):
|
||||||
> Add foo5
|
> Add foo5
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp actual expected
|
||||||
"
|
"
|
||||||
|
|
||||||
rm -rf sm1 &&
|
rm -rf sm1 &&
|
||||||
git checkout-index sm1
|
git checkout-index sm1
|
||||||
test_expect_success 'typechanged submodule(submodule->blob)' "
|
test_expect_success 'typechanged submodule(submodule->blob)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head4(submodule)->$head5(blob):
|
* sm1 $head4(submodule)->$head5(blob):
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp actual expected
|
||||||
"
|
"
|
||||||
|
|
||||||
rm -f sm1 &&
|
rm -f sm1 &&
|
||||||
test_create_repo sm1 &&
|
test_create_repo sm1 &&
|
||||||
head6=$(add_file sm1 foo6 foo7)
|
head6=$(add_file sm1 foo6 foo7)
|
||||||
test_expect_success 'nonexistent commit' "
|
test_expect_success 'nonexistent commit' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head4...$head6:
|
* sm1 $head4...$head6:
|
||||||
Warn: sm1 doesn't contain commit $head4_full
|
Warn: sm1 doesn't contain commit $head4_full
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp actual expected
|
test_i18ncmp actual expected
|
||||||
"
|
"
|
||||||
|
|
||||||
commit_file
|
commit_file
|
||||||
test_expect_success 'typechanged submodule(blob->submodule)' "
|
test_expect_success 'typechanged submodule(blob->submodule)' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head5(blob)->$head6(submodule) (2):
|
* sm1 $head5(blob)->$head6(submodule) (2):
|
||||||
> Add foo7
|
> Add foo7
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_i18ncmp expected actual
|
test_i18ncmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
commit_file sm1 &&
|
commit_file sm1 &&
|
||||||
rm -rf sm1
|
rm -rf sm1
|
||||||
test_expect_success 'deleted submodule' "
|
test_expect_success 'deleted submodule' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_create_repo sm2 &&
|
test_create_repo sm2 &&
|
||||||
@ -192,43 +228,43 @@ head7=$(add_file sm2 foo8 foo9) &&
|
|||||||
git add sm2
|
git add sm2
|
||||||
|
|
||||||
test_expect_success 'multiple submodules' "
|
test_expect_success 'multiple submodules' "
|
||||||
git submodule summary >actual &&
|
git submodule summary >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'path filter' "
|
test_expect_success 'path filter' "
|
||||||
git submodule summary sm2 >actual &&
|
git submodule summary sm2 >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
commit_file sm2
|
commit_file sm2
|
||||||
test_expect_success 'given commit' "
|
test_expect_success 'given commit' "
|
||||||
git submodule summary HEAD^ >actual &&
|
git submodule summary HEAD^ >actual &&
|
||||||
cat >expected <<-EOF &&
|
cat >expected <<-EOF &&
|
||||||
* sm1 $head6...0000000:
|
* sm1 $head6...0000000:
|
||||||
|
|
||||||
* sm2 0000000...$head7 (2):
|
* sm2 0000000...$head7 (2):
|
||||||
> Add foo9
|
> Add foo9
|
||||||
|
|
||||||
EOF
|
EOF
|
||||||
test_cmp expected actual
|
test_cmp expected actual
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success '--for-status' "
|
test_expect_success '--for-status' "
|
||||||
git submodule summary --for-status HEAD^ >actual &&
|
git submodule summary --for-status HEAD^ >actual &&
|
||||||
test_i18ncmp actual - <<EOF
|
test_i18ncmp actual - <<EOF
|
||||||
# Submodule changes to be committed:
|
# Submodule changes to be committed:
|
||||||
#
|
#
|
||||||
# * sm1 $head6...0000000:
|
# * sm1 $head6...0000000:
|
||||||
@ -240,14 +276,14 @@ EOF
|
|||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'fail when using --files together with --cached' "
|
test_expect_success 'fail when using --files together with --cached' "
|
||||||
test_must_fail git submodule summary --files --cached
|
test_must_fail git submodule summary --files --cached
|
||||||
"
|
"
|
||||||
|
|
||||||
test_expect_success 'should not fail in an empty repo' "
|
test_expect_success 'should not fail in an empty repo' "
|
||||||
git init xyzzy &&
|
git init xyzzy &&
|
||||||
cd xyzzy &&
|
cd xyzzy &&
|
||||||
git submodule summary >output 2>&1 &&
|
git submodule summary >output 2>&1 &&
|
||||||
test_cmp output /dev/null
|
test_cmp output /dev/null
|
||||||
"
|
"
|
||||||
|
|
||||||
test_done
|
test_done
|
||||||
|
@ -11,216 +11,338 @@ These tests exercise the "git submodule sync" subcommand.
|
|||||||
. ./test-lib.sh
|
. ./test-lib.sh
|
||||||
|
|
||||||
test_expect_success setup '
|
test_expect_success setup '
|
||||||
echo file > file &&
|
echo file >file &&
|
||||||
git add file &&
|
git add file &&
|
||||||
test_tick &&
|
test_tick &&
|
||||||
git commit -m upstream &&
|
git commit -m upstream &&
|
||||||
git clone . super &&
|
git clone . super &&
|
||||||
git clone super submodule &&
|
git clone super submodule &&
|
||||||
(cd submodule &&
|
(
|
||||||
git submodule add ../submodule sub-submodule &&
|
cd submodule &&
|
||||||
test_tick &&
|
git submodule add ../submodule sub-submodule &&
|
||||||
git commit -m "sub-submodule"
|
test_tick &&
|
||||||
|
git commit -m "sub-submodule"
|
||||||
) &&
|
) &&
|
||||||
(cd super &&
|
(
|
||||||
git submodule add ../submodule submodule &&
|
cd super &&
|
||||||
test_tick &&
|
git submodule add ../submodule submodule &&
|
||||||
git commit -m "submodule"
|
test_tick &&
|
||||||
|
git commit -m "submodule"
|
||||||
) &&
|
) &&
|
||||||
git clone super super-clone &&
|
git clone super super-clone &&
|
||||||
(cd super-clone && git submodule update --init --recursive) &&
|
(
|
||||||
|
cd super-clone &&
|
||||||
|
git submodule update --init --recursive
|
||||||
|
) &&
|
||||||
git clone super empty-clone &&
|
git clone super empty-clone &&
|
||||||
(cd empty-clone && git submodule init) &&
|
(
|
||||||
|
cd empty-clone &&
|
||||||
|
git submodule init
|
||||||
|
) &&
|
||||||
git clone super top-only-clone &&
|
git clone super top-only-clone &&
|
||||||
git clone super relative-clone &&
|
git clone super relative-clone &&
|
||||||
(cd relative-clone && git submodule update --init --recursive) &&
|
(
|
||||||
|
cd relative-clone &&
|
||||||
|
git submodule update --init --recursive
|
||||||
|
) &&
|
||||||
git clone super recursive-clone &&
|
git clone super recursive-clone &&
|
||||||
(cd recursive-clone && git submodule update --init --recursive)
|
(
|
||||||
'
|
cd recursive-clone &&
|
||||||
|
git submodule update --init --recursive
|
||||||
test_expect_success 'change submodule' '
|
|
||||||
(cd submodule &&
|
|
||||||
echo second line >> file &&
|
|
||||||
test_tick &&
|
|
||||||
git commit -a -m "change submodule"
|
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'change submodule' '
|
||||||
|
(
|
||||||
|
cd submodule &&
|
||||||
|
echo second line >>file &&
|
||||||
|
test_tick &&
|
||||||
|
git commit -a -m "change submodule"
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
reset_submodule_urls () {
|
||||||
|
local root
|
||||||
|
root=$(pwd) &&
|
||||||
|
(
|
||||||
|
cd super-clone/submodule &&
|
||||||
|
git config remote.origin.url "$root/submodule"
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
cd super-clone/submodule/sub-submodule &&
|
||||||
|
git config remote.origin.url "$root/submodule"
|
||||||
|
)
|
||||||
|
}
|
||||||
|
|
||||||
test_expect_success 'change submodule url' '
|
test_expect_success 'change submodule url' '
|
||||||
(cd super &&
|
(
|
||||||
cd submodule &&
|
cd super &&
|
||||||
git checkout master &&
|
cd submodule &&
|
||||||
git pull
|
git checkout master &&
|
||||||
|
git pull
|
||||||
) &&
|
) &&
|
||||||
mv submodule moved-submodule &&
|
mv submodule moved-submodule &&
|
||||||
(cd moved-submodule &&
|
(
|
||||||
git config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&
|
cd moved-submodule &&
|
||||||
test_tick &&
|
git config -f .gitmodules submodule.sub-submodule.url ../moved-submodule &&
|
||||||
git commit -a -m moved-sub-submodule
|
test_tick &&
|
||||||
|
git commit -a -m moved-sub-submodule
|
||||||
) &&
|
) &&
|
||||||
(cd super &&
|
(
|
||||||
git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
|
cd super &&
|
||||||
test_tick &&
|
git config -f .gitmodules submodule.submodule.url ../moved-submodule &&
|
||||||
git commit -a -m moved-submodule
|
test_tick &&
|
||||||
|
git commit -a -m moved-submodule
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" should update submodule URLs' '
|
test_expect_success '"git submodule sync" should update submodule URLs' '
|
||||||
(cd super-clone &&
|
(
|
||||||
git pull --no-recurse-submodules &&
|
cd super-clone &&
|
||||||
git submodule sync
|
git pull --no-recurse-submodules &&
|
||||||
|
git submodule sync
|
||||||
) &&
|
) &&
|
||||||
test -d "$(cd super-clone/submodule &&
|
test -d "$(
|
||||||
git config remote.origin.url
|
cd super-clone/submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
)" &&
|
)" &&
|
||||||
test ! -d "$(cd super-clone/submodule/sub-submodule &&
|
test ! -d "$(
|
||||||
git config remote.origin.url
|
cd super-clone/submodule/sub-submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
)" &&
|
)" &&
|
||||||
(cd super-clone/submodule &&
|
(
|
||||||
git checkout master &&
|
cd super-clone/submodule &&
|
||||||
git pull
|
git checkout master &&
|
||||||
|
git pull
|
||||||
) &&
|
) &&
|
||||||
(cd super-clone &&
|
(
|
||||||
test -d "$(git config submodule.submodule.url)"
|
cd super-clone &&
|
||||||
|
test -d "$(git config submodule.submodule.url)"
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync --recursive" should update all submodule URLs' '
|
test_expect_success '"git submodule sync --recursive" should update all submodule URLs' '
|
||||||
(cd super-clone &&
|
(
|
||||||
(cd submodule &&
|
cd super-clone &&
|
||||||
git pull --no-recurse-submodules
|
(
|
||||||
) &&
|
cd submodule &&
|
||||||
git submodule sync --recursive
|
git pull --no-recurse-submodules
|
||||||
|
) &&
|
||||||
|
git submodule sync --recursive
|
||||||
) &&
|
) &&
|
||||||
test -d "$(cd super-clone/submodule &&
|
test -d "$(
|
||||||
git config remote.origin.url
|
cd super-clone/submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
)" &&
|
)" &&
|
||||||
test -d "$(cd super-clone/submodule/sub-submodule &&
|
test -d "$(
|
||||||
git config remote.origin.url
|
cd super-clone/submodule/sub-submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
)" &&
|
)" &&
|
||||||
(cd super-clone/submodule/sub-submodule &&
|
(
|
||||||
git checkout master &&
|
cd super-clone/submodule/sub-submodule &&
|
||||||
git pull
|
git checkout master &&
|
||||||
|
git pull
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success 'reset submodule URLs' '
|
||||||
|
reset_submodule_urls super-clone
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '"git submodule sync" should update submodule URLs - subdirectory' '
|
||||||
|
(
|
||||||
|
cd super-clone &&
|
||||||
|
git pull --no-recurse-submodules &&
|
||||||
|
mkdir -p sub &&
|
||||||
|
cd sub &&
|
||||||
|
git submodule sync >../../output
|
||||||
|
) &&
|
||||||
|
grep "\\.\\./submodule" output &&
|
||||||
|
test -d "$(
|
||||||
|
cd super-clone/submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
|
)" &&
|
||||||
|
test ! -d "$(
|
||||||
|
cd super-clone/submodule/sub-submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
|
)" &&
|
||||||
|
(
|
||||||
|
cd super-clone/submodule &&
|
||||||
|
git checkout master &&
|
||||||
|
git pull
|
||||||
|
) &&
|
||||||
|
(
|
||||||
|
cd super-clone &&
|
||||||
|
test -d "$(git config submodule.submodule.url)"
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
|
test_expect_success '"git submodule sync --recursive" should update all submodule URLs - subdirectory' '
|
||||||
|
(
|
||||||
|
cd super-clone &&
|
||||||
|
(
|
||||||
|
cd submodule &&
|
||||||
|
git pull --no-recurse-submodules
|
||||||
|
) &&
|
||||||
|
mkdir -p sub &&
|
||||||
|
cd sub &&
|
||||||
|
git submodule sync --recursive >../../output
|
||||||
|
) &&
|
||||||
|
grep "\\.\\./submodule/sub-submodule" output &&
|
||||||
|
test -d "$(
|
||||||
|
cd super-clone/submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
|
)" &&
|
||||||
|
test -d "$(
|
||||||
|
cd super-clone/submodule/sub-submodule &&
|
||||||
|
git config remote.origin.url
|
||||||
|
)" &&
|
||||||
|
(
|
||||||
|
cd super-clone/submodule/sub-submodule &&
|
||||||
|
git checkout master &&
|
||||||
|
git pull
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" should update known submodule URLs' '
|
test_expect_success '"git submodule sync" should update known submodule URLs' '
|
||||||
(cd empty-clone &&
|
(
|
||||||
git pull &&
|
cd empty-clone &&
|
||||||
git submodule sync &&
|
git pull &&
|
||||||
test -d "$(git config submodule.submodule.url)"
|
git submodule sync &&
|
||||||
|
test -d "$(git config submodule.submodule.url)"
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" should not vivify uninteresting submodule' '
|
test_expect_success '"git submodule sync" should not vivify uninteresting submodule' '
|
||||||
(cd top-only-clone &&
|
(
|
||||||
git pull &&
|
cd top-only-clone &&
|
||||||
git submodule sync &&
|
git pull &&
|
||||||
test -z "$(git config submodule.submodule.url)" &&
|
git submodule sync &&
|
||||||
git submodule sync submodule &&
|
test -z "$(git config submodule.submodule.url)" &&
|
||||||
test -z "$(git config submodule.submodule.url)"
|
git submodule sync submodule &&
|
||||||
|
test -z "$(git config submodule.submodule.url)"
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form foo' '
|
test_expect_success '"git submodule sync" handles origin URL of the form foo' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin foo &&
|
cd relative-clone &&
|
||||||
git submodule sync &&
|
git remote set-url origin foo &&
|
||||||
(cd submodule &&
|
git submodule sync &&
|
||||||
#actual fails with: "cannot strip off url foo
|
(
|
||||||
test "$(git config remote.origin.url)" = "../submodule"
|
cd submodule &&
|
||||||
)
|
#actual fails with: "cannot strip off url foo
|
||||||
|
test "$(git config remote.origin.url)" = "../submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form foo/bar' '
|
test_expect_success '"git submodule sync" handles origin URL of the form foo/bar' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin foo/bar &&
|
cd relative-clone &&
|
||||||
git submodule sync &&
|
git remote set-url origin foo/bar &&
|
||||||
(cd submodule &&
|
git submodule sync &&
|
||||||
#actual foo/submodule
|
(
|
||||||
test "$(git config remote.origin.url)" = "../foo/submodule"
|
cd submodule &&
|
||||||
)
|
#actual foo/submodule
|
||||||
(cd submodule/sub-submodule &&
|
test "$(git config remote.origin.url)" = "../foo/submodule"
|
||||||
test "$(git config remote.origin.url)" != "../../foo/submodule"
|
) &&
|
||||||
)
|
(
|
||||||
|
cd submodule/sub-submodule &&
|
||||||
|
test "$(git config remote.origin.url)" != "../../foo/submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync --recursive" propagates changes in origin' '
|
test_expect_success '"git submodule sync --recursive" propagates changes in origin' '
|
||||||
(cd recursive-clone &&
|
(
|
||||||
git remote set-url origin foo/bar &&
|
cd recursive-clone &&
|
||||||
git submodule sync --recursive &&
|
git remote set-url origin foo/bar &&
|
||||||
(cd submodule &&
|
git submodule sync --recursive &&
|
||||||
#actual foo/submodule
|
(
|
||||||
test "$(git config remote.origin.url)" = "../foo/submodule"
|
cd submodule &&
|
||||||
)
|
#actual foo/submodule
|
||||||
(cd submodule/sub-submodule &&
|
test "$(git config remote.origin.url)" = "../foo/submodule"
|
||||||
test "$(git config remote.origin.url)" = "../../foo/submodule"
|
) &&
|
||||||
)
|
(
|
||||||
|
cd submodule/sub-submodule &&
|
||||||
|
test "$(git config remote.origin.url)" = "../../foo/submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form ./foo' '
|
test_expect_success '"git submodule sync" handles origin URL of the form ./foo' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin ./foo &&
|
cd relative-clone &&
|
||||||
git submodule sync &&
|
git remote set-url origin ./foo &&
|
||||||
(cd submodule &&
|
git submodule sync &&
|
||||||
#actual ./submodule
|
(
|
||||||
test "$(git config remote.origin.url)" = "../submodule"
|
cd submodule &&
|
||||||
)
|
#actual ./submodule
|
||||||
|
test "$(git config remote.origin.url)" = "../submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form ./foo/bar' '
|
test_expect_success '"git submodule sync" handles origin URL of the form ./foo/bar' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin ./foo/bar &&
|
cd relative-clone &&
|
||||||
git submodule sync &&
|
git remote set-url origin ./foo/bar &&
|
||||||
(cd submodule &&
|
git submodule sync &&
|
||||||
#actual ./foo/submodule
|
(
|
||||||
test "$(git config remote.origin.url)" = "../foo/submodule"
|
cd submodule &&
|
||||||
)
|
#actual ./foo/submodule
|
||||||
|
test "$(git config remote.origin.url)" = "../foo/submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form ../foo' '
|
test_expect_success '"git submodule sync" handles origin URL of the form ../foo' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin ../foo &&
|
cd relative-clone &&
|
||||||
git submodule sync &&
|
git remote set-url origin ../foo &&
|
||||||
(cd submodule &&
|
git submodule sync &&
|
||||||
#actual ../submodule
|
(
|
||||||
test "$(git config remote.origin.url)" = "../../submodule"
|
cd submodule &&
|
||||||
)
|
#actual ../submodule
|
||||||
|
test "$(git config remote.origin.url)" = "../../submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form ../foo/bar' '
|
test_expect_success '"git submodule sync" handles origin URL of the form ../foo/bar' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin ../foo/bar &&
|
cd relative-clone &&
|
||||||
git submodule sync &&
|
git remote set-url origin ../foo/bar &&
|
||||||
(cd submodule &&
|
git submodule sync &&
|
||||||
#actual ../foo/submodule
|
(
|
||||||
test "$(git config remote.origin.url)" = "../../foo/submodule"
|
cd submodule &&
|
||||||
)
|
#actual ../foo/submodule
|
||||||
|
test "$(git config remote.origin.url)" = "../../foo/submodule"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
test_expect_success '"git submodule sync" handles origin URL of the form ../foo/bar with deeply nested submodule' '
|
test_expect_success '"git submodule sync" handles origin URL of the form ../foo/bar with deeply nested submodule' '
|
||||||
(cd relative-clone &&
|
(
|
||||||
git remote set-url origin ../foo/bar &&
|
cd relative-clone &&
|
||||||
mkdir -p a/b/c &&
|
git remote set-url origin ../foo/bar &&
|
||||||
( cd a/b/c &&
|
mkdir -p a/b/c &&
|
||||||
git init &&
|
(
|
||||||
:> .gitignore &&
|
cd a/b/c &&
|
||||||
git add .gitignore &&
|
git init &&
|
||||||
test_tick &&
|
>.gitignore &&
|
||||||
git commit -m "initial commit" ) &&
|
git add .gitignore &&
|
||||||
git submodule add ../bar/a/b/c ./a/b/c &&
|
test_tick &&
|
||||||
git submodule sync &&
|
git commit -m "initial commit"
|
||||||
(cd a/b/c &&
|
) &&
|
||||||
#actual ../foo/bar/a/b/c
|
git submodule add ../bar/a/b/c ./a/b/c &&
|
||||||
test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"
|
git submodule sync &&
|
||||||
)
|
(
|
||||||
|
cd a/b/c &&
|
||||||
|
#actual ../foo/bar/a/b/c
|
||||||
|
test "$(git config remote.origin.url)" = "../../../../foo/bar/a/b/c"
|
||||||
|
)
|
||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
@ -80,6 +80,21 @@ test_expect_success 'submodule update detaching the HEAD ' '
|
|||||||
)
|
)
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'submodule update from subdirectory' '
|
||||||
|
(cd super/submodule &&
|
||||||
|
git reset --hard HEAD~1
|
||||||
|
) &&
|
||||||
|
mkdir super/sub &&
|
||||||
|
(cd super/sub &&
|
||||||
|
(cd ../submodule &&
|
||||||
|
compare_head
|
||||||
|
) &&
|
||||||
|
git submodule update ../submodule &&
|
||||||
|
cd ../submodule &&
|
||||||
|
! compare_head
|
||||||
|
)
|
||||||
|
'
|
||||||
|
|
||||||
apos="'";
|
apos="'";
|
||||||
test_expect_success 'submodule update does not fetch already present commits' '
|
test_expect_success 'submodule update does not fetch already present commits' '
|
||||||
(cd submodule &&
|
(cd submodule &&
|
||||||
|
@ -80,6 +80,22 @@ test_expect_success 'test basic "submodule foreach" usage' '
|
|||||||
test_i18ncmp expect actual
|
test_i18ncmp expect actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
cat >expect <<EOF
|
||||||
|
Entering '../sub1'
|
||||||
|
$pwd/clone-foo1-../sub1-$sub1sha1
|
||||||
|
Entering '../sub3'
|
||||||
|
$pwd/clone-foo3-../sub3-$sub3sha1
|
||||||
|
EOF
|
||||||
|
|
||||||
|
test_expect_success 'test "submodule foreach" from subdirectory' '
|
||||||
|
mkdir clone/sub &&
|
||||||
|
(
|
||||||
|
cd clone/sub &&
|
||||||
|
git submodule foreach "echo \$toplevel-\$name-\$sm_path-\$sha1" >../../actual
|
||||||
|
) &&
|
||||||
|
test_i18ncmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup nested submodules' '
|
test_expect_success 'setup nested submodules' '
|
||||||
git clone submodule nested1 &&
|
git clone submodule nested1 &&
|
||||||
git clone submodule nested2 &&
|
git clone submodule nested2 &&
|
||||||
|
Loading…
Reference in New Issue
Block a user