Skip to content

Commit a94f911

Browse files
LukeShugitster
authored andcommitted
subtree: use "$*" instead of "$@" as appropriate
"$*" is for when you want to concatenate the args together, whitespace-separated; and "$@" is for when you want them to be separate strings. There are several places in subtree that erroneously use $@ when concatenating args together into an error message. For instance, if the args are argv[1]="dead" and argv[2]="beef", then the line die "You must provide exactly one revision. Got: '$@'" surely intends to call 'die' with the argument argv[1]="You must provide exactly one revision. Got: 'dead beef'" however, because the line used $@ instead of $*, it will actually call 'die' with the arguments argv[1]="You must provide exactly one revision. Got: 'dead" argv[2]="beef'" This isn't a big deal, because 'die' concatenates its arguments together anyway (using "$*"). But that doesn't change the fact that it was a mistake to use $@ instead of $*, even though in the end $@ still ended up doing the right thing. Signed-off-by: Luke Shumaker <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent e2b11e4 commit a94f911

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

contrib/subtree/git-subtree.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,14 +58,14 @@ progress () {
5858
assert () {
5959
if ! "$@"
6060
then
61-
die "assertion failed: " "$@"
61+
die "assertion failed: $*"
6262
fi
6363
}
6464

6565
ensure_single_rev () {
6666
if test $# -ne 1
6767
then
68-
die "You must provide exactly one revision. Got: '$@'"
68+
die "You must provide exactly one revision. Got: '$*'"
6969
fi
7070
}
7171

@@ -690,7 +690,7 @@ cmd_add () {
690690

691691
cmd_add_repository "$@"
692692
else
693-
say >&2 "error: parameters were '$@'"
693+
say >&2 "error: parameters were '$*'"
694694
die "Provide either a commit or a repository and commit."
695695
fi
696696
}

0 commit comments

Comments
 (0)