{"thread":{"id":"14582","subject":"git status in clean working dir","startedAt":"2008-07-21T23:13:55Z","lastAt":"2008-07-24T16:54:55Z","messageCount":30,"participants":["David Bremner","Junio C Hamano","Abhijit Menon-Sen","Jeff King","Mike Hommey","Pierre Habouzit","Johannes Sixt","Johannes Schindelin","Ask Bjørn Hansen"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"84256","messageId":"0ttzeirft8.wl%bremner@pivot.cs.unb.ca","threadId":"14582","inReplyTo":null,"subject":"git status in clean working dir","fromName":"David Bremner","fromEmail":"bremner@unb.ca","sentAt":"2008-07-21T23:13:55Z","receivedAt":"2008-07-21T23:13:55Z","isPatch":false,"sender":{"key":"bremner@unb.ca","avatar":null},"body":"\nAccording to the manual page for git-status (version 1.5.6.3)\n\n       If there is no path that is different between the index file\n       and the current HEAD commit (i.e., there is nothing to commit\n       by running git-commit), the command exits with non-zero status.\n\nBut it doesn't seem to work that way for me.\n\ngit status -a \n\nexits with 0\n\nbut \n\ngit commit -a \n\nexits with 1\n\nIs the man page wrong, or is this a bug? Or, option #3 ?\n\nDavid\n\nP.S. Please CC me. I'm not on the list.\n"},{"id":"84261","messageId":"7vy73ur6pz.fsf@gitster.siamese.dyndns.org","threadId":"14582","inReplyTo":"0ttzeirft8.wl%bremner@pivot.cs.unb.ca","subject":"Re: git status in clean working dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-22T02:30:16Z","receivedAt":"2008-07-22T02:30:16Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"David Bremner <bremner@unb.ca> writes:\n\n> According to the manual page for git-status (version 1.5.6.3)\n>\n>        If there is no path that is different between the index file\n>        and the current HEAD commit (i.e., there is nothing to commit\n>        by running git-commit), the command exits with non-zero status.\n>\n> But it doesn't seem to work that way for me.\n>\n> git status -a \n>\n> exits with 0\n> ...\n\nTry \"git status -a >/dev/null\" or \"git --no-pager status -a\".\n\nI think this is an instance of the c8af1de (make git-status use a pager,\n2008-04-23) stupidity raising its ugly head again.\n\nDo people mind reverting that patch?\n"},{"id":"84262","messageId":"20080722023626.GA31026@toroid.org","threadId":"14582","inReplyTo":"7vy73ur6pz.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Abhijit Menon-Sen","fromEmail":"ams@toroid.org","sentAt":"2008-07-22T02:36:26Z","receivedAt":"2008-07-22T02:36:26Z","isPatch":false,"sender":{"key":"ams@toroid.org","avatar":null},"body":"At 2008-07-21 19:30:16 -0700, gitster@pobox.com wrote:\n>\n> I think this is an instance of the c8af1de (make git-status use a\n> pager, 2008-04-23) stupidity raising its ugly head again.\n> \n> Do people mind reverting that patch?\n\nI think that is an excellent idea. I've found myself annoyed time and\nagain by \"git status\" starting the pager for just a couple of lines of\noutput.\n\n-- ams\n"},{"id":"84263","messageId":"7vtzeir68z.fsf@gitster.siamese.dyndns.org","threadId":"14582","inReplyTo":"7vy73ur6pz.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-22T02:40:28Z","receivedAt":"2008-07-22T02:40:28Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n>> git status -a \n>>\n>> exits with 0\n>> ...\n>\n> Try \"git status -a >/dev/null\" or \"git --no-pager status -a\".\n>\n> I think this is an instance of the c8af1de (make git-status use a pager,\n> 2008-04-23) stupidity raising its ugly head again.\n>\n> Do people mind reverting that patch?\n\nActually, the situation is now even worse than I originally thought\nespecially with Jeff's pager.<cmd> patch on 'master' recently.  For\nexample, you can screw yourself quite badly by forcing diff-files used in\nthe scripts you run to page, defeating --exit-code option.  Which means\n\n (1) It hurts?  Don't do it then; but\n\n (2) Then why are we even allowing to configure the plumbing to page?\n\nShould we maintain a table of commands that we allow paging to be\ncustomized, and ignore pager.<cmd> for commands that are not in the list?\n\nWhich codepath should issue error messages when the user tries to break\nthe system by saying \"pager.diff-files = true\"?\n"},{"id":"84265","messageId":"7vljzur5wd.fsf@gitster.siamese.dyndns.org","threadId":"14582","inReplyTo":"7vtzeir68z.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-22T02:48:02Z","receivedAt":"2008-07-22T02:48:02Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Actually, the situation is now even worse than I originally thought\n> especially with Jeff's pager.<cmd> patch on 'master' recently.  For\n> example, you can screw yourself quite badly by forcing diff-files used in\n> the scripts you run to page, defeating --exit-code option.  Which means\n>\n>  (1) It hurts?  Don't do it then; but\n>\n>  (2) Then why are we even allowing to configure the plumbing to page?\n>\n> Should we maintain a table of commands that we allow paging to be\n> customized, and ignore pager.<cmd> for commands that are not in the list?\n>\n> Which codepath should issue error messages when the user tries to break\n> the system by saying \"pager.diff-files = true\"?\n\nAnother possibility is to set up an extra process whose sole purpose is to\nwait for the main process that feeds the pager pipe and relay its exit\nstatus to the outside world.  But I do not think we would want to go\nthere...\n"},{"id":"84268","messageId":"20080722044157.GA20787@sigill.intra.peff.net","threadId":"14582","inReplyTo":"7vtzeir68z.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T04:41:57Z","receivedAt":"2008-07-22T04:41:57Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 21, 2008 at 07:40:28PM -0700, Junio C Hamano wrote:\n\n> Actually, the situation is now even worse than I originally thought\n> especially with Jeff's pager.<cmd> patch on 'master' recently.  For\n> example, you can screw yourself quite badly by forcing diff-files used in\n> the scripts you run to page, defeating --exit-code option.  Which means\n\nActually, you could _always_ do that with \"git -p diff-files\". Which is\nobviously stupid, just as setting pager.diff-files is. In the reported\ncase, though, \"status\" is broken, which we now do by default. So no\nstupidity required.\n\n>  (2) Then why are we even allowing to configure the plumbing to page?\n\n  1. Laziness. We just never marked which shouldn't be allowed to page.\n     But again, in this case, we have explicitly marked status as \"this\n     should page\" so I don't think this is a plumbing / porcelain thing.\n     Status fulfills both roles here (some people want it paged, because\n     they use it as porcelain, and some people want the exit code).\n\n  2. We don't always know all git commands. We execute user scripts as\n     \"git foo\", but we don't know what they do. Worse than that, we have\n     to commit our pager choice early because we might be exec'ing (but\n     this is somewhat of an artifact of the way the code is structured,\n     and not necessarily an impossible obstacle).\n\n> Should we maintain a table of commands that we allow paging to be\n> customized, and ignore pager.<cmd> for commands that are not in the list?\n\nThe patch below sets up the infrastructure, which is trivial. Note that\nthis _doesn't_ handle the case of \"git -p status\", because we have to\ncommit that choice at a different time (again, we might be able to\novercome that with a little code restructuring).\n\nThis marks diff-files as FORBID_PAGER; I will leave it to others to\nfight about which commands should have it. But it doesn't make sense to\nmark \"status\" since some people obviously _want_ the paging there.\n\n> Which codepath should issue error messages when the user tries to break\n> the system by saying \"pager.diff-files = true\"?\n\nNo error, but it is silently ignored. :)\n\n---\ndiff --git a/git.c b/git.c\nindex 74ea0e6..72cadb5 100644\n--- a/git.c\n+++ b/git.c\n@@ -210,6 +210,7 @@ const char git_version_string[] = GIT_VERSION;\n  * RUN_SETUP for reading from the configuration file.\n  */\n #define NEED_WORK_TREE\t(1<<2)\n+#define FORBID_PAGER\t(1<<3)\n \n struct cmd_struct {\n \tconst char *cmd;\n@@ -231,6 +232,8 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)\n \t\tuse_pager = check_pager_config(p->cmd);\n \tif (use_pager == -1 && p->option & USE_PAGER)\n \t\tuse_pager = 1;\n+\tif (use_pager ==  1 && p->option & FORBID_PAGER)\n+\t\tuse_pager = 0;\n \tcommit_pager_choice();\n \n \tif (p->option & NEED_WORK_TREE)\n@@ -286,7 +289,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"count-objects\", cmd_count_objects, RUN_SETUP },\n \t\t{ \"describe\", cmd_describe, RUN_SETUP },\n \t\t{ \"diff\", cmd_diff },\n-\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP },\n+\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP | FORBID_PAGER },\n \t\t{ \"diff-index\", cmd_diff_index, RUN_SETUP },\n \t\t{ \"diff-tree\", cmd_diff_tree, RUN_SETUP },\n \t\t{ \"fast-export\", cmd_fast_export, RUN_SETUP },\n"},{"id":"84269","messageId":"20080722044359.GB20787@sigill.intra.peff.net","threadId":"14582","inReplyTo":"7vljzur5wd.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T04:44:00Z","receivedAt":"2008-07-22T04:44:00Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jul 21, 2008 at 07:48:02PM -0700, Junio C Hamano wrote:\n\n> Another possibility is to set up an extra process whose sole purpose is to\n> wait for the main process that feeds the pager pipe and relay its exit\n> status to the outside world.  But I do not think we would want to go\n> there...\n\nWe could also swap the parent/child relationship, and have the pager as\nchild. But I assume that it is done the way we have it because otherwise\nthe shell gets confused about when the command ends (i.e., we want it to\nrun until pager completion). I didn't test, though.\n\n-Peff\n"},{"id":"84270","messageId":"20080722045223.GC20787@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722044359.GB20787@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T04:52:23Z","receivedAt":"2008-07-22T04:52:23Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 12:44:00AM -0400, Jeff King wrote:\n\n> We could also swap the parent/child relationship, and have the pager as\n> child. But I assume that it is done the way we have it because otherwise\n> the shell gets confused about when the command ends (i.e., we want it to\n> run until pager completion). I didn't test, though.\n\nHmm, it looks like the MINGW32 codepath already _does_ spawn in that\norder, but has a \"wait_for_child\" atexit handler. I wonder if there is a\nreason all platforms can't use that trick (though the mingw approach\nuses run_command, which makes it harder to do the \"wait for input before\nstarting less\" trick).\n\n-Peff\n"},{"id":"84275","messageId":"20080722053921.GA4983@glandium.org","threadId":"14582","inReplyTo":"20080722044157.GA20787@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2008-07-22T05:39:21Z","receivedAt":"2008-07-22T05:39:21Z","isPatch":false,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Tue, Jul 22, 2008 at 12:41:57AM -0400, Jeff King wrote:\n> On Mon, Jul 21, 2008 at 07:40:28PM -0700, Junio C Hamano wrote:\n> \n> > Actually, the situation is now even worse than I originally thought\n> > especially with Jeff's pager.<cmd> patch on 'master' recently.  For\n> > example, you can screw yourself quite badly by forcing diff-files used in\n> > the scripts you run to page, defeating --exit-code option.  Which means\n> \n> Actually, you could _always_ do that with \"git -p diff-files\". Which is\n> obviously stupid, just as setting pager.diff-files is. In the reported\n> case, though, \"status\" is broken, which we now do by default. So no\n> stupidity required.\n> \n> >  (2) Then why are we even allowing to configure the plumbing to page?\n> \n>   1. Laziness. We just never marked which shouldn't be allowed to page.\n>      But again, in this case, we have explicitly marked status as \"this\n>      should page\" so I don't think this is a plumbing / porcelain thing.\n>      Status fulfills both roles here (some people want it paged, because\n>      they use it as porcelain, and some people want the exit code).\n> \n>   2. We don't always know all git commands. We execute user scripts as\n>      \"git foo\", but we don't know what they do. Worse than that, we have\n>      to commit our pager choice early because we might be exec'ing (but\n>      this is somewhat of an artifact of the way the code is structured,\n>      and not necessarily an impossible obstacle).\n> \n> > Should we maintain a table of commands that we allow paging to be\n> > customized, and ignore pager.<cmd> for commands that are not in the list?\n> \n> The patch below sets up the infrastructure, which is trivial. Note that\n> this _doesn't_ handle the case of \"git -p status\", because we have to\n> commit that choice at a different time (again, we might be able to\n> overcome that with a little code restructuring).\n> \n> This marks diff-files as FORBID_PAGER; I will leave it to others to\n> fight about which commands should have it. But it doesn't make sense to\n> mark \"status\" since some people obviously _want_ the paging there.\n\nWhy not \"simply\" forbid the pager when output is not a terminal ?\n\nMike\n"},{"id":"84276","messageId":"20080722060643.GA25023@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722053921.GA4983@glandium.org","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T06:06:43Z","receivedAt":"2008-07-22T06:06:43Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 07:39:21AM +0200, Mike Hommey wrote:\n\n> > This marks diff-files as FORBID_PAGER; I will leave it to others to\n> > fight about which commands should have it. But it doesn't make sense to\n> > mark \"status\" since some people obviously _want_ the paging there.\n> \n> Why not \"simply\" forbid the pager when output is not a terminal ?\n\nWe already do that (see pager.c:53). The original poster still had a\nproblem, but I don't know if it was for actual usage or simply a toy\n\n  $ git status\n  $ echo $?\n  $ echo \"why don't exit codes work in status?\" | mail git@vger\n\nquestion.\n\n-Peff\n"},{"id":"84281","messageId":"20080722061807.GA6714@glandium.org","threadId":"14582","inReplyTo":"20080722060643.GA25023@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Mike Hommey","fromEmail":"mh@glandium.org","sentAt":"2008-07-22T06:18:07Z","receivedAt":"2008-07-22T06:18:07Z","isPatch":false,"sender":{"key":"mh@glandium.org","avatar":"https://avatars.githubusercontent.com/u/1038527?v=4"},"body":"On Tue, Jul 22, 2008 at 02:06:43AM -0400, Jeff King wrote:\n> On Tue, Jul 22, 2008 at 07:39:21AM +0200, Mike Hommey wrote:\n> \n> > > This marks diff-files as FORBID_PAGER; I will leave it to others to\n> > > fight about which commands should have it. But it doesn't make sense to\n> > > mark \"status\" since some people obviously _want_ the paging there.\n> > \n> > Why not \"simply\" forbid the pager when output is not a terminal ?\n> \n> We already do that (see pager.c:53). The original poster still had a\n> problem, but I don't know if it was for actual usage or simply a toy\n> \n>   $ git status\n>   $ echo $?\n>   $ echo \"why don't exit codes work in status?\" | mail git@vger\n> \n> question.\n\nAs you said in another branch of the thread, this part would be solved by\nhaving parent/child being reverted.\n\nNow, for the case where diff-files can have a pager if the user shoots\nhimself in the foot, if the output is not a terminal and pager.c already\ndoes the right thing, I don't see where diff-files having a pager will\nbe a problem.\n\nIf diff-files' output is a terminal, it's obviously intended to be\ndisplayed, be it in a script or not. But most of the time, its output\nwill be piped, thus not triggering the pager anyways.\n\nAnd for diff-files' exit code, well, see the first paragraph.\n\nMike\n"},{"id":"84283","messageId":"20080722064603.GA25221@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722061807.GA6714@glandium.org","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T06:46:04Z","receivedAt":"2008-07-22T06:46:04Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 08:18:07AM +0200, Mike Hommey wrote:\n\n> > We already do that (see pager.c:53). The original poster still had a\n> > problem, but I don't know if it was for actual usage or simply a toy\n> > \n> >   $ git status\n> >   $ echo $?\n> >   $ echo \"why don't exit codes work in status?\" | mail git@vger\n> > \n> > question.\n> \n> As you said in another branch of the thread, this part would be solved by\n> having parent/child being reverted.\n> \n> Now, for the case where diff-files can have a pager if the user shoots\n> himself in the foot, if the output is not a terminal and pager.c already\n> does the right thing, I don't see where diff-files having a pager will\n> be a problem.\n\nAh, OK. I misunderstood your original post. Yes, there are two ways\npaging can screw you: munging the data in a pipeline and munging the\nexit code. We already deal with former, so it is really just the latter\nthat is posing a problem in this thread.\n\nI am tempted by the \"order switching\" I mentioned, but that would entail\nthe git process waiting to clean the pager, during which time it may be\nconsuming memory. But maybe that isn't worth worrying about.\n\n-Peff\n"},{"id":"84286","messageId":"20080722071009.GA3610@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722064603.GA25221@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:10:09Z","receivedAt":"2008-07-22T07:10:09Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 02:46:04AM -0400, Jeff King wrote:\n\n> I am tempted by the \"order switching\" I mentioned, but that would entail\n> the git process waiting to clean the pager, during which time it may be\n> consuming memory. But maybe that isn't worth worrying about.\n\nIt feels very wrong proposing this during release freeze, but here is\nthe \"pager is child of git\" implementation.\n\nPatch 1/1 adds a bit of necessary infrastructure to run-command, and\npatch 2/2 does the deed. The nice thing is that it unifies the Windows\nand Unix implementations of setup_pager, so we get a nice line\nreduction.\n\n pager.c       |   49 ++++++++-----------------------------------------\n run-command.c |    2 ++\n run-command.h |    1 +\n 3 files changed, 11 insertions(+), 41 deletions(-)\n"},{"id":"84287","messageId":"20080722071246.GA3584@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722071009.GA3610@sigill.intra.peff.net","subject":"[PATCH 1/2] run-command: add pre-exec callback","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:12:46Z","receivedAt":"2008-07-22T07:12:46Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This is a function provided by the caller which is called\n_after_ the process is forked, but before the spawned\nprogram is executed. On platforms (like mingw) where\nsubprocesses are forked and executed in a single call, the\npreexec callback is simply ignored.\n\nThis will be used in the following patch to do some setup\nfor 'less' that must happen in the forked child.\n\nSigned-off-by: Jeff King <peff@peff.net>\n---\n run-command.c |    2 ++\n run-command.h |    1 +\n 2 files changed, 3 insertions(+), 0 deletions(-)\n\ndiff --git a/run-command.c b/run-command.c\nindex 6e29fdf..73d0c31 100644\n--- a/run-command.c\n+++ b/run-command.c\n@@ -110,6 +110,8 @@ int start_command(struct child_process *cmd)\n \t\t\t\t\tunsetenv(*cmd->env);\n \t\t\t}\n \t\t}\n+\t\tif (cmd->preexec_cb)\n+\t\t\tcmd->preexec_cb();\n \t\tif (cmd->git_cmd) {\n \t\t\texecv_git_cmd(cmd->argv);\n \t\t} else {\ndiff --git a/run-command.h b/run-command.h\nindex 5203a9e..4f2b7d7 100644\n--- a/run-command.h\n+++ b/run-command.h\n@@ -42,6 +42,7 @@ struct child_process {\n \tunsigned no_stderr:1;\n \tunsigned git_cmd:1; /* if this is to be git sub-command */\n \tunsigned stdout_to_stderr:1;\n+\tvoid (*preexec_cb)(void);\n };\n \n int start_command(struct child_process *);\n-- \n1.6.0.rc0.1.g9291f.dirty\n"},{"id":"84288","messageId":"20080722071411.GB3584@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722071246.GA3584@sigill.intra.peff.net","subject":"[PATCH 2/2] spawn pager via run_command interface","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:14:12Z","receivedAt":"2008-07-22T07:14:12Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"This has two important effects:\n\n 1. The pager is now the _child_ process, instead of the\n    parent. This means that whatever spawned git (e.g., the\n    shell) will see the exit code of the git process, and\n    not the pager.\n\n 2. The mingw and regular code are now unified, which makes\n    the setup_pager function much simpler.\n\nThere are two caveats:\n\n 1. We used to call execlp directly on the pager, followed\n    by trying to exec it via the shall. We now just use the\n    shell (which is what mingw has always done). This may\n    have different results for pager names which contain\n    shell metacharacters.\n\n    It is also slightly less efficient because we\n    unnecessarily run the shell; however, pager spawning is\n    by definition an interactive task, so it shouldn't be\n    a huge problem.\n\n 2. The git process will remain in memory while the user\n    looks through the pager. This is potentially wasteful.\n    We could get around this by turning the parent into a\n    meta-process which spawns _both_ git and the pager,\n    collects the exit status from git, waits for both to\n    end, and then exits with git's exit code.\n---\n pager.c |   49 ++++++++-----------------------------------------\n 1 files changed, 8 insertions(+), 41 deletions(-)\n\ndiff --git a/pager.c b/pager.c\nindex 6b5c9e4..7743742 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -1,4 +1,5 @@\n #include \"cache.h\"\n+#include \"run-command.h\"\n \n /*\n  * This is split up from the rest of git so that we can do\n@@ -8,7 +9,7 @@\n static int spawned_pager;\n \n #ifndef __MINGW32__\n-static void run_pager(const char *pager)\n+static void pager_preexec(void)\n {\n \t/*\n \t * Work around bug in \"less\" by not starting it until we\n@@ -20,16 +21,17 @@ static void run_pager(const char *pager)\n \tFD_SET(0, &in);\n \tselect(1, &in, NULL, &in, NULL);\n \n-\texeclp(pager, pager, NULL);\n-\texecl(\"/bin/sh\", \"sh\", \"-c\", pager, NULL);\n+\tsetenv(\"LESS\", \"FRSX\", 0);\n }\n-#else\n-#include \"run-command.h\"\n+#endif\n \n static const char *pager_argv[] = { \"sh\", \"-c\", NULL, NULL };\n static struct child_process pager_process = {\n \t.argv = pager_argv,\n-\t.in = -1\n+\t.in = -1,\n+#ifndef __MINGW32__\n+\t.preexec_cb = pager_preexec,\n+#endif\n };\n static void wait_for_pager(void)\n {\n@@ -40,14 +42,9 @@ static void wait_for_pager(void)\n \tclose(2);\n \tfinish_command(&pager_process);\n }\n-#endif\n \n void setup_pager(void)\n {\n-#ifndef __MINGW32__\n-\tpid_t pid;\n-\tint fd[2];\n-#endif\n \tconst char *pager = getenv(\"GIT_PAGER\");\n \n \tif (!isatty(1))\n@@ -66,35 +63,6 @@ void setup_pager(void)\n \n \tspawned_pager = 1; /* means we are emitting to terminal */\n \n-#ifndef __MINGW32__\n-\tif (pipe(fd) < 0)\n-\t\treturn;\n-\tpid = fork();\n-\tif (pid < 0) {\n-\t\tclose(fd[0]);\n-\t\tclose(fd[1]);\n-\t\treturn;\n-\t}\n-\n-\t/* return in the child */\n-\tif (!pid) {\n-\t\tdup2(fd[1], 1);\n-\t\tdup2(fd[1], 2);\n-\t\tclose(fd[0]);\n-\t\tclose(fd[1]);\n-\t\treturn;\n-\t}\n-\n-\t/* The original process turns into the PAGER */\n-\tdup2(fd[0], 0);\n-\tclose(fd[0]);\n-\tclose(fd[1]);\n-\n-\tsetenv(\"LESS\", \"FRSX\", 0);\n-\trun_pager(pager);\n-\tdie(\"unable to execute pager '%s'\", pager);\n-\texit(255);\n-#else\n \t/* spawn the pager */\n \tpager_argv[2] = pager;\n \tif (start_command(&pager_process))\n@@ -107,7 +75,6 @@ void setup_pager(void)\n \n \t/* this makes sure that the parent terminates after the pager */\n \tatexit(wait_for_pager);\n-#endif\n }\n \n int pager_in_use(void)\n-- \n1.6.0.rc0.1.g9291f.dirty\n"},{"id":"84289","messageId":"20080722071630.GA3669@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722071411.GB3584@sigill.intra.peff.net","subject":"Re: [PATCH 2/2] spawn pager via run_command interface","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:16:30Z","receivedAt":"2008-07-22T07:16:30Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 03:14:12AM -0400, Jeff King wrote:\n\n>  static struct child_process pager_process = {\n>  \t.argv = pager_argv,\n> -\t.in = -1\n> +\t.in = -1,\n> +#ifndef __MINGW32__\n> +\t.preexec_cb = pager_preexec,\n> +#endif\n\nI couldn't recall if this initializer style is portable enough for us.\nIt was already there wrapped in ifdefs, but perhaps it was only ok\nbecause the mingw version always uses the same compiler?\n\n-Peff\n"},{"id":"84295","messageId":"20080722073108.GA9714@artemis.madism.org","threadId":"14582","inReplyTo":"20080722071630.GA3669@sigill.intra.peff.net","subject":"Re: [PATCH 2/2] spawn pager via run_command interface","fromName":"Pierre Habouzit","fromEmail":"madcoder@debian.org","sentAt":"2008-07-22T07:31:08Z","receivedAt":"2008-07-22T07:31:08Z","isPatch":true,"sender":{"key":"madcoder@debian.org","avatar":"https://avatars.githubusercontent.com/u/44708?v=4"},"body":"On Tue, Jul 22, 2008 at 07:16:30AM +0000, Jeff King wrote:\n> On Tue, Jul 22, 2008 at 03:14:12AM -0400, Jeff King wrote:\n> \n> >  static struct child_process pager_process = {\n> >  \t.argv = pager_argv,\n> > -\t.in = -1\n> > +\t.in = -1,\n> > +#ifndef __MINGW32__\n> > +\t.preexec_cb = pager_preexec,\n> > +#endif\n> \n> I couldn't recall if this initializer style is portable enough for us.\n> It was already there wrapped in ifdefs, but perhaps it was only ok\n> because the mingw version always uses the same compiler?\n\n  it's not, I asked long time ago, and it's C99, which mingw supports\nindeed, and we don't want to require a C99 compiler.\n\n-- \n·O·  Pierre Habouzit\n··O                                                madcoder@debian.org\nOOO                                                http://www.madism.org\n"},{"id":"84296","messageId":"48858D95.7060409@viscovery.net","threadId":"14582","inReplyTo":"20080722044157.GA20787@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-07-22T07:34:45Z","receivedAt":"2008-07-22T07:34:45Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> @@ -231,6 +232,8 @@ static int run_command(struct cmd_struct *p, int argc, const char **argv)\n>  \t\tuse_pager = check_pager_config(p->cmd);\n>  \tif (use_pager == -1 && p->option & USE_PAGER)\n>  \t\tuse_pager = 1;\n> +\tif (use_pager ==  1 && p->option & FORBID_PAGER)\n> +\t\tuse_pager = 0;\n>  \tcommit_pager_choice();\n>  \n>  \tif (p->option & NEED_WORK_TREE)\n> @@ -286,7 +289,7 @@ static void handle_internal_command(int argc, const char **argv)\n>  \t\t{ \"count-objects\", cmd_count_objects, RUN_SETUP },\n>  \t\t{ \"describe\", cmd_describe, RUN_SETUP },\n>  \t\t{ \"diff\", cmd_diff },\n> -\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP },\n> +\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP | FORBID_PAGER },\n\nEvery now and then I want to use 'git -p diff-files', and I think that is\na valid use-case. But your suggested patch seems to forbid the pager even\nin this case. :-(\n\n-- Hannes\n"},{"id":"84299","messageId":"20080722074632.GA3999@sigill.intra.peff.net","threadId":"14582","inReplyTo":"48858D95.7060409@viscovery.net","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:46:32Z","receivedAt":"2008-07-22T07:46:32Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 09:34:45AM +0200, Johannes Sixt wrote:\n\n> > -\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP },\n> > +\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP | FORBID_PAGER },\n> \n> Every now and then I want to use 'git -p diff-files', and I think that is\n> a valid use-case. But your suggested patch seems to forbid the pager even\n> in this case. :-(\n\nActually, it doesn't. If you read earlier in the message, this applies\nonly to pager.* config. That being said, I think Junio's ultimate goal\nwas to not allow stupid people to accidentally set the pager on\nplumbing, at the expense of any smart people who might want to do it for\na good reason.\n\nThough I have to wonder why \"git diff --raw\" is not enough for you.\n\nAt any rate, I think this isn't the right route. We haven't actually\nseen evidence of somebody setting pager.diff-files and complaining about\nbreakage. We have seen people complaining about the lost exit code from\n\"git status\", which is not something that would be on the \"forbid\" list\nanyway. The real solution is to preserve the exit code when spawning the\npager, which I just posted a patch for.\n\n-Peff\n"},{"id":"84300","messageId":"488590B9.1080804@viscovery.net","threadId":"14582","inReplyTo":"20080722071630.GA3669@sigill.intra.peff.net","subject":"Re: [PATCH 2/2] spawn pager via run_command interface","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-07-22T07:48:09Z","receivedAt":"2008-07-22T07:48:09Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> On Tue, Jul 22, 2008 at 03:14:12AM -0400, Jeff King wrote:\n> \n>>  static struct child_process pager_process = {\n>>  \t.argv = pager_argv,\n>> -\t.in = -1\n>> +\t.in = -1,\n>> +#ifndef __MINGW32__\n>> +\t.preexec_cb = pager_preexec,\n>> +#endif\n> \n> I couldn't recall if this initializer style is portable enough for us.\n> It was already there wrapped in ifdefs, but perhaps it was only ok\n> because the mingw version always uses the same compiler?\n\nYes, that's because on mingw we know that we use gcc. This really must be\nchanged for portability.\n\nBTW, you could remove the #ifndef __MINGW32__ around both the definition\nand the use of pager_preexec. We have everything on mingw to compile and\nlink this function.\n\n-- Hannes\n"},{"id":"84301","messageId":"20080722074905.GB3999@sigill.intra.peff.net","threadId":"14582","inReplyTo":"20080722073108.GA9714@artemis.madism.org","subject":"Re: [PATCH 2/2] spawn pager via run_command interface","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:49:05Z","receivedAt":"2008-07-22T07:49:05Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 09:31:08AM +0200, Pierre Habouzit wrote:\n\n> > I couldn't recall if this initializer style is portable enough for us.\n> > It was already there wrapped in ifdefs, but perhaps it was only ok\n> > because the mingw version always uses the same compiler?\n> \n>   it's not, I asked long time ago, and it's C99, which mingw supports\n> indeed, and we don't want to require a C99 compiler.\n\nOK, then this should be squashed in.\n\ndiff --git a/pager.c b/pager.c\nindex 7743742..aa0966c 100644\n--- a/pager.c\n+++ b/pager.c\n@@ -26,13 +26,8 @@ static void pager_preexec(void)\n #endif\n \n static const char *pager_argv[] = { \"sh\", \"-c\", NULL, NULL };\n-static struct child_process pager_process = {\n-\t.argv = pager_argv,\n-\t.in = -1,\n-#ifndef __MINGW32__\n-\t.preexec_cb = pager_preexec,\n-#endif\n-};\n+static struct child_process pager_process;\n+\n static void wait_for_pager(void)\n {\n \tfflush(stdout);\n@@ -65,6 +60,11 @@ void setup_pager(void)\n \n \t/* spawn the pager */\n \tpager_argv[2] = pager;\n+\tpager_process.argv = pager_argv;\n+\tpager_process.in = -1;\n+#ifndef __MINGW32__\n+\tpager_process.preexec_cb = pager_preexec;\n+#endif\n \tif (start_command(&pager_process))\n \t\treturn;\n \n"},{"id":"84302","messageId":"20080722075035.GC3999@sigill.intra.peff.net","threadId":"14582","inReplyTo":"488590B9.1080804@viscovery.net","subject":"Re: [PATCH 2/2] spawn pager via run_command interface","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T07:50:35Z","receivedAt":"2008-07-22T07:50:35Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 09:48:09AM +0200, Johannes Sixt wrote:\n\n> BTW, you could remove the #ifndef __MINGW32__ around both the definition\n> and the use of pager_preexec. We have everything on mingw to compile and\n> link this function.\n\nAh, OK. I left it around the function because I was worried about fd_set\nneeding some magic for compilation.\n\nHowever, it still won't be _used_ on Windows, because there is no\nopportunity to use the pre-exec callback (it is silently ignored).\n\n-Peff\n"},{"id":"84303","messageId":"48859220.6080509@viscovery.net","threadId":"14582","inReplyTo":"20080722074632.GA3999@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-07-22T07:54:08Z","receivedAt":"2008-07-22T07:54:08Z","isPatch":false,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> On Tue, Jul 22, 2008 at 09:34:45AM +0200, Johannes Sixt wrote:\n> \n>>> -\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP },\n>>> +\t\t{ \"diff-files\", cmd_diff_files, RUN_SETUP | FORBID_PAGER },\n>> Every now and then I want to use 'git -p diff-files', and I think that is\n>> a valid use-case. But your suggested patch seems to forbid the pager even\n>> in this case. :-(\n> \n> Actually, it doesn't. If you read earlier in the message, this applies\n> only to pager.* config. That being said, I think Junio's ultimate goal\n> was to not allow stupid people to accidentally set the pager on\n> plumbing, at the expense of any smart people who might want to do it for\n> a good reason.\n> \n> Though I have to wonder why \"git diff --raw\" is not enough for you.\n\nUsually, I use plumbing with a pager while I'm writing or debugging a\nscript, and I'm studying its output. So, no, I'm not interested in \"git\ndiff --raw\". ;)\n\n-- Hannes\n"},{"id":"84307","messageId":"48859A57.9090302@viscovery.net","threadId":"14582","inReplyTo":"20080722075035.GC3999@sigill.intra.peff.net","subject":"Re: [PATCH 2/2] spawn pager via run_command interface","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2008-07-22T08:29:11Z","receivedAt":"2008-07-22T08:29:11Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Jeff King schrieb:\n> On Tue, Jul 22, 2008 at 09:48:09AM +0200, Johannes Sixt wrote:\n> \n>> BTW, you could remove the #ifndef __MINGW32__ around both the definition\n>> and the use of pager_preexec. We have everything on mingw to compile and\n>> link this function.\n> \n> Ah, OK. I left it around the function because I was worried about fd_set\n> needing some magic for compilation.\n\nI do not expect you to know the intricacies of the mingw port. Hence,\nstaying on the safe side, like you did, is of course highly appreciated.\n\n> However, it still won't be _used_ on Windows, because there is no\n> opportunity to use the pre-exec callback (it is silently ignored).\n\nThat's fine.\n\n-- Hannes\n"},{"id":"84311","messageId":"7viquymg5k.fsf@gitster.siamese.dyndns.org","threadId":"14582","inReplyTo":"20080722071009.GA3610@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2008-07-22T09:17:43Z","receivedAt":"2008-07-22T09:17:43Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jeff King <peff@peff.net> writes:\n\n> On Tue, Jul 22, 2008 at 02:46:04AM -0400, Jeff King wrote:\n>\n>> I am tempted by the \"order switching\" I mentioned, but that would entail\n>> the git process waiting to clean the pager, during which time it may be\n>> consuming memory. But maybe that isn't worth worrying about.\n>\n> It feels very wrong proposing this during release freeze, but here is\n> the \"pager is child of git\" implementation.\n\nAnother slight worry I have is if the now-parent git process does the\nright thing when the user kills the pager without viewing the output to\nthe end.  git itself will get stuck with write() while the user is\nreading, and then notice that the pipe does not have any more reader when\nthe pager is killed.  This fact itself won't change by swapping the\nparent-child relationship, but would we get a sensible behaviour after\nthat, or have we been ignoring what happens afterwards only because our\nexit status has been hidden behind the pager?  Running \"git log\" and\nkilling it by \"q\" (my pager is \"less\") makes it exit with 141.\n\nI shouldn't worry, if everything is written correctly in the other parts\nof the system, this swap should not have much ill effect.\n\nBy the way [2/2] was not signed-off.  Just forgotten?\n"},{"id":"84314","messageId":"20080722094054.GA5720@sigill.intra.peff.net","threadId":"14582","inReplyTo":"7viquymg5k.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-22T09:40:55Z","receivedAt":"2008-07-22T09:40:55Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Tue, Jul 22, 2008 at 02:17:43AM -0700, Junio C Hamano wrote:\n\n> Another slight worry I have is if the now-parent git process does the\n> right thing when the user kills the pager without viewing the output to\n> the end.  git itself will get stuck with write() while the user is\n> reading, and then notice that the pipe does not have any more reader when\n> the pager is killed.  This fact itself won't change by swapping the\n> parent-child relationship, but would we get a sensible behaviour after\n> that, or have we been ignoring what happens afterwards only because our\n> exit status has been hidden behind the pager?  Running \"git log\" and\n> killing it by \"q\" (my pager is \"less\") makes it exit with 141.\n\nHmm, good point. Though previously in this case, we were getting\nwhatever code the pager provided. Which means nobody probably cared that\nmuch. Though I suppose that people who use \"$?\" in their prompt might\nsee scariness.\n\n> I shouldn't worry, if everything is written correctly in the other parts\n> of the system, this swap should not have much ill effect.\n\nI am a little unhappy about the git process hanging around, but I don't\nknow if it is worth making a meta-process just to manage the pager.\n\nAlso, I think people with a pager that has spaces in in it will now need\nto quote it (e.g., PAGER=\"/path with space/less\" used to work, but now\nis passed to the shell). Arguably, this brings it in line with other\nspawned programs, like EDITOR, but it is a difference, and we are in\nrelease freeze. That could be fixed with some magic in run_command.\n(Note that it has always been run by the shell under Windows, so again,\nthis is making things more consistent).\n\n> By the way [2/2] was not signed-off.  Just forgotten?\n\nYes, forgotten. If you are planning on applying, please forge (and\nsquash the portability fix).\n\n-Peff\n"},{"id":"84322","messageId":"alpine.DEB.1.00.0807221323440.3391@eeepc-johanness","threadId":"14582","inReplyTo":"20080722045223.GC20787@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2008-07-22T11:24:27Z","receivedAt":"2008-07-22T11:24:27Z","isPatch":false,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Tue, 22 Jul 2008, Jeff King wrote:\n\n> On Tue, Jul 22, 2008 at 12:44:00AM -0400, Jeff King wrote:\n> \n> > We could also swap the parent/child relationship, and have the pager \n> > as child. But I assume that it is done the way we have it because \n> > otherwise the shell gets confused about when the command ends (i.e., \n> > we want it to run until pager completion). I didn't test, though.\n> \n> Hmm, it looks like the MINGW32 codepath already _does_ spawn in that \n> order, but has a \"wait_for_child\" atexit handler. I wonder if there is a \n> reason all platforms can't use that trick (though the mingw approach \n> uses run_command, which makes it harder to do the \"wait for input before \n> starting less\" trick).\n\nI recently suggested exactly that already, to catch SIGSEGVs in the paged \nprocess, amongst other things.\n\nCiao,\nDscho\n"},{"id":"84325","messageId":"877ibe2eo1.wl%bremner@pivot.cs.unb.ca","threadId":"14582","inReplyTo":"20080722060643.GA25023@sigill.intra.peff.net","subject":"Re: git status in clean working dir","fromName":"David Bremner","fromEmail":"bremner@unb.ca","sentAt":"2008-07-22T14:10:06Z","receivedAt":"2008-07-22T14:10:06Z","isPatch":false,"sender":{"key":"bremner@unb.ca","avatar":null},"body":">>>>> \"Jeff\" == Jeff King <peff@peff.net> writes:\n    Jeff> We already do that (see pager.c:53). The original poster\n    Jeff> still had a problem, but I don't know if it was for actual\n    Jeff> usage or simply a toy\n\n    Jeff>   $ git status \n    Jeff>   $ echo $?  \n    Jeff>   $ echo \"why don't exit codes work in status?\" | mail git@vger\n\nWell, I wanted to know if git status was the right tool to detect a\nworking directory with no changes to commit. So I tried it in the\nshell, and it failed.  I then read the man page. For me, it would be\nfine to document the current behaviour (i.e. in practice \"git status\n-a > /dev/null\" would be what I would use in scripts anyway).  To be\nhonest the current behaviour was not something I would have guessed.\n\nThanks to all for paying attention to my complaint,\n\nDavid\n"},{"id":"84677","messageId":"D42305E3-82DA-46C1-B55F-74AD9AD48197@develooper.com","threadId":"14582","inReplyTo":"7vtzeir68z.fsf@gitster.siamese.dyndns.org","subject":"Re: git status in clean working dir","fromName":"Ask Bjørn Hansen","fromEmail":"ask@develooper.com","sentAt":"2008-07-24T06:56:48Z","receivedAt":"2008-07-24T06:56:48Z","isPatch":false,"sender":{"key":"ask@develooper.com","avatar":"https://gravatar.com/avatar/05ce68433216df7d04bb0d82b7d93b11957e2137e6ed23c4b5bc061d78635f2f?d=mp&s=160"},"body":"\nOn Jul 21, 2008, at 19:40, Junio C Hamano wrote:\n\n> (2) Then why are we even allowing to configure the plumbing to page?\n\n\nI don't have an opinion on the the appropriateness of paging various  \ncommands, but to solve the problem of scripts getting tripped up by  \nthe paging, couldn't the plumping check if STDOUT is a tty and only do  \nthe paging if so?\n\n(In Perl \"page_output(...) if $pager_configured and -t STDOUT\")\n\n\n  - ask\n\n-- \nhttp://develooper.com/ - http://askask.com/\n"},{"id":"84744","messageId":"20080724165455.GD20816@sigill.intra.peff.net","threadId":"14582","inReplyTo":"D42305E3-82DA-46C1-B55F-74AD9AD48197@develooper.com","subject":"Re: git status in clean working dir","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2008-07-24T16:54:55Z","receivedAt":"2008-07-24T16:54:55Z","isPatch":false,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Wed, Jul 23, 2008 at 11:56:48PM -0700, Ask Bjørn Hansen wrote:\n\n>> (2) Then why are we even allowing to configure the plumbing to page?\n>\n> I don't have an opinion on the the appropriateness of paging various  \n> commands, but to solve the problem of scripts getting tripped up by the \n> paging, couldn't the plumping check if STDOUT is a tty and only do the \n> paging if so?\n>\n> (In Perl \"page_output(...) if $pager_configured and -t STDOUT\")\n\nWe already do this, so \"git status >/dev/null\" produces the correct exit\ncode. But scripts don't necessarily redirect stdout.\n\n-Peff\n"}]}