diff options
author | Rene Scharfe <rene.scharfe@lsrfire.ath.cx> | 2006-06-10 16:13:41 +0200 |
---|---|---|
committer | Junio C Hamano <junkio@cox.net> | 2006-06-10 11:14:00 -0700 |
commit | 52ba03cbb1c718093946f5254187082bd7b32845 (patch) | |
tree | 75bb33782f3527ad2617be04884d489cf9eba1df /builtin-tar-tree.c | |
parent | 5e3a620cd5f7baaf27198192a614271c6145ec3b (diff) | |
download | git-52ba03cbb1c718093946f5254187082bd7b32845.tar.gz git-52ba03cbb1c718093946f5254187082bd7b32845.tar.xz |
Built-in git-get-tar-commit-id
By being an internal command git-get-commit-id can make use of
struct ustar_header and other stuff and stops wasting precious
disk space.
Note: I recycled one of the two "tar-tree" entries instead of
splitting that cleanup into a separate patch.
Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx>
Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'builtin-tar-tree.c')
-rw-r--r-- | builtin-tar-tree.c | 25 |
1 files changed, 25 insertions, 0 deletions
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c index 7663b9bd8..58a8ccd4d 100644 --- a/builtin-tar-tree.c +++ b/builtin-tar-tree.c @@ -402,3 +402,28 @@ int cmd_tar_tree(int argc, const char **argv, char **envp) return remote_tar(argc, argv); return generate_tar(argc, argv, envp); } + +/* ustar header + extended global header content */ +#define HEADERSIZE (2 * RECORDSIZE) + +int cmd_get_tar_commit_id(int argc, const char **argv, char **envp) +{ + char buffer[HEADERSIZE]; + struct ustar_header *header = (struct ustar_header *)buffer; + char *content = buffer + RECORDSIZE; + ssize_t n; + + n = xread(0, buffer, HEADERSIZE); + if (n < HEADERSIZE) + die("git-get-tar-commit-id: read error"); + if (header->typeflag[0] != 'g') + return 1; + if (memcmp(content, "52 comment=", 11)) + return 1; + + n = xwrite(1, content + 11, 41); + if (n < 41) + die("git-get-tar-commit-id: write error"); + + return 0; +} |