| 1213 | } |
| 1214 | |
| 1215 | static void import_marks(char *input_file, int check_exists) |
| 1216 | { |
| 1217 | char line[512]; |
| 1218 | FILE *f; |
| 1219 | struct stat sb; |
| 1220 | |
| 1221 | if (check_exists && stat(input_file, &sb)) |
| 1222 | return; |
| 1223 | |
| 1224 | f = xfopen(input_file, "r"); |
| 1225 | while (fgets(line, sizeof(line), f)) { |
| 1226 | uint32_t mark; |
| 1227 | char *line_end, *mark_end; |
| 1228 | struct object_id oid; |
| 1229 | struct object *object; |
| 1230 | struct commit *commit; |
| 1231 | enum object_type type; |
| 1232 | |
| 1233 | line_end = strchr(line, '\n'); |
| 1234 | if (line[0] != ':' || !line_end) |
| 1235 | die(_("corrupt mark line: %s"), line); |
| 1236 | *line_end = '\0'; |
| 1237 | |
| 1238 | mark = strtoumax(line + 1, &mark_end, 10); |
| 1239 | if (!mark || mark_end == line + 1 |
| 1240 | || *mark_end != ' ' || get_oid_hex(mark_end + 1, &oid)) |
| 1241 | die(_("corrupt mark line: %s"), line); |
| 1242 | |
| 1243 | if (last_idnum < mark) |
| 1244 | last_idnum = mark; |
| 1245 | |
| 1246 | type = odb_read_object_info(the_repository->objects, &oid, NULL); |
| 1247 | if (type < 0) |
| 1248 | die(_("object not found: %s"), oid_to_hex(&oid)); |
| 1249 | |
| 1250 | if (type != OBJ_COMMIT) |
| 1251 | /* only commits */ |
| 1252 | continue; |
| 1253 | |
| 1254 | commit = lookup_commit(the_repository, &oid); |
| 1255 | if (!commit) |
| 1256 | die(_("not a commit? can't happen: %s"), oid_to_hex(&oid)); |
| 1257 | |
| 1258 | object = &commit->object; |
| 1259 | |
| 1260 | if (object->flags & SHOWN) |
| 1261 | error(_("object %s already has a mark"), oid_to_hex(&oid)); |
| 1262 | |
| 1263 | mark_object(object, mark); |
| 1264 | |
| 1265 | object->flags |= SHOWN; |
| 1266 | } |
| 1267 | fclose(f); |
| 1268 | } |
| 1269 | |
| 1270 | static void handle_deletes(void) |
| 1271 | { |
no test coverage detected