summaryrefslogtreecommitdiff
path: root/git-cvsimport.perl
diff options
context:
space:
mode:
authorAndy Whitcroft <apw@shadowen.org>2006-09-20 17:37:04 +0100
committerJunio C Hamano <junkio@cox.net>2006-09-20 10:21:46 -0700
commit1f24c58724a64e7b100ae8d8e0318c9e564df88b (patch)
tree377899388ab1b981873ac8d34d9e818290393f06 /git-cvsimport.perl
parent9f613ddd21cbd05bfc139d9b1551b5780aa171f6 (diff)
downloadgit-1f24c58724a64e7b100ae8d8e0318c9e564df88b.tar.gz
cvsimport: move over to using git-for-each-ref to read refs.
cvsimport opens all of the files in $GIT_DIR/refs/heads and reads out the sha1's in order to work out what time the last commit on that branch was made (in CVS) thus allowing incremental updates. However, this takes no account of hierachical refs naming producing the following error for each directory in $GIT_DIR/refs: Use of uninitialized value in chomp at /usr/bin/git-cvsimport line 503. Use of uninitialized value in concatenation (.) or string at /usr/bin/git-cvsimport line 505. usage: git-cat-file [-t|-s|-e|-p|<type>] <sha1> Take advantage of the new packed refs work to use the new for-each-ref iterator to get this information. Signed-off-by: Andy Whitcroft <apw@shadowen.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git-cvsimport.perl')
-rwxr-xr-xgit-cvsimport.perl25
1 files changed, 10 insertions, 15 deletions
diff --git a/git-cvsimport.perl b/git-cvsimport.perl
index e5a00a1285..14e2c6131b 100755
--- a/git-cvsimport.perl
+++ b/git-cvsimport.perl
@@ -495,22 +495,17 @@ unless(-d $git_dir) {
$tip_at_start = `git-rev-parse --verify HEAD`;
# Get the last import timestamps
- opendir(D,"$git_dir/refs/heads");
- while(defined(my $head = readdir(D))) {
- next if $head =~ /^\./;
- open(F,"$git_dir/refs/heads/$head")
- or die "Bad head branch: $head: $!\n";
- chomp(my $ftag = <F>);
- close(F);
- open(F,"git-cat-file commit $ftag |");
- while(<F>) {
- next unless /^author\s.*\s(\d+)\s[-+]\d{4}$/;
- $branch_date{$head} = $1;
- last;
- }
- close(F);
+ my $fmt = '($ref, $author) = (%(refname), %(author));';
+ open(H, "git-for-each-ref --perl --format='$fmt' refs/heads |") or
+ die "Cannot run git-for-each-ref: $!\n";
+ while(defined(my $entry = <H>)) {
+ my ($ref, $author);
+ eval($entry) || die "cannot eval refs list: $@";
+ my ($head) = ($ref =~ m|^refs/heads/(.*)|);
+ $author =~ /^.*\s(\d+)\s[-+]\d{4}$/;
+ $branch_date{$head} = $1;
}
- closedir(D);
+ close(H);
}
-d $git_dir