object-file: move mkdir_in_gitdir() into "path.c"

The `mkdir_in_gitdir()` function is similar to `safe_create_dir()`, but
the former is hosted in "object-file.c" whereas the latter is hosted in
"path.c". The latter code unit makes way more sense though as the logic
has nothing to do with object files in particular.

Move the file into "path.c". While at it, we:

  - Rename the function to `safe_create_dir_in_gitdir()` so that the
    function names are similar to one another.

  - Remove the dependency on `the_repository` by making the callers pass
    the repository instead.

Adjust callers accordingly.

Signed-off-by: Patrick Steinhardt <ps@pks.im>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
This commit is contained in:
Patrick Steinhardt
2025-04-15 11:38:14 +02:00
committed by Junio C Hamano
parent 0dfca98881
commit d1fa670de0
6 changed files with 47 additions and 36 deletions

11
path.h
View File

@@ -221,6 +221,17 @@ char *xdg_cache_home(const char *filename);
*/
void safe_create_dir(struct repository *repo, const char *dir, int share);
/*
* Similar to `safe_create_dir()`, but with two differences:
*
* - It knows to resolve gitlink files for symlinked worktrees.
*
* - It always adjusts shared permissions.
*
* Returns a negative erorr code on error, 0 on success.
*/
int safe_create_dir_in_gitdir(struct repository *repo, const char *path);
# ifdef USE_THE_REPOSITORY_VARIABLE
# include "strbuf.h"
# include "repository.h"