Skip to content

Commit 8b71503

Browse files
committed
Merge branch 'dl/subtree-limit-to-one-rev'
"git subtree" (in contrib/) update. * dl/subtree-limit-to-one-rev: contrib/subtree: ensure only one rev is provided
2 parents 6364386 + 77128ed commit 8b71503

File tree

1 file changed

+12
-12
lines changed

1 file changed

+12
-12
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ git subtree add --prefix=<prefix> <repository> <ref>
1414
git subtree merge --prefix=<prefix> <commit>
1515
git subtree pull --prefix=<prefix> <repository> <ref>
1616
git subtree push --prefix=<prefix> <repository> <ref>
17-
git subtree split --prefix=<prefix> <commit...>
17+
git subtree split --prefix=<prefix> <commit>
1818
--
1919
h,help show the help
2020
q quiet
@@ -77,6 +77,12 @@ assert () {
7777
fi
7878
}
7979

80+
ensure_single_rev () {
81+
if test $# -ne 1
82+
then
83+
die "You must provide exactly one revision. Got: '$@'"
84+
fi
85+
}
8086

8187
while test $# -gt 0
8288
do
@@ -185,6 +191,7 @@ if test "$command" != "pull" &&
185191
then
186192
revs=$(git rev-parse $default --revs-only "$@") || exit $?
187193
dirs=$(git rev-parse --no-revs --no-flags "$@") || exit $?
194+
ensure_single_rev $revs
188195
if test -n "$dirs"
189196
then
190197
die "Error: Use --prefix instead of bare filenames."
@@ -716,9 +723,8 @@ cmd_add_repository () {
716723
}
717724

718725
cmd_add_commit () {
719-
revs=$(git rev-parse $default --revs-only "$@") || exit $?
720-
set -- $revs
721-
rev="$1"
726+
rev=$(git rev-parse $default --revs-only "$@") || exit $?
727+
ensure_single_rev $rev
722728

723729
debug "Adding $dir as '$rev'..."
724730
git read-tree --prefix="$dir" $rev || exit $?
@@ -817,16 +823,10 @@ cmd_split () {
817823
}
818824

819825
cmd_merge () {
820-
revs=$(git rev-parse $default --revs-only "$@") || exit $?
826+
rev=$(git rev-parse $default --revs-only "$@") || exit $?
827+
ensure_single_rev $rev
821828
ensure_clean
822829

823-
set -- $revs
824-
if test $# -ne 1
825-
then
826-
die "You must provide exactly one revision. Got: '$revs'"
827-
fi
828-
rev="$1"
829-
830830
if test -n "$squash"
831831
then
832832
first_split="$(find_latest_squash "$dir")"

0 commit comments

Comments
 (0)