path: create path.h
Move all path related declarations from cache.h to a new path.h header file. This makes cache.h smaller and makes it easier to add new path related functions. Signed-off-by: Brandon Williams <bmwill@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Brandon Williams committed
Jun 22, 2017 at 11:43 UTC
e7d72d07535012b73c6bed67a5a09b1f58082203
3 files changed
+64
-58
cache.h
+1
-58
@@ -11,6 +11,7 @@
11
#include "string-list.h"
12
#include "pack-revindex.h"
13
#include "hash.h"
14
+#include "path.h"
15
16
#ifndef platform_SHA_CTX
17
/*
@@ -892,64 +893,6 @@ extern void check_repository_format(void);
893
#define DATA_CHANGED 0x0020
894
#define TYPE_CHANGED 0x0040
895
895
-/*
896
- * Return a statically allocated filename, either generically (mkpath), in
897
- * the repository directory (git_path), or in a submodule's repository
898
- * directory (git_path_submodule). In all cases, note that the result
899
- * may be overwritten by another call to _any_ of the functions. Consider
900
- * using the safer "dup" or "strbuf" formats below (in some cases, the
901
- * unsafe versions have already been removed).
902
- */
903
-extern const char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
904
-extern const char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
905
-extern const char *git_common_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
906
-
907
-extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
908
- __attribute__((format (printf, 3, 4)));
909
-extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
910
- __attribute__((format (printf, 2, 3)));
911
-extern void strbuf_git_common_path(struct strbuf *sb, const char *fmt, ...)
912
- __attribute__((format (printf, 2, 3)));
913
-extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
914
- __attribute__((format (printf, 2, 3)));
915
-extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
916
- const char *fmt, ...)
917
- __attribute__((format (printf, 3, 4)));
918
-extern char *git_pathdup(const char *fmt, ...)
919
- __attribute__((format (printf, 1, 2)));
920
-extern char *mkpathdup(const char *fmt, ...)
921
- __attribute__((format (printf, 1, 2)));
922
-extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
923
- __attribute__((format (printf, 2, 3)));
924
-
925
-extern void report_linked_checkout_garbage(void);
926
-
927
-/*
928
- * You can define a static memoized git path like:
929
- *
930
- * static GIT_PATH_FUNC(git_path_foo, "FOO");
931
- *
932
- * or use one of the global ones below.
933
- */
934
-#define GIT_PATH_FUNC(func, filename) \
935
- const char *func(void) \
936
- { \
937
- static char *ret; \
938
- if (!ret) \
939
- ret = git_pathdup(filename); \
940
- return ret; \
941
- }
942
-
943
-const char *git_path_cherry_pick_head(void);
944
-const char *git_path_revert_head(void);
945
-const char *git_path_squash_msg(void);
946
-const char *git_path_merge_msg(void);
947
-const char *git_path_merge_rr(void);
948
-const char *git_path_merge_mode(void);
949
-const char *git_path_merge_head(void);
950
-const char *git_path_fetch_head(void);
951
-const char *git_path_shallow(void);
952
-
896
/*
897
* Return the name of the file in the local object database that would
898
* be used to store a loose object with the specified sha1. The
path.c
+1
@@ -8,6 +8,7 @@
8
#include "dir.h"
9
#include "worktree.h"
10
#include "submodule-config.h"
11
+#include "path.h"
12
13
static int get_st_mode_bits(const char *path, int *mode)
14
{
path.h
new
+62
@@ -0,0 +1,62 @@
1
+#ifndef PATH_H
2
+#define PATH_H
3
+
4
+/*
5
+ * Return a statically allocated filename, either generically (mkpath), in
6
+ * the repository directory (git_path), or in a submodule's repository
7
+ * directory (git_path_submodule). In all cases, note that the result
8
+ * may be overwritten by another call to _any_ of the functions. Consider
9
+ * using the safer "dup" or "strbuf" formats below (in some cases, the
10
+ * unsafe versions have already been removed).
11
+ */
12
+extern const char *mkpath(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
13
+extern const char *git_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
14
+extern const char *git_common_path(const char *fmt, ...) __attribute__((format (printf, 1, 2)));
15
+
16
+extern char *mksnpath(char *buf, size_t n, const char *fmt, ...)
17
+ __attribute__((format (printf, 3, 4)));
18
+extern void strbuf_git_path(struct strbuf *sb, const char *fmt, ...)
19
+ __attribute__((format (printf, 2, 3)));
20
+extern void strbuf_git_common_path(struct strbuf *sb, const char *fmt, ...)
21
+ __attribute__((format (printf, 2, 3)));
22
+extern char *git_path_buf(struct strbuf *buf, const char *fmt, ...)
23
+ __attribute__((format (printf, 2, 3)));
24
+extern int strbuf_git_path_submodule(struct strbuf *sb, const char *path,
25
+ const char *fmt, ...)
26
+ __attribute__((format (printf, 3, 4)));
27
+extern char *git_pathdup(const char *fmt, ...)
28
+ __attribute__((format (printf, 1, 2)));
29
+extern char *mkpathdup(const char *fmt, ...)
30
+ __attribute__((format (printf, 1, 2)));
31
+extern char *git_pathdup_submodule(const char *path, const char *fmt, ...)
32
+ __attribute__((format (printf, 2, 3)));
33
+
34
+extern void report_linked_checkout_garbage(void);
35
+
36
+/*
37
+ * You can define a static memoized git path like:
38
+ *
39
+ * static GIT_PATH_FUNC(git_path_foo, "FOO");
40
+ *
41
+ * or use one of the global ones below.
42
+ */
43
+#define GIT_PATH_FUNC(func, filename) \
44
+ const char *func(void) \
45
+ { \
46
+ static char *ret; \
47
+ if (!ret) \
48
+ ret = git_pathdup(filename); \
49
+ return ret; \
50
+ }
51
+
52
+const char *git_path_cherry_pick_head(void);
53
+const char *git_path_revert_head(void);
54
+const char *git_path_squash_msg(void);
55
+const char *git_path_merge_msg(void);
56
+const char *git_path_merge_rr(void);
57
+const char *git_path_merge_mode(void);
58
+const char *git_path_merge_head(void);
59
+const char *git_path_fetch_head(void);
60
+const char *git_path_shallow(void);
61
+
62
+#endif /* PATH_H */