Skip to content

Commit d052cc0

Browse files
matheustavaresgitster
authored andcommitted
entry: extract a header file for entry.c functions
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 <[email protected]> Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent f59d15b commit d052cc0

File tree

9 files changed

+49
-32
lines changed

9 files changed

+49
-32
lines changed

apply.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
#include "quote.h"
2222
#include "rerere.h"
2323
#include "apply.h"
24+
#include "entry.h"
2425

2526
struct gitdiff_data {
2627
struct strbuf *root;

builtin/checkout-index.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111
#include "quote.h"
1212
#include "cache-tree.h"
1313
#include "parse-options.h"
14+
#include "entry.h"
1415

1516
#define CHECKOUT_ALL 4
1617
static int nul_term_line;

builtin/checkout.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626
#include "unpack-trees.h"
2727
#include "wt-status.h"
2828
#include "xdiff-interface.h"
29+
#include "entry.h"
2930

3031
static const char * const checkout_usage[] = {
3132
N_("git checkout [<options>] <branch>"),

builtin/difftool.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
#include "lockfile.h"
2424
#include "object-store.h"
2525
#include "dir.h"
26+
#include "entry.h"
2627

2728
static int trust_exit_code;
2829

builtin/stash.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,7 @@
1515
#include "log-tree.h"
1616
#include "diffcore.h"
1717
#include "exec-cmd.h"
18+
#include "entry.h"
1819

1920
#define INCLUDE_ALL_FILES 2
2021

cache.h

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -1621,30 +1621,6 @@ const char *show_ident_date(const struct ident_split *id,
16211621
*/
16221622
int ident_cmp(const struct ident_split *, const struct ident_split *);
16231623

1624-
struct checkout {
1625-
struct index_state *istate;
1626-
const char *base_dir;
1627-
int base_dir_len;
1628-
struct delayed_checkout *delayed_checkout;
1629-
struct checkout_metadata meta;
1630-
unsigned force:1,
1631-
quiet:1,
1632-
not_new:1,
1633-
clone:1,
1634-
refresh_cache:1;
1635-
};
1636-
#define CHECKOUT_INIT { NULL, "" }
1637-
1638-
#define TEMPORARY_FILENAME_LENGTH 25
1639-
int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath, int *nr_checkouts);
1640-
void enable_delayed_checkout(struct checkout *state);
1641-
int finish_delayed_checkout(struct checkout *state, int *nr_checkouts);
1642-
/*
1643-
* Unlink the last component and schedule the leading directories for
1644-
* removal, such that empty directories get removed.
1645-
*/
1646-
void unlink_entry(const struct cache_entry *ce);
1647-
16481624
struct cache_def {
16491625
struct strbuf path;
16501626
int flags;

entry.c

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
#include "submodule.h"
77
#include "progress.h"
88
#include "fsmonitor.h"
9+
#include "entry.h"
910

1011
static void create_directories(const char *path, int path_len,
1112
const struct checkout *state)
@@ -429,14 +430,6 @@ static void mark_colliding_entries(const struct checkout *state,
429430
}
430431
}
431432

432-
/*
433-
* Write the contents from ce out to the working tree.
434-
*
435-
* When topath[] is not NULL, instead of writing to the working tree
436-
* file named by ce, a temporary file is created by this function and
437-
* its name is returned in topath[], which must be able to hold at
438-
* least TEMPORARY_FILENAME_LENGTH bytes long.
439-
*/
440433
int checkout_entry(struct cache_entry *ce, const struct checkout *state,
441434
char *topath, int *nr_checkouts)
442435
{

entry.h

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
#ifndef ENTRY_H
2+
#define ENTRY_H
3+
4+
#include "cache.h"
5+
#include "convert.h"
6+
7+
struct checkout {
8+
struct index_state *istate;
9+
const char *base_dir;
10+
int base_dir_len;
11+
struct delayed_checkout *delayed_checkout;
12+
struct checkout_metadata meta;
13+
unsigned force:1,
14+
quiet:1,
15+
not_new:1,
16+
clone:1,
17+
refresh_cache:1;
18+
};
19+
#define CHECKOUT_INIT { NULL, "" }
20+
21+
#define TEMPORARY_FILENAME_LENGTH 25
22+
/*
23+
* Write the contents from ce out to the working tree.
24+
*
25+
* When topath[] is not NULL, instead of writing to the working tree
26+
* file named by ce, a temporary file is created by this function and
27+
* its name is returned in topath[], which must be able to hold at
28+
* least TEMPORARY_FILENAME_LENGTH bytes long.
29+
*/
30+
int checkout_entry(struct cache_entry *ce, const struct checkout *state,
31+
char *topath, int *nr_checkouts);
32+
33+
void enable_delayed_checkout(struct checkout *state);
34+
int finish_delayed_checkout(struct checkout *state, int *nr_checkouts);
35+
36+
/*
37+
* Unlink the last component and schedule the leading directories for
38+
* removal, such that empty directories get removed.
39+
*/
40+
void unlink_entry(const struct cache_entry *ce);
41+
42+
#endif /* ENTRY_H */

unpack-trees.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include "fsmonitor.h"
1717
#include "object-store.h"
1818
#include "promisor-remote.h"
19+
#include "entry.h"
1920

2021
/*
2122
* Error messages expected by scripts out of plumbing commands such as

0 commit comments

Comments
 (0)