On 01/30, Junio C Hamano wrote:
> Thomas Gummerer <[email protected]> writes:
>
> > create_stash () {
> > - stash_msg="$1"
> > - untracked="$2"
> > + stash_msg=
> > + untracked=
> > + new_style=
> > ...
> > + while test $# != 0
> > + do
> > + case "$1" in
> > + -m|--message)
> > + shift
> > + stash_msg="$1"
>
> ${1?"-m needs an argument"}
>
> to error check "git stash create -m<Enter>"?
>
> > + if test -z "$new_style"
> > + then
> > + stash_msg="$*"
> > + fi
>
> This breaks external users who do "git stash create" in the old
> fashioned way, I think, but can be easily fixed with something like:
>
> stash_msg=$1 untracked=$2
>
> If the existing tests did not catch this, I guess there is a
> coverage gap we may want to fill. Perhaps add a new test to 3903
> that runs "git stash create message untracked" and makes sure it
> still works?
No I don't think this breaks. It was never possible to add an
untracked argument to git stash create. The difference is in a part
of this patch that is snipped out in your reply:
@@ -697,7 +739,7 @@ clear)
;;
create)
shift
- create_stash "$*" && echo "$w_commit"
+ create_stash "$@" && echo "$w_commit"
;;
store)
shift
If I understand this piece correctly (I'm not very proficient in
shell, but my testing seems to agree with me), previously we used $*,
which transformed all arguments to git stash create into one argument
in create_stash. This needed to change to $@, as otherwise we can't
pull the arguments apart for the new calling style. The two argument
version of create_stash was only used internally in the save_stash
function.
> > diff --git a/t/t3903-stash.sh b/t/t3903-stash.sh
> > index 0171b824c9..34e9610bb6 100755
> > --- a/t/t3903-stash.sh
> > +++ b/t/t3903-stash.sh
> > @@ -784,4 +784,22 @@ test_expect_success 'push -m shows right message' '
> > test_cmp expect actual
> > '
> >
> > +test_expect_success 'deprecated version of stash create stores correct
> > message' '
> > + >foo &&
> > + git add foo &&
> > + STASH_ID=$(git stash create "create test message") &&
> > + echo "On master: create test message" >expect &&
> > + git show --pretty=%s ${STASH_ID} | head -n1 >actual &&
> > + test_cmp expect actual
> > +'
> > +
> > +test_expect_success 'new style stash create stores correct message' '
> > + >foo &&
> > + git add foo &&
> > + STASH_ID=$(git stash create -m "create test message new style") &&
> > + echo "On master: create test message new style" >expect &&
> > + git show --pretty=%s ${STASH_ID} | head -n1 >actual &&
> > + test_cmp expect actual
> > +'
> > +
> > test_done
--
Thomas