* 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;
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!
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);
/* 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);
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
# 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") };
# 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 = <TEMPFILE>; }
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 = <TEMPFILE>; }
is($blobcontents, $test_text, "cat_blob: roundtrip data");
+ close TEMPFILE;
+ unlink $tmpfile;
# paths
is($r->repo_path, "./.git", "repo_path");