From 74fbbc0ecd181592ebfd35821b97de33e173dea5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Thu, 16 Jan 2025 03:28:51 +0000 Subject: [PATCH] config: force absolute path when `-C /' (chdir) is used 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. --- 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 442759dec..358ddd2a2 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)); -- 2.47.2