]> git.ipfire.org Git - thirdparty/git.git/blob - t/helper/test-crontab.c
Merge branch 'jk/clone-allow-bare-and-o-together'
[thirdparty/git.git] / t / helper / test-crontab.c
1 #include "test-tool.h"
2 #include "cache.h"
3
4 /*
5 * Usage: test-tool crontab <file> -l|<input>
6 *
7 * If -l is specified, then write the contents of <file> to stdout.
8 * Otherwise, copy the contents of <input> into <file>.
9 */
10 int cmd__crontab(int argc, const char **argv)
11 {
12 int a;
13 FILE *from, *to;
14
15 if (argc != 3)
16 usage("test-tool crontab <file> -l|<input>");
17
18 if (!strcmp(argv[2], "-l")) {
19 from = fopen(argv[1], "r");
20 if (!from)
21 return 0;
22 to = stdout;
23 } else {
24 from = xfopen(argv[2], "r");
25 to = xfopen(argv[1], "w");
26 }
27
28 while ((a = fgetc(from)) != EOF)
29 fputc(a, to);
30
31 fclose(from);
32 if (to != stdout)
33 fclose(to);
34
35 return 0;
36 }