From ae9ee41de86cc98adad1a0c70651c55acc3fb699 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 12 May 2007 21:49:33 -0700 Subject: git-config: do not forget seeing "a.b.var" means we are out of "a.var" section. Earlier code tried to be half-careful and knew the logic that seeing "a.var" after seeing "a.b.var" is a sign of the previous "a.b." section has ended, but forgot it has to handle the other way. Seeing "a.b.var" after seeing "a.var" is a sign that "a." section has ended, so a new "a.var2" variable should be added before the location "a.b.var" appears. Signed-off-by: Junio C Hamano diff --git a/config.c b/config.c index 70d1055..7b655fd 100644 --- a/config.c +++ b/config.c @@ -451,6 +451,9 @@ static int matches(const char* key, const char* value) static int store_aux(const char* key, const char* value) { + const char *ep; + size_t section_len; + switch (store.state) { case KEY_SEEN: if (matches(key, value)) { @@ -468,12 +471,29 @@ static int store_aux(const char* key, const char* value) } break; case SECTION_SEEN: - if (strncmp(key, store.key, store.baselen+1)) { + /* + * What we are looking for is in store.key (both + * section and var), and its section part is baselen + * long. We found key (again, both section and var). + * We would want to know if this key is in the same + * section as what we are looking for. We already + * know we are in the same section as what should + * hold store.key. + */ + ep = strrchr(key, '.'); + section_len = ep - key; + + if ((section_len != store.baselen) || + memcmp(key, store.key, section_len+1)) { store.state = SECTION_END_SEEN; break; - } else - /* do not increment matches: this is no match */ - store.offset[store.seen] = ftell(config_file); + } + + /* + * Do not increment matches: this is no match, but we + * just made sure we are in the desired section. + */ + store.offset[store.seen] = ftell(config_file); /* fallthru */ case SECTION_END_SEEN: case START: -- cgit v0.10.2-6-g49f6 From b18a2be37a0de27902ad6491960ed910083b0310 Mon Sep 17 00:00:00 2001 From: Steffen Prohaska Date: Sun, 13 May 2007 09:12:52 +0200 Subject: git-config: test for 'do not forget "a.b.var" ends "a.var" section'. Added test for mentioned bugfix. Signed-off-by: Steffen Prohaska Signed-off-by: Junio C Hamano diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 78c2e08..a1d777c 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -407,6 +407,25 @@ EOF test_expect_success "section was removed properly" \ "git diff -u expect .git/config" +rm .git/config + +cat > expect << EOF +[gitcvs] + enabled = true + dbname = %Ggitcvs2.%a.%m.sqlite +[gitcvs "ext"] + dbname = %Ggitcvs1.%a.%m.sqlite +EOF + +test_expect_success 'section ending' ' + + git-config gitcvs.enabled true && + git-config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite && + git-config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite && + cmp .git/config expect + +' + test_expect_success numbers ' git-config kilo.gram 1k && -- cgit v0.10.2-6-g49f6 From 0ab311d60108f8d93dbcac53623e8e593901b5ea Mon Sep 17 00:00:00 2001 From: Matthieu Castet Date: Sun, 13 May 2007 11:57:00 -0700 Subject: Remove stale non-static-inline prototype for tree_entry_extract() When 4651ece8 made the function a "static inline", it should have removd the stale prototype but everybody missed that. Thomas Glanzmann noticed this broke compilation with Forte12 compiler on his Sun boxes. Signed-off-by: Junio C Hamano diff --git a/tree-walk.h b/tree-walk.h index 43458cf..ee747ab 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -27,7 +27,6 @@ static inline int tree_entry_len(const char *name, const unsigned char *sha1) void update_tree_entry(struct tree_desc *); void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size); -const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *); /* Helper function that does both of the above and returns true for success */ int tree_entry(struct tree_desc *, struct name_entry *); -- cgit v0.10.2-6-g49f6 From b24dd51bf6102f5341d4753fad8ff73413ca66d3 Mon Sep 17 00:00:00 2001 From: Quy Tonthat Date: Sun, 13 May 2007 21:41:45 +1000 Subject: RPM spec: include files in technical/ to package. Not only that they are interesting to users, some of the files are linked to by the included "Git User's Manual" Signed-off-by: Quy Tonthat Signed-off-by: Junio C Hamano diff --git a/git.spec.in b/git.spec.in index b0ea628..2170424 100644 --- a/git.spec.in +++ b/git.spec.in @@ -167,8 +167,13 @@ rm -rf $RPM_BUILD_ROOT %{_datadir}/git-core/ %doc README COPYING Documentation/*.txt %{!?_without_docs: %doc Documentation/*.html Documentation/howto} +%{!?_without_docs: %doc Documentation/technical} %changelog +* Tue May 13 2007 Quy Tonthat +- Added lib files for git-gui +- Added Documentation/technical (As needed by Git Users Manual) + * Tue May 8 2007 Quy Tonthat - Added howto files -- cgit v0.10.2-6-g49f6 From 645833b564f585a25acd75c878ffda752909c273 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 12 May 2007 14:36:20 -0700 Subject: git-svn: don't drop the username from URLs when dcommit is run We no longer store usernames in URLs stored in git-svn-id lines for dcommit, so we shouldn't rely on those URLs when connecting to the remote repository to commit. diff --git a/git-svn.perl b/git-svn.perl index 3c4f490..d74e6d3 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -393,7 +393,7 @@ sub cmd_dcommit { } else { my %ed_opts = ( r => $last_rev, log => get_commit_entry($d)->{log}, - ra => Git::SVN::Ra->new($url), + ra => Git::SVN::Ra->new($gs->full_url), tree_a => "$d~1", tree_b => $d, editor_cb => sub { -- cgit v0.10.2-6-g49f6 From 0dc03d6a30213e9aa0eb88886cee24b993a24a29 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 May 2007 01:04:43 -0700 Subject: git-svn: clean up caching of SVN::Ra functions This patch was originally intended to make the Perl GC more sensitive to the SVN::Pool objects and not accidentally clean them up when they shouldn't be (causing segfaults). That didn't work, but this patch makes the code a bit cleaner regardless Put our caches for get_dir and check_path calls directly into the SVN::Ra object so they auto-expire when it is destroyed. dirents returned by get_dir() no longer needs the pool object stored persistently along with the cache data, as they'll be converted to native Perl hash references. Since calling rev_proplist repeatedly per-revision is no longer needed in git-svn, we do not cache calls to it. Signed-off-by: Eric Wong diff --git a/git-svn.perl b/git-svn.perl index d74e6d3..721a468 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1390,7 +1390,7 @@ sub traverse_ignore { } } foreach (sort keys %$dirent) { - next if $dirent->{$_}->kind != $SVN::Node::dir; + next if $dirent->{$_}->{kind} != $SVN::Node::dir; $self->traverse_ignore($fh, "$path/$_", $r); } } @@ -2888,7 +2888,7 @@ my ($can_do_switch, %ignored_err, $RA); BEGIN { # enforce temporary pool usage for some simple functions my $e; - foreach (qw/get_latest_revnum get_uuid get_repos_root/) { + foreach (qw/rev_proplist get_latest_revnum get_uuid get_repos_root/) { $e .= "sub $_ { my \$self = shift; my \$pool = SVN::Pool->new; @@ -2897,29 +2897,7 @@ BEGIN { wantarray ? \@ret : \$ret[0]; }\n"; } - # get_dir needs $pool held in cache for dirents to work, - # check_path is cacheable and rev_proplist is close enough - # for our purposes. - foreach (qw/check_path get_dir rev_proplist/) { - $e .= "my \%${_}_cache; my \$${_}_rev = 0; sub $_ { - my \$self = shift; - my \$r = pop; - my \$k = join(\"\\0\", \@_); - if (my \$x = \$${_}_cache{\$r}->{\$k}) { - return wantarray ? \@\$x : \$x->[0]; - } - my \$pool = SVN::Pool->new; - my \@ret = \$self->SUPER::$_(\@_, \$r, \$pool); - if (\$r != \$${_}_rev) { - \%${_}_cache = ( pool => [] ); - \$${_}_rev = \$r; - } - \$${_}_cache{\$r}->{\$k} = \\\@ret; - push \@{\$${_}_cache{pool}}, \$pool; - wantarray ? \@ret : \$ret[0]; }\n"; - } - $e .= "\n1;"; - eval $e or die $@; + eval "$e; 1;" or die $@; } sub new { @@ -2952,9 +2930,47 @@ sub new { $self->{svn_path} = $url; $self->{repos_root} = $self->get_repos_root; $self->{svn_path} =~ s#^\Q$self->{repos_root}\E(/|$)##; + $self->{cache} = { check_path => { r => 0, data => {} }, + get_dir => { r => 0, data => {} } }; $RA = bless $self, $class; } +sub check_path { + my ($self, $path, $r) = @_; + my $cache = $self->{cache}->{check_path}; + if ($r == $cache->{r} && exists $cache->{data}->{$path}) { + return $cache->{data}->{$path}; + } + my $pool = SVN::Pool->new; + my $t = $self->SUPER::check_path($path, $r, $pool); + $pool->clear; + if ($r != $cache->{r}) { + %{$cache->{data}} = (); + $cache->{r} = $r; + } + $cache->{data}->{$path} = $t; +} + +sub get_dir { + my ($self, $dir, $r) = @_; + my $cache = $self->{cache}->{get_dir}; + if ($r == $cache->{r}) { + if (my $x = $cache->{data}->{$dir}) { + return wantarray ? @$x : $x->[0]; + } + } + my $pool = SVN::Pool->new; + my ($d, undef, $props) = $self->SUPER::get_dir($dir, $r, $pool); + my %dirents = map { $_ => { kind => $d->{$_}->kind } } keys %$d; + $pool->clear; + if ($r != $cache->{r}) { + %{$cache->{data}} = (); + $cache->{r} = $r; + } + $cache->{data}->{$dir} = [ \%dirents, $r, $props ]; + wantarray ? (\%dirents, $r, $props) : \%dirents; +} + sub DESTROY { # do not call the real DESTROY since we store ourselves in $RA } @@ -3169,7 +3185,7 @@ sub match_globs { return unless scalar @x == 3; my $dirents = $x[0]; foreach my $de (keys %$dirents) { - next if $dirents->{$de}->kind != $SVN::Node::dir; + next if $dirents->{$de}->{kind} != $SVN::Node::dir; my $p = $g->{path}->full_path($de); next if $exists->{$p}; next if (length $g->{path}->{right} && -- cgit v0.10.2-6-g49f6 From 4c03c3eb4e31c2d1f88ca0c7106c647a246e81ff Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 May 2007 01:04:44 -0700 Subject: git-svn: fix segfaults due to initial SVN pool being cleared Some parts of SVN always seem to use it, even if the SVN::Ra object we're using is no longer used and we've created a new one in its place. It's also true that only one SVN::Ra connection can exist at once... Using SVN::Pool->new_default when the SVN::Ra object is created doesn't seem to help very much, either... Hopefully this fixes all segfault problems users have been experiencing over the past few months. Signed-off-by: Eric Wong diff --git a/git-svn.perl b/git-svn.perl index 721a468..ae14bab 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2904,7 +2904,6 @@ sub new { my ($class, $url) = @_; $url =~ s!/+$!!; return $RA if ($RA && $RA->{url} eq $url); - $RA->{pool}->clear if $RA; SVN::_Core::svn_config_ensure($config_dir, undef); my ($baton, $callbacks) = SVN::Core::auth_open_helper([ -- cgit v0.10.2-6-g49f6 From 4a1bb4c3f87f355dd52fcd0babcbd005d59d7ed6 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 13 May 2007 09:58:14 -0700 Subject: git-svn: don't attempt to minimize URLs by default For tracking branches and tags, git-svn prefers to connect to the root of the repository or at least the level that houses branches and tags as well as trunk. However, users that are accustomed to tracking a single directory have no use for this feature. As pointed out by Junio, users may not have permissions to connect to connect to a higher-level path in the repository. While the current minimize_url() function detects lack of permissions to certain paths _after_ successful logins, it cannot effectively determine if it is trying to access a login-only portion of a repo when the user expects to connect to a part where anonymous access is allowed. For people used to the git-svnimport switches of --trunk, --tags, --branches, they'll already pass the repository root (or root+subdirectory), so minimize URL isn't of too much use to them, either. For people *not* used to git-svnimport, git-svn also supports: git svn init --minimize-url \ --trunk http://repository-root/foo/trunk \ --branches http://repository-root/foo/branches \ --tags http://repository-root/foo/tags And this is where the new --minimize-url command-line switch comes in to allow for this behavior to continue working. diff --git a/git-svn.perl b/git-svn.perl index ae14bab..f4c9ff1 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -80,6 +80,7 @@ my %icv; my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared, 'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags, 'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix, + 'minimize-url|m' => \$Git::SVN::_minimize_url, 'no-metadata' => sub { $icv{noMetadata} = 1 }, 'use-svm-props' => sub { $icv{useSvmProps} = 1 }, 'use-svnsync-props' => sub { $icv{useSvnsyncProps} = 1 }, @@ -820,7 +821,7 @@ use strict; use warnings; use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent $_repack $_repack_flags $_use_svm_props $_head - $_use_svnsync_props $no_reuse_existing/; + $_use_svnsync_props $no_reuse_existing $_minimize_url/; use Carp qw/croak/; use File::Path qw/mkpath/; use File::Copy qw/copy/; @@ -1037,7 +1038,7 @@ sub init_remote_config { "[svn-remote \"$existing\"]\n"; } $self->{repo_id} = $existing; - } else { + } elsif ($_minimize_url) { my $min_url = Git::SVN::Ra->new($url)->minimize_url; $existing = find_existing_remote($min_url, $r); if ($existing) { diff --git a/t/t9100-git-svn-basic.sh b/t/t9100-git-svn-basic.sh index eb628fe..70c3669 100755 --- a/t/t9100-git-svn-basic.sh +++ b/t/t9100-git-svn-basic.sh @@ -229,7 +229,7 @@ test_expect_failure 'exit if init-ing a would clobber a URL' " test_expect_success \ 'init allows us to connect to another directory in the same repo' " - git-svn init -i bar $svnrepo/bar && + git-svn init --minimize-url -i bar $svnrepo/bar && git config --get svn-remote.svn.fetch \ '^bar:refs/remotes/bar$' && git config --get svn-remote.svn.fetch \ diff --git a/t/t9104-git-svn-follow-parent.sh b/t/t9104-git-svn-follow-parent.sh index bd4f366..35aa45c 100755 --- a/t/t9104-git-svn-follow-parent.sh +++ b/t/t9104-git-svn-follow-parent.sh @@ -28,7 +28,7 @@ test_expect_success 'initialize repo' " " test_expect_success 'init and fetch a moved directory' " - git-svn init -i thunk $svnrepo/thunk && + git-svn init --minimize-url -i thunk $svnrepo/thunk && git-svn fetch -i thunk && test \"\`git-rev-parse --verify refs/remotes/thunk@2\`\" \ = \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" && @@ -68,7 +68,8 @@ test_expect_success 'follow larger parent' " echo hi > import/trunk/thunk/bump/thud/file && svn import -m 'import a larger parent' import $svnrepo/larger-parent && svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger && - git-svn init -i larger $svnrepo/another-larger/trunk/thunk/bump/thud && + git-svn init --minimize-url -i larger \ + $svnrepo/another-larger/trunk/thunk/bump/thud && git-svn fetch -i larger && git-rev-parse --verify refs/remotes/larger && git-rev-parse --verify \ @@ -90,14 +91,14 @@ test_expect_success 'follow higher-level parent' " cd .. svn mkdir -m 'new glob at top level' $svnrepo/glob && svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob && - git-svn init -i blob $svnrepo/glob/blob && + git-svn init --minimize-url -i blob $svnrepo/glob/blob && git-svn fetch -i blob " test_expect_success 'follow deleted directory' " svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye && svn rm -m 'remove glob' $svnrepo/glob && - git-svn init -i glob $svnrepo/glob && + git-svn init --minimize-url -i glob $svnrepo/glob && git-svn fetch -i glob && test \"\`git cat-file blob refs/remotes/glob:blob/bye\`\" = hi && test \"\`git ls-tree refs/remotes/glob | wc -l \`\" -eq 1 @@ -127,7 +128,7 @@ test_expect_success 'follow-parent avoids deleting relevant info' " poke native/t/c.t && svn commit -m 'reorg test' && cd .. && - git-svn init -i r9270-t \ + git-svn init --minimize-url -i r9270-t \ $svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t && git-svn fetch -i r9270-t && test \`git rev-list r9270-t | wc -l\` -eq 2 && @@ -137,7 +138,7 @@ test_expect_success 'follow-parent avoids deleting relevant info' " test_expect_success "track initial change if it was only made to parent" " svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk && - git-svn init -i r9270-d \ + git-svn init --minimize-url -i r9270-d \ $svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t && git-svn fetch -i r9270-d && test \`git rev-list r9270-d | wc -l\` -eq 3 && diff --git a/t/t9105-git-svn-commit-diff.sh b/t/t9105-git-svn-commit-diff.sh index c668dd1..318e172 100755 --- a/t/t9105-git-svn-commit-diff.sh +++ b/t/t9105-git-svn-commit-diff.sh @@ -33,7 +33,7 @@ test_expect_success 'test the commit-diff command' " test_expect_success 'commit-diff to a sub-directory (with git-svn config)' " svn import -m 'sub-directory' import $svnrepo/subdir && - git-svn init $svnrepo/subdir && + git-svn init --minimize-url $svnrepo/subdir && git-svn fetch && git-svn commit-diff -r3 '$prev' '$head' && svn cat $svnrepo/subdir/readme > readme.2 && diff --git a/t/t9110-git-svn-use-svm-props.sh b/t/t9110-git-svn-use-svm-props.sh index 9db0d8f..59e17f2 100755 --- a/t/t9110-git-svn-use-svm-props.sh +++ b/t/t9110-git-svn-use-svm-props.sh @@ -9,9 +9,10 @@ test_description='git-svn useSvmProps test' test_expect_success 'load svm repo' " svnadmin load -q $rawsvnrepo < ../t9110/svm.dump && - git-svn init -R arr -i bar $svnrepo/mirror/arr && - git-svn init -R argh -i dir $svnrepo/mirror/argh && - git-svn init -R argh -i e $svnrepo/mirror/argh/a/b/c/d/e && + git-svn init --minimize-url -R arr -i bar $svnrepo/mirror/arr && + git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh && + git-svn init --minimize-url -R argh -i e \ + $svnrepo/mirror/argh/a/b/c/d/e && git-config svn.useSvmProps true && git-svn fetch --all " diff --git a/t/t9111-git-svn-use-svnsync-props.sh b/t/t9111-git-svn-use-svnsync-props.sh index 483d7f8..e523214 100755 --- a/t/t9111-git-svn-use-svnsync-props.sh +++ b/t/t9111-git-svn-use-svnsync-props.sh @@ -9,9 +9,9 @@ test_description='git-svn useSvnsyncProps test' test_expect_success 'load svnsync repo' " svnadmin load -q $rawsvnrepo < ../t9111/svnsync.dump && - git-svn init -R arr -i bar $svnrepo/bar && - git-svn init -R argh -i dir $svnrepo/dir && - git-svn init -R argh -i e $svnrepo/dir/a/b/c/d/e && + git-svn init --minimize-url -R arr -i bar $svnrepo/bar && + git-svn init --minimize-url -R argh -i dir $svnrepo/dir && + git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e && git-config svn.useSvnsyncProps true && git-svn fetch --all " -- cgit v0.10.2-6-g49f6