title: libgit2 does not return a valid blob
body: <p>I'm trying to get a blob of a repository with libgit2:</p>
  
  <pre><code>#include &lt;git2.h&gt;
  #include &lt;stdio.h&gt;
  
  int main() {
  
      git_libgit2_init();
  
      git_repository *repo = NULL;
      int error = git_repository_open(&amp;repo, "/home/martin/Dokumente/TestRepository");
  
      if (error &lt; 0) {
    const git_error *e = git_error_last();
    printf("Error %d/%d: %s\n", error, e-&gt;klass, e-&gt;message);
    exit(error);
  }
  
  git_diff *diff = NULL;
  git_diff_options opts = GIT_DIFF_OPTIONS_INIT;
  opts.flags |= GIT_DIFF_IGNORE_WHITESPACE;
  opts.flags |= GIT_DIFF_INCLUDE_UNTRACKED;
  
  error = git_diff_index_to_workdir(&amp;diff, repo, NULL, &amp;opts);
  if (error &lt; 0) {
    const git_error *e = git_error_last();
    printf("Error %d/%d: %s\n", error, e-&gt;klass, e-&gt;message);
    exit(error);
  }
  
  git_patch* patch = nullptr;
  git_patch_from_diff(&amp;patch, diff, 0);
  
  bool oldFile = false;
  const git_diff_delta *dd = git_patch_get_delta(patch);
  const git_oid &amp;id = (!oldFile) ? dd-&gt;new_file.id : dd-&gt;old_file.id;
  
  git_object *obj = nullptr;
  git_object_lookup(&amp;obj, repo, &amp;id, GIT_OBJECT_ANY);
  git_blob* blob = reinterpret_cast&lt;git_blob *&gt;(obj);
  
  const char* pointer = (const char*)git_blob_rawcontent(blob);
  
  // cleanup
  git_object_free(obj);
  git_patch_free(patch);
  git_diff_free(diff);
  git_repository_free(repo);
  
  return 0;
  }
  </code></pre>
  
  <p>The repository</p>
  
  <ul>
  <li><p>create a new repository</p></li>
  <li><p>commit a file like:</p>
  
  <p>1
  2
  3
  4</p></li>
  <li><p>remove the 4 again, but do not commit</p></li>
  <li><p>let the program run</p></li>
  </ul>
  
  <p><strong>Expected</strong>:
  The program runs fine.</p>
  
  <p><strong>Observed</strong>:
  obj is still a nullptr after executing
  git_object_lookup()</p>
  
  <p>When setting the variable oldFile to true, the program runs fine and the pointer "pointer" contains the raw blob.</p>
  
  <p>Does anybody know why I don't get a valid object from git_object_lookup() back?</p>