Skip to content

Commit d616a23

Browse files
committed
builtin-commit: fix amending of the initial commit
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>
1 parent 7263881 commit d616a23

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

builtin-commit.c

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -374,20 +374,20 @@ static int prepare_log_message(const char *index_file, const char *prefix)
374374

375375
if (no_edit) {
376376
struct rev_info rev;
377-
unsigned char sha1[40];
377+
unsigned char sha1[20];
378378
const char *parent = "HEAD";
379379

380380
fclose(fp);
381381

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

385-
if (get_sha1("HEAD", sha1) != 0)
386-
return !!active_nr;
387-
388385
if (amend)
389386
parent = "HEAD^1";
390387

388+
if (get_sha1(parent, sha1))
389+
return !!active_nr;
390+
391391
init_revisions(&rev, "");
392392
rev.abbrev = 0;
393393
setup_revisions(0, NULL, &rev, parent);

0 commit comments

Comments
 (0)