Skip to content

Commit a03b097

Browse files
dschogitster
authored andcommitted
Use a better name for the function interpolating paths
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 <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 644e6b2 commit a03b097

File tree

7 files changed

+11
-11
lines changed

7 files changed

+11
-11
lines changed

builtin/credential-cache.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,7 +90,7 @@ static char *get_socket_path(void)
9090
{
9191
struct stat sb;
9292
char *old_dir, *socket;
93-
old_dir = expand_user_path("~/.git-credential-cache", 0);
93+
old_dir = interpolate_path("~/.git-credential-cache", 0);
9494
if (old_dir && !stat(old_dir, &sb) && S_ISDIR(sb.st_mode))
9595
socket = xstrfmt("%s/socket", old_dir);
9696
else

builtin/credential-store.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -173,7 +173,7 @@ int cmd_credential_store(int argc, const char **argv, const char *prefix)
173173
if (file) {
174174
string_list_append(&fns, file);
175175
} else {
176-
if ((file = expand_user_path("~/.git-credentials", 0)))
176+
if ((file = interpolate_path("~/.git-credentials", 0)))
177177
string_list_append_nodup(&fns, file);
178178
file = xdg_config_home("credentials");
179179
if (file)

builtin/gc.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1542,7 +1542,7 @@ static char *launchctl_service_filename(const char *name)
15421542
struct strbuf filename = STRBUF_INIT;
15431543
strbuf_addf(&filename, "~/Library/LaunchAgents/%s.plist", name);
15441544

1545-
expanded = expand_user_path(filename.buf, 1);
1545+
expanded = interpolate_path(filename.buf, 1);
15461546
if (!expanded)
15471547
die(_("failed to expand path '%s'"), filename.buf);
15481548

cache.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1246,7 +1246,7 @@ typedef int create_file_fn(const char *path, void *cb);
12461246
int raceproof_create_file(const char *path, create_file_fn fn, void *cb);
12471247

12481248
int mkdir_in_gitdir(const char *path);
1249-
char *expand_user_path(const char *path, int real_home);
1249+
char *interpolate_path(const char *path, int real_home);
12501250
const char *enter_repo(const char *path, int strict);
12511251
static inline int is_absolute_path(const char *path)
12521252
{

config.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -137,7 +137,7 @@ static int handle_path_include(const char *path, struct config_include_data *inc
137137
if (!path)
138138
return config_error_nonbool("include.path");
139139

140-
expanded = expand_user_path(path, 0);
140+
expanded = interpolate_path(path, 0);
141141
if (!expanded)
142142
return error(_("could not expand include path '%s'"), path);
143143
path = expanded;
@@ -185,7 +185,7 @@ static int prepare_include_condition_pattern(struct strbuf *pat)
185185
char *expanded;
186186
int prefix = 0;
187187

188-
expanded = expand_user_path(pat->buf, 1);
188+
expanded = interpolate_path(pat->buf, 1);
189189
if (expanded) {
190190
strbuf_reset(pat);
191191
strbuf_addstr(pat, expanded);
@@ -1270,7 +1270,7 @@ int git_config_pathname(const char **dest, const char *var, const char *value)
12701270
{
12711271
if (!value)
12721272
return config_error_nonbool(var);
1273-
*dest = expand_user_path(value, 0);
1273+
*dest = interpolate_path(value, 0);
12741274
if (!*dest)
12751275
die(_("failed to expand user dir in: '%s'"), value);
12761276
return 0;
@@ -1844,7 +1844,7 @@ void git_global_config(char **user_out, char **xdg_out)
18441844
char *xdg_config = NULL;
18451845

18461846
if (!user_config) {
1847-
user_config = expand_user_path("~/.gitconfig", 0);
1847+
user_config = interpolate_path("~/.gitconfig", 0);
18481848
xdg_config = xdg_config_home("config");
18491849
}
18501850

path.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -724,7 +724,7 @@ static struct passwd *getpw_str(const char *username, size_t len)
724724
*
725725
* If real_home is true, strbuf_realpath($HOME) is used in the `~/` expansion.
726726
*/
727-
char *expand_user_path(const char *path, int real_home)
727+
char *interpolate_path(const char *path, int real_home)
728728
{
729729
struct strbuf user_path = STRBUF_INIT;
730730
const char *to_copy = path;
@@ -811,7 +811,7 @@ const char *enter_repo(const char *path, int strict)
811811
strbuf_add(&validated_path, path, len);
812812

813813
if (used_path.buf[0] == '~') {
814-
char *newpath = expand_user_path(used_path.buf, 0);
814+
char *newpath = interpolate_path(used_path.buf, 0);
815815
if (!newpath)
816816
return NULL;
817817
strbuf_attach(&used_path, newpath, strlen(newpath),

sequencer.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1241,7 +1241,7 @@ N_("Your name and email address were configured automatically based\n"
12411241

12421242
static const char *implicit_ident_advice(void)
12431243
{
1244-
char *user_config = expand_user_path("~/.gitconfig", 0);
1244+
char *user_config = interpolate_path("~/.gitconfig", 0);
12451245
char *xdg_config = xdg_config_home("config");
12461246
int config_exists = file_exists(user_config) || file_exists(xdg_config);
12471247

0 commit comments

Comments
 (0)