@@ -3059,15 +3059,13 @@ static int write_ref_to_lockfile(struct ref_lock *lock,
3059
3059
}
3060
3060
3061
3061
/*
3062
- * Write sha1 into the ref specified by the lock. Make sure that errno
3063
- * is sane on error.
3062
+ * Commit a change to a loose reference that has already been written
3063
+ * to the loose reference lockfile. Also update the reflogs if
3064
+ * necessary, using the specified lockmsg (which can be NULL).
3064
3065
*/
3065
- static int write_ref_sha1 (struct ref_lock * lock ,
3066
- const unsigned char * sha1 , const char * logmsg )
3066
+ static int commit_ref_update (struct ref_lock * lock ,
3067
+ const unsigned char * sha1 , const char * logmsg )
3067
3068
{
3068
- if (write_ref_to_lockfile (lock , sha1 ))
3069
- return -1 ;
3070
-
3071
3069
clear_loose_ref_cache (& ref_cache );
3072
3070
if (log_ref_write (lock -> ref_name , lock -> old_sha1 , sha1 , logmsg ) < 0 ||
3073
3071
(strcmp (lock -> ref_name , lock -> orig_ref_name ) &&
@@ -3106,6 +3104,21 @@ static int write_ref_sha1(struct ref_lock *lock,
3106
3104
return 0 ;
3107
3105
}
3108
3106
3107
+ /*
3108
+ * Write sha1 as the new value of the reference specified by the
3109
+ * (open) lock. On error, roll back the lockfile and set errno
3110
+ * appropriately.
3111
+ */
3112
+ static int write_ref_sha1 (struct ref_lock * lock ,
3113
+ const unsigned char * sha1 , const char * logmsg )
3114
+ {
3115
+ if (write_ref_to_lockfile (lock , sha1 ) ||
3116
+ commit_ref_update (lock , sha1 , logmsg ))
3117
+ return -1 ;
3118
+
3119
+ return 0 ;
3120
+ }
3121
+
3109
3122
int create_symref (const char * ref_target , const char * refs_heads_master ,
3110
3123
const char * logmsg )
3111
3124
{
0 commit comments