{"thread":{"id":"24205","subject":"[PATCH 0/4] git --paginate: do not commit pager choice too early","startedAt":"2010-06-26T19:22:03Z","lastAt":"2010-08-16T16:41:48Z","messageCount":42,"participants":["Jonathan Nieder","Jeff King","Nguyen Thai Ngoc Duy","Junio C Hamano","Ævar Arnfjörð Bjarmason","Nguyễn Thái Ngọc Duy","Thomas Rast"],"isPatch":true,"patchVersion":1,"patchTotal":4},"messages":[{"id":"144329","messageId":"20100626192203.GA19973@burratino","threadId":"24205","inReplyTo":null,"subject":"[PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T19:22:03Z","receivedAt":"2010-06-26T19:22:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Here’s a fix from the famous setup cleanup series[1].\n\nThe problem it fixes is somewhat obscure: ‘git -p foo’ is not paying\nattention to the repository-local ‘[core] pager’ configuration when\nrun from a subdirectory.  But it is a real bug, and the fix gives\nan example of how to deal with repository setup and should be safe.\n\nPatch is against master.  There is a small semantic conflict with\njn/grep-open: SIMPLEPAGER should be changed to SIMPLEPAGERTTY in the\nprerequisites for the test_default_pager function.  Please let me\nknow if I should push a merge commit to help resolve that.\n\nThoughts?\nJonathan Nieder (3):\n  t7006 (pager): introduce helper for parameterized tests\n  t7006: test pager configuration for several git commands\n  tests: local config file should be honored from subdirs of toplevel\n\nNguyễn Thái Ngọc Duy (1):\n  git --paginate: do not commit pager choice too early\n\n git.c            |    2 +-\n t/t7006-pager.sh |  234 +++++++++++++++++++++++++++++++++++++++++------------\n 2 files changed, 182 insertions(+), 54 deletions(-)\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/144778\n"},{"id":"144330","messageId":"20100626192302.GA20051@burratino","threadId":"24205","inReplyTo":"20100626192203.GA19973@burratino","subject":"[PATCH 1/4] t7006 (pager): introduce helper for parameterized tests","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T19:23:02Z","receivedAt":"2010-06-26T19:23:02Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The current tests test pager configuration for ‘git log’, but other\ncommands use a different setup procedure and should therefore be\ntested separately.  Add a helper to make this easier.\n\nThis patch introduces the helper and changes some existing tests to\nuse it.  The only functional change should be the introduction of ‘git\nlog - ’ to a few test descriptions.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7006-pager.sh |   72 ++++++++++++++++++++++++++++++++++++++++-------------\n 1 files changed, 54 insertions(+), 18 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 9a83241..b117ebb 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -172,58 +172,94 @@ then\n \ttest_set_prereq SIMPLEPAGER\n fi\n \n-test_expect_success SIMPLEPAGER 'default pager is used by default' '\n+# Use this helper to make it easy for the caller of your\n+# terminal-using function to specify whether it should fail.\n+# If you write\n+#\n+#\tyour_test() {\n+#\t\tparse_args \"$@\"\n+#\n+#\t\t$test_expectation \"$cmd - behaves well\" \"\n+#\t\t\t...\n+#\t\t\t$full_command &&\n+#\t\t\t...\n+#\t\t\"\n+#\t}\n+#\n+# then your test can be used like this:\n+#\n+#\tyour_test expect_(success|failure) [test_must_fail] 'git foo'\n+#\n+parse_args() {\n+\ttest_expectation=\"test_$1\"\n+\tshift\n+\tif test \"$1\" = test_must_fail\n+\tthen\n+\t\tfull_command=\"test_must_fail test_terminal \"\n+\t\tshift\n+\telse\n+\t\tfull_command=\"test_terminal \"\n+\tfi\n+\tcmd=$1\n+\tfull_command=\"$full_command $1\"\n+}\n+\n+parse_args expect_success 'git log'\n+$test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n \tunset PAGER GIT_PAGER;\n \ttest_might_fail git config --unset core.pager &&\n \trm -f default_pager_used ||\n \tcleanup_fail &&\n \n-\tcat >$less <<-\\EOF &&\n+\tcat >\\$less <<-\\EOF &&\n \t#!/bin/sh\n \twc >default_pager_used\n \tEOF\n-\tchmod +x $less &&\n+\tchmod +x \\$less &&\n \t(\n-\t\tPATH=.:$PATH &&\n+\t\tPATH=.:\\$PATH &&\n \t\texport PATH &&\n-\t\ttest_terminal git log\n+\t\t$full_command\n \t) &&\n \ttest -e default_pager_used\n-'\n+\"\n \n-test_expect_success TTY 'PAGER overrides default pager' '\n+parse_args expect_success 'git log'\n+$test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\n \tunset GIT_PAGER;\n \ttest_might_fail git config --unset core.pager &&\n \trm -f PAGER_used ||\n \tcleanup_fail &&\n \n-\tPAGER=\"wc >PAGER_used\" &&\n+\tPAGER='wc >PAGER_used' &&\n \texport PAGER &&\n-\ttest_terminal git log &&\n+\t$full_command &&\n \ttest -e PAGER_used\n-'\n+\"\n \n-test_expect_success TTY 'core.pager overrides PAGER' '\n+parse_args expect_success 'git log'\n+$test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n \tunset GIT_PAGER;\n \trm -f core.pager_used ||\n \tcleanup_fail &&\n \n \tPAGER=wc &&\n \texport PAGER &&\n-\tgit config core.pager \"wc >core.pager_used\" &&\n-\ttest_terminal git log &&\n+\tgit config core.pager 'wc >core.pager_used' &&\n+\t$full_command &&\n \ttest -e core.pager_used\n-'\n+\"\n \n-test_expect_success TTY 'GIT_PAGER overrides core.pager' '\n+parse_args expect_success 'git log'\n+$test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n \trm -f GIT_PAGER_used ||\n \tcleanup_fail &&\n \n \tgit config core.pager wc &&\n-\tGIT_PAGER=\"wc >GIT_PAGER_used\" &&\n+\tGIT_PAGER='wc >GIT_PAGER_used' &&\n \texport GIT_PAGER &&\n-\ttest_terminal git log &&\n+\t$full_command &&\n \ttest -e GIT_PAGER_used\n-'\n+\"\n \n test_done\n-- \n1.7.1.579.ge2549\n"},{"id":"144331","messageId":"20100626192450.GB20051@burratino","threadId":"24205","inReplyTo":"20100626192203.GA19973@burratino","subject":"[PATCH 2/4] t7006: test pager configuration for several git commands","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T19:24:50Z","receivedAt":"2010-06-26T19:24:50Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Test choice of pager at several stages of repository setup.  This\nprovides some (admittedly uninteresting) examples to keep in mind when\nconsidering changes to the setup procedure.\n\nImproved-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThe patch from ‘diff -w’ should be easier to review.  I’ll send it as\na reply.\n\nThanks to both Junio and Hannes for improvements.\n\n t/t7006-pager.sh |  146 +++++++++++++++++++++++++++++++++---------------------\n 1 files changed, 89 insertions(+), 57 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex b117ebb..4420f91 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -204,62 +204,94 @@ parse_args() {\n \tfull_command=\"$full_command $1\"\n }\n \n-parse_args expect_success 'git log'\n-$test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n-\tunset PAGER GIT_PAGER;\n-\ttest_might_fail git config --unset core.pager &&\n-\trm -f default_pager_used ||\n-\tcleanup_fail &&\n-\n-\tcat >\\$less <<-\\EOF &&\n-\t#!/bin/sh\n-\twc >default_pager_used\n-\tEOF\n-\tchmod +x \\$less &&\n-\t(\n-\t\tPATH=.:\\$PATH &&\n-\t\texport PATH &&\n-\t\t$full_command\n-\t) &&\n-\ttest -e default_pager_used\n-\"\n-\n-parse_args expect_success 'git log'\n-$test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\n-\tunset GIT_PAGER;\n-\ttest_might_fail git config --unset core.pager &&\n-\trm -f PAGER_used ||\n-\tcleanup_fail &&\n-\n-\tPAGER='wc >PAGER_used' &&\n-\texport PAGER &&\n-\t$full_command &&\n-\ttest -e PAGER_used\n-\"\n-\n-parse_args expect_success 'git log'\n-$test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n-\tunset GIT_PAGER;\n-\trm -f core.pager_used ||\n-\tcleanup_fail &&\n-\n-\tPAGER=wc &&\n-\texport PAGER &&\n-\tgit config core.pager 'wc >core.pager_used' &&\n-\t$full_command &&\n-\ttest -e core.pager_used\n-\"\n-\n-parse_args expect_success 'git log'\n-$test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n-\trm -f GIT_PAGER_used ||\n-\tcleanup_fail &&\n-\n-\tgit config core.pager wc &&\n-\tGIT_PAGER='wc >GIT_PAGER_used' &&\n-\texport GIT_PAGER &&\n-\t$full_command &&\n-\ttest -e GIT_PAGER_used\n-\"\n+test_default_pager() {\n+\tparse_args \"$@\"\n+\n+\t$test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n+\t\tunset PAGER GIT_PAGER;\n+\t\ttest_might_fail git config --unset core.pager &&\n+\t\trm -f default_pager_used ||\n+\t\tcleanup_fail &&\n+\n+\t\tcat >\\$less <<-\\EOF &&\n+\t\t#!/bin/sh\n+\t\twc >default_pager_used\n+\t\tEOF\n+\t\tchmod +x \\$less &&\n+\t\t(\n+\t\t\tPATH=.:\\$PATH &&\n+\t\t\texport PATH &&\n+\t\t\t$full_command\n+\t\t) &&\n+\t\ttest -e default_pager_used\n+\t\"\n+}\n+\n+test_PAGER_overrides() {\n+\tparse_args \"$@\"\n+\n+\t$test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\n+\t\tunset GIT_PAGER;\n+\t\ttest_might_fail git config --unset core.pager &&\n+\t\trm -f PAGER_used ||\n+\t\tcleanup_fail &&\n+\n+\t\tPAGER='wc >PAGER_used' &&\n+\t\texport PAGER &&\n+\t\t$full_command &&\n+\t\ttest -e PAGER_used\n+\t\"\n+}\n+\n+test_core_pager_overrides() {\n+\tparse_args \"$@\"\n+\n+\t$test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n+\t\tunset GIT_PAGER;\n+\t\trm -f core.pager_used ||\n+\t\tcleanup_fail &&\n+\n+\t\tPAGER=wc &&\n+\t\texport PAGER &&\n+\t\tgit config core.pager 'wc >core.pager_used' &&\n+\t\t$full_command &&\n+\t\ttest -e core.pager_used\n+\t\"\n+}\n+\n+test_GIT_PAGER_overrides() {\n+\tparse_args \"$@\"\n+\n+\t$test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n+\t\trm -f GIT_PAGER_used ||\n+\t\tcleanup_fail &&\n+\n+\t\tgit config core.pager wc &&\n+\t\tGIT_PAGER='wc >GIT_PAGER_used' &&\n+\t\texport GIT_PAGER &&\n+\t\t$full_command &&\n+\t\ttest -e GIT_PAGER_used\n+\t\"\n+}\n+\n+test_default_pager        expect_success 'git log'\n+test_PAGER_overrides      expect_success 'git log'\n+test_core_pager_overrides expect_success 'git log'\n+test_GIT_PAGER_overrides  expect_success 'git log'\n+\n+test_default_pager        expect_success 'git -p log'\n+test_PAGER_overrides      expect_success 'git -p log'\n+test_core_pager_overrides expect_success 'git -p log'\n+test_GIT_PAGER_overrides  expect_success 'git -p log'\n+\n+test_default_pager        expect_success test_must_fail 'git -p'\n+test_PAGER_overrides      expect_success test_must_fail 'git -p'\n+test_core_pager_overrides expect_success test_must_fail 'git -p'\n+test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'\n+\n+test_default_pager        expect_success test_must_fail 'git -p nonsense'\n+test_PAGER_overrides      expect_success test_must_fail 'git -p nonsense'\n+test_core_pager_overrides expect_success test_must_fail 'git -p nonsense'\n+test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.1.579.ge2549\n"},{"id":"144332","messageId":"20100626192537.GC20051@burratino","threadId":"24205","inReplyTo":"20100626192203.GA19973@burratino","subject":"[PATCH 3/4] tests: local config file should be honored from subdirs of toplevel","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T19:25:37Z","receivedAt":"2010-06-26T19:25:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"When git is passed the --paginate option, starting up a pager requires\ndeciding what pager to start, which requires access to the core.pager\nconfiguration.  If --paginate is handled before searching for the\ngit dir, this configuration will be missed.\n\nIn other words, with --paginate and only with --paginate, any\nrepository-local core.pager setting is being ignored [*].\n\n[*] unless the git directory is ./.git or GIT_DIR or GIT_CONFIG was\nset explicitly.\n\nAdd a test to demonstrate this counterintuitive behavior.  Noticed\nwhile reading over a patch by Duy that fixes it.\n\nCc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nImproved-by: Johannes Sixt <j6t@kdbg.org>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7006-pager.sh |   26 ++++++++++++++++++++++++++\n 1 files changed, 26 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 4420f91..2b106be 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -259,6 +259,28 @@ test_core_pager_overrides() {\n \t\"\n }\n \n+test_core_pager_subdir() {\n+\tparse_args \"$@\"\n+\n+\t$test_expectation TTY \"$cmd - core.pager from subdirectory\" \"\n+\t\tunset GIT_PAGER;\n+\t\trm -f core.pager_used &&\n+\t\trm -fr sub ||\n+\t\tcleanup_fail &&\n+\n+\t\tPAGER=wc &&\n+\t\tstampname=\\$(pwd)/core.pager_used &&\n+\t\texport PAGER stampname &&\n+\t\tgit config core.pager 'wc >\\\"\\$stampname\\\"' &&\n+\t\tmkdir sub &&\n+\t\t(\n+\t\t\tcd sub &&\n+\t\t\t$full_command\n+\t\t) &&\n+\t\ttest -e core.pager_used\n+\t\"\n+}\n+\n test_GIT_PAGER_overrides() {\n \tparse_args \"$@\"\n \n@@ -277,21 +299,25 @@ test_GIT_PAGER_overrides() {\n test_default_pager        expect_success 'git log'\n test_PAGER_overrides      expect_success 'git log'\n test_core_pager_overrides expect_success 'git log'\n+test_core_pager_subdir    expect_success 'git log'\n test_GIT_PAGER_overrides  expect_success 'git log'\n \n test_default_pager        expect_success 'git -p log'\n test_PAGER_overrides      expect_success 'git -p log'\n test_core_pager_overrides expect_success 'git -p log'\n+test_core_pager_subdir    expect_failure 'git -p log'\n test_GIT_PAGER_overrides  expect_success 'git -p log'\n \n test_default_pager        expect_success test_must_fail 'git -p'\n test_PAGER_overrides      expect_success test_must_fail 'git -p'\n test_core_pager_overrides expect_success test_must_fail 'git -p'\n+test_core_pager_subdir    expect_failure test_must_fail 'git -p'\n test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'\n \n test_default_pager        expect_success test_must_fail 'git -p nonsense'\n test_PAGER_overrides      expect_success test_must_fail 'git -p nonsense'\n test_core_pager_overrides expect_success test_must_fail 'git -p nonsense'\n+test_core_pager_subdir    expect_failure test_must_fail 'git -p nonsense'\n test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.1.579.ge2549\n"},{"id":"144333","messageId":"20100626192637.GD20051@burratino","threadId":"24205","inReplyTo":"20100626192203.GA19973@burratino","subject":"[PATCH 4/4] git --paginate: do not commit pager choice too early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T19:26:37Z","receivedAt":"2010-06-26T19:26:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nWhen git is passed the --paginate option, starting up a pager requires\ndeciding what pager to start, which requires access to the core.pager\nconfiguration.\n\nAt the relevant moment, the repository has not been searched for yet.\nAttempting to access the configuration at this point results in\ngit_dir being set to .git [*], which is almost certainly not what was\nwanted.  In particular, when run from a subdirectory of the toplevel,\ngit --paginate does not respect the core.pager setting from the\ncurrent repository.\n\n[*] unless GIT_DIR or GIT_CONFIG is set\n\nSo delay the pager startup when possible:\n\n1. run_argv() already commits pager choice inside run_builtin() if a\n   command is found.  For commands that use RUN_SETUP, waiting until\n   then fixes the problem described above: once git knows where to\n   look, it happily respects the core.pager setting.\n\n2. list_common_cmds_help() prints out 29 lines and exits.  This can\n   benefit from pagination, so we need to commit the pager choice\n   before writing this output.\n\n   Luckily ‘git’ without subcommand has no other reason to access a\n   repository, so it would be intuitive to ignore repository-local\n   configuration in this case.  Simpler for now to choose a pager\n   using the funny code that notices a repository that happens to be\n   at .git.  That this accesses a repository when it is very\n   convenient to is a bug but not an important one.\n\n3. help_unknown_cmd() prints out a few lines to stderr.  It is not\n   important to paginate this, so don’t.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThanks for reading.\n\n git.c            |    2 +-\n t/t7006-pager.sh |   58 ++++++++++++++++++++++++++++++++++++++++++-----------\n 2 files changed, 47 insertions(+), 13 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 99f0363..25e7693 100644\n--- a/git.c\n+++ b/git.c\n@@ -511,12 +511,12 @@ int main(int argc, const char **argv)\n \targv++;\n \targc--;\n \thandle_options(&argv, &argc, NULL);\n-\tcommit_pager_choice();\n \tif (argc > 0) {\n \t\tif (!prefixcmp(argv[0], \"--\"))\n \t\t\targv[0] += 2;\n \t} else {\n \t\t/* The user didn't specify a command; give them help */\n+\t\tcommit_pager_choice();\n \t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n \t\tlist_common_cmds_help();\n \t\tprintf(\"\\n%s\\n\", git_more_info_string);\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 2b106be..eefef45 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -244,9 +244,21 @@ test_PAGER_overrides() {\n }\n \n test_core_pager_overrides() {\n+\tif_local_config=\n+\tused_if_wanted='overrides PAGER'\n+\ttest_core_pager \"$@\"\n+}\n+\n+test_local_config_ignored() {\n+\tif_local_config='! '\n+\tused_if_wanted='is not used'\n+\ttest_core_pager \"$@\"\n+}\n+\n+test_core_pager() {\n \tparse_args \"$@\"\n \n-\t$test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n+\t$test_expectation TTY \"$cmd - repository-local core.pager setting $used_if_wanted\" \"\n \t\tunset GIT_PAGER;\n \t\trm -f core.pager_used ||\n \t\tcleanup_fail &&\n@@ -255,14 +267,26 @@ test_core_pager_overrides() {\n \t\texport PAGER &&\n \t\tgit config core.pager 'wc >core.pager_used' &&\n \t\t$full_command &&\n-\t\ttest -e core.pager_used\n+\t\t${if_local_config}test -e core.pager_used\n \t\"\n }\n \n test_core_pager_subdir() {\n+\tif_local_config=\n+\tused_if_wanted='overrides PAGER'\n+\ttest_pager_subdir_helper \"$@\"\n+}\n+\n+test_no_local_config_subdir() {\n+\tif_local_config='! '\n+\tused_if_wanted='is not used'\n+\ttest_pager_subdir_helper \"$@\"\n+}\n+\n+test_pager_subdir_helper() {\n \tparse_args \"$@\"\n \n-\t$test_expectation TTY \"$cmd - core.pager from subdirectory\" \"\n+\t$test_expectation TTY \"$cmd - core.pager $used_if_wanted from subdirectory\" \"\n \t\tunset GIT_PAGER;\n \t\trm -f core.pager_used &&\n \t\trm -fr sub ||\n@@ -277,7 +301,7 @@ test_core_pager_subdir() {\n \t\t\tcd sub &&\n \t\t\t$full_command\n \t\t) &&\n-\t\ttest -e core.pager_used\n+\t\t${if_local_config}test -e core.pager_used\n \t\"\n }\n \n@@ -296,6 +320,20 @@ test_GIT_PAGER_overrides() {\n \t\"\n }\n \n+test_doesnt_paginate() {\n+\tparse_args \"$@\"\n+\n+\t$test_expectation TTY \"no pager for '$cmd'\" \"\n+\t\trm -f GIT_PAGER_used ||\n+\t\tcleanup_fail &&\n+\n+\t\tGIT_PAGER='wc >GIT_PAGER_used' &&\n+\t\texport GIT_PAGER &&\n+\t\t$full_command &&\n+\t\t! test -e GIT_PAGER_used\n+\t\"\n+}\n+\n test_default_pager        expect_success 'git log'\n test_PAGER_overrides      expect_success 'git log'\n test_core_pager_overrides expect_success 'git log'\n@@ -305,19 +343,15 @@ test_GIT_PAGER_overrides  expect_success 'git log'\n test_default_pager        expect_success 'git -p log'\n test_PAGER_overrides      expect_success 'git -p log'\n test_core_pager_overrides expect_success 'git -p log'\n-test_core_pager_subdir    expect_failure 'git -p log'\n+test_core_pager_subdir    expect_success 'git -p log'\n test_GIT_PAGER_overrides  expect_success 'git -p log'\n \n test_default_pager        expect_success test_must_fail 'git -p'\n test_PAGER_overrides      expect_success test_must_fail 'git -p'\n-test_core_pager_overrides expect_success test_must_fail 'git -p'\n-test_core_pager_subdir    expect_failure test_must_fail 'git -p'\n+test_local_config_ignored expect_failure test_must_fail 'git -p'\n+test_no_local_config_subdir expect_success test_must_fail 'git -p'\n test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'\n \n-test_default_pager        expect_success test_must_fail 'git -p nonsense'\n-test_PAGER_overrides      expect_success test_must_fail 'git -p nonsense'\n-test_core_pager_overrides expect_success test_must_fail 'git -p nonsense'\n-test_core_pager_subdir    expect_failure test_must_fail 'git -p nonsense'\n-test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p nonsense'\n+test_doesnt_paginate      expect_success test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.1.579.ge2549\n"},{"id":"144334","messageId":"20100626192836.GE20051@burratino","threadId":"24205","inReplyTo":"20100626192450.GB20051@burratino","subject":"Re: [PATCH 2/4] t7006: test pager configuration for several git commands","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-26T19:28:36Z","receivedAt":"2010-06-26T19:28:36Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jonathan Nieder wrote:\n\n> Test choice of pager at several stages of repository setup.\n\nHere it is again, without whitespace changes. :)\n\n t/t7006-pager.sh |   40 ++++++++++++++++++++++++++++++++++++----\n 1 files changed, 36 insertions(+), 4 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex b117ebb..4420f91 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -204,7 +204,9 @@ parse_args() {\n \tfull_command=\"$full_command $1\"\n }\n \n-parse_args expect_success 'git log'\n+test_default_pager() {\n+\tparse_args \"$@\"\n+\n $test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n \tunset PAGER GIT_PAGER;\n \ttest_might_fail git config --unset core.pager &&\n@@ -223,8 +225,11 @@ $test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n \t) &&\n \ttest -e default_pager_used\n \"\n+}\n+\n+test_PAGER_overrides() {\n+\tparse_args \"$@\"\n \n-parse_args expect_success 'git log'\n $test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\n \tunset GIT_PAGER;\n \ttest_might_fail git config --unset core.pager &&\n@@ -236,8 +241,11 @@ $test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\n \t$full_command &&\n \ttest -e PAGER_used\n \"\n+}\n+\n+test_core_pager_overrides() {\n+\tparse_args \"$@\"\n \n-parse_args expect_success 'git log'\n $test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n \tunset GIT_PAGER;\n \trm -f core.pager_used ||\n@@ -249,8 +257,11 @@ $test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n \t$full_command &&\n \ttest -e core.pager_used\n \"\n+}\n+\n+test_GIT_PAGER_overrides() {\n+\tparse_args \"$@\"\n \n-parse_args expect_success 'git log'\n $test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n \trm -f GIT_PAGER_used ||\n \tcleanup_fail &&\n@@ -261,5 +272,26 @@ $test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n \t$full_command &&\n \ttest -e GIT_PAGER_used\n \"\n+}\n+\n+test_default_pager        expect_success 'git log'\n+test_PAGER_overrides      expect_success 'git log'\n+test_core_pager_overrides expect_success 'git log'\n+test_GIT_PAGER_overrides  expect_success 'git log'\n+\n+test_default_pager        expect_success 'git -p log'\n+test_PAGER_overrides      expect_success 'git -p log'\n+test_core_pager_overrides expect_success 'git -p log'\n+test_GIT_PAGER_overrides  expect_success 'git -p log'\n+\n+test_default_pager        expect_success test_must_fail 'git -p'\n+test_PAGER_overrides      expect_success test_must_fail 'git -p'\n+test_core_pager_overrides expect_success test_must_fail 'git -p'\n+test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'\n+\n+test_default_pager        expect_success test_must_fail 'git -p nonsense'\n+test_PAGER_overrides      expect_success test_must_fail 'git -p nonsense'\n+test_core_pager_overrides expect_success test_must_fail 'git -p nonsense'\n+test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.1.579.ge2549\n"},{"id":"144381","messageId":"20100628094033.GA18629@coredump.intra.peff.net","threadId":"24205","inReplyTo":"20100626192203.GA19973@burratino","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-28T09:40:34Z","receivedAt":"2010-06-28T09:40:34Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Sat, Jun 26, 2010 at 02:22:03PM -0500, Jonathan Nieder wrote:\n\n> Here’s a fix from the famous setup cleanup series[1].\n> \n> The problem it fixes is somewhat obscure: ‘git -p foo’ is not paying\n> attention to the repository-local ‘[core] pager’ configuration when\n> run from a subdirectory.  But it is a real bug, and the fix gives\n> an example of how to deal with repository setup and should be safe.\n> \n> Patch is against master.  There is a small semantic conflict with\n> jn/grep-open: SIMPLEPAGER should be changed to SIMPLEPAGERTTY in the\n> prerequisites for the test_default_pager function.  Please let me\n> know if I should push a merge commit to help resolve that.\n\nI just read through the patches, and it seems like a reasonable fix. So\nin that sense, ACK.\n\nBut reading the message for patch 4/4, I can't help but wonder if the\nright way forward is for the git wrapper to _always_ find the repository\nas the very first thing. I.e., make finding the repository a\nnon-destructive thing (especially don't end in a different directory),\nand just do it before we run any other code.\n\nFor a few commands like \"init\" or \"clone\", we would end up just\nignoring this information, but the worst case should be a little bit of\nwasted effort.\n\nAnd then all these silly setup and timing issues could just go away, as\nwe would know that GIT_DIR and GIT_WORK_TREE would be set properly.\n\n-Peff\n"},{"id":"144383","messageId":"20100628101335.GA5007@burratino","threadId":"24205","inReplyTo":"20100628094033.GA18629@coredump.intra.peff.net","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-06-28T10:13:35Z","receivedAt":"2010-06-28T10:13:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Jeff King wrote:\n\n> But reading the message for patch 4/4, I can't help but wonder if the\n> right way forward is for the git wrapper to _always_ find the repository\n> as the very first thing.\n[...]\n> the worst case should be a little bit of\n> wasted effort.\n\nThis is a very useful thought.  Git without the chdir() to toplevel\nwould be pleasanter, I think.  (Yes, I realize you weren’t necessarily\nsuggesting suppressing a chdir_to_toplevel() in place of\nsetup_git_repository() and friends.)\n\nRegarding the repository search: automounters can cause pain if\nDISCOVERY_ACROSS_FILESYSTEM is set and GIT_CEILING_DIRECTORIES is not\nset appropriately.  An important script that does\n\n  tmpdir=$(mktemp -d)\n  cd \"$tmpdir\"\n  ...\n\n  git diff --no-index a b\n  ...\n\ncould hang indefinitely if some nut has created a named pipe at\n/tmp/.git.  I haven’t come up with any non far-fetched reason to mind\nthe repository search, though.\n\nWill think about this.\n"},{"id":"144384","messageId":"20100628102201.GA24817@coredump.intra.peff.net","threadId":"24205","inReplyTo":"20100628101335.GA5007@burratino","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Jeff King","fromEmail":"peff@peff.net","sentAt":"2010-06-28T10:22:01Z","receivedAt":"2010-06-28T10:22:01Z","isPatch":true,"sender":{"key":"peff@peff.net","avatar":"https://avatars.githubusercontent.com/u/45925?v=4"},"body":"On Mon, Jun 28, 2010 at 05:13:35AM -0500, Jonathan Nieder wrote:\n\n> > But reading the message for patch 4/4, I can't help but wonder if the\n> > right way forward is for the git wrapper to _always_ find the repository\n> > as the very first thing.\n> [...]\n> > the worst case should be a little bit of\n> > wasted effort.\n> \n> This is a very useful thought.  Git without the chdir() to toplevel\n> would be pleasanter, I think.  (Yes, I realize you weren’t necessarily\n> suggesting suppressing a chdir_to_toplevel() in place of\n> setup_git_repository() and friends.)\n\nI had just meant that we would not do the chdir() initially, but would\ndo so right before running the actual command which wanted repository\nsetup (and commands like init which do not do that setup would never\nchdir to the toplevel). But we must always run at least aliases and\nexternal sub-commands from the toplevel to keep backwards compatibility.\n\n> Regarding the repository search: automounters can cause pain if\n> DISCOVERY_ACROSS_FILESYSTEM is set and GIT_CEILING_DIRECTORIES is not\n> set appropriately.  An important script that does\n> \n>   tmpdir=$(mktemp -d)\n>   cd \"$tmpdir\"\n>   ...\n> \n>   git diff --no-index a b\n>   ...\n> \n> could hang indefinitely if some nut has created a named pipe at\n> /tmp/.git.  I haven’t come up with any non far-fetched reason to mind\n> the repository search, though.\n> \n> Will think about this.\n\nYeah, I considered that, too. But I doubt it is a big problem. If it\nwere, then just running \"git log\" when you are not in a repository would\nbe similarly painful. The people who have setups like that are already\nhaving to deal with GIT_CEILING_DIRECTORIES to make things less painful\n(though I imagine the new cross-filesystem discovery code will prevent\nmost of the pain without them having to actually do anything).\n\nSo yes, we are adding the extra lookup for commands like \"git clone\",\nbut I suspect in practice nobody will care. If it is a big deal, we can\ndo something like:\n\n  if (!strcmp(cmd, \"clone\") || !strcmp(cmd, \"init\"))\n     ... don't do setup ...\n\nwhich I admit is a terrible hack, but it is an optimization, not a\ncorrectness thing. So we are not shutting out external user-defined\ncommands that might not care about the repo. We are just making our\ncommon built-in ones a bit more efficient.\n\n-Peff\n"},{"id":"144386","messageId":"AANLkTilYQ_n6hQLC8C9qNtKa_-Jz6ec9FXlDL5NXe4Kc@mail.gmail.com","threadId":"24205","inReplyTo":"20100628102201.GA24817@coredump.intra.peff.net","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-06-28T12:45:16Z","receivedAt":"2010-06-28T12:45:16Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/6/28 Jeff King <peff@peff.net>:\n> On Mon, Jun 28, 2010 at 05:13:35AM -0500, Jonathan Nieder wrote:\n>\n>> > But reading the message for patch 4/4, I can't help but wonder if the\n>> > right way forward is for the git wrapper to _always_ find the repository\n>> > as the very first thing.\n>> [...]\n>> > the worst case should be a little bit of\n>> > wasted effort.\n>>\n>> This is a very useful thought.  Git without the chdir() to toplevel\n>> would be pleasanter, I think.  (Yes, I realize you weren’t necessarily\n>> suggesting suppressing a chdir_to_toplevel() in place of\n>> setup_git_repository() and friends.)\n>\n> I had just meant that we would not do the chdir() initially, but would\n> do so right before running the actual command which wanted repository\n> setup (and commands like init which do not do that setup would never\n> chdir to the toplevel). But we must always run at least aliases and\n> external sub-commands from the toplevel to keep backwards compatibility.\n\nI think I'm missing something here. Looking up aliases means\nrepository search must be done in git wrapper anyway. Even if we don't\nhave to do repo search in git wrapper, the very first thing a sub\ncommand does is likely git_config(), which will need repo again. As\nlong as repo search does not have any side effects, everything should\nbe fine, IMO.\n\n> So yes, we are adding the extra lookup for commands like \"git clone\",\n> but I suspect in practice nobody will care. If it is a big deal, we can\n> do something like:\n>\n>  if (!strcmp(cmd, \"clone\") || !strcmp(cmd, \"init\"))\n>     ... don't do setup ...\n>\n\nIf git wrapper does not need setup (i.e. aliases) at all, that should\nhappen without hacks. \"clone\" and \"init\" do not have RUN_SETUP (nor\nRUN_SETUP_GENTLY in my series), so there should not be any setup\nbefore cmd_{init,clone} is run.\n\nPS. I haven't forgotten my cleanup series. Day job has been taking too\nmuch of my energy unfortunately.\n-- \nDuy\n"},{"id":"144439","messageId":"7vpqzacs3h.fsf@alter.siamese.dyndns.org","threadId":"24205","inReplyTo":"20100626192203.GA19973@burratino","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-06-29T05:42:26Z","receivedAt":"2010-06-29T05:42:26Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> Patch is against master.  There is a small semantic conflict with\n> jn/grep-open: SIMPLEPAGER should be changed to SIMPLEPAGERTTY in the\n> prerequisites for the test_default_pager function.  Please let me\n> know if I should push a merge commit to help resolve that.\n\nThanks for advance warning; please double check the merge result in 'pu'\nwhen I push it out...\n"},{"id":"145581","messageId":"7v630hyf5r.fsf@alter.siamese.dyndns.org","threadId":"24205","inReplyTo":"7vpqzacs3h.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-07-14T20:36:16Z","receivedAt":"2010-07-14T20:36:16Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n>\n>> Patch is against master.  There is a small semantic conflict with\n>> jn/grep-open: SIMPLEPAGER should be changed to SIMPLEPAGERTTY in the\n>> prerequisites for the test_default_pager function.  Please let me\n>> know if I should push a merge commit to help resolve that.\n>\n> Thanks for advance warning; please double check the merge result in 'pu'\n> when I push it out...\n\nI hate an enumeration that pretends to be exhausitive but is not.\n\n    So delay the pager startup when possible:\n    \n    1. run_argv() already commits pager choice inside run_builtin() if a\n       command is found.  For commands that use RUN_SETUP, waiting until\n       then fixes the problem described above: once git knows where to\n       look, it happily respects the core.pager setting.\n\n... and for commands that do not use RUN_SETUP, what happens?\n\n    2. list_common_cmds_help() prints out 29 lines and exits....\n    3. help_unknown_cmd() prints out a few lines to stderr.  It is not\n       important to paginate this, so don’t.\n\nMissing from the above enumeration are are external commands.  They depend\non commit_pager_choice() to be called before execv_dashed_external() gets\ncalled.  For example, \"git -p request-pull $args\" no longer works with\nthis patch.\n\nSigh..\n"},{"id":"145585","messageId":"20100714213043.GA1590@burratino","threadId":"24205","inReplyTo":"7v630hyf5r.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-07-14T21:30:43Z","receivedAt":"2010-07-14T21:30:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> ... and for commands that do not use RUN_SETUP, what happens?\n\nrun_builtin() still commits pager choice.  The bug is neither\nfixed nor made worse for them.\n\n> Missing from the above enumeration are are external commands.  They depend\n> on commit_pager_choice() to be called before execv_dashed_external() gets\n> called.  For example, \"git -p request-pull $args\" no longer works with\n> this patch.\n\nSomething like the following may help.\n\nThis does not protect against calling setup_pager() more than\nonce.  Once the first pager has been set up, isatty(1) is false,\npreventing additional pagers from being spawned and competing with it.\n\nAs futureproofing against --paginate=always, setup_pager() should\nprobably be taught to check pager_in_use(), but that should\nprobably wait for a separate patch.\n\ndiff --git a/git.c b/git.c\nindex 25e7693..2dcd952 100644\n--- a/git.c\n+++ b/git.c\n@@ -162,6 +162,7 @@ static int handle_alias(int *argcp, const char ***argv)\n \tint unused_nongit;\n \n \tsubdir = setup_git_directory_gently(&unused_nongit);\n+\tcommit_pager_choice();\n \n \talias_command = (*argv)[0];\n \talias_string = alias_lookup(alias_command);\n@@ -433,6 +434,7 @@ static void execv_dashed_external(const char **argv)\n \tint status;\n \n \tstrbuf_addf(&cmd, \"git-%s\", argv[0]);\n+\tcommit_pager_choice();\n \n \t/*\n \t * argv[0] must be the git command, but the argv array\n-- \n"},{"id":"145588","messageId":"20100714225512.GA13636@burratino","threadId":"24205","inReplyTo":"7v630hyf5r.fsf@alter.siamese.dyndns.org","subject":"[PATCH] git --paginate: paginate external commands again","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-07-14T22:55:12Z","receivedAt":"2010-07-14T22:55:12Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"73e25e7c (git --paginate: do not commit pager choice too early,\n2010-06-26) failed to take some cases into account.\n\n1b. Builtins that do not use RUN_SETUP (like git config) do\n    not find GIT_DIR set correctly when the pager is launched\n    from run_builtin().  So the core.pager configuration is\n    not honored from subdirectories of the toplevel for them.\n\n4a. External git commands (like git request-pull) relied on the\n    early pager launch to take care of handling the -p option.\n    Ever since 73e25e7c, they do not honor the -p option at all.\n\n4b. Commands invoked through ! aliases (like ls) were also relying\n    on the early pager launch.\n\nFix (4a) by launching the pager (if requested) before running such a\n“dashed external”.  For simplicity, this still does not search for a\n.git directory before running the external command; when run from a\nsubdirectory of the toplevel, therefore, the “[core] pager”\nconfiguration is still not honored.\n\nFix (4b) by launching pager if requested before carrying out such an\nalias.  Actually doing this has no effect, since the pager (if any)\nwould have already been launched in a failed attempt to try a\ndashed external first.  The choice-of-pager-not-honored-from-\nsubdirectory bug still applies here, too.\n\n(1b) is not a regression.  There is no need to fix it yet.\n\nNoticed by Junio.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJunio C Hamano wrote:\n\n> I hate an enumeration that pretends to be exhausitive but is not.\n\nSorry about that.\n\nHere’s a patch that could be squashed in or applied on top.\n\n git.c            |    3 +++\n t/t7006-pager.sh |   47 +++++++++++++++++++++++++++++++++++------------\n 2 files changed, 38 insertions(+), 12 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 25e7693..99517dd 100644\n--- a/git.c\n+++ b/git.c\n@@ -167,6 +167,7 @@ static int handle_alias(int *argcp, const char ***argv)\n \talias_string = alias_lookup(alias_command);\n \tif (alias_string) {\n \t\tif (alias_string[0] == '!') {\n+\t\t\tcommit_pager_choice();\n \t\t\tif (*argcp > 1) {\n \t\t\t\tstruct strbuf buf;\n \n@@ -432,6 +433,8 @@ static void execv_dashed_external(const char **argv)\n \tconst char *tmp;\n \tint status;\n \n+\tcommit_pager_choice();\n+\n \tstrbuf_addf(&cmd, \"git-%s\", argv[0]);\n \n \t/*\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex eefef45..9215c2f 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -334,17 +334,40 @@ test_doesnt_paginate() {\n \t\"\n }\n \n-test_default_pager        expect_success 'git log'\n-test_PAGER_overrides      expect_success 'git log'\n-test_core_pager_overrides expect_success 'git log'\n-test_core_pager_subdir    expect_success 'git log'\n-test_GIT_PAGER_overrides  expect_success 'git log'\n-\n-test_default_pager        expect_success 'git -p log'\n-test_PAGER_overrides      expect_success 'git -p log'\n-test_core_pager_overrides expect_success 'git -p log'\n-test_core_pager_subdir    expect_success 'git -p log'\n-test_GIT_PAGER_overrides  expect_success 'git -p log'\n+test_pager_choices() {\n+\ttest_default_pager        expect_success \"$@\"\n+\ttest_PAGER_overrides      expect_success \"$@\"\n+\ttest_core_pager_overrides expect_success \"$@\"\n+\ttest_core_pager_subdir    expect_success \"$@\"\n+\ttest_GIT_PAGER_overrides  expect_success \"$@\"\n+}\n+\n+test_expect_success 'setup: some aliases' '\n+\tgit config alias.aliasedlog log &&\n+\tgit config alias.true \"!true\"\n+'\n+\n+test_pager_choices                       'git log'\n+test_pager_choices                       'git -p log'\n+test_pager_choices                       'git aliasedlog'\n+\n+test_default_pager        expect_success 'git -p aliasedlog'\n+test_PAGER_overrides      expect_success 'git -p aliasedlog'\n+test_core_pager_overrides expect_success 'git -p aliasedlog'\n+test_core_pager_subdir    expect_failure 'git -p aliasedlog'\n+test_GIT_PAGER_overrides  expect_success 'git -p aliasedlog'\n+\n+test_default_pager        expect_success 'git -p true'\n+test_PAGER_overrides      expect_success 'git -p true'\n+test_core_pager_overrides expect_success 'git -p true'\n+test_core_pager_subdir    expect_failure 'git -p true'\n+test_GIT_PAGER_overrides  expect_success 'git -p true'\n+\n+test_default_pager        expect_success test_must_fail 'git -p request-pull'\n+test_PAGER_overrides      expect_success test_must_fail 'git -p request-pull'\n+test_core_pager_overrides expect_success test_must_fail 'git -p request-pull'\n+test_core_pager_subdir    expect_failure test_must_fail 'git -p request-pull'\n+test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p request-pull'\n \n test_default_pager        expect_success test_must_fail 'git -p'\n test_PAGER_overrides      expect_success test_must_fail 'git -p'\n@@ -352,6 +375,6 @@ test_local_config_ignored expect_failure test_must_fail 'git -p'\n test_no_local_config_subdir expect_success test_must_fail 'git -p'\n test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'\n \n-test_doesnt_paginate      expect_success test_must_fail 'git -p nonsense'\n+test_doesnt_paginate      expect_failure test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.2.rc2.532.g65d9b.dirty\n"},{"id":"145747","messageId":"AANLkTim9f_A5OjiXYRK584CrKTG_Lol9oXwguBwwIW19@mail.gmail.com","threadId":"24205","inReplyTo":"7v630hyf5r.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH 0/4] git --paginate: do not commit pager choice too early","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-07-18T12:27:00Z","receivedAt":"2010-07-18T12:27:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/7/15 Junio C Hamano <gitster@pobox.com>:\n> Missing from the above enumeration are are external commands.  They depend\n> on commit_pager_choice() to be called before execv_dashed_external() gets\n> called.  For example, \"git -p request-pull $args\" no longer works with\n> this patch.\n>\n> Sigh..\n\nI'm sorry. I missed those paths..\n-- \nDuy\n"},{"id":"147277","messageId":"20100806023529.GB22369@burratino","threadId":"24205","inReplyTo":"7v630hyf5r.fsf@alter.siamese.dyndns.org","subject":"[PATCH jn/paginate-fix 0/12] Re: git --paginate: do not commit pager choice too early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T02:35:29Z","receivedAt":"2010-08-06T02:35:29Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n>     So delay the pager startup when possible:\n>     \n>     1. run_argv() already commits pager choice inside run_builtin() if a\n>        command is found.  For commands that use RUN_SETUP, waiting until\n>        then fixes the problem described above: once git knows where to\n>        look, it happily respects the core.pager setting.\n> \n> ... and for commands that do not use RUN_SETUP, what happens?\n\nLet’s help some of them out a little.\n\nThese patches teach a few more built-ins to do something like\nRUN_SETUP; more precisely, a RUN_SETUP_GENTLY facility is introduced\nto run setup_git_directory_gently() early just like NEEDS_PREFIX has\nalways caused setup_git_directory() to be run early.\n\nThis series wouldn’t be possible without Duy’s recent efforts to roll\nout other fixes from the famous nd/setup topic --- thanks!\nThe patches should be familiar[1] and I think they are better\njustified now.\n\nThe first 8 patches apply on top to jn/paginate-fix from pu.  Between\npatch 8 and 9 I have a merge of jn/maint-setup-fix^, with the\nfollowing explanation:\n\n\tMerge branch 'jn/maint-setup-fix' (early part) into jn/paginate-fix\n\n\tThat topic includes a fix for “git index-pack” (which used\n\tto save the cwd before the repository search to work around\n\ta bug) which is needed before the repository search can be\n\tsafely run earlier.\n\nThat merge involves a trivial conflict between adding the\nRUN_SETUP_GENTLY flag for this topic and removing USE_PAGER for\ngrep -O.  The conflict is only nominal --- the two changes do not\ninterfere with each other.\n\nOne final note: this series is deliberately very conservative, in that\nit does not touch commands like diff (which has a --no-index mode\nsuppressing the repository search).  Such commands are neither\nhelped nor hindered by this series, and I think that during this\ntransition time we should be opportunistic rather than rigid: the rule\nis to run the repository search as soon as can be easily justified but\nno sooner.\n\nThoughts welcome, as always.\n\nNguyễn Thái Ngọc Duy (12):\n  git wrapper: introduce startup_info struct\n  setup: remember whether repository was found\n  git wrapper: allow setup_git_directory_gently() be called earlier\n  shortlog: run setup_git_directory_gently() sooner\n  grep: run setup_git_directory_gently() sooner\n  apply: run setup_git_directory_gently() sooner\n  bundle: run setup_git_directory_gently() sooner\n  config: run setup_git_directory_gently() sooner\n  index-pack: run setup_git_directory_gently() sooner\n  ls-remote: run setup_git_directory_gently() sooner\n  var: run setup_git_directory_gently() sooner\n  merge-file: run setup_git_directory_gently() sooner\n\n[1] http://thread.gmane.org/gmane.comp.version-control.git/144000/focus=144110\n"},{"id":"147278","messageId":"20100806024034.GC22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 01/12] git wrapper: introduce startup_info struct","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T02:40:35Z","receivedAt":"2010-08-06T02:40:35Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nThe startup_info struct will collect information managed by the git\nsetup code, such as the prefix for relative paths passed on the\ncommand line (i.e., path to the starting cwd from the toplevel of\nthe work tree) and whether a git repository has been found.\n\nIn other words, startup_info is intended to be a collection of global\nvariables with results that were previously returned from setup\nfunctions.  This state is global anyway (since the cwd is), even\nif it is not currently tracked that way.  Letting these values persist\nmeans there is more flexibility in deciding when to run setup.\n\nFor now, the struct is empty.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nChanges from last round:\n - commit message\n - remove unnecessary memset (since statics are already automatically\n   zero-initialized)\n\n cache.h       |    5 +++++\n environment.c |    1 +\n git.c         |    3 +++\n 3 files changed, 9 insertions(+), 0 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex c9fa3df..0822c3b 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1097,6 +1097,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix);\n char *alias_lookup(const char *alias);\n int split_cmdline(char *cmdline, const char ***argv);\n \n+/* git.c */\n+struct startup_info {\n+};\n+extern struct startup_info *startup_info;\n+\n /* builtin/merge.c */\n int checkout_fast_forward(const unsigned char *from, const unsigned char *to);\n \ndiff --git a/environment.c b/environment.c\nindex 83d38d3..eeb2687 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -53,6 +53,7 @@ enum object_creation_mode object_creation_mode = OBJECT_CREATION_MODE;\n char *notes_ref_name;\n int grafts_replace_parents = 1;\n int core_apply_sparse_checkout;\n+struct startup_info *startup_info;\n \n /* Parallel index stat data preload? */\n int core_preload_index = 0;\ndiff --git a/git.c b/git.c\nindex 99517dd..8a8d2b2 100644\n--- a/git.c\n+++ b/git.c\n@@ -14,6 +14,7 @@ const char git_usage_string[] =\n const char git_more_info_string[] =\n \t\"See 'git help COMMAND' for more information on a specific command.\";\n \n+static struct startup_info git_startup_info;\n static int use_pager = -1;\n struct pager_config {\n \tconst char *cmd;\n@@ -489,6 +490,8 @@ int main(int argc, const char **argv)\n {\n \tconst char *cmd;\n \n+\tstartup_info = &git_startup_info;\n+\n \tcmd = git_extract_argv0_path(argv[0]);\n \tif (!cmd)\n \t\tcmd = \"git-help\";\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147279","messageId":"20100806024633.GF22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 02/12] setup: remember whether repository was found","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T02:46:33Z","receivedAt":"2010-08-06T02:46:33Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nAs v1.7.2~16^2 (git --paginate: paginate external commands\nagain, 2010-07-14) explains, builtins (like git config) that\ndo not use RUN_SETUP are not finding GIT_DIR set correctly when\nit is time to launch the pager from run_builtin().  If they\nwere to search for a repository sooner, then the outcome of such\nearly repository accesses would be more predictable and reliable.\n\nThe cmd_*() functions learn whether a repository was found through the\n*nongit_ok return value from setup_git_directory_gently().  If\nrun_builtin() is to take care of the repository search itself, that\ndatum needs to be retrievable from somewhere else.  Use the\nstartup_info struct for this.\n\nAs a bonus, this information becomes available to functions such as\ngit_config() which might want to avoid trying to access a repository\nwhen none is present.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nTweaked the log message a bit.\n\n cache.h |    1 +\n setup.c |   12 +++++++++++-\n 2 files changed, 12 insertions(+), 1 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 0822c3b..f9e82a8 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1099,6 +1099,7 @@ int split_cmdline(char *cmdline, const char ***argv);\n \n /* git.c */\n struct startup_info {\n+\tint have_repository;\n };\n extern struct startup_info *startup_info;\n \ndiff --git a/setup.c b/setup.c\nindex 7e04602..1e32fb7 100644\n--- a/setup.c\n+++ b/setup.c\n@@ -315,7 +315,7 @@ const char *read_gitfile_gently(const char *path)\n  * We cannot decide in this function whether we are in the work tree or\n  * not, since the config can only be read _after_ this function was called.\n  */\n-const char *setup_git_directory_gently(int *nongit_ok)\n+static const char *setup_git_directory_gently_1(int *nongit_ok)\n {\n \tconst char *work_tree_env = getenv(GIT_WORK_TREE_ENVIRONMENT);\n \tconst char *env_ceiling_dirs = getenv(CEILING_DIRECTORIES_ENVIRONMENT);\n@@ -470,6 +470,16 @@ const char *setup_git_directory_gently(int *nongit_ok)\n \treturn cwd + offset;\n }\n \n+const char *setup_git_directory_gently(int *nongit_ok)\n+{\n+\tconst char *prefix;\n+\n+\tprefix = setup_git_directory_gently_1(nongit_ok);\n+\tif (startup_info)\n+\t\tstartup_info->have_repository = !nongit_ok || !*nongit_ok;\n+\treturn prefix;\n+}\n+\n int git_config_perm(const char *var, const char *value)\n {\n \tint i;\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147280","messageId":"20100806025216.GG22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 03/12] git wrapper: allow setup_git_directory_gently() be called earlier","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T02:52:16Z","receivedAt":"2010-08-06T02:52:16Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nIn the spirit of v1.4.2-rc3~34^2^2 (Call setup_git_directory() much\nearlier, 2006-07-28), let run_builtin() take care of searching for a\nrepository for built-ins that want to make use of one if present.\n\nSo now you can mark your command with RUN_SETUP_GENTLY and use\n\n\tnongit = !startup_info->have_repository;\n\nin place of\n\n\tprefix = setup_git_directory_gently(&nongit);\n\nand everything will be the same, except the repository is\ndiscovered a little sooner.\n\nAs v1.7.2~16^2 (2010-07-14) explains, this should allow more commands\nto robustly use features like \"git --paginate\" that look at local\nconfiguration before the command is actually run.\n\nThis patch sets up the infrastructure.  Later patches will teach\nparticular commands to use it.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n - reordered setup option bits (RUN_SETUP_GENTLY lives next to RUN_SETUP now)\n\n - squashed in \"builtin: check pager.<cmd> configuration if\n   RUN_SETUP_GENTLY is used\"\n\n git.c |   13 +++++++++----\n 1 files changed, 9 insertions(+), 4 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 8a8d2b2..c46c996 100644\n--- a/git.c\n+++ b/git.c\n@@ -230,13 +230,14 @@ static int handle_alias(int *argcp, const char ***argv)\n \n const char git_version_string[] = GIT_VERSION;\n \n-#define RUN_SETUP\t(1<<0)\n-#define USE_PAGER\t(1<<1)\n+#define RUN_SETUP\t\t(1<<0)\n+#define RUN_SETUP_GENTLY\t(1<<1)\n+#define USE_PAGER\t\t(1<<2)\n /*\n  * require working tree to be present -- anything uses this needs\n  * RUN_SETUP for reading from the configuration file.\n  */\n-#define NEED_WORK_TREE\t(1<<2)\n+#define NEED_WORK_TREE\t\t(1<<3)\n \n struct cmd_struct {\n \tconst char *cmd;\n@@ -255,8 +256,12 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n \tif (!help) {\n \t\tif (p->option & RUN_SETUP)\n \t\t\tprefix = setup_git_directory();\n+\t\tif (p->option & RUN_SETUP_GENTLY) {\n+\t\t\tint nongit_ok;\n+\t\t\tprefix = setup_git_directory_gently(&nongit_ok);\n+\t\t}\n \n-\t\tif (use_pager == -1 && p->option & RUN_SETUP)\n+\t\tif (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))\n \t\t\tuse_pager = check_pager_config(p->cmd);\n \t\tif (use_pager == -1 && p->option & USE_PAGER)\n \t\t\tuse_pager = 1;\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147281","messageId":"20100806030135.GH22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 04/12] shortlog: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:01:37Z","receivedAt":"2010-08-06T03:01:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nshortlog already runs a repository search unconditionally;\nrunning such a search earlier is not very risky.\n\nWithout this change, the “[pager] shortlog” configuration\nis not respected at all: “git shortlog” unconditionally paginates.\n\nThe tests are a bit slow.  Running the full battery like this\nfor all built-in commands would be counterproductive; the intent is\nrather to test shortlog as a representative example command using\n..._gently().\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nClarified commit message; simplified diff by keeping the nongit\nvariable; added tests.\n\n builtin/shortlog.c |    3 +--\n git.c              |    2 +-\n t/t7006-pager.sh   |    9 +++++++++\n 3 files changed, 11 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/shortlog.c b/builtin/shortlog.c\nindex 5089502..36cb24b 100644\n--- a/builtin/shortlog.c\n+++ b/builtin/shortlog.c\n@@ -249,7 +249,7 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n {\n \tstatic struct shortlog log;\n \tstatic struct rev_info rev;\n-\tint nongit;\n+\tint nongit = !startup_info->have_repository;\n \n \tstatic const struct option options[] = {\n \t\tOPT_BOOLEAN('n', \"numbered\", &log.sort_by_number,\n@@ -265,7 +265,6 @@ int cmd_shortlog(int argc, const char **argv, const char *prefix)\n \n \tstruct parse_opt_ctx_t ctx;\n \n-\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_default_config, NULL);\n \tshortlog_init(&log);\n \tinit_revisions(&rev, prefix);\ndiff --git a/git.c b/git.c\nindex c46c996..b821058 100644\n--- a/git.c\n+++ b/git.c\n@@ -384,7 +384,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"revert\", cmd_revert, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"rm\", cmd_rm, RUN_SETUP },\n \t\t{ \"send-pack\", cmd_send_pack, RUN_SETUP },\n-\t\t{ \"shortlog\", cmd_shortlog, USE_PAGER },\n+\t\t{ \"shortlog\", cmd_shortlog, RUN_SETUP_GENTLY | USE_PAGER },\n \t\t{ \"show-branch\", cmd_show_branch, RUN_SETUP },\n \t\t{ \"show\", cmd_show, RUN_SETUP | USE_PAGER },\n \t\t{ \"status\", cmd_status, RUN_SETUP | NEED_WORK_TREE },\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 9215c2f..084dfdb 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -377,4 +377,13 @@ test_GIT_PAGER_overrides  expect_success test_must_fail 'git -p'\n \n test_doesnt_paginate      expect_failure test_must_fail 'git -p nonsense'\n \n+test_pager_choices                       'git shortlog'\n+test_expect_success 'setup: configure shortlog not to paginate' '\n+\tgit config pager.shortlog false\n+'\n+test_doesnt_paginate      expect_success 'git shortlog'\n+test_no_local_config_subdir expect_success 'git shortlog'\n+test_default_pager        expect_success 'git -p shortlog'\n+test_core_pager_subdir    expect_success 'git -p shortlog'\n+\n test_done\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147282","messageId":"20100806030637.GI22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 05/12] grep: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:06:39Z","receivedAt":"2010-08-06T03:06:39Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\ngit grep already runs a repository search unconditionally,\neven when the --no-index option is supplied; running such a\nsearch earlier is not very risky.\n\nJust like with shortlog, without this change, the\n“[pager] grep” configuration is not respected at all.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nAside from rewriting the commit message and adding tests, this\ndrops the interesting\n\n -\t\t/* die the same way as if we did it at the beginning */\n -\t\tsetup_git_directory();\n +\t\tdie(\"No git repository found\");\n\nhunk.  That change might be a good idea but it does not fit the\ntheme of this chapter.\n\n builtin/grep.c   |    6 ++----\n git.c            |    2 +-\n t/t7006-pager.sh |   13 +++++++++++++\n 3 files changed, 16 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/grep.c b/builtin/grep.c\nindex d0a73da..cd44926 100644\n--- a/builtin/grep.c\n+++ b/builtin/grep.c\n@@ -791,7 +791,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \tconst char **paths = NULL;\n \tint i;\n \tint dummy;\n-\tint nongit = 0, use_index = 1;\n+\tint use_index = 1;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN(0, \"cached\", &cached,\n \t\t\t\"search in index instead of in the work tree\"),\n@@ -879,8 +879,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\tOPT_END()\n \t};\n \n-\tprefix = setup_git_directory_gently(&nongit);\n-\n \t/*\n \t * 'git grep -h', unlike 'git grep -h <pattern>', is a request\n \t * to show usage information and exit.\n@@ -925,7 +923,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix)\n \t\t\t     PARSE_OPT_STOP_AT_NON_OPTION |\n \t\t\t     PARSE_OPT_NO_INTERNAL_HELP);\n \n-\tif (use_index && nongit)\n+\tif (use_index && !startup_info->have_repository)\n \t\t/* die the same way as if we did it at the beginning */\n \t\tsetup_git_directory();\n \ndiff --git a/git.c b/git.c\nindex b821058..0240179 100644\n--- a/git.c\n+++ b/git.c\n@@ -336,7 +336,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"fsck-objects\", cmd_fsck, RUN_SETUP },\n \t\t{ \"gc\", cmd_gc, RUN_SETUP },\n \t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n-\t\t{ \"grep\", cmd_grep, USE_PAGER },\n+\t\t{ \"grep\", cmd_grep, RUN_SETUP_GENTLY | USE_PAGER },\n \t\t{ \"hash-object\", cmd_hash_object },\n \t\t{ \"help\", cmd_help },\n \t\t{ \"index-pack\", cmd_index_pack },\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 084dfdb..fd7f77b 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -105,6 +105,19 @@ test_expect_success TTY 'no pager with --no-pager' '\n \t! test -e paginated.out\n '\n \n+test_expect_success TTY 'configuration can disable pager' '\n+\trm -f paginated.out &&\n+\ttest_might_fail git config --unset pager.grep &&\n+\ttest_terminal git grep initial &&\n+\ttest -e paginated.out &&\n+\n+\trm -f paginated.out &&\n+\tgit config pager.grep false &&\n+\ttest_when_finished \"git config --unset pager.grep\" &&\n+\ttest_terminal git grep initial &&\n+\t! test -e paginated.out\n+'\n+\n # A colored commit log will begin with an appropriate ANSI escape\n # for the first color; the text \"commit\" comes later.\n colorful() {\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147283","messageId":"20100806030844.GJ22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 06/12] apply: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:08:45Z","receivedAt":"2010-08-06T03:08:45Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nAs v1.7.2~16^2 (2010-07-14) explains, without this change,\n“git --paginate apply” can ignore the repository-local\n“[core] pager” configuration.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nNew explanation and test; simplified patch by keeping the\nis_not_gitdir local.\n\n builtin/apply.c  |    3 +--\n git.c            |    2 +-\n t/t7006-pager.sh |    3 +++\n 3 files changed, 5 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 562e534..08f3586 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -3611,7 +3611,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n {\n \tint i;\n \tint errs = 0;\n-\tint is_not_gitdir;\n+\tint is_not_gitdir = !startup_info->have_repository;\n \tint binary;\n \tint force_apply = 0;\n \n@@ -3684,7 +3684,6 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n \t\tOPT_END()\n \t};\n \n-\tprefix = setup_git_directory_gently(&is_not_gitdir);\n \tprefix_length = prefix ? strlen(prefix) : 0;\n \tgit_config(git_apply_config, NULL);\n \tif (apply_default_whitespace)\ndiff --git a/git.c b/git.c\nindex 0240179..82b390b 100644\n--- a/git.c\n+++ b/git.c\n@@ -301,7 +301,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"add\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"stage\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n-\t\t{ \"apply\", cmd_apply },\n+\t\t{ \"apply\", cmd_apply, RUN_SETUP_GENTLY },\n \t\t{ \"archive\", cmd_archive },\n \t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex fd7f77b..96fbb0f 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -399,4 +399,7 @@ test_no_local_config_subdir expect_success 'git shortlog'\n test_default_pager        expect_success 'git -p shortlog'\n test_core_pager_subdir    expect_success 'git -p shortlog'\n \n+test_core_pager_subdir    expect_success test_must_fail \\\n+                                         'git -p apply </dev/null'\n+\n test_done\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147284","messageId":"20100806031204.GK22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 07/12] bundle: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:12:46Z","receivedAt":"2010-08-06T03:12:46Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nWithout this change, “git -p bundle” does not always\nrespect the repository-local “[core] pager” setting.\n\nIt is hard to notice because subcommands other than\n“git bundle unbundle” do not produce much output.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nNew tests and explanation.\n\nThe first new test perhaps deserves some explanation.  Its\nonly purpose is to let us use the \n\n\ttest -e paginated.out || test -e subdir/paginated.out\n\nhedge in other tests with good conscience.\n\n builtin/bundle.c |    6 ++----\n git.c            |    2 +-\n t/t7006-pager.sh |   33 +++++++++++++++++++++++++++++++++\n 3 files changed, 36 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/bundle.c b/builtin/bundle.c\nindex 2006cc5..80649ba 100644\n--- a/builtin/bundle.c\n+++ b/builtin/bundle.c\n@@ -18,7 +18,6 @@ static const char builtin_bundle_usage[] =\n int cmd_bundle(int argc, const char **argv, const char *prefix)\n {\n \tstruct bundle_header header;\n-\tint nongit;\n \tconst char *cmd, *bundle_file;\n \tint bundle_fd = -1;\n \tchar buffer[PATH_MAX];\n@@ -31,7 +30,6 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)\n \targc -= 2;\n \targv += 2;\n \n-\tprefix = setup_git_directory_gently(&nongit);\n \tif (prefix && bundle_file[0] != '/') {\n \t\tsnprintf(buffer, sizeof(buffer), \"%s/%s\", prefix, bundle_file);\n \t\tbundle_file = buffer;\n@@ -54,11 +52,11 @@ int cmd_bundle(int argc, const char **argv, const char *prefix)\n \t\treturn !!list_bundle_refs(&header, argc, argv);\n \t}\n \tif (!strcmp(cmd, \"create\")) {\n-\t\tif (nongit)\n+\t\tif (!startup_info->have_repository)\n \t\t\tdie(\"Need a repository to create a bundle.\");\n \t\treturn !!create_bundle(&header, bundle_file, argc, argv);\n \t} else if (!strcmp(cmd, \"unbundle\")) {\n-\t\tif (nongit)\n+\t\tif (!startup_info->have_repository)\n \t\t\tdie(\"Need a repository to unbundle.\");\n \t\treturn !!unbundle(&header, bundle_fd) ||\n \t\t\tlist_bundle_refs(&header, argc, argv);\ndiff --git a/git.c b/git.c\nindex 82b390b..94bb1e3 100644\n--- a/git.c\n+++ b/git.c\n@@ -306,7 +306,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\n \t\t{ \"branch\", cmd_branch, RUN_SETUP },\n-\t\t{ \"bundle\", cmd_bundle },\n+\t\t{ \"bundle\", cmd_bundle, RUN_SETUP_GENTLY },\n \t\t{ \"cat-file\", cmd_cat_file, RUN_SETUP },\n \t\t{ \"checkout\", cmd_checkout, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"checkout-index\", cmd_checkout_index,\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 96fbb0f..6680668 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -57,6 +57,21 @@ test_expect_success TTY 'some commands use a pager' '\n \ttest -e paginated.out\n '\n \n+test_expect_failure TTY 'pager runs from subdir' '\n+\techo subdir/paginated.out >expected &&\n+\tmkdir -p subdir &&\n+\trm -f paginated.out subdir/paginated.out &&\n+\t(\n+\t\tcd subdir &&\n+\t\ttest_terminal git log\n+\t) &&\n+\t{\n+\t\tls paginated.out subdir/paginated.out ||\n+\t\t:\n+\t} >actual &&\n+\ttest_cmp expected actual\n+'\n+\n test_expect_success TTY 'some commands do not use a pager' '\n \trm -f paginated.out ||\n \tcleanup_fail &&\n@@ -118,6 +133,24 @@ test_expect_success TTY 'configuration can disable pager' '\n \t! test -e paginated.out\n '\n \n+test_expect_success 'configuration can enable pager (from subdir)' '\n+\trm -f paginated.out &&\n+\tmkdir -p subdir &&\n+\tgit config pager.bundle true &&\n+\ttest_when_finished \"git config --unset pager.bundle\" &&\n+\n+\tgit bundle create test.bundle --all &&\n+\trm -f paginated.out subdir/paginated.out &&\n+\t(\n+\t\tcd subdir &&\n+\t\ttest_terminal git bundle unbundle ../test.bundle\n+\t) &&\n+\t{\n+\t\ttest -e paginated.out ||\n+\t\ttest -e subdir/paginated.out\n+\t}\n+'\n+\n # A colored commit log will begin with an appropriate ANSI escape\n # for the first color; the text \"commit\" comes later.\n colorful() {\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147285","messageId":"20100806031509.GL22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 08/12] config: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:15:09Z","receivedAt":"2010-08-06T03:15:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nFor the pager choice (and the choice to paginate) to reflect the\ncurrent repository configuration, the repository needs to be\nlocated first.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nRelative to the previous round, this simplifies the patch by retaining\nthe nongit var; squashes in a test; and adds some words of explanation\nto the log message.\n\n builtin/config.c |    5 ++---\n git.c            |    4 ++--\n t/t7006-pager.sh |    8 ++++++++\n 3 files changed, 12 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex f3d1660..3f8ef91 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -330,11 +330,10 @@ static int get_colorbool(int print)\n \t\treturn get_colorbool_found ? 0 : 1;\n }\n \n-int cmd_config(int argc, const char **argv, const char *unused_prefix)\n+int cmd_config(int argc, const char **argv, const char *prefix)\n {\n-\tint nongit;\n+\tint nongit = !startup_info->have_repository;\n \tchar *value;\n-\tconst char *prefix = setup_git_directory_gently(&nongit);\n \n \tconfig_exclusive_filename = getenv(CONFIG_ENVIRONMENT);\n \ndiff --git a/git.c b/git.c\nindex 94bb1e3..f57003d 100644\n--- a/git.c\n+++ b/git.c\n@@ -319,7 +319,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"clean\", cmd_clean, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"commit\", cmd_commit, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"commit-tree\", cmd_commit_tree, RUN_SETUP },\n-\t\t{ \"config\", cmd_config },\n+\t\t{ \"config\", cmd_config, RUN_SETUP_GENTLY },\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@@ -376,7 +376,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"reflog\", cmd_reflog, RUN_SETUP },\n \t\t{ \"remote\", cmd_remote, RUN_SETUP },\n \t\t{ \"replace\", cmd_replace, RUN_SETUP },\n-\t\t{ \"repo-config\", cmd_config },\n+\t\t{ \"repo-config\", cmd_config, RUN_SETUP_GENTLY },\n \t\t{ \"rerere\", cmd_rerere, RUN_SETUP },\n \t\t{ \"reset\", cmd_reset, RUN_SETUP },\n \t\t{ \"rev-list\", cmd_rev_list, RUN_SETUP },\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 6680668..dbbe8d9 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -133,6 +133,14 @@ test_expect_success TTY 'configuration can disable pager' '\n \t! test -e paginated.out\n '\n \n+test_expect_success 'git config uses a pager if configured to' '\n+\trm -f paginated.out &&\n+\tgit config pager.config true &&\n+\ttest_when_finished \"git config --unset pager.config\" &&\n+\ttest_terminal git config --list &&\n+\ttest -e paginated.out\n+'\n+\n test_expect_success 'configuration can enable pager (from subdir)' '\n \trm -f paginated.out &&\n \tmkdir -p subdir &&\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147286","messageId":"20100806031853.GM22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 09/12] index-pack: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:18:53Z","receivedAt":"2010-08-06T03:18:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nindex-pack already runs a repository search unconditionally; running\nsuch a search earlier is not risky and ensures GIT_DIR will be set\ncorrectly if the configuration needs to be accessed from\nrun_builtin().\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nRequires the jn/maint-setup-fix topic to apply.  See the cover\nletter \"[PATCH jn/paginate-fix 0/12] Re: ...\" for more on that.\n\nJust like last round, except for the new log message.\n\n builtin/index-pack.c |    2 --\n git.c                |    2 +-\n 2 files changed, 1 insertions(+), 3 deletions(-)\n\ndiff --git a/builtin/index-pack.c b/builtin/index-pack.c\nindex 89a1f12..e852890 100644\n--- a/builtin/index-pack.c\n+++ b/builtin/index-pack.c\n@@ -880,12 +880,10 @@ int cmd_index_pack(int argc, const char **argv, const char *prefix)\n \tchar *index_name_buf = NULL, *keep_name_buf = NULL;\n \tstruct pack_idx_entry **idx_objects;\n \tunsigned char pack_sha1[20];\n-\tint nongit;\n \n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage(index_pack_usage);\n \n-\tprefix = setup_git_directory_gently(&nongit);\n \tgit_config(git_index_pack_config, NULL);\n \tif (prefix && chdir(prefix))\n \t\tdie(\"Cannot come back to cwd\");\ndiff --git a/git.c b/git.c\nindex e89c010..92ec5d3 100644\n--- a/git.c\n+++ b/git.c\n@@ -339,7 +339,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"grep\", cmd_grep, RUN_SETUP_GENTLY },\n \t\t{ \"hash-object\", cmd_hash_object },\n \t\t{ \"help\", cmd_help },\n-\t\t{ \"index-pack\", cmd_index_pack },\n+\t\t{ \"index-pack\", cmd_index_pack, RUN_SETUP_GENTLY },\n \t\t{ \"init\", cmd_init_db },\n \t\t{ \"init-db\", cmd_init_db },\n \t\t{ \"log\", cmd_log, RUN_SETUP | USE_PAGER },\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147287","messageId":"20100806032007.GN22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 10/12] ls-remote: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:20:08Z","receivedAt":"2010-08-06T03:20:08Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nls-remote already runs a repository search unconditionally to learn\nabout remote nicknames and \"[url] insteadof\" shortcuts.  Run that\nsearch a little sooner, and now one can try\n\n\t[pager]\n\t\tls-remote\n\nto automatically paginate ls-remote output, or use repository-local\n\n\t[core]\n\t\tpager = whatever\n\nwith \"git --paginate ls-remote <url>\".\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nAs before, aside from the commit message.\n\n builtin/ls-remote.c |    3 ---\n git.c               |    4 ++--\n 2 files changed, 2 insertions(+), 5 deletions(-)\n\ndiff --git a/builtin/ls-remote.c b/builtin/ls-remote.c\nindex 34480cf..97eed40 100644\n--- a/builtin/ls-remote.c\n+++ b/builtin/ls-remote.c\n@@ -32,7 +32,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n {\n \tint i;\n \tconst char *dest = NULL;\n-\tint nongit;\n \tunsigned flags = 0;\n \tint quiet = 0;\n \tconst char *uploadpack = NULL;\n@@ -42,8 +41,6 @@ int cmd_ls_remote(int argc, const char **argv, const char *prefix)\n \tstruct transport *transport;\n \tconst struct ref *ref;\n \n-\tsetup_git_directory_gently(&nongit);\n-\n \tfor (i = 1; i < argc; i++) {\n \t\tconst char *arg = argv[i];\n \ndiff --git a/git.c b/git.c\nindex 92ec5d3..63630e7 100644\n--- a/git.c\n+++ b/git.c\n@@ -345,7 +345,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"log\", cmd_log, RUN_SETUP | USE_PAGER },\n \t\t{ \"ls-files\", cmd_ls_files, RUN_SETUP },\n \t\t{ \"ls-tree\", cmd_ls_tree, RUN_SETUP },\n-\t\t{ \"ls-remote\", cmd_ls_remote },\n+\t\t{ \"ls-remote\", cmd_ls_remote, RUN_SETUP_GENTLY },\n \t\t{ \"mailinfo\", cmd_mailinfo },\n \t\t{ \"mailsplit\", cmd_mailsplit },\n \t\t{ \"merge\", cmd_merge, RUN_SETUP | NEED_WORK_TREE },\n@@ -366,7 +366,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"pack-objects\", cmd_pack_objects, RUN_SETUP },\n \t\t{ \"pack-redundant\", cmd_pack_redundant, RUN_SETUP },\n \t\t{ \"patch-id\", cmd_patch_id },\n-\t\t{ \"peek-remote\", cmd_ls_remote },\n+\t\t{ \"peek-remote\", cmd_ls_remote, RUN_SETUP_GENTLY },\n \t\t{ \"pickaxe\", cmd_blame, RUN_SETUP },\n \t\t{ \"prune\", cmd_prune, RUN_SETUP },\n \t\t{ \"prune-packed\", cmd_prune_packed, RUN_SETUP },\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147288","messageId":"20100806032139.GO22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 11/12] var: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:21:40Z","receivedAt":"2010-08-06T03:21:40Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nPart of a campaign to make repository-local configuration\navailable early (simplifying the startup sequence for\nbuilt-in commands).\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nsnuck in a little vertical compression while at it ;-)\n\n builtin/var.c |    9 ++-------\n git.c         |    2 +-\n 2 files changed, 3 insertions(+), 8 deletions(-)\n\ndiff --git a/builtin/var.c b/builtin/var.c\nindex 70fdb4d..0744bb8 100644\n--- a/builtin/var.c\n+++ b/builtin/var.c\n@@ -74,14 +74,9 @@ static int show_config(const char *var, const char *value, void *cb)\n \n int cmd_var(int argc, const char **argv, const char *prefix)\n {\n-\tconst char *val;\n-\tint nongit;\n-\tif (argc != 2) {\n+\tconst char *val = NULL;\n+\tif (argc != 2)\n \t\tusage(var_usage);\n-\t}\n-\n-\tsetup_git_directory_gently(&nongit);\n-\tval = NULL;\n \n \tif (strcmp(argv[1], \"-l\") == 0) {\n \t\tgit_config(show_config, NULL);\ndiff --git a/git.c b/git.c\nindex 63630e7..84bef76 100644\n--- a/git.c\n+++ b/git.c\n@@ -398,7 +398,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"update-ref\", cmd_update_ref, RUN_SETUP },\n \t\t{ \"update-server-info\", cmd_update_server_info, RUN_SETUP },\n \t\t{ \"upload-archive\", cmd_upload_archive },\n-\t\t{ \"var\", cmd_var },\n+\t\t{ \"var\", cmd_var, RUN_SETUP_GENTLY },\n \t\t{ \"verify-tag\", cmd_verify_tag, RUN_SETUP },\n \t\t{ \"version\", cmd_version },\n \t\t{ \"whatchanged\", cmd_whatchanged, RUN_SETUP | USE_PAGER },\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147290","messageId":"20100806032742.GP22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH 12/12] merge-file: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:27:43Z","receivedAt":"2010-08-06T03:27:43Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n\nPart of a campaign to make repository-local configuration\navailable early (simplifying the startup sequence for\nbuilt-in commands).\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nAs before (except the commit message).\n\nWell, that’s it.  There’s also a separate fix for\n\"check-ref-format --branch\", which I’ll send under separate\ncover.\n\nStill to be considered are various commands that currently\ndo not do an unconditional repository search, especially\nlow-level commands that are not about the current repository:\nverify-pack, mailinfo, hash-object, archive --remote,\ncheck-ref-format, diff --no-index, help, and all the others.\nLet’s bite off one thing at a time. :)\n\nThanks for reading; I hope the patches were not too dull.\nThoughts (especially improvements) welcome, as always.\n\n builtin/merge-file.c |    4 +---\n git.c                |    2 +-\n 2 files changed, 2 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/merge-file.c b/builtin/merge-file.c\nindex b8e9e5b..b6664d4 100644\n--- a/builtin/merge-file.c\n+++ b/builtin/merge-file.c\n@@ -28,7 +28,6 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \txmparam_t xmp = {{0}};\n \tint ret = 0, i = 0, to_stdout = 0;\n \tint quiet = 0;\n-\tint nongit;\n \tstruct option options[] = {\n \t\tOPT_BOOLEAN('p', \"stdout\", &to_stdout, \"send results to standard output\"),\n \t\tOPT_SET_INT(0, \"diff3\", &xmp.style, \"use a diff3 based merge\", XDL_MERGE_DIFF3),\n@@ -50,8 +49,7 @@ int cmd_merge_file(int argc, const char **argv, const char *prefix)\n \txmp.style = 0;\n \txmp.favor = 0;\n \n-\tprefix = setup_git_directory_gently(&nongit);\n-\tif (!nongit) {\n+\tif (startup_info->have_repository) {\n \t\t/* Read the configuration file */\n \t\tgit_config(git_xmerge_config, NULL);\n \t\tif (0 <= git_xmerge_style)\ndiff --git a/git.c b/git.c\nindex 84bef76..5433875 100644\n--- a/git.c\n+++ b/git.c\n@@ -350,7 +350,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"mailsplit\", cmd_mailsplit },\n \t\t{ \"merge\", cmd_merge, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"merge-base\", cmd_merge_base, RUN_SETUP },\n-\t\t{ \"merge-file\", cmd_merge_file },\n+\t\t{ \"merge-file\", cmd_merge_file, RUN_SETUP_GENTLY },\n \t\t{ \"merge-index\", cmd_merge_index, RUN_SETUP },\n \t\t{ \"merge-ours\", cmd_merge_ours, RUN_SETUP },\n \t\t{ \"merge-recursive\", cmd_merge_recursive, RUN_SETUP | NEED_WORK_TREE },\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147291","messageId":"20100806033411.GQ22369@burratino","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"[PATCH master 0/2] fix \"check-ref-format --branch\" from subdir of toplevel","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:34:11Z","receivedAt":"2010-08-06T03:34:11Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Here’s a quick fix from the nd/setup series.  Tested against master,\nthough it probably should be against maint.\n\nJonathan Nieder (2):\n  check-ref-format: split off functions for subcommands\n  check-ref-format --branch: run repository search\n\n builtin/check-ref-format.c  |   44 ++++++++++++++++++++++++++----------------\n t/t1402-check-ref-format.sh |   17 ++++++++++++++++\n 2 files changed, 44 insertions(+), 17 deletions(-)\n"},{"id":"147292","messageId":"20100806033606.GR22369@burratino","threadId":"24205","inReplyTo":"20100806033411.GQ22369@burratino","subject":"[PATCH 1/2] check-ref-format: handle subcommands in separate functions","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:36:07Z","receivedAt":"2010-08-06T03:36:07Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The code for each subcommand should be easier to read and manipulate\nthis way.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n builtin/check-ref-format.c |   42 +++++++++++++++++++++++++-----------------\n 1 files changed, 25 insertions(+), 17 deletions(-)\n\ndiff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c\nindex b106c65..8707ee9 100644\n--- a/builtin/check-ref-format.c\n+++ b/builtin/check-ref-format.c\n@@ -33,28 +33,36 @@ static void collapse_slashes(char *dst, const char *src)\n \t*dst = '\\0';\n }\n \n+static int check_ref_format_branch(const char *arg)\n+{\n+\tstruct strbuf sb = STRBUF_INIT;\n+\n+\tif (strbuf_check_branch_ref(&sb, arg))\n+\t\tdie(\"'%s' is not a valid branch name\", arg);\n+\tprintf(\"%s\\n\", sb.buf + 11);\n+\treturn 0;\n+}\n+\n+static int check_ref_format_print(const char *arg)\n+{\n+\tchar *refname = xmalloc(strlen(arg) + 1);\n+\n+\tif (check_ref_format(arg))\n+\t\treturn 1;\n+\tcollapse_slashes(refname, arg);\n+\tprintf(\"%s\\n\", refname);\n+\treturn 0;\n+}\n+\n int cmd_check_ref_format(int argc, const char **argv, const char *prefix)\n {\n \tif (argc == 2 && !strcmp(argv[1], \"-h\"))\n \t\tusage(builtin_check_ref_format_usage);\n \n-\tif (argc == 3 && !strcmp(argv[1], \"--branch\")) {\n-\t\tstruct strbuf sb = STRBUF_INIT;\n-\n-\t\tif (strbuf_check_branch_ref(&sb, argv[2]))\n-\t\t\tdie(\"'%s' is not a valid branch name\", argv[2]);\n-\t\tprintf(\"%s\\n\", sb.buf + 11);\n-\t\texit(0);\n-\t}\n-\tif (argc == 3 && !strcmp(argv[1], \"--print\")) {\n-\t\tchar *refname = xmalloc(strlen(argv[2]) + 1);\n-\n-\t\tif (check_ref_format(argv[2]))\n-\t\t\texit(1);\n-\t\tcollapse_slashes(refname, argv[2]);\n-\t\tprintf(\"%s\\n\", refname);\n-\t\texit(0);\n-\t}\n+\tif (argc == 3 && !strcmp(argv[1], \"--branch\"))\n+\t\treturn check_ref_format_branch(argv[2]);\n+\tif (argc == 3 && !strcmp(argv[1], \"--print\"))\n+\t\treturn check_ref_format_print(argv[2]);\n \tif (argc != 2)\n \t\tusage(builtin_check_ref_format_usage);\n \treturn !!check_ref_format(argv[1]);\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147293","messageId":"20100806033922.GS22369@burratino","threadId":"24205","inReplyTo":"20100806033411.GQ22369@burratino","subject":"[PATCH 2/2] Allow \"check-ref-format --branch\" from subdirectory","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-06T03:39:22Z","receivedAt":"2010-08-06T03:39:22Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"check-ref-format --branch requires access to the repository\nto resolve refs like @{-1}.\n\nNoticed by Duy.\n\nCc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThe original used the RUN_SETUP_GENTLY flag to run setup\nunconditionally.  That might still be a good idea, but I am\nmore comfortable running setup just for this subcommand\nfor now so commands like \"git check-ref-format refs/foo\" are not\naffected.\n\n builtin/check-ref-format.c  |    2 ++\n t/t1402-check-ref-format.sh |   17 +++++++++++++++++\n 2 files changed, 19 insertions(+), 0 deletions(-)\n\ndiff --git a/builtin/check-ref-format.c b/builtin/check-ref-format.c\nindex 8707ee9..ae3f281 100644\n--- a/builtin/check-ref-format.c\n+++ b/builtin/check-ref-format.c\n@@ -36,7 +36,9 @@ static void collapse_slashes(char *dst, const char *src)\n static int check_ref_format_branch(const char *arg)\n {\n \tstruct strbuf sb = STRBUF_INIT;\n+\tint nongit;\n \n+\tsetup_git_directory_gently(&nongit);\n \tif (strbuf_check_branch_ref(&sb, arg))\n \t\tdie(\"'%s' is not a valid branch name\", arg);\n \tprintf(\"%s\\n\", sb.buf + 11);\ndiff --git a/t/t1402-check-ref-format.sh b/t/t1402-check-ref-format.sh\nindex eb45afb..782e75d 100755\n--- a/t/t1402-check-ref-format.sh\n+++ b/t/t1402-check-ref-format.sh\n@@ -41,6 +41,23 @@ test_expect_success \"check-ref-format --branch @{-1}\" '\n \trefname2=$(git check-ref-format --branch @{-2}) &&\n \ttest \"$refname2\" = master'\n \n+test_expect_success 'check-ref-format --branch from subdir' '\n+\tmkdir subdir &&\n+\n+\tT=$(git write-tree) &&\n+\tsha1=$(echo A | git commit-tree $T) &&\n+\tgit update-ref refs/heads/master $sha1 &&\n+\tgit update-ref refs/remotes/origin/master $sha1\n+\tgit checkout master &&\n+\tgit checkout origin/master &&\n+\tgit checkout master &&\n+\trefname=$(\n+\t\tcd subdir &&\n+\t\tgit check-ref-format --branch @{-1}\n+\t) &&\n+\ttest \"$refname\" = \"$sha1\"\n+'\n+\n valid_ref_normalized() {\n \ttest_expect_success \"ref name '$1' simplifies to '$2'\" \"\n \t\trefname=\\$(git check-ref-format --print '$1') &&\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"147295","messageId":"AANLkTincgypcb3Bq8KpFXv9guBO+xQKJ-TkuGEpk9W62@mail.gmail.com","threadId":"24205","inReplyTo":"20100806023529.GB22369@burratino","subject":"Re: [PATCH jn/paginate-fix 0/12] Re: git --paginate: do not commit pager choice too early","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-06T04:26:52Z","receivedAt":"2010-08-06T04:26:52Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/8/6 Jonathan Nieder <jrnieder@gmail.com>:\n> Nguyễn Thái Ngọc Duy (12):\n>  git wrapper: introduce startup_info struct\n>  setup: remember whether repository was found\n>  git wrapper: allow setup_git_directory_gently() be called earlier\n>  shortlog: run setup_git_directory_gently() sooner\n>  grep: run setup_git_directory_gently() sooner\n>  apply: run setup_git_directory_gently() sooner\n>  bundle: run setup_git_directory_gently() sooner\n>  config: run setup_git_directory_gently() sooner\n>  index-pack: run setup_git_directory_gently() sooner\n>  ls-remote: run setup_git_directory_gently() sooner\n>  var: run setup_git_directory_gently() sooner\n>  merge-file: run setup_git_directory_gently() sooner\n>\n> [1] http://thread.gmane.org/gmane.comp.version-control.git/144000/focus=144110\n>\n\nI was waiting for jn/maint-setup-fix to graduate before pushing out\nsome more patches then I got side tracked by the subtree clone.\nAnyway, thanks!\n-- \nDuy\n"},{"id":"147337","messageId":"7v8w4j8r5d.fsf@alter.siamese.dyndns.org","threadId":"24205","inReplyTo":"20100806033922.GS22369@burratino","subject":"Re: [PATCH 2/2] Allow \"check-ref-format --branch\" from subdirectory","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-06T19:42:06Z","receivedAt":"2010-08-06T19:42:06Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> check-ref-format --branch requires access to the repository\n> to resolve refs like @{-1}.\n\nThanks; the patch makes sense to me.\n"},{"id":"148147","messageId":"AANLkTi=pAvJ=R9XVvo9fJqo6RPa+hn3dMfj2UGqTFCbU@mail.gmail.com","threadId":"24205","inReplyTo":"20100806030844.GJ22369@burratino","subject":"Re: [PATCH 06/12] apply: run setup_git_directory_gently() sooner","fromName":"Ævar Arnfjörð Bjarmason","fromEmail":"avarab@gmail.com","sentAt":"2010-08-15T20:13:26Z","receivedAt":"2010-08-15T20:13:26Z","isPatch":true,"sender":{"key":"avarab@gmail.com","avatar":"https://avatars.githubusercontent.com/u/45301?v=4"},"body":"2010/8/6 Jonathan Nieder <jrnieder@gmail.com>:\n> From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>\n> As v1.7.2~16^2 (2010-07-14) explains, without this change,\n> “git --paginate apply” can ignore the repository-local\n> “[core] pager” configuration.\n\nApplying this patch broke the following tests:\n\n    ./t4119-apply-config.sh ./t4111-apply-subdir.sh\n./t4131-apply-fake-ancestor.sh\n\nI didn't look into why, they're breaking in pu now at 6ea3604. I\ndidn't look into why, see the smoke report at\nhttp://smoke.git.nix.is/app/projects/report_details/33\n"},{"id":"148154","messageId":"AANLkTim6E8JFyjM=gdhbobm4sOskCJyHvT5oGj9fhoAd@mail.gmail.com","threadId":"24205","inReplyTo":"AANLkTi=pAvJ=R9XVvo9fJqo6RPa+hn3dMfj2UGqTFCbU@mail.gmail.com","subject":"Re: [PATCH 06/12] apply: run setup_git_directory_gently() sooner","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-15T22:34:51Z","receivedAt":"2010-08-15T22:34:51Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Mon, Aug 16, 2010 at 6:13 AM, Ævar Arnfjörð Bjarmason\n<avarab@gmail.com> wrote:\n> 2010/8/6 Jonathan Nieder <jrnieder@gmail.com>:\n>> From: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n>>\n>> As v1.7.2~16^2 (2010-07-14) explains, without this change,\n>> “git --paginate apply” can ignore the repository-local\n>> “[core] pager” configuration.\n>\n> Applying this patch broke the following tests:\n>\n>    ./t4119-apply-config.sh ./t4111-apply-subdir.sh\n> ./t4131-apply-fake-ancestor.sh\n>\n> I didn't look into why, they're breaking in pu now at 6ea3604. I\n> didn't look into why, see the smoke report at\n> http://smoke.git.nix.is/app/projects/report_details/33\n\nThe patch loses prefix and git-apply couldn't find files on disk. This\npatch may fix it. I'm running tests now.\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 6c4b747..29f4194 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -3779,7 +3779,7 @@ static int option_parse_directory(const struct\noption *opt,\n \treturn 0;\n }\n\n-int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n+int cmd_apply(int argc, const char **argv, const char *prefix_)\n {\n \tint i;\n \tint errs = 0;\n@@ -3856,6 +3856,7 @@ int cmd_apply(int argc, const char **argv, const\nchar *unused_prefix)\n \t\tOPT_END()\n \t};\n\n+\tprefix = prefix_;\n \tprefix_length = prefix ? strlen(prefix) : 0;\n \tgit_config(git_apply_config, NULL);\n \tif (apply_default_whitespace)\n-- \nDuy\n"},{"id":"148156","messageId":"20100815231154.GA3296@burratino","threadId":"24205","inReplyTo":"AANLkTim6E8JFyjM=gdhbobm4sOskCJyHvT5oGj9fhoAd@mail.gmail.com","subject":"Re: [PATCH 06/12] apply: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-15T23:11:54Z","receivedAt":"2010-08-15T23:11:54Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> The patch loses prefix and git-apply couldn't find files on disk. This\n> patch may fix it. I'm running tests now.\n\nOh, good catch.  Thanks!\n\n> diff --git a/builtin/apply.c b/builtin/apply.c\n> index 6c4b747..29f4194 100644\n> --- a/builtin/apply.c\n> +++ b/builtin/apply.c\n> @@ -3779,7 +3779,7 @@ static int option_parse_directory(const struct\n> option *opt,\n>  \treturn 0;\n>  }\n> \n> -int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n> +int cmd_apply(int argc, const char **argv, const char *prefix_)\n>  {\n>  \tint i;\n>  \tint errs = 0;\n> @@ -3856,6 +3856,7 @@ int cmd_apply(int argc, const char **argv, const\n> char *unused_prefix)\n>  \t\tOPT_END()\n>  \t};\n> \n> +\tprefix = prefix_;\n\nThis is why we shouldn’t be using globals so cavalierly. :)\n"},{"id":"148162","messageId":"1281918972-27207-1-git-send-email-pclouds@gmail.com","threadId":"24205","inReplyTo":"20100806030844.GJ22369@burratino","subject":"[PATCH 06/12 v2] apply: run setup_git_directory_gently() sooner","fromName":"Nguyễn Thái Ngọc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-08-16T00:36:12Z","receivedAt":"2010-08-16T00:36:12Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"As v1.7.2~16^2 (2010-07-14) explains, without this change,\n“git --paginate apply” can ignore the repository-local\n“[core] pager” configuration.\n\nSigned-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n This is a replacement for 4ce097c (apply: run\n setup_git_directory_gently() sooner) in pu, branch jn/paginate-fix,\n which fixes prefix loss in 4ce097c.\n\n All tests seem to run ok for me.\n\n builtin/apply.c  |    6 +++---\n git.c            |    2 +-\n t/t7006-pager.sh |    3 +++\n 3 files changed, 7 insertions(+), 4 deletions(-)\n\ndiff --git a/builtin/apply.c b/builtin/apply.c\nindex 12ef9ea..f005ba1 100644\n--- a/builtin/apply.c\n+++ b/builtin/apply.c\n@@ -3607,11 +3607,11 @@ static int option_parse_directory(const struct option *opt,\n \treturn 0;\n }\n \n-int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n+int cmd_apply(int argc, const char **argv, const char *prefix_)\n {\n \tint i;\n \tint errs = 0;\n-\tint is_not_gitdir;\n+\tint is_not_gitdir = !startup_info->have_repository;\n \tint binary;\n \tint force_apply = 0;\n \n@@ -3684,7 +3684,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)\n \t\tOPT_END()\n \t};\n \n-\tprefix = setup_git_directory_gently(&is_not_gitdir);\n+\tprefix = prefix_;\n \tprefix_length = prefix ? strlen(prefix) : 0;\n \tgit_config(git_apply_config, NULL);\n \tif (apply_default_whitespace)\ndiff --git a/git.c b/git.c\nindex 5a47bfb..38dbe70 100644\n--- a/git.c\n+++ b/git.c\n@@ -301,7 +301,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"add\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"stage\", cmd_add, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"annotate\", cmd_annotate, RUN_SETUP },\n-\t\t{ \"apply\", cmd_apply },\n+\t\t{ \"apply\", cmd_apply, RUN_SETUP_GENTLY },\n \t\t{ \"archive\", cmd_archive },\n \t\t{ \"bisect--helper\", cmd_bisect__helper, RUN_SETUP | NEED_WORK_TREE },\n \t\t{ \"blame\", cmd_blame, RUN_SETUP },\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex bb95335..6c86d70 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -391,4 +391,7 @@ test_no_local_config_subdir expect_success 'git shortlog'\n test_default_pager        expect_success 'git -p shortlog'\n test_core_pager_subdir    expect_success 'git -p shortlog'\n \n+test_core_pager_subdir    expect_success test_must_fail \\\n+\t\t\t\t\t 'git -p apply </dev/null'\n+\n test_done\n-- \n1.7.1.rc1.69.g24c2f7\n"},{"id":"148175","messageId":"7vhbivdy54.fsf@alter.siamese.dyndns.org","threadId":"24205","inReplyTo":"1281918972-27207-1-git-send-email-pclouds@gmail.com","subject":"Re: [PATCH 06/12 v2] apply: run setup_git_directory_gently() sooner","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-16T03:39:19Z","receivedAt":"2010-08-16T03:39:19Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Nguyễn Thái Ngọc Duy  <pclouds@gmail.com> writes:\n\n> As v1.7.2~16^2 (2010-07-14) explains, without this change,\n> “git --paginate apply” can ignore the repository-local\n> “[core] pager” configuration.\n>\n> Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> Signed-off-by: Junio C Hamano <gitster@pobox.com>\n> ---\n>  This is a replacement for 4ce097c (apply: run\n>  setup_git_directory_gently() sooner) in pu, branch jn/paginate-fix,\n>  which fixes prefix loss in 4ce097c.\n\nThanks for a quick fix.\n"},{"id":"148180","messageId":"201008160921.33198.trast@student.ethz.ch","threadId":"24205","inReplyTo":"20100806031204.GK22369@burratino","subject":"Re: [PATCH 07/12] bundle: run setup_git_directory_gently() sooner","fromName":"Thomas Rast","fromEmail":"trast@student.ethz.ch","sentAt":"2010-08-16T07:21:32Z","receivedAt":"2010-08-16T07:21:32Z","isPatch":true,"sender":{"key":"tr@thomasrast.ch","avatar":"https://avatars.githubusercontent.com/u/153510?v=4"},"body":"Jonathan Nieder wrote:\n>  builtin/bundle.c |    6 ++----\n>  git.c            |    2 +-\n>  t/t7006-pager.sh |   33 +++++++++++++++++++++++++++++++++\n>  3 files changed, 36 insertions(+), 5 deletions(-)\n[...]\n> +test_expect_success 'configuration can enable pager (from subdir)' '\n> +\trm -f paginated.out &&\n> +\tmkdir -p subdir &&\n> +\tgit config pager.bundle true &&\n> +\ttest_when_finished \"git config --unset pager.bundle\" &&\n> +\n> +\tgit bundle create test.bundle --all &&\n> +\trm -f paginated.out subdir/paginated.out &&\n> +\t(\n> +\t\tcd subdir &&\n> +\t\ttest_terminal git bundle unbundle ../test.bundle\n> +\t) &&\n> +\t{\n> +\t\ttest -e paginated.out ||\n> +\t\ttest -e subdir/paginated.out\n> +\t}\n> +'\n> +\n>  # A colored commit log will begin with an appropriate ANSI escape\n>  # for the first color; the text \"commit\" comes later.\n>  colorful() {\n\nOn my valgrind test setup, this never worked (i.e., fails and bisects\nto this commit).\n\nOddly, I am seeing this error message from the second test (second in\nt7006, not in this patch):\n\n  expecting success: \n          rm -f stdout_is_tty ||\n          cleanup_fail &&\n\n          if test -t 1\n          then\n                  >stdout_is_tty\n          elif\n                  test_have_prereq PERL &&\n                  \"$PERL_PATH\" \"$TEST_DIRECTORY\"/t7006/test-terminal.perl \\\n                          sh -c \"test -t 1\"\n          then\n                  >test_terminal_works\n          fi\n\n  Can't locate IO/Pty.pm in @INC (@INC contains: <snip>) at /local/home/trast/git/t/t7006/test-terminal.perl line 4.\n  BEGIN failed--compilation aborted at /local/home/trast/git/t/t7006/test-terminal.perl line 4.\n  ok 2 - set up terminal for tests\n\nWhich raises a few questions: Why was this never an issue before?  Am\nI supposed to have IO::Pty with a perl install (it's a perl 5.8.8) or\ndoes the test need a prerequisite other than HAVE_PERL?4\n\n-- \nThomas Rast\ntrast@{inf,student}.ethz.ch\n"},{"id":"148181","messageId":"20100816080709.GA17566@burratino","threadId":"24205","inReplyTo":"201008160921.33198.trast@student.ethz.ch","subject":"Re: [PATCH 07/12] bundle: run setup_git_directory_gently() sooner","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-16T08:07:09Z","receivedAt":"2010-08-16T08:07:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"On Mon, Aug 16, 2010 at 09:21:32AM +0200, Thomas Rast wrote:\n> Jonathan Nieder wrote:\n\n>> +test_expect_success 'configuration can enable pager (from subdir)' '\n[...]\n>> +\t\ttest_terminal git bundle unbundle ../test.bundle\n[...]\n> On my valgrind test setup, this never worked (i.e., fails and bisects\n> to this commit).\n\nAgh, sloppy me...  Fixes below.\n\n> Oddly, I am seeing this error message from the second test (second in\n> t7006, not in this patch):\n[...]\n>   Can't locate IO/Pty.pm in @INC (@INC contains: <snip>) at /local/home/trast/git/t/t7006/test-terminal.perl line 4.\n>   BEGIN failed--compilation aborted at /local/home/trast/git/t/t7006/test-terminal.perl line 4.\n>   ok 2 - set up terminal for tests\n> \n> Which raises a few questions: Why was this never an issue before?\n\nThat’s expected behavior, marked with “ok”. :)  That test is checking\nif IO::Pty is available and works; if not, the relevant tests should\nbe skipped.\n\n> does the test need a prerequisite other than HAVE_PERL?4\n\nExactly.\n\nJonathan Nieder (2):\n  t7006 (pager): add missing TTY prerequisite\n  t7006 (pager): add missing TTY prerequisite\n\n t/t7006-pager.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n"},{"id":"148182","messageId":"20100816081126.GC17566@burratino","threadId":"24205","inReplyTo":"20100816080709.GA17566@burratino","subject":"[PATCH 2/2] t7006 (pager): add missing TTY prerequisite","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-08-16T08:11:26Z","receivedAt":"2010-08-16T08:11:26Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"The config pagination test should not run if there is not a tty\navailable to force pagination on.\n\nReported-by: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nThis one fixes for “config: run setup_git_directory_gently()\nsooner”.\n\nThanks again for the report.  I’ll think more about how to make\nproblems like this easily reproducible (a test_mentions_prereq()\nfunction?).\n\n t/t7006-pager.sh |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex fcd846a..fb744e3 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -134,7 +134,7 @@ test_expect_success TTY 'configuration can disable pager' '\n \t! test -e paginated.out\n '\n \n-test_expect_success 'git config uses a pager if configured to' '\n+test_expect_success TTY 'git config uses a pager if configured to' '\n \trm -f paginated.out &&\n \tgit config pager.config true &&\n \ttest_when_finished \"git config --unset pager.config\" &&\n-- \n1.7.2.1.544.ga752d.dirty\n"},{"id":"148190","messageId":"7vd3ticxwz.fsf@alter.siamese.dyndns.org","threadId":"24205","inReplyTo":"20100816081126.GC17566@burratino","subject":"Re: [PATCH 2/2] t7006 (pager): add missing TTY prerequisite","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-08-16T16:41:48Z","receivedAt":"2010-08-16T16:41:48Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jonathan Nieder <jrnieder@gmail.com> writes:\n\n> The config pagination test should not run if there is not a tty\n> available to force pagination on.\n>\n> Reported-by: Thomas Rast <trast@student.ethz.ch>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n> This one fixes for “config: run setup_git_directory_gently()\n> sooner”.\n\nSomehow we didn't seem to have got 1/2, but here is what I'll queue.\n\nBy the way, could you stop using those \"pretty quotes\" and stick to the\ngood old \"ASCII 0x22\" double-quotes?  I find them ugly in the git log\noutput.\n\n-- >8 --\nFrom: Jonathan Nieder <jrnieder@gmail.com>\nDate: Mon, 16 Aug 2010 03:08:34 -0500\nSubject: [PATCH] t7006 (pager): add missing TTY prerequisites\n\nThe \"git bundle unbundle\" and \"git config\" pagination tests are not\nsupposed to run when stdout is not a terminal and IO::Pty not available\nto make one on the fly.\n\nReported-by: Thomas Rast <trast@student.ethz.ch>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nSigned-off-by: Junio C Hamano <gitster@pobox.com>\n---\n t/t7006-pager.sh |    4 ++--\n 1 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 017565f..fb744e3 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -134,7 +134,7 @@ test_expect_success TTY 'configuration can disable pager' '\n \t! test -e paginated.out\n '\n \n-test_expect_success 'git config uses a pager if configured to' '\n+test_expect_success TTY 'git config uses a pager if configured to' '\n \trm -f paginated.out &&\n \tgit config pager.config true &&\n \ttest_when_finished \"git config --unset pager.config\" &&\n@@ -142,7 +142,7 @@ test_expect_success 'git config uses a pager if configured to' '\n \ttest -e paginated.out\n '\n \n-test_expect_success 'configuration can enable pager (from subdir)' '\n+test_expect_success TTY 'configuration can enable pager (from subdir)' '\n \trm -f paginated.out &&\n \tmkdir -p subdir &&\n \tgit config pager.bundle true &&\n-- \n1.7.2.1.224.g2f41ea\n"}]}