mirror of
https://github.com/git/git.git
synced 2026-01-23 09:01:15 +00:00
Merge branch 'status-no-lock-index'
This branch allows third-party tools to call `git status --no-lock-index` to avoid lock contention with the interactive Git usage of the actual human user. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This commit is contained in:
@@ -111,6 +111,11 @@ configuration variable documented in linkgit:git-config[1].
|
||||
without options are equivalent to 'always' and 'never'
|
||||
respectively.
|
||||
|
||||
--no-lock-index::
|
||||
--lock-index::
|
||||
Specifies whether `git status` should try to lock the index and
|
||||
update it afterwards if any changes were detected. Defaults to
|
||||
`--lock-index`.
|
||||
|
||||
OUTPUT
|
||||
------
|
||||
|
||||
@@ -1333,6 +1333,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
|
||||
|
||||
int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
static int no_lock_index = 0;
|
||||
static struct wt_status s;
|
||||
int fd;
|
||||
struct object_id oid;
|
||||
@@ -1362,6 +1363,8 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
N_("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)"),
|
||||
PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
|
||||
OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
|
||||
OPT_BOOL(0, "no-lock-index", &no_lock_index,
|
||||
N_("do not lock the index")),
|
||||
OPT_END(),
|
||||
};
|
||||
|
||||
@@ -1386,7 +1389,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
read_cache_preload(&s.pathspec);
|
||||
refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &s.pathspec, NULL, NULL);
|
||||
|
||||
fd = hold_locked_index(&index_lock, 0);
|
||||
fd = no_lock_index ? -1 : hold_locked_index(&index_lock, 0);
|
||||
|
||||
s.is_initial = get_sha1(s.reference, oid.hash) ? 1 : 0;
|
||||
if (!s.is_initial)
|
||||
|
||||
@@ -1670,4 +1670,15 @@ test_expect_success '"Initial commit" should not be noted in commit template' '
|
||||
test_i18ngrep ! "Initial commit" output
|
||||
'
|
||||
|
||||
test_expect_success '--no-lock-index' '
|
||||
test_commit some-file &&
|
||||
test-chmtime =1234567890 .git/index &&
|
||||
git status --no-lock-index &&
|
||||
test-chmtime -v +0 .git/index >out &&
|
||||
grep ^1234567890 out &&
|
||||
git status &&
|
||||
test-chmtime -v +0 .git/index >out &&
|
||||
! grep ^1234567890 out
|
||||
'
|
||||
|
||||
test_done
|
||||
|
||||
Reference in New Issue
Block a user