* [PATCH] config: force absolute path when `-C /' (chdir) is used
@ 2025-01-16 3:28 Eric Wong
0 siblings, 0 replies; only message in thread
From: Eric Wong @ 2025-01-16 3:28 UTC (permalink / raw)
To: meta
For rare cases where we rely on `-c' to override temporary
options, we also chdir(2) to `/' to avoid hitting a users'
$worktree/.git/config. Thus, the config file must be given as
as an absolute path. While the majority of or code assumes
absolute paths are used for config files, it's possible we end
up on some strange setups where $ENV{HOME} is a relative path.
---
Noticed while experimenting with libgit2 to optionally reduce
vfork+execve usage...
lib/PublicInbox/Config.pm | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/lib/PublicInbox/Config.pm b/lib/PublicInbox/Config.pm
index 442759de..358ddd2a 100644
--- a/lib/PublicInbox/Config.pm
+++ b/lib/PublicInbox/Config.pm
@@ -186,7 +186,10 @@ sub git_config_dump {
my %env;
my $opt = { 2 => $lei->{2} // 2 };
if (@opt_c) {
- unshift(@opt_c, '-c', "include.path=$file") if defined($file);
+ if (defined $file) {
+ $file = rel2abs_collapsed($file); # for $opt->{-C}
+ unshift @opt_c, '-c', "include.path=$file";
+ }
tmp_cmd_opt(\%env, $opt);
}
my @cmd = (git_exe, @opt_c, qw(config -z -l --includes));
^ permalink raw reply related [flat|nested] only message in thread
only message in thread, other threads:[~2025-01-16 3:28 UTC | newest]
Thread overview: (only message) (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2025-01-16 3:28 [PATCH] config: force absolute path when `-C /' (chdir) is used Eric Wong
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).