From: Junio C Hamano Date: Tue, 16 Sep 2008 08:24:58 +0000 (-0700) Subject: Merge branch 'maint' X-Git-Tag: v1.6.1-rc1~235 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/97d7fee2cb068f215a593c6e5623b265db45d3bc?ds=inline;hp=-c Merge branch 'maint' * maint: Cosmetical command name fix Start conforming code to "git subcmd" style part 3 t9700/test.pl: remove File::Temp requirement t9700/test.pl: avoid bareword 'STDERR' in 3-argument open() --- 97d7fee2cb068f215a593c6e5623b265db45d3bc diff --combined builtin-read-tree.c index 362216b272,ac219ac2db..0706c95818 --- a/builtin-read-tree.c +++ b/builtin-read-tree.c @@@ -64,7 -64,7 +64,7 @@@ static void prime_cache_tree(void } - static const char read_tree_usage[] = "git-read-tree ( | [[-m [--trivial] [--aggressive] | --reset | --prefix=] [-u | -i]] [--exclude-per-directory=] [--index-output=] [ []])"; + static const char read_tree_usage[] = "git read-tree ( | [[-m [--trivial] [--aggressive] | --reset | --prefix=] [-u | -i]] [--exclude-per-directory=] [--index-output=] [ []])"; static struct lock_file lock_file; @@@ -206,7 -206,6 +206,7 @@@ int cmd_read_tree(int argc, const char break; case 2: opts.fn = twoway_merge; + opts.initial_checkout = !active_nr; break; case 3: default: diff --combined builtin-update-index.c index ce83224756,9d19c51e8e..417f9724ab --- a/builtin-update-index.c +++ b/builtin-update-index.c @@@ -14,7 -14,7 +14,7 @@@ * Default to not allowing changes to the list of files. The * tool doesn't actually care, but this makes it harder to add * files to the revision control by mistake by doing something - * like "git-update-index *" and suddenly having all the object + * like "git update-index *" and suddenly having all the object * files be revision controlled. */ static int allow_add; @@@ -194,10 -194,6 +194,10 @@@ static int process_path(const char *pat int len; struct stat st; + len = strlen(path); + if (has_symlink_leading_path(len, path)) + return error("'%s' is beyond a symbolic link", path); + /* * First things first: get the stat information, to decide * what to do about the pathname! @@@ -205,6 -201,7 +205,6 @@@ if (lstat(path, &st) < 0) return process_lstat_error(path, errno); - len = strlen(path); if (S_ISDIR(st.st_mode)) return process_directory(path, len, &st); @@@ -313,18 -310,18 +313,18 @@@ static void read_index_info(int line_te /* This reads lines formatted in one of three formats: * * (1) mode SP sha1 TAB path - * The first format is what "git-apply --index-info" + * The first format is what "git apply --index-info" * reports, and used to reconstruct a partial tree * that is used for phony merge base tree when falling * back on 3-way merge. * * (2) mode SP type SP sha1 TAB path - * The second format is to stuff git-ls-tree output + * The second format is to stuff "git ls-tree" output * into the index file. * * (3) mode SP sha1 SP stage TAB path * This format is to put higher order stages into the - * index file and matches git-ls-files --stage output. + * index file and matches "git ls-files --stage" output. */ errno = 0; ul = strtoul(buf.buf, &ptr, 8); diff --combined t/t9700/test.pl index 851cea4a4b,504f95a47d..697daf3ffd --- a/t/t9700/test.pl +++ b/t/t9700/test.pl @@@ -9,12 -9,14 +9,11 @@@ use Test::More qw(no_plan) use Cwd; use File::Basename; - use File::Temp; BEGIN { use_ok('Git') } # set up -our $repo_dir = "trash directory"; our $abs_repo_dir = Cwd->cwd; -die "this must be run by calling the t/t97* shell script(s)\n" - if basename(Cwd->cwd) ne $repo_dir; ok(our $r = Git->repository(Directory => "."), "open repository"); # config @@@ -35,7 -37,7 +34,7 @@@ is($r->get_color("color.test.slot1", "r # Failure cases for config: # Save and restore STDERR; we will probably extract this into a # "dies_ok" method and possibly move the STDERR handling to Git.pm. - open our $tmpstderr, ">&", STDERR or die "cannot save STDERR"; close STDERR; + open our $tmpstderr, ">&STDERR" or die "cannot save STDERR"; close STDERR; eval { $r->config("test.dupstring") }; ok($@, "config: duplicate entry in scalar context fails"); eval { $r->config_bool("test.boolother") }; @@@ -66,21 -68,25 +65,25 @@@ is($r->ident_person("Name", "email", "1 # objects and hashes ok(our $file1hash = $r->command_oneline('rev-parse', "HEAD:file1"), "(get file hash)"); - our $tmpfile = File::Temp->new; - is($r->cat_blob($file1hash, $tmpfile), 15, "cat_blob: size"); + my $tmpfile = "file.tmp"; + open TEMPFILE, "+>$tmpfile" or die "Can't open $tmpfile: $!"; + is($r->cat_blob($file1hash, \*TEMPFILE), 15, "cat_blob: size"); our $blobcontents; - { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; } + { local $/; seek TEMPFILE, 0, 0; $blobcontents = ; } is($blobcontents, "changed file 1\n", "cat_blob: data"); - seek $tmpfile, 0, 0; + close TEMPFILE or die "Failed writing to $tmpfile: $!"; is(Git::hash_object("blob", $tmpfile), $file1hash, "hash_object: roundtrip"); - $tmpfile = File::Temp->new(); - print $tmpfile my $test_text = "test blob, to be inserted\n"; + open TEMPFILE, ">$tmpfile" or die "Can't open $tmpfile: $!"; + print TEMPFILE my $test_text = "test blob, to be inserted\n"; + close TEMPFILE or die "Failed writing to $tmpfile: $!"; like(our $newhash = $r->hash_and_insert_object($tmpfile), qr/[0-9a-fA-F]{40}/, "hash_and_insert_object: returns hash"); - $tmpfile = File::Temp->new; - is($r->cat_blob($newhash, $tmpfile), length $test_text, "cat_blob: roundtrip size"); - { local $/; seek $tmpfile, 0, 0; $blobcontents = <$tmpfile>; } + open TEMPFILE, "+>$tmpfile" or die "Can't open $tmpfile: $!"; + is($r->cat_blob($newhash, \*TEMPFILE), length $test_text, "cat_blob: roundtrip size"); + { local $/; seek TEMPFILE, 0, 0; $blobcontents = ; } is($blobcontents, $test_text, "cat_blob: roundtrip data"); + close TEMPFILE; + unlink $tmpfile; # paths is($r->repo_path, "./.git", "repo_path");