Skip to content

Commit 0dc4a63

Browse files
committed
path-walk: fix setup of pending objects
The previous change established a buggy instance of 'git repack -adf --path-walk' when there exist paths that are tracked in the index and that is the only instance of those paths in the history of the repository. This change fixes that bug. The core problem here is that the "maybe_interesting" member of 'struct type_and_oid_list' is not initialized to '1'. This member was added in 6333e7a (path-walk: mark trees and blobs as UNINTERESTING, 2024-12-20) in a way to help when creating packfiles for a small commit range using the sparse path algorithm (enabled by pack.useSparse=true). The idea here is that the list is marked as "maybe_interesting" if an object is added that does not have the UNINITERSTING flag on it. Later, this is checked again in case all objects in the list were marked UNINTERESTING after that point in time. In this case, the algorithm skips the list as there is no reason to visit it. This leads to the problem where the "maybe_interesting" member was not appropriately initialized when the list is created from pending objects. This is the fix for now. To help avoid this from happening in the future, a follow-up change will make initializing lists use a shared method instead of allowing for an update to this initialization process to miss some existing copies. Signed-off-by: Derrick Stolee <[email protected]>
1 parent 5b19173 commit 0dc4a63

File tree

2 files changed

+3
-1
lines changed

2 files changed

+3
-1
lines changed

path-walk.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -385,6 +385,7 @@ static int setup_pending_objects(struct path_walk_info *info,
385385
list->type = OBJ_TREE;
386386
strmap_put(&ctx->paths_to_lists, path, list);
387387
}
388+
list->maybe_interesting = 1;
388389
oid_array_append(&list->oids, &obj->oid);
389390
free(path);
390391
} else {
@@ -404,6 +405,7 @@ static int setup_pending_objects(struct path_walk_info *info,
404405
list->type = OBJ_BLOB;
405406
strmap_put(&ctx->paths_to_lists, path, list);
406407
}
408+
list->maybe_interesting = 1;
407409
oid_array_append(&list->oids, &obj->oid);
408410
} else {
409411
/* assume a root tree, such as a lightweight tag. */

t/t7700-repack.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -838,7 +838,7 @@ test_expect_success '-n overrides repack.updateServerInfo=true' '
838838
test_server_info_missing
839839
'
840840

841-
test_expect_failure 'pending objects are repacked appropriately' '
841+
test_expect_success 'pending objects are repacked appropriately' '
842842
git init pending &&
843843
844844
(

0 commit comments

Comments
 (0)