summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMichael Haggerty <mhagger@alum.mit.edu>2015-05-10 04:45:34 +0200
committerJunio C Hamano <gitster@pobox.com>2015-05-13 06:25:26 +0200
commit29957fda0b6a061c49792875f303570b4b451d62 (patch)
tree15a7c11512d0c033d84990283813cc41a6528131
parentcommit_ref_update(): new function, extracted from write_ref_sha1() (diff)
downloadgit-29957fda0b6a061c49792875f303570b4b451d62.tar.xz
git-29957fda0b6a061c49792875f303570b4b451d62.zip
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 <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r--refs.c12
1 files changed, 8 insertions, 4 deletions
diff --git a/refs.c b/refs.c
index 7661db9563..18ce8e6e89 100644
--- a/refs.c
+++ b/refs.c
@@ -2799,8 +2799,9 @@ static int rename_ref_available(const char *oldname, const char *newname)
return ret;
}
-static int write_ref_sha1(struct ref_lock *lock, const unsigned char *sha1,
- const char *logmsg);
+static int write_ref_to_lockfile(struct ref_lock *lock, const unsigned char *sha1);
+static int commit_ref_update(struct ref_lock *lock,
+ const unsigned char *sha1, const char *logmsg);
int rename_ref(const char *oldrefname, const char *newrefname, const char *logmsg)
{
@@ -2859,7 +2860,9 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
}
lock->force_write = 1;
hashcpy(lock->old_sha1, orig_sha1);
- if (write_ref_sha1(lock, orig_sha1, logmsg)) {
+
+ if (write_ref_to_lockfile(lock, orig_sha1) ||
+ commit_ref_update(lock, orig_sha1, logmsg)) {
error("unable to write current sha1 into %s", newrefname);
goto rollback;
}
@@ -2876,7 +2879,8 @@ int rename_ref(const char *oldrefname, const char *newrefname, const char *logms
lock->force_write = 1;
flag = log_all_ref_updates;
log_all_ref_updates = 0;
- if (write_ref_sha1(lock, orig_sha1, NULL))
+ if (write_ref_to_lockfile(lock, orig_sha1) ||
+ commit_ref_update(lock, orig_sha1, NULL))
error("unable to write current sha1 into %s", oldrefname);
log_all_ref_updates = flag;