diff options
author | Nguyễn Thái Ngọc Duy <pclouds@gmail.com> | 2019-01-12 09:13:24 +0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2019-01-14 12:13:04 -0800 |
commit | 3a95f31d1cdc93fa4f926c6537f84186edd85ca9 (patch) | |
tree | 102d6623808b54f676dcbde75b1ed28705358f60 /repository.c | |
parent | 1d18d7581cf1ce45314b7ed58e52d5cc73b2e7a7 (diff) | |
download | git-3a95f31d1cdc93fa4f926c6537f84186edd85ca9.tar.gz |
repository.c: replace hold_locked_index() with repo_hold_locked_index()
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 <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'repository.c')
-rw-r--r-- | repository.c | 10 |
1 files changed, 10 insertions, 0 deletions
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); +} |