GitlabCI Merge Request - get commit difference between branches

When using gitlab-ci doing

git log --pretty=format:'%s' --date=relative origin/<branch_name>..HEAD
returns plenty of open branches instead the commits. Why is that?
Sample:

$ git log --pretty=format:'%s' --date=relative origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}..origin/${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} --until=3.weeks.ago
 .git/FETCH_HEAD:UDC-738
 .git/FETCH_HEAD:UDC-831
 .git/FETCH_HEAD:UDC-965

I am trying to get out the commit difference between branches, but GitlabCi seems to be running in detached head and ruturning the active branches instead.

I’ve tried using the CI_MERGE_REQUEST_SOURCE_BRANCH_SHA1 and CI_MERGE_REQUEST_TARGET_BRANCH_SHA1 as well with no luck.

Is it a misunderstanding on my end of what the git-log should return, or am I getting wrong results & how to get to the commit difference between the branches?

I’ve made this as a sample, but getting different results now apparently the target_sha is not available there.

Possible issuess with the variable - checking if I can replace it somehow

Thanks in advance

Seem like I have to attach the head.
Disclaimer I get the script running through python, that’s why it get’s me any results at all.

I had to do a fetch & attach the branch to fix this if anyone needs it in the future.

This worked just fine

    - git fetch
    - git checkout ${FETCH_HEAD}
    - export ISSUES=`git log --pretty=format:'%s' --date=relative origin/${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}..HEAD | grep -e 'xxx-[0-9]\{1,4\}' -o`