]> git.ipfire.org Git - thirdparty/public-inbox.git/commitdiff
config: force absolute path when `-C /' (chdir) is used
authorEric Wong <e@80x24.org>
Thu, 16 Jan 2025 03:28:51 +0000 (03:28 +0000)
committerEric Wong <e@80x24.org>
Fri, 17 Jan 2025 19:26:40 +0000 (19:26 +0000)
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

index 442759dec9f2a820561724e3b5fed22106236dac..358ddd2a20e907f61c60cc31a2f9495931b41375 100644 (file)
@@ -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));