Mehul Jain <mehul.jain2...@gmail.com> writes:

> On Mon, Apr 4, 2016 at 12:58 AM, Eric Sunshine <sunsh...@sunshineco.com> 
> wrote:
>> On Fri, Apr 1, 2016 at 6:27 AM, Mehul Jain <mehul.jain2...@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/
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majord...@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

Reply via email to