]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Use a better name for the function interpolating paths
authorJohannes Schindelin <johannes.schindelin@gmx.de>
Sat, 24 Jul 2021 22:06:52 +0000 (22:06 +0000)
committerJunio C Hamano <gitster@pobox.com>
Mon, 26 Jul 2021 19:17:16 +0000 (12:17 -0700)
It is not immediately clear what `expand_user_path()` means, so let's
rename it to `interpolate_path()`. This also opens the path for
interpolating more than just a home directory.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/credential-cache.c
builtin/credential-store.c
builtin/gc.c
cache.h
config.c
path.c
sequencer.c

index 76a6ba37223fa94347192bdd7762da29cf6de920..e8a74157471948c5b94f897b7cd1b20d2f0c17c2 100644 (file)
@@ -90,7 +90,7 @@ static char *get_socket_path(void)
 {
        struct stat sb;
        char *old_dir, *socket;
-       old_dir = expand_user_path("~/.git-credential-cache", 0);
+       old_dir = interpolate_path("~/.git-credential-cache", 0);
        if (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode))
                socket = xstrfmt("%s/socket", old_dir);
        else
index ae3c1ba75fe60306f8819b1038660e73749aa83b..62a4f3c26531432da689dabe38b724c6e5484c7d 100644 (file)
@@ -173,7 +173,7 @@ int cmd_credential_store(int argc, const char **argv, const char *prefix)
        if (file) {
                string_list_append(&fns, file);
        } else {
-               if ((file = expand_user_path("~/.git-credentials", 0)))
+               if ((file = interpolate_path("~/.git-credentials", 0)))
                        string_list_append_nodup(&fns, file);
                file = xdg_config_home("credentials");
                if (file)
index f05d2f0a1ac9cd5637237d7da987452523a8ced3..6ce5ca451265991590b7beb6b1674dc273e5a610 100644 (file)
@@ -1542,7 +1542,7 @@ static char *launchctl_service_filename(const char *name)
        struct strbuf filename = STRBUF_INIT;
        strbuf_addf(&filename, "~/Library/LaunchAgents/%s.plist", name);
 
-       expanded = expand_user_path(filename.buf, 1);
+       expanded = interpolate_path(filename.buf, 1);
        if (!expanded)
                die(_("failed to expand path '%s'"), filename.buf);
 
diff --git a/cache.h b/cache.h
index ba04ff8bd36b3627c95fc7b9b3fc2aec2d55c205..87e4cbe9c5f42239fe1a022fc700626fb820d0e3 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1246,7 +1246,7 @@ typedef int create_file_fn(const char *path, void *cb);
 int raceproof_create_file(const char *path, create_file_fn fn, void *cb);
 
 int mkdir_in_gitdir(const char *path);
-char *expand_user_path(const char *path, int real_home);
+char *interpolate_path(const char *path, int real_home);
 const char *enter_repo(const char *path, int strict);
 static inline int is_absolute_path(const char *path)
 {
index f9c400ad3062d9953142d6a2f9c4b357962c48c7..c17b9797292695dd180df683fc52edfa373b51d8 100644 (file)
--- a/config.c
+++ b/config.c
@@ -137,7 +137,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
        if (!path)
                return config_error_nonbool("include.path");
 
-       expanded = expand_user_path(path, 0);
+       expanded = interpolate_path(path, 0);
        if (!expanded)
                return error(_("could not expand include path '%s'"), path);
        path = expanded;
@@ -185,7 +185,7 @@ static int prepare_include_condition_pattern(struct strbuf *pat)
        char *expanded;
        int prefix = 0;
 
-       expanded = expand_user_path(pat->buf, 1);
+       expanded = interpolate_path(pat->buf, 1);
        if (expanded) {
                strbuf_reset(pat);
                strbuf_addstr(pat, expanded);
@@ -1270,7 +1270,7 @@ int git_config_pathname(const char **dest, const char *var, const char *value)
 {
        if (!value)
                return config_error_nonbool(var);
-       *dest = expand_user_path(value, 0);
+       *dest = interpolate_path(value, 0);
        if (!*dest)
                die(_("failed to expand user dir in: '%s'"), value);
        return 0;
@@ -1844,7 +1844,7 @@ void git_global_config(char **user_out, char **xdg_out)
        char *xdg_config = NULL;
 
        if (!user_config) {
-               user_config = expand_user_path("~/.gitconfig", 0);
+               user_config = interpolate_path("~/.gitconfig", 0);
                xdg_config = xdg_config_home("config");
        }
 
diff --git a/path.c b/path.c
index bf329e535cfddf92728a2d23e4c6d7b229a8b884..8dc5ad2cb55a0116881b4c0a3764bb63e38f1381 100644 (file)
--- a/path.c
+++ b/path.c
@@ -724,7 +724,7 @@ static struct passwd *getpw_str(const char *username, size_t len)
  *
  * If real_home is true, strbuf_realpath($HOME) is used in the `~/` expansion.
  */
-char *expand_user_path(const char *path, int real_home)
+char *interpolate_path(const char *path, int real_home)
 {
        struct strbuf user_path = STRBUF_INIT;
        const char *to_copy = path;
@@ -811,7 +811,7 @@ const char *enter_repo(const char *path, int strict)
                strbuf_add(&validated_path, path, len);
 
                if (used_path.buf[0] == '~') {
-                       char *newpath = expand_user_path(used_path.buf, 0);
+                       char *newpath = interpolate_path(used_path.buf, 0);
                        if (!newpath)
                                return NULL;
                        strbuf_attach(&used_path, newpath, strlen(newpath),
index 0bec01cf38e8173c930b84250a61e84eb0c6963b..007a851804dce6f3886dee24bcbd8a3c44115bde 100644 (file)
@@ -1241,7 +1241,7 @@ N_("Your name and email address were configured automatically based\n"
 
 static const char *implicit_ident_advice(void)
 {
-       char *user_config = expand_user_path("~/.gitconfig", 0);
+       char *user_config = interpolate_path("~/.gitconfig", 0);
        char *xdg_config = xdg_config_home("config");
        int config_exists = file_exists(user_config) || file_exists(xdg_config);