From 4da588357a4a8b73f6a8d9c24435dabee74d0a7e Mon Sep 17 00:00:00 2001 From: Ronnie Sahlberg Date: Tue, 6 May 2014 15:45:52 -0700 Subject: refs.c: add new functions reflog_exists and delete_reflog Add two new functions, reflog_exists and delete_reflog, to hide the internal reflog implementation (that they are files under .git/logs/...) from callers. Update checkout.c to use these functions in update_refs_for_switch instead of building pathnames and calling out to file access functions. Update reflog.c to use these to check if the reflog exists. Now there are still many places in reflog.c where we are still leaking the reflog storage implementation but this at least reduces the number of such dependencies by one. Finally change two places in refs.c itself to use the new function to check if a ref exists or not isntead of build-path-and-stat(). Now, this is strictly not all that important since these are in parts of refs that are implementing the actual file storage backend but on the other hand it will not hurt either. Signed-off-by: Ronnie Sahlberg Acked-by: Michael Haggerty Signed-off-by: Junio C Hamano --- builtin/reflog.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'builtin/reflog.c') diff --git a/builtin/reflog.c b/builtin/reflog.c index c12a9784e6..e8a8fb13b9 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -369,7 +369,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused, if (!lock) return error("cannot lock ref '%s'", ref); log_file = git_pathdup("logs/%s", ref); - if (!file_exists(log_file)) + if (!reflog_exists(ref)) goto finish; if (!cmd->dry_run) { newlog_path = git_pathdup("logs/%s.lock", ref); -- cgit v1.2.1