remove shellquote usage for tags
use ',' to encode '/' in "archivename/foo--bar--0.0" so we can allow "--branch"-less trees which are valid in Arch ("archivename/foo--0.0") Signed-off-by: Eric Wong <normalperson@yhbt.net> Signed-off-by: Martin Langhoff <martin@catalyst.net.nz>
Eric Wong committed
Nov 12, 2005 at 01:25 UTC
a7fb51d3d4d303d61831b2fe5127a088b050e60b
1 file changed
+28
-27
git-archimport.perl
+28
-27
@@ -52,6 +52,7 @@ $ENV{'TZ'}="UTC";
52
53
my $git_dir = $ENV{"GIT_DIR"} || ".git";
54
$ENV{"GIT_DIR"} = $git_dir;
55
+my $ptag_dir = "$git_dir/archimport/tags";
56
57
our($opt_h,$opt_v, $opt_T,
58
$opt_C,$opt_t);
@@ -195,16 +196,19 @@ unless (-d $git_dir) { # initial import
196
opendir(DIR, "$git_dir/archimport/tags")
197
|| die "can't opendir: $!";
198
while (my $file = readdir(DIR)) {
198
- # skip non-interesting-files
199
- next unless -f "$git_dir/archimport/tags/$file";
200
- next if $file =~ m/--base-0$/; # don't care for base-0
199
+ # skip non-interesting-files
200
+ next unless -f "$ptag_dir/$file";
201
+
202
+ # convert first '--' to '/' from old git-archimport to use
203
+ # as an archivename/c--b--v private tag
204
+ if ($file !~ m!,!) {
205
+ my $oldfile = $file;
206
+ $file =~ s!--!,!;
207
+ print STDERR "converting old tag $oldfile to $file\n";
208
+ rename("$ptag_dir/$oldfile", "$ptag_dir/$file") or die $!;
209
+ }
210
my $sha = ptag($file);
211
chomp $sha;
203
- # reconvert the 3rd '--' sequence from the end
204
- # into a slash
205
- # $file = reverse $file;
206
- # $file =~ s!^(.+?--.+?--.+?--.+?)--(.+)$!$1/$2!;
207
- # $file = reverse $file;
212
$rptags{$sha} = $file;
213
}
214
closedir DIR;
@@ -581,19 +585,20 @@ sub parselog {
585
# write/read a tag
586
sub tag {
587
my ($tag, $commit) = @_;
584
- $tag =~ s|/|--|g;
585
- $tag = shell_quote($tag);
588
+
589
+ # don't use subdirs for tags yet, it could screw up other porcelains
590
+ $tag =~ s|/|,|;
591
592
if ($commit) {
588
- open(C,">$git_dir/refs/tags/$tag")
593
+ open(C,">","$git_dir/refs/tags/$tag")
594
or die "Cannot create tag $tag: $!\n";
595
print C "$commit\n"
596
or die "Cannot write tag $tag: $!\n";
597
close(C)
598
or die "Cannot write tag $tag: $!\n";
594
- print " * Created tag ' $tag' on '$commit'\n" if $opt_v;
599
+ print " * Created tag '$tag' on '$commit'\n" if $opt_v;
600
} else { # read
596
- open(C,"<$git_dir/refs/tags/$tag")
601
+ open(C,"<","$git_dir/refs/tags/$tag")
602
or die "Cannot read tag $tag: $!\n";
603
$commit = <C>;
604
chomp $commit;
@@ -608,15 +613,16 @@ sub tag {
613
# reads fail softly if the tag isn't there
614
sub ptag {
615
my ($tag, $commit) = @_;
611
- $tag =~ s|/|--|g;
612
- $tag = shell_quote($tag);
616
+
617
+ # don't use subdirs for tags yet, it could screw up other porcelains
618
+ $tag =~ s|/|,|g;
619
614
- unless (-d "$git_dir/archimport/tags") {
615
- mkpath("$git_dir/archimport/tags");
616
- }
620
+ my $tag_file = "$ptag_dir/$tag";
621
+ my $tag_branch_dir = dirname($tag_file);
622
+ mkpath($tag_branch_dir) unless (-d $tag_branch_dir);
623
624
if ($commit) { # write
619
- open(C,">$git_dir/archimport/tags/$tag")
625
+ open(C,">",$tag_file)
626
or die "Cannot create tag $tag: $!\n";
627
print C "$commit\n"
628
or die "Cannot write tag $tag: $!\n";
@@ -626,10 +632,10 @@ sub ptag {
632
unless $tag =~ m/--base-0$/;
633
} else { # read
634
# if the tag isn't there, return 0
629
- unless ( -s "$git_dir/archimport/tags/$tag") {
635
+ unless ( -s $tag_file) {
636
return 0;
637
}
632
- open(C,"<$git_dir/archimport/tags/$tag")
638
+ open(C,"<",$tag_file)
639
or die "Cannot read tag $tag: $!\n";
640
$commit = <C>;
641
chomp $commit;
@@ -779,12 +785,7 @@ sub commitid2pset {
785
chomp $commitid;
786
my $name = $rptags{$commitid}
787
|| die "Cannot find reverse tag mapping for $commitid";
782
- # the keys in %rptag are slightly munged; unmunge
783
- # reconvert the 3rd '--' sequence from the end
784
- # into a slash
785
- $name = reverse $name;
786
- $name =~ s!^(.+?--.+?--.+?--.+?)--(.+)$!$1/$2!;
787
- $name = reverse $name;
788
+ $name =~ s|,|/|;
789
my $ps = $psets{$name}
790
|| (print Dumper(sort keys %psets)) && die "Cannot find patchset for $name";
791
return $ps;