aboutsummaryrefslogtreecommitdiff
path: root/get-tar-commit-id.c
diff options
context:
space:
mode:
authorRene Scharfe <rene.scharfe@lsrfire.ath.cx>2005-04-29 19:51:04 -0700
committerLinus Torvalds <torvalds@ppc970.osdl.org>2005-04-29 19:51:04 -0700
commit87fec8fc9e790fedbee0c9fc810dbd1bf006d7b6 (patch)
tree72f4d42eac2cd9099a663c16cb8201f90a8ff9c9 /get-tar-commit-id.c
parent0fc65a4572625405ff6dd9d8c16d835f2b1ebd49 (diff)
downloadgit-87fec8fc9e790fedbee0c9fc810dbd1bf006d7b6.tar.gz
git-87fec8fc9e790fedbee0c9fc810dbd1bf006d7b6.tar.xz
[PATCH] GIT: Create tar archives of tree on the fly
Write commit ID to global extended pax header at the beginning of the tar file, if possible. get-tar-commit-id.c is an example program to get the ID back out of such a tar archive. Signed-off-by: Rene Scharfe <rene.scharfe@lsrfire.ath.cx> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'get-tar-commit-id.c')
-rw-r--r--get-tar-commit-id.c27
1 files changed, 27 insertions, 0 deletions
diff --git a/get-tar-commit-id.c b/get-tar-commit-id.c
new file mode 100644
index 000000000..a1a17e53d
--- /dev/null
+++ b/get-tar-commit-id.c
@@ -0,0 +1,27 @@
+#include <stdio.h>
+#include <string.h>
+#include <unistd.h>
+
+#define HEADERSIZE 1024
+
+int main(int argc, char **argv)
+{
+ char buffer[HEADERSIZE];
+ ssize_t n;
+
+ n = read(0, buffer, HEADERSIZE);
+ if (n < HEADERSIZE) {
+ fprintf(stderr, "read error\n");
+ return 3;
+ }
+ if (buffer[156] != 'g')
+ return 1;
+ if (memcmp(&buffer[512], "52 comment=", 11))
+ return 1;
+ n = write(1, &buffer[523], 41);
+ if (n < 41) {
+ fprintf(stderr, "write error\n");
+ return 2;
+ }
+ return 0;
+}