MCPcopy Index your code
hub / github.com/git/git / lock_file

Function lock_file

lockfile.c:165–187  ·  view source on GitHub ↗

Make sure errno contains a meaningful value on error */

Source from the content-addressed store, hash-verified

163
164/* Make sure errno contains a meaningful value on error */
165static int lock_file(struct lock_file *lk, const char *path, int flags,
166 int mode)
167{
168 struct strbuf base_path = STRBUF_INIT;
169 struct strbuf lock_path = STRBUF_INIT;
170 struct strbuf pid_path = STRBUF_INIT;
171
172 strbuf_addstr(&base_path, path);
173 if (!(flags & LOCK_NO_DEREF))
174 resolve_symlink(&base_path);
175
176 get_lock_path(&lock_path, base_path.buf);
177 get_pid_path(&pid_path, base_path.buf);
178
179 lk->tempfile = create_tempfile_mode(lock_path.buf, mode);
180 if (lk->tempfile)
181 lk->pid_tempfile = create_lock_pid_file(pid_path.buf, mode);
182
183 strbuf_release(&base_path);
184 strbuf_release(&lock_path);
185 strbuf_release(&pid_path);
186 return lk->tempfile ? lk->tempfile->fd : -1;
187}
188
189/*
190 * Constants defining the gaps between attempts to lock a file. The

Callers 1

lock_file_timeoutFunction · 0.70

Calls 7

strbuf_addstrFunction · 0.85
resolve_symlinkFunction · 0.85
get_lock_pathFunction · 0.85
get_pid_pathFunction · 0.85
create_tempfile_modeFunction · 0.85
create_lock_pid_fileFunction · 0.85
strbuf_releaseFunction · 0.85

Tested by

no test coverage detected