[PATCH] Builtin git-cat-file
From: Timo Hirvonen <hidden>
Date: 2016-06-15 22:42:27
Subsystem:
kernel build + files below scripts/ (unless maintained elsewhere), the rest · Maintainers:
Nathan Chancellor, Nicolas Schier, Linus Torvalds
Signed-off-by: Timo Hirvonen <redacted> --- Not huge disc space savings but avoids fork+exec. 95174d93a8fb39b907f4f7359a381b9ad5757e5d Makefile | 6 +++--- cat-file.c => builtin-cat-file.c | 3 ++- builtin.h | 1 + git.c | 1 + 4 files changed, 7 insertions(+), 4 deletions(-) rename cat-file.c => builtin-cat-file.c (98%) 95174d93a8fb39b907f4f7359a381b9ad5757e5d
diff --git a/Makefile b/Makefile
index 5423b7a..faab3f9 100644
--- a/Makefile
+++ b/Makefile@@ -149,7 +149,7 @@ SIMPLE_PROGRAMS = \ # ... and all the rest that could be moved out of bindir to gitexecdir PROGRAMS = \ - git-apply$X git-cat-file$X \ + git-apply$X \ git-checkout-index$X git-clone-pack$X git-commit-tree$X \ git-convert-objects$X git-diff-files$X \ git-diff-index$X git-diff-stages$X \
@@ -171,7 +171,7 @@ PROGRAMS = \ BUILT_INS = git-log$X git-whatchanged$X git-show$X \ git-count-objects$X git-diff$X git-push$X \ git-grep$X git-rev-list$X git-check-ref-format$X \ - git-init-db$X + git-init-db$X git-cat-file$X # what 'all' will build and 'install' will install, in gitexecdir ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@ -220,7 +220,7 @@ LIB_OBJS = \ BUILTIN_OBJS = \ builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \ builtin-grep.o builtin-rev-list.o builtin-check-ref-format.o \ - builtin-init-db.o + builtin-init-db.o builtin-cat-file.o GITLIBS = $(LIB_FILE) $(XDIFF_LIB) LIBS = $(GITLIBS) -lz
diff --git a/cat-file.c b/builtin-cat-file.c
similarity index 98%
rename from cat-file.c
rename to builtin-cat-file.c
index 7413fee..8ab136e 100644
--- a/cat-file.c
+++ b/builtin-cat-file.c@@ -7,6 +7,7 @@ #include "cache.h" #include "exec_cmd.h" #include "tag.h" #include "tree.h" +#include "builtin.h" static void flush_buffer(const char *buf, unsigned long size) {
@@ -93,7 +94,7 @@ static int pprint_tag(const unsigned cha return 0; } -int main(int argc, char **argv) +int cmd_cat_file(int argc, const char **argv, char **envp) { unsigned char sha1[20]; char type[20];
diff --git a/builtin.h b/builtin.h
index 6054126..01f2eec 100644
--- a/builtin.h
+++ b/builtin.h@@ -27,5 +27,6 @@ extern int cmd_grep(int argc, const char extern int cmd_rev_list(int argc, const char **argv, char **envp); extern int cmd_check_ref_format(int argc, const char **argv, char **envp); extern int cmd_init_db(int argc, const char **argv, char **envp); +extern int cmd_cat_file(int argc, const char **argv, char **envp); #endif
diff --git a/git.c b/git.c
index 3216d31..6df0902 100644
--- a/git.c
+++ b/git.c@@ -52,6 +52,7 @@ static void handle_internal_command(int { "grep", cmd_grep }, { "rev-list", cmd_rev_list }, { "init-db", cmd_init_db }, + { "cat-file", cmd_cat_file }, { "check-ref-format", cmd_check_ref_format } }; int i;
--
1.3.3.g40505-dirty