In trying to write a pre-receive hook which rejects certain kinds of changes to certain kinds of files, I am stumped as to why the following is legal in that script:
git show <new_commit>:<file>
as is used in this example (after having teased out the affected files using diff with --name-only), but not
git diff <old_commit> <new_commit> -- <file>
I prefer the latter so that I only reject changes introduced rather than patterns already existing in the files, but it generates the error: "unknown revision or path not in the working tree" when executed from this script.
I suspect it has to do with the ordering of events, since both work at the command-line on my bare repo, but would like to understand the distinction.