threads / discuss / 4197

Make "git rev-list" be a builtin

Subject: Make "git rev-list" be a builtin

## tl;dr

3 messages between May 18, 2006 and May 18, 2006.

replies: 2people: 2as markdown or json

Linus Torvalds· May 18, 2006, 21:19 UTC · lore

This was surprisingly easy. The diff is truly minimal: rename "main()" to "cmd_rev_list()" in rev-list.c, and rename the whole file to reflect its new built-in status.

We should have done this long ago.
Signed-off-by: Linus Torvalds <torvalds@osdl.org>
---
[ NOTE! The diff is a git-only "git diff -M" with rename information, 
  because quite frankly, it's just a hell of a lot more readable that way. 
  But I thought I'd mention it explicitly, since it won't apply for 
  anybody who tries to apply it as a regular unified diff with "patch" ]
 Makefile                         |    6 +++---
 rev-list.c => builtin-rev-list.c |    3 ++-
 builtin.h                        |    1 +
 git.c                            |    1 +
 4 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/Makefile b/Makefile
index 3a28580..281fa69 100644
--- a/Makefile
+++ b/Makefile
@@ -158,7 +158,7 @@ PROGRAMS = \
 	git-ls-files$X git-ls-tree$X git-mailinfo$X git-merge-base$X \
 	git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \
 	git-peek-remote$X git-prune-packed$X git-read-tree$X \
-	git-receive-pack$X git-rev-list$X git-rev-parse$X \
+	git-receive-pack$X git-rev-parse$X \
 	git-send-pack$X git-show-branch$X git-shell$X \
 	git-show-index$X git-ssh-fetch$X \
 	git-ssh-upload$X git-tar-tree$X git-unpack-file$X \
@@ -170,7 +170,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-add$X
+	git-grep$X git-add$X git-rev-list$X
 
 # what 'all' will build and 'install' will install, in gitexecdir
 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS)
@@ -218,7 +218,7 @@ LIB_OBJS = \
 
 BUILTIN_OBJS = \
 	builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \
-	builtin-grep.o builtin-add.o
+	builtin-grep.o builtin-add.o builtin-rev-list.o
 
 GITLIBS = $(LIB_FILE) $(XDIFF_LIB)
 LIBS = $(GITLIBS) -lz
diff --git a/rev-list.c b/builtin-rev-list.c
similarity index 99%
rename from rev-list.c
rename to builtin-rev-list.c
index 235ae4c..171f9d5 100644
--- a/rev-list.c
+++ b/builtin-rev-list.c
@@ -7,6 +7,7 @@ #include "blob.h"
 #include "tree-walk.h"
 #include "diff.h"
 #include "revision.h"
+#include "builtin.h"
 
 /* bits #0-15 in revision.h */
 
@@ -291,7 +292,7 @@ static void mark_edges_uninteresting(str
 	}
 }
 
-int main(int argc, const char **argv)
+int cmd_rev_list(int argc, const char **argv, char **envp)
 {
 	struct commit_list *list;
 	int i;
diff --git a/builtin.h b/builtin.h
index ccd0e31..a94d728 100644
--- a/builtin.h
+++ b/builtin.h
@@ -26,5 +26,6 @@ extern int cmd_count_objects(int argc, c
 extern int cmd_push(int argc, const char **argv, char **envp);
 extern int cmd_grep(int argc, const char **argv, char **envp);
 extern int cmd_add(int argc, const char **argv, char **envp);
+extern int cmd_rev_list(int argc, const char **argv, char **envp);
 
 #endif
diff --git a/git.c b/git.c
index 6a470cf..e2bba53 100644
--- a/git.c
+++ b/git.c
@@ -52,6 +52,7 @@ static void handle_internal_command(int 
 		{ "diff", cmd_diff },
 		{ "grep", cmd_grep },
 		{ "add", cmd_add },
+		{ "rev-list", cmd_rev_list },
 	};
 	int i;
 
 rename rev-list.c => builtin-rev-list.c (99%)
Junio C Hamano· May 18, 2006, 21:50 UTC · re: Linus Torvalds · lore

Re: Make "git rev-list" be a builtin

Linus Torvalds <torvalds@osdl.org> writes:
Show 5 quoted lines
> This was surprisingly easy. The diff is truly minimal: rename "main()" to 
> "cmd_rev_list()" in rev-list.c, and rename the whole file to reflect its 
> new built-in status.
>
> We should have done this long ago.
Should we have?

Certainly it is almost trivial, and it means we need to worry about one less file, but is that the point?

Linus Torvalds· May 18, 2006, 22:00 UTC · re: Junio C Hamano · lore

Re: Make "git rev-list" be a builtin

On Thu, 18 May 2006, Junio C Hamano wrote:
Show 8 quoted lines
> Linus Torvalds <torvalds@osdl.org> writes:
> >
> > We should have done this long ago.
> 
> Should we have?
> 
> Certainly it is almost trivial, and it means we need to worry
> about one less file, but is that the point?
Take a look at the size of the binaries before and after.
This is the _stripped_ binaries (on ppc) before:
  -rwxr-xr-x 9 torvalds torvalds 213392 May 18 14:56 git
  -rwxr-xr-x 1 torvalds torvalds 167540 May 18 14:56 git-rev-list
and after:
  -rwxr-xr-x 10 torvalds torvalds 216740 May 18 14:56 git
  -rwxr-xr-x 10 torvalds torvalds 216740 May 18 14:56 git-rev-list

ie the "git" binary grew by about 3kB, and the "git-rev-list" binary shrank by about 164kB (because it now takes zero disk-space: it's the same as the git binary).

So on ppc, you win about 160kB of disk space from this (and much more if you don't strip the binaries - "git-rev-list" is over half a megabyte with the debugging info for me).

Now, x86 probably has less of that, because it's a denser instruction set, but I'd expect that to be in the 100kB range too.

			Linus

← back to recent threads