* 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
| 72 | * (and staging them) would blindly overwrite ALL the old content. |
| 73 | */ |
| 74 | int 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 |