Skip to content

Commit ba43b7f

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 ad4cd6c commit ba43b7f

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
@@ -2773,8 +2773,9 @@ static int rename_ref_available(const char *oldname, const char *newname)
27732773
return ret;
27742774
}
27752775

2776-
static int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1,
2777-
const char *logmsg);
2776+
static int write_ref_to_lockfile(struct ref_lock *lock, const unsigned char *sha1);
2777+
static int commit_ref_update(struct ref_lock *lock,
2778+
const unsigned char *sha1, const char *logmsg);
27782779

27792780
int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)
27802781
{
@@ -2832,7 +2833,9 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
28322833
goto rollback;
28332834
}
28342835
hashcpy(lock->old_sha1, orig_sha1);
2835-
if (write_ref_sha1(lock, orig_sha1, logmsg)) {
2836+
2837+
if (write_ref_to_lockfile(lock, orig_sha1) ||
2838+
commit_ref_update(lock, orig_sha1, logmsg)) {
28362839
error("unable to write current sha1 into %s", newrefname);
28372840
goto rollback;
28382841
}
@@ -2848,7 +2851,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
28482851

28492852
flag = log_all_ref_updates;
28502853
log_all_ref_updates = 0;
2851-
if (write_ref_sha1(lock, orig_sha1, NULL))
2854+
if (write_ref_to_lockfile(lock, orig_sha1) ||
2855+
commit_ref_update(lock, orig_sha1, NULL))
28522856
error("unable to write current sha1 into %s", oldrefname);
28532857
log_all_ref_updates = flag;
28542858

0 commit comments

Comments
 (0)