Skip to content
This repository was archived by the owner on Sep 11, 2020. It is now read-only.

dotgit: handle refs that exist in both packed-refs and a loose ref file #666

Merged
merged 3 commits into from
Nov 28, 2017

Conversation

strib
Copy link
Contributor

@strib strib commented Nov 28, 2017

If a repo starts out with a packed-refs file, and later a reference is updated by creating a new reference file for a name that already exists in packed-refs, then the same reference will be listed in two places (possibly with two different ref values). This is legal in git; the loose ref file always takes precedence over the packed-ref file. However, to support this properly, go-git needs to do two things:

  1. On ref removal, remove it from both places. First remove the ref file, and then remove the packed-refs file (under a lock). Note that if the underlying storage layer is distributed and might be accessed concurrently, we'd likely require stronger locking semantics to make sure the (possibly out-of-date) packed-refs value isn't accessed after the loose ref is deleted but before packed-refs is cleaned up, but I leave that for future work.
  2. When listing refs, don't double-report refs in packed-refs. This used to be the case, but recently (dotgit: remove ref cache for packed refs #651) it was changed, so this restores the original logic (without adding the packed-refs cache back in).

@strib
Copy link
Contributor Author

strib commented Nov 28, 2017

(If #665 is merged first, we'll need to update the test in this PR to get it to compile, so please don't blindly merge it.)

@mcuadros
Copy link
Contributor

mcuadros commented Nov 28, 2017

@strib merge yourself when you are ready.

@strib strib merged commit 6dda959 into src-d:master Nov 28, 2017
@strib strib deleted the strib/delete-from-packed-ref branch November 28, 2017 18:13
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants