git log pretty oneline output with just short hash and filename

Viewed 561

I need to get a list of remotely changed files as a single line that I then process line by line to generate a list of outdated files.

But I am astounded that out of all the possible pretty format %tokens, there is not one to get the filename: https://git-scm.com/docs/pretty-formats

git log --pretty=format:'%f' -- 'myfilename-to-check';

pretty=format:'%f' will give me the commit message, but how can I get the filename inside the pretty format.

Yes I know I can do --name-only or --name-status but that does not allow me to format the output exactly as I need it.

Is there no formatting %token / %key that shows the filename ?

Update

My apologies, I forgot to state that that there are multiple filenames to check:

git log --pretty=format:'%f' -- 'myfilename-to-check-1' 'myfilename-to-check-2' 'myfilename-to-check-3' 'myfilename-to-check-...etc...';
2 Answers

There is not such placeholder for changed files. Here is a workaround in bash.

git rev-list HEAD -- myfile-to-check | while read commit;do
    echo $(git log -1 $commit --pretty=format:'%h-%f' --name-only)
done

git rev-list prints the commit hashes that change myfile-to-check. echo and git log -1 prints the short hash, sanitized subject, and changed files of each commit one by one.

Since this does not seem to be supported, you can simply concatenate the filename to each line of your git log output, using sed for instance

git log --pretty=format:'%f' -- 'myfilename-to-check'| sed 's/$/ myfilename-to-check/'
Related