From: Eric Wong Date: Thu, 16 Jan 2025 03:28:51 +0000 (+0000) Subject: config: force absolute path when `-C /' (chdir) is used X-Git-Url: http://git.ipfire.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=74fbbc0ecd181592ebfd35821b97de33e173dea5;p=thirdparty%2Fpublic-inbox.git 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. --- 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));