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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxxx>
---
 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

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]