Re: git status in clean working dir

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Jeff King
Date: Monday, July 21, 2008 - 9:41 pm

On Mon, Jul 21, 2008 at 07:40:28PM -0700, Junio C Hamano wrote:


Actually, you could _always_ do that with "git -p diff-files". Which is
obviously stupid, just as setting pager.diff-files is. In the reported
case, though, "status" is broken, which we now do by default. So no
stupidity required.


  1. Laziness. We just never marked which shouldn't be allowed to page.
     But again, in this case, we have explicitly marked status as "this
     should page" so I don't think this is a plumbing / porcelain thing.
     Status fulfills both roles here (some people want it paged, because
     they use it as porcelain, and some people want the exit code).

  2. We don't always know all git commands. We execute user scripts as
     "git foo", but we don't know what they do. Worse than that, we have
     to commit our pager choice early because we might be exec'ing (but
     this is somewhat of an artifact of the way the code is structured,
     and not necessarily an impossible obstacle).


The patch below sets up the infrastructure, which is trivial. Note that
this _doesn't_ handle the case of "git -p status", because we have to
commit that choice at a different time (again, we might be able to
overcome that with a little code restructuring).

This marks diff-files as FORBID_PAGER; I will leave it to others to
fight about which commands should have it. But it doesn't make sense to
mark "status" since some people obviously _want_ the paging there.


No error, but it is silently ignored. :)

---
diff --git a/git.c b/git.c
index 74ea0e6..72cadb5 100644
--- a/git.c
+++ b/git.c
@@ -210,6 +210,7 @@ const char git_version_string[] = GIT_VERSION;
  * RUN_SETUP for reading from the configuration file.
  */
 #define NEED_WORK_TREE	(1<<2)
+#define FORBID_PAGER	(1<<3)
 
 struct cmd_struct {
 	const char *cmd;
@@ -231,6 +232,8 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)
 		use_pager = check_pager_config(p->cmd);
 	if (use_pager == -1 && p->option & USE_PAGER)
 		use_pager = 1;
+	if (use_pager ==  1 && p->option & FORBID_PAGER)
+		use_pager = 0;
 	commit_pager_choice();
 
 	if (p->option & NEED_WORK_TREE)
@@ -286,7 +289,7 @@ static void handle_internal_command(int argc, const char **argv)
 		{ "count-objects", cmd_count_objects, RUN_SETUP },
 		{ "describe", cmd_describe, RUN_SETUP },
 		{ "diff", cmd_diff },
-		{ "diff-files", cmd_diff_files, RUN_SETUP },
+		{ "diff-files", cmd_diff_files, RUN_SETUP | FORBID_PAGER },
 		{ "diff-index", cmd_diff_index, RUN_SETUP },
 		{ "diff-tree", cmd_diff_tree, RUN_SETUP },
 		{ "fast-export", cmd_fast_export, RUN_SETUP },
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@vger.kernel.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
git status in clean working dir, David Bremner, (Mon Jul 21, 4:13 pm)
Re: git status in clean working dir, Junio C Hamano, (Mon Jul 21, 7:30 pm)
Re: git status in clean working dir, Abhijit Menon-Sen, (Mon Jul 21, 7:36 pm)
Re: git status in clean working dir, Junio C Hamano, (Mon Jul 21, 7:40 pm)
Re: git status in clean working dir, Junio C Hamano, (Mon Jul 21, 7:48 pm)
Re: git status in clean working dir, Jeff King, (Mon Jul 21, 9:41 pm)
Re: git status in clean working dir, Jeff King, (Mon Jul 21, 9:44 pm)
Re: git status in clean working dir, Jeff King, (Mon Jul 21, 9:52 pm)
Re: git status in clean working dir, Mike Hommey, (Mon Jul 21, 10:39 pm)
Re: git status in clean working dir, Jeff King, (Mon Jul 21, 11:06 pm)
Re: git status in clean working dir, Mike Hommey, (Mon Jul 21, 11:18 pm)
Re: git status in clean working dir, Jeff King, (Mon Jul 21, 11:46 pm)
Re: git status in clean working dir, Jeff King, (Tue Jul 22, 12:10 am)
[PATCH 1/2] run-command: add pre-exec callback, Jeff King, (Tue Jul 22, 12:12 am)
[PATCH 2/2] spawn pager via run_command interface, Jeff King, (Tue Jul 22, 12:14 am)
Re: [PATCH 2/2] spawn pager via run_command interface, Pierre Habouzit, (Tue Jul 22, 12:31 am)
Re: git status in clean working dir, Johannes Sixt, (Tue Jul 22, 12:34 am)
Re: git status in clean working dir, Jeff King, (Tue Jul 22, 12:46 am)
Re: [PATCH 2/2] spawn pager via run_command interface, Johannes Sixt, (Tue Jul 22, 12:48 am)
Re: git status in clean working dir, Johannes Sixt, (Tue Jul 22, 12:54 am)
Re: [PATCH 2/2] spawn pager via run_command interface, Johannes Sixt, (Tue Jul 22, 1:29 am)
Re: git status in clean working dir, Johannes Schindelin, (Tue Jul 22, 4:24 am)
Re: git status in clean working dir, David Bremner, (Tue Jul 22, 7:10 am)
Re: git status in clean working dir, Ask Bjørn Hansen, (Wed Jul 23, 11:56 pm)
Re: git status in clean working dir, Jeff King, (Thu Jul 24, 9:54 am)