File tree Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Expand file tree Collapse file tree 1 file changed +4
-1
lines changed Original file line number Diff line number Diff line change @@ -1565,14 +1565,17 @@ static int save_head(const char *head)
1565
1565
static struct lock_file head_lock ;
1566
1566
struct strbuf buf = STRBUF_INIT ;
1567
1567
int fd ;
1568
+ ssize_t written ;
1568
1569
1569
1570
fd = hold_lock_file_for_update (& head_lock , git_path_head_file (), 0 );
1570
1571
if (fd < 0 ) {
1571
1572
rollback_lock_file (& head_lock );
1572
1573
return error_errno (_ ("could not lock HEAD" ));
1573
1574
}
1574
1575
strbuf_addf (& buf , "%s\n" , head );
1575
- if (write_in_full (fd , buf .buf , buf .len ) < 0 ) {
1576
+ written = write_in_full (fd , buf .buf , buf .len );
1577
+ strbuf_release (& buf );
1578
+ if (written < 0 ) {
1576
1579
rollback_lock_file (& head_lock );
1577
1580
return error_errno (_ ("could not write to '%s'" ),
1578
1581
git_path_head_file ());
You can’t perform that action at this time.
0 commit comments