All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Johannes Schindelin via GitGitGadget" <gitgitgadget@gmail.com>
To: git@vger.kernel.org
Cc: Ramsay Jones <ramsay@ramsayjones.plus.com>,
	Duy Nguyen <pclouds@gmail.com>,
	Junio C Hamano <gitster@pobox.com>, Johannes Sixt <j6t@kdbg.org>,
	Jeff King <peff@peff.net>,
	Eric Sunshine <sunshine@sunshineco.com>,
	Johannes Schindelin <johannes.schindelin@gmx.de>,
	Johannes Schindelin <johannes.schindelin@gmx.de>
Subject: [PATCH v3 4/5] Use a better name for the function interpolating paths
Date: Sat, 24 Jul 2021 22:06:52 +0000	[thread overview]
Message-ID: <19fd9c3c803a300b586c76736301a7379c4c6226.1627164413.git.gitgitgadget@gmail.com> (raw)
In-Reply-To: <pull.66.v3.git.1627164413.gitgitgadget@gmail.com>

From: Johannes Schindelin <johannes.schindelin@gmx.de>

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>
---
 builtin/credential-cache.c | 2 +-
 builtin/credential-store.c | 2 +-
 builtin/gc.c               | 2 +-
 cache.h                    | 2 +-
 config.c                   | 8 ++++----
 path.c                     | 4 ++--
 sequencer.c                | 2 +-
 7 files changed, 11 insertions(+), 11 deletions(-)

diff --git a/builtin/credential-cache.c b/builtin/credential-cache.c
index 76a6ba37223..e8a74157471 100644
--- a/builtin/credential-cache.c
+++ b/builtin/credential-cache.c
@@ -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
diff --git a/builtin/credential-store.c b/builtin/credential-store.c
index ae3c1ba75fe..62a4f3c2653 100644
--- a/builtin/credential-store.c
+++ b/builtin/credential-store.c
@@ -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)
diff --git a/builtin/gc.c b/builtin/gc.c
index f05d2f0a1ac..6ce5ca45126 100644
--- a/builtin/gc.c
+++ b/builtin/gc.c
@@ -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 ba04ff8bd36..87e4cbe9c5f 100644
--- 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)
 {
diff --git a/config.c b/config.c
index f9c400ad306..c17b9797292 100644
--- 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 bf329e535cf..8dc5ad2cb55 100644
--- 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),
diff --git a/sequencer.c b/sequencer.c
index 0bec01cf38e..007a851804d 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -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);
 
-- 
gitgitgadget


  parent reply	other threads:[~2021-07-24 22:07 UTC|newest]

Thread overview: 53+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-11-06 14:53 [PATCH 0/1] mingw: handle absolute paths in expand_user_path() Johannes Schindelin via GitGitGadget
2018-11-06 14:53 ` [PATCH 1/1] " Johannes Schindelin via GitGitGadget
2018-11-06 15:54   ` Ramsay Jones
2018-11-06 16:10     ` Ramsay Jones
2018-11-06 18:27       ` Duy Nguyen
2018-11-07  1:21     ` Junio C Hamano
2018-11-07 11:19       ` Johannes Schindelin
2018-11-07 17:42         ` Ramsay Jones
2018-11-08  0:16           ` Junio C Hamano
2018-11-08 13:04             ` Johannes Schindelin
2018-11-08 14:43               ` Junio C Hamano
2018-11-08 15:39                 ` Johannes Schindelin
2018-11-09  2:05             ` Joseph Moisan
2018-11-09 10:21               ` Jeff King
2018-11-06 18:24   ` Duy Nguyen
2018-11-07 11:19     ` Johannes Schindelin
2018-11-06 21:32   ` Johannes Sixt
2018-11-07 11:23     ` Johannes Schindelin
2018-11-07 18:52       ` Johannes Sixt
2018-11-07 20:41         ` Jeff King
2018-11-07 21:36           ` Johannes Sixt
2018-11-07 22:03             ` Jeff King
2018-11-08  0:30               ` Junio C Hamano
2018-11-08  1:18                 ` Jeff King
2018-11-08  3:26                   ` Junio C Hamano
2018-11-08 13:11               ` Johannes Schindelin
2018-11-08 14:25                 ` Duy Nguyen
2018-11-08 15:45                   ` Johannes Schindelin
2018-11-08 17:40                     ` Eric Sunshine
2018-11-09 10:19                     ` Jeff King
2018-11-09 16:16                       ` Duy Nguyen
2018-11-12  3:03                         ` Junio C Hamano
2018-11-08 14:47                 ` Junio C Hamano
2018-11-08 15:46                   ` Johannes Schindelin
2021-07-01 16:03 ` [PATCH v2 0/2] " Johannes Schindelin via GitGitGadget
2021-07-01 16:03   ` [PATCH v2 1/2] tests: exercise the RUNTIME_PREFIX feature Johannes Schindelin via GitGitGadget
2021-07-01 16:03   ` [PATCH v2 2/2] expand_user_path(): support specifying paths relative to the runtime prefix Johannes Schindelin via GitGitGadget
2021-07-01 17:42   ` [PATCH v2 0/2] mingw: handle absolute paths in expand_user_path() Junio C Hamano
2021-07-24 22:06   ` [PATCH v3 0/5] " Johannes Schindelin via GitGitGadget
2021-07-24 22:06     ` [PATCH v3 1/5] tests: exercise the RUNTIME_PREFIX feature Johannes Schindelin via GitGitGadget
2021-07-24 22:06     ` [PATCH v3 2/5] expand_user_path(): remove stale part of the comment Johannes Schindelin via GitGitGadget
2021-07-24 22:06     ` [PATCH v3 3/5] expand_user_path(): clarify the role of the `real_home` parameter Johannes Schindelin via GitGitGadget
2021-07-24 22:06     ` Johannes Schindelin via GitGitGadget [this message]
2021-07-26 22:05       ` [PATCH v3 4/5] Use a better name for the function interpolating paths Junio C Hamano
2021-07-27  7:57         ` Fabian Stelzer
2021-07-27 22:56           ` Junio C Hamano
2021-07-28  0:14             ` Junio C Hamano
2021-07-28  0:39               ` Junio C Hamano
2021-07-28  5:43                 ` Junio C Hamano
2021-07-28  8:18                   ` Fabian Stelzer
2021-07-28 17:08                     ` Junio C Hamano
2021-07-24 22:06     ` [PATCH v3 5/5] interpolate_path(): allow specifying paths relative to the runtime prefix Johannes Schindelin via GitGitGadget
2021-07-26 17:56     ` [PATCH v3 0/5] mingw: handle absolute paths in expand_user_path() Junio C Hamano

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=19fd9c3c803a300b586c76736301a7379c4c6226.1627164413.git.gitgitgadget@gmail.com \
    --to=gitgitgadget@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=j6t@kdbg.org \
    --cc=johannes.schindelin@gmx.de \
    --cc=pclouds@gmail.com \
    --cc=peff@peff.net \
    --cc=ramsay@ramsayjones.plus.com \
    --cc=sunshine@sunshineco.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.