Skip to content

Commit 29957fd

Browse files
mhaggergitster
authored andcommitted
rename_ref(): inline calls to write_ref_sha1() from this function
Most of what it does is unneeded from these call sites. Signed-off-by: Michael Haggerty <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 38e50e8 commit 29957fd

File tree

1 file changed

+8
-4
lines changed

1 file changed

+8
-4
lines changed

refs.c

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -2799,8 +2799,9 @@ static int rename_ref_available(const char *oldname, const char *newname)
27992799
return ret;
28002800
}
28012801

2802-
static int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1,
2803-
const char *logmsg);
2802+
static int write_ref_to_lockfile(struct ref_lock *lock, const unsigned char *sha1);
2803+
static int commit_ref_update(struct ref_lock *lock,
2804+
const unsigned char *sha1, const char *logmsg);
28042805

28052806
int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)
28062807
{
@@ -2859,7 +2860,9 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
28592860
}
28602861
lock->force_write = 1;
28612862
hashcpy(lock->old_sha1, orig_sha1);
2862-
if (write_ref_sha1(lock, orig_sha1, logmsg)) {
2863+
2864+
if (write_ref_to_lockfile(lock, orig_sha1) ||
2865+
commit_ref_update(lock, orig_sha1, logmsg)) {
28632866
error("unable to write current sha1 into %s", newrefname);
28642867
goto rollback;
28652868
}
@@ -2876,7 +2879,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
28762879
lock->force_write = 1;
28772880
flag = log_all_ref_updates;
28782881
log_all_ref_updates = 0;
2879-
if (write_ref_sha1(lock, orig_sha1, NULL))
2882+
if (write_ref_to_lockfile(lock, orig_sha1) ||
2883+
commit_ref_update(lock, orig_sha1, NULL))
28802884
error("unable to write current sha1 into %s", oldrefname);
28812885
log_all_ref_updates = flag;
28822886

0 commit comments

Comments
 (0)