Commit Diff


commit - 5cc266baadfb13464b72e1ccbec0462eb641f0b6
commit + e1ed7f77442c0693e02984d550e3cc674e3c0dc0
blob - dbe625f9575b42c5baeca2ec33f1d9a00b3d6b52
blob + 05a75f232076b90a968af03806db100560885424
--- lib/fileindex.c
+++ lib/fileindex.c
@@ -121,14 +121,14 @@ got_fileindex_entry_get(struct got_fileindex *fileinde
 }
 
 const struct got_error *
-got_fileindex_for_each_entry(struct got_fileindex *fileindex,
+got_fileindex_for_each_entry_safe(struct got_fileindex *fileindex,
     const struct got_error *(cb)(void *, struct got_fileindex_entry *),
     void *cb_arg)
 {
 	const struct got_error *err = NULL;
-	struct got_fileindex_entry *entry;
+	struct got_fileindex_entry *entry, *tmp;
 
-	TAILQ_FOREACH(entry, &fileindex->entries, entry) {
+	TAILQ_FOREACH_SAFE(entry, &fileindex->entries, entry, tmp) {
 		err = cb(cb_arg, entry);
 		if (err)
 			break;
blob - f93174f7e634e06da5a522e80f1baba31dcca4e0
blob + 327aba8462b861055c62b7528aebd302317f75d2
--- lib/got_lib_fileindex.h
+++ lib/got_lib_fileindex.h
@@ -100,5 +100,6 @@ void got_fileindex_entry_remove(struct got_fileindex *
 struct got_fileindex_entry *got_fileindex_entry_get(struct got_fileindex *,
     const char *);
 const struct got_error *got_fileindex_read(struct got_fileindex *, FILE *);
-const struct got_error *got_fileindex_for_each_entry(struct got_fileindex *,
+const struct got_error *got_fileindex_for_each_entry_safe(
+    struct got_fileindex *,
     const struct got_error *(cb)(void *, struct got_fileindex_entry *), void *);
blob - 68c4f29cd8883e493adf2db836518b1f1a28d4af
blob + e43e15f1fb069fc763545860dc8cdbbdb516522a
--- lib/worktree.c
+++ lib/worktree.c
@@ -800,7 +800,8 @@ remove_missing_files(struct got_worktree *worktree, co
 	a.missing_entries.nentries = 0;
 	a.current_subdir = apply_path_prefix(worktree, path);
 	TAILQ_INIT(&a.missing_entries.entries);
-	err = got_fileindex_for_each_entry(fileindex, collect_missing_file, &a);
+	err = got_fileindex_for_each_entry_safe(fileindex,
+	    collect_missing_file, &a);
 	if (err)
 		return err;