[PATCH/RFC] Retire SIMPLE_*** stuff.

Subsystems: kernel build + files below scripts/ (unless maintained elsewhere), the rest

2 messages, 2 authors, 2016-06-15 · open the first message on its own page

[PATCH/RFC] Retire SIMPLE_*** stuff.

From: Junio C Hamano <hidden>
Date: 2016-06-15 22:42:29

It used to be a good idea to keep simple stuff without linking with git
library, but more and more programs are using the config mechanism, and
yet more things are becoming internal.

Signed-off-by: Junio C Hamano <redacted>
---

 Makefile |   24 +++++-------------------
 1 files changed, 5 insertions(+), 19 deletions(-)
diff --git a/Makefile b/Makefile
index 5226fa1..d65fc71 100644
--- a/Makefile
+++ b/Makefile
@@ -142,12 +142,7 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)
 	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 	  git-cherry-pick git-status
 
-# 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-stripspace$X git-daemon$X
-
-# ... and all the rest that could be moved out of bindir to gitexecdir
+# Programs could be moved out of bindir to gitexecdir
 PROGRAMS = \
 	git-checkout-index$X git-clone-pack$X \
 	git-convert-objects$X git-fetch-pack$X git-fsck-objects$X \
@@ -162,7 +157,9 @@ PROGRAMS = \
 	git-upload-pack$X git-verify-pack$X git-write-tree$X \
 	git-update-ref$X git-symbolic-ref$X \
 	git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
-	git-describe$X git-merge-tree$X git-blame$X git-imap-send$X
+	git-describe$X git-merge-tree$X git-blame$X git-imap-send$X \
+	git-get-tar-commit-id$X git-mailsplit$X \
+	git-stripspace$X git-daemon$X
 
 BUILT_INS = git-log$X git-whatchanged$X git-show$X \
 	git-count-objects$X git-diff$X git-push$X \
@@ -175,7 +172,7 @@ BUILT_INS = git-log$X git-whatchanged$X 
 	git-diff-index$X git-diff-stages$X git-diff-tree$X git-cat-file$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
-ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
+ALL_PROGRAMS = $(PROGRAMS) $(SCRIPTS)
 
 # Backward compatibility -- to be removed after 1.0
 PROGRAMS += git-ssh-pull$X git-ssh-push$X
@@ -386,11 +383,9 @@ else
 endif
 ifdef NEEDS_SOCKET
 	LIBS += -lsocket
-	SIMPLE_LIB += -lsocket
 endif
 ifdef NEEDS_NSL
 	LIBS += -lnsl
-	SIMPLE_LIB += -lnsl
 endif
 ifdef NO_D_TYPE_IN_DIRENT
 	ALL_CFLAGS += -DNO_D_TYPE_IN_DIRENT
@@ -428,6 +428,8 @@ endif
 
 ifdef NO_ICONV
 	ALL_CFLAGS += -DNO_ICONV
+else
+	LIBS += $(LIB_4_ICONV)
 endif
 
 ifdef PPC_SHA1
@@ -559,15 +554,6 @@ endif
 git-%$X: %.o $(GITLIBS)
 	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS)
 
-$(SIMPLE_PROGRAMS) : $(LIB_FILE)
-$(SIMPLE_PROGRAMS) : git-%$X : %.o
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
-		$(LIB_FILE) $(SIMPLE_LIB)
-
-git-mailinfo$X: mailinfo.o $(LIB_FILE)
-	$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
-		$(LIB_FILE) $(SIMPLE_LIB) $(LIB_4_ICONV)
-
 git-local-fetch$X: fetch.o
 git-ssh-fetch$X: rsh.o fetch.o
 git-ssh-upload$X: rsh.o
-- 
1.4.0.rc2.g55be

[PATCH] Built-in git-get-tar-commit-id (was: [PATCH/RFC] Retire SIMPLE_*** stuff.)

From: Rene Scharfe <hidden>
Date: 2016-06-15 22:42:29

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 <redacted>
diff --git a/Makefile b/Makefile
index 5226fa1..2a1e639 100644
--- a/Makefile
+++ b/Makefile
@@ -142,11 +142,11 @@ SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)
 	  $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
 	  git-cherry-pick git-status
 
 # 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
 PROGRAMS = \
 	git-checkout-index$X git-clone-pack$X \
@@ -167,11 +167,11 @@ 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-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
 
 # what 'all' will build and 'install' will install, in gitexecdir
diff --git a/builtin-tar-tree.c b/builtin-tar-tree.c
index 7663b9b..58a8ccd 100644
--- a/builtin-tar-tree.c
+++ b/builtin-tar-tree.c
@@ -400,5 +400,30 @@ int cmd_tar_tree(int argc, const char **
 		usage(tar_tree_usage);
 	if (!strncmp("--remote=", argv[1], 9))
 		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;
+}
diff --git a/builtin.h b/builtin.h
index ffa9340..b9f36be 100644
--- a/builtin.h
+++ b/builtin.h
@@ -30,10 +30,11 @@ extern int cmd_add(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_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);
 extern int cmd_commit_tree(int argc, const char **argv, char **envp);
 extern int cmd_apply(int argc, const char **argv, char **envp);
diff --git a/get-tar-commit-id.c b/get-tar-commit-id.c
deleted file mode 100644
index 4166290..0000000
--- a/get-tar-commit-id.c
+++ /dev/null
@@ -1,30 +0,0 @@
-/*
- * 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;
-}
diff --git a/git.c b/git.c
index 6db8f2b..9469d44 100644
--- a/git.c
+++ b/git.c
@@ -161,11 +161,11 @@ static void handle_internal_command(int 
 		{ "grep", cmd_grep },
 		{ "rm", cmd_rm },
 		{ "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 },
 		{ "ls-tree", cmd_ls_tree },
 		{ "tar-tree", cmd_tar_tree },
Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help