Re: [PATCH 5/5] t/t5520: test --[no-]autostash with pull.rebase=true
- From
Matthieu Moy <matthieu.moy@grenoble-inp.fr>
- Date
- Apr 4, 2016, 16:52 UTC
- Message-ID
- <vpq4mbhmi3g.fsf@anie.imag.fr>
- In-Reply-To
- <CA+DCAeRqY7-qZt-upa5=nY8OkUL4Q76ogk5nrF_WAaiFiWOy1A@mail.gmail.com>
Mehul Jain <mehul.jain2029@gmail.com> writes:
Show 21 quoted lines
> On Mon, Apr 4, 2016 at 12:58 AM, Eric Sunshine <sunshine@sunshineco.com> wrote: >> On Fri, Apr 1, 2016 at 6:27 AM, Mehul Jain <mehul.jain2029@gmail.com> wrote: >>> In test_autostash() there's a line >>> >>> echo test_cmp_rev HEAD^ copy && >>> >>> Originally it should have been >>> >>> test_cmp_rev HEAD^ copy && >>> >>> but this raise following error while testing >>> >>> ./t5520-pull.sh: 684: eval: diff -u: not found >> >> This is caused by the custom IFS=',\t=' which is still in effect when >> test_cmp_rev() is invoked. You need to restore IFS within the loop >> itself. > > Thanks for pointing it out. I made a mistake by not considering > the consequences of setting IFS=',\t='. I tried it out again and > this time all tests passed perfectly.
I think it would be much simpler to drop the loop, and write instead something like (untested):
test_autostash () {
expect="$1"
cmd="$2"
config_variable="$3"
value="$4"
test_expect_success "$cmd, $config_variable=$value" '
if [ "$value" = "" ]; then
test_unconfig $config_variable
else
test_config $config_variable $value
fi && git reset --hard before-rebase &&
echo dirty >new_file &&
git add new_file && if [ $expect = "ok" ]; then
git pull '$cmd' . copy &&
test_cmp_rev HEAD^ copy &&
test "$(cat new_file)" = dirty &&
test "$(cat file)" = "modified again"
else
test_must_fail git pull '$cmd' . copy 2>err &&
test_i18ngrep "uncommitted changes." err
fi
'
}test_autostash ok --rebase rebase.autostash=true test_autostash ok '--rebase --autostash' rebase.autostash=true test_autostash ok '--rebase --autostash' rebase.autostash=false test_autostash ok '--rebase --autostash' rebase.autostash= test_autostash err '--rebase --no-autostash' rebase.autostash=true test_autostash err '--rebase --no-autostash' rebase.autostash=false test_autostash err '--rebase --no-autostash' rebase.autostash= test_autostash ok --autostash pull.rebase=true test_autostash err --no-autostash pull.rebase=true
-- Matthieu Moy http://www-verimag.imag.fr/~moy/