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

[FYI/PATCH 3/5] Git::SVN: use accessor to write path

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Sep 17, 2012, 09:10 UTC
Message-ID
<20120917091053.GD358@elie.Belkin>
In-Reply-To
<20120917090435.GA358@elie.Belkin>
From: Michael G. Schwern <schwern@pobox.com>
Date: Fri, 27 Jul 2012 13:00:48 -0700

This patch only touches cases where the path field is written to using $gs->{path}. Cases where the path is set directly in a hash literal will be addressed separately.

[jn: split from a larger patch]
Signed-off-by: Eric Wong <normalperson@yhbt.net>
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
---
 perl/Git/SVN.pm |   24 ++++++++++++++----------
 1 file changed, 14 insertions(+), 10 deletions(-)
diff --git a/perl/Git/SVN.pm b/perl/Git/SVN.pm
index 02d5abc0..826a7fa6 100644
--- a/perl/Git/SVN.pm
+++ b/perl/Git/SVN.pm
@@ -315,11 +315,11 @@ sub init_remote_config {
 					     "$url => $min_url\n";
 			}
 			my $old_path = $self->path;
-			$self->{path} = $url;
-			$self->{path} =~ s!^\Q$min_url\E(/|$)!!;
+			$url =~ s!^\Q$min_url\E(/|$)!!;
 			if (length $old_path) {
-				$self->{path} .= "/$old_path";
+				$url .= "/$old_path";
 			}
+			$self->path($url);
 			$url = $min_url;
 		}
 	}
@@ -343,8 +343,10 @@ sub init_remote_config {
 	unless ($no_write) {
 		command_noisy('config',
 			      "svn-remote.$self->{repo_id}.url", $url);
-		$self->{path} =~ s{^/}{};
-		$self->{path} =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
+		my $path = $self->path;
+		$path =~ s{^/}{};
+		$path =~ s{%([0-9A-F]{2})}{chr hex($1)}ieg;
+		$self->path($path);
 		command_noisy('config', '--add',
 			      "svn-remote.$self->{repo_id}.fetch",
 			      $self->path.":".$self->refname);
@@ -435,17 +437,19 @@ sub new {
 		}
 	}
 	my $self = _new($class, $repo_id, $ref_id, $path);
-	if (!defined $self->path || !length $self->path) {
+	$path = $self->path;
+	if (!defined $path || !length $path) {
 		my $fetch = command_oneline('config', '--get',
 		                            "svn-remote.$repo_id.fetch",
 		                            ":$ref_id\$") or
 		     die "Failed to read \"svn-remote.$repo_id.fetch\" ",
 		         "\":$ref_id\$\" in config\n";
-		($self->{path}, undef) = split(/\s*:\s*/, $fetch);
+		($path, undef) = split(/\s*:\s*/, $fetch);
 	}
-	$self->{path} =~ s{/+}{/}g;
-	$self->{path} =~ s{\A/}{};
-	$self->{path} =~ s{/\z}{};
+	$path =~ s{/+}{/}g;
+	$path =~ s{\A/}{};
+	$path =~ s{/\z}{};
+	$self->path($path);
 	$self->{url} = command_oneline('config', '--get',
 	                               "svn-remote.$repo_id.url") or
                   die "Failed to read \"svn-remote.$repo_id.url\" in config\n";
-- 
1.7.10.4
Previous: Jonathan NiederNext: Jonathan Nieder
Message 6 of 18 in “Make git-svn Use accessors for paths and urls”
  1. Michael G. SchwernJul 27, 2012
  2. 1/5 Make Git::SVN use accessors internally for path.Michael G. Schwern, Jul 27, 2012
  3. Jonathan NiederSep 17, 2012
  4. 1/5 Git::SVN: introduce path accessorJonathan Nieder, Sep 17, 2012
  5. 2/5 Git::SVN: use accessor to read pathJonathan Nieder, Sep 17, 2012
  6. 3/5 Git::SVN: use accessor to write pathJonathan Nieder, Sep 17, 2012
  7. 4/5 Git::SVN::_new: use accessor to write path fieldJonathan Nieder, Sep 17, 2012
  8. 5/5 Git::SVN: rename private path fieldJonathan Nieder, Sep 17, 2012
  9. Junio C HamanoSep 18, 2012
  10. Eric WongSep 18, 2012
  11. 2/5 Make Git::SVN use an accessor for URLs internally.Michael G. Schwern, Jul 27, 2012
  12. 3/5 Make Git::SVN::Ra use an accessor for URLsMichael G. Schwern, Jul 27, 2012
  13. 4/5 Change the rest of the code to use Git::SVN->path instead of the hash directly.Michael G. Schwern, Jul 27, 2012
  14. 5/5 Change the rest of the code to use the Git::SVN and Git::SVN::Ra url accessors.Michael G. Schwern, Jul 27, 2012
  15. Eric WongJul 28, 2012
  16. Jonathan NiederJul 28, 2012
  17. Michael G SchwernJul 28, 2012
  18. Jonathan NiederJul 28, 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.