diff --git a/Documentation/git-status.txt b/Documentation/git-status.txt index 81cab9aefb..f0173c1e3e 100644 --- a/Documentation/git-status.txt +++ b/Documentation/git-status.txt @@ -130,6 +130,13 @@ ignored, then the directory is not shown, but all contents are shown. without options are equivalent to 'always' and 'never' respectively. +--no-lock-index:: +--lock-index:: + (DEPRECATED: use --no-optional-locks instead) + Specifies whether `git status` should try to lock the index and + update it afterwards if any changes were detected. Defaults to + `--lock-index`. + ...:: See the 'pathspec' entry in linkgit:gitglossary[7]. diff --git a/builtin/commit.c b/builtin/commit.c index 0162085655..c521ce633f 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1354,6 +1354,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; @@ -1385,6 +1386,9 @@ 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_("(DEPRECATED: use `git --no-optional-locks status` " + "instead) Do not lock the index")), OPT_END(), }; @@ -1398,6 +1402,12 @@ int cmd_status(int argc, const char **argv, const char *prefix) finalize_colopts(&s.colopts, -1); finalize_deferred_config(&s); + if (no_lock_index) { + warning("--no-lock-index is deprecated, use --no-optional-locks" + " instead"); + setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1); + } + handle_untracked_files_arg(&s); handle_ignored_arg(&s); diff --git a/t/t7508-status.sh b/t/t7508-status.sh index 50052e2872..3941f7b095 100755 --- a/t/t7508-status.sh +++ b/t/t7508-status.sh @@ -1671,6 +1671,17 @@ test_expect_success '"Initial commit" should not be noted in commit template' ' test_i18ngrep ! "Initial commit" output ' +test_expect_success '--no-lock-index prevents index update and is deprecated' ' + test-chmtime =1234567890 .git/index && + git status --no-lock-index 2>err && + grep "no-lock-index is deprecated" err && + test-chmtime -v +0 .git/index >out && + grep ^1234567890 out && + git status && + test-chmtime -v +0 .git/index >out && + ! grep ^1234567890 out +' + test_expect_success '--no-optional-locks prevents index update' ' test-chmtime =1234567890 .git/index && git --no-optional-locks status &&