title: why do I hit assert in libgit2 when performing remote fetch
body: <p>I'm trying to implement merge with libgit2, and I always hit this assert when performing remote_fetch or create_annotated_commit followed by git_repository_free</p>
  
  <p>But I don't know what I did wrong? And there is no libgit error generated. And I also don't understand the meaning of this assert.</p>
  
  <p>A typical call stack is the following:</p>
  
  <pre><code>2  __GI_abort              abort.c       90  0x7f35da541f5d 
  3  __assert_fail_base      assert.c      92  0x7f35da537f17 
  4  __GI___assert_fail      assert.c      101 0x7f35da537fc2 
  5  git_mwindow_put_pack    mwindow.c     106 0x7f35db69725f 
  6  pack_backend__free      odb_pack.c    565 0x7f35db6a3dda 
  7  odb_free                odb.c         679 0x7f35db69d5c4 
  8  git_odb_free            odb.c         696 0x7f35db69d67c 
  9  set_odb                 repository.c  95  0x7f35db6d40c3 
  10 git_repository__cleanup repository.c  150 0x7f35db6d42a3 
  11 git_repository_free     repository.c  161 0x7f35db6d42da 
  12 GitEngine::~GitEngine   GitEngine.cpp 268 0x556a9e4f067d 
  13 main                    main.cpp      24  0x556a9e4eed8e 
  </code></pre>
  
  <p>To reproduce this issue, I simply need to do this:</p>
  
  <pre><code>    git_remote *remote;
      int err = git_remote_create(&amp;remote, m_repo, "remotefetch", "./repoD/");
      git_fetch_options fetch_opts = GIT_FETCH_OPTIONS_INIT;
      if (err) {
          qDebug() &lt;&lt; "error";
      }
      err = git_remote_fetch(remote, nullptr, &amp;fetch_opts, nullptr);
      if (err) {
          qDebug() &lt;&lt; "error";
      }
  
      if (m_repo) //this is in the destructor 
      git_repository_free(m_repo);
  
  </code></pre>
  
  <p>if I replace git_remote_create with git_remote_create_anonymous, the issue will be gone.</p>
  
  <p>However, event with git_remote_create_anonymous, if I call git_annotated_commit_from_fetchhead later, before git_repository_free , I will hit the same assert again. I have no idea why? I checked the git repository with the command line, the merge seemed to be performed correctly.</p>