MCPcopy Create free account
hub / github.com/git/git / files_log_ref_write

Function files_log_ref_write

refs/files-backend.c:1955–1999  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1953}
1954
1955static int files_log_ref_write(struct files_ref_store *refs,
1956 const char *refname,
1957 const struct object_id *old_oid,
1958 const struct object_id *new_oid,
1959 const char *committer_info, const char *msg,
1960 int flags, struct strbuf *err)
1961{
1962 int logfd, result;
1963
1964 if (flags & REF_SKIP_CREATE_REFLOG)
1965 return 0;
1966
1967 result = log_ref_setup(refs, refname,
1968 flags & REF_FORCE_CREATE_REFLOG,
1969 &logfd, err);
1970
1971 if (result)
1972 return result;
1973
1974 if (logfd < 0)
1975 return 0;
1976 result = log_ref_write_fd(logfd, old_oid, new_oid, committer_info, msg);
1977 if (result) {
1978 struct strbuf sb = STRBUF_INIT;
1979 int save_errno = errno;
1980
1981 files_reflog_path(refs, &sb, refname);
1982 strbuf_addf(err, "unable to append to '%s': %s",
1983 sb.buf, strerror(save_errno));
1984 strbuf_release(&sb);
1985 close(logfd);
1986 return -1;
1987 }
1988 if (close(logfd)) {
1989 struct strbuf sb = STRBUF_INIT;
1990 int save_errno = errno;
1991
1992 files_reflog_path(refs, &sb, refname);
1993 strbuf_addf(err, "unable to append to '%s': %s",
1994 sb.buf, strerror(save_errno));
1995 strbuf_release(&sb);
1996 return -1;
1997 }
1998 return 0;
1999}
2000
2001/*
2002 * Write oid into the open lockfile, then close the lockfile. On

Callers 2

commit_ref_updateFunction · 0.85
parse_and_write_reflogFunction · 0.85

Calls 5

log_ref_setupFunction · 0.85
log_ref_write_fdFunction · 0.85
files_reflog_pathFunction · 0.85
strbuf_addfFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected