Skip to content

Commit 1c4ad23

Browse files
dschoGit for Windows Build Agent
authored and
Git for Windows Build Agent
committed
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 3d5e9c6 + 274eb91 commit 1c4ad23

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
@@ -145,6 +145,13 @@ ignored, then the directory is not shown, but all contents are shown.
145145
threshold.
146146
See also linkgit:git-diff[1] `--find-renames`.
147147

148+
--no-lock-index::
149+
--lock-index::
150+
(DEPRECATED: use --no-optional-locks instead)
151+
Specifies whether `git status` should try to lock the index and
152+
update it afterwards if any changes were detected. Defaults to
153+
`--lock-index`.
154+
148155
<pathspec>...::
149156
See the 'pathspec' entry in linkgit:gitglossary[7].
150157

builtin/commit.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1302,6 +1302,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13021302
{
13031303
static int no_renames = -1;
13041304
static const char *rename_score_arg = (const char *)-1;
1305+
static int no_lock_index = 0;
13051306
static struct wt_status s;
13061307
unsigned int progress_flag = 0;
13071308
int fd;
@@ -1340,6 +1341,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13401341
{ OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg,
13411342
N_("n"), N_("detect renames, optionally set similarity index"),
13421343
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score },
1344+
OPT_BOOL(0, "no-lock-index", &no_lock_index,
1345+
N_("(DEPRECATED: use `git --no-optional-locks status` "
1346+
"instead) Do not lock the index")),
13431347
OPT_END(),
13441348
};
13451349

@@ -1353,6 +1357,12 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13531357
finalize_colopts(&s.colopts, -1);
13541358
finalize_deferred_config(&s);
13551359

1360+
if (no_lock_index) {
1361+
warning("--no-lock-index is deprecated, use --no-optional-locks"
1362+
" instead");
1363+
setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1);
1364+
}
1365+
13561366
handle_untracked_files_arg(&s);
13571367
handle_ignored_arg(&s);
13581368

t/t7508-status.sh

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

1672+
test_expect_success '--no-lock-index prevents index update and is deprecated' '
1673+
test-tool chmtime =1234567890 .git/index &&
1674+
git status --no-lock-index 2>err &&
1675+
grep "no-lock-index is deprecated" err &&
1676+
test-tool chmtime -v +0 .git/index >out &&
1677+
grep ^1234567890 out &&
1678+
git status &&
1679+
test-tool chmtime -v +0 .git/index >out &&
1680+
! grep ^1234567890 out
1681+
'
1682+
16721683
test_expect_success '--no-optional-locks prevents index update' '
16731684
test-tool chmtime =1234567890 .git/index &&
16741685
git --no-optional-locks status &&

0 commit comments

Comments
 (0)