summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: d824cbb)
raw | patch | inline | side by side (parent: d824cbb)
author | Thomas Rast <trast@student.ethz.ch> | |
Sat, 27 Jun 2009 15:58:47 +0000 (17:58 +0200) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sat, 27 Jun 2009 18:14:53 +0000 (11:14 -0700) |
Lots of die() calls did not actually report the kind of error, which
can leave the user confused as to the real problem. Use die_errno()
where we check a system/library call that sets errno on failure, or
one of the following that wrap such calls:
Function Passes on error from
-------- --------------------
odb_pack_keep open
read_ancestry fopen
read_in_full xread
strbuf_read xread
strbuf_read_file open or strbuf_read_file
strbuf_readlink readlink
write_in_full xwrite
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
can leave the user confused as to the real problem. Use die_errno()
where we check a system/library call that sets errno on failure, or
one of the following that wrap such calls:
Function Passes on error from
-------- --------------------
odb_pack_keep open
read_ancestry fopen
read_in_full xread
strbuf_read xread
strbuf_read_file open or strbuf_read_file
strbuf_readlink readlink
write_in_full xwrite
Signed-off-by: Thomas Rast <trast@student.ethz.ch>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
30 files changed:
diff --git a/abspath.c b/abspath.c
index 649f34f83365db3513c5166b897c4f033831444d..4bee0ba1ec6fcf49e88b874f0a415f4220117c0a 100644 (file)
--- a/abspath.c
+++ b/abspath.c
if (*buf) {
if (!*cwd && !getcwd(cwd, sizeof(cwd)))
- die ("Could not get current working directory");
+ die_errno ("Could not get current working directory");
if (chdir(buf))
- die ("Could not switch to '%s'", buf);
+ die_errno ("Could not switch to '%s'", buf);
}
if (!getcwd(buf, PATH_MAX))
- die ("Could not get current working directory");
+ die_errno ("Could not get current working directory");
if (last_elem) {
int len = strlen(buf);
if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
len = readlink(buf, next_buf, PATH_MAX);
if (len < 0)
- die ("Invalid symlink: %s", buf);
+ die_errno ("Invalid symlink '%s'", buf);
if (PATH_MAX <= len)
die("symbolic link too long: %s", buf);
next_buf[len] = '\0';
}
if (*cwd && chdir(cwd))
- die ("Could not change back to '%s'", cwd);
+ die_errno ("Could not change back to '%s'", cwd);
return buf;
}
} else {
const char *cwd = get_pwd_cwd();
if (!cwd)
- die("Cannot determine the current working directory");
+ die_errno("Cannot determine the current working directory");
if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX)
die("Too long path: %.*s", 60, path);
}
diff --git a/builtin-add.c b/builtin-add.c
index c1b229a9d8a026ec88cdbf0492856021cacc8097..8f651c137a9d5e0f19e266d73c58f785c0e36af7 100644 (file)
--- a/builtin-add.c
+++ b/builtin-add.c
launch_editor(file, NULL, NULL);
if (stat(file, &st))
- die("Could not stat '%s'", file);
+ die_errno("Could not stat '%s'", file);
if (!st.st_size)
die("Empty patch. Aborted.");
diff --git a/builtin-apply.c b/builtin-apply.c
index 6526c087b99c021eebb53454966ed649c08bb833..dbc7f2165d5e8e700a7d7cff527eb6a99ef07184 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2823,8 +2823,8 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
} else {
if (!cached) {
if (lstat(path, &st) < 0)
- die("unable to stat newly created file %s",
- path);
+ die_errno("unable to stat newly created file '%s'",
+ path);
fill_stat_cache_info(ce, &st);
}
if (write_sha1_file(buf, size, blob_type, ce->sha1) < 0)
@@ -2913,7 +2913,7 @@ static void create_one_file(char *path, unsigned mode, const char *buf, unsigned
++nr;
}
}
- die("unable to write file %s mode %o", path, mode);
+ die_errno("unable to write file '%s' mode %o", path, mode);
}
static void create_file(struct patch *patch)
diff --git a/builtin-archive.c b/builtin-archive.c
index 3c5a5a7822afebf87ef6eb1f89c7c54d76844161..f9a4bea41e95b9a34f190fc2b696c7394d0e0971 100644 (file)
--- a/builtin-archive.c
+++ b/builtin-archive.c
{
int output_fd = open(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
if (output_fd < 0)
- die("could not create archive file: %s ", output_file);
+ die_errno("could not create archive file '%s'", output_file);
if (output_fd != 1) {
if (dup2(output_fd, 1) < 0)
- die("could not redirect output");
+ die_errno("could not redirect output");
else
close(output_fd);
}
diff --git a/builtin-blame.c b/builtin-blame.c
index 7d8fbd5919a4b635f7fc536194f881fbb1f40ed4..fd6ca51eebb2234be429b47b572ae2f30592ff4e 100644 (file)
--- a/builtin-blame.c
+++ b/builtin-blame.c
@@ -2008,23 +2008,23 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
if (contents_from) {
if (stat(contents_from, &st) < 0)
- die("Cannot stat %s", contents_from);
+ die_errno("Cannot stat '%s'", contents_from);
read_from = contents_from;
}
else {
if (lstat(path, &st) < 0)
- die("Cannot lstat %s", path);
+ die_errno("Cannot lstat '%s'", path);
read_from = path;
}
mode = canon_mode(st.st_mode);
switch (st.st_mode & S_IFMT) {
case S_IFREG:
if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
- die("cannot open or read %s", read_from);
+ die_errno("cannot open or read '%s'", read_from);
break;
case S_IFLNK:
if (strbuf_readlink(&buf, read_from, st.st_size) < 0)
- die("cannot readlink %s", read_from);
+ die_errno("cannot readlink '%s'", read_from);
break;
default:
die("unsupported file type %s", read_from);
diff --git a/builtin-clone.c b/builtin-clone.c
index 5f34414ff712afe288105ba06b7281fd649189d0..d2b0757e538b9fbbcc20e48174886bf4f8b036d9 100644 (file)
--- a/builtin-clone.c
+++ b/builtin-clone.c
dir = opendir(src->buf);
if (!dir)
- die("failed to open %s", src->buf);
+ die_errno("failed to open '%s'", src->buf);
if (mkdir(dest->buf, 0777)) {
if (errno != EEXIST)
- die("failed to create directory %s", dest->buf);
+ die_errno("failed to create directory '%s'", dest->buf);
else if (stat(dest->buf, &buf))
- die("failed to stat %s", dest->buf);
+ die_errno("failed to stat '%s'", dest->buf);
else if (!S_ISDIR(buf.st_mode))
die("%s exists and is not a directory", dest->buf);
}
if (!link(src->buf, dest->buf))
continue;
if (option_local)
- die("failed to create link %s", dest->buf);
+ die_errno("failed to create link '%s'", dest->buf);
option_no_hardlinks = 1;
}
if (copy_file(dest->buf, src->buf, 0666))
- die("failed to copy file to %s", dest->buf);
+ die_errno("failed to copy file to '%s'", dest->buf);
}
closedir(dir);
}
diff --git a/builtin-commit.c b/builtin-commit.c
index 88c51bdd3ae996673fa8abaa97a3da98396f5f3e..4bcce06fbffdf10ec701dfbc0b6b90a11513f89e 100644 (file)
--- a/builtin-commit.c
+++ b/builtin-commit.c
if (isatty(0))
fprintf(stderr, "(reading log message from standard input)\n");
if (strbuf_read(&sb, 0, 0) < 0)
- die("could not read log from standard input");
+ die_errno("could not read log from standard input");
hook_arg1 = "message";
} else if (logfile) {
if (strbuf_read_file(&sb, logfile, 0) < 0)
/* Finally, get the commit message */
strbuf_reset(&sb);
if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
+ int saved_errno = errno;
rollback_index_files();
- die("could not read commit message");
+ die("could not read commit message: %s", strerror(saved_errno));
}
/* Truncate the message just before the diff, if any. */
diff --git a/builtin-fast-export.c b/builtin-fast-export.c
index 333d43894a70dcb68b6989218446c1008760afae..9a8a6fc6b1e98162a1548b40bd4281172e18d7b2 100644 (file)
--- a/builtin-fast-export.c
+++ b/builtin-fast-export.c
printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size);
if (size && fwrite(buf, size, 1, stdout) != 1)
- die ("Could not write blob %s", sha1_to_hex(sha1));
+ die_errno ("Could not write blob '%s'", sha1_to_hex(sha1));
printf("\n");
show_progress();
index 1248d5e3a3b87df7b72e3afeadbc082040acb7ea..9d524000b5ba4d9c7566edd5756b68d728ec362b 100644 (file)
--- a/builtin-fmt-merge-msg.c
+++ b/builtin-fmt-merge-msg.c
if (inpath && strcmp(inpath, "-")) {
in = fopen(inpath, "r");
if (!in)
- die("cannot open %s", inpath);
+ die_errno("cannot open '%s'", inpath);
}
if (strbuf_read(&input, fileno(in), 0) < 0)
diff --git a/builtin-fsck.c b/builtin-fsck.c
index a49dbe14c70ab1ac9154c5e1458847d597a81191..d0f48cdd2aed47b9ef124b8f925a7a7d1621c850 100644 (file)
--- a/builtin-fsck.c
+++ b/builtin-fsck.c
return;
}
if (!(f = fopen(filename, "w")))
- die("Could not open %s", filename);
+ die_errno("Could not open '%s'", filename);
if (obj->type == OBJ_BLOB) {
enum object_type type;
unsigned long size;
diff --git a/builtin-init-db.c b/builtin-init-db.c
index d1fa12a59efb34256b2cc80b03c637cc844d84ff..4a5600631c5800d7f9d844118f37c0672b89b581 100644 (file)
--- a/builtin-init-db.c
+++ b/builtin-init-db.c
memcpy(template + template_baselen, de->d_name, namelen+1);
if (lstat(path, &st_git)) {
if (errno != ENOENT)
- die("cannot stat %s", path);
+ die_errno("cannot stat '%s'", path);
}
else
exists = 1;
if (lstat(template, &st_template))
- die("cannot stat template %s", template);
+ die_errno("cannot stat template '%s'", template);
if (S_ISDIR(st_template.st_mode)) {
DIR *subdir = opendir(template);
int baselen_sub = baselen + namelen;
int template_baselen_sub = template_baselen + namelen;
if (!subdir)
- die("cannot opendir %s", template);
+ die_errno("cannot opendir '%s'", template);
path[baselen_sub++] =
template[template_baselen_sub++] = '/';
path[baselen_sub] =
int len;
len = readlink(template, lnk, sizeof(lnk));
if (len < 0)
- die("cannot readlink %s", template);
+ die_errno("cannot readlink '%s'", template);
if (sizeof(lnk) <= len)
die("insanely long symlink %s", template);
lnk[len] = 0;
if (symlink(lnk, path))
- die("cannot symlink %s %s", lnk, path);
+ die_errno("cannot symlink '%s' '%s'", lnk, path);
}
else if (S_ISREG(st_template.st_mode)) {
if (copy_file(path, template, st_template.st_mode))
- die("cannot copy %s to %s", template, path);
+ die_errno("cannot copy '%s' to '%s'", template,
+ path);
}
else
error("ignoring template %s", template);
if (!strcmp(".", git_dir))
return 1;
if (!getcwd(cwd, sizeof(cwd)))
- die("cannot tell cwd");
+ die_errno("cannot tell cwd");
if (!strcmp(git_dir, cwd))
return 1;
/*
if (!git_work_tree_cfg) {
git_work_tree_cfg = xcalloc(PATH_MAX, 1);
if (!getcwd(git_work_tree_cfg, PATH_MAX))
- die ("Cannot access current working directory.");
+ die_errno ("Cannot access current working directory");
}
if (access(get_git_work_tree(), X_OK))
- die ("Cannot access work tree '%s'",
- get_git_work_tree());
+ die_errno ("Cannot access work tree '%s'",
+ get_git_work_tree());
}
set_git_dir(make_absolute_path(git_dir));
diff --git a/builtin-log.c b/builtin-log.c
index 0d34050556855d6bab8b4c4121e833cc326324df..750957cfa9d84eb499b3d53687b832d639a72a42 100644 (file)
--- a/builtin-log.c
+++ b/builtin-log.c
if (use_stdout)
die("standard output, or directory, which one?");
if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
- die("Could not create directory %s",
- output_directory);
+ die_errno("Could not create directory '%s'",
+ output_directory);
}
if (rev.pending.nr == 1) {
diff --git a/builtin-mailsplit.c b/builtin-mailsplit.c
index 71f3b3b8741e505fc652e6c74c75972f19211f71..ad5f6b593df45f01360f3daa8b37d024ee793e9e 100644 (file)
--- a/builtin-mailsplit.c
+++ b/builtin-mailsplit.c
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
if (fd < 0)
- die("cannot open output file %s", name);
+ die_errno("cannot open output file '%s'", name);
output = fdopen(fd, "w");
/* Copy it out, while searching for a line that begins with
int is_partial = len && buf[len-1] != '\n';
if (fwrite(buf, 1, len, output) != len)
- die("cannot write output");
+ die_errno("cannot write output");
len = read_line_with_nul(buf, sizeof(buf), mbox);
if (len == 0) {
status = 1;
break;
}
- die("cannot read mbox");
+ die_errno("cannot read mbox");
}
if (!is_partial && !is_bare && is_from_line(buf, len))
break; /* done with one message */
diff --git a/builtin-merge.c b/builtin-merge.c
index 436263bc19ab63ec1874bdf7b2742f53c8b6529e..82335b09ede674d93d9ea7200a2c5a6ab2980505 100644 (file)
--- a/builtin-merge.c
+++ b/builtin-merge.c
printf("Squash commit -- not updating HEAD\n");
fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
if (fd < 0)
- die("Could not write to %s", git_path("SQUASH_MSG"));
+ die_errno("Could not write to '%s'", git_path("SQUASH_MSG"));
init_revisions(&rev, NULL);
rev.ignore_merges = 1;
fp = fopen(git_path("MERGE_MSG"), "a");
if (!fp)
- die("Could not open %s for writing", git_path("MERGE_MSG"));
+ die_errno("Could not open '%s' for writing",
+ git_path("MERGE_MSG"));
fprintf(fp, "\nConflicts:\n");
for (pos = 0; pos < active_nr; pos++) {
struct cache_entry *ce = active_cache[pos];
sha1_to_hex(j->item->object.sha1));
fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
if (fd < 0)
- die("Could open %s for writing",
- git_path("MERGE_HEAD"));
+ die_errno("Could not open '%s' for writing",
+ git_path("MERGE_HEAD"));
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
- die("Could not write to %s", git_path("MERGE_HEAD"));
+ die_errno("Could not write to '%s'", git_path("MERGE_HEAD"));
close(fd);
strbuf_addch(&merge_msg, '\n');
fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
if (fd < 0)
- die("Could open %s for writing", git_path("MERGE_MSG"));
+ die_errno("Could not open '%s' for writing",
+ git_path("MERGE_MSG"));
if (write_in_full(fd, merge_msg.buf, merge_msg.len) !=
merge_msg.len)
- die("Could not write to %s", git_path("MERGE_MSG"));
+ die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
close(fd);
fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
if (fd < 0)
- die("Could open %s for writing", git_path("MERGE_MODE"));
+ die_errno("Could not open '%s' for writing",
+ git_path("MERGE_MODE"));
strbuf_reset(&buf);
if (!allow_fast_forward)
strbuf_addf(&buf, "no-ff");
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
- die("Could not write to %s", git_path("MERGE_MODE"));
+ die_errno("Could not write to '%s'", git_path("MERGE_MODE"));
close(fd);
}
diff --git a/builtin-rev-parse.c b/builtin-rev-parse.c
index 112d622cda6f74f9752627d9adf3a1cdb04851c3..da26dbc020996a5e60430b6b09f70e2326352dc1 100644 (file)
--- a/builtin-rev-parse.c
+++ b/builtin-rev-parse.c
continue;
}
if (!getcwd(cwd, PATH_MAX))
- die("unable to get current working directory");
+ die_errno("unable to get current working directory");
printf("%s/.git\n", cwd);
continue;
}
diff --git a/builtin-revert.c b/builtin-revert.c
index c87115af30abd9515599586af860ccd07b96b264..151aa6a981832954120359f7c953015525b530d8 100644 (file)
--- a/builtin-revert.c
+++ b/builtin-revert.c
{
int len = strlen(string);
if (write_in_full(msg_fd, string, len) < 0)
- die ("Could not write to MERGE_MSG");
+ die_errno ("Could not write to MERGE_MSG");
}
static void add_message_to_msg(const char *message)
diff --git a/builtin-stripspace.c b/builtin-stripspace.c
index d6e3896c006796ccca12c00de45e36583387f05b..1fd2205d530ad510a18ff5a441ca7b5cb1cc34a6 100644 (file)
--- a/builtin-stripspace.c
+++ b/builtin-stripspace.c
strip_comments = 1;
if (strbuf_read(&buf, 0, 1024) < 0)
- die("could not read the input");
+ die_errno("could not read the input");
stripspace(&buf, strip_comments);
diff --git a/builtin-tag.c b/builtin-tag.c
index 7b51095c80b4b14eb389c19bfc1889ce1c187530..165bec3069cbb31025258a0c20d61158482025ed 100644 (file)
--- a/builtin-tag.c
+++ b/builtin-tag.c
else {
if (!strcmp(msgfile, "-")) {
if (strbuf_read(&buf, 0, 1024) < 0)
- die("cannot read %s", msgfile);
+ die_errno("cannot read '%s'", msgfile);
} else {
if (strbuf_read_file(&buf, msgfile, 1024) < 0)
die_errno("could not open or read '%s'",
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index f88e7219367c309dbc3d3e7ce2db32666703a91d..8b3a35e12da2cca8b632d4139bc2c5ba2409d322 100644 (file)
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
n = write_in_full(1, content + 11, 41);
if (n < 41)
- die("git get-tar-commit-id: write error");
+ die_errno("git get-tar-commit-id: write error");
return 0;
}
diff --git a/combine-diff.c b/combine-diff.c
index 60d03676bbd0dba7be79c7098d7cae553962ca98..bbf74fc42e4e72eb3df99272fb75a03bbeaf726a 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
done = read_in_full(fd, result, len);
if (done < 0)
- die("read error '%s'", elem->path);
+ die_errno("read error '%s'", elem->path);
else if (done < len)
die("early EOF '%s'", elem->path);
index 48043f5bdb2fd31f46114422f1995ff365a26bb6..aec613f85a567c6a3f28f4d79d134ee72b53510b 100644 (file)
--- a/diff.c
+++ b/diff.c
size = buf.len;
}
if (write_in_full(fd, blob, size) != size)
- die("unable to write temp-file");
+ die_errno("unable to write temp-file");
close(fd);
temp->name = temp->tmp_path;
strcpy(temp->hex, sha1_to_hex(sha1));
if (S_ISLNK(st.st_mode)) {
struct strbuf sb = STRBUF_INIT;
if (strbuf_readlink(&sb, name, st.st_size) < 0)
- die("readlink(%s)", name);
+ die_errno("readlink(%s)", name);
prep_temp_blob(name, temp, sb.buf, sb.len,
(one->sha1_valid ?
one->sha1 : null_sha1),
return;
}
if (lstat(one->path, &st) < 0)
- die("stat %s", one->path);
+ die_errno("stat '%s'", one->path);
if (index_path(one->sha1, one->path, &st, 0))
die("cannot hash %s", one->path);
}
index 8ec880bdbdf61ce26116fc265c464fbf553f5afc..d3e86c722a6663a65f69b73621f57aa6331a5e5b 100644 (file)
--- a/entry.c
+++ b/entry.c
if (errno == EEXIST && state->force &&
!unlink_or_warn(buf) && !mkdir(buf, 0777))
continue;
- die("cannot create directory at %s", buf);
+ die_errno("cannot create directory at '%s'", buf);
}
}
free(buf);
diff --git a/fast-import.c b/fast-import.c
index d31a4e8217ea58d6f3c7459877ede7f4b8bf99b2..7ef9865aa6da794ab52cfc50f21f9f41f861fc4f 100644 (file)
--- a/fast-import.c
+++ b/fast-import.c
keep_fd = odb_pack_keep(name, sizeof(name), pack_data->sha1);
if (keep_fd < 0)
- die("cannot create keep file");
+ die_errno("cannot create keep file");
write_or_die(keep_fd, keep_msg, strlen(keep_msg));
if (close(keep_fd))
- die("failed to write keep file");
+ die_errno("failed to write keep file");
snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
get_object_directory(), sha1_to_hex(pack_data->sha1));
diff --git a/hash-object.c b/hash-object.c
index 47cf43c3cdd2bcd7638360a130fc8ef04ce132e9..9455dd0709aeb81436ef2e3e36422578d66ce8e7 100644 (file)
--- a/hash-object.c
+++ b/hash-object.c
int fd;
fd = open(path, O_RDONLY);
if (fd < 0)
- die("Cannot open %s", path);
+ die_errno("Cannot open '%s'", path);
hash_fd(fd, type, write_object, vpath);
}
diff --git a/ll-merge.c b/ll-merge.c
index 81c02ad0531e98379d8cd11dc7c2d70214d67fb4..caf22be92723f3a00a70a0b8ce7aab05dc235dcb 100644 (file)
--- a/ll-merge.c
+++ b/ll-merge.c
strcpy(path, ".merge_file_XXXXXX");
fd = xmkstemp(path);
if (write_in_full(fd, src->ptr, src->size) != src->size)
- die("unable to write temp-file");
+ die_errno("unable to write temp-file");
close(fd);
}
index 99a356e9ee75cb247d80ed6dc0b251ceb0bd9e46..a609e3ebd106ed985fa2065dc4af6565e5a379a6 100644 (file)
--- a/mktag.c
+++ b/mktag.c
setup_git_directory();
if (strbuf_read(&buf, 0, 4096) < 0) {
- die("could not read from stdin");
+ die_errno("could not read from stdin");
}
/* Verify it for some basic sanity: it needs to start with
diff --git a/read-cache.c b/read-cache.c
index f76b5bb2e13a06fbc393a2344f0310ee5e702594..4e3e272ee409de66de2059a8be475fddcaa4dc28 100644 (file)
--- a/read-cache.c
+++ b/read-cache.c
mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
close(fd);
if (mmap == MAP_FAILED)
- die("unable to map index file");
+ die_errno("unable to map index file");
hdr = mmap;
if (verify_hdr(hdr, mmap_size) < 0)
index 4d27f28c8fdc259a7ff308865690d0dfd88279a6..e3781b656d77be94e04c5229e6a190c5fc496490 100644 (file)
--- a/setup.c
+++ b/setup.c
return NULL;
set_git_dir(make_absolute_path(gitdirenv));
if (chdir(work_tree_env) < 0)
- die ("Could not chdir to %s", work_tree_env);
+ die_errno ("Could not chdir to '%s'", work_tree_env);
strcat(buffer, "/");
return retval;
}
}
if (!getcwd(cwd, sizeof(cwd)-1))
- die("Unable to read current working directory");
+ die_errno("Unable to read current working directory");
ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
if (offset <= ceil_offset) {
if (nongit_ok) {
if (chdir(cwd))
- die("Cannot come back to cwd");
+ die_errno("Cannot come back to cwd");
*nongit_ok = 1;
return NULL;
}
static char buffer[PATH_MAX + 1];
char *rel;
if (retval && chdir(retval))
- die ("Could not jump back into original cwd");
+ die_errno ("Could not jump back into original cwd");
rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
if (rel && *rel && chdir(get_git_work_tree()))
- die ("Could not jump to working directory");
+ die_errno ("Could not jump to working directory");
return rel && *rel ? strcat(rel, "/") : NULL;
}
diff --git a/transport.c b/transport.c
index 17891d5149aab99ce0ec5538a0e11b8e9c2398ec..8decd663f1a5de98146f6a2590b8b1eb9ddf1b5b 100644 (file)
--- a/transport.c
+++ b/transport.c
@@ -158,7 +158,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
if (!mkdtemp(temp_dir.buf))
- die ("Could not make temporary directory");
+ die_errno ("Could not make temporary directory");
temp_dir_len = temp_dir.len;
strbuf_addstr(&buf, rsync_url(transport->url));
strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
if (!mkdtemp(temp_dir.buf))
- die ("Could not make temporary directory");
+ die_errno ("Could not make temporary directory");
strbuf_addch(&temp_dir, '/');
if (flags & TRANSPORT_PUSH_ALL) {
diff --git a/unpack-file.c b/unpack-file.c
index 75cd2f1a6adf3ea773a6acc3f1e7f122e30676e5..ac9cbf7cd8ed1367151de0e8b96668f498b7f1a1 100644 (file)
--- a/unpack-file.c
+++ b/unpack-file.c
strcpy(path, ".merge_file_XXXXXX");
fd = xmkstemp(path);
if (write_in_full(fd, buf, size) != size)
- die("unable to write temp-file");
+ die_errno("unable to write temp-file");
close(fd);
return path;
}