I have a list of commits and I want git-log(1) or git-show(1) to show all of them. But only them. Not also commits that are reachable from them.
You need --stdin
which lets you provide options and commits from
standard in as well as the one you’ve already provided. Keep in mind
that it seems that this should be the last argument that you provide.
Then you need --no-walk
which stops the command from finding
ancestors.
$ cat example.txt
HEAD
HEAD~2
HEAD~5
$ <example.txt git log --no-walk --stdin
ref=commits
[ "$(git notes --ref="$ref" | head -1)" ] \
&& git notes --ref="$ref" list \
| cut -d' ' -f 2 \
| git log --no-walk --ignore-missing --stdin
(Thanks to eftshift0)
git-show(1) will let you both show commits and other kinds of objects (the example application takes objects from Git Notes and Notes can be attached to any object).
$ cat example.txt
HEAD
HEAD~2
HEAD~5
<example.txt git show --stdin
The example application:
ref=commits
[ "$(git notes --ref="$ref" | head -1)" ] \
&& git notes --ref="$ref" list \
| cut -d' ' -f 2 \
| git show --ignore-missing --stdin