Skip to content

Commit 4e2bef5

Browse files
dturner-twgitster
authored andcommitted
refs: break out check for reflog autocreation
This is just for clarity. Signed-off-by: David Turner <dturner@twopensource.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
1 parent a4c653d commit 4e2bef5

File tree

1 file changed

+11
-5
lines changed

1 file changed

+11
-5
lines changed

refs.c

Lines changed: 11 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -3053,6 +3053,16 @@ static int copy_msg(char *buf, const char *msg)
30533053
return cp - buf;
30543054
}
30553055

3056+
static int should_autocreate_reflog(const char *refname)
3057+
{
3058+
if (!log_all_ref_updates)
3059+
return 0;
3060+
return starts_with(refname, "refs/heads/") ||
3061+
starts_with(refname, "refs/remotes/") ||
3062+
starts_with(refname, "refs/notes/") ||
3063+
!strcmp(refname, "HEAD");
3064+
}
3065+
30563066
/* This function will fill in *err and return -1 on failure */
30573067
int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct strbuf *err)
30583068
{
@@ -3063,11 +3073,7 @@ int log_ref_setup(const char *refname, struct strbuf *sb_logfile, struct strbuf
30633073
logfile = sb_logfile->buf;
30643074
/* make sure the rest of the function can't change "logfile" */
30653075
sb_logfile = NULL;
3066-
if (log_all_ref_updates &&
3067-
(starts_with(refname, "refs/heads/") ||
3068-
starts_with(refname, "refs/remotes/") ||
3069-
starts_with(refname, "refs/notes/") ||
3070-
!strcmp(refname, "HEAD"))) {
3076+
if (should_autocreate_reflog(refname)) {
30713077
if (safe_create_leading_directories(logfile) < 0) {
30723078
strbuf_addf(err, "unable to create directory for %s: "
30733079
"%s", logfile, strerror(errno));

0 commit comments

Comments
 (0)