summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--wt-status.c7
1 files changed, 4 insertions, 3 deletions
diff --git a/wt-status.c b/wt-status.c
index a2e9d332d8..a715e71906 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -2258,11 +2258,12 @@ int has_uncommitted_changes(int ignore_submodules)
int require_clean_work_tree(const char *action, const char *hint, int ignore_submodules, int gently)
{
struct lock_file *lock_file = xcalloc(1, sizeof(*lock_file));
- int err = 0;
+ int err = 0, fd;
- hold_locked_index(lock_file, 0);
+ fd = hold_locked_index(lock_file, 0);
refresh_cache(REFRESH_QUIET);
- update_index_if_able(&the_index, lock_file);
+ if (0 <= fd)
+ update_index_if_able(&the_index, lock_file);
rollback_lock_file(lock_file);
if (has_unstaged_changes(ignore_submodules)) {