aboutsummaryrefslogtreecommitdiff
path: root/builtin-merge.c
diff options
context:
space:
mode:
authorThomas Rast <trast@student.ethz.ch>2009-06-27 17:58:47 +0200
committerJunio C Hamano <gitster@pobox.com>2009-06-27 11:14:53 -0700
commit0721c314a5c8fddc877140ab5a333c42c62f780d (patch)
tree3fbea50f91636df092ac245284e811a32738842c /builtin-merge.c
parentd824cbba02a4061400a0e382f9bd241fbbff34f0 (diff)
downloadgit-0721c314a5c8fddc877140ab5a333c42c62f780d.tar.gz
git-0721c314a5c8fddc877140ab5a333c42c62f780d.tar.xz
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>
Diffstat (limited to 'builtin-merge.c')
-rw-r--r--builtin-merge.c21
1 files changed, 12 insertions, 9 deletions
diff --git a/builtin-merge.c b/builtin-merge.c
index 436263bc1..82335b09e 100644
--- a/builtin-merge.c
+++ b/builtin-merge.c
@@ -268,7 +268,7 @@ static void squash_message(void)
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;
@@ -764,7 +764,8 @@ static int suggest_conflicts(void)
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];
@@ -1186,27 +1187,29 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
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);
}