Skip to content

Commit b1cda70

Browse files
committed
Merge branch 'dt/refs-backend-pre-vtable'
Code preparation for pluggable ref backends. * dt/refs-backend-pre-vtable: refs: break out ref conflict checks files_log_ref_write: new function initdb: make safe_create_dir public refs: split filesystem-based refs code into a new file refs/refs-internal.h: new header file refname_is_safe(): improve docstring pack_if_possible_fn(): use ref_type() instead of is_per_worktree_ref() copy_msg(): rename to copy_reflog_msg() verify_refname_available(): new function verify_refname_available(): rename function
2 parents fa5f239 + 0845122 commit b1cda70

File tree

7 files changed

+3949
-3855
lines changed

7 files changed

+3949
-3855
lines changed

Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -772,6 +772,7 @@ LIB_OBJS += reachable.o
772772
LIB_OBJS += read-cache.o
773773
LIB_OBJS += reflog-walk.o
774774
LIB_OBJS += refs.o
775+
LIB_OBJS += refs/files-backend.o
775776
LIB_OBJS += ref-filter.o
776777
LIB_OBJS += remote.o
777778
LIB_OBJS += replace_object.o
@@ -2432,7 +2433,7 @@ profile-clean:
24322433
$(RM) $(addsuffix *.gcno,$(addprefix $(PROFILE_DIR)/, $(object_dirs)))
24332434

24342435
clean: profile-clean coverage-clean
2435-
$(RM) *.o *.res block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o
2436+
$(RM) *.o *.res refs/*.o block-sha1/*.o ppc/*.o compat/*.o compat/*/*.o
24362437
$(RM) xdiff/*.o vcs-svn/*.o ewah/*.o builtin/*.o
24372438
$(RM) $(LIB_FILE) $(XDIFF_LIB) $(VCSSVN_LIB)
24382439
$(RM) $(ALL_PROGRAMS) $(SCRIPT_LIB) $(BUILT_INS) git$X

builtin/init-db.c

Lines changed: 0 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -24,18 +24,6 @@ static int init_shared_repository = -1;
2424
static const char *init_db_template_dir;
2525
static const char *git_link;
2626

27-
static void safe_create_dir(const char *dir, int share)
28-
{
29-
if (mkdir(dir, 0777) < 0) {
30-
if (errno != EEXIST) {
31-
perror(dir);
32-
exit(1);
33-
}
34-
}
35-
else if (share && adjust_shared_perm(dir))
36-
die(_("Could not make %s writable by group"), dir);
37-
}
38-
3927
static void copy_templates_1(struct strbuf *path, struct strbuf *template,
4028
DIR *dir)
4129
{

cache.h

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1768,4 +1768,12 @@ void stat_validity_update(struct stat_validity *sv, int fd);
17681768
int versioncmp(const char *s1, const char *s2);
17691769
void sleep_millisec(int millisec);
17701770

1771+
/*
1772+
* Create a directory and (if share is nonzero) adjust its permissions
1773+
* according to the shared_repository setting. Only use this for
1774+
* directories under $GIT_DIR. Don't use it for working tree
1775+
* directories.
1776+
*/
1777+
void safe_create_dir(const char *dir, int share);
1778+
17711779
#endif /* CACHE_H */

path.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -740,6 +740,18 @@ int adjust_shared_perm(const char *path)
740740
return 0;
741741
}
742742

743+
void safe_create_dir(const char *dir, int share)
744+
{
745+
if (mkdir(dir, 0777) < 0) {
746+
if (errno != EEXIST) {
747+
perror(dir);
748+
exit(1);
749+
}
750+
}
751+
else if (share && adjust_shared_perm(dir))
752+
die(_("Could not make %s writable by group"), dir);
753+
}
754+
743755
static int have_same_root(const char *path1, const char *path2)
744756
{
745757
int is_abs1, is_abs2;

0 commit comments

Comments
 (0)