title: libgit2 get content from older commit in C++
body: <p>My problem seems quite simple but I seem to be on the wrong path on this.</p>
  <p>I want to retreive an object from an older commit. What I have is she short OID (e.g. a6bcd4) to exactly this commit. There have been several new commits since this commit has been processed.</p>
  <p>The code for retreiving this looks like the following.</p>
  <p><em>long_branch</em> is pointing to master, and <em>path</em> is pointing to a file abcd/file.txt</p>
  <pre><code>git_oid oid;
  git_tree *tree;
  git_commit *commit;
  
  if (git_reference_name_to_id(&amp;oid, m_repo, long_branch.c_str())) return nullptr;
  
  if (git_commit_lookup(&amp;commit, m_repo, &amp;oid)) return nullptr;
  git_commit_tree(&amp;tree, commit);
  
  git_tree_entry *entry;
  git_tree_entry_bypath(&amp;entry, tree, path.c_str());
  
  git_object *obj;
  git_tree_entry_to_object(&amp;obj, m_repo, entry);
  </code></pre>
  <p>All calls return 0 (zero), so there is no error, but what I get is always the latest (HEAD) version of this file.</p>