| 696 | } |
| 697 | |
| 698 | static int write_each_note_helper(struct tree_write_stack *tws, |
| 699 | const char *path, unsigned int mode, |
| 700 | const struct object_id *oid) |
| 701 | { |
| 702 | size_t path_len = strlen(path); |
| 703 | unsigned int n = 0; |
| 704 | int ret; |
| 705 | |
| 706 | /* Determine common part of tree write stack */ |
| 707 | while (tws && 3 * n < path_len && |
| 708 | matches_tree_write_stack(tws, path + 3 * n)) { |
| 709 | n++; |
| 710 | tws = tws->next; |
| 711 | } |
| 712 | |
| 713 | /* tws point to last matching tree_write_stack entry */ |
| 714 | ret = tree_write_stack_finish_subtree(tws); |
| 715 | if (ret) |
| 716 | return ret; |
| 717 | |
| 718 | /* Start subtrees needed to satisfy path */ |
| 719 | while (3 * n + 2 < path_len && path[3 * n + 2] == '/') { |
| 720 | tree_write_stack_init_subtree(tws, path + 3 * n); |
| 721 | n++; |
| 722 | tws = tws->next; |
| 723 | } |
| 724 | |
| 725 | /* There should be no more directory components in the given path */ |
| 726 | assert(memchr(path + 3 * n, '/', path_len - (3 * n)) == NULL); |
| 727 | |
| 728 | /* Finally add given entry to the current tree object */ |
| 729 | write_tree_entry(&tws->buf, mode, path + 3 * n, path_len - (3 * n), |
| 730 | oid->hash); |
| 731 | |
| 732 | return 0; |
| 733 | } |
| 734 | |
| 735 | struct write_each_note_data { |
| 736 | struct tree_write_stack *root; |
no test coverage detected