[RFC PATCH 3/8] sequencer: refactor update_head()
- From
- Phillip Wood <phillip.wood@talktalk.net>
- Date
- Sep 25, 2017, 10:10 UTC
- Message-ID
- <20170925101041.18344-4-phillip.wood@talktalk.net>
- In-Reply-To
- <20170925101041.18344-1-phillip.wood@talktalk.net>
From: Phillip Wood <phillip.wood@dunelm.org.uk>
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@dunelm.org.uk> --- 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