git/list[1] front-page[2] threads[3] people[4] search[5] about
 

[PATCH 4/6] config: use OPT_FILENAME()

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Dec 27, 2018, 15:56 UTC
Message-ID
<20181227155611.10585-5-pclouds@gmail.com>
In-Reply-To
<20181227155611.10585-1-pclouds@gmail.com>

Do not handle prefix directly. It's simpler to use OPT_FILENAME() instead. The othe reason for doing this is because this code (where the deleted code is) will be factored out and called when "prefix" is not available.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/config.c | 6 +-----
 1 file changed, 1 insertion(+), 5 deletions(-)
diff --git a/builtin/config.c b/builtin/config.c
index 771cfa54bd..c22d25de12 100644
--- a/builtin/config.c
+++ b/builtin/config.c
@@ -126,7 +126,7 @@ static struct option builtin_config_options[] = {
 	OPT_BOOL(0, "system", &use_system_config, N_("use system config file")),
 	OPT_BOOL(0, "local", &use_local_config, N_("use repository config file")),
 	OPT_BOOL(0, "worktree", &use_worktree_config, N_("use per-worktree config file")),
-	OPT_STRING('f', "file", &given_config_source.file, N_("file"), N_("use given config file")),
+	OPT_FILENAME('f', "file", &given_config_source.file, N_("use given config file")),
 	OPT_STRING(0, "blob", &given_config_source.blob, N_("blob-id"), N_("read config from given blob object")),
 	OPT_GROUP(N_("Action")),
 	OPT_BIT(0, "get", &actions, N_("get value: name [value-regex]"), ACTION_GET),
@@ -657,10 +657,6 @@ int cmd_config(int argc, const char **argv, const char *prefix)
 			      "extension worktreeConfig is enabled. "
 			      "Please read \"CONFIGURATION FILE\"\n"
 			      "section in \"git help worktree\" for details"));
-	} else if (given_config_source.file) {
-		if (!is_absolute_path(given_config_source.file) && prefix)
-			given_config_source.file =
-				prefix_filename(prefix, given_config_source.file);
 	}
 
 	if (respect_includes_opt == -1)
-- 
2.20.0.482.g66447595a7
Previous: Duy NguyenNext: Eric Sunshine
Message 9 of 12 in “Add "git config --move-to"”
  1. 0/6 Add "git config --move-to"Nguyễn Thái Ngọc Duy, Dec 27, 2018
  2. 1/6 config.c: avoid git_path() in do_git_config_sequence()Nguyễn Thái Ngọc Duy, Dec 27, 2018
  3. Junio C HamanoJan 10, 2019
  4. 2/6 worktree.c: add get_worktree_config()Nguyễn Thái Ngọc Duy, Dec 27, 2018
  5. Eric SunshineDec 27, 2018
  6. 3/6 config.c: add repo_config_set_worktree_gently()Nguyễn Thái Ngọc Duy, Dec 27, 2018
  7. Derrick StoleeApr 30, 2019
  8. Duy NguyenMay 1, 2019
  9. 4/6 config: use OPT_FILENAME()Nguyễn Thái Ngọc Duy, Dec 27, 2018
  10. Eric SunshineDec 27, 2018
  11. 5/6 config: factor out set_config_source_file()Nguyễn Thái Ngọc Duy, Dec 27, 2018
  12. 6/6 config: add --move-toNguyễn Thái Ngọc Duy, Dec 27, 2018

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.