From 1fda91b511c76eb233f99877c60d1c5f7801f647 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 24 Aug 2010 10:33:59 -0700 Subject: Fix 'git log' early pager startup error case We start the pager too early for several git commands, which results in the errors sometimes going to the pager rather than show up as errors. This is often hidden by the fact that we pass in '-X' to less by default, which causes 'less' to exit for small output, but if you do export LESS=-S you can then clearly see the problem by doing git log --prretty which shows the error message ("fatal: unrecognized argument: --prretty") being sent to the pager. This happens for pretty much all git commands that use USE_PAGER, and then check arguments separately. But "git diff" does it too early too (even though it does an explicit setup_pager() call) This only fixes it for the trivial "git log" family case. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano diff --git a/builtin/log.c b/builtin/log.c index 08b8722..eaa1ee0 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -125,6 +125,7 @@ static void cmd_log_init(int argc, const char **argv, const char *prefix, rev->show_decorations = 1; load_ref_decorations(decoration_style); } + setup_pager(); } /* @@ -491,12 +492,6 @@ int cmd_log_reflog(int argc, const char **argv, const char *prefix) rev.use_terminator = 1; rev.always_show_header = 1; - /* - * We get called through "git reflog", so unlike the other log - * routines, we need to set up our pager manually.. - */ - setup_pager(); - return cmd_log_walk(&rev); } diff --git a/git.c b/git.c index f37028b..b83c1d1 100644 --- a/git.c +++ b/git.c @@ -336,7 +336,7 @@ static void handle_internal_command(int argc, const char **argv) { "index-pack", cmd_index_pack }, { "init", cmd_init_db }, { "init-db", cmd_init_db }, - { "log", cmd_log, RUN_SETUP | USE_PAGER }, + { "log", cmd_log, RUN_SETUP }, { "ls-files", cmd_ls_files, RUN_SETUP }, { "ls-tree", cmd_ls_tree, RUN_SETUP }, { "ls-remote", cmd_ls_remote }, @@ -380,7 +380,7 @@ static void handle_internal_command(int argc, const char **argv) { "send-pack", cmd_send_pack, RUN_SETUP }, { "shortlog", cmd_shortlog, USE_PAGER }, { "show-branch", cmd_show_branch, RUN_SETUP }, - { "show", cmd_show, RUN_SETUP | USE_PAGER }, + { "show", cmd_show, RUN_SETUP }, { "status", cmd_status, RUN_SETUP | NEED_WORK_TREE }, { "stripspace", cmd_stripspace }, { "symbolic-ref", cmd_symbolic_ref, RUN_SETUP }, @@ -395,7 +395,7 @@ static void handle_internal_command(int argc, const char **argv) { "var", cmd_var }, { "verify-tag", cmd_verify_tag, RUN_SETUP }, { "version", cmd_version }, - { "whatchanged", cmd_whatchanged, RUN_SETUP | USE_PAGER }, + { "whatchanged", cmd_whatchanged, RUN_SETUP }, { "write-tree", cmd_write_tree, RUN_SETUP }, { "verify-pack", cmd_verify_pack }, { "show-ref", cmd_show_ref, RUN_SETUP }, -- cgit v0.10.2-6-g49f6 From 2244eab01bfef95621ab61d2d08a3d21ba1353cf Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Tue, 24 Aug 2010 20:53:11 -0600 Subject: tree-walk: Correct bitrotted comment about tree_entry() There was a code comment that referred to the "above two functions" but over time the functions immediately preceding the comment have changed. Just mention the relevant functions by name. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano diff --git a/tree-walk.h b/tree-walk.h index 42110a4..f78361a 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -28,7 +28,10 @@ static inline int tree_entry_len(const char *name, const unsigned char *sha1) void update_tree_entry(struct tree_desc *); void init_tree_desc(struct tree_desc *desc, const void *buf, unsigned long size); -/* Helper function that does both of the above and returns true for success */ +/* + * Helper function that does both tree_entry_extract() and update_tree_entry() + * and returns true for success + */ int tree_entry(struct tree_desc *, struct name_entry *); void *fill_tree_descriptor(struct tree_desc *desc, const unsigned char *sha1); -- cgit v0.10.2-6-g49f6 From ea16a030aaaaebb3d0038e3ec2d9cd837985dee0 Mon Sep 17 00:00:00 2001 From: Jay Soffian Date: Thu, 26 Aug 2010 17:34:29 -0400 Subject: for-each-ref: fix objectname:short bug When objectname:short was introduced, it forgot to copy the result of find_unique_abbrev. Because the result of find_unique_abbrev is a pointer to static buffer, this resulted in the same value being substituted in for each ref. Signed-off-by: Jay Soffian Acked-by: Jeff King Signed-off-by: Junio C Hamano diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index a2b28c6..89e75c6 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -228,7 +228,8 @@ static void grab_common_values(struct atom_value *val, int deref, struct object v->s = s; } else if (!strcmp(name, "objectname:short")) { - v->s = find_unique_abbrev(obj->sha1, DEFAULT_ABBREV); + v->s = xstrdup(find_unique_abbrev(obj->sha1, + DEFAULT_ABBREV)); } } } -- cgit v0.10.2-6-g49f6