Skip to content

Commit

Permalink
builtin-commit: fix amending of the initial commit
Browse files Browse the repository at this point in the history
When amending initial commit without editor, the command
incorrectly barfed because the check to see if there is anything
to commit referenced the non-existent HEAD^1.

Signed-off-by: Junio C Hamano <gitster@pobox.com>
  • Loading branch information
Junio C Hamano committed Dec 23, 2007
1 parent 7263881 commit d616a23
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions builtin-commit.c
Original file line number Diff line number Diff line change
Expand Up @@ -374,20 +374,20 @@ static int prepare_log_message(const char *index_file, const char *prefix)

if (no_edit) {
struct rev_info rev;
unsigned char sha1[40];
unsigned char sha1[20];
const char *parent = "HEAD";

fclose(fp);

if (!active_nr && read_cache() < 0)
die("Cannot read index");

if (get_sha1("HEAD", sha1) != 0)
return !!active_nr;

if (amend)
parent = "HEAD^1";

if (get_sha1(parent, sha1))
return !!active_nr;

init_revisions(&rev, "");
rev.abbrev = 0;
setup_revisions(0, NULL, &rev, parent);
Expand Down

0 comments on commit d616a23

Please sign in to comment.