Merge branch 'tr/die_errno'
* tr/die_errno: Use die_errno() instead of die() when checking syscalls Convert existing die(..., strerror(errno)) to die_errno() die_errno(): double % in strerror() output just in case Introduce die_errno() that appends strerror(errno) to die()
This commit is contained in:
@ -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;
|
||||
@ -294,9 +294,9 @@ static void squash_message(void)
|
||||
NULL, NULL, rev.date_mode, 0);
|
||||
}
|
||||
if (write(fd, out.buf, out.len) < 0)
|
||||
die("Writing SQUASH_MSG: %s", strerror(errno));
|
||||
die_errno("Writing SQUASH_MSG");
|
||||
if (close(fd))
|
||||
die("Finishing SQUASH_MSG: %s", strerror(errno));
|
||||
die_errno("Finishing SQUASH_MSG");
|
||||
strbuf_release(&out);
|
||||
}
|
||||
|
||||
@ -428,8 +428,8 @@ static void merge_name(const char *remote, struct strbuf *msg)
|
||||
|
||||
fp = fopen(git_path("FETCH_HEAD"), "r");
|
||||
if (!fp)
|
||||
die("could not open %s for reading: %s",
|
||||
git_path("FETCH_HEAD"), strerror(errno));
|
||||
die_errno("could not open '%s' for reading",
|
||||
git_path("FETCH_HEAD"));
|
||||
strbuf_getline(&line, fp, '\n');
|
||||
fclose(fp);
|
||||
ptr = strstr(line.buf, "\tnot-for-merge\t");
|
||||
@ -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];
|
||||
@ -1189,27 +1190,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);
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user