Skip to content

Commit 4553883

Browse files
committed
squash! status: offer *not* to lock the index and update it
This is a fix that should have gone into v2.15.0, but was forgotten in the last-minute rebasing frenzy. status: carry the --no-lock-index option for backwards-compatibility When a third-party tool periodically runs `git status` in order to keep track of the state of the working tree, it is a bad idea to lock the index: it might interfere with interactive commands executed by the user, e.g. when the user wants to commit files. Git for Windows introduced the `--no-lock-index` option a long time ago to fix that (it made it into Git for Windows v2.9.2(3)) by simply avoiding to write that file. The downside is that the periodic `git status` calls will be a little bit more wasteful because they may have to refresh the index repeatedly, only to throw away the updates when it exits. This cannot really be helped, though, as tools wanting to get a periodic update of the status have no way to predict when the user may want to lock the index herself. Sadly, a competing approach was submitted (by somebody who apparently has less work on their plate than this maintainer) that made it into v2.15.0 but is *different*: instead of a `git status`-only option, it is an option that comes *before* the Git command and is called differently, too. Let's give previous users a chance to upgrade to newer Git for Windows versions by handling the `--no-lock-index` option, still, though with a big fat warning. Signed-off-by: Johannes Schindelin <[email protected]>
1 parent 8de0b6e commit 4553883

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

builtin/commit.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1393,19 +1393,19 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13931393
if (argc == 2 && !strcmp(argv[1], "-h"))
13941394
usage_with_options(builtin_status_usage, builtin_status_options);
13951395

1396-
if (no_lock_index) {
1397-
warning("--no-lock-index is deprecated, use --no-optional-locks"
1398-
" instead");
1399-
setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1);
1400-
}
1401-
14021396
status_init_config(&s, git_status_config);
14031397
argc = parse_options(argc, argv, prefix,
14041398
builtin_status_options,
14051399
builtin_status_usage, 0);
14061400
finalize_colopts(&s.colopts, -1);
14071401
finalize_deferred_config(&s);
14081402

1403+
if (no_lock_index) {
1404+
warning("--no-lock-index is deprecated, use --no-optional-locks"
1405+
" instead");
1406+
setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1);
1407+
}
1408+
14091409
handle_untracked_files_arg(&s);
14101410
handle_ignored_arg(&s);
14111411

0 commit comments

Comments
 (0)