wt-status: implement opportunisitc index update correctly
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>
This commit is contained in:
		| @ -2258,10 +2258,11 @@ 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); | ||||
| 	if (0 <= fd) | ||||
| 		update_index_if_able(&the_index, lock_file); | ||||
| 	rollback_lock_file(lock_file); | ||||
|  | ||||
|  | ||||
		Reference in New Issue
	
	Block a user
	 Junio C Hamano
					Junio C Hamano