MCPcopy Create free account
hub / github.com/git/git / write_completed_directory

Function write_completed_directory

merge-ort.c:3887–4066  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

3885}
3886
3887static int write_completed_directory(struct merge_options *opt,
3888 const char *new_directory_name,
3889 struct directory_versions *info)
3890{
3891 const char *prev_dir;
3892 struct merged_info *dir_info = NULL;
3893 unsigned int offset, ret = 0;
3894
3895 /*
3896 * Some explanation of info->versions and info->offsets...
3897 *
3898 * process_entries() iterates over all relevant files AND
3899 * directories in reverse lexicographic order, and calls this
3900 * function. Thus, an example of the paths that process_entries()
3901 * could operate on (along with the directories for those paths
3902 * being shown) is:
3903 *
3904 * xtract.c ""
3905 * tokens.txt ""
3906 * src/moduleB/umm.c src/moduleB
3907 * src/moduleB/stuff.h src/moduleB
3908 * src/moduleB/baz.c src/moduleB
3909 * src/moduleB src
3910 * src/moduleA/foo.c src/moduleA
3911 * src/moduleA/bar.c src/moduleA
3912 * src/moduleA src
3913 * src ""
3914 * Makefile ""
3915 *
3916 * info->versions:
3917 *
3918 * always contains the unprocessed entries and their
3919 * version_info information. For example, after the first five
3920 * entries above, info->versions would be:
3921 *
3922 * xtract.c <xtract.c's version_info>
3923 * token.txt <token.txt's version_info>
3924 * umm.c <src/moduleB/umm.c's version_info>
3925 * stuff.h <src/moduleB/stuff.h's version_info>
3926 * baz.c <src/moduleB/baz.c's version_info>
3927 *
3928 * Once a subdirectory is completed we remove the entries in
3929 * that subdirectory from info->versions, writing it as a tree
3930 * (write_tree()). Thus, as soon as we get to src/moduleB,
3931 * info->versions would be updated to
3932 *
3933 * xtract.c <xtract.c's version_info>
3934 * token.txt <token.txt's version_info>
3935 * moduleB <src/moduleB's version_info>
3936 *
3937 * info->offsets:
3938 *
3939 * helps us track which entries in info->versions correspond to
3940 * which directories. When we are N directories deep (e.g. 4
3941 * for src/modA/submod/subdir/), we have up to N+1 unprocessed
3942 * directories (+1 because of toplevel dir). Corresponding to
3943 * the info->versions example above, after processing five entries
3944 * info->offsets will be:

Callers 1

process_entriesFunction · 0.85

Calls 3

strmap_getFunction · 0.85
string_list_appendFunction · 0.70
write_treeFunction · 0.70

Tested by

no test coverage detected