use GOT_OBJECTS_PACK_DIR instead of variants of the same which contain typos
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101
diff --git a/lib/fetch.c b/lib/fetch.c
index 72d9e46..93751d1 100644
--- a/lib/fetch.c
+++ b/lib/fetch.c
@@ -300,15 +300,8 @@ got_fetch(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
fetchfd = -1;
- if (asprintf(&path, "%s/objects/path", repo_path) == -1) {
- err = got_error_from_errno("asprintf");
- goto done;
- }
- err = got_path_mkdir(path);
- free(path);
- if (err)
- goto done;
- if (asprintf(&path, "%s/objects/path/fetching.pack", repo_path) == -1) {
+ if (asprintf(&path, "%s/%s/fetching.pack",
+ repo_path, GOT_OBJECTS_PACK_DIR) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
@@ -321,7 +314,8 @@ got_fetch(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
err = got_error_from_errno("dup");
goto done;
}
- if (asprintf(&path, "%s/objects/path/fetching.idx", repo_path) == -1) {
+ if (asprintf(&path, "%s/%s/fetching.idx",
+ repo_path, GOT_OBJECTS_PACK_DIR) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
@@ -441,14 +435,14 @@ got_fetch(struct got_object_id **pack_hash, struct got_pathlist_head *refs,
err = got_object_id_str(&id_str, *pack_hash);
if (err)
goto done;
- if (asprintf(&packpath, "%s/objects/pack/pack-%s.pack",
- repo_path, id_str) == -1) {
+ if (asprintf(&packpath, "%s/%s/pack-%s.pack",
+ repo_path, GOT_OBJECTS_PACK_DIR, id_str) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
- if (asprintf(&idxpath, "%s/objects/pack/pack-%s.idx",
- repo_path, id_str) == -1) {
+ if (asprintf(&idxpath, "%s/%s/pack-%s.idx",
+ repo_path, GOT_OBJECTS_PACK_DIR, id_str) == -1) {
err = got_error_from_errno("asprintf");
goto done;
}
diff --git a/lib/got_lib_repository.h b/lib/got_lib_repository.h
index 5b1a405..df440da 100644
--- a/lib/got_lib_repository.h
+++ b/lib/got_lib_repository.h
@@ -14,6 +14,20 @@
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
*/
+#define GOT_GIT_DIR ".git"
+
+/* Mandatory files and directories inside the git directory. */
+#define GOT_OBJECTS_DIR "objects"
+#define GOT_REFS_DIR "refs"
+#define GOT_HEAD_FILE "HEAD"
+#define GOT_GITCONFIG "config"
+
+/* Other files and directories inside the git directory. */
+#define GOT_FETCH_HEAD_FILE "FETCH_HEAD"
+#define GOT_ORIG_HEAD_FILE "ORIG_HEAD"
+#define GOT_OBJECTS_PACK_DIR "objects/pack"
+#define GOT_PACKED_REFS_FILE "packed-refs"
+
#define GOT_PACKIDX_CACHE_SIZE 16
#define GOT_PACK_CACHE_SIZE GOT_PACKIDX_CACHE_SIZE
diff --git a/lib/repository.c b/lib/repository.c
index 1b376cc..734d7b1 100644
--- a/lib/repository.c
+++ b/lib/repository.c
@@ -63,20 +63,6 @@
#define nitems(_a) (sizeof(_a) / sizeof((_a)[0]))
#endif
-#define GOT_GIT_DIR ".git"
-
-/* Mandatory files and directories inside the git directory. */
-#define GOT_OBJECTS_DIR "objects"
-#define GOT_REFS_DIR "refs"
-#define GOT_HEAD_FILE "HEAD"
-#define GOT_GITCONFIG "config"
-
-/* Other files and directories inside the git directory. */
-#define GOT_FETCH_HEAD_FILE "FETCH_HEAD"
-#define GOT_ORIG_HEAD_FILE "ORIG_HEAD"
-#define GOT_OBJECTS_PACK_DIR "objects/pack"
-#define GOT_PACKED_REFS_FILE "packed-refs"
-
const char *
got_repo_get_path(struct got_repository *repo)
{