title: Gitlab CI variables and script section give different results
body: <p>I've searched a lot of examples but they did not work for me.</p>
  <p>I'm trying to run linters for changed files when MR is opened.</p>
  <p>My <code>.gitlab-ci.yml</code></p>
  <pre><code>run_linters:
    image: python:3
    variables:
      FILES: git diff --name-only $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | grep *.py
    before_script:
      - python3 -m pip install black==21.5b1
      - python3 -m pip install flake8==3.9.2
    script:
      - echo $FILES
      - git diff --name-only $CI_MERGE_REQUEST_TARGET_BRANCH_NAME | grep *.py
      - black --check $FILES
      - flake8 $FILES
    only:
      - merge_requests
  </code></pre>
  <p>And I'm getting strange output.</p>
  <p><code>echo $FILES</code> says <code>git diff --name-only main | grep incoming_file.py</code></p>
  <p><code>incoming_file.py</code> is the only file in that MR. Why is it around <code>grep</code>?</p>
  <p>And <code>git diff</code> at script section says <code>fatal: ambiguous argument 'main': unknown revision or path not in the working tree.</code></p>
  <ol>
  <li>Why is filename present around <code>grep</code>?</li>
  <li>Why are same <code>git diff</code> commands give different result?</li>
  </ol>