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

Function commit_ref

refs/files-backend.c:1810–1839  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1808}
1809
1810static int commit_ref(struct ref_lock *lock)
1811{
1812 char *path = get_locked_file_path(&lock->lk);
1813 struct stat st;
1814
1815 if (!lstat(path, &st) && S_ISDIR(st.st_mode)) {
1816 /*
1817 * There is a directory at the path we want to rename
1818 * the lockfile to. Hopefully it is empty; try to
1819 * delete it.
1820 */
1821 size_t len = strlen(path);
1822 struct strbuf sb_path = STRBUF_INIT;
1823
1824 strbuf_attach(&sb_path, path, len, len + 1);
1825
1826 /*
1827 * If this fails, commit_lock_file() will also fail
1828 * and will report the problem.
1829 */
1830 remove_empty_directories(&sb_path);
1831 strbuf_release(&sb_path);
1832 } else {
1833 free(path);
1834 }
1835
1836 if (commit_lock_file(&lock->lk))
1837 return -1;
1838 return 0;
1839}
1840
1841static int open_or_create_logfile(const char *path, void *cb)
1842{

Callers 3

commit_ref_updateFunction · 0.85
files_transaction_finishFunction · 0.85
files_reflog_expireFunction · 0.85

Calls 5

get_locked_file_pathFunction · 0.85
strbuf_attachFunction · 0.85
remove_empty_directoriesFunction · 0.85
strbuf_releaseFunction · 0.85
commit_lock_fileFunction · 0.85

Tested by

no test coverage detected