@@ -1355,6 +1355,16 @@ int git_config_pathname(const char **dest, const char *var, const char *value)
return 0;
}
+int git_config_strbuf_pathname(struct strbuf *dest, const char *var, const char *value)
+{
+ if (!value)
+ return config_error_nonbool(var);
+ strbuf_interpolate_path(value, 0, dest);
+ if (!dest->len)
+ die(_("failed to expand user dir in: '%s'"), value);
+ return 0;
+}
+
int git_config_expiry_date(timestamp_t *timestamp, const char *var, const char *value)
{
if (!value)
@@ -22,6 +22,7 @@
*/
struct object_id;
+struct strbuf;
/* git_config_parse_key() returns these negated: */
#define CONFIG_INVALID_KEY 1
@@ -287,6 +288,7 @@ int git_config_string(const char **, const char *, const char *);
* user's home directory when found at the beginning of the path.
*/
int git_config_pathname(const char **, const char *, const char *);
+int git_config_strbuf_pathname(struct strbuf *, const char *, const char *);
int git_config_expiry_date(timestamp_t *, const char *, const char *);
int git_config_color(char *, const char *, const char *);
Add a new git_config_strbuf_pathname function, similar to git_config_pathname, that works with a strbuf relying on the recently introduced strbuf_interpolate_path. Signed-off-by: Rubén Justo <rjusto@gmail.com> --- config.c | 10 ++++++++++ config.h | 2 ++ 2 files changed, 12 insertions(+)