Andrew's git
/
gitweb.git
/ diff
summary
|
log
|
commit
| diff |
tree
commit
grep
author
committer
pickaxe
?
re
wt-status: implement opportunisitc index update correctly
author
Junio C Hamano
<gitster@pobox.com>
Wed, 7 Dec 2016 19:11:26 +0000
(11:11 -0800)
committer
Junio C Hamano
<gitster@pobox.com>
Wed, 7 Dec 2016 19:31:58 +0000
(11:31 -0800)
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
patch
|
blob
|
history
raw
|
patch
|
inline
| side by side (from parent 1:
8d7a455
)
diff --git
a/wt-status.c
b/wt-status.c
index a2e9d332d8332bb1dbeea26b683c5e3f032a822e..a715e71906a9a2fbd62180dd017d140f68ad14a0 100644
(file)
--- 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 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);
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)) {
rollback_lock_file(lock_file);
if (has_unstaged_changes(ignore_submodules)) {