Skip to content

Commit 43d151a

Browse files
author
Junio C Hamano
committed
Merge branch 'maint'
* maint: git-svn: don't attempt to minimize URLs by default git-svn: fix segfaults due to initial SVN pool being cleared git-svn: clean up caching of SVN::Ra functions git-svn: don't drop the username from URLs when dcommit is run RPM spec: include files in technical/ to package. Remove stale non-static-inline prototype for tree_entry_extract() git-config: test for 'do not forget "a.b.var" ends "a.var" section'. git-config: do not forget seeing "a.b.var" means we are out of "a.var" section.
2 parents f987afa + 4a1bb4c commit 43d151a

10 files changed

+110
-49
lines changed

config.c

Lines changed: 24 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -451,6 +451,9 @@ static int matches(const char* key, const char* value)
451451

452452
static int store_aux(const char* key, const char* value)
453453
{
454+
const char *ep;
455+
size_t section_len;
456+
454457
switch (store.state) {
455458
case KEY_SEEN:
456459
if (matches(key, value)) {
@@ -468,12 +471,29 @@ static int store_aux(const char* key, const char* value)
468471
}
469472
break;
470473
case SECTION_SEEN:
471-
if (strncmp(key, store.key, store.baselen+1)) {
474+
/*
475+
* What we are looking for is in store.key (both
476+
* section and var), and its section part is baselen
477+
* long. We found key (again, both section and var).
478+
* We would want to know if this key is in the same
479+
* section as what we are looking for. We already
480+
* know we are in the same section as what should
481+
* hold store.key.
482+
*/
483+
ep = strrchr(key, '.');
484+
section_len = ep - key;
485+
486+
if ((section_len != store.baselen) ||
487+
memcmp(key, store.key, section_len+1)) {
472488
store.state = SECTION_END_SEEN;
473489
break;
474-
} else
475-
/* do not increment matches: this is no match */
476-
store.offset[store.seen] = ftell(config_file);
490+
}
491+
492+
/*
493+
* Do not increment matches: this is no match, but we
494+
* just made sure we are in the desired section.
495+
*/
496+
store.offset[store.seen] = ftell(config_file);
477497
/* fallthru */
478498
case SECTION_END_SEEN:
479499
case START:

git-svn.perl

Lines changed: 46 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,7 @@ BEGIN
8080
my %init_opts = ( 'template=s' => \$_template, 'shared:s' => \$_shared,
8181
'trunk|T=s' => \$_trunk, 'tags|t=s' => \$_tags,
8282
'branches|b=s' => \$_branches, 'prefix=s' => \$_prefix,
83+
'minimize-url|m' => \$Git::SVN::_minimize_url,
8384
'no-metadata' => sub { $icv{noMetadata} = 1 },
8485
'use-svm-props' => sub { $icv{useSvmProps} = 1 },
8586
'use-svnsync-props' => sub { $icv{useSvnsyncProps} = 1 },
@@ -393,7 +394,7 @@ sub cmd_dcommit {
393394
} else {
394395
my %ed_opts = ( r => $last_rev,
395396
log => get_commit_entry($d)->{log},
396-
ra => Git::SVN::Ra->new($url),
397+
ra => Git::SVN::Ra->new($gs->full_url),
397398
tree_a => "$d~1",
398399
tree_b => $d,
399400
editor_cb => sub {
@@ -820,7 +821,7 @@ package Git::SVN;
820821
use warnings;
821822
use vars qw/$default_repo_id $default_ref_id $_no_metadata $_follow_parent
822823
$_repack $_repack_flags $_use_svm_props $_head
823-
$_use_svnsync_props $no_reuse_existing/;
824+
$_use_svnsync_props $no_reuse_existing $_minimize_url/;
824825
use Carp qw/croak/;
825826
use File::Path qw/mkpath/;
826827
use File::Copy qw/copy/;
@@ -1037,7 +1038,7 @@ sub init_remote_config {
10371038
"[svn-remote \"$existing\"]\n";
10381039
}
10391040
$self->{repo_id} = $existing;
1040-
} else {
1041+
} elsif ($_minimize_url) {
10411042
my $min_url = Git::SVN::Ra->new($url)->minimize_url;
10421043
$existing = find_existing_remote($min_url, $r);
10431044
if ($existing) {
@@ -1390,7 +1391,7 @@ sub traverse_ignore {
13901391
}
13911392
}
13921393
foreach (sort keys %$dirent) {
1393-
next if $dirent->{$_}->kind != $SVN::Node::dir;
1394+
next if $dirent->{$_}->{kind} != $SVN::Node::dir;
13941395
$self->traverse_ignore($fh, "$path/$_", $r);
13951396
}
13961397
}
@@ -2888,7 +2889,7 @@ package Git::SVN::Ra;
28882889
BEGIN {
28892890
# enforce temporary pool usage for some simple functions
28902891
my $e;
2891-
foreach (qw/get_latest_revnum get_uuid get_repos_root/) {
2892+
foreach (qw/rev_proplist get_latest_revnum get_uuid get_repos_root/) {
28922893
$e .= "sub $_ {
28932894
my \$self = shift;
28942895
my \$pool = SVN::Pool->new;
@@ -2897,36 +2898,13 @@ BEGIN
28972898
wantarray ? \@ret : \$ret[0]; }\n";
28982899
}
28992900

2900-
# get_dir needs $pool held in cache for dirents to work,
2901-
# check_path is cacheable and rev_proplist is close enough
2902-
# for our purposes.
2903-
foreach (qw/check_path get_dir rev_proplist/) {
2904-
$e .= "my \%${_}_cache; my \$${_}_rev = 0; sub $_ {
2905-
my \$self = shift;
2906-
my \$r = pop;
2907-
my \$k = join(\"\\0\", \@_);
2908-
if (my \$x = \$${_}_cache{\$r}->{\$k}) {
2909-
return wantarray ? \@\$x : \$x->[0];
2910-
}
2911-
my \$pool = SVN::Pool->new;
2912-
my \@ret = \$self->SUPER::$_(\@_, \$r, \$pool);
2913-
if (\$r != \$${_}_rev) {
2914-
\%${_}_cache = ( pool => [] );
2915-
\$${_}_rev = \$r;
2916-
}
2917-
\$${_}_cache{\$r}->{\$k} = \\\@ret;
2918-
push \@{\$${_}_cache{pool}}, \$pool;
2919-
wantarray ? \@ret : \$ret[0]; }\n";
2920-
}
2921-
$e .= "\n1;";
2922-
eval $e or die $@;
2901+
eval "$e; 1;" or die $@;
29232902
}
29242903

29252904
sub new {
29262905
my ($class, $url) = @_;
29272906
$url =~ s!/+$!!;
29282907
return $RA if ($RA && $RA->{url} eq $url);
2929-
$RA->{pool}->clear if $RA;
29302908

29312909
SVN::_Core::svn_config_ensure($config_dir, undef);
29322910
my ($baton, $callbacks) = SVN::Core::auth_open_helper([
@@ -2952,9 +2930,47 @@ sub new {
29522930
$self->{svn_path} = $url;
29532931
$self->{repos_root} = $self->get_repos_root;
29542932
$self->{svn_path} =~ s#^\Q$self->{repos_root}\E(/|$)##;
2933+
$self->{cache} = { check_path => { r => 0, data => {} },
2934+
get_dir => { r => 0, data => {} } };
29552935
$RA = bless $self, $class;
29562936
}
29572937

2938+
sub check_path {
2939+
my ($self, $path, $r) = @_;
2940+
my $cache = $self->{cache}->{check_path};
2941+
if ($r == $cache->{r} && exists $cache->{data}->{$path}) {
2942+
return $cache->{data}->{$path};
2943+
}
2944+
my $pool = SVN::Pool->new;
2945+
my $t = $self->SUPER::check_path($path, $r, $pool);
2946+
$pool->clear;
2947+
if ($r != $cache->{r}) {
2948+
%{$cache->{data}} = ();
2949+
$cache->{r} = $r;
2950+
}
2951+
$cache->{data}->{$path} = $t;
2952+
}
2953+
2954+
sub get_dir {
2955+
my ($self, $dir, $r) = @_;
2956+
my $cache = $self->{cache}->{get_dir};
2957+
if ($r == $cache->{r}) {
2958+
if (my $x = $cache->{data}->{$dir}) {
2959+
return wantarray ? @$x : $x->[0];
2960+
}
2961+
}
2962+
my $pool = SVN::Pool->new;
2963+
my ($d, undef, $props) = $self->SUPER::get_dir($dir, $r, $pool);
2964+
my %dirents = map { $_ => { kind => $d->{$_}->kind } } keys %$d;
2965+
$pool->clear;
2966+
if ($r != $cache->{r}) {
2967+
%{$cache->{data}} = ();
2968+
$cache->{r} = $r;
2969+
}
2970+
$cache->{data}->{$dir} = [ \%dirents, $r, $props ];
2971+
wantarray ? (\%dirents, $r, $props) : \%dirents;
2972+
}
2973+
29582974
sub DESTROY {
29592975
# do not call the real DESTROY since we store ourselves in $RA
29602976
}
@@ -3169,7 +3185,7 @@ sub match_globs {
31693185
return unless scalar @x == 3;
31703186
my $dirents = $x[0];
31713187
foreach my $de (keys %$dirents) {
3172-
next if $dirents->{$de}->kind != $SVN::Node::dir;
3188+
next if $dirents->{$de}->{kind} != $SVN::Node::dir;
31733189
my $p = $g->{path}->full_path($de);
31743190
next if $exists->{$p};
31753191
next if (length $g->{path}->{right} &&

git.spec.in

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -185,8 +185,13 @@ rm -rf $RPM_BUILD_ROOT
185185
%{_datadir}/git-core/
186186
%doc README COPYING Documentation/*.txt
187187
%{!?_without_docs: %doc Documentation/*.html Documentation/howto}
188+
%{!?_without_docs: %doc Documentation/technical}
188189

189190
%changelog
191+
* Tue May 13 2007 Quy Tonthat <[email protected]>
192+
- Added lib files for git-gui
193+
- Added Documentation/technical (As needed by Git Users Manual)
194+
190195
* Tue May 8 2007 Quy Tonthat <[email protected]>
191196
- Added howto files
192197

t/t1300-repo-config.sh

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -407,6 +407,25 @@ EOF
407407
test_expect_success "section was removed properly" \
408408
"git diff -u expect .git/config"
409409

410+
rm .git/config
411+
412+
cat > expect << EOF
413+
[gitcvs]
414+
enabled = true
415+
dbname = %Ggitcvs2.%a.%m.sqlite
416+
[gitcvs "ext"]
417+
dbname = %Ggitcvs1.%a.%m.sqlite
418+
EOF
419+
420+
test_expect_success 'section ending' '
421+
422+
git-config gitcvs.enabled true &&
423+
git-config gitcvs.ext.dbname %Ggitcvs1.%a.%m.sqlite &&
424+
git-config gitcvs.dbname %Ggitcvs2.%a.%m.sqlite &&
425+
cmp .git/config expect
426+
427+
'
428+
410429
test_expect_success numbers '
411430
412431
git-config kilo.gram 1k &&

t/t9100-git-svn-basic.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -229,7 +229,7 @@ test_expect_failure 'exit if init-ing a would clobber a URL' "
229229

230230
test_expect_success \
231231
'init allows us to connect to another directory in the same repo' "
232-
git-svn init -i bar $svnrepo/bar &&
232+
git-svn init --minimize-url -i bar $svnrepo/bar &&
233233
git config --get svn-remote.svn.fetch \
234234
'^bar:refs/remotes/bar$' &&
235235
git config --get svn-remote.svn.fetch \

t/t9104-git-svn-follow-parent.sh

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ test_expect_success 'initialize repo' "
2828
"
2929

3030
test_expect_success 'init and fetch a moved directory' "
31-
git-svn init -i thunk $svnrepo/thunk &&
31+
git-svn init --minimize-url -i thunk $svnrepo/thunk &&
3232
git-svn fetch -i thunk &&
3333
test \"\`git-rev-parse --verify refs/remotes/thunk@2\`\" \
3434
= \"\`git-rev-parse --verify refs/remotes/thunk~1\`\" &&
@@ -68,7 +68,8 @@ test_expect_success 'follow larger parent' "
6868
echo hi > import/trunk/thunk/bump/thud/file &&
6969
svn import -m 'import a larger parent' import $svnrepo/larger-parent &&
7070
svn cp -m 'hi' $svnrepo/larger-parent $svnrepo/another-larger &&
71-
git-svn init -i larger $svnrepo/another-larger/trunk/thunk/bump/thud &&
71+
git-svn init --minimize-url -i larger \
72+
$svnrepo/another-larger/trunk/thunk/bump/thud &&
7273
git-svn fetch -i larger &&
7374
git-rev-parse --verify refs/remotes/larger &&
7475
git-rev-parse --verify \
@@ -90,14 +91,14 @@ test_expect_success 'follow higher-level parent' "
9091
cd ..
9192
svn mkdir -m 'new glob at top level' $svnrepo/glob &&
9293
svn mv -m 'move blob down a level' $svnrepo/blob $svnrepo/glob/blob &&
93-
git-svn init -i blob $svnrepo/glob/blob &&
94+
git-svn init --minimize-url -i blob $svnrepo/glob/blob &&
9495
git-svn fetch -i blob
9596
"
9697

9798
test_expect_success 'follow deleted directory' "
9899
svn mv -m 'bye!' $svnrepo/glob/blob/hi $svnrepo/glob/blob/bye &&
99100
svn rm -m 'remove glob' $svnrepo/glob &&
100-
git-svn init -i glob $svnrepo/glob &&
101+
git-svn init --minimize-url -i glob $svnrepo/glob &&
101102
git-svn fetch -i glob &&
102103
test \"\`git cat-file blob refs/remotes/glob:blob/bye\`\" = hi &&
103104
test \"\`git ls-tree refs/remotes/glob | wc -l \`\" -eq 1
@@ -127,7 +128,7 @@ test_expect_success 'follow-parent avoids deleting relevant info' "
127128
poke native/t/c.t &&
128129
svn commit -m 'reorg test' &&
129130
cd .. &&
130-
git-svn init -i r9270-t \
131+
git-svn init --minimize-url -i r9270-t \
131132
$svnrepo/r9270/trunk/subversion/bindings/swig/perl/native/t &&
132133
git-svn fetch -i r9270-t &&
133134
test \`git rev-list r9270-t | wc -l\` -eq 2 &&
@@ -137,7 +138,7 @@ test_expect_success 'follow-parent avoids deleting relevant info' "
137138

138139
test_expect_success "track initial change if it was only made to parent" "
139140
svn cp -m 'wheee!' $svnrepo/r9270/trunk $svnrepo/r9270/drunk &&
140-
git-svn init -i r9270-d \
141+
git-svn init --minimize-url -i r9270-d \
141142
$svnrepo/r9270/drunk/subversion/bindings/swig/perl/native/t &&
142143
git-svn fetch -i r9270-d &&
143144
test \`git rev-list r9270-d | wc -l\` -eq 3 &&

t/t9105-git-svn-commit-diff.sh

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ test_expect_success 'test the commit-diff command' "
3333

3434
test_expect_success 'commit-diff to a sub-directory (with git-svn config)' "
3535
svn import -m 'sub-directory' import $svnrepo/subdir &&
36-
git-svn init $svnrepo/subdir &&
36+
git-svn init --minimize-url $svnrepo/subdir &&
3737
git-svn fetch &&
3838
git-svn commit-diff -r3 '$prev' '$head' &&
3939
svn cat $svnrepo/subdir/readme > readme.2 &&

t/t9110-git-svn-use-svm-props.sh

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,10 @@ test_description='git-svn useSvmProps test'
99

1010
test_expect_success 'load svm repo' "
1111
svnadmin load -q $rawsvnrepo < ../t9110/svm.dump &&
12-
git-svn init -R arr -i bar $svnrepo/mirror/arr &&
13-
git-svn init -R argh -i dir $svnrepo/mirror/argh &&
14-
git-svn init -R argh -i e $svnrepo/mirror/argh/a/b/c/d/e &&
12+
git-svn init --minimize-url -R arr -i bar $svnrepo/mirror/arr &&
13+
git-svn init --minimize-url -R argh -i dir $svnrepo/mirror/argh &&
14+
git-svn init --minimize-url -R argh -i e \
15+
$svnrepo/mirror/argh/a/b/c/d/e &&
1516
git-config svn.useSvmProps true &&
1617
git-svn fetch --all
1718
"

t/t9111-git-svn-use-svnsync-props.sh

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,9 +9,9 @@ test_description='git-svn useSvnsyncProps test'
99

1010
test_expect_success 'load svnsync repo' "
1111
svnadmin load -q $rawsvnrepo < ../t9111/svnsync.dump &&
12-
git-svn init -R arr -i bar $svnrepo/bar &&
13-
git-svn init -R argh -i dir $svnrepo/dir &&
14-
git-svn init -R argh -i e $svnrepo/dir/a/b/c/d/e &&
12+
git-svn init --minimize-url -R arr -i bar $svnrepo/bar &&
13+
git-svn init --minimize-url -R argh -i dir $svnrepo/dir &&
14+
git-svn init --minimize-url -R argh -i e $svnrepo/dir/a/b/c/d/e &&
1515
git-config svn.useSvnsyncProps true &&
1616
git-svn fetch --all
1717
"

tree-walk.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@ static inline int tree_entry_len(const char *name, const unsigned char *sha1)
2727

2828
void update_tree_entry(struct tree_desc *);
2929
void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size);
30-
const unsigned char *tree_entry_extract(struct tree_desc *, const char **, unsigned int *);
3130

3231
/* Helper function that does both of the above and returns true for success */
3332
int tree_entry(struct tree_desc *, struct name_entry *);

0 commit comments

Comments
 (0)