Skip to content

Commit

Permalink
git-commit: clean up die messages
Browse files Browse the repository at this point in the history
These are three types of cleanups here:

  1. remove newline from die message (die/report adds it
     already)
  2. typo: s/merger/merge/
  3. the old "* no commit message?  aborting commit." is now
     prepended with "fatal: ", making the asterisk look a
     little funny. Let's just remove it.

Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Jeff King authored and Junio C Hamano committed Dec 2, 2007
1 parent 7168624 commit b5b644a
Showing 1 changed file with 9 additions and 10 deletions.
19 changes: 9 additions & 10 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -336,7 +336,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)

fp = fopen(git_path(commit_editmsg), "w");
if (fp == NULL)
die("could not open %s\n", git_path(commit_editmsg));
die("could not open %s", git_path(commit_editmsg));

stripspace(&sb, 0);

Expand All @@ -362,8 +362,7 @@ static int prepare_log_message(const char *index_file, const char *prefix)
}

if (fwrite(sb.buf, 1, sb.len, fp) < sb.len)
die("could not write commit template: %s\n",
strerror(errno));
die("could not write commit template: %s", strerror(errno));

strbuf_release(&sb);

Expand Down Expand Up @@ -470,13 +469,13 @@ static void determine_author_info(struct strbuf *sb)

a = strstr(use_message_buffer, "\nauthor ");
if (!a)
die("invalid commit: %s\n", use_message);
die("invalid commit: %s", use_message);

lb = strstr(a + 8, " <");
rb = strstr(a + 8, "> ");
eol = strchr(a + 8, '\n');
if (!lb || !rb || !eol)
die("invalid commit: %s\n", use_message);
die("invalid commit: %s", use_message);

name = xstrndup(a + 8, lb - (a + 8));
email = xstrndup(lb + 2, rb - (lb + 2));
Expand All @@ -488,7 +487,7 @@ static void determine_author_info(struct strbuf *sb)
const char *rb = strchr(force_author, '>');

if (!lb || !rb)
die("malformed --author parameter\n");
die("malformed --author parameter");
name = xstrndup(force_author, lb - force_author);
email = xstrndup(lb + 2, rb - (lb + 2));
}
Expand Down Expand Up @@ -518,7 +517,7 @@ static int parse_and_validate_options(int argc, const char *argv[])
if (amend && initial_commit)
die("You have nothing to amend.");
if (amend && in_merge)
die("You are in the middle of a merger -- cannot amend.");
die("You are in the middle of a merge -- cannot amend.");

if (use_message)
f++;
Expand Down Expand Up @@ -641,7 +640,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)

commit = lookup_commit(sha1);
if (!commit)
die("couldn't look up newly created commit\n");
die("couldn't look up newly created commit");
if (!commit || parse_commit(commit))
die("could not parse newly created commit");

Expand Down Expand Up @@ -777,7 +776,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
launch_editor(git_path(commit_editmsg), &sb, env);
} else if (strbuf_read_file(&sb, git_path(commit_editmsg), 0) < 0) {
rollback_index_files();
die("could not read commit message\n");
die("could not read commit message");
}
if (run_hook(index_file, "commit-msg", git_path(commit_editmsg))) {
rollback_index_files();
Expand All @@ -792,7 +791,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
stripspace(&sb, 1);
if (sb.len < header_len || message_is_empty(&sb, header_len)) {
rollback_index_files();
die("* no commit message? aborting commit.");
die("no commit message? aborting commit.");
}
strbuf_addch(&sb, '\0');
if (is_encoding_utf8(git_commit_encoding) && !is_utf8(sb.buf))
Expand Down

0 comments on commit b5b644a

Please sign in to comment.