1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-28 04:36:10 +02:00

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
commit 65c6a4696a
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
necessarily be removed: if the files still exist in your directory
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
does not exist any more, it will update the index accordingly.

View File

@ -111,7 +111,7 @@ all::
# times (my ext3 doesn't).
#
# 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
#

View File

@ -415,7 +415,7 @@ GIT_PARSE_WITH(iconv))
# times (my ext3 doesn't).
#
# 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

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:";
@ -119,6 +115,10 @@ sub read_repo_config {
getopts($opts) or usage();
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");
if ($opt_d) {
@ -527,18 +527,12 @@ sub is_sha1 {
return $s =~ /^[a-f0-9]{40}$/;
}
sub get_headref ($$) {
my $name = shift;
my $git_dir = shift;
my $f = "$git_dir/$remote/$name";
if (open(my $fh, $f)) {
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;
sub get_headref ($) {
my $name = shift;
my $r = `git rev-parse --verify '$name' 2>/dev/null`;
return undef unless $? == 0;
chomp $r;
return $r;
}
-d $git_tree
@ -698,7 +692,8 @@ ()
$ignorebranch{'#CVSPS_NO_BRANCH'} = 1;
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
# use the index primed by git-init
$ENV{GIT_INDEX_FILE} = "$git_dir/index";
@ -722,7 +717,7 @@ sub commit {
update_index(@old, @new);
@old = @new = ();
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;
my @commit_args;
@ -733,7 +728,7 @@ sub commit {
foreach my $rx (@mergerx) {
next unless $logmsg =~ $rx && $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;
print "Merge parent branch: $mparent\n" if $opt_v;
}
@ -870,29 +865,27 @@ sub commit {
print STDERR "Branch $branch erroneously stems from itself -- changed ancestor to $opt_o\n";
$ancestor = $opt_o;
}
if (-f "$git_dir/$remote/$branch") {
if (defined get_headref("$remote/$branch")) {
print STDERR "Branch $branch already exists!\n";
$state=11;
next;
}
unless (open(H,"$git_dir/$remote/$ancestor")) {
my $id = get_headref("$remote/$ancestor");
if (!$id) {
print STDERR "Branch $ancestor does not exist!\n";
$ignorebranch{$branch} = 1;
$state=11;
next;
}
chomp(my $id = <H>);
close(H);
unless (open(H,"> $git_dir/$remote/$branch")) {
print STDERR "Could not create branch $branch: $!\n";
system(qw(git update-ref -m cvsimport),
"$remote/$branch", $id);
if($? != 0) {
print STDERR "Could not create branch $branch\n";
$ignorebranch{$branch} = 1;
$state=11;
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;
$state = 9;
@ -1004,7 +997,7 @@ sub commit {
$orig_branch = "master";
print "DONE; creating $orig_branch branch\n" if $opt_v;
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")
if ($opt_r && $opt_o ne 'HEAD');
system('git-update-ref', 'HEAD', "$orig_branch");

View File

@ -16,7 +16,7 @@ cat path0 >path1
chmod +x path1
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'
mv path0 path0-

View File

@ -27,7 +27,7 @@ Line 15
'
test_expect_success \
'update-cache --add a file.' \
'update-index --add a file.' \
'git update-index --add path0'
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
--- a/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-check-files git-ls-tree git-merge-base git-merge-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-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 \
diff --git a/git-pull-script b/git-fetch-script
similarity index 87%

View File

@ -200,7 +200,7 @@ diff a/Documentation/git.txt b/Documentation/git.txt
diff a/Makefile b/Makefile
--- a/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-check-files git-ls-tree git-merge-base git-merge-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-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 \
diff a/git-fetch-script b/git-fetch-script
--- /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' '
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) &&
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