[PATCH 2/4] builtin-commit: fix amending of the initial commit

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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@xxxxxxxxx>
---
 builtin-commit.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/builtin-commit.c b/builtin-commit.c
index 96410de..d8f0dfd 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -374,7 +374,7 @@ 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);
@@ -382,12 +382,12 @@ static int prepare_log_message(const char *index_file, const char *prefix)
 		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);
-- 
1.5.4.rc1.19.g9151fa

-
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html

[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux