]> git.ipfire.org Git - thirdparty/git.git/commitdiff
entry: extract a header file for entry.c functions
authorMatheus Tavares <matheus.bernardino@usp.br>
Tue, 23 Mar 2021 14:19:32 +0000 (11:19 -0300)
committerJunio C Hamano <gitster@pobox.com>
Tue, 23 Mar 2021 17:34:05 +0000 (10:34 -0700)
The declarations of entry.c's public functions and structures currently
reside in cache.h. Although not many, they contribute to the size of
cache.h and, when changed, cause the unnecessary recompilation of
modules that don't really use these functions. So let's move them to a
new entry.h header. While at it let's also move a comment related to
checkout_entry() from entry.c to entry.h as it's more useful to describe
the function there.

Original-patch-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
apply.c
builtin/checkout-index.c
builtin/checkout.c
builtin/difftool.c
builtin/stash.c
cache.h
entry.c
entry.h [new file with mode: 0644]
unpack-trees.c

diff --git a/apply.c b/apply.c
index 668b16e9893d2f1e0501f2771716138db6e2efdd..ea92a2455d7cb0392b78883ae7f6e63c97029b0e 100644 (file)
--- a/apply.c
+++ b/apply.c
@@ -21,6 +21,7 @@
 #include "quote.h"
 #include "rerere.h"
 #include "apply.h"
+#include "entry.h"
 
 struct gitdiff_data {
        struct strbuf *root;
index 023e49e271c2e3ed2dc4c5f1f27d39000353aeb7..c0bf4ac1b2d5d0d51989f1adaa8ceca46721ca27 100644 (file)
@@ -11,6 +11,7 @@
 #include "quote.h"
 #include "cache-tree.h"
 #include "parse-options.h"
+#include "entry.h"
 
 #define CHECKOUT_ALL 4
 static int nul_term_line;
index 2d6550bc3c8638a3d25a04924a1352a43854d4c6..06c90d76e8d052604997d6861663a2291493a66f 100644 (file)
@@ -26,6 +26,7 @@
 #include "unpack-trees.h"
 #include "wt-status.h"
 #include "xdiff-interface.h"
+#include "entry.h"
 
 static const char * const checkout_usage[] = {
        N_("git checkout [<options>] <branch>"),
index 6e18e623fddfbfb33a3de9f4df8cabbbc048ed51..ef25729d4966fa9ac8361e6c96656fd071c5c97e 100644 (file)
@@ -23,6 +23,7 @@
 #include "lockfile.h"
 #include "object-store.h"
 #include "dir.h"
+#include "entry.h"
 
 static int trust_exit_code;
 
index ba774cce674f339bf68d5fcda80eb8b2d8253cf2..11f3ae303933a4c956f120fadac60bf267c78a13 100644 (file)
@@ -15,6 +15,7 @@
 #include "log-tree.h"
 #include "diffcore.h"
 #include "exec-cmd.h"
+#include "entry.h"
 
 #define INCLUDE_ALL_FILES 2
 
diff --git a/cache.h b/cache.h
index 6fda8091f11de129b2f52a8d3aa58216023d6c34..5d45d145faae07c28a5778c3f2872a4ab9a07eaa 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -1621,30 +1621,6 @@ const char *show_ident_date(const struct ident_split *id,
  */
 int ident_cmp(const struct ident_split *, const struct ident_split *);
 
-struct checkout {
-       struct index_state *istate;
-       const char *base_dir;
-       int base_dir_len;
-       struct delayed_checkout *delayed_checkout;
-       struct checkout_metadata meta;
-       unsigned force:1,
-                quiet:1,
-                not_new:1,
-                clone:1,
-                refresh_cache:1;
-};
-#define CHECKOUT_INIT { NULL, "" }
-
-#define TEMPORARY_FILENAME_LENGTH 25
-int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath, int *nr_checkouts);
-void enable_delayed_checkout(struct checkout *state);
-int finish_delayed_checkout(struct checkout *state, int *nr_checkouts);
-/*
- * Unlink the last component and schedule the leading directories for
- * removal, such that empty directories get removed.
- */
-void unlink_entry(const struct cache_entry *ce);
-
 struct cache_def {
        struct strbuf path;
        int flags;
diff --git a/entry.c b/entry.c
index 7b9f43716f76e6e7a701966045429b263cfb691e..c3e511bfb34d29ca6d3e782b760ea87547d8bf38 100644 (file)
--- a/entry.c
+++ b/entry.c
@@ -6,6 +6,7 @@
 #include "submodule.h"
 #include "progress.h"
 #include "fsmonitor.h"
+#include "entry.h"
 
 static void create_directories(const char *path, int path_len,
                               const struct checkout *state)
@@ -429,14 +430,6 @@ static void mark_colliding_entries(const struct checkout *state,
        }
 }
 
-/*
- * Write the contents from ce out to the working tree.
- *
- * When topath[] is not NULL, instead of writing to the working tree
- * file named by ce, a temporary file is created by this function and
- * its name is returned in topath[], which must be able to hold at
- * least TEMPORARY_FILENAME_LENGTH bytes long.
- */
 int checkout_entry(struct cache_entry *ce, const struct checkout *state,
                   char *topath, int *nr_checkouts)
 {
diff --git a/entry.h b/entry.h
new file mode 100644 (file)
index 0000000..acbbb90
--- /dev/null
+++ b/entry.h
@@ -0,0 +1,42 @@
+#ifndef ENTRY_H
+#define ENTRY_H
+
+#include "cache.h"
+#include "convert.h"
+
+struct checkout {
+       struct index_state *istate;
+       const char *base_dir;
+       int base_dir_len;
+       struct delayed_checkout *delayed_checkout;
+       struct checkout_metadata meta;
+       unsigned force:1,
+                quiet:1,
+                not_new:1,
+                clone:1,
+                refresh_cache:1;
+};
+#define CHECKOUT_INIT { NULL, "" }
+
+#define TEMPORARY_FILENAME_LENGTH 25
+/*
+ * Write the contents from ce out to the working tree.
+ *
+ * When topath[] is not NULL, instead of writing to the working tree
+ * file named by ce, a temporary file is created by this function and
+ * its name is returned in topath[], which must be able to hold at
+ * least TEMPORARY_FILENAME_LENGTH bytes long.
+ */
+int checkout_entry(struct cache_entry *ce, const struct checkout *state,
+                  char *topath, int *nr_checkouts);
+
+void enable_delayed_checkout(struct checkout *state);
+int finish_delayed_checkout(struct checkout *state, int *nr_checkouts);
+
+/*
+ * Unlink the last component and schedule the leading directories for
+ * removal, such that empty directories get removed.
+ */
+void unlink_entry(const struct cache_entry *ce);
+
+#endif /* ENTRY_H */
index eb8fcda31ba797132a6afec3d17a08eb138883e2..5b3dd38f8c66a80dab3ef15dae99afb9e80c0f73 100644 (file)
@@ -16,6 +16,7 @@
 #include "fsmonitor.h"
 #include "object-store.h"
 #include "promisor-remote.h"
+#include "entry.h"
 
 /*
  * Error messages expected by scripts out of plumbing commands such as