Browse Source
"git fetch" and "git pull" are now declared sparse-index clean. Also "git ls-files" learns the "--sparse" option to help debugging. * ds/fetch-pull-with-sparse-index: test-read-cache: remove --table, --expand options t1091/t3705: remove 'test-tool read-cache --table' t1092: replace 'read-cache --table' with 'ls-files --sparse' ls-files: add --sparse option fetch/pull: use the sparse indexmaint
![gitster@pobox.com](/assets/img/avatar_default.png)
8 changed files with 168 additions and 82 deletions
@ -1,83 +1,39 @@ |
|||||||
#include "test-tool.h" |
#include "test-tool.h" |
||||||
#include "cache.h" |
#include "cache.h" |
||||||
#include "config.h" |
#include "config.h" |
||||||
#include "blob.h" |
|
||||||
#include "commit.h" |
|
||||||
#include "tree.h" |
|
||||||
#include "sparse-index.h" |
|
||||||
|
|
||||||
static void print_cache_entry(struct cache_entry *ce) |
|
||||||
{ |
|
||||||
const char *type; |
|
||||||
printf("%06o ", ce->ce_mode & 0177777); |
|
||||||
|
|
||||||
if (S_ISSPARSEDIR(ce->ce_mode)) |
|
||||||
type = tree_type; |
|
||||||
else if (S_ISGITLINK(ce->ce_mode)) |
|
||||||
type = commit_type; |
|
||||||
else |
|
||||||
type = blob_type; |
|
||||||
|
|
||||||
printf("%s %s\t%s\n", |
|
||||||
type, |
|
||||||
oid_to_hex(&ce->oid), |
|
||||||
ce->name); |
|
||||||
} |
|
||||||
|
|
||||||
static void print_cache(struct index_state *istate) |
|
||||||
{ |
|
||||||
int i; |
|
||||||
for (i = 0; i < istate->cache_nr; i++) |
|
||||||
print_cache_entry(istate->cache[i]); |
|
||||||
} |
|
||||||
|
|
||||||
int cmd__read_cache(int argc, const char **argv) |
int cmd__read_cache(int argc, const char **argv) |
||||||
{ |
{ |
||||||
struct repository *r = the_repository; |
|
||||||
int i, cnt = 1; |
int i, cnt = 1; |
||||||
const char *name = NULL; |
const char *name = NULL; |
||||||
int table = 0, expand = 0; |
|
||||||
|
|
||||||
initialize_the_repository(); |
initialize_the_repository(); |
||||||
|
|
||||||
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) { |
if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) { |
||||||
if (skip_prefix(*argv, "--print-and-refresh=", &name)) |
argc--; |
||||||
continue; |
argv++; |
||||||
if (!strcmp(*argv, "--table")) |
|
||||||
table = 1; |
|
||||||
else if (!strcmp(*argv, "--expand")) |
|
||||||
expand = 1; |
|
||||||
} |
} |
||||||
|
|
||||||
if (argc == 1) |
if (argc == 2) |
||||||
cnt = strtol(argv[0], NULL, 0); |
cnt = strtol(argv[1], NULL, 0); |
||||||
setup_git_directory(); |
setup_git_directory(); |
||||||
git_config(git_default_config, NULL); |
git_config(git_default_config, NULL); |
||||||
|
|
||||||
prepare_repo_settings(r); |
|
||||||
r->settings.command_requires_full_index = 0; |
|
||||||
|
|
||||||
for (i = 0; i < cnt; i++) { |
for (i = 0; i < cnt; i++) { |
||||||
repo_read_index(r); |
read_cache(); |
||||||
|
|
||||||
if (expand) |
|
||||||
ensure_full_index(r->index); |
|
||||||
|
|
||||||
if (name) { |
if (name) { |
||||||
int pos; |
int pos; |
||||||
|
|
||||||
refresh_index(r->index, REFRESH_QUIET, |
refresh_index(&the_index, REFRESH_QUIET, |
||||||
NULL, NULL, NULL); |
NULL, NULL, NULL); |
||||||
pos = index_name_pos(r->index, name, strlen(name)); |
pos = index_name_pos(&the_index, name, strlen(name)); |
||||||
if (pos < 0) |
if (pos < 0) |
||||||
die("%s not in index", name); |
die("%s not in index", name); |
||||||
printf("%s is%s up to date\n", name, |
printf("%s is%s up to date\n", name, |
||||||
ce_uptodate(r->index->cache[pos]) ? "" : " not"); |
ce_uptodate(the_index.cache[pos]) ? "" : " not"); |
||||||
write_file(name, "%d\n", i); |
write_file(name, "%d\n", i); |
||||||
} |
} |
||||||
if (table) |
discard_cache(); |
||||||
print_cache(r->index); |
|
||||||
discard_index(r->index); |
|
||||||
} |
} |
||||||
return 0; |
return 0; |
||||||
} |
} |
||||||
|
Loading…
Reference in new issue