Skip to content

Commit dbd57f9

Browse files
pcloudsgitster
authored andcommitted
Add test-index-version
Commit 06aaaa0 may step index format version up and down, depends on whether extended flags present in the index. This adds a test to check for index format version. Signed-off-by: Nguyễn Thái Ngọc Duy <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent 83b327b commit dbd57f9

File tree

3 files changed

+16
-0
lines changed

3 files changed

+16
-0
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -153,6 +153,7 @@ test-date
153153
test-delta
154154
test-dump-cache-tree
155155
test-genrandom
156+
test-index-version
156157
test-match-trees
157158
test-parse-options
158159
test-path-utils

Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1580,6 +1580,7 @@ TEST_PROGRAMS += test-parse-options$X
15801580
TEST_PROGRAMS += test-path-utils$X
15811581
TEST_PROGRAMS += test-sha1$X
15821582
TEST_PROGRAMS += test-sigchain$X
1583+
TEST_PROGRAMS += test-index-version$X
15831584

15841585
all:: $(TEST_PROGRAMS)
15851586

test-index-version.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
#include "cache.h"
2+
3+
int main(int argc, const char **argv)
4+
{
5+
struct cache_header hdr;
6+
int version;
7+
8+
memset(&hdr,0,sizeof(hdr));
9+
if (read(0, &hdr, sizeof(hdr)) != sizeof(hdr))
10+
return 0;
11+
version = ntohl(hdr.hdr_version);
12+
printf("%d\n", version);
13+
return 0;
14+
}

0 commit comments

Comments
 (0)