summaryrefslogtreecommitdiff
path: root/t/helper
diff options
context:
space:
mode:
Diffstat (limited to 't/helper')
-rw-r--r--t/helper/test-genzeros.c21
-rw-r--r--t/helper/test-read-cache.c5
-rw-r--r--t/helper/test-read-midx.c3
-rw-r--r--t/helper/test-ref-store.c3
4 files changed, 24 insertions, 8 deletions
diff --git a/t/helper/test-genzeros.c b/t/helper/test-genzeros.c
index 9532f5bac9..8ca988d621 100644
--- a/t/helper/test-genzeros.c
+++ b/t/helper/test-genzeros.c
@@ -3,18 +3,31 @@
int cmd__genzeros(int argc, const char **argv)
{
- long count;
+ /* static, so that it is NUL-initialized */
+ static const char zeros[256 * 1024];
+ intmax_t count;
+ ssize_t n;
if (argc > 2) {
fprintf(stderr, "usage: %s [<count>]\n", argv[0]);
return 1;
}
- count = argc > 1 ? strtol(argv[1], NULL, 0) : -1L;
+ count = argc > 1 ? strtoimax(argv[1], NULL, 0) : -1;
- while (count < 0 || count--) {
- if (putchar(0) == EOF)
+ /* Writing out individual NUL bytes is slow... */
+ while (count < 0)
+ if (write(1, zeros, ARRAY_SIZE(zeros)) < 0)
return -1;
+
+ while (count > 0) {
+ n = write(1, zeros, count < ARRAY_SIZE(zeros) ?
+ count : ARRAY_SIZE(zeros));
+
+ if (n < 0)
+ return -1;
+
+ count -= n;
}
return 0;
diff --git a/t/helper/test-read-cache.c b/t/helper/test-read-cache.c
index b52c174acc..0d9f08931a 100644
--- a/t/helper/test-read-cache.c
+++ b/t/helper/test-read-cache.c
@@ -39,8 +39,6 @@ int cmd__read_cache(int argc, const char **argv)
int table = 0, expand = 0;
initialize_the_repository();
- prepare_repo_settings(r);
- r->settings.command_requires_full_index = 0;
for (++argv, --argc; *argv && starts_with(*argv, "--"); ++argv, --argc) {
if (skip_prefix(*argv, "--print-and-refresh=", &name))
@@ -56,6 +54,9 @@ int cmd__read_cache(int argc, const char **argv)
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);
diff --git a/t/helper/test-read-midx.c b/t/helper/test-read-midx.c
index 9d6fa7a377..27072ba94d 100644
--- a/t/helper/test-read-midx.c
+++ b/t/helper/test-read-midx.c
@@ -55,9 +55,10 @@ static int read_midx_file(const char *object_dir, int show_objects)
printf("%s %"PRIu64"\t%s\n",
oid_to_hex(&oid), e.offset, e.p->pack_name);
}
- return 0;
}
+ close_midx(m);
+
return 0;
}
diff --git a/t/helper/test-ref-store.c b/t/helper/test-ref-store.c
index b314b81a45..3986665037 100644
--- a/t/helper/test-ref-store.c
+++ b/t/helper/test-ref-store.c
@@ -123,9 +123,10 @@ static int cmd_resolve_ref(struct ref_store *refs, const char **argv)
int resolve_flags = arg_flags(*argv++, "resolve-flags");
int flags;
const char *ref;
+ int ignore_errno;
ref = refs_resolve_ref_unsafe(refs, refname, resolve_flags,
- &oid, &flags);
+ &oid, &flags, &ignore_errno);
printf("%s %s 0x%x\n", oid_to_hex(&oid), ref ? ref : "(null)", flags);
return ref ? 0 : 1;
}