test-lib-functions.sh: teach test_commit -C <dir>
Specifically when setting up submodule tests, it comes in handy if we can create commits in repositories that are not at the root of the tested trash dir. Add "-C <dir>" similar to gits -C parameter that will perform the operation in the given directory. Signed-off-by: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
parent
89c8626557
commit
6f94351b0a
@ -157,16 +157,21 @@ debug () {
|
|||||||
GIT_TEST_GDB=1 "$@"
|
GIT_TEST_GDB=1 "$@"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Call test_commit with the arguments "<message> [<file> [<contents> [<tag>]]]"
|
# Call test_commit with the arguments
|
||||||
|
# [-C <directory>] <message> [<file> [<contents> [<tag>]]]"
|
||||||
#
|
#
|
||||||
# This will commit a file with the given contents and the given commit
|
# This will commit a file with the given contents and the given commit
|
||||||
# message, and tag the resulting commit with the given tag name.
|
# message, and tag the resulting commit with the given tag name.
|
||||||
#
|
#
|
||||||
# <file>, <contents>, and <tag> all default to <message>.
|
# <file>, <contents>, and <tag> all default to <message>.
|
||||||
|
#
|
||||||
|
# If the first argument is "-C", the second argument is used as a path for
|
||||||
|
# the git invocations.
|
||||||
|
|
||||||
test_commit () {
|
test_commit () {
|
||||||
notick= &&
|
notick= &&
|
||||||
signoff= &&
|
signoff= &&
|
||||||
|
indir= &&
|
||||||
while test $# != 0
|
while test $# != 0
|
||||||
do
|
do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
@ -176,21 +181,26 @@ test_commit () {
|
|||||||
--signoff)
|
--signoff)
|
||||||
signoff="$1"
|
signoff="$1"
|
||||||
;;
|
;;
|
||||||
|
-C)
|
||||||
|
indir="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*)
|
*)
|
||||||
break
|
break
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
shift
|
shift
|
||||||
done &&
|
done &&
|
||||||
|
indir=${indir:+"$indir"/} &&
|
||||||
file=${2:-"$1.t"} &&
|
file=${2:-"$1.t"} &&
|
||||||
echo "${3-$1}" > "$file" &&
|
echo "${3-$1}" > "$indir$file" &&
|
||||||
git add "$file" &&
|
git ${indir:+ -C "$indir"} add "$file" &&
|
||||||
if test -z "$notick"
|
if test -z "$notick"
|
||||||
then
|
then
|
||||||
test_tick
|
test_tick
|
||||||
fi &&
|
fi &&
|
||||||
git commit $signoff -m "$1" &&
|
git ${indir:+ -C "$indir"} commit $signoff -m "$1" &&
|
||||||
git tag "${4:-$1}"
|
git ${indir:+ -C "$indir"} tag "${4:-$1}"
|
||||||
}
|
}
|
||||||
|
|
||||||
# Call test_merge with the arguments "<message> <commit>", where <commit>
|
# Call test_merge with the arguments "<message> <commit>", where <commit>
|
||||||
|
Loading…
x
Reference in New Issue
Block a user