diff options
Diffstat (limited to 't/helper')
-rw-r--r-- | t/helper/test-drop-caches.c | 4 | ||||
-rw-r--r-- | t/helper/test-read-cache.c | 64 | ||||
-rw-r--r-- | t/helper/test-ref-store.c | 9 |
3 files changed, 18 insertions, 59 deletions
diff --git a/t/helper/test-drop-caches.c b/t/helper/test-drop-caches.c index 7b4278462b..e37396dd9c 100644 --- a/t/helper/test-drop-caches.c +++ b/t/helper/test-drop-caches.c @@ -3,6 +3,7 @@ #if defined(GIT_WINDOWS_NATIVE) #include "lazyload.h" +#include <winnt.h> static int cmd_sync(void) { @@ -86,7 +87,8 @@ static int cmd_dropcaches(void) { HANDLE hProcess = GetCurrentProcess(); HANDLE hToken; - DECLARE_PROC_ADDR(ntdll.dll, DWORD, NtSetSystemInformation, INT, PVOID, ULONG); + DECLARE_PROC_ADDR(ntdll.dll, DWORD, NTAPI, NtSetSystemInformation, INT, PVOID, + ULONG); SYSTEM_MEMORY_LIST_COMMAND command; int status; diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c index 0d9f08931a..b736ef1642 100644 --- a/t/helper/test-read-cache.c +++ b/t/helper/test-read-cache.c @@ -1,83 +1,39 @@ #include "test-tool.h" #include "cache.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) { - struct repository *r = the_repository; int i, cnt = 1; const char *name = NULL; - int table = 0, expand = 0; initialize_the_repository(); - for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) { - if (skip_prefix(*argv, "--print-and-refresh=", &name)) - continue; - if (!strcmp(*argv, "--table")) - table = 1; - else if (!strcmp(*argv, "--expand")) - expand = 1; + if (argc > 1 && skip_prefix(argv[1], "--print-and-refresh=", &name)) { + argc--; + argv++; } - if (argc == 1) - cnt = strtol(argv[0], NULL, 0); + if (argc == 2) + cnt = strtol(argv[1], NULL, 0); setup_git_directory(); git_config(git_default_config, NULL); - prepare_repo_settings(r); - r->settings.command_requires_full_index = 0; - for (i = 0; i < cnt; i++) { - repo_read_index(r); - - if (expand) - ensure_full_index(r->index); - + read_cache(); if (name) { int pos; - refresh_index(r->index, REFRESH_QUIET, + refresh_index(&the_index, REFRESH_QUIET, NULL, NULL, NULL); - pos = index_name_pos(r->index, name, strlen(name)); + pos = index_name_pos(&the_index, name, strlen(name)); if (pos < 0) die("%s not in index", 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); } - if (table) - print_cache(r->index); - discard_index(r->index); + discard_cache(); } return 0; } diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c index 24dd4bec08..3e4ddaee70 100644 --- a/t/helper/test-ref-store.c +++ b/t/helper/test-ref-store.c @@ -269,7 +269,7 @@ static int cmd_delete_ref(struct ref_store *refs, const char **argv) struct object_id old_oid; if (get_oid_hex(sha1_buf, &old_oid)) - die("not sha-1"); + die("cannot parse %s as %s", sha1_buf, the_hash_algo->name); return refs_delete_ref(refs, msg, refname, &old_oid, flags); } @@ -284,9 +284,10 @@ static int cmd_update_ref(struct ref_store *refs, const char **argv) struct object_id old_oid; struct object_id new_oid; - if (get_oid_hex(old_sha1_buf, &old_oid) || - get_oid_hex(new_sha1_buf, &new_oid)) - die("not sha-1"); + if (get_oid_hex(old_sha1_buf, &old_oid)) + die("cannot parse %s as %s", old_sha1_buf, the_hash_algo->name); + if (get_oid_hex(new_sha1_buf, &new_oid)) + die("cannot parse %s as %s", new_sha1_buf, the_hash_algo->name); return refs_update_ref(refs, msg, refname, &new_oid, &old_oid, |