From 3a95f31d1cdc93fa4f926c6537f84186edd85ca9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Sat, 12 Jan 2019 09:13:24 +0700 Subject: repository.c: replace hold_locked_index() with repo_hold_locked_index() MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit hold_locked_index() assumes the index path at $GIT_DIR/index. This is not good for places that take an arbitrary index_state instead of the_index, which is basically everywhere except builtin/. Replace it with repo_hold_locked_index(). hold_locked_index() remains as a wrapper around repo_hold_locked_index() to reduce changes in builtin/ Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- repository.c | 10 ++++++++++ 1 file changed, 10 insertions(+) (limited to 'repository.c') diff --git a/repository.c b/repository.c index 7b02e1dffa..9411c4baee 100644 --- a/repository.c +++ b/repository.c @@ -3,6 +3,7 @@ #include "object-store.h" #include "config.h" #include "object.h" +#include "lockfile.h" #include "submodule-config.h" /* The main repository */ @@ -263,3 +264,12 @@ int repo_read_index(struct repository *repo) return read_index_from(repo->index, repo->index_file, repo->gitdir); } + +int repo_hold_locked_index(struct repository *repo, + struct lock_file *lf, + int flags) +{ + if (!repo->index_file) + BUG("the repo hasn't been setup"); + return hold_lock_file_for_update(lf, repo->index_file, flags); +} -- cgit v1.2.3 From f8adbec9feaa7a1ab9814db1115826e87033712e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Nguy=E1=BB=85n=20Th=C3=A1i=20Ng=E1=BB=8Dc=20Duy?= Date: Thu, 24 Jan 2019 15:29:12 +0700 Subject: cache.h: flip NO_THE_INDEX_COMPATIBILITY_MACROS switch MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit By default, index compat macros are off from now on, because they could hide the_index dependency. Only those in builtin can use it. Signed-off-by: Nguyễn Thái Ngọc Duy Signed-off-by: Junio C Hamano --- repository.c | 6 ++++++ 1 file changed, 6 insertions(+) (limited to 'repository.c') diff --git a/repository.c b/repository.c index 9411c4baee..36a3b52d70 100644 --- a/repository.c +++ b/repository.c @@ -1,3 +1,8 @@ +/* + * not really _using_ the compat macros, just make sure the_index + * declaration matches the definition in this file. + */ +#define USE_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" #include "repository.h" #include "object-store.h" @@ -9,6 +14,7 @@ /* The main repository */ static struct repository the_repo; struct repository *the_repository; +struct index_state the_index; void initialize_the_repository(void) { -- cgit v1.2.3