- len = snprintf(buf, sizeof(buf), "ref: %s\n", target);
- if (sizeof(buf) <= len) {
- error("refname too long: %s", target);
- goto error_free_return;
- }
- lockpath = mkpathdup("%s.lock", ref_path);
- fd = open(lockpath, O_CREAT | O_EXCL | O_WRONLY, 0666);
- if (fd < 0) {
- error("Unable to open %s for writing", lockpath);
- goto error_free_return;
- }
- written = write_in_full(fd, buf, len);
- if (close(fd) != 0 || written != len) {
- error("Unable to write to %s", lockpath);
- goto error_unlink_return;
- }
- if (rename(lockpath, ref_path) < 0) {
- error("Unable to create %s", ref_path);
- goto error_unlink_return;
- }
- if (adjust_shared_perm(ref_path)) {
- error("Unable to fix permissions on %s", lockpath);
- error_unlink_return:
- unlink_or_warn(lockpath);
- error_free_return:
- free(lockpath);
- free(ref_path);
- return -1;
- }
- free(lockpath);
-
-#ifndef NO_SYMLINK_HEAD
- done:
-#endif
+static void update_symref_reflog(struct ref_lock *lock, const char *refname,
+ const char *target, const char *logmsg)
+{
+ struct strbuf err = STRBUF_INIT;
+ unsigned char new_sha1[20];