Use die_errno() instead of die() when checking syscalls
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>
Thomas Rast committed
Jun 27, 2009 at 17:58 UTC
0721c314a5c8fddc877140ab5a333c42c62f780d
30 files changed
+79
-74
abspath.c
+6
-6
@@ -41,13 +41,13 @@ const char *make_absolute_path(const char *path)
41
42
if (*buf) {
43
if (!*cwd && !getcwd(cwd, sizeof(cwd)))
44
- die ("Could not get current working directory");
44
+ die_errno ("Could not get current working directory");
45
46
if (chdir(buf))
47
- die ("Could not switch to '%s'", buf);
47
+ die_errno ("Could not switch to '%s'", buf);
48
}
49
if (!getcwd(buf, PATH_MAX))
50
- die ("Could not get current working directory");
50
+ die_errno ("Could not get current working directory");
51
52
if (last_elem) {
53
int len = strlen(buf);
@@ -63,7 +63,7 @@ const char *make_absolute_path(const char *path)
63
if (!lstat(buf, &st) && S_ISLNK(st.st_mode)) {
64
len = readlink(buf, next_buf, PATH_MAX);
65
if (len < 0)
66
- die ("Invalid symlink: %s", buf);
66
+ die_errno ("Invalid symlink '%s'", buf);
67
if (PATH_MAX <= len)
68
die("symbolic link too long: %s", buf);
69
next_buf[len] = '\0';
@@ -75,7 +75,7 @@ const char *make_absolute_path(const char *path)
75
}
76
77
if (*cwd && chdir(cwd))
78
- die ("Could not change back to '%s'", cwd);
78
+ die_errno ("Could not change back to '%s'", cwd);
79
80
return buf;
81
}
@@ -109,7 +109,7 @@ const char *make_nonrelative_path(const char *path)
109
} else {
110
const char *cwd = get_pwd_cwd();
111
if (!cwd)
112
- die("Cannot determine the current working directory");
112
+ die_errno("Cannot determine the current working directory");
113
if (snprintf(buf, PATH_MAX, "%s/%s", cwd, path) >= PATH_MAX)
114
die("Too long path: %.*s", 60, path);
115
}
builtin-add.c
+1
-1
@@ -220,7 +220,7 @@ int edit_patch(int argc, const char **argv, const char *prefix)
220
launch_editor(file, NULL, NULL);
221
222
if (stat(file, &st))
223
- die("Could not stat '%s'", file);
223
+ die_errno("Could not stat '%s'", file);
224
if (!st.st_size)
225
die("Empty patch. Aborted.");
226
builtin-apply.c
+3
-3
@@ -2823,8 +2823,8 @@ static void add_index_file(const char *path, unsigned mode, void *buf, unsigned
2823
} else {
2824
if (!cached) {
2825
if (lstat(path, &st) < 0)
2826
- die("unable to stat newly created file %s",
2827
- path);
2826
+ die_errno("unable to stat newly created file '%s'",
2827
+ path);
2828
fill_stat_cache_info(ce, &st);
2829
}
2830
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
2913
++nr;
2914
}
2915
}
2916
- die("unable to write file %s mode %o", path, mode);
2916
+ die_errno("unable to write file '%s' mode %o", path, mode);
2917
}
2918
2919
static void create_file(struct patch *patch)
builtin-archive.c
+2
-2
@@ -13,10 +13,10 @@ static void create_output_file(const char *output_file)
13
{
14
int output_fd = open(output_file, O_CREAT | O_WRONLY | O_TRUNC, 0666);
15
if (output_fd < 0)
16
- die("could not create archive file: %s ", output_file);
16
+ die_errno("could not create archive file '%s'", output_file);
17
if (output_fd != 1) {
18
if (dup2(output_fd, 1) < 0)
19
- die("could not redirect output");
19
+ die_errno("could not redirect output");
20
else
21
close(output_fd);
22
}
builtin-blame.c
+4
-4
@@ -2008,23 +2008,23 @@ static struct commit *fake_working_tree_commit(const char *path, const char *con
2008
2009
if (contents_from) {
2010
if (stat(contents_from, &st) < 0)
2011
- die("Cannot stat %s", contents_from);
2011
+ die_errno("Cannot stat '%s'", contents_from);
2012
read_from = contents_from;
2013
}
2014
else {
2015
if (lstat(path, &st) < 0)
2016
- die("Cannot lstat %s", path);
2016
+ die_errno("Cannot lstat '%s'", path);
2017
read_from = path;
2018
}
2019
mode = canon_mode(st.st_mode);
2020
switch (st.st_mode & S_IFMT) {
2021
case S_IFREG:
2022
if (strbuf_read_file(&buf, read_from, st.st_size) != st.st_size)
2023
- die("cannot open or read %s", read_from);
2023
+ die_errno("cannot open or read '%s'", read_from);
2024
break;
2025
case S_IFLNK:
2026
if (strbuf_readlink(&buf, read_from, st.st_size) < 0)
2027
- die("cannot readlink %s", read_from);
2027
+ die_errno("cannot readlink '%s'", read_from);
2028
break;
2029
default:
2030
die("unsupported file type %s", read_from);
builtin-clone.c
+5
-5
@@ -220,13 +220,13 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
220
221
dir = opendir(src->buf);
222
if (!dir)
223
- die("failed to open %s", src->buf);
223
+ die_errno("failed to open '%s'", src->buf);
224
225
if (mkdir(dest->buf, 0777)) {
226
if (errno != EEXIST)
227
- die("failed to create directory %s", dest->buf);
227
+ die_errno("failed to create directory '%s'", dest->buf);
228
else if (stat(dest->buf, &buf))
229
- die("failed to stat %s", dest->buf);
229
+ die_errno("failed to stat '%s'", dest->buf);
230
else if (!S_ISDIR(buf.st_mode))
231
die("%s exists and is not a directory", dest->buf);
232
}
@@ -257,11 +257,11 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest)
257
if (!link(src->buf, dest->buf))
258
continue;
259
if (option_local)
260
- die("failed to create link %s", dest->buf);
260
+ die_errno("failed to create link '%s'", dest->buf);
261
option_no_hardlinks = 1;
262
}
263
if (copy_file(dest->buf, src->buf, 0666))
264
- die("failed to copy file to %s", dest->buf);
264
+ die_errno("failed to copy file to '%s'", dest->buf);
265
}
266
closedir(dir);
267
}
builtin-commit.c
+3
-2
@@ -434,7 +434,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
434
if (isatty(0))
435
fprintf(stderr, "(reading log message from standard input)\n");
436
if (strbuf_read(&sb, 0, 0) < 0)
437
- die("could not read log from standard input");
437
+ die_errno("could not read log from standard input");
438
hook_arg1 = "message";
439
} else if (logfile) {
440
if (strbuf_read_file(&sb, logfile, 0) < 0)
@@ -964,8 +964,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
964
/* Finally, get the commit message */
965
strbuf_reset(&sb);
966
if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
967
+ int saved_errno = errno;
968
rollback_index_files();
968
- die("could not read commit message");
969
+ die("could not read commit message: %s", strerror(saved_errno));
970
}
971
972
/* Truncate the message just before the diff, if any. */
builtin-fast-export.c
+1
-1
@@ -119,7 +119,7 @@ static void handle_object(const unsigned char *sha1)
119
120
printf("blob\nmark :%"PRIu32"\ndata %lu\n", last_idnum, size);
121
if (size && fwrite(buf, size, 1, stdout) != 1)
122
- die ("Could not write blob %s", sha1_to_hex(sha1));
122
+ die_errno ("Could not write blob '%s'", sha1_to_hex(sha1));
123
printf("\n");
124
125
show_progress();
builtin-fmt-merge-msg.c
+1
-1
@@ -368,7 +368,7 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix)
368
if (inpath && strcmp(inpath, "-")) {
369
in = fopen(inpath, "r");
370
if (!in)
371
- die("cannot open %s", inpath);
371
+ die_errno("cannot open '%s'", inpath);
372
}
373
374
if (strbuf_read(&input, fileno(in), 0) < 0)
builtin-fsck.c
+1
-1
@@ -217,7 +217,7 @@ static void check_unreachable_object(struct object *obj)
217
return;
218
}
219
if (!(f = fopen(filename, "w")))
220
- die("Could not open %s", filename);
220
+ die_errno("Could not open '%s'", filename);
221
if (obj->type == OBJ_BLOB) {
222
enum object_type type;
223
unsigned long size;
builtin-init-db.c
+11
-10
@@ -61,20 +61,20 @@ static void copy_templates_1(char *path, int baselen,
61
memcpy(template + template_baselen, de->d_name, namelen+1);
62
if (lstat(path, &st_git)) {
63
if (errno != ENOENT)
64
- die("cannot stat %s", path);
64
+ die_errno("cannot stat '%s'", path);
65
}
66
else
67
exists = 1;
68
69
if (lstat(template, &st_template))
70
- die("cannot stat template %s", template);
70
+ die_errno("cannot stat template '%s'", template);
71
72
if (S_ISDIR(st_template.st_mode)) {
73
DIR *subdir = opendir(template);
74
int baselen_sub = baselen + namelen;
75
int template_baselen_sub = template_baselen + namelen;
76
if (!subdir)
77
- die("cannot opendir %s", template);
77
+ die_errno("cannot opendir '%s'", template);
78
path[baselen_sub++] =
79
template[template_baselen_sub++] = '/';
80
path[baselen_sub] =
@@ -91,16 +91,17 @@ static void copy_templates_1(char *path, int baselen,
91
int len;
92
len = readlink(template, lnk, sizeof(lnk));
93
if (len < 0)
94
- die("cannot readlink %s", template);
94
+ die_errno("cannot readlink '%s'", template);
95
if (sizeof(lnk) <= len)
96
die("insanely long symlink %s", template);
97
lnk[len] = 0;
98
if (symlink(lnk, path))
99
- die("cannot symlink %s %s", lnk, path);
99
+ die_errno("cannot symlink '%s' '%s'", lnk, path);
100
}
101
else if (S_ISREG(st_template.st_mode)) {
102
if (copy_file(path, template, st_template.st_mode))
103
- die("cannot copy %s to %s", template, path);
103
+ die_errno("cannot copy '%s' to '%s'", template,
104
+ path);
105
}
106
else
107
error("ignoring template %s", template);
@@ -350,7 +351,7 @@ static int guess_repository_type(const char *git_dir)
351
if (!strcmp(".", git_dir))
352
return 1;
353
if (!getcwd(cwd, sizeof(cwd)))
353
- die("cannot tell cwd");
354
+ die_errno("cannot tell cwd");
355
if (!strcmp(git_dir, cwd))
356
return 1;
357
/*
@@ -440,11 +441,11 @@ int cmd_init_db(int argc, const char **argv, const char *prefix)
441
if (!git_work_tree_cfg) {
442
git_work_tree_cfg = xcalloc(PATH_MAX, 1);
443
if (!getcwd(git_work_tree_cfg, PATH_MAX))
443
- die ("Cannot access current working directory.");
444
+ die_errno ("Cannot access current working directory");
445
}
446
if (access(get_git_work_tree(), X_OK))
446
- die ("Cannot access work tree '%s'",
447
- get_git_work_tree());
447
+ die_errno ("Cannot access work tree '%s'",
448
+ get_git_work_tree());
449
}
450
451
set_git_dir(make_absolute_path(git_dir));
builtin-log.c
+2
-2
@@ -1013,8 +1013,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
1013
if (use_stdout)
1014
die("standard output, or directory, which one?");
1015
if (mkdir(output_directory, 0777) < 0 && errno != EEXIST)
1016
- die("Could not create directory %s",
1017
- output_directory);
1016
+ die_errno("Could not create directory '%s'",
1017
+ output_directory);
1018
}
1019
1020
if (rev.pending.nr == 1) {
builtin-mailsplit.c
+3
-3
@@ -81,7 +81,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
81
82
fd = open(name, O_WRONLY | O_CREAT | O_EXCL, 0666);
83
if (fd < 0)
84
- die("cannot open output file %s", name);
84
+ die_errno("cannot open output file '%s'", name);
85
output = fdopen(fd, "w");
86
87
/* Copy it out, while searching for a line that begins with
@@ -91,7 +91,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
91
int is_partial = len && buf[len-1] != '\n';
92
93
if (fwrite(buf, 1, len, output) != len)
94
- die("cannot write output");
94
+ die_errno("cannot write output");
95
96
len = read_line_with_nul(buf, sizeof(buf), mbox);
97
if (len == 0) {
@@ -99,7 +99,7 @@ static int split_one(FILE *mbox, const char *name, int allow_bare)
99
status = 1;
100
break;
101
}
102
- die("cannot read mbox");
102
+ die_errno("cannot read mbox");
103
}
104
if (!is_partial && !is_bare && is_from_line(buf, len))
105
break; /* done with one message */
builtin-merge.c
+12
-9
@@ -268,7 +268,7 @@ static void squash_message(void)
268
printf("Squash commit -- not updating HEAD\n");
269
fd = open(git_path("SQUASH_MSG"), O_WRONLY | O_CREAT, 0666);
270
if (fd < 0)
271
- die("Could not write to %s", git_path("SQUASH_MSG"));
271
+ die_errno("Could not write to '%s'", git_path("SQUASH_MSG"));
272
273
init_revisions(&rev, NULL);
274
rev.ignore_merges = 1;
@@ -764,7 +764,8 @@ static int suggest_conflicts(void)
764
765
fp = fopen(git_path("MERGE_MSG"), "a");
766
if (!fp)
767
- die("Could not open %s for writing", git_path("MERGE_MSG"));
767
+ die_errno("Could not open '%s' for writing",
768
+ git_path("MERGE_MSG"));
769
fprintf(fp, "\nConflicts:\n");
770
for (pos = 0; pos < active_nr; pos++) {
771
struct cache_entry *ce = active_cache[pos];
@@ -1186,27 +1187,29 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
1187
sha1_to_hex(j->item->object.sha1));
1188
fd = open(git_path("MERGE_HEAD"), O_WRONLY | O_CREAT, 0666);
1189
if (fd < 0)
1189
- die("Could open %s for writing",
1190
- git_path("MERGE_HEAD"));
1190
+ die_errno("Could not open '%s' for writing",
1191
+ git_path("MERGE_HEAD"));
1192
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
1192
- die("Could not write to %s", git_path("MERGE_HEAD"));
1193
+ die_errno("Could not write to '%s'", git_path("MERGE_HEAD"));
1194
close(fd);
1195
strbuf_addch(&merge_msg, '\n');
1196
fd = open(git_path("MERGE_MSG"), O_WRONLY | O_CREAT, 0666);
1197
if (fd < 0)
1197
- die("Could open %s for writing", git_path("MERGE_MSG"));
1198
+ die_errno("Could not open '%s' for writing",
1199
+ git_path("MERGE_MSG"));
1200
if (write_in_full(fd, merge_msg.buf, merge_msg.len) !=
1201
merge_msg.len)
1200
- die("Could not write to %s", git_path("MERGE_MSG"));
1202
+ die_errno("Could not write to '%s'", git_path("MERGE_MSG"));
1203
close(fd);
1204
fd = open(git_path("MERGE_MODE"), O_WRONLY | O_CREAT | O_TRUNC, 0666);
1205
if (fd < 0)
1204
- die("Could open %s for writing", git_path("MERGE_MODE"));
1206
+ die_errno("Could not open '%s' for writing",
1207
+ git_path("MERGE_MODE"));
1208
strbuf_reset(&buf);
1209
if (!allow_fast_forward)
1210
strbuf_addf(&buf, "no-ff");
1211
if (write_in_full(fd, buf.buf, buf.len) != buf.len)
1209
- die("Could not write to %s", git_path("MERGE_MODE"));
1212
+ die_errno("Could not write to '%s'", git_path("MERGE_MODE"));
1213
close(fd);
1214
}
1215
builtin-rev-parse.c
+1
-1
@@ -592,7 +592,7 @@ int cmd_rev_parse(int argc, const char **argv, const char *prefix)
592
continue;
593
}
594
if (!getcwd(cwd, PATH_MAX))
595
- die("unable to get current working directory");
595
+ die_errno("unable to get current working directory");
596
printf("%s/.git\n", cwd);
597
continue;
598
}
builtin-revert.c
+1
-1
@@ -135,7 +135,7 @@ static void add_to_msg(const char *string)
135
{
136
int len = strlen(string);
137
if (write_in_full(msg_fd, string, len) < 0)
138
- die ("Could not write to MERGE_MSG");
138
+ die_errno ("Could not write to MERGE_MSG");
139
}
140
141
static void add_message_to_msg(const char *message)
builtin-stripspace.c
+1
-1
@@ -78,7 +78,7 @@ int cmd_stripspace(int argc, const char **argv, const char *prefix)
78
strip_comments = 1;
79
80
if (strbuf_read(&buf, 0, 1024) < 0)
81
- die("could not read the input");
81
+ die_errno("could not read the input");
82
83
stripspace(&buf, strip_comments);
84
builtin-tag.c
+1
-1
@@ -442,7 +442,7 @@ int cmd_tag(int argc, const char **argv, const char *prefix)
442
else {
443
if (!strcmp(msgfile, "-")) {
444
if (strbuf_read(&buf, 0, 1024) < 0)
445
- die("cannot read %s", msgfile);
445
+ die_errno("cannot read '%s'", msgfile);
446
} else {
447
if (strbuf_read_file(&buf, msgfile, 1024) < 0)
448
die_errno("could not open or read '%s'",
builtin-tar-tree.c
+1
-1
@@ -91,7 +91,7 @@ int cmd_get_tar_commit_id(int argc, const char **argv, const char *prefix)
91
92
n = write_in_full(1, content + 11, 41);
93
if (n < 41)
94
- die("git get-tar-commit-id: write error");
94
+ die_errno("git get-tar-commit-id: write error");
95
96
return 0;
97
}
combine-diff.c
+1
-1
@@ -746,7 +746,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
746
747
done = read_in_full(fd, result, len);
748
if (done < 0)
749
- die("read error '%s'", elem->path);
749
+ die_errno("read error '%s'", elem->path);
750
else if (done < len)
751
die("early EOF '%s'", elem->path);
752
diff.c
+3
-3
@@ -1982,7 +1982,7 @@ static void prep_temp_blob(const char *path, struct diff_tempfile *temp,
1982
size = buf.len;
1983
}
1984
if (write_in_full(fd, blob, size) != size)
1985
- die("unable to write temp-file");
1985
+ die_errno("unable to write temp-file");
1986
close(fd);
1987
temp->name = temp->tmp_path;
1988
strcpy(temp->hex, sha1_to_hex(sha1));
@@ -2026,7 +2026,7 @@ static struct diff_tempfile *prepare_temp_file(const char *name,
2026
if (S_ISLNK(st.st_mode)) {
2027
struct strbuf sb = STRBUF_INIT;
2028
if (strbuf_readlink(&sb, name, st.st_size) < 0)
2029
- die("readlink(%s)", name);
2029
+ die_errno("readlink(%s)", name);
2030
prep_temp_blob(name, temp, sb.buf, sb.len,
2031
(one->sha1_valid ?
2032
one->sha1 : null_sha1),
@@ -2219,7 +2219,7 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
2219
return;
2220
}
2221
if (lstat(one->path, &st) < 0)
2222
- die("stat %s", one->path);
2222
+ die_errno("stat '%s'", one->path);
2223
if (index_path(one->sha1, one->path, &st, 0))
2224
die("cannot hash %s", one->path);
2225
}
entry.c
+1
-1
@@ -37,7 +37,7 @@ static void create_directories(const char *path, int path_len,
37
if (errno == EEXIST && state->force &&
38
!unlink_or_warn(buf) && !mkdir(buf, 0777))
39
continue;
40
- die("cannot create directory at %s", buf);
40
+ die_errno("cannot create directory at '%s'", buf);
41
}
42
}
43
free(buf);
fast-import.c
+2
-2
@@ -905,10 +905,10 @@ static char *keep_pack(char *curr_index_name)
905
906
keep_fd = odb_pack_keep(name, sizeof(name), pack_data->sha1);
907
if (keep_fd < 0)
908
- die("cannot create keep file");
908
+ die_errno("cannot create keep file");
909
write_or_die(keep_fd, keep_msg, strlen(keep_msg));
910
if (close(keep_fd))
911
- die("failed to write keep file");
911
+ die_errno("failed to write keep file");
912
913
snprintf(name, sizeof(name), "%s/pack/pack-%s.pack",
914
get_object_directory(), sha1_to_hex(pack_data->sha1));
hash-object.c
+1
-1
@@ -29,7 +29,7 @@ static void hash_object(const char *path, const char *type, int write_object,
29
int fd;
30
fd = open(path, O_RDONLY);
31
if (fd < 0)
32
- die("Cannot open %s", path);
32
+ die_errno("Cannot open '%s'", path);
33
hash_fd(fd, type, write_object, vpath);
34
}
35
ll-merge.c
+1
-1
@@ -152,7 +152,7 @@ static void create_temp(mmfile_t *src, char *path)
152
strcpy(path, ".merge_file_XXXXXX");
153
fd = xmkstemp(path);
154
if (write_in_full(fd, src->ptr, src->size) != src->size)
155
- die("unable to write temp-file");
155
+ die_errno("unable to write temp-file");
156
close(fd);
157
}
158
mktag.c
+1
-1
@@ -165,7 +165,7 @@ int main(int argc, char **argv)
165
setup_git_directory();
166
167
if (strbuf_read(&buf, 0, 4096) < 0) {
168
- die("could not read from stdin");
168
+ die_errno("could not read from stdin");
169
}
170
171
/* Verify it for some basic sanity: it needs to start with
read-cache.c
+1
-1
@@ -1265,7 +1265,7 @@ int read_index_from(struct index_state *istate, const char *path)
1265
mmap = xmmap(NULL, mmap_size, PROT_READ | PROT_WRITE, MAP_PRIVATE, fd, 0);
1266
close(fd);
1267
if (mmap == MAP_FAILED)
1268
- die("unable to map index file");
1268
+ die_errno("unable to map index file");
1269
1270
hdr = mmap;
1271
if (verify_hdr(hdr, mmap_size) < 0)
setup.c
+5
-5
@@ -327,7 +327,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
327
return NULL;
328
set_git_dir(make_absolute_path(gitdirenv));
329
if (chdir(work_tree_env) < 0)
330
- die ("Could not chdir to %s", work_tree_env);
330
+ die_errno ("Could not chdir to '%s'", work_tree_env);
331
strcat(buffer, "/");
332
return retval;
333
}
@@ -339,7 +339,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
339
}
340
341
if (!getcwd(cwd, sizeof(cwd)-1))
342
- die("Unable to read current working directory");
342
+ die_errno("Unable to read current working directory");
343
344
ceil_offset = longest_ancestor_length(cwd, env_ceiling_dirs);
345
if (ceil_offset < 0 && has_dos_drive_prefix(cwd))
@@ -382,7 +382,7 @@ const char *setup_git_directory_gently(int *nongit_ok)
382
if (offset <= ceil_offset) {
383
if (nongit_ok) {
384
if (chdir(cwd))
385
- die("Cannot come back to cwd");
385
+ die_errno("Cannot come back to cwd");
386
*nongit_ok = 1;
387
return NULL;
388
}
@@ -493,10 +493,10 @@ const char *setup_git_directory(void)
493
static char buffer[PATH_MAX + 1];
494
char *rel;
495
if (retval && chdir(retval))
496
- die ("Could not jump back into original cwd");
496
+ die_errno ("Could not jump back into original cwd");
497
rel = get_relative_cwd(buffer, PATH_MAX, get_git_work_tree());
498
if (rel && *rel && chdir(get_git_work_tree()))
499
- die ("Could not jump to working directory");
499
+ die_errno ("Could not jump to working directory");
500
return rel && *rel ? strcat(rel, "/") : NULL;
501
}
502
transport.c
+2
-2
@@ -158,7 +158,7 @@ static struct ref *get_refs_via_rsync(struct transport *transport, int for_push)
158
159
strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
160
if (!mkdtemp(temp_dir.buf))
161
- die ("Could not make temporary directory");
161
+ die_errno ("Could not make temporary directory");
162
temp_dir_len = temp_dir.len;
163
164
strbuf_addstr(&buf, rsync_url(transport->url));
@@ -321,7 +321,7 @@ static int rsync_transport_push(struct transport *transport,
321
322
strbuf_addstr(&temp_dir, git_path("rsync-refs-XXXXXX"));
323
if (!mkdtemp(temp_dir.buf))
324
- die ("Could not make temporary directory");
324
+ die_errno ("Could not make temporary directory");
325
strbuf_addch(&temp_dir, '/');
326
327
if (flags & TRANSPORT_PUSH_ALL) {
unpack-file.c
+1
-1
@@ -17,7 +17,7 @@ static char *create_temp_file(unsigned char *sha1)
17
strcpy(path, ".merge_file_XXXXXX");
18
fd = xmkstemp(path);
19
if (write_in_full(fd, buf, size) != size)
20
- die("unable to write temp-file");
20
+ die_errno("unable to write temp-file");
21
close(fd);
22
return path;
23
}