]> git.ipfire.org Git - thirdparty/git.git/commit - cache.h
factor out refresh_and_write_cache function
authorThomas Gummerer <t.gummerer@gmail.com>
Wed, 11 Sep 2019 18:20:25 +0000 (19:20 +0100)
committerJunio C Hamano <gitster@pobox.com>
Fri, 20 Sep 2019 16:58:21 +0000 (09:58 -0700)
commit22184497a36a90e541617a51de6671ca5948612c
treea70eaa44081f73758d7665191e42e3877fe884e2
parent745f6812895b31c02b29bdfe4ae8e5498f776c26
factor out refresh_and_write_cache function

Getting the lock for the index, refreshing it and then writing it is a
pattern that happens more than once throughout the codebase, and isn't
trivial to get right.  Factor out the refresh_and_write_cache function
from builtin/am.c to read-cache.c, so it can be re-used in other
places in a subsequent commit.

Note that we return different error codes for failing to refresh the
cache, and failing to write the index.  The current caller only cares
about failing to write the index.  However for other callers we're
going to convert in subsequent patches we will need this distinction.

Helped-by: Martin Ă…gren <martin.agren@gmail.com>
Helped-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
Signed-off-by: Thomas Gummerer <t.gummerer@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
cache.h
read-cache.c