Stefan Beller <stefanbel...@googlemail.com> writes: >> git_path is for resolving paths within GIT_DIR, such as >> git_path("config") and git_path("COMMIT_EDITMSG"). >> >> Jonathan > > Before we're doing double work, I just wrote down my understanding > so far. Feel free to tweak it, or remove obvious parts.
> path API > ======== I am not sure if they deserve to be called "API"; it is just a set of simple helper functions. > `mkpath`:: > The parameters are in printf format. This function can be > used to construct short-lived filename strings. It is meant > to be used for direct use in system functions such as > dir(mkpath("%s/pack", get_objects_directory())). > The return value is a pointer to such a sanitized filename > string, but it resides in a static buffer, so it will > be overwritten by the next call to mkpath (or other functions?) > This function only does string handling. It doesn't actually > change anything on the filesystem. (This is not Gits mkdir -p) > > `mkpathdup`:: > The same as mkpath, but the memory is duplicated into a new > buffer, so it is not short-lived, but stays as long as the > caller doesn't free the memory, which the caller is supposed > to do. Good. > `xstrdup`:: > Duplicates the given string, making the caller responsible > to free the return value. Basically the same as strdup(2) > with errorhandling. > > I am not sure if this belongs into the path api documentation, > but it's not documented anywhere else. This does not belong. It should be grouped together with xmalloc(), xcalloc(), xrealloc(), etc. and these are not "path" functions. > `git_path`:: > git_path is for resolving paths within GIT_DIR, such as > git_path("config") and git_path("COMMIT_EDITMSG"). > This is similar to mkpath, returning a pointer to a static > buffer, which may be overwritten soon. > > `git_pathdup`:: > The same as git_path, but creating a new buffer. The caller > is responsible to free the returned buffer. OK. > `git_path_submodule`:: Similar to git_path() but is run for a submodule specified by the "path" given as its first parameter. -- To unsubscribe from this list: send the line "unsubscribe git" in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html