mirror of
https://github.com/git/git.git
synced 2024-11-24 10:26:17 +08:00
611c7785e8
At the end of `git checkout <pathspec>`, we get a message informing how many entries were updated in the working tree. However, this number can be inaccurate for two reasons: 1) Delayed entries currently get counted twice. 2) Failed entries are included in the count. The first problem happens because the counter is first incremented before inserting the entry in the delayed checkout queue, and once again when finish_delayed_checkout() calls checkout_entry(). And the second happens because the counter is incremented too early in checkout_entry(), before the entry was in fact checked out. Fix that by moving the count increment further down in the call stack and removing the duplicate increment on delayed entries. Note that we have to keep a per-entry reference for the counter (both on parallel checkout and delayed checkout) because not all entries are always accumulated at the same counter. See checkout_worktree(), at builtin/checkout.c for an example. Signed-off-by: Matheus Tavares <matheus.bernardino@usp.br> Signed-off-by: Junio C Hamano <gitster@pobox.com>
60 lines
1.8 KiB
C
60 lines
1.8 KiB
C
#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 { .base_dir = "" }
|
|
|
|
#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.
|
|
*
|
|
* With checkout_entry_ca(), callers can optionally pass a preloaded
|
|
* conv_attrs struct (to avoid reloading it), when ce refers to a
|
|
* regular file. If ca is NULL, the attributes will be loaded
|
|
* internally when (and if) needed.
|
|
*/
|
|
int checkout_entry_ca(struct cache_entry *ce, struct conv_attrs *ca,
|
|
const struct checkout *state, char *topath,
|
|
int *nr_checkouts);
|
|
static inline int checkout_entry(struct cache_entry *ce,
|
|
const struct checkout *state, char *topath,
|
|
int *nr_checkouts)
|
|
{
|
|
return checkout_entry_ca(ce, NULL, state, topath, nr_checkouts);
|
|
}
|
|
|
|
void enable_delayed_checkout(struct checkout *state);
|
|
int finish_delayed_checkout(struct checkout *state, int show_progress);
|
|
|
|
/*
|
|
* 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);
|
|
|
|
void *read_blob_entry(const struct cache_entry *ce, size_t *size);
|
|
int fstat_checkout_output(int fd, const struct checkout *state, struct stat *st);
|
|
void update_ce_after_write(const struct checkout *state, struct cache_entry *ce,
|
|
struct stat *st);
|
|
|
|
#endif /* ENTRY_H */
|