# The ones that do not have to link with lcrypto, lz nor xdiff.
SIMPLE_PROGRAMS = \
- git-get-tar-commit-id$X git-mailsplit$X \
+ git-mailsplit$X \
git-stripspace$X git-daemon$X
# ... and all the rest that could be moved out of bindir to gitexecdir
git-grep$X git-add$X git-rm$X git-rev-list$X \
git-check-ref-format$X git-rev-parse$X \
git-init-db$X git-tar-tree$X git-upload-tar$X git-format-patch$X \
- git-ls-files$X git-ls-tree$X \
+ git-ls-files$X git-ls-tree$X git-get-tar-commit-id$X \
git-read-tree$X git-commit-tree$X \
git-apply$X git-show-branch$X git-diff-files$X \
git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
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;
+}
extern int cmd_init_db(int argc, const char **argv, char **envp);
extern int cmd_tar_tree(int argc, const char **argv, char **envp);
extern int cmd_upload_tar(int argc, const char **argv, char **envp);
+extern int cmd_get_tar_commit_id(int argc, const char **argv, char **envp);
extern int cmd_ls_files(int argc, const char **argv, char **envp);
extern int cmd_ls_tree(int argc, const char **argv, char **envp);
extern int cmd_read_tree(int argc, const char **argv, char **envp);
+++ /dev/null
-/*
- * Copyright (C) 2005 Rene Scharfe
- */
-#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;
-}
{ "add", cmd_add },
{ "rev-list", cmd_rev_list },
{ "init-db", cmd_init_db },
- { "tar-tree", cmd_tar_tree },
+ { "get-tar-commit-id", cmd_get_tar_commit_id },
{ "upload-tar", cmd_upload_tar },
{ "check-ref-format", cmd_check_ref_format },
{ "ls-files", cmd_ls_files },