Merge branch 'maint'

* maint:
  Replace the word 'update-cache' by 'update-index' everywhere
  cvsimport: fix usage of cvsimport.module
  t7003-filter-branch: Fix test of a failing --msg-filter.
  cvsimport: miscellaneous packed-ref fixes
  cvsimport: use rev-parse to support packed refs
  Add basic cvsimport tests
This commit is contained in:
Junio C Hamano
2007-11-30 16:21:33 -08:00
12 changed files with 155 additions and 40 deletions

View File

@ -3707,7 +3707,7 @@ should use the `--remove` and `--add` flags respectively.
NOTE! A `--remove` flag does 'not' mean that subsequent filenames will NOTE! A `--remove` flag does 'not' mean that subsequent filenames will
necessarily be removed: if the files still exist in your directory necessarily be removed: if the files still exist in your directory
structure, the index will be updated with their new status, not structure, the index will be updated with their new status, not
removed. The only thing `--remove` means is that update-cache will be removed. The only thing `--remove` means is that update-index will be
considering a removed file to be a valid thing, and if the file really considering a removed file to be a valid thing, and if the file really
does not exist any more, it will update the index accordingly. does not exist any more, it will update the index accordingly.

View File

@ -111,7 +111,7 @@ all::
# times (my ext3 doesn't). # times (my ext3 doesn't).
# #
# Define USE_STDEV below if you want git to care about the underlying device # Define USE_STDEV below if you want git to care about the underlying device
# change being considered an inode change from the update-cache perspective. # change being considered an inode change from the update-index perspective.
# #
# Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8 # Define ASCIIDOC8 if you want to format documentation with AsciiDoc 8
# #

View File

@ -415,7 +415,7 @@ GIT_PARSE_WITH(iconv))
# times (my ext3 doesn't). # times (my ext3 doesn't).
# #
# Define USE_STDEV below if you want git to care about the underlying device # Define USE_STDEV below if you want git to care about the underlying device
# change being considered an inode change from the update-cache perspective. # change being considered an inode change from the update-index perspective.
## Output files ## Output files

View File

@ -108,10 +108,6 @@ sub read_repo_config {
} }
} }
} }
if (@ARGV == 0) {
chomp(my $module = `git-repo-config --get cvsimport.module`);
push(@ARGV, $module);
}
} }
my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:"; my $opts = "haivmkuo:d:p:r:C:z:s:M:P:A:S:L:";
@ -119,6 +115,10 @@ read_repo_config($opts);
getopts($opts) or usage(); getopts($opts) or usage();
usage if $opt_h; usage if $opt_h;
if (@ARGV == 0) {
chomp(my $module = `git-repo-config --get cvsimport.module`);
push(@ARGV, $module) if $? == 0;
}
@ARGV <= 1 or usage("You can't specify more than one CVS module"); @ARGV <= 1 or usage("You can't specify more than one CVS module");
if ($opt_d) { if ($opt_d) {
@ -527,18 +527,12 @@ sub is_sha1 {
return $s =~ /^[a-f0-9]{40}$/; return $s =~ /^[a-f0-9]{40}$/;
} }
sub get_headref ($$) { sub get_headref ($) {
my $name = shift; my $name = shift;
my $git_dir = shift; my $r = `git rev-parse --verify '$name' 2>/dev/null`;
return undef unless $? == 0;
my $f = "$git_dir/$remote/$name"; chomp $r;
if (open(my $fh, $f)) { return $r;
chomp(my $r = <$fh>);
is_sha1($r) or die "Cannot get head id for $name ($r): $!";
return $r;
}
die "unable to open $f: $!" unless $! == POSIX::ENOENT;
return undef;
} }
-d $git_tree -d $git_tree
@ -698,7 +692,8 @@ my (@old,@new,@skipped,%ignorebranch);
$ignorebranch{'#CVSPS_NO_BRANCH'} = 1; $ignorebranch{'#CVSPS_NO_BRANCH'} = 1;
sub commit { sub commit {
if ($branch eq $opt_o && !$index{branch} && !get_headref($branch, $git_dir)) { if ($branch eq $opt_o && !$index{branch} &&
!get_headref("$remote/$branch")) {
# looks like an initial commit # looks like an initial commit
# use the index primed by git-init # use the index primed by git-init
$ENV{GIT_INDEX_FILE} = "$git_dir/index"; $ENV{GIT_INDEX_FILE} = "$git_dir/index";
@ -722,7 +717,7 @@ sub commit {
update_index(@old, @new); update_index(@old, @new);
@old = @new = (); @old = @new = ();
my $tree = write_tree(); my $tree = write_tree();
my $parent = get_headref($last_branch, $git_dir); my $parent = get_headref("$remote/$last_branch");
print "Parent ID " . ($parent ? $parent : "(empty)") . "\n" if $opt_v; print "Parent ID " . ($parent ? $parent : "(empty)") . "\n" if $opt_v;
my @commit_args; my @commit_args;
@ -733,7 +728,7 @@ sub commit {
foreach my $rx (@mergerx) { foreach my $rx (@mergerx) {
next unless $logmsg =~ $rx && $1; next unless $logmsg =~ $rx && $1;
my $mparent = $1 eq 'HEAD' ? $opt_o : $1; my $mparent = $1 eq 'HEAD' ? $opt_o : $1;
if (my $sha1 = get_headref($mparent, $git_dir)) { if (my $sha1 = get_headref("$remote/$mparent")) {
push @commit_args, '-p', $mparent; push @commit_args, '-p', $mparent;
print "Merge parent branch: $mparent\n" if $opt_v; print "Merge parent branch: $mparent\n" if $opt_v;
} }
@ -870,29 +865,27 @@ while (<CVS>) {
print STDERR "Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\n"; print STDERR "Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\n";
$ancestor = $opt_o; $ancestor = $opt_o;
} }
if (-f "$git_dir/$remote/$branch") { if (defined get_headref("$remote/$branch")) {
print STDERR "Branch $branch already exists!\n"; print STDERR "Branch $branch already exists!\n";
$state=11; $state=11;
next; next;
} }
unless (open(H,"$git_dir/$remote/$ancestor")) { my $id = get_headref("$remote/$ancestor");
if (!$id) {
print STDERR "Branch $ancestor does not exist!\n"; print STDERR "Branch $ancestor does not exist!\n";
$ignorebranch{$branch} = 1; $ignorebranch{$branch} = 1;
$state=11; $state=11;
next; next;
} }
chomp(my $id = <H>);
close(H); system(qw(git update-ref -m cvsimport),
unless (open(H,"> $git_dir/$remote/$branch")) { "$remote/$branch", $id);
print STDERR "Could not create branch $branch: $!\n"; if($? != 0) {
print STDERR "Could not create branch $branch\n";
$ignorebranch{$branch} = 1; $ignorebranch{$branch} = 1;
$state=11; $state=11;
next; next;
} }
print H "$id\n"
or die "Could not write branch $branch: $!";
close(H)
or die "Could not write branch $branch: $!";
} }
$last_branch = $branch if $branch ne $last_branch; $last_branch = $branch if $branch ne $last_branch;
$state = 9; $state = 9;
@ -1004,7 +997,7 @@ if ($orig_branch) {
$orig_branch = "master"; $orig_branch = "master";
print "DONE; creating $orig_branch branch\n" if $opt_v; print "DONE; creating $orig_branch branch\n" if $opt_v;
system("git-update-ref", "refs/heads/master", "$remote/$opt_o") system("git-update-ref", "refs/heads/master", "$remote/$opt_o")
unless -f "$git_dir/refs/heads/master"; unless defined get_headref('refs/heads/master');
system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o") system("git-symbolic-ref", "$remote/HEAD", "$remote/$opt_o")
if ($opt_r && $opt_o ne 'HEAD'); if ($opt_r && $opt_o ne 'HEAD');
system('git-update-ref', 'HEAD', "$orig_branch"); system('git-update-ref', 'HEAD', "$orig_branch");

View File

@ -16,7 +16,7 @@ cat path0 >path1
chmod +x path1 chmod +x path1
test_expect_success \ test_expect_success \
'update-cache --add two files with and without +x.' \ 'update-index --add two files with and without +x.' \
'git update-index --add path0 path1' 'git update-index --add path0 path1'
mv path0 path0- mv path0 path0-

View File

@ -27,7 +27,7 @@ Line 15
' '
test_expect_success \ test_expect_success \
'update-cache --add a file.' \ 'update-index --add a file.' \
'git update-index --add path0' 'git update-index --add path0'
test_expect_success \ test_expect_success \

View File

@ -90,7 +90,7 @@ diff --git a/Documentation/git.txt b/Documentation/git.txt
diff --git a/Makefile b/Makefile diff --git a/Makefile b/Makefile
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -30,7 +30,7 @@ PROG= git-update-cache git-diff-files @@ -30,7 +30,7 @@ PROG= git-update-index git-diff-files
git-checkout-cache git-diff-tree git-rev-tree git-ls-files \ git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
git-check-files git-ls-tree git-merge-base git-merge-cache \ git-check-files git-ls-tree git-merge-base git-merge-cache \
git-unpack-file git-export git-diff-cache git-convert-cache \ git-unpack-file git-export git-diff-cache git-convert-cache \

View File

@ -9,7 +9,7 @@ diff --git a/Makefile b/Makefile
- git-deltafy-script - git-deltafy-script
+ git-deltafy-script git-fetch-script + git-deltafy-script git-fetch-script
PROG= git-update-cache git-diff-files git-init-db git-write-tree \ PROG= git-update-index git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \ git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff --git a/git-pull-script b/git-fetch-script diff --git a/git-pull-script b/git-fetch-script
similarity index 87% similarity index 87%

View File

@ -200,7 +200,7 @@ diff a/Documentation/git.txt b/Documentation/git.txt
diff a/Makefile b/Makefile diff a/Makefile b/Makefile
--- a/Makefile --- a/Makefile
+++ b/Makefile +++ b/Makefile
@@ -30,7 +30,7 @@ PROG= git-update-cache git-diff-files @@ -30,7 +30,7 @@ PROG= git-update-index git-diff-files
git-checkout-cache git-diff-tree git-rev-tree git-ls-files \ git-checkout-cache git-diff-tree git-rev-tree git-ls-files \
git-check-files git-ls-tree git-merge-base git-merge-cache \ git-check-files git-ls-tree git-merge-base git-merge-cache \
git-unpack-file git-export git-diff-cache git-convert-cache \ git-unpack-file git-export git-diff-cache git-convert-cache \

View File

@ -8,7 +8,7 @@ diff a/Makefile b/Makefile
- git-deltafy-script - git-deltafy-script
+ git-deltafy-script git-fetch-script + git-deltafy-script git-fetch-script
PROG= git-update-cache git-diff-files git-init-db git-write-tree \ PROG= git-update-index git-diff-files git-init-db git-write-tree \
git-read-tree git-commit-tree git-cat-file git-fsck-cache \ git-read-tree git-commit-tree git-cat-file git-fsck-cache \
diff a/git-fetch-script b/git-fetch-script diff a/git-fetch-script b/git-fetch-script
--- /dev/null --- /dev/null

View File

@ -114,7 +114,7 @@ test_expect_success 'use index-filter to move into a subdirectory' '
test_expect_success 'stops when msg filter fails' ' test_expect_success 'stops when msg filter fails' '
old=$(git rev-parse HEAD) && old=$(git rev-parse HEAD) &&
! git-filter-branch -f --msg-filter false && ! git-filter-branch -f --msg-filter false HEAD &&
test $old = $(git rev-parse HEAD) && test $old = $(git rev-parse HEAD) &&
rm -rf .git-rewrite rm -rf .git-rewrite
' '

122
t/t9600-cvsimport.sh Executable file
View File

@ -0,0 +1,122 @@
#!/bin/sh
test_description='git-cvsimport basic tests'
. ./test-lib.sh
if ! ( type cvs && type cvsps ) >/dev/null 2>&1
then
test_expect_success 'skipping cvsimport tests, cvs/cvsps not found' ''
test_done
exit
fi
CVSROOT=$(pwd)/cvsroot
export CVSROOT
# for clean cvsps cache
HOME=$(pwd)
export HOME
test_expect_success 'setup cvsroot' 'cvs init'
test_expect_success 'setup a cvs module' '
mkdir $CVSROOT/module &&
cvs co -d module-cvs module &&
cd module-cvs &&
cat <<EOF >o_fortuna &&
O Fortuna
velut luna
statu variabilis,
semper crescis
aut decrescis;
vita detestabilis
nunc obdurat
et tunc curat
ludo mentis aciem,
egestatem,
potestatem
dissolvit ut glaciem.
EOF
cvs add o_fortuna &&
cat <<EOF >message &&
add "O Fortuna" lyrics
These public domain lyrics make an excellent sample text.
EOF
cvs commit -F message &&
cd ..
'
test_expect_success 'import a trivial module' '
git cvsimport -a -z 0 -C module-git module &&
git diff module-cvs/o_fortuna module-git/o_fortuna
'
test_expect_success 'pack refs' 'cd module-git && git gc && cd ..'
test_expect_success 'update cvs module' '
cd module-cvs &&
cat <<EOF >o_fortuna &&
O Fortune,
like the moon
you are changeable,
ever waxing
and waning;
hateful life
first oppresses
and then soothes
as fancy takes it;
poverty
and power
it melts them like ice.
EOF
cat <<EOF >message &&
translate to English
My Latin is terrible.
EOF
cvs commit -F message &&
cd ..
'
test_expect_success 'update git module' '
cd module-git &&
git cvsimport -a -z 0 module &&
git merge origin &&
cd .. &&
git diff module-cvs/o_fortuna module-git/o_fortuna
'
test_expect_success 'update cvs module' '
cd module-cvs &&
echo 1 >tick &&
cvs add tick &&
cvs commit -m 1
cd ..
'
test_expect_success 'cvsimport.module config works' '
cd module-git &&
git config cvsimport.module module &&
git cvsimport -a -z0 &&
git merge origin &&
cd .. &&
git diff module-cvs/tick module-git/tick
'
test_done