From: Lucas Seiki Oshiro Date: Mon, 08 Jun 2026 15:05:40 GMT Subject: Re: [GSoC PATCH v2 1/4] path: introduce format_path() for centralized path formatting Message-ID: <22E79E77-BCC3-4622-BD39-F4ED7DDA9511@gmail.com> In-Reply-To: <20260605163012.181089-2-jayatheerthkulkarni2005@gmail.com> > +++ b/path.h > @@ -262,6 +262,36 @@ enum scld_error safe_create_leading_directories_no_share(char *path); > int safe_create_file_with_leading_directories(struct repository *repo, > const char *path); > > +/** > + * The formatting strategy to apply when writing a path into a buffer. > + */ > +enum path_format { > + /* Output the path exactly as-is without any modifications. */ > + PATH_FORMAT_UNMODIFIED, > + > + /* Output a path relative to the provided directory prefix. */ > + PATH_FORMAT_RELATIVE, > + > + /* Output a relative path only if the path shares a root with the prefix. */ > + PATH_FORMAT_RELATIVE_IF_SHARED, > + > + /* Output a fully resolved, absolute canonical path. */ > + PATH_FORMAT_CANONICAL > +}; > + > +/** > + * Format a path according to the specified formatting strategy and append > + * the result to the given strbuf. > + * > + * `buf` : The string buffer to append the formatted path to. > + * `path` : The path string that needs to be formatted. > + * `prefix` : The directory prefix to calculate relative offsets against. > + * Pass NULL to default to the current working directory where applicable. > + * `format` : The formatting behavior rule to execute. > + */ > +void format_path(struct strbuf *buf, const char *path, > + const char *prefix, enum path_format format); Nitpick: the documentation is clear to me, but maybe the function name "format" and the parameter name "buf" can mislead the user to think that it only formats the path without appending to the existing string in `buf`. My suggestion is to rename them to something like `append_formatted_path` and `dest`, respectively.