title: Git: Show the committed contents of all files that changed between two revisions
body: <p>Given a commit range <code>&lt;old_sha&gt;..&lt;new_sha&gt;</code>, I want the <em>committed</em> contents (not the list of changed files, and not their diffs), as of <code>&lt;new_sha&gt;</code>, of all files that changed between <code>&lt;old_sha&gt;</code> and <code>&lt;new_sha&gt;</code>. I can't simply read from disk because I want to ignore un-committed changes.</p>
  <p>Additional constraints:</p>
  <ul>
  <li>I don't want to modify the working directory as part of this operation, so I can't, e.g., stash unstaged changes, read from disk, and then git stash pop.</li>
  <li>Must be relatively performant in a very large repo (it'll be executed in a pre-push hook).</li>
  </ul>
  <p>The closest I've gotten is:</p>
  <ul>
  <li>Get the list of changed files</li>
  <li>Run <code>git show head:path/to/file_a head:path/to/file_b</code>, which writes the committed file contents to stdout, but without a delimiter, so there's no way of programmatically knowing where each file ends/begins.</li>
  </ul>