Skip to content

Commit 1b1fe47

Browse files
committed
require_clean_work_tree: ensure that the index was read
The function would otherwise pretend to work fine, but totally ignore the working directory. Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
1 parent 6f12736 commit 1b1fe47

1 file changed

Lines changed: 7 additions & 0 deletions

File tree

wt-status.c

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1778,6 +1778,13 @@ int require_clean_work_tree(const char *action, const char *hint, int gently)
17781778
struct lock_file *lock_file = xcalloc(1, sizeof(*lock_file));
17791779
int err = 0;
17801780

1781+
if (read_cache() < 0) {
1782+
error("Could not read index");
1783+
if (gently)
1784+
return -1;
1785+
exit(1);
1786+
}
1787+
17811788
hold_locked_index(lock_file, 0);
17821789
refresh_cache(REFRESH_QUIET);
17831790
update_index_if_able(&the_index, lock_file);

0 commit comments

Comments
 (0)