Commit 66cba96f002a13482c34efaaf5ace08a33f45ec4

Stefan Sperling 2020-03-18T16:11:27

use GOT_OBJECTS_PACK_DIR instead of variants of the same which contain typos

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)
 {