{"thread":{"id":"29905","subject":"[PATCH] git-svn: Use git-config --path for pathname-valued variables","startedAt":"2012-03-10T06:22:23Z","lastAt":"2012-03-10T06:22:23Z","messageCount":1,"participants":["Alex Plotnick"],"isPatch":true,"patchVersion":1,"patchTotal":null},"messages":[{"id":"186612","messageId":"1331360543-11716-1-git-send-email-shrike@netaxs.com","threadId":"29905","inReplyTo":null,"subject":"[PATCH] git-svn: Use git-config --path for pathname-valued variables","fromName":"Alex Plotnick","fromEmail":"shrike@netaxs.com","sentAt":"2012-03-10T06:22:23Z","receivedAt":"2012-03-10T06:22:23Z","isPatch":true,"sender":{"key":"shrike@netaxs.com","avatar":null},"body":"read_git_config automatically converts Getopt::Long-style option\nspecs to calls to git-config. It already provided type specifiers\nfor integer and boolean-valued config variables, but did not\nhandle pathnames specially. Thus, seemingly reasonable settings\nlike \"svn.authorsfile = ~/svn-authors\" could cause commands to\nfail since the leading tilde was not expanded.\n\nBecause Getopt::Long specs do not provide a specific flag for paths,\nwe use the heuristic that string-valued options whose names end in\n\"file\" should be treated as pathnames.\n\nThis patch also makes it clearer that at most one type specifier\nwill be used.\n\nSigned-off-by: Alex Plotnick <shrike@netaxs.com>\n---\n git-svn.perl                    |    9 +++++++--\n t/t9130-git-svn-authors-file.sh |    5 ++---\n 2 files changed, 9 insertions(+), 5 deletions(-)\n\ndiff --git a/git-svn.perl b/git-svn.perl\nindex 4334b95..5b065d6 100755\n--- a/git-svn.perl\n+++ b/git-svn.perl\n@@ -1810,8 +1810,13 @@ sub read_git_config {\n \t\tmy ($key) = ($o =~ /^([a-zA-Z\\-]+)/);\n \t\t$key =~ s/-//g;\n \t\tmy $arg = 'git config';\n-\t\t$arg .= ' --int' if ($o =~ /[:=]i$/);\n-\t\t$arg .= ' --bool' if ($o !~ /[:=][sfi]$/);\n+\t\tif ($o =~ /[:=]i$/) {\n+\t\t\t$arg .= ' --int';\n+\t\t} elsif ($o !~ /[:=][sfi]$/) {\n+\t\t\t$arg .= ' --bool';\n+\t\t} elsif ($o =~ /[:=]s$/ && $key =~ /file$/) {\n+\t\t\t$arg .= ' --path';\n+\t\t}\n \t\tif (ref $v eq 'ARRAY') {\n \t\t\tchomp(my @tmp = `$arg --get-all svn.$key`);\n \t\t\t@$v = @tmp if @tmp;\ndiff --git a/t/t9130-git-svn-authors-file.sh b/t/t9130-git-svn-authors-file.sh\nindex c3443ce..aa50183 100755\n--- a/t/t9130-git-svn-authors-file.sh\n+++ b/t/t9130-git-svn-authors-file.sh\n@@ -98,9 +98,8 @@ test_expect_success 'fresh clone with svn.authors-file in config' '\n \t\ttest_config=\"$HOME\"/.gitconfig &&\n \t\tsane_unset GIT_DIR &&\n \t\tsane_unset GIT_CONFIG &&\n-\t\tgit config --global \\\n-\t\t  svn.authorsfile \"$HOME\"/svn-authors &&\n-\t\ttest x\"$HOME\"/svn-authors = x\"$(git config svn.authorsfile)\" &&\n+\t\tgit config --global svn.authorsfile \"~/svn-authors\" &&\n+\t\ttest x\"$HOME\"/svn-authors = x\"$(git config --path svn.authorsfile)\" &&\n \t\tgit svn clone \"$svnrepo\" gitconfig.clone &&\n \t\tcd gitconfig.clone &&\n \t\tnr_ex=$(git log | grep \"^Author:.*example.com\" | wc -l) &&\n-- \n1.7.9.2\n"}]}