diff --git a/refs.c b/refs.c
index 03968ad7..790b1ff0 100644
--- a/refs.c
+++ b/refs.c
@@ -835,11 +835,13 @@ static void copy_reflog_msg(struct strbuf *sb, const char *msg)
strbuf_rtrim(sb);
}
-static char *normalize_reflog_message(const char *msg)
+static char *normalize_reflog_message_or_null(const char *msg)
{
struct strbuf sb = STRBUF_INIT;
- if (msg && *msg)
+ if (!msg)
+ return NULL;
+ if (*msg)
copy_reflog_msg(&sb, msg);
return strbuf_detach(&sb, NULL);
}@@ -1067,7 +1069,7 @@ struct ref_update *ref_transaction_add_update(
oidcpy(&update->new_oid, new_oid);
if (flags & REF_HAVE_OLD)
oidcpy(&update->old_oid, old_oid);
- update->msg = normalize_reflog_message(msg);
+ update->msg = normalize_reflog_message_or_null(msg);
return update;
}
@@ -1951,7 +1953,7 @@ int refs_create_symref(struct ref_store *refs,
char *msg;
int retval;
- msg = normalize_reflog_message(logmsg);
+ msg = normalize_reflog_message_or_null(logmsg);
retval = refs->be->create_symref(refs, ref_target, refs_heads_master,
msg);
free(msg);
@@ -2339,7 +2341,7 @@ int refs_delete_refs(struct ref_store *refs, const char *logmsg,
char *msg;
int retval;
- msg = normalize_reflog_message(logmsg);
+ msg = normalize_reflog_message_or_null(logmsg);
retval = refs->be->delete_refs(refs, msg, refnames, flags);
free(msg);
return retval;
@@ -2357,7 +2359,7 @@ int refs_rename_ref(struct ref_store *refs, const char *oldref,
char *msg;
int retval;
- msg = normalize_reflog_message(logmsg);
+ msg = normalize_reflog_message_or_null(logmsg);
retval = refs->be->rename_ref(refs, oldref, newref, msg);
free(msg);
return retval;
@@ -2374,7 +2376,7 @@ int refs_copy_existing_ref(struct ref_store *refs, const char *oldref,
char *msg;
int retval;
- msg = normalize_reflog_message(logmsg);
+ msg = normalize_reflog_message_or_null(logmsg);
retval = refs->be->copy_ref(refs, oldref, newref, msg);
free(msg);
return retval;
diff --git a/t/t1417-reflog-symref.sh b/t/t1417-reflog-symref.sh
index 6149531f..3687b058 100755
--- a/t/t1417-reflog-symref.sh
+++ b/t/t1417-reflog-symref.sh
@@ -53,7 +53,7 @@ test_expect_success setup '
test $hcnt -ne $kcnt
'
-test_expect_failure 'HEAD reflog symbolic-ref' '
+test_expect_success 'HEAD reflog symbolic-ref' '
hcnt1=$(git reflog show HEAD | wc -l) &&
git symbolic-ref HEAD refs/heads/unu &&
git symbolic-ref HEAD refs/heads/du &&
@@ -62,7 +62,7 @@ test_expect_failure 'HEAD reflog symbolic-ref' '
test $hcnt1 = $hcnt2
'
-test_expect_failure 'refs/heads/KVAR reflog symbolic-ref' '
+test_expect_success 'refs/heads/KVAR reflog symbolic-ref' '
kcnt1=$(git reflog show refs/heads/KVAR | wc -l) &&
git symbolic-ref refs/heads/KVAR refs/heads/tri &&
git symbolic-ref refs/heads/KVAR refs/heads/du &&
@@ -71,7 +71,7 @@ test_expect_failure 'refs/heads/KVAR reflog symbolic-ref' '
test $kcnt1 = $kcnt2
'
-test_expect_failure 'double symref reflog symbolic-ref' '
+test_expect_success 'double symref reflog symbolic-ref' '
hcnt1=$(git reflog show HEAD | wc -l) &&
kcnt1=$(git reflog show refs/heads/KVAR | wc -l) &&
git symbolic-ref HEAD refs/heads/KVAR &&
--