summaryrefslogtreecommitdiff
path: root/git.c
diff options
context:
space:
mode:
authorLinus Torvalds <torvalds@osdl.org>2006-02-28 19:30:19 (GMT)
committerJunio C Hamano <junkio@cox.net>2006-02-28 22:49:34 (GMT)
commit70b006b9712b57741ec1320b15aef2f8b1d6a905 (patch)
tree7845b22673d54b11eca632f19a6a157d2bd949df /git.c
parentf67b45f862d17b54037b9b59eefc385624d1fa83 (diff)
downloadgit-70b006b9712b57741ec1320b15aef2f8b1d6a905.zip
git-70b006b9712b57741ec1320b15aef2f8b1d6a905.tar.gz
git-70b006b9712b57741ec1320b15aef2f8b1d6a905.tar.bz2
Tie it all together: "git log"
This is what the previous diffs all built up to. We can do "git log" as a trivial small helper function inside git.c, because the infrastructure is all there for us to use as a library. Signed-off-by: Linus Torvalds <torvalds@osdl.org> Signed-off-by: Junio C Hamano <junkio@cox.net>
Diffstat (limited to 'git.c')
-rw-r--r--git.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/git.c b/git.c
index 993cd0d..b0da6b1 100644
--- a/git.c
+++ b/git.c
@@ -12,6 +12,10 @@
#include "git-compat-util.h"
#include "exec_cmd.h"
+#include "cache.h"
+#include "commit.h"
+#include "revision.h"
+
#ifndef PATH_MAX
# define PATH_MAX 4096
#endif
@@ -245,6 +249,25 @@ static int cmd_help(int argc, char **argv, char **envp)
return 0;
}
+#define LOGSIZE (65536)
+
+static int cmd_log(int argc, char **argv, char **envp)
+{
+ struct rev_info rev;
+ struct commit *commit;
+ char *buf = xmalloc(LOGSIZE);
+
+ argc = setup_revisions(argc, argv, &rev, "HEAD");
+ prepare_revision_walk(&rev);
+ setup_pager();
+ while ((commit = get_revision(&rev)) != NULL) {
+ pretty_print_commit(CMIT_FMT_DEFAULT, commit, ~0, buf, LOGSIZE, 18);
+ printf("%s\n", buf);
+ }
+ free(buf);
+ return 0;
+}
+
#define ARRAY_SIZE(x) (sizeof(x)/sizeof(x[0]))
static void handle_internal_command(int argc, char **argv, char **envp)
@@ -256,6 +279,7 @@ static void handle_internal_command(int argc, char **argv, char **envp)
} commands[] = {
{ "version", cmd_version },
{ "help", cmd_help },
+ { "log", cmd_log },
};
int i;