]> granicus.if.org Git - git/commitdiff
pack: move pack-closing functions
authorJonathan Tan <jonathantanmy@google.com>
Fri, 18 Aug 2017 22:20:21 +0000 (15:20 -0700)
committerJunio C Hamano <gitster@pobox.com>
Wed, 23 Aug 2017 22:12:06 +0000 (15:12 -0700)
The function close_pack_fd() needs to be temporarily made global. Its
scope will be restored to static in a subsequent commit.

Signed-off-by: Jonathan Tan <jonathantanmy@google.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/am.c
builtin/clone.c
builtin/fetch.c
builtin/merge.c
builtin/receive-pack.c
cache.h
packfile.c
packfile.h
sha1_file.c

index 81095dae029836febd8bfb5504fdb39866ed5cf6..c369dd1dce2d705206414d0bbf5a4415d9487cab 100644 (file)
@@ -31,6 +31,7 @@
 #include "mailinfo.h"
 #include "apply.h"
 #include "string-list.h"
+#include "packfile.h"
 
 /**
  * Returns 1 if the file is empty or does not exist, 0 otherwise.
index f7e17d22951cfd8e498143c009fa0303d0ff8319..8d11b570a1ca43eae3224ade805352b8a447423e 100644 (file)
@@ -25,6 +25,7 @@
 #include "remote.h"
 #include "run-command.h"
 #include "connected.h"
+#include "packfile.h"
 
 /*
  * Overall FIXMEs:
index d84c26391c59cddb57d278b81f69ddf72af01fa8..08e094bf1237407f3de937970f2b7ea39c359f43 100644 (file)
@@ -17,6 +17,7 @@
 #include "connected.h"
 #include "argv-array.h"
 #include "utf8.h"
+#include "packfile.h"
 
 static const char * const builtin_fetch_usage[] = {
        N_("git fetch [<options>] [<repository> [<refspec>...]]"),
index 328945d6093aae40410b0c437a21c588ac6d6692..dfd6830602e62ec2cc0439b8e140bda6eae6e9fb 100644 (file)
@@ -32,6 +32,7 @@
 #include "gpg-interface.h"
 #include "sequencer.h"
 #include "string-list.h"
+#include "packfile.h"
 
 #define DEFAULT_TWOHEAD (1<<0)
 #define DEFAULT_OCTOPUS (1<<1)
index 14b6e09b42f1d423307c98275f5b203078b82445..52c63ebfdc737688a7d99f6be34c43cf80b1d011 100644 (file)
@@ -23,6 +23,7 @@
 #include "fsck.h"
 #include "tmp-objdir.h"
 #include "oidset.h"
+#include "packfile.h"
 
 static const char * const receive_pack_usage[] = {
        N_("git receive-pack <git-dir>"),
diff --git a/cache.h b/cache.h
index 9fd61e9ea0039e656c617110d0a7c4d558e27ceb..48f44959d26a9ebca2b7a69f14706a8d7ded2c3f 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1639,15 +1639,7 @@ extern int odb_mkstemp(struct strbuf *template, const char *pattern);
  */
 extern int odb_pack_keep(const char *name);
 
-/*
- * munmap the index file for the specified packfile (if it is
- * currently mmapped).
- */
-extern void close_pack_index(struct packed_git *);
-
 extern unsigned char *use_pack(struct packed_git *, struct pack_window **, off_t, unsigned long *);
-extern void close_pack_windows(struct packed_git *);
-extern void close_all_packs(void);
 extern void unuse_pack(struct pack_window **);
 extern void clear_delta_base_cache(void);
 extern struct packed_git *add_packed_git(const char *path, size_t path_len, int local);
index 8daa74ad11b5d473235fba9fa5270aaaf81689e6..c8e2dbdeecba351ff3009f77c8e5859fa089f24f 100644 (file)
@@ -257,3 +257,57 @@ void release_pack_memory(size_t need)
        while (need >= (cur - pack_mapped) && unuse_one_window(NULL))
                ; /* nothing */
 }
+
+void close_pack_windows(struct packed_git *p)
+{
+       while (p->windows) {
+               struct pack_window *w = p->windows;
+
+               if (w->inuse_cnt)
+                       die("pack '%s' still has open windows to it",
+                           p->pack_name);
+               munmap(w->base, w->len);
+               pack_mapped -= w->len;
+               pack_open_windows--;
+               p->windows = w->next;
+               free(w);
+       }
+}
+
+int close_pack_fd(struct packed_git *p)
+{
+       if (p->pack_fd < 0)
+               return 0;
+
+       close(p->pack_fd);
+       pack_open_fds--;
+       p->pack_fd = -1;
+
+       return 1;
+}
+
+void close_pack_index(struct packed_git *p)
+{
+       if (p->index_data) {
+               munmap((void *)p->index_data, p->index_size);
+               p->index_data = NULL;
+       }
+}
+
+static void close_pack(struct packed_git *p)
+{
+       close_pack_windows(p);
+       close_pack_fd(p);
+       close_pack_index(p);
+}
+
+void close_all_packs(void)
+{
+       struct packed_git *p;
+
+       for (p = packed_git; p; p = p->next)
+               if (p->do_not_close)
+                       die("BUG: want to close pack marked 'do-not-close'");
+               else
+                       close_pack(p);
+}
index f6fe1c74184266a66e026718ff1f90dc4fa1a176..c6a07de6232ed5d626a6ba9c6fd2d903cc410fc6 100644 (file)
@@ -43,6 +43,17 @@ extern void pack_report(void);
  */
 extern int open_pack_index(struct packed_git *);
 
+/*
+ * munmap the index file for the specified packfile (if it is
+ * currently mmapped).
+ */
+extern void close_pack_index(struct packed_git *);
+
+extern void close_pack_windows(struct packed_git *);
+extern void close_all_packs(void);
+
+extern int close_pack_fd(struct packed_git *);
+
 extern int unuse_one_window(struct packed_git *current);
 
 extern void release_pack_memory(size_t);
index dce232fb5c6c5eed4fd92bea103cc9d9fe271ad0..de4aed63df292d8814fcf4279db0062147c6cbc1 100644 (file)
@@ -719,53 +719,6 @@ void *xmmap(void *start, size_t length,
        return ret;
 }
 
-void close_pack_windows(struct packed_git *p)
-{
-       while (p->windows) {
-               struct pack_window *w = p->windows;
-
-               if (w->inuse_cnt)
-                       die("pack '%s' still has open windows to it",
-                           p->pack_name);
-               munmap(w->base, w->len);
-               pack_mapped -= w->len;
-               pack_open_windows--;
-               p->windows = w->next;
-               free(w);
-       }
-}
-
-static int close_pack_fd(struct packed_git *p)
-{
-       if (p->pack_fd < 0)
-               return 0;
-
-       close(p->pack_fd);
-       pack_open_fds--;
-       p->pack_fd = -1;
-
-       return 1;
-}
-
-static void close_pack(struct packed_git *p)
-{
-       close_pack_windows(p);
-       close_pack_fd(p);
-       close_pack_index(p);
-}
-
-void close_all_packs(void)
-{
-       struct packed_git *p;
-
-       for (p = packed_git; p; p = p->next)
-               if (p->do_not_close)
-                       die("BUG: want to close pack marked 'do-not-close'");
-               else
-                       close_pack(p);
-}
-
-
 /*
  * The LRU pack is the one with the oldest MRU window, preferring packs
  * with no used windows, or the oldest mtime if it has no windows allocated.
@@ -848,14 +801,6 @@ void unuse_pack(struct pack_window **w_cursor)
        }
 }
 
-void close_pack_index(struct packed_git *p)
-{
-       if (p->index_data) {
-               munmap((void *)p->index_data, p->index_size);
-               p->index_data = NULL;
-       }
-}
-
 static unsigned int get_max_fd_limit(void)
 {
 #ifdef RLIMIT_NOFILE