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

Function is_writing_gitmodules_ok

submodule.c:74–79  ·  view source on GitHub ↗

* Check if the .gitmodules file is safe to write. * * Writing to the .gitmodules file requires that the file exists in the * working tree or, if it doesn't, that a brand new .gitmodules file is going * to be created (i.e. it's neither in the index nor in the current branch). * * It is not safe to write to .gitmodules if it's not in the working tree but * it is in the index or in the current

Source from the content-addressed store, hash-verified

72 * (and staging them) would blindly overwrite ALL the old content.
73 */
74int is_writing_gitmodules_ok(void)
75{
76 struct object_id oid;
77 return file_exists(GITMODULES_FILE) ||
78 (repo_get_oid(the_repository, GITMODULES_INDEX, &oid) < 0 && repo_get_oid(the_repository, GITMODULES_HEAD, &oid) < 0);
79}
80
81/*
82 * Check if the .gitmodules file has unstaged modifications. This must be

Callers 5

module_addFunction · 0.85

Calls 2

file_existsFunction · 0.85
repo_get_oidFunction · 0.85

Tested by 3