mirror of
https://github.com/git/git.git
synced 2026-01-17 06:13:11 +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:
@@ -145,6 +145,13 @@ ignored, then the directory is not shown, but all contents are shown.
|
||||
threshold.
|
||||
See also linkgit:git-diff[1] `--find-renames`.
|
||||
|
||||
--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`.
|
||||
|
||||
<pathspec>...::
|
||||
See the 'pathspec' entry in linkgit:gitglossary[7].
|
||||
|
||||
|
||||
@@ -1304,6 +1304,7 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
{
|
||||
static int no_renames = -1;
|
||||
static const char *rename_score_arg = (const char *)-1;
|
||||
static int no_lock_index = 0;
|
||||
static struct wt_status s;
|
||||
unsigned int progress_flag = 0;
|
||||
int fd;
|
||||
@@ -1342,6 +1343,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
|
||||
{ OPTION_CALLBACK, 'M', "find-renames", &rename_score_arg,
|
||||
N_("n"), N_("detect renames, optionally set similarity index"),
|
||||
PARSE_OPT_OPTARG | PARSE_OPT_NONEG, opt_parse_rename_score },
|
||||
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(),
|
||||
};
|
||||
|
||||
@@ -1355,6 +1359,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);
|
||||
|
||||
|
||||
@@ -1669,6 +1669,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-tool chmtime =1234567890 .git/index &&
|
||||
git status --no-lock-index 2>err &&
|
||||
grep "no-lock-index is deprecated" err &&
|
||||
test-tool chmtime -v +0 .git/index >out &&
|
||||
grep ^1234567890 out &&
|
||||
git status &&
|
||||
test-tool chmtime -v +0 .git/index >out &&
|
||||
! grep ^1234567890 out
|
||||
'
|
||||
|
||||
test_expect_success '--no-optional-locks prevents index update' '
|
||||
test-tool chmtime =1234567890 .git/index &&
|
||||
git --no-optional-locks status &&
|
||||
|
||||
Reference in New Issue
Block a user