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

[PATCH] git-svn: Use git-config --path for pathname-valued variables

From
APAlex Plotnick <shrike@netaxs.com>
Date
Mar 10, 2012, 06:22 UTC
Message-ID
<1331360543-11716-1-git-send-email-shrike@netaxs.com>

read_git_config automatically converts Getopt::Long-style option specs to calls to git-config. It already provided type specifiers for integer and boolean-valued config variables, but did not handle pathnames specially. Thus, seemingly reasonable settings like "svn.authorsfile = ~/svn-authors" could cause commands to fail since the leading tilde was not expanded.

Because Getopt::Long specs do not provide a specific flag for paths, we use the heuristic that string-valued options whose names end in "file" should be treated as pathnames.

This patch also makes it clearer that at most one type specifier will be used.

Signed-off-by: Alex Plotnick <shrike@netaxs.com>
---
 git-svn.perl                    |    9 +++++++--
 t/t9130-git-svn-authors-file.sh |    5 ++---
 2 files changed, 9 insertions(+), 5 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index 4334b95..5b065d6 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -1810,8 +1810,13 @@ sub read_git_config {
 		my ($key) = ($o =~ /^([a-zA-Z\-]+)/);
 		$key =~ s/-//g;
 		my $arg = 'git config';
-		$arg .= ' --int' if ($o =~ /[:=]i$/);
-		$arg .= ' --bool' if ($o !~ /[:=][sfi]$/);
+		if ($o =~ /[:=]i$/) {
+			$arg .= ' --int';
+		} elsif ($o !~ /[:=][sfi]$/) {
+			$arg .= ' --bool';
+		} elsif ($o =~ /[:=]s$/ && $key =~ /file$/) {
+			$arg .= ' --path';
+		}
 		if (ref $v eq 'ARRAY') {
 			chomp(my @tmp = `$arg --get-all svn.$key`);
 			@$v = @tmp if @tmp;
diff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh
index c3443ce..aa50183 100755
--- a/t/t9130-git-svn-authors-file.sh
+++ b/t/t9130-git-svn-authors-file.sh
@@ -98,9 +98,8 @@ test_expect_success 'fresh clone with svn.authors-file in config' '
 		test_config="$HOME"/.gitconfig &&
 		sane_unset GIT_DIR &&
 		sane_unset GIT_CONFIG &&
-		git config --global \
-		  svn.authorsfile "$HOME"/svn-authors &&
-		test x"$HOME"/svn-authors = x"$(git config svn.authorsfile)" &&
+		git config --global svn.authorsfile "~/svn-authors" &&
+		test x"$HOME"/svn-authors = x"$(git config --path svn.authorsfile)" &&
 		git svn clone "$svnrepo" gitconfig.clone &&
 		cd gitconfig.clone &&
 		nr_ex=$(git log | grep "^Author:.*example.com" | wc -l) &&
-- 
1.7.9.2
Message 1 of 1 in “git-svn: Use git-config --path for pathname-valued variables”
  1. git-svn: Use git-config --path for pathname-valued variablesAlex Plotnick, Mar 10, 2012

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.