1. 09 9月, 2017 2 次提交
    • M
      packed_ref_store: implement reference transactions · 2775d872
      Michael Haggerty 提交于
      Implement the methods needed to support reference transactions for
      the packed-refs backend. The new methods are not yet used.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      2775d872
    • M
      packed-backend: don't adjust the reference count on lock/unlock · 39c8df0c
      Michael Haggerty 提交于
      The old code incremented the packed ref cache reference count when
      acquiring the packed-refs lock, and decremented the count when
      releasing the lock. This is unnecessary because:
      
      * Another process cannot change the packed-refs file because it is
        locked.
      
      * When we ourselves change the packed-refs file, we do so by first
        modifying the packed ref-cache, and then writing the data from the
        ref-cache to disk. So the packed ref-cache remains fresh because any
        changes that we plan to make to the file are made in the cache first
        anyway.
      
      So there is no reason for the cache to become stale.
      
      Moreover, the extra reference count causes a problem if we
      intentionally clear the packed refs cache, as we sometimes need to do
      if we change the cache in anticipation of writing a change to disk,
      but then the write to disk fails. In that case, `packed_refs_unlock()`
      would have no easy way to find the cache whose reference count it
      needs to decrement.
      
      This whole issue will soon become moot due to upcoming changes that
      avoid changing the in-memory cache as part of updating the packed-refs
      on disk, but this change makes that transition easier.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      39c8df0c
  2. 28 7月, 2017 1 次提交
    • M
      packed_ref_store: handle a packed-refs file that is a symlink · 198b808e
      Michael Haggerty 提交于
      One of the tricks that `contrib/workdir/git-new-workdir` plays is to
      making `packed-refs` in the new workdir a symlink to the `packed-refs`
      file in the original repository. Before
      42dfa7ec ("commit_packed_refs(): use a staging file separate from
      the lockfile", 2017-06-23), a lockfile was used as the staging file,
      and because the `LOCK_NO_DEREF` was not used, the pointed-to file was
      locked and modified.
      
      But after that commit, the staging file was created using a tempfile,
      with the end result that rewriting the `packed-refs` file in the
      workdir overwrote the symlink rather than the original `packed-refs`
      file.
      
      Change `commit_packed_refs()` to use `get_locked_file_path()` to find
      the path of the file that it should overwrite. Since that path was
      properly resolved when the lockfile was created, this restores the
      pre-42dfa7ec behavior.
      
      Also add a test case to document this use case and prevent a
      regression like this from recurring.
      Signed-off-by: NMichael Haggerty <mhagger@alum.mit.edu>
      Reviewed-by: NJonathan Nieder <jrnieder@gmail.com>
      Signed-off-by: NJunio C Hamano <gitster@pobox.com>
      198b808e
  3. 04 7月, 2017 2 次提交
  4. 24 6月, 2017 9 次提交