Skip to content

Commit

Permalink
Merge branch 'jk/maint-advice-empty-amend' into maint
Browse files Browse the repository at this point in the history
* jk/maint-advice-empty-amend:
  commit: give advice on empty amend
  • Loading branch information
Junio C Hamano committed Jun 22, 2010
2 parents b2a6095 + f197ed2 commit abd3fd3
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions builtin/commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,11 @@ static const char implicit_ident_advice[] =
"\n"
" git commit --amend --author='Your Name <you@example.com>'\n";

static const char empty_amend_advice[] =
"You asked to amend the most recent commit, but doing so would make\n"
"it empty. You can repeat your command with --allow-empty, or you can\n"
"remove the commit entirely with \"git reset HEAD^\".\n";

static unsigned char head_sha1[20];

static char *use_message_buffer;
Expand Down Expand Up @@ -699,6 +704,8 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
if (!commitable && !in_merge && !allow_empty &&
!(amend && is_a_merge(head_sha1))) {
run_status(stdout, index_file, prefix, 0, s);
if (amend)
fputs(empty_amend_advice, stderr);
return 0;
}

Expand Down

0 comments on commit abd3fd3

Please sign in to comment.