git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: git@vger.kernel.org
Cc: Paul Tan <pyokagan@gmail.com>
Subject: [PATCH 1/3] wt-status: implement opportunisitc index update correctly
Date: Wed,  7 Dec 2016 11:41:03 -0800	[thread overview]
Message-ID: <20161207194105.25780-2-gitster@pobox.com> (raw)
In-Reply-To: <20161207194105.25780-1-gitster@pobox.com>

The require_clean_work_tree() function calls hold_locked_index()
with die_on_error=0 to signal that it is OK if it fails to obtain
the lock, but unconditionally calls update_index_if_able(), which
will try to write into fd=-1.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
 wt-status.c | 7 ++++---
 1 file 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)) {
-- 
2.11.0-274-g0631465056


  reply	other threads:[~2016-12-07 19:41 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2016-12-03  1:44 [BUG] Index.lock error message regression in git 2.11.0 Robbie Iannucci
2016-12-03  1:52 ` Robbie Iannucci
2016-12-06 21:56 ` Junio C Hamano
2016-12-06 22:15   ` Re* " Junio C Hamano
2016-12-07 18:21     ` Junio C Hamano
2016-12-07 19:41       ` [PATCH 0/3] Do not be totally silent upon lock error Junio C Hamano
2016-12-07 19:41         ` Junio C Hamano [this message]
2016-12-07 20:48           ` [PATCH 1/3] wt-status: implement opportunisitc index update correctly Stefan Beller
2016-12-07 20:53             ` Junio C Hamano
2016-12-07 20:56               ` Stefan Beller
2016-12-07 21:08             ` Junio C Hamano
2016-12-07 22:06               ` Stefan Beller
2016-12-08 10:18             ` Paul Tan
2016-12-08 18:01               ` Junio C Hamano
2016-12-07 19:41         ` [PATCH 2/3] hold_locked_index(): align error handling with hold_lockfile_for_update() Junio C Hamano
2016-12-07 19:41         ` [PATCH 3/3] lockfile: LOCK_REPORT_ON_ERROR Junio C Hamano
2016-12-08 11:53           ` Johannes Schindelin
2016-12-08 18:10             ` Robbie Iannucci
2016-12-08 18:22             ` Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20161207194105.25780-2-gitster@pobox.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=pyokagan@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).