diff options
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/am.c | 8 | ||||
-rw-r--r-- | builtin/commit.c | 5 | ||||
-rw-r--r-- | builtin/fast-export.c | 4 | ||||
-rw-r--r-- | builtin/fsck.c | 3 | ||||
-rw-r--r-- | builtin/merge.c | 4 | ||||
-rw-r--r-- | builtin/pull.c | 3 |
6 files changed, 7 insertions, 20 deletions
diff --git a/builtin/am.c b/builtin/am.c index a95dd8b4e6..f5dac7783e 100644 --- a/builtin/am.c +++ b/builtin/am.c @@ -1275,12 +1275,8 @@ static int parse_mail(struct am_state *state, const char *mail) die("BUG: invalid value for state->scissors"); } - mi.input = fopen(mail, "r"); - if (!mi.input) - die("could not open input"); - mi.output = fopen(am_path(state, "info"), "w"); - if (!mi.output) - die("could not open output 'info'"); + mi.input = xfopen(mail, "r"); + mi.output = xfopen(am_path(state, "info"), "w"); if (mailinfo(&mi, am_path(state, "msg"), am_path(state, "patch"))) die("could not parse patch"); diff --git a/builtin/commit.c b/builtin/commit.c index 1d805f5da8..eda0d32311 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1695,10 +1695,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix) if (!reflog_msg) reflog_msg = "commit (merge)"; pptr = commit_list_append(current_head, pptr); - fp = fopen(git_path_merge_head(), "r"); - if (fp == NULL) - die_errno(_("could not open '%s' for reading"), - git_path_merge_head()); + fp = xfopen(git_path_merge_head(), "r"); while (strbuf_getline_lf(&m, fp) != EOF) { struct commit *parent; diff --git a/builtin/fast-export.c b/builtin/fast-export.c index e0220630d0..128b99e6da 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -905,9 +905,7 @@ static void export_marks(char *file) static void import_marks(char *input_file) { char line[512]; - FILE *f = fopen(input_file, "r"); - if (!f) - die_errno("cannot read '%s'", input_file); + FILE *f = xfopen(input_file, "r"); while (fgets(line, sizeof(line), f)) { uint32_t mark; diff --git a/builtin/fsck.c b/builtin/fsck.c index b5e13a4556..00beaaa4e6 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -280,8 +280,7 @@ static void check_unreachable_object(struct object *obj) free(filename); return; } - if (!(f = fopen(filename, "w"))) - die_errno("Could not open '%s'", filename); + f = xfopen(filename, "w"); if (obj->type == OBJ_BLOB) { if (stream_blob_to_fd(fileno(f), &obj->oid, NULL, 1)) die_errno("Could not write '%s'", filename); diff --git a/builtin/merge.c b/builtin/merge.c index 703827f006..65a1501858 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -839,9 +839,7 @@ static int suggest_conflicts(void) struct strbuf msgbuf = STRBUF_INIT; filename = git_path_merge_msg(); - fp = fopen(filename, "a"); - if (!fp) - die_errno(_("Could not open '%s' for writing"), filename); + fp = xfopen(filename, "a"); append_conflicts_hint(&msgbuf); fputs(msgbuf.buf, fp); diff --git a/builtin/pull.c b/builtin/pull.c index dd1a4a94e4..589c25becf 100644 --- a/builtin/pull.c +++ b/builtin/pull.c @@ -337,8 +337,7 @@ static void get_merge_heads(struct oid_array *merge_heads) struct strbuf sb = STRBUF_INIT; struct object_id oid; - if (!(fp = fopen(filename, "r"))) - die_errno(_("could not open '%s' for reading"), filename); + fp = xfopen(filename, "r"); while (strbuf_getline_lf(&sb, fp) != EOF) { if (get_oid_hex(sb.buf, &oid)) continue; /* invalid line: does not start with SHA1 */ |