[PATCH 2/4] config.c: introduce git_config_strbuf_pathname

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 config.c | 10 ++++++++++
 config.h |  2 ++
 2 files changed, 12 insertions(+)

diff --git a/config.c b/config.c
index eebce8c7e0..9beeb63b50 100644
--- a/config.c
+++ b/config.c
@@ -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)
diff --git a/config.h b/config.h
index f4966e3749..e405f1c140 100644
--- a/config.h
+++ b/config.h
@@ -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 *);
-- 
2.44.0.697.g9b33b46f29




[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux