[RFC PATCH 3/8] sequencer: refactor update_head()

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

 



From: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>

The previous commit was a mechanical translation of the code from
builtin/commit.c. Now that it uses its own strbuf for the reflog
message it can be simplified slightly.

Signed-off-by: Phillip Wood <phillip.wood@xxxxxxxxxxxxx>
---
 sequencer.c | 7 +++----
 1 file changed, 3 insertions(+), 4 deletions(-)

diff --git a/sequencer.c b/sequencer.c
index 917ad4a16216b30adb2c2c9650217926d8db8ba7..1795a4df2a0021b2419d941c6083e49cd6647314 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -759,8 +759,9 @@ int update_head(const struct commit *old_head, const struct object_id *new_head,
 	int ret = 0;
 
 	reflog_msg = getenv("GIT_REFLOG_ACTION");
-	if (!reflog_msg)
-		reflog_msg="";
+	if (reflog_msg)
+		strbuf_addstr(&sb, reflog_msg);
+	strbuf_addstr(&sb, ": ");
 
 	nl = strchr(msg->buf, '\n');
 	if (nl) {
@@ -769,8 +770,6 @@ int update_head(const struct commit *old_head, const struct object_id *new_head,
 		strbuf_addbuf(&sb, msg);
 		strbuf_addch(&sb, '\n');
 	}
-	strbuf_insert(&sb, 0, reflog_msg, strlen(reflog_msg));
-	strbuf_insert(&sb, strlen(reflog_msg), ": ", 2);
 
 	transaction = ref_transaction_begin(err);
 	if (!transaction ||
-- 
2.14.1




[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