lockfile: change lock_file::filename into a strbuf
For now, we still make sure to allocate at least PATH_MAX characters for the strbuf because resolve_symlink() doesn't know how to expand the space for its return value. (That will be fixed in a moment.) Another alternative would be to just use a strbuf as scratch space in lock_file() but then store a pointer to the naked string in struct lock_file. But lock_file objects are often reused. By reusing the same strbuf, we can avoid having to reallocate the string most times when a lock_file object is reused. Helped-by: Torsten Bögershausen <tboegi@web.de> Signed-off-by: Michael Haggerty <mhagger@alum.mit.edu> Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
committed by
Junio C Hamano
parent
3e88e8fc08
commit
cf6950d3bf
@ -431,7 +431,7 @@ static int expire_reflog(const char *ref, const unsigned char *sha1, int unused,
|
||||
write_str_in_full(lock->lock_fd, "\n") != 1 ||
|
||||
close_ref(lock) < 0)) {
|
||||
status |= error("Couldn't write %s",
|
||||
lock->lk->filename);
|
||||
lock->lk->filename.buf);
|
||||
unlink(newlog_path);
|
||||
} else if (rename(newlog_path, log_file)) {
|
||||
status |= error("cannot rename %s to %s",
|
||||
|
||||
Reference in New Issue
Block a user