| 957 | }; |
| 958 | |
| 959 | static int check_has_commit(const struct object_id *oid, void *data) |
| 960 | { |
| 961 | struct has_commit_data *cb = data; |
| 962 | struct repository subrepo; |
| 963 | enum object_type type; |
| 964 | |
| 965 | if (repo_submodule_init(&subrepo, cb->repo, cb->path, cb->super_oid)) { |
| 966 | cb->result = 0; |
| 967 | /* subrepo failed to init, so don't clean it up. */ |
| 968 | return 0; |
| 969 | } |
| 970 | |
| 971 | type = odb_read_object_info(subrepo.objects, oid, NULL); |
| 972 | |
| 973 | switch (type) { |
| 974 | case OBJ_COMMIT: |
| 975 | goto cleanup; |
| 976 | case OBJ_BAD: |
| 977 | /* |
| 978 | * Object is missing or invalid. If invalid, an error message |
| 979 | * has already been printed. |
| 980 | */ |
| 981 | cb->result = 0; |
| 982 | goto cleanup; |
| 983 | default: |
| 984 | die(_("submodule entry '%s' (%s) is a %s, not a commit"), |
| 985 | cb->path, oid_to_hex(oid), type_name(type)); |
| 986 | } |
| 987 | cleanup: |
| 988 | repo_clear(&subrepo); |
| 989 | return 0; |
| 990 | } |
| 991 | |
| 992 | static int submodule_has_commits(struct repository *r, |
| 993 | const char *path, |
nothing calls this directly
no test coverage detected