Skip to content

Commit 79619a9

Browse files
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 681b3b9 + fadb2ac commit 79619a9

File tree

2 files changed

+16
-0
lines changed

2 files changed

+16
-0
lines changed

Documentation/git-status.txt

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,6 +111,13 @@ configuration variable documented in linkgit:git-config[1].
111111
without options are equivalent to 'always' and 'never'
112112
respectively.
113113

114+
--no-lock-index::
115+
--lock-index::
116+
(DEPRECATED: use --no-optional-locks instead)
117+
Specifies whether `git status` should try to lock the index and
118+
update it afterwards if any changes were detected. Defaults to
119+
`--lock-index`.
120+
114121
<pathspec>...::
115122
See the 'pathspec' entry in linkgit:gitglossary[7].
116123

builtin/commit.c

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1340,6 +1340,7 @@ static int git_status_config(const char *k, const char *v, void *cb)
13401340

13411341
int cmd_status(int argc, const char **argv, const char *prefix)
13421342
{
1343+
static int no_lock_index = 0;
13431344
static struct wt_status s;
13441345
int fd;
13451346
struct object_id oid;
@@ -1369,12 +1370,20 @@ int cmd_status(int argc, const char **argv, const char *prefix)
13691370
N_("ignore changes to submodules, optional when: all, dirty, untracked. (Default: all)"),
13701371
PARSE_OPT_OPTARG, NULL, (intptr_t)"all" },
13711372
OPT_COLUMN(0, "column", &s.colopts, N_("list untracked files in columns")),
1373+
OPT_BOOL(0, "no-lock-index", &no_lock_index,
1374+
N_("do not lock the index")),
13721375
OPT_END(),
13731376
};
13741377

13751378
if (argc == 2 && !strcmp(argv[1], "-h"))
13761379
usage_with_options(builtin_status_usage, builtin_status_options);
13771380

1381+
if (no_lock_index) {
1382+
warning("--no-lock-index is deprecated, use --no-optional-locks"
1383+
" instead");
1384+
setenv(GIT_OPTIONAL_LOCKS_ENVIRONMENT, "false", 1);
1385+
}
1386+
13781387
status_init_config(&s, git_status_config);
13791388
argc = parse_options(argc, argv, prefix,
13801389
builtin_status_options,

0 commit comments

Comments
 (0)