]> git.ipfire.org Git - thirdparty/git.git/commit - refs/refs-internal.h
refs: resolve symbolic refs first
authorMichael Haggerty <mhagger@alum.mit.edu>
Mon, 25 Apr 2016 13:56:07 +0000 (15:56 +0200)
committerMichael Haggerty <mhagger@alum.mit.edu>
Mon, 13 Jun 2016 09:23:50 +0000 (11:23 +0200)
commit92b1551b1d407065f961ffd1d972481063a0edcc
treeb0414772aae6e158900945f1e5374f523aa8f1cc
parent8a679de6f1a4bd077f828273f75eea46947b5b73
refs: resolve symbolic refs first

Before committing ref updates, split symbolic ref updates into two
parts: an update to the underlying ref, and a log-only update to the
symbolic ref. This ensures that both references are locked correctly
during the transaction, including while their reflogs are updated.

Similarly, if the reference pointed to by HEAD is modified directly, add
a separate log-only update to HEAD, rather than leaving the job of
updating HEAD's reflog to commit_ref_update(). This change ensures that
HEAD is locked correctly while its reflog is being modified, as well as
being cheaper (HEAD only needs to be resolved once).

This makes use of a new function, lock_raw_ref(), which is analogous to
read_raw_ref(), but acquires a lock on the reference before reading it.

This change still has two problems:

* There are redundant read_ref_full() reference lookups.

* It is still possible to get incorrect reflogs for symbolic references
  if there is a concurrent update by another process, since the old_oid
  of a symref is determined before the lock on the pointed-to ref is
  held.

Both problems will soon be fixed.

Signed-off-by: David Turner <dturner@twopensource.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu>
WIP
refs/files-backend.c
refs/refs-internal.h
t/t1400-update-ref.sh