Skip to content

Commit ae22751

Browse files
matheustavaresgitster
authored andcommitted
entry: add checkout_entry_ca() taking preloaded conv_attrs
The parallel checkout machinery will call checkout_entry() for entries that could not be written in parallel due to path collisions. At this point, we will already be holding the conversion attributes for each entry, and it would be wasteful to let checkout_entry() load these again. Instead, let's add the checkout_entry_ca() variant, which optionally takes a preloaded conv_attrs struct. Signed-off-by: Matheus Tavares <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 30419e7 commit ae22751

File tree

2 files changed

+20
-7
lines changed

2 files changed

+20
-7
lines changed

entry.c

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -440,12 +440,13 @@ static void mark_colliding_entries(const struct checkout *state,
440440
}
441441
}
442442

443-
int checkout_entry(struct cache_entry *ce, const struct checkout *state,
444-
char *topath, int *nr_checkouts)
443+
int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
444+
const struct checkout *state, char *topath,
445+
int *nr_checkouts)
445446
{
446447
static struct strbuf path = STRBUF_INIT;
447448
struct stat st;
448-
struct conv_attrs ca_buf, *ca = NULL;
449+
struct conv_attrs ca_buf;
449450

450451
if (ce->ce_flags & CE_WT_REMOVE) {
451452
if (topath)
@@ -459,7 +460,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state,
459460
}
460461

461462
if (topath) {
462-
if (S_ISREG(ce->ce_mode)) {
463+
if (S_ISREG(ce->ce_mode) && !ca) {
463464
convert_attrs(state->istate, &ca_buf, ce->name);
464465
ca = &ca_buf;
465466
}
@@ -530,7 +531,7 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state,
530531
if (nr_checkouts)
531532
(*nr_checkouts)++;
532533

533-
if (S_ISREG(ce->ce_mode)) {
534+
if (S_ISREG(ce->ce_mode) && !ca) {
534535
convert_attrs(state->istate, &ca_buf, ce->name);
535536
ca = &ca_buf;
536537
}

entry.h

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,9 +26,21 @@ struct checkout {
2626
* file named by ce, a temporary file is created by this function and
2727
* its name is returned in topath[], which must be able to hold at
2828
* least TEMPORARY_FILENAME_LENGTH bytes long.
29+
*
30+
* With checkout_entry_ca(), callers can optionally pass a preloaded
31+
* conv_attrs struct (to avoid reloading it), when ce refers to a
32+
* regular file. If ca is NULL, the attributes will be loaded
33+
* internally when (and if) needed.
2934
*/
30-
int checkout_entry(struct cache_entry *ce, const struct checkout *state,
31-
char *topath, int *nr_checkouts);
35+
int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
36+
const struct checkout *state, char *topath,
37+
int *nr_checkouts);
38+
static inline int checkout_entry(struct cache_entry *ce,
39+
const struct checkout *state, char *topath,
40+
int *nr_checkouts)
41+
{
42+
return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts);
43+
}
3244

3345
void enable_delayed_checkout(struct checkout *state);
3446
int finish_delayed_checkout(struct checkout *state, int *nr_checkouts);

0 commit comments

Comments
 (0)