back out mini-commits; no significant performance difference
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 780 781 782 783 784 785 786 787 788 789 790 791 792 793 794 795 796 797 798 799 800 801 802 803 804 805 806 807 808 809 810 811 812 813 814 815 816 817 818 819 820 821 822 823 824 825 826 827 828 829 830 831 832 833 834 835 836 837 838 839 840 841 842 843 844 845 846 847 848 849 850 851 852 853 854 855 856 857 858 859 860 861 862 863 864 865 866 867 868 869 870 871 872 873 874 875 876 877 878 879 880 881 882 883 884 885 886 887 888 889 890 891 892 893 894 895 896 897 898 899 900 901 902 903 904 905 906 907 908 909 910 911 912 913 914 915 916 917 918 919 920 921 922 923 924 925 926 927 928 929 930 931 932 933 934 935 936 937 938 939 940 941 942 943 944 945 946 947 948 949 950 951 952 953 954 955 956 957 958 959 960 961 962 963 964 965 966 967 968 969 970 971 972 973 974 975 976 977 978 979 980 981 982 983 984 985 986 987 988 989 990 991 992 993 994 995 996 997 998 999 1000 1001 1002 1003 1004 1005 1006 1007 1008 1009 1010 1011 1012 1013 1014 1015 1016 1017 1018 1019 1020 1021 1022 1023 1024 1025 1026 1027 1028 1029 1030 1031 1032 1033 1034 1035 1036 1037 1038 1039 1040 1041 1042 1043 1044 1045 1046 1047 1048 1049 1050 1051 1052 1053 1054 1055 1056 1057 1058 1059 1060 1061 1062 1063 1064 1065 1066 1067 1068 1069 1070 1071 1072 1073 1074 1075 1076 1077 1078 1079 1080 1081 1082 1083 1084 1085 1086 1087 1088 1089 1090 1091 1092 1093 1094 1095 1096 1097 1098 1099 1100 1101 1102 1103 1104 1105 1106 1107 1108 1109 1110 1111 1112 1113 1114 1115 1116 1117 1118 1119 1120 1121 1122 1123 1124 1125 1126 1127 1128 1129 1130 1131 1132 1133 1134 1135 1136 1137 1138 1139 1140 1141 1142 1143 1144 1145 1146 1147 1148 1149 1150 1151 1152 1153 1154 1155 1156 1157 1158 1159 1160 1161 1162 1163 1164 1165 1166 1167 1168 1169 1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 1282 1283 1284 1285 1286 1287 1288 1289 1290 1291 1292 1293 1294 1295 1296 1297 1298 1299 1300 1301 1302 1303 1304 1305 1306 1307 1308 1309 1310 1311 1312 1313 1314 1315 1316 1317 1318 1319 1320 1321 1322 1323 1324 1325 1326 1327 1328 1329 1330 1331 1332 1333 1334 1335 1336 1337 1338 1339 1340 1341 1342 1343 1344 1345 1346 1347 1348 1349 1350 1351 1352 1353 1354 1355 1356 1357 1358 1359 1360 1361 1362 1363 1364 1365 1366 1367 1368 1369 1370 1371 1372 1373 1374 1375 1376 1377 1378 1379 1380 1381 1382 1383 1384 1385 1386 1387 1388 1389 1390 1391 1392 1393 1394 1395 1396 1397 1398 1399 1400 1401 1402 1403 1404 1405 1406 1407 1408 1409 1410 1411 1412 1413 1414 1415 1416 1417 1418 1419 1420 1421 1422 1423 1424 1425 1426 1427 1428 1429 1430 1431 1432 1433 1434 1435 1436 1437 1438 1439 1440 1441 1442 1443 1444 1445 1446 1447 1448 1449 1450 1451 1452 1453 1454 1455 1456 1457 1458 1459 1460 1461
diff --git a/lib/commit_graph.c b/lib/commit_graph.c
index 1356457..d0e80bc 100644
--- a/lib/commit_graph.c
+++ b/lib/commit_graph.c
@@ -163,12 +163,12 @@ is_merge_point(struct got_commit_graph_node *node)
}
static const struct got_error *
-detect_changed_path(int *changed, struct got_mini_commit_object *commit,
+detect_changed_path(int *changed, struct got_commit_object *commit,
struct got_object_id *commit_id, const char *path,
struct got_repository *repo)
{
const struct got_error *err = NULL;
- struct got_mini_commit_object *pcommit = NULL;
+ struct got_commit_object *pcommit = NULL;
struct got_tree_object *tree = NULL, *ptree = NULL;
struct got_object_qid *pid;
@@ -194,7 +194,7 @@ detect_changed_path(int *changed, struct got_mini_commit_object *commit,
*changed = 1; /* The path was created in this commit. */
free(obj_id);
} else {
- err = got_object_open_as_mini_commit(&pcommit, repo, pid->id);
+ err = got_object_open_as_commit(&pcommit, repo, pid->id);
if (err)
goto done;
@@ -211,7 +211,7 @@ done:
if (ptree)
got_object_tree_close(ptree);
if (pcommit)
- got_object_mini_commit_close(pcommit);
+ got_object_commit_close(pcommit);
return err;
}
@@ -275,7 +275,7 @@ close_branch(struct got_commit_graph *graph, struct got_object_id *commit_id)
static const struct got_error *
advance_branch(struct got_commit_graph *graph,
struct got_commit_graph_node *node,
- struct got_object_id *commit_id, struct got_mini_commit_object *commit,
+ struct got_object_id *commit_id, struct got_commit_object *commit,
struct got_repository *repo)
{
const struct got_error *err;
@@ -382,8 +382,8 @@ free_node(struct got_commit_graph_node *node)
static const struct got_error *
add_node(struct got_commit_graph_node **new_node,
struct got_commit_graph *graph, struct got_object_id *commit_id,
- struct got_mini_commit_object *commit,
- struct got_commit_graph_node *child_node, struct got_repository *repo)
+ struct got_commit_object *commit, struct got_commit_graph_node *child_node,
+ struct got_repository *repo)
{
const struct got_error *err = NULL;
struct got_commit_graph_node *node;
@@ -456,11 +456,11 @@ got_commit_graph_open(struct got_commit_graph **graph,
int first_parent_traversal, struct got_repository *repo)
{
const struct got_error *err = NULL;
- struct got_mini_commit_object *commit;
+ struct got_commit_object *commit;
*graph = NULL;
- err = got_object_open_as_mini_commit(&commit, repo, commit_id);
+ err = got_object_open_as_commit(&commit, repo, commit_id);
if (err)
return err;
@@ -475,7 +475,7 @@ got_commit_graph_open(struct got_commit_graph **graph,
*graph = alloc_graph(path);
if (*graph == NULL) {
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
return got_error_from_errno();
}
@@ -484,7 +484,7 @@ got_commit_graph_open(struct got_commit_graph **graph,
err = add_node(&(*graph)->head_node, *graph, commit_id, commit, NULL,
repo);
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
if (err) {
got_commit_graph_close(*graph);
*graph = NULL;
@@ -547,20 +547,20 @@ fetch_commits_from_open_branches(int *ncommits,
for (i = 0; i < arg.ntips; i++) {
struct got_object_id *commit_id;
struct got_commit_graph_node *child_node, *new_node;
- struct got_mini_commit_object *commit;
+ struct got_commit_object *commit;
int changed;
commit_id = &graph->tips[i].id;
child_node = graph->tips[i].node;
- err = got_object_open_as_mini_commit(&commit, repo, commit_id);
+ err = got_object_open_as_commit(&commit, repo, commit_id);
if (err)
break;
err = detect_changed_path(&changed, commit, commit_id,
graph->path, repo);
if (err) {
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
if (err->code != GOT_ERR_NO_OBJ)
break;
err = close_branch(graph, commit_id);
@@ -572,7 +572,7 @@ fetch_commits_from_open_branches(int *ncommits,
*changed_id = commit_id;
err = add_node(&new_node, graph, commit_id, commit, child_node,
repo);
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
if (err)
break;
if (new_node)
@@ -628,21 +628,21 @@ got_commit_graph_iter_start(struct got_commit_graph *graph,
{
const struct got_error *err = NULL;
struct got_commit_graph_node *start_node;
- struct got_mini_commit_object *commit;
+ struct got_commit_object *commit;
int changed;
start_node = got_object_idset_get(graph->node_ids, id);
if (start_node == NULL)
return got_error(GOT_ERR_NO_OBJ);
- err = got_object_open_as_mini_commit(&commit, repo, &start_node->id);
+ err = got_object_open_as_commit(&commit, repo, &start_node->id);
if (err)
return err;
err = detect_changed_path(&changed, commit, &start_node->id,
graph->path, repo);
if (err) {
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
return err;
}
@@ -654,13 +654,13 @@ got_commit_graph_iter_start(struct got_commit_graph *graph,
err = fetch_commits_from_open_branches(&ncommits,
&changed_id, graph, repo);
if (err) {
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
return err;
}
}
start_node = got_object_idset_get(graph->node_ids, changed_id);
}
- got_object_mini_commit_close(commit);
+ got_object_commit_close(commit);
graph->iter_node = start_node;
return NULL;
diff --git a/lib/got_lib_object.h b/lib/got_lib_object.h
index fe430ca..fc8b2ee 100644
--- a/lib/got_lib_object.h
+++ b/lib/got_lib_object.h
@@ -48,20 +48,3 @@ struct got_blob_object {
uint8_t *read_buf;
struct got_object_id id;
};
-
-/* Small version of got_commit_object. Used by commit graph. */
-struct got_mini_commit_object {
- struct got_object_id *tree_id;
- unsigned int nparents;
- struct got_object_id_queue parent_ids;
- struct tm tm_committer; /* UTC */
- int refcnt; /* > 0 if open and/or cached */
-};
-
-const struct got_error *
-got_object_mini_commit_open(struct got_mini_commit_object **,
- struct got_repository *, struct got_object *);
-void got_object_mini_commit_close(struct got_mini_commit_object *);
-const struct got_error *got_object_open_as_mini_commit(
- struct got_mini_commit_object **, struct got_repository *,
- struct got_object_id *);
diff --git a/lib/got_lib_object_cache.h b/lib/got_lib_object_cache.h
index f54f072..d574268 100644
--- a/lib/got_lib_object_cache.h
+++ b/lib/got_lib_object_cache.h
@@ -18,7 +18,6 @@ enum got_object_cache_type {
GOT_OBJECT_CACHE_TYPE_OBJ,
GOT_OBJECT_CACHE_TYPE_TREE,
GOT_OBJECT_CACHE_TYPE_COMMIT,
- GOT_OBJECT_CACHE_TYPE_MINI_COMMIT,
};
struct got_object_cache_entry {
@@ -27,7 +26,6 @@ struct got_object_cache_entry {
struct got_object *obj;
struct got_tree_object *tree;
struct got_commit_object *commit;
- struct got_mini_commit_object *mini_commit;
} data;
};
diff --git a/lib/got_lib_object_parse.h b/lib/got_lib_object_parse.h
index 45ef92b..b427544 100644
--- a/lib/got_lib_object_parse.h
+++ b/lib/got_lib_object_parse.h
@@ -14,11 +14,7 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
-const struct got_error *got_object_qid_alloc_partial(struct got_object_qid **);
struct got_commit_object *got_object_commit_alloc_partial(void);
-struct got_mini_commit_object *got_object_mini_commit_alloc_partial(void);
-const struct got_error *got_object_commit_add_parent(struct got_commit_object *,
- const char *);
struct got_tree_entry *got_alloc_tree_entry_partial(void);
const struct got_error *got_object_read_header_privsep(struct got_object**,
struct got_repository *repo, int);
@@ -27,16 +23,11 @@ const struct got_error *got_object_read_blob_privsep(size_t *, int, int,
const struct got_error *got_object_read_commit_privsep(
struct got_commit_object **, struct got_object *, int,
struct got_repository *);
-const struct got_error *got_object_read_mini_commit_privsep(
- struct got_mini_commit_object **, struct got_object *, int,
- struct got_repository *);
const struct got_error *got_object_read_tree_privsep(struct got_tree_object **,
struct got_object *, int, struct got_repository *);
const struct got_error *got_object_parse_commit(struct got_commit_object **,
char *, size_t);
-const struct got_error *got_object_parse_mini_commit(
- struct got_mini_commit_object **, char *, size_t);
const struct got_error *got_object_parse_tree(struct got_tree_object **,
uint8_t *, size_t);
const struct got_error *got_read_file_to_mem(uint8_t **, size_t *, FILE *);
@@ -51,8 +42,5 @@ const struct got_error *got_object_packed_read_privsep(struct got_object **,
struct got_object_id *);
const struct got_error *got_object_read_packed_commit_privsep(
struct got_commit_object **, struct got_object *, struct got_pack *);
-const struct got_error *got_object_read_packed_mini_commit_privsep(
- struct got_mini_commit_object **, struct got_object *, struct got_pack *,
- struct got_repository *);
const struct got_error *got_object_read_packed_tree_privsep(
struct got_tree_object **, struct got_object *, struct got_pack *);
diff --git a/lib/got_lib_privsep.h b/lib/got_lib_privsep.h
index 4a84a70..b39f11f 100644
--- a/lib/got_lib_privsep.h
+++ b/lib/got_lib_privsep.h
@@ -82,8 +82,6 @@ enum got_imsg_type {
GOT_IMSG_COMMIT_REQUEST,
GOT_IMSG_COMMIT,
GOT_IMSG_COMMIT_LOGMSG,
- GOT_IMSG_MINI_COMMIT_REQUEST,
- GOT_IMSG_MINI_COMMIT,
GOT_IMSG_TREE_REQUEST,
GOT_IMSG_TREE,
GOT_IMSG_TREE_ENTRY,
@@ -144,21 +142,6 @@ struct got_imsg_commit_object {
*/
} __attribute__((__packed__));
-/* Structure for GOT_IMSG_MINI_COMMIT data. */
-struct got_imsg_commit_object_mini {
- uint8_t tree_id[SHA1_DIGEST_LENGTH];
- struct tm tm_committer;
- int nparents;
-
- /*
- * Set if this commit is a parent of the requested commit.
- * Allows got-read-pack to seed the main process mini-commit cache.
- */
- int is_parent;
- uint8_t parent_id[SHA1_DIGEST_LENGTH];
-
- /* Followed by 'nparents' SHA1_DIGEST_LENGTH length strings */
-} __attribute__((__packed__));
/* Structure for GOT_IMSG_TREE_ENTRY. */
struct got_imsg_tree_entry {
@@ -219,13 +202,8 @@ const struct got_error *got_privsep_recv_obj(struct got_object **,
struct imsgbuf *);
const struct got_error *got_privsep_send_commit(struct imsgbuf *,
struct got_commit_object *);
-const struct got_error *got_privsep_send_mini_commit(struct imsgbuf *,
- struct got_mini_commit_object *, struct got_object_id *);
const struct got_error *got_privsep_recv_commit(struct got_commit_object **,
struct imsgbuf *);
-const struct got_error *got_privsep_recv_mini_commit(
- struct got_mini_commit_object **, struct got_object_id **,
- struct imsgbuf *);
const struct got_error *got_privsep_recv_tree(struct got_tree_object **,
struct imsgbuf *);
const struct got_error *got_privsep_send_tree(struct imsgbuf *,
@@ -236,5 +214,4 @@ const struct got_error *got_privsep_init_pack_child(struct imsgbuf *,
struct got_pack *, struct got_packidx *);
const struct got_error *got_privsep_send_packed_obj_req(struct imsgbuf *, int,
struct got_object_id *);
-const struct got_error *got_privsep_send_mini_commit_req(struct imsgbuf *, int,
- struct got_object *);
+const struct got_error *got_privsep_send_pack_child_ready(struct imsgbuf *);
diff --git a/lib/got_lib_repository.h b/lib/got_lib_repository.h
index 5211dc1..feabca1 100644
--- a/lib/got_lib_repository.h
+++ b/lib/got_lib_repository.h
@@ -38,7 +38,6 @@ struct got_repository {
struct got_object_cache objcache;
struct got_object_cache treecache;
struct got_object_cache commitcache;
- struct got_object_cache minicommitcache;
};
const struct got_error*got_repo_cache_object(struct got_repository *,
@@ -53,10 +52,6 @@ const struct got_error*got_repo_cache_commit(struct got_repository *,
struct got_object_id *, struct got_commit_object *);
struct got_commit_object *got_repo_get_cached_commit(struct got_repository *,
struct got_object_id *);
-const struct got_error*got_repo_cache_mini_commit(struct got_repository *,
- struct got_object_id *, struct got_mini_commit_object *);
-struct got_mini_commit_object *got_repo_get_cached_mini_commit(
- struct got_repository *, struct got_object_id *);
const struct got_error *got_repo_cache_packidx(struct got_repository *,
struct got_packidx *);
const struct got_error *got_repo_search_packidx(struct got_packidx **, int *,
diff --git a/lib/object.c b/lib/object.c
index 959246b..c58c241 100644
--- a/lib/object.c
+++ b/lib/object.c
@@ -350,87 +350,6 @@ got_object_commit_open(struct got_commit_object **commit,
return open_commit(commit, repo, obj, 1);
}
-static const struct got_error *
-open_mini_commit(struct got_mini_commit_object **commit,
- struct got_repository *repo, struct got_object *obj, int check_cache)
-{
- const struct got_error *err = NULL;
-
- if (check_cache) {
- *commit = got_repo_get_cached_mini_commit(repo, &obj->id);
- if (*commit != NULL) {
- (*commit)->refcnt++;
- return NULL;
- }
- } else
- *commit = NULL;
-
- if (obj->type != GOT_OBJ_TYPE_COMMIT)
- return got_error(GOT_ERR_OBJ_TYPE);
-
- if (obj->flags & GOT_OBJ_FLAG_PACKED) {
- struct got_pack *pack;
- pack = got_repo_get_cached_pack(repo, obj->path_packfile);
- if (pack == NULL) {
- err = got_repo_cache_pack(&pack, repo,
- obj->path_packfile, NULL);
- if (err)
- return err;
- }
- err = got_object_read_packed_mini_commit_privsep(commit, obj,
- pack, repo);
- } else {
- int fd;
- err = open_loose_object(&fd, obj, repo);
- if (err)
- return err;
- err = got_object_read_mini_commit_privsep(commit, obj, fd,
- repo);
- close(fd);
- }
-
- if (err == NULL) {
- (*commit)->refcnt++;
- err = got_repo_cache_mini_commit(repo, &obj->id, *commit);
- }
-
- return err;
-}
-
-const struct got_error *
-got_object_open_as_mini_commit(struct got_mini_commit_object **commit,
- struct got_repository *repo, struct got_object_id *id)
-{
- const struct got_error *err;
- struct got_object *obj;
-
- *commit = got_repo_get_cached_mini_commit(repo, id);
- if (*commit != NULL) {
- (*commit)->refcnt++;
- return NULL;
- }
-
- err = got_object_open(&obj, repo, id);
- if (err)
- return err;
- if (got_object_get_type(obj) != GOT_OBJ_TYPE_COMMIT) {
- err = got_error(GOT_ERR_OBJ_TYPE);
- goto done;
- }
-
- err = open_mini_commit(commit, repo, obj, 0);
-done:
- got_object_close(obj);
- return err;
-}
-
-const struct got_error *
-got_object_mini_commit_open(struct got_mini_commit_object **commit,
- struct got_repository *repo, struct got_object *obj)
-{
- return open_mini_commit(commit, repo, obj, 1);
-}
-
const struct got_error *
got_object_qid_alloc(struct got_object_qid **qid, struct got_object_id *id)
{
@@ -1155,6 +1074,7 @@ done:
return err;
}
+
static const struct got_error *
request_commit(struct got_commit_object **commit, struct got_repository *repo,
struct got_object *obj, int fd)
@@ -1171,21 +1091,6 @@ request_commit(struct got_commit_object **commit, struct got_repository *repo,
return got_privsep_recv_commit(commit, ibuf);
}
-static const struct got_error *
-request_mini_commit(struct got_mini_commit_object **commit,
- struct got_repository *repo, struct got_object *obj, int fd)
-{
- const struct got_error *err = NULL;
- struct imsgbuf *ibuf;
-
- ibuf = repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].ibuf;
- err = got_privsep_send_mini_commit_req(ibuf, fd, obj);
- if (err)
- return err;
-
- return got_privsep_recv_mini_commit(commit, NULL, ibuf);
-}
-
const struct got_error *
got_object_read_packed_commit_privsep(struct got_commit_object **commit,
struct got_object *obj, struct got_pack *pack)
@@ -1200,35 +1105,6 @@ got_object_read_packed_commit_privsep(struct got_commit_object **commit,
}
const struct got_error *
-got_object_read_packed_mini_commit_privsep(
- struct got_mini_commit_object **commit, struct got_object *obj,
- struct got_pack *pack, struct got_repository *repo)
-{
- const struct got_error *err = NULL;
- struct got_object_id *pid = NULL;
-
- err = got_privsep_send_mini_commit_req(pack->privsep_child->ibuf, -1,
- obj);
- if (err)
- return err;
-
- while (1) {
- err = got_privsep_recv_mini_commit(commit, &pid,
- pack->privsep_child->ibuf);
- if (err || pid == NULL)
- break;
-
- /* got-read-pack has sent a parent commit; cache it. */
- err = got_repo_cache_mini_commit(repo, pid, *commit);
- free(pid);
- if (err)
- break;
- }
-
- return err;
-}
-
-const struct got_error *
got_object_read_commit_privsep(struct got_commit_object **commit,
struct got_object *obj, int obj_fd, struct got_repository *repo)
{
@@ -1265,43 +1141,6 @@ got_object_read_commit_privsep(struct got_commit_object **commit,
return request_commit(commit, repo, obj, obj_fd);
}
-const struct got_error *
-got_object_read_mini_commit_privsep(struct got_mini_commit_object **commit,
- struct got_object *obj, int obj_fd, struct got_repository *repo)
-{
- int imsg_fds[2];
- pid_t pid;
- struct imsgbuf *ibuf;
-
- if (repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd != -1)
- return request_mini_commit(commit, repo, obj, obj_fd);
-
- ibuf = calloc(1, sizeof(*ibuf));
- if (ibuf == NULL)
- return got_error_from_errno();
-
- if (socketpair(AF_UNIX, SOCK_STREAM, PF_UNSPEC, imsg_fds) == -1)
- return got_error_from_errno();
-
- pid = fork();
- if (pid == -1)
- return got_error_from_errno();
- else if (pid == 0) {
- exec_privsep_child(imsg_fds, GOT_PATH_PROG_READ_COMMIT,
- repo->path);
- /* not reached */
- }
-
- close(imsg_fds[1]);
- repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].imsg_fd =
- imsg_fds[0];
- repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].pid = pid;
- imsg_init(ibuf, imsg_fds[0]);
- repo->privsep_children[GOT_REPO_PRIVSEP_CHILD_COMMIT].ibuf = ibuf;
-
- return request_mini_commit(commit, repo, obj, obj_fd);
-}
-
static const struct got_error *
request_tree(struct got_tree_object **tree, struct got_repository *repo,
struct got_object *obj, int fd)
diff --git a/lib/object_cache.c b/lib/object_cache.c
index 112f328..24b34b5 100644
--- a/lib/object_cache.c
+++ b/lib/object_cache.c
@@ -32,10 +32,9 @@
#include "got_lib_object_idcache.h"
#include "got_lib_object_cache.h"
-#define GOT_OBJECT_CACHE_SIZE_OBJ 1024
-#define GOT_OBJECT_CACHE_SIZE_TREE 2048
-#define GOT_OBJECT_CACHE_SIZE_COMMIT 512
-#define GOT_OBJECT_CACHE_SIZE_MINI_COMMIT 32
+#define GOT_OBJECT_CACHE_SIZE_OBJ 1024
+#define GOT_OBJECT_CACHE_SIZE_TREE 2048
+#define GOT_OBJECT_CACHE_SIZE_COMMIT 512
const struct got_error *
got_object_cache_init(struct got_object_cache *cache,
@@ -53,9 +52,6 @@ got_object_cache_init(struct got_object_cache *cache,
case GOT_OBJECT_CACHE_TYPE_COMMIT:
size = GOT_OBJECT_CACHE_SIZE_COMMIT;
break;
- case GOT_OBJECT_CACHE_TYPE_MINI_COMMIT:
- size = GOT_OBJECT_CACHE_SIZE_MINI_COMMIT;
- break;
}
cache->idcache = got_object_idcache_alloc(size);
@@ -89,9 +85,6 @@ got_object_cache_add(struct got_object_cache *cache, struct got_object_id *id, v
case GOT_OBJECT_CACHE_TYPE_COMMIT:
got_object_commit_close(ce->data.commit);
break;
- case GOT_OBJECT_CACHE_TYPE_MINI_COMMIT:
- got_object_mini_commit_close(ce->data.mini_commit);
- break;
}
free(ce);
cache->cache_evict++;
@@ -111,9 +104,6 @@ got_object_cache_add(struct got_object_cache *cache, struct got_object_id *id, v
case GOT_OBJECT_CACHE_TYPE_COMMIT:
ce->data.commit = (struct got_commit_object *)item;
break;
- case GOT_OBJECT_CACHE_TYPE_MINI_COMMIT:
- ce->data.mini_commit = (struct got_mini_commit_object *)item;
- break;
}
err = got_object_idcache_add(cache->idcache, id, ce);
@@ -142,8 +132,6 @@ got_object_cache_get(struct got_object_cache *cache, struct got_object_id *id)
return ce->data.tree;
case GOT_OBJECT_CACHE_TYPE_COMMIT:
return ce->data.commit;
- case GOT_OBJECT_CACHE_TYPE_MINI_COMMIT:
- return ce->data.mini_commit;
}
}
@@ -169,7 +157,6 @@ void check_refcount(struct got_object_id *id, void *data, void *arg)
struct got_object *obj;
struct got_tree_object *tree;
struct got_commit_object *commit;
- struct got_mini_commit_object *mini_commit;
char *id_str;
if (got_object_id_str(&id_str, id) != NULL)
@@ -197,13 +184,6 @@ void check_refcount(struct got_object_id *id, void *data, void *arg)
fprintf(stderr, "commit %s has %d unclaimed references\n",
id_str, commit->refcnt - 1);
break;
- case GOT_OBJECT_CACHE_TYPE_MINI_COMMIT:
- mini_commit = ce->data.mini_commit;
- if (mini_commit->refcnt == 1)
- break;
- fprintf(stderr, "commit %s has %d unclaimed references\n",
- id_str, mini_commit->refcnt - 1);
- break;
}
free(id_str);
}
@@ -223,9 +203,6 @@ got_object_cache_close(struct got_object_cache *cache)
case GOT_OBJECT_CACHE_TYPE_COMMIT:
print_cache_stats(cache, "commit");
break;
- case GOT_OBJECT_CACHE_TYPE_MINI_COMMIT:
- print_cache_stats(cache, "mini-commit");
- break;
}
got_object_idcache_for_each(cache->idcache, check_refcount, cache);
diff --git a/lib/object_parse.c b/lib/object_parse.c
index 834b928..07d5265 100644
--- a/lib/object_parse.c
+++ b/lib/object_parse.c
@@ -42,10 +42,10 @@
#include "got_lib_sha1.h"
#include "got_lib_delta.h"
-#include "got_lib_inflate.h"
-#include "got_lib_object.h"
#include "got_lib_privsep.h"
#include "got_lib_pack.h"
+#include "got_lib_inflate.h"
+#include "got_lib_object.h"
#include "got_lib_object_cache.h"
#include "got_lib_repository.h"
@@ -102,24 +102,6 @@ got_object_close(struct got_object *obj)
free(obj);
}
-const struct got_error *
-got_object_qid_alloc_partial(struct got_object_qid **qid)
-{
- const struct got_error *err = NULL;
-
- *qid = malloc(sizeof(**qid));
- if (*qid == NULL)
- return got_error_from_errno();
-
- (*qid)->id = malloc(sizeof(*((*qid)->id)));
- if ((*qid)->id == NULL) {
- err = got_error_from_errno();
- got_object_qid_free(*qid);
- *qid = NULL;
- }
- return err;
-}
-
void
got_object_qid_free(struct got_object_qid *qid)
{
@@ -146,25 +128,6 @@ got_object_commit_alloc_partial(void)
return commit;
}
-struct got_mini_commit_object *
-got_object_mini_commit_alloc_partial(void)
-{
- struct got_mini_commit_object *commit;
-
- commit = calloc(1, sizeof(*commit));
- if (commit == NULL)
- return NULL;
- commit->tree_id = calloc(1, sizeof(*commit->tree_id));
- if (commit->tree_id == NULL) {
- free(commit);
- return NULL;
- }
-
- SIMPLEQ_INIT(&commit->parent_ids);
-
- return commit;
-}
-
const struct got_error *
got_object_commit_add_parent(struct got_commit_object *commit,
const char *id_str)
@@ -172,34 +135,17 @@ got_object_commit_add_parent(struct got_commit_object *commit,
const struct got_error *err = NULL;
struct got_object_qid *qid;
- err = got_object_qid_alloc_partial(&qid);
- if (err)
- return err;
+ qid = malloc(sizeof(*qid));
+ if (qid == NULL)
+ return got_error_from_errno();
- if (!got_parse_sha1_digest(qid->id->sha1, id_str)) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- free(qid->id);
- free(qid);
+ qid->id = malloc(sizeof(*qid->id));
+ if (qid->id == NULL) {
+ err = got_error_from_errno();
+ got_object_qid_free(qid);
return err;
}
- SIMPLEQ_INSERT_TAIL(&commit->parent_ids, qid, entry);
- commit->nparents++;
-
- return NULL;
-}
-
-const struct got_error *
-got_object_mini_commit_add_parent(struct got_mini_commit_object *commit,
- const char *id_str)
-{
- const struct got_error *err = NULL;
- struct got_object_qid *qid;
-
- err = got_object_qid_alloc_partial(&qid);
- if (err)
- return err;
-
if (!got_parse_sha1_digest(qid->id->sha1, id_str)) {
err = got_error(GOT_ERR_BAD_OBJ_DATA);
free(qid->id);
@@ -309,36 +255,14 @@ got_object_commit_close(struct got_commit_object *commit)
free(commit);
}
-void
-got_object_mini_commit_close(struct got_mini_commit_object *commit)
-{
- struct got_object_qid *qid;
-
- if (commit->refcnt > 0) {
- commit->refcnt--;
- if (commit->refcnt > 0)
- return;
- }
-
- while (!SIMPLEQ_EMPTY(&commit->parent_ids)) {
- qid = SIMPLEQ_FIRST(&commit->parent_ids);
- SIMPLEQ_REMOVE_HEAD(&commit->parent_ids, entry);
- got_object_qid_free(qid);
- }
-
- free(commit->tree_id);
- free(commit);
-}
-
const struct got_error *
-got_object_parse_commit(struct got_commit_object **commit, char *buf,
- size_t len)
+got_object_parse_commit(struct got_commit_object **commit, char *buf, size_t len)
{
const struct got_error *err = NULL;
char *s = buf;
size_t tlen;
ssize_t remain = (ssize_t)len;
-
+
*commit = got_object_commit_alloc_partial();
if (*commit == NULL)
return got_error_from_errno();
@@ -451,109 +375,6 @@ done:
return err;
}
-const struct got_error *
-got_object_parse_mini_commit(struct got_mini_commit_object **commit, char *buf,
- size_t len)
-{
- const struct got_error *err = NULL;
- char *s = buf;
- size_t tlen;
- ssize_t remain = (ssize_t)len;
-
- *commit = got_object_mini_commit_alloc_partial();
- if (*commit == NULL)
- return got_error_from_errno();
-
- tlen = strlen(GOT_COMMIT_TAG_TREE);
- if (strncmp(s, GOT_COMMIT_TAG_TREE, tlen) == 0) {
- remain -= tlen;
- if (remain < SHA1_DIGEST_STRING_LENGTH) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- s += tlen;
- if (!got_parse_sha1_digest((*commit)->tree_id->sha1, s)) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- remain -= SHA1_DIGEST_STRING_LENGTH;
- s += SHA1_DIGEST_STRING_LENGTH;
- } else {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
-
- tlen = strlen(GOT_COMMIT_TAG_PARENT);
- while (strncmp(s, GOT_COMMIT_TAG_PARENT, tlen) == 0) {
- remain -= tlen;
- if (remain < SHA1_DIGEST_STRING_LENGTH) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- s += tlen;
- err = got_object_mini_commit_add_parent(*commit, s);
- if (err)
- goto done;
-
- remain -= SHA1_DIGEST_STRING_LENGTH;
- s += SHA1_DIGEST_STRING_LENGTH;
- }
-
- tlen = strlen(GOT_COMMIT_TAG_AUTHOR);
- if (strncmp(s, GOT_COMMIT_TAG_AUTHOR, tlen) == 0) {
- char *p;
- size_t slen;
-
- remain -= tlen;
- if (remain <= 0) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- s += tlen;
- p = strchr(s, '\n');
- if (p == NULL) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- *p = '\0';
- slen = strlen(s);
- s += slen + 1;
- remain -= slen + 1;
- }
-
- tlen = strlen(GOT_COMMIT_TAG_COMMITTER);
- if (strncmp(s, GOT_COMMIT_TAG_COMMITTER, tlen) == 0) {
- char *p;
- size_t slen;
-
- remain -= tlen;
- if (remain <= 0) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- s += tlen;
- p = strchr(s, '\n');
- if (p == NULL) {
- err = got_error(GOT_ERR_BAD_OBJ_DATA);
- goto done;
- }
- *p = '\0';
- slen = strlen(s);
- err = parse_commit_time(&(*commit)->tm_committer, s);
- if (err)
- goto done;
- s += slen + 1;
- remain -= slen + 1;
- }
-
-done:
- if (err) {
- got_object_mini_commit_close(*commit);
- *commit = NULL;
- }
- return err;
-}
-
void
got_object_tree_entry_close(struct got_tree_entry *te)
{
diff --git a/lib/privsep.c b/lib/privsep.c
index ff2cfa6..2429a94 100644
--- a/lib/privsep.c
+++ b/lib/privsep.c
@@ -39,7 +39,6 @@
#include "got_lib_inflate.h"
#include "got_lib_object.h"
#include "got_lib_object_parse.h"
-#include "got_lib_object_cache.h"
#include "got_lib_privsep.h"
#include "got_lib_pack.h"
@@ -215,20 +214,6 @@ got_privsep_send_stop(int fd)
return err;
}
-static void
-init_imsg_object(struct got_imsg_object *iobj, struct got_object *obj)
-{
- memcpy(iobj->id, obj->id.sha1, sizeof(iobj->id));
- iobj->type = obj->type;
- iobj->flags = obj->flags;
- iobj->hdrlen = obj->hdrlen;
- iobj->size = obj->size;
- if (iobj->flags & GOT_OBJ_FLAG_PACKED) {
- iobj->pack_offset = obj->pack_offset;
- iobj->pack_idx = obj->pack_idx;
- }
-}
-
const struct got_error *
got_privsep_send_obj_req(struct imsgbuf *ibuf, int fd, struct got_object *obj)
{
@@ -251,7 +236,15 @@ got_privsep_send_obj_req(struct imsgbuf *ibuf, int fd, struct got_object *obj)
return got_error(GOT_ERR_OBJ_TYPE);
}
- init_imsg_object(&iobj, obj);
+ memcpy(iobj.id, obj->id.sha1, sizeof(iobj.id));
+ iobj.type = obj->type;
+ iobj.flags = obj->flags;
+ iobj.hdrlen = obj->hdrlen;
+ iobj.size = obj->size;
+ if (iobj.flags & GOT_OBJ_FLAG_PACKED) {
+ iobj.pack_offset = obj->pack_offset;
+ iobj.pack_idx = obj->pack_idx;
+ }
iobjp = &iobj;
iobj_size = sizeof(iobj);
@@ -264,28 +257,6 @@ got_privsep_send_obj_req(struct imsgbuf *ibuf, int fd, struct got_object *obj)
}
const struct got_error *
-got_privsep_send_mini_commit_req(struct imsgbuf *ibuf, int fd,
- struct got_object *obj)
-{
- struct got_imsg_object iobj, *iobjp;
- size_t iobj_size;
-
- if (obj->type != GOT_OBJ_TYPE_COMMIT)
- return got_error(GOT_ERR_OBJ_TYPE);
-
- init_imsg_object(&iobj, obj);
-
- iobjp = &iobj;
- iobj_size = sizeof(iobj);
-
- if (imsg_compose(ibuf, GOT_IMSG_MINI_COMMIT_REQUEST, 0, 0, fd,
- iobjp, iobj_size) == -1)
- return got_error_from_errno();
-
- return flush_imsg(ibuf);
-}
-
-const struct got_error *
got_privsep_send_blob_req(struct imsgbuf *ibuf, int infd)
{
if (imsg_compose(ibuf, GOT_IMSG_BLOB_REQUEST, 0, 0, infd, NULL, 0)
@@ -488,54 +459,6 @@ done:
}
const struct got_error *
-got_privsep_send_mini_commit(struct imsgbuf *ibuf,
- struct got_mini_commit_object *commit, struct got_object_id *parent_id)
-{
- const struct got_error *err = NULL;
- struct got_imsg_commit_object_mini icommit;
- uint8_t *buf;
- size_t len, total;
- struct got_object_qid *qid;
-
- memcpy(icommit.tree_id, commit->tree_id->sha1, sizeof(icommit.tree_id));
- memcpy(&icommit.tm_committer, &commit->tm_committer,
- sizeof(icommit.tm_committer));
- icommit.nparents = commit->nparents;
-
- icommit.is_parent = parent_id ? 1 : 0;
- if (parent_id)
- memcpy(icommit.parent_id, parent_id->sha1,
- sizeof(icommit.parent_id));
- else
- memset(&icommit.parent_id, 0, sizeof(icommit.parent_id));
-
- total = sizeof(icommit) + icommit.nparents * SHA1_DIGEST_LENGTH;
-
- buf = malloc(total);
- if (buf == NULL)
- return got_error_from_errno();
-
- len = 0;
- memcpy(buf + len, &icommit, sizeof(icommit));
- len += sizeof(icommit);
- SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
- memcpy(buf + len, qid->id, SHA1_DIGEST_LENGTH);
- len += SHA1_DIGEST_LENGTH;
- }
-
- if (imsg_compose(ibuf, GOT_IMSG_MINI_COMMIT, 0, 0, -1,
- buf, len) == -1) {
- err = got_error_from_errno();
- }
-
- free(buf);
- if (err)
- return err;
-
- return parent_id ? NULL : flush_imsg(ibuf);
-}
-
-const struct got_error *
got_privsep_recv_commit(struct got_commit_object **commit, struct imsgbuf *ibuf)
{
const struct got_error *err = NULL;
@@ -669,9 +592,17 @@ got_privsep_recv_commit(struct got_commit_object **commit, struct imsgbuf *ibuf)
for (i = 0; i < icommit.nparents; i++) {
struct got_object_qid *qid;
- err = got_object_qid_alloc_partial(&qid);
- if (err)
+ qid = calloc(1, sizeof(*qid));
+ if (qid == NULL) {
+ err = got_error_from_errno();
break;
+ }
+ qid->id = calloc(1, sizeof(*qid->id));
+ if (qid->id == NULL) {
+ err = got_error_from_errno();
+ free(qid);
+ break;
+ }
memcpy(qid->id, data + len + i * SHA1_DIGEST_LENGTH,
sizeof(*qid->id));
@@ -689,104 +620,6 @@ got_privsep_recv_commit(struct got_commit_object **commit, struct imsgbuf *ibuf)
return err;
}
-static const struct got_error *
-get_mini_commit(struct got_mini_commit_object **commit,
- struct got_imsg_commit_object_mini *icommit, uint8_t *data)
-{
- const struct got_error *err = NULL;
- int i;
-
- *commit = got_object_mini_commit_alloc_partial();
- if (*commit == NULL)
- return got_error_from_errno();
-
- memcpy((*commit)->tree_id->sha1, icommit->tree_id,
- SHA1_DIGEST_LENGTH);
- memcpy(&(*commit)->tm_committer, &icommit->tm_committer,
- sizeof((*commit)->tm_committer));
-
- for (i = 0; i < icommit->nparents; i++) {
- struct got_object_qid *qid;
-
- err = got_object_qid_alloc_partial(&qid);
- if (err)
- break;
-
- memcpy(qid->id,
- data + sizeof(*icommit) + (i * SHA1_DIGEST_LENGTH),
- sizeof(*qid->id));
- SIMPLEQ_INSERT_TAIL(&(*commit)->parent_ids, qid, entry);
- (*commit)->nparents++;
- }
-
- return err;
-}
-
-const struct got_error *
-got_privsep_recv_mini_commit(struct got_mini_commit_object **commit,
- struct got_object_id **parent_id, struct imsgbuf *ibuf)
-{
- const struct got_error *err = NULL;
- struct imsg imsg;
- struct got_imsg_commit_object_mini icommit;
- size_t datalen;
- const size_t min_datalen =
- MIN(sizeof(struct got_imsg_error),
- sizeof(struct got_imsg_commit_object_mini));
- uint8_t *data;
-
- *commit = NULL;
-
- err = got_privsep_recv_imsg(&imsg, ibuf, min_datalen);
- if (err)
- return err;
-
- data = imsg.data;
- datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
-
- switch (imsg.hdr.type) {
- case GOT_IMSG_ERROR:
- err = recv_imsg_error(&imsg, datalen);
- break;
- case GOT_IMSG_MINI_COMMIT:
- if (datalen < sizeof(icommit)) {
- err = got_error(GOT_ERR_PRIVSEP_LEN);
- break;
- }
-
- memcpy(&icommit, data, sizeof(icommit));
- if (datalen != sizeof(icommit) +
- icommit.nparents * SHA1_DIGEST_LENGTH) {
- err = got_error(GOT_ERR_PRIVSEP_LEN);
- break;
- }
- if (icommit.nparents < 0) {
- err = got_error(GOT_ERR_PRIVSEP_LEN);
- break;
- }
- /* got-read-pack might send us parent commits for caching */
- if (icommit.is_parent) {
- if (parent_id == NULL) {
- err = got_error(GOT_ERR_PRIVSEP_MSG);
- break;
- }
- *parent_id = malloc(sizeof(**parent_id));
- memcpy((*parent_id)->sha1, &icommit.parent_id,
- sizeof(*(*parent_id)->sha1));
- } else if (parent_id)
- *parent_id = NULL;
- err = get_mini_commit(commit, &icommit, data);
- break;
- default:
- err = got_error(GOT_ERR_PRIVSEP_MSG);
- break;
- }
-
- imsg_free(&imsg);
-
- return err;
-}
-
const struct got_error *
got_privsep_send_tree(struct imsgbuf *ibuf, struct got_tree_object *tree)
{
diff --git a/lib/repository.c b/lib/repository.c
index 968cec4..d82e38e 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -232,28 +232,6 @@ got_repo_get_cached_commit(struct got_repository *repo,
}
const struct got_error *
-got_repo_cache_mini_commit(struct got_repository *repo,
- struct got_object_id *id, struct got_mini_commit_object *commit)
-{
-#ifndef GOT_NO_OBJ_CACHE
- const struct got_error *err = NULL;
- err = got_object_cache_add(&repo->minicommitcache, id, commit);
- if (err)
- return err;
- commit->refcnt++;
-#endif
- return NULL;
-}
-
-struct got_mini_commit_object *
-got_repo_get_cached_mini_commit(struct got_repository *repo,
- struct got_object_id *id)
-{
- return (struct got_mini_commit_object *)got_object_cache_get(
- &repo->minicommitcache, id);
-}
-
-const struct got_error *
open_repo(struct got_repository *repo, const char *path)
{
const struct got_error *err = NULL;
@@ -376,10 +354,6 @@ got_repo_open(struct got_repository **repop, const char *path)
GOT_OBJECT_CACHE_TYPE_COMMIT);
if (err)
goto done;
- err = got_object_cache_init(&repo->minicommitcache,
- GOT_OBJECT_CACHE_TYPE_MINI_COMMIT);
- if (err)
- goto done;
normpath = got_path_normalize(abspath);
if (normpath == NULL) {
@@ -439,7 +413,6 @@ got_repo_close(struct got_repository *repo)
got_object_cache_close(&repo->objcache);
got_object_cache_close(&repo->treecache);
got_object_cache_close(&repo->commitcache);
- got_object_cache_close(&repo->minicommitcache);
for (i = 0; i < nitems(repo->privsep_children); i++) {
if (repo->privsep_children[i].imsg_fd == -1)
diff --git a/libexec/got-read-commit/got-read-commit.c b/libexec/got-read-commit/got-read-commit.c
index 8ae1f39..f6b5435 100644
--- a/libexec/got-read-commit/got-read-commit.c
+++ b/libexec/got-read-commit/got-read-commit.c
@@ -39,60 +39,30 @@
#include "got_lib_privsep.h"
static const struct got_error *
-read_commit_data(uint8_t **p, size_t *len, struct got_object *obj, FILE *f)
+read_commit_object(struct got_commit_object **commit, struct got_object *obj,
+ FILE *f)
{
- const struct got_error *err;
+ const struct got_error *err = NULL;
+ size_t len;
+ uint8_t *p;
if (obj->flags & GOT_OBJ_FLAG_PACKED)
- err = got_read_file_to_mem(p, len, f);
+ err = got_read_file_to_mem(&p, &len, f);
else
- err = got_inflate_to_mem(p, len, f);
+ err = got_inflate_to_mem(&p, &len, f);
if (err)
return err;
- if (*len < obj->hdrlen + obj->size) {
- free(*p);
- *p = NULL;
- *len = 0;
- return got_error(GOT_ERR_BAD_OBJ_DATA);
+ if (len < obj->hdrlen + obj->size) {
+ err = got_error(GOT_ERR_BAD_OBJ_DATA);
+ goto done;
}
/* Skip object header. */
- *len -= obj->hdrlen;
- return NULL;
-}
-
-static const struct got_error *
-read_commit_object(struct got_commit_object **commit, struct got_object *obj,
- FILE *f)
-{
- const struct got_error *err;
- uint8_t *p;
- size_t len;
-
- err = read_commit_data(&p, &len, obj, f);
- if (err)
- return err;
-
+ len -= obj->hdrlen;
err = got_object_parse_commit(commit, p + obj->hdrlen, len);
free(p);
- return err;
-}
-
-static const struct got_error *
-read_commit_object_mini(struct got_mini_commit_object **commit,
- struct got_object *obj, FILE *f)
-{
- const struct got_error *err;
- size_t len;
- uint8_t *p;
-
- err = read_commit_data(&p, &len, obj, f);
- if (err)
- return err;
-
- err = got_object_parse_mini_commit(commit, p + obj->hdrlen, len);
- free(p);
+done:
return err;
}
@@ -100,6 +70,7 @@ int
main(int argc, char *argv[])
{
const struct got_error *err = NULL;
+ struct got_commit_object *commit = NULL;
struct imsgbuf ibuf;
size_t datalen;
@@ -119,7 +90,6 @@ main(int argc, char *argv[])
struct got_imsg_object iobj;
FILE *f = NULL;
struct got_object *obj = NULL;
- int mini = 0;
err = got_privsep_recv_imsg(&imsg, &ibuf, 0);
if (err) {
@@ -131,16 +101,9 @@ main(int argc, char *argv[])
if (imsg.hdr.type == GOT_IMSG_STOP)
break;
- switch (imsg.hdr.type) {
- case GOT_IMSG_COMMIT_REQUEST:
- mini = 0;
- break;
- case GOT_IMSG_MINI_COMMIT_REQUEST:
- mini = 1;
- break;
- default:
- err = got_error(GOT_ERR_PRIVSEP_MSG);
- goto done;
+ if (imsg.hdr.type != GOT_IMSG_COMMIT_REQUEST) {
+ err = got_error(GOT_ERR_PRIVSEP_MSG);
+ goto done;
}
datalen = imsg.hdr.len - IMSG_HEADER_SIZE;
@@ -176,21 +139,11 @@ main(int argc, char *argv[])
goto done;
}
- if (mini) {
- struct got_mini_commit_object *commit;
- err = read_commit_object_mini(&commit, obj, f);
- if (err)
- goto done;
- err = got_privsep_send_mini_commit(&ibuf, commit, NULL);
- got_object_mini_commit_close(commit);
- } else {
- struct got_commit_object *commit;
- err = read_commit_object(&commit, obj, f);
- if (err)
- goto done;
- err = got_privsep_send_commit(&ibuf, commit);
- got_object_commit_close(commit);
- }
+ err = read_commit_object(&commit, obj, f);
+ if (err)
+ goto done;
+
+ err = got_privsep_send_commit(&ibuf, commit);
done:
if (f)
fclose(f);
diff --git a/libexec/got-read-pack/got-read-pack.c b/libexec/got-read-pack/got-read-pack.c
index f1be1b6..010b14b 100644
--- a/libexec/got-read-pack/got-read-pack.c
+++ b/libexec/got-read-pack/got-read-pack.c
@@ -145,115 +145,6 @@ commit_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
}
static const struct got_error *
-send_parent_commit(size_t *totlen, struct imsgbuf *ibuf,
- struct got_object_id *pid, struct got_pack *pack,
- struct got_packidx *packidx, int recurse)
-{
- const struct got_error *err = NULL;
- struct got_object *pobj;
- struct got_mini_commit_object *pcommit = NULL;
- uint8_t *buf;
- size_t len, plen;
- int idx;
-
- idx = got_packidx_get_object_idx(packidx, pid);
- if (idx == -1) /* parent commit not in same pack file */
- return NULL;
-
- err = got_packfile_open_object(&pobj, pack, packidx, idx, pid);
- if (err)
- return err;
-
- err = got_packfile_extract_object_to_mem(&buf, &len, pobj,
- pack);
- if (err) {
- got_object_close(pobj);
- return err;
- }
-
- pobj->size = len;
- err = got_object_parse_mini_commit(&pcommit, buf, len);
- free(buf);
-
- plen = sizeof(*pcommit) + (pcommit->nparents * SHA1_DIGEST_LENGTH);
- if (*totlen + plen >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
- goto done;
- *totlen += plen;
-
- err = got_privsep_send_mini_commit(ibuf, pcommit, pid);
- if (err)
- goto done;
-
- /* Send the first grandparent along as well if there is room. */
- if (recurse > 0) {
- struct got_object_qid *qid;
- qid = SIMPLEQ_FIRST(&pcommit->parent_ids);
- if (qid)
- err = send_parent_commit(totlen, ibuf, qid->id, pack,
- packidx, recurse - 1);
- }
-done:
- got_object_close(pobj);
- got_object_mini_commit_close(pcommit);
- return err;
-}
-
-static const struct got_error *
-mini_commit_request(struct imsg *imsg, struct imsgbuf *ibuf,
- struct got_pack *pack, struct got_packidx *packidx,
- struct got_object_cache *objcache)
-{
- const struct got_error *err = NULL;
- struct got_object *obj = NULL;
- struct got_mini_commit_object *commit = NULL;
- uint8_t *buf;
- size_t len, totlen;
- struct got_object_qid *qid;
-
- err = get_object(&obj, imsg, ibuf, pack, packidx, objcache,
- GOT_OBJ_TYPE_COMMIT);
- if (err)
- return err;
-
- err = got_packfile_extract_object_to_mem(&buf, &len, obj, pack);
- if (err)
- return err;
-
- obj->size = len;
- err = got_object_parse_mini_commit(&commit, buf, len);
- free(buf);
-
- /*
- * Try to pre-seed the main process mini-commit cache with parent
- * commits from this pack file. This makes more efficient use of
- * imsg pipe buffers per system call.
- */
- totlen = sizeof(struct got_imsg_commit_object_mini) +
- (commit->nparents * sizeof(SHA1_DIGEST_LENGTH));
- SIMPLEQ_FOREACH(qid, &commit->parent_ids, entry) {
- if (totlen >= MAX_IMSGSIZE - IMSG_HEADER_SIZE)
- break;
- err = send_parent_commit(&totlen, ibuf, qid->id,
- pack, packidx, 1);
- if (err)
- goto done;
- }
-
- err = got_privsep_send_mini_commit(ibuf, commit, NULL);
-done:
- got_object_close(obj);
- got_object_mini_commit_close(commit);
- if (err) {
- if (err->code == GOT_ERR_PRIVSEP_PIPE)
- err = NULL;
- else
- got_privsep_send_error(ibuf, err);
- }
-
- return err;
-}
-
-static const struct got_error *
tree_request(struct imsg *imsg, struct imsgbuf *ibuf, struct got_pack *pack,
struct got_packidx *packidx, struct got_object_cache *objcache)
{
@@ -573,10 +464,6 @@ main(int argc, char *argv[])
err = commit_request(&imsg, &ibuf, pack, packidx,
&objcache);
break;
- case GOT_IMSG_MINI_COMMIT_REQUEST:
- err = mini_commit_request(&imsg, &ibuf, pack, packidx,
- &objcache);
- break;
case GOT_IMSG_TREE_REQUEST:
err = tree_request(&imsg, &ibuf, pack, packidx,
&objcache);