Skip to content

Commit 27e4153

Browse files
dschoGit for Windows Build Agent
authored andcommitted
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 <[email protected]>
2 parents b55f86d + 4915c54 commit 27e4153

File tree

3 files changed

+28
-0
lines changed

3 files changed

+28
-0
lines changed

Documentation/git-status.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -149,6 +149,13 @@ ignored, then the directory is not shown, but all contents are shown.
149149
threshold.
150150
See also linkgit:git-diff[1] `--find-renames`.
151151

152+
--no-lock-index::
153+
--lock-index::
154+
(DEPRECATED: use --no-optional-locks instead)
155+
Specifies whether `git status` should try to lock the index and
156+
update it afterwards if any changes were detected. Defaults to
157+
`--lock-index`.
158+
152159
<pathspec>...::
153160
See the 'pathspec' entry in linkgit:gitglossary[7].
154161

builtin/commit.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1351,6 +1351,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13511351
{
13521352
static int no_renames = -1;
13531353
static const char *rename_score_arg = (const char *)-1;
1354+
static int no_lock_index = 0;
13541355
static struct wt_status s;
13551356
unsigned int progress_flag = 0;
13561357
int fd;
@@ -1389,6 +1390,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13891390
{ OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg,
13901391
N_("n"), N_("detect renames, optionally set similarity index"),
13911392
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score },
1393+
OPT_BOOL(0, "no-lock-index", &no_lock_index,
1394+
N_("(DEPRECATED: use `git --no-optional-locks status` "
1395+
"instead) Do not lock the index")),
13921396
OPT_END(),
13931397
};
13941398

@@ -1402,6 +1406,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
14021406
finalize_colopts(&s.colopts, -1);
14031407
finalize_deferred_config(&s);
14041408

1409+
if (no_lock_index) {
1410+
warning("--no-lock-index is deprecated, use --no-optional-locks"
1411+
" instead");
1412+
setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1);
1413+
}
1414+
14051415
handle_untracked_files_arg(&s);
14061416
handle_ignored_arg(&s);
14071417

t/t7508-status.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1607,6 +1607,17 @@ test_expect_success '"Initial commit" should not be noted in commit template' '
16071607
test_i18ngrep ! "Initial commit" output
16081608
'
16091609

1610+
test_expect_success '--no-lock-index prevents index update and is deprecated' '
1611+
test-tool chmtime =1234567890 .git/index &&
1612+
git status --no-lock-index 2>err &&
1613+
grep "no-lock-index is deprecated" err &&
1614+
test-tool chmtime -v +0 .git/index >out &&
1615+
grep ^1234567890 out &&
1616+
git status &&
1617+
test-tool chmtime -v +0 .git/index >out &&
1618+
! grep ^1234567890 out
1619+
'
1620+
16101621
test_expect_success '--no-optional-locks prevents index update' '
16111622
test-tool chmtime =1234567890 .git/index &&
16121623
git --no-optional-locks status &&

0 commit comments

Comments
 (0)