@matheusbsbs / matheus-bagliano / commits / 9590b041ea
Fork 0

Builtins: control the use of pager from the command table.

This moves the built-in "always-use-pager" logic for log family to the command dispatch table of git wrapper. This makes it easier to change the default use of pager, and has an added benefit that we fork and exec the pager early before packs are mmapped. Pointed out by Juergen Ruehle <j.ruehle@bmiag.de>. Signed-off-by: Junio C Hamano <junkio@cox.net>

Junio C Hamano committed Jul 31, 2006 at 02:53 UTC 9590b041ea464c46d5a6811df5bce83c5dd4d457
2 files changed +8 -6
builtin-log.c
-1
@@ -34,7 +34,6 @@ static int cmd_log_walk(struct rev_info *rev)
34 struct commit *commit;
35
36 prepare_revision_walk(rev);
37 - setup_pager();
37 while ((commit = get_revision(rev)) != NULL) {
38 log_tree_commit(rev, commit);
39 free(commit->buffer);
git.c
+8 -5
@@ -211,6 +211,7 @@ static int handle_alias(int *argcp, const char ***argv)
211 const char git_version_string[] = GIT_VERSION;
212
213 #define NEEDS_PREFIX 1
214 +#define USE_PAGER 2
215
216 static void handle_internal_command(int argc, const char **argv, char **envp)
217 {
@@ -218,13 +219,13 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
219 static struct cmd_struct {
220 const char *cmd;
221 int (*fn)(int, const char **, const char *);
221 - int prefix;
222 + int option;
223 } commands[] = {
224 { "version", cmd_version },
225 { "help", cmd_help },
225 - { "log", cmd_log, NEEDS_PREFIX },
226 - { "whatchanged", cmd_whatchanged, NEEDS_PREFIX },
227 - { "show", cmd_show, NEEDS_PREFIX },
226 + { "log", cmd_log, NEEDS_PREFIX | USE_PAGER },
227 + { "whatchanged", cmd_whatchanged, NEEDS_PREFIX | USE_PAGER },
228 + { "show", cmd_show, NEEDS_PREFIX | USE_PAGER },
229 { "push", cmd_push },
230 { "format-patch", cmd_format_patch, NEEDS_PREFIX },
231 { "count-objects", cmd_count_objects },
@@ -275,8 +276,10 @@ static void handle_internal_command(int argc, const char **argv, char **envp)
276 continue;
277
278 prefix = NULL;
278 - if (p->prefix)
279 + if (p->option & NEEDS_PREFIX)
280 prefix = setup_git_directory();
281 + if (p->option & USE_PAGER)
282 + setup_pager();
283 if (getenv("GIT_TRACE")) {
284 int i;
285 fprintf(stderr, "trace: built-in: git");