{"thread":{"id":"23437","subject":"[PATCH/RFC 0/9] Setup cleanup, chapter one","startedAt":"2010-04-13T02:11:54Z","lastAt":"2010-04-15T17:43:49Z","messageCount":30,"participants":["Jonathan Nieder","Nguyen Thai Ngoc Duy","Johannes Sixt","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":9},"messages":[{"id":"139381","messageId":"20100413021153.GA3978@progeny.tock","threadId":"23437","inReplyTo":null,"subject":"[PATCH/RFC 0/9] Setup cleanup, chapter one","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:11:54Z","receivedAt":"2010-04-13T02:11:54Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"These patches are designed to make people who want the pager.<cmd>\nconfiguration to be more reliable a little happier.  More importantly,\nthey bring the setup procedure closer to doing the Right Thing™.\n\nMore precisely:\n\nThe pager configuration procedure does not always do as much as one\nwould like:\n\nA. Unless one runs check_pager_config() first, the pager.<cmd>\n   configuration is ignored.  The setup procedure does not run\n   check_pager_config() for commands that do not use RUN_SETUP.\n\nB. Unless one runs setup_repository_gently() first, functions that\n   check configuration expect to find configuration in ./.git/config.\n   This is wrong for two reasons: some commands should ignore the\n   per-repository configuration, and most commands should be walking\n   parent parent directories to find an appropriate .git or foo.git\n   dir.  The upshot is that the per-repository configuration is\n   ignored for pager.<cmd> and core.pager when git is run from the\n   toplevel of a repository.\n\nThese patches are a modest attempt to start to ameliorate these\nproblems.  Patches 1, 2, and 4 introduce new tests to make sure\nwe are not making things worse.\n\nPatch 3 delays startup of the pager.  By the time we actually need\nto start a pager for commands with the RUN_SETUP option, the .git\ndirectory will already have been found, addressing problem (B) for\nthose commands.\n\nPatches 5 and 6 are something of a trojan horse: they introduce\ninfrastructure that I expect to be more widely useful after this\nmodest patch series.  That infrastructure is a collection of global\nvariables representing the state of the current repository, for\nbuilt-in commands only (for now).  The main benefit now is that it\nlets us pass more data to builtins without changing the builtin API.\n\nPatches 7 gives builtins the option to search for a repository\nearly even if they do not require a repository to work.  The benefits\nof patch 3 will accrue to such commands just as though they used\nRUN_SETUP.  Patch 8 addresses problem (A) for builtins using this new\nRUN_SETUP_GENTLY option.\n\nAnd patch 9 is an example command taking advantage of the opportunity.\nI don’t imagine anyone was eagerly awaiting the ability to make their\n‘git config’ automatically paginate.  The secondary benefits\n(especially UI consistency) are in my opinion more important.\n\nThis series would not be possible without the hard work of Nguyễn Thái\nNgọc Duy.  It consists mostly of patches by him.  A footnote [1] contains\nsome context if you would like it.\n\nThoughts?\n\nJonathan Nieder (4):\n  t7006: GIT_DIR/config should be honored in subdirs of toplevel\n  t7006: test pager configuration for several git commands\n  t7006: test pager.<cmd> configuration\n  builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used\n\nNguyễn Thái Ngọc Duy (5):\n  builtins: do not commit pager choice early\n  builtin: introduce startup_info struct\n  builtin: remember whether repository was found\n  builtin: Support RUN_SETUP_GENTLY to set up repository early if found\n  config: run setup before commiting pager choice\n\n builtin/config.c |    6 +-\n cache.h          |    6 ++\n environment.c    |    1 +\n git.c            |   23 +++++--\n setup.c          |   12 ++++-\n t/t7006-pager.sh |  168 +++++++++++++++++++++++++++++++++++++++++-------------\n 6 files changed, 165 insertions(+), 51 deletions(-)\n\n[1] I warned that something like this was coming at\n<http://thread.gmane.org/gmane.comp.version-control.git/144090>.\n\nI will send a rebased version of the rest of the nd/setup series to\nthe list as a follow-up.  But beware: after perhaps introducing all\nkinds of bugs through repeated rebasing, I didn’t give the later\npatches of the series another glance.\n"},{"id":"139382","messageId":"20100413021355.GA4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 1/9] t7006: GIT_DIR/config should be honored in subdirs of toplevel","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:13:56Z","receivedAt":"2010-04-13T02:13:56Z","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\nrequires deciding what pager to start, which requires access to the\ncore.pager configuration.\n\nUnfortunately, the --paginate option is handled before git has a\nchance to search for a git directory.  The effect is that with\n--paginate and only with --paginate, a repository-local core.pager\nsetting does not take effect [*].\n\n[*] unless the git directory is simply .git in the cwd or GIT_DIR\nor GIT_CONFIG was set explicitly.\n\nAdd a test to demonstrate this counterintuitive behavior.\n\nNoticed while reading over a patch by Nguyễn Thái Ngọc Duy that\nfixes it.\n\nCc: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7006-pager.sh |   32 ++++++++++++++++++++++++++++++++\n 1 files changed, 32 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex d9202d5..4f804ed 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -164,6 +164,38 @@ test_expect_success TTY 'core.pager overrides PAGER' '\n \ttest -e core.pager_used\n '\n \n+unset GIT_PAGER\n+rm -f core.pager_used\n+rm -fr sub\n+test_expect_success TTY 'core.pager in subdir' '\n+\tPAGER=wc &&\n+\tstampname=$(pwd)/core.pager_used &&\n+\texport PAGER stampname &&\n+\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n+\tmkdir sub &&\n+\t(\n+\t\tcd sub &&\n+\t\ttest_terminal git log\n+\t) &&\n+\ttest -e \"$stampname\"\n+'\n+\n+unset GIT_PAGER\n+rm -f core.pager_used\n+rm -fr sub\n+test_expect_failure TTY 'core.pager in subdir with --paginate' '\n+\tPAGER=wc &&\n+\tstampname=$(pwd)/core.pager_used &&\n+\texport PAGER stampname &&\n+\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n+\tmkdir sub &&\n+\t(\n+\t\tcd sub &&\n+\t\ttest_terminal git --paginate log\n+\t) &&\n+\ttest -e \"$stampname\"\n+'\n+\n rm -f GIT_PAGER_used\n test_expect_success TTY 'GIT_PAGER overrides core.pager' '\n \tgit config core.pager wc &&\n-- \n1.7.0.4\n"},{"id":"139383","messageId":"20100413021734.GB4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 2/9] t7006: test pager configuration for several git commands","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:17:35Z","receivedAt":"2010-04-13T02:17:35Z","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\nway we can have some (admittedly uninteresting) examples in mind when\nconsidering future changes to the setup procedure.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7006-pager.sh |  151 ++++++++++++++++++++++++++++-------------------------\n 1 files changed, 80 insertions(+), 71 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 4f804ed..403c260 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -131,78 +131,87 @@ then\n \ttest_set_prereq SIMPLEPAGER\n fi\n \n-unset PAGER GIT_PAGER\n-git config --unset core.pager\n-rm -f default_pager_used\n-test_expect_success SIMPLEPAGER 'default pager is used by default' '\n-\tcat > $less <<-EOF &&\n-\t#!$SHELL_PATH\n-\twc > default_pager_used\n-\tEOF\n-\tchmod +x $less &&\n-\tPATH=.:$PATH test_terminal git log &&\n-\ttest -e default_pager_used\n-'\n-\n-unset GIT_PAGER\n-git config --unset core.pager\n-rm -f PAGER_used\n-test_expect_success TTY 'PAGER overrides default pager' '\n-\tPAGER=\"wc > PAGER_used\" &&\n-\texport PAGER &&\n-\ttest_terminal git log &&\n-\ttest -e PAGER_used\n-'\n-\n-unset GIT_PAGER\n-rm -f core.pager_used\n-test_expect_success TTY 'core.pager overrides PAGER' '\n-\tPAGER=wc &&\n-\texport PAGER &&\n-\tgit config core.pager \"wc > core.pager_used\" &&\n-\ttest_terminal git log &&\n-\ttest -e core.pager_used\n-'\n-\n-unset GIT_PAGER\n-rm -f core.pager_used\n-rm -fr sub\n-test_expect_success TTY 'core.pager in subdir' '\n-\tPAGER=wc &&\n-\tstampname=$(pwd)/core.pager_used &&\n-\texport PAGER stampname &&\n-\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n-\tmkdir sub &&\n-\t(\n-\t\tcd sub &&\n-\t\ttest_terminal git log\n-\t) &&\n-\ttest -e \"$stampname\"\n-'\n+test_pager_choice() {\n+\tif test $# = 1\n+\tthen\n+\t\tcmd=$1\n+\t\tfull_cmd=\"test_terminal $cmd\"\n+\telse\n+\t\tcmd=$2\n+\t\tfull_cmd=\"test_must_fail test_terminal $cmd\"\n+\tfi\n \n-unset GIT_PAGER\n-rm -f core.pager_used\n-rm -fr sub\n-test_expect_failure TTY 'core.pager in subdir with --paginate' '\n-\tPAGER=wc &&\n-\tstampname=$(pwd)/core.pager_used &&\n-\texport PAGER stampname &&\n-\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n-\tmkdir sub &&\n-\t(\n-\t\tcd sub &&\n-\t\ttest_terminal git --paginate log\n-\t) &&\n-\ttest -e \"$stampname\"\n-'\n+\tcase \"$cmd\" in\n+\t*-p*)\n+\t\ttest_expect_expected=test_expect_failure\n+\t\t;;\n+\t*)\n+\t\ttest_expect_expected=test_expect_success\n+\t\t;;\n+\tesac\n+\n+\tunset PAGER GIT_PAGER\n+\tgit config --unset core.pager\n+\trm -f default_pager_used\n+\ttest_expect_success SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n+\t\tcat > $less <<-\\EOF &&\n+\t\t#!$SHELL_PATH\n+\t\twc > default_pager_used\n+\t\tEOF\n+\t\tchmod +x $less &&\n+\t\tPATH=.:\\$PATH $full_cmd &&\n+\t\ttest -e default_pager_used\n+\t\"\n+\n+\tunset GIT_PAGER\n+\tgit config --unset core.pager\n+\trm -f PAGER_used\n+\ttest_expect_success TTY \"$cmd - PAGER overrides default pager\" \"\n+\t\tPAGER='wc > PAGER_used' &&\n+\t\texport PAGER &&\n+\t\t$full_cmd &&\n+\t\ttest -e PAGER_used\n+\t\"\n+\n+\tunset GIT_PAGER\n+\trm -f core.pager_used\n+\ttest_expect_success TTY \"$cmd - core.pager overrides PAGER\" \"\n+\t\tPAGER=wc &&\n+\t\texport PAGER &&\n+\t\tgit config core.pager 'wc > core.pager_used' &&\n+\t\t$full_cmd &&\n+\t\ttest -e core.pager_used\n+\t\"\n+\n+\tunset GIT_PAGER\n+\trm -f core.pager_used\n+\trm -fr sub\n+\t$test_expect_expected TTY \"$cmd - core.pager in subdir\" \"\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_cmd\n+\t\t) &&\n+\t\ttest -e \\\"\\$stampname\\\"\n+\t\"\n+\n+\trm -f GIT_PAGER_used\n+\ttest_expect_success TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n+\t\tgit config core.pager wc &&\n+\t\tGIT_PAGER='wc > GIT_PAGER_used' &&\n+\t\texport GIT_PAGER &&\n+\t\t$full_cmd &&\n+\t\ttest -e GIT_PAGER_used\n+\t\"\n+}\n \n-rm -f GIT_PAGER_used\n-test_expect_success TTY 'GIT_PAGER overrides core.pager' '\n-\tgit config core.pager wc &&\n-\tGIT_PAGER=\"wc > GIT_PAGER_used\" &&\n-\texport GIT_PAGER &&\n-\ttest_terminal git log &&\n-\ttest -e GIT_PAGER_used\n-'\n+test_pager_choice 'git log'\n+test_pager_choice 'git -p log'\n+test_pager_choice test_must_fail 'git -p'\n+test_pager_choice test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.0.4\n"},{"id":"139384","messageId":"20100413022420.GC4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 3/9] builtins: do not commit pager choice early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:24:20Z","receivedAt":"2010-04-13T02:24:20Z","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\nIf git is passed the --paginate option, committing the pager choice\nwill require setting up a pager, which requires access to repository\nfor the core.pager configuration.\n\nAfter handle_options() is called, the repository has not been searched\nfor yet.  Unless GIT_DIR or GIT_CONFIG is set, attempting to access\nthe configuration at this point results in git_dir being set to .git,\nwhich is almost certainly not what was wanted.  If a git command is\nrun from a subdirectory of the toplevel directory of a git repository\nand the --paginate option is supplied, the core.pager setting from\nthat repository is not being respected.\n\nThere are several possible code paths after handle_options() and\ncommit_pager_choice() are called:\n\n1. list_common_cmds_help() is a printout of 29 lines.  This can\n   benefit from pagination, so do commit the pager choice before\n   writing this output.\n\n   Since ‘git’ without subcommand has no other reason to access the\n   repository, ideally this would not involve accessing the\n   repository-specific configuration file.  But for now, it is simpler\n   to commit the pager choice using the funny code that would notice\n   whatever repository happens to be at .git.  That this accesses a\n   repository if it happens to be very convenient to is a bug but not\n   a very important one.\n\n2. run_argv() already commits pager choice inside run_builtin() if a\n   command is found.  If the relevant git subcommand searches for a\n   git directory, not commiting to a pager before then means the\n   core.pager setting from the correct $GIT_DIR/config will be\n   respected.\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---\nDuy’s version did not allow paginating list_common_cmds_help() output.\nI have an idea for fixing the setup procedure for that later, but one\nthing at a time.  In other words, this is analogous to a lock pushdown\nin a way: the immediate goal is not to eliminate problems but to reduce\ntheir scope.\n\n git.c            |    2 +-\n t/t7006-pager.sh |   65 +++++++++++++++++++++++++++++++++++++----------------\n 2 files changed, 46 insertions(+), 21 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 6bae305..32720e5 100644\n--- a/git.c\n+++ b/git.c\n@@ -502,12 +502,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 403c260..944e830 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -132,23 +132,28 @@ then\n fi\n \n test_pager_choice() {\n-\tif test $# = 1\n+\twrapper=test_terminal\n+\n+\tif test \"$1\" = test_must_fail\n \tthen\n-\t\tcmd=$1\n-\t\tfull_cmd=\"test_terminal $cmd\"\n-\telse\n-\t\tcmd=$2\n-\t\tfull_cmd=\"test_must_fail test_terminal $cmd\"\n+\t\twrapper=\"test_must_fail $wrapper\"\n+\t\tshift\n \tfi\n \n-\tcase \"$cmd\" in\n-\t*-p*)\n-\t\ttest_expect_expected=test_expect_failure\n-\t\t;;\n-\t*)\n-\t\ttest_expect_expected=test_expect_success\n-\t\t;;\n-\tesac\n+\tcmd=$1\n+\ttoplevel_expectation=${2:-success}\n+\tuse_repository_config=\"${3:-yes}\"\n+\n+\tfull_cmd=\"$wrapper $cmd\"\n+\ttest_expectation=\"test_expect_$toplevel_expectation\"\n+\tif test \"$use_repository_config\" = no\n+\tthen\n+\t\tif_want_local_config='! '\n+\t\tused_if_wanted='is not used'\n+\telse\n+\t\tif_want_local_config=\n+\t\tused_if_wanted='overrides PAGER'\n+\tfi\n \n \tunset PAGER GIT_PAGER\n \tgit config --unset core.pager\n@@ -175,18 +180,18 @@ test_pager_choice() {\n \n \tunset GIT_PAGER\n \trm -f core.pager_used\n-\ttest_expect_success TTY \"$cmd - core.pager overrides PAGER\" \"\n+\t$test_expectation TTY \"$cmd - core.pager ${used_if_wanted}\" \"\n \t\tPAGER=wc &&\n \t\texport PAGER &&\n \t\tgit config core.pager 'wc > core.pager_used' &&\n \t\t$full_cmd &&\n-\t\ttest -e core.pager_used\n+\t\t${if_want_local_config}test -e core.pager_used\n \t\"\n \n \tunset GIT_PAGER\n \trm -f core.pager_used\n \trm -fr sub\n-\t$test_expect_expected TTY \"$cmd - core.pager in subdir\" \"\n+\ttest_expect_success TTY \"$cmd - core.pager ${used_if_wanted} from subdirectory\" \"\n \t\tPAGER=wc &&\n \t\tstampname=\\$(pwd)/core.pager_used &&\n \t\texport PAGER stampname &&\n@@ -196,7 +201,7 @@ test_pager_choice() {\n \t\t\tcd sub &&\n \t\t\t$full_cmd\n \t\t) &&\n-\t\ttest -e \\\"\\$stampname\\\"\n+\t\t${if_want_local_config}test -e \\\"\\$stampname\\\"\n \t\"\n \n \trm -f GIT_PAGER_used\n@@ -209,9 +214,29 @@ test_pager_choice() {\n \t\"\n }\n \n+doesnt_paginate() {\n+\tif test $# = 1\n+\tthen\n+\t\tcmd=$1\n+\t\tfull_cmd=\"test_terminal $cmd\"\n+\telse\n+\t\tcmd=$2\n+\t\tfull_cmd=\"test_must_fail test_terminal $cmd\"\n+\tfi\n+\n+\trm -f GIT_PAGER_used\n+\ttest_expect_success TTY \"no pager for '$cmd'\" \"\n+\t\tGIT_PAGER='wc > GIT_PAGER_used' &&\n+\t\texport GIT_PAGER\n+\t\t$full_cmd &&\n+\t\t! test -e GIT_PAGER_used\n+\t\"\n+}\n+\n test_pager_choice 'git log'\n test_pager_choice 'git -p log'\n-test_pager_choice test_must_fail 'git -p'\n-test_pager_choice test_must_fail 'git -p nonsense'\n+test_pager_choice test_must_fail 'git -p' failure no\n+\n+doesnt_paginate test_must_fail 'git -p nonsense'\n \n test_done\n-- \n1.7.0.4\n"},{"id":"139385","messageId":"20100413022505.GD4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 4/9] t7006: test pager.<cmd> configuration","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:25:05Z","receivedAt":"2010-04-13T02:25:05Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n t/t7006-pager.sh |   20 ++++++++++++++++++++\n 1 files changed, 20 insertions(+), 0 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 944e830..237a689 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -71,6 +71,22 @@ test_expect_success TTY 'git --paginate rev-list uses a pager' '\n \ttest -e paginated.out\n '\n \n+rm -f paginated.out\n+test_expect_success TTY 'git rev-list uses a pager if configured to' '\n+\tgit config pager.rev-list true &&\n+\ttest_terminal git rev-list HEAD &&\n+\ttest -e paginated.out\n+'\n+git config --unset pager.rev-list\n+\n+rm -f paginated.out\n+test_expect_failure TTY 'git config uses a pager if configured to' '\n+\tgit config pager.config true &&\n+\ttest_terminal git config --list &&\n+\ttest -e paginated.out\n+'\n+git --no-pager config --unset pager.config\n+\n rm -f file paginated.out\n test_expect_success 'no pager even with --paginate when stdout is a pipe' '\n \tgit --paginate log | cat &&\n@@ -239,4 +255,8 @@ test_pager_choice test_must_fail 'git -p' failure no\n \n doesnt_paginate test_must_fail 'git -p nonsense'\n \n+doesnt_paginate 'git rev-list HEAD'\n+git config pager.rev-list true\n+test_pager_choice 'git rev-list HEAD'\n+\n test_done\n-- \n1.7.0.4\n"},{"id":"139387","messageId":"20100413022746.GE4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 5/9] builtin: introduce startup_info struct","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:27:46Z","receivedAt":"2010-04-13T02:27: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\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 representing results that were previously returned from\nsetup functions.  Letting these values persist means there is more\nflexibility 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---\nCreation of struct split off from its population, mostly for\nreviewability.  Feel free to merge this patch with the next one\nif you prefer.\n\n cache.h       |    5 +++++\n environment.c |    1 +\n git.c         |    4 ++++\n 3 files changed, 10 insertions(+), 0 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex 5eb0573..1479824 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1058,6 +1058,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 876c5e5..c36c902 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -52,6 +52,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 32720e5..b1d51c9 100644\n--- a/git.c\n+++ b/git.c\n@@ -13,6 +13,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@@ -477,6 +478,9 @@ int main(int argc, const char **argv)\n {\n \tconst char *cmd;\n \n+\tmemset(&git_startup_info, 0, sizeof(git_startup_info));\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.0.4\n"},{"id":"139388","messageId":"20100413022821.GF4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 6/9] builtin: remember whether repository was found","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:28:21Z","receivedAt":"2010-04-13T02:28:21Z","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\nAttempts to access gitdir are everywhere, even before cmd_*() is\ncalled (in particular for alias handling, pager configuration, work\ntree, and other core configuration).  Because the repository has not\nbeen found, repository-specific information (GIT_DIR/config) can not\nbe read.  This can lead to obscure bugs.\n\nThe sooner we set up gitdir, the less trouble we may have to deal with.\n\nCurrently, the cmd_*() functions learn whether a repository was\nfound through the *nongit_ok return value to\nsetup_git_directory_gently().  If run_builtin() is to take care of\nthis sooner, then they will have to get it from somewhere else.\nstartup_info is a good place for this.\n\nAs a bonus, this information can be used to teach functions such as\ngit_config() to avoid trying to access a repository if none is\npresent.\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 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 1479824..030ba01 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1060,6 +1060,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 5716d90..3b4ff09 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@@ -443,6 +443,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.0.4\n"},{"id":"139389","messageId":"20100413022922.GG4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 7/9] builtin: Support RUN_SETUP_GENTLY to set up repository early if found","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:29:22Z","receivedAt":"2010-04-13T02:29:22Z","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\nAttempts to access gitdir are everywhere, even before cmd_*() is\ncalled (examples: alias handling, pager configuration, work tree).\nBecause the repository has not been found, repository-specific\ninformation (i.e., $GIT_DIR/config) can not be read.  This leads to\nobscure bugs.\n\nSo the sooner we setup gitdir, the less trouble we may have to deal with.\n\nThis patch sets up the infrastructure.  Later patches will teach\nparticular commands to use it where applicable.\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 git.c |   11 ++++++++---\n 1 files changed, 8 insertions(+), 3 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex b1d51c9..20e9bfc 100644\n--- a/git.c\n+++ b/git.c\n@@ -220,13 +220,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 USE_PAGER\t\t(1<<1)\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<<2)\n+#define RUN_SETUP_GENTLY\t(1<<3)\n \n struct cmd_struct {\n \tconst char *cmd;\n@@ -245,6 +246,10 @@ 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\t\tuse_pager = check_pager_config(p->cmd);\n-- \n1.7.0.4\n"},{"id":"139390","messageId":"20100413023003.GH4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:30:03Z","receivedAt":"2010-04-13T02:30:03Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Eventually, all git commands should check their configuration at\nstart-up.  For now, reading configuration before repository discovery\nis dangerous because it could cause a pager.<cmd> setting from the\ncurrent repository to be neglected.\n\nBut for commands with RUN_SETUP or RUN_SETUP_GENTLY set, it is safe.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\n git.c |    2 +-\n 1 files changed, 1 insertions(+), 1 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 20e9bfc..56e93cf 100644\n--- a/git.c\n+++ b/git.c\n@@ -251,7 +251,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\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.0.4\n"},{"id":"139391","messageId":"20100413023124.GI4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[PATCH 9/9] config: run setup before commiting pager choice","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T02:31:24Z","receivedAt":"2010-04-13T02:31:24Z","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 in the first place)\nto reflect the current repository configuration, the repository\nneeds to be searched for 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---\nThat’s the end of the mini-series.  I hope you enjoyed reading it as\nmuch as I did adapting it.\n\nLooking forward to your thoughts,\nJonathan\n\n builtin/config.c |    6 ++----\n git.c            |    4 ++--\n t/t7006-pager.sh |   16 ++++++++++------\n 3 files changed, 14 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 4bc46b1..ecc8f87 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -326,11 +326,9 @@ 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 \tchar *value;\n-\tconst char *prefix = setup_git_directory_gently(&nongit);\n \n \tconfig_exclusive_filename = getenv(CONFIG_ENVIRONMENT);\n \n@@ -409,7 +407,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n \t}\n \telse if (actions == ACTION_EDIT) {\n \t\tcheck_argc(argc, 0, 0);\n-\t\tif (!config_exclusive_filename && nongit)\n+\t\tif (!config_exclusive_filename && !startup_info->have_repository)\n \t\t\tdie(\"not in a git directory\");\n \t\tgit_config(git_default_config, NULL);\n \t\tlaunch_editor(config_exclusive_filename ?\ndiff --git a/git.c b/git.c\nindex 56e93cf..0a0d9eb 100644\n--- a/git.c\n+++ b/git.c\n@@ -309,7 +309,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@@ -366,7 +366,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 237a689..e58b14d 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -80,7 +80,7 @@ test_expect_success TTY 'git rev-list uses a pager if configured to' '\n git config --unset pager.rev-list\n \n rm -f paginated.out\n-test_expect_failure TTY 'git config uses a pager if configured to' '\n+test_expect_success TTY 'git config uses a pager if configured to' '\n \tgit config pager.config true &&\n \ttest_terminal git config --list &&\n \ttest -e paginated.out\n@@ -172,7 +172,7 @@ test_pager_choice() {\n \tfi\n \n \tunset PAGER GIT_PAGER\n-\tgit config --unset core.pager\n+\tgit --no-pager config --unset core.pager\n \trm -f default_pager_used\n \ttest_expect_success SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n \t\tcat > $less <<-\\EOF &&\n@@ -185,7 +185,7 @@ test_pager_choice() {\n \t\"\n \n \tunset GIT_PAGER\n-\tgit config --unset core.pager\n+\tgit --no-pager config --unset core.pager\n \trm -f PAGER_used\n \ttest_expect_success TTY \"$cmd - PAGER overrides default pager\" \"\n \t\tPAGER='wc > PAGER_used' &&\n@@ -199,7 +199,7 @@ test_pager_choice() {\n \t$test_expectation TTY \"$cmd - core.pager ${used_if_wanted}\" \"\n \t\tPAGER=wc &&\n \t\texport PAGER &&\n-\t\tgit config core.pager 'wc > core.pager_used' &&\n+\t\tgit --no-pager config core.pager 'wc > core.pager_used' &&\n \t\t$full_cmd &&\n \t\t${if_want_local_config}test -e core.pager_used\n \t\"\n@@ -211,7 +211,7 @@ test_pager_choice() {\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\tgit --no-pager config core.pager 'wc > \\\"\\$stampname\\\"' &&\n \t\tmkdir sub &&\n \t\t(\n \t\t\tcd sub &&\n@@ -222,7 +222,7 @@ test_pager_choice() {\n \n \trm -f GIT_PAGER_used\n \ttest_expect_success TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n-\t\tgit config core.pager wc &&\n+\t\tgit --no-pager config core.pager wc &&\n \t\tGIT_PAGER='wc > GIT_PAGER_used' &&\n \t\texport GIT_PAGER &&\n \t\t$full_cmd &&\n@@ -259,4 +259,8 @@ doesnt_paginate 'git rev-list HEAD'\n git config pager.rev-list true\n test_pager_choice 'git rev-list HEAD'\n \n+doesnt_paginate 'git config -l'\n+git config pager.config true\n+test_pager_choice 'git config -l'\n+\n test_done\n-- \n1.7.0.4\n"},{"id":"139392","messageId":"20100413030853.GJ4118@progeny.tock","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"[RFC/PATCH 00/46] nd/setup remainder for convenient reference","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T03:08:53Z","receivedAt":"2010-04-13T03:08:53Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"I was thinking of sending the remainder of nd/setup after this to save\nothers the trouble of rebasing, but I fear the traffic would be too\ndisruptive.  So I am putting it up by git.\n\nCaveats: maybe these patches make no sense.  After I last rebased\nthem, I walked away without looking.  Still, maybe they can save\nyou some time.\n\nGood night,\nJonathan\n\nThe following changes since commit e0cc2322c409c6cfa897f395f6feb058e2d53d4a:\n  Nguyễn Thái Ngọc Duy (1):\n        config: run setup before commiting pager choice\n\nare available in the git repository at:\n\n  git://repo.or.cz/git/jrn.git/ nd/setup\n\nJonathan Nieder (5):\n      t0001: test git init when run via an alias\n      t5512: test that ls-remote does not require a git repository\n      t7002: test git grep --no-index from a bare repository\n      t7006: expose test_terminal() for use by other tests\n      help: note why it is appropriate for this command not to use RUN_SETUP_GENTLY\n\nNguyễn Thái Ngọc Duy (41):\n      t1300: test that scripted commands do not respect stray .git/config\n      setup: save prefix (original cwd relative to toplevel) in startup_info\n      builtin: remove prefix variable from run_builtin()\n      run_builtin(): save \"-h\" detection result for later use\n      builtin: remember whether repository has been searched for\n      builtin: USE_PAGER should not be used without RUN_SETUP*\n      hash-object: use RUN_SETUP_GENTLY\n      shortlog: use RUN_SETUP_GENTLY\n      grep: use RUN_SETUP_GENTLY\n      archive: use RUN_SETUP_GENTLY\n      mailinfo: use RUN_SETUP_GENTLY\n      check-ref-format: use RUN_SETUP_GENTLY\n      verify-pack: use RUN_SETUP_GENTLY\n      apply: use RUN_SETUP_GENTLY\n      bundle: use RUN_SETUP_GENTLY\n      diff: use RUN_SETUP_GENTLY\n      ls-remote: use RUN_SETUP_GENTLY\n      var: use RUN_SETUP_GENTLY\n      merge-file: use RUN_SETUP_GENTLY\n      worktree setup: calculate prefix even if no worktree is found\n      index-pack: trust the prefix returned by setup_git_directory_gently()\n      index-pack: use RUN_SETUP_GENTLY\n      Move enter_repo() to setup.c\n      enter_repo(): initialize other variables as setup_git_directory_gently() does\n      rev-parse --git-dir: print relative gitdir correctly\n      worktree setup: call set_git_dir explicitly\n      Add git_config_early()\n      Use git_config_early() instead of git_config() during repo setup\n      worktree setup: restore original state when things go wrong\n      init/clone: turn on startup->have_repository properly\n      git_config(): do not read .git/config if there is no repository\n      Do not read .git/info/exclude if there is no repository\n      Do not read .git/info/attributes if there is no repository\n      apply: do not check sha1 if there is no repository\n      config: do not read .git/config if there is no repository\n      builtins: utilize startup_info->help where possible\n      builtins: check for startup_info->help, print and exit early\n      Allow to undo setup_git_directory_gently() gracefully (and fix alias code)\n      alias: keep repository found while collecting aliases as long as possible\n      Guard unallowed access to repository when it's not set up\n      builtins: setup repository before print unknown command error\n\n attr.c                                    |    5 +-\n builtin/apply.c                           |    9 +-\n builtin/archive.c                         |    2 +-\n builtin/branch.c                          |    3 +\n builtin/bundle.c                          |    6 +-\n builtin/check-ref-format.c                |    2 +-\n builtin/checkout-index.c                  |    3 +\n builtin/clone.c                           |    3 +-\n builtin/commit.c                          |    6 +\n builtin/config.c                          |    9 +-\n builtin/diff.c                            |    6 +-\n builtin/gc.c                              |    3 +\n builtin/grep.c                            |   11 +-\n builtin/hash-object.c                     |    9 +-\n builtin/help.c                            |    5 +\n builtin/index-pack.c                      |   21 +--\n builtin/init-db.c                         |   10 +-\n builtin/log.c                             |    6 +-\n builtin/ls-files.c                        |    3 +\n builtin/ls-remote.c                       |    3 -\n builtin/mailinfo.c                        |    3 -\n builtin/merge-file.c                      |    4 +-\n builtin/merge-ours.c                      |    2 +-\n builtin/merge.c                           |    3 +\n builtin/pack-redundant.c                  |    2 +-\n builtin/rev-parse.c                       |    8 +\n builtin/shortlog.c                        |    4 +-\n builtin/show-ref.c                        |    2 +-\n builtin/update-index.c                    |    3 +\n builtin/upload-archive.c                  |    7 +-\n builtin/var.c                             |    2 -\n cache.h                                   |    8 +-\n config.c                                  |   22 +++-\n dir.c                                     |    8 +-\n environment.c                             |   31 ++++-\n git.c                                     |   84 +++++++-----\n help.c                                    |    4 +\n path.c                                    |   91 ------------\n setup.c                                   |  213 ++++++++++++++++++++++++++---\n t/lib-pager.sh                            |   37 +++++\n t/{t7006 => lib-pager}/test-terminal.perl |    0\n t/t0001-init.sh                           |   56 ++++++++\n t/t1300-repo-config.sh                    |   15 ++\n t/t1302-repo-version.sh                   |    2 +-\n t/t1500-rev-parse.sh                      |    2 +-\n t/t1501-worktree.sh                       |    5 +\n t/t5512-ls-remote.sh                      |   14 ++\n t/t7002-grep.sh                           |  116 ++++++++++++++++\n t/t7006-pager.sh                          |   29 +----\n t/t7020-help.sh                           |   18 +++\n 50 files changed, 660 insertions(+), 260 deletions(-)\n create mode 100644 t/lib-pager.sh\n rename t/{t7006 => lib-pager}/test-terminal.perl (100%)\n create mode 100755 t/t7020-help.sh\n"},{"id":"139393","messageId":"u2ufcaeb9bf1004122229l72de0e55i8dbd993d6cb16d2b@mail.gmail.com","threadId":"23437","inReplyTo":"20100413023003.GH4118@progeny.tock","subject":"Re: [PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-04-13T05:29:00Z","receivedAt":"2010-04-13T05:29:00Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/4/13 Jonathan Nieder <jrnieder@gmail.com>:\n> Eventually, all git commands should check their configuration at\n> start-up.  For now, reading configuration before repository discovery\n> is dangerous because it could cause a pager.<cmd> setting from the\n> current repository to be neglected.\n>\n> But for commands with RUN_SETUP or RUN_SETUP_GENTLY set, it is safe.\n>\n> Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>\n> ---\n>  git.c |    2 +-\n>  1 files changed, 1 insertions(+), 1 deletions(-)\n>\n> diff --git a/git.c b/git.c\n> index 20e9bfc..56e93cf 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -251,7 +251,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n>                        prefix = setup_git_directory_gently(&nongit_ok);\n>                }\n>\n> -               if (use_pager == -1 && p->option & RUN_SETUP)\n> +               if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))\n>                        use_pager = check_pager_config(p->cmd);\n>                if (use_pager == -1 && p->option & USE_PAGER)\n>                        use_pager = 1;\n\nThis still leaves a chance of going wrong: when user explicitly gives\n\"--paginate\", use_pager will be 1, but commands like \"git init\" does\nnot have RUN_SETUP*. So when setup_pager is called later on, it will\nmess things up. This could be solved completely (indeed I have a patch\nunder testing), but it would require unset_git_directory(), making\nthis series a bit longer :(\n\n\n-- \nDuy\n"},{"id":"139395","messageId":"4BC4107E.20101@viscovery.net","threadId":"23437","inReplyTo":"20100413021734.GB4118@progeny.tock","subject":"Re: [PATCH 2/9] t7006: test pager configuration for several git commands","fromName":"Johannes Sixt","fromEmail":"j.sixt@viscovery.net","sentAt":"2010-04-13T06:34:38Z","receivedAt":"2010-04-13T06:34:38Z","isPatch":true,"sender":{"key":"j6t@kdbg.org","avatar":"https://avatars.githubusercontent.com/u/14810926?v=4"},"body":"Am 4/13/2010 4:17, schrieb Jonathan Nieder:\n> +test_pager_choice() {\n> +...\n> +\ttest_expect_success SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n> +\t\tcat > $less <<-\\EOF &&\n> +\t\t#!$SHELL_PATH\n\nThis shell script is simple enough that you can use '#!/bin/sh' and avoid\n$ expansion where one must ask whether it needs quoting or not.\n\n> +\t\twc > default_pager_used\n> +\t\tEOF\n> +...\n> +\t\"\n> +...\n> +\ttest_expect_success TTY \"$cmd - PAGER overrides default pager\" \"\n> +...\n> +\t$test_expect_expected TTY \"$cmd - core.pager in subdir\" \"\n> +...\n> +\ttest_expect_success TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n> +...\n>  \n> +test_pager_choice 'git log'\n> +test_pager_choice 'git -p log'\n> +test_pager_choice test_must_fail 'git -p'\n> +test_pager_choice test_must_fail 'git -p nonsense'\n\nThe intents of the test cases would be much easier to follow and to review\nif this were written as, for example:\n\ntest_default_pager        'git log'\ntest_PAGER_overrides      'git log'\ntest_core_pager_overrides 'git log'\ntest_core_pager_subdir    'git log'\ntest_GIT_PAGER_overrides  'git log'\ntest_default_pager        'git -p log'\ntest_PAGER_overrides      'git -p log'\ntest_core_pager_overrides 'git -p log'\ntest_core_pager_subdir    'git -p log' fails\ntest_GIT_PAGER_overrides  'git -p log'\ntest_default_pager        'test_must_fail git -p'\ntest_PAGER_overrides      'test_must_fail git -p'\ntest_core_pager_overrides 'test_must_fail git -p'\ntest_core_pager_subdir    'test_must_fail git -p' fails\ntest_GIT_PAGER_overrides  'test_must_fail git -p'\ntest_default_pager        'test_must_fail git -p nonsense'\ntest_PAGER_overrides      'test_must_fail git -p nonsense'\ntest_core_pager_overrides 'test_must_fail git -p nonsense'\ntest_core_pager_subdir    'test_must_fail git -p nonsense' fails\ntest_GIT_PAGER_overrides  'test_must_fail git -p nonsense'\n\nthe point being that it is less factorized (not the exact syntax).\n\n-- Hannes\n"},{"id":"139409","messageId":"y2yfcaeb9bf1004130312l197983cnf92371acc88464db@mail.gmail.com","threadId":"23437","inReplyTo":"20100413023003.GH4118@progeny.tock","subject":"Re: [PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-04-13T10:12:43Z","receivedAt":"2010-04-13T10:12:43Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/4/13 Jonathan Nieder <jrnieder@gmail.com>:\n> diff --git a/git.c b/git.c\n> index 20e9bfc..56e93cf 100644\n> --- a/git.c\n> +++ b/git.c\n> @@ -251,7 +251,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n>                        prefix = setup_git_directory_gently(&nongit_ok);\n>                }\n>\n> -               if (use_pager == -1 && p->option & RUN_SETUP)\n> +               if (use_pager == -1 && p->option & (RUN_SETUP | RUN_SETUP_GENTLY))\n>                        use_pager = check_pager_config(p->cmd);\n>                if (use_pager == -1 && p->option & USE_PAGER)\n>                        use_pager = 1;\n\nOn the second look, there's another case, when RUN_SETUP_GENTLY is\nset, but no repository is found. git_config() will pick\n$(cwd)/.git/config if it exists. I guess it's OK for this series\nbecause the true fix will require more changes.\n-- \nDuy\n"},{"id":"139437","messageId":"20100413220737.GA1676@progeny.tock","threadId":"23437","inReplyTo":"4BC4107E.20101@viscovery.net","subject":"Re: [PATCH 2/9] t7006: test pager configuration for several git commands","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-13T22:07:37Z","receivedAt":"2010-04-13T22:07:37Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Johannes Sixt wrote:\n\n> The intents of the test cases would be much easier to follow and to review\n> if this were written as, for example:\n> \n> test_default_pager        'git log'\n> test_PAGER_overrides      'git log'\n> test_core_pager_overrides 'git log'\n> test_core_pager_subdir    'git log'\n> test_GIT_PAGER_overrides  'git log'\n> test_default_pager        'git -p log'\n[...]\n\nGood idea.  This would also make the expected result much easier to\nchange test-by-test.  Will do, thanks.\n\nJonathan\n"},{"id":"139443","messageId":"20100414012632.GA7121@progeny.tock","threadId":"23437","inReplyTo":"20100413021734.GB4118@progeny.tock","subject":"[PATCH 2/9 v2] t7006: test pager configuration for several git commands","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-14T01:26:33Z","receivedAt":"2010-04-14T01:26:33Z","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.  Some\npatches under consideration will produce different results for\ndifferent commands, so it should be useful to have examples like this\nin mind to illustrate their effect.\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\nImproved-by: Johannes Sixt <j6t@kdbg.org>\n---\nChanges from v1:\n - Use /bin/sh instead of $SHELL_PATH to simplify quoting issues\n - Split the test_pager_choice function into single-test pieces to\n   make the test easier to understand.\n\nI’ll resend the patches 3 and 9 with corresponding adjustments in a\nmoment.\n\nThanks to Hannes for the feedback.\n\n t/t7006-pager.sh |  192 +++++++++++++++++++++++++++++++++++-------------------\n 1 files changed, 124 insertions(+), 68 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 4f804ed..d5f8a18 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -131,78 +131,134 @@ then\n \ttest_set_prereq SIMPLEPAGER\n fi\n \n-unset PAGER GIT_PAGER\n-git config --unset core.pager\n-rm -f default_pager_used\n-test_expect_success SIMPLEPAGER 'default pager is used by default' '\n-\tcat > $less <<-EOF &&\n-\t#!$SHELL_PATH\n-\twc > default_pager_used\n-\tEOF\n-\tchmod +x $less &&\n-\tPATH=.:$PATH test_terminal git log &&\n-\ttest -e default_pager_used\n-'\n+# Tests for pager choice.\n \n-unset GIT_PAGER\n-git config --unset core.pager\n-rm -f PAGER_used\n-test_expect_success TTY 'PAGER overrides default pager' '\n-\tPAGER=\"wc > PAGER_used\" &&\n-\texport PAGER &&\n-\ttest_terminal git log &&\n-\ttest -e PAGER_used\n-'\n+# Usage:\n+#\tparse_args expect_(success|failure) [test_must_fail] git whatever\n+#\t$test_expectation \"$cmd - behaves well\" \"\n+#\t\t...\n+#\t\t$full_command &&\n+#\t\t...\n+#\t\"\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-unset GIT_PAGER\n-rm -f core.pager_used\n-test_expect_success TTY 'core.pager overrides PAGER' '\n-\tPAGER=wc &&\n-\texport PAGER &&\n-\tgit config core.pager \"wc > core.pager_used\" &&\n-\ttest_terminal git log &&\n-\ttest -e core.pager_used\n-'\n+# usage: test_default_pager expect_(success|failure) [test_must_fail] command\n+test_default_pager() {\n+\tparse_args \"$@\"\n \n-unset GIT_PAGER\n-rm -f core.pager_used\n-rm -fr sub\n-test_expect_success TTY 'core.pager in subdir' '\n-\tPAGER=wc &&\n-\tstampname=$(pwd)/core.pager_used &&\n-\texport PAGER stampname &&\n-\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n-\tmkdir sub &&\n-\t(\n-\t\tcd sub &&\n-\t\ttest_terminal git log\n-\t) &&\n-\ttest -e \"$stampname\"\n-'\n+\tunset PAGER GIT_PAGER\n+\tgit config --unset core.pager\n+\trm -f default_pager_used\n+\t$test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n+\t\tcat >$less <<-\\EOF &&\n+\t\t\t#!/bin/sh\n+\t\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-unset GIT_PAGER\n-rm -f core.pager_used\n-rm -fr sub\n-test_expect_failure TTY 'core.pager in subdir with --paginate' '\n-\tPAGER=wc &&\n-\tstampname=$(pwd)/core.pager_used &&\n-\texport PAGER stampname &&\n-\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n-\tmkdir sub &&\n-\t(\n-\t\tcd sub &&\n-\t\ttest_terminal git --paginate log\n-\t) &&\n-\ttest -e \"$stampname\"\n-'\n+test_PAGER_overrides() {\n+\tparse_args \"$@\"\n \n-rm -f GIT_PAGER_used\n-test_expect_success TTY 'GIT_PAGER overrides core.pager' '\n-\tgit config core.pager wc &&\n-\tGIT_PAGER=\"wc > GIT_PAGER_used\" &&\n-\texport GIT_PAGER &&\n-\ttest_terminal git log &&\n-\ttest -e GIT_PAGER_used\n-'\n+\tunset GIT_PAGER\n+\tgit config --unset core.pager\n+\trm -f PAGER_used\n+\t$test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\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+\tunset GIT_PAGER\n+\trm -f core.pager_used\n+\t$test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\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_core_pager_subdir() {\n+\tparse_args \"$@\"\n+\n+\tunset GIT_PAGER\n+\trm -f core.pager_used\n+\trm -fr sub\n+\t$test_expectation TTY \"$cmd - core.pager from subdirectory\" \"\n+\t\tstampname=\\$(pwd)/core.pager_used &&\n+\t\tPAGER=wc &&\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 \\\"\\$stampname\\\"\n+\t\"\n+}\n+\n+test_GIT_PAGER_overrides() {\n+\tparse_args \"$@\"\n+\n+\trm -f GIT_PAGER_used\n+\t$test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\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_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.0.4\n"},{"id":"139446","messageId":"20100414021704.GA22766@progeny.tock","threadId":"23437","inReplyTo":"20100413022420.GC4118@progeny.tock","subject":"[PATCH 3/9 v2] builtins: do not commit pager choice early","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-14T02:17:04Z","receivedAt":"2010-04-14T02:17:04Z","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\nIf git is passed the --paginate option, committing the pager choice\nwill require setting up a pager, which requires access to repository\nfor the core.pager configuration.\n\nAfter handle_options() is called, the repository has not been searched\nfor yet.  Unless GIT_DIR or GIT_CONFIG is set, attempting to access\nthe configuration at this point results in git_dir being set to .git,\nwhich is almost certainly not what was wanted.  If a git command is\nrun from a subdirectory of the toplevel directory of a git repository\nand the --paginate option is supplied, the core.pager setting from\nthat repository is not being respected.\n\nThere are several possible code paths after handle_options() and\ncommit_pager_choice() are called:\n\n1. list_common_cmds_help() is a printout of 29 lines.  This can\n   benefit from pagination, so do commit the pager choice before\n   writing this output.\n\n   Since ‘git’ without subcommand has no other reason to access the\n   repository, ideally this would not involve accessing the\n   repository-specific configuration file.  But for now, it is simpler\n   to commit the pager choice using the funny code that would notice\n   whatever repository happens to be at .git.  That this accesses a\n   repository if it happens to be very convenient is a bug but not\n   a very important one.\n\n2. run_argv() already commits pager choice inside run_builtin() if a\n   command is found.  If the relevant git subcommand searches for a\n   git directory, not commiting to a pager before then means the\n   core.pager setting from the correct $GIT_DIR/config will be\n   respected.\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---\nRebased on top of patch 2 v2\n\n git.c            |    2 +-\n t/t7006-pager.sh |   63 +++++++++++++++++++++++++++++++++++++++++++----------\n 2 files changed, 52 insertions(+), 13 deletions(-)\n\ndiff --git a/git.c b/git.c\nindex 6bae305..32720e5 100644\n--- a/git.c\n+++ b/git.c\n@@ -502,12 +502,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 d5f8a18..a240b15 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -190,27 +190,58 @@ test_PAGER_overrides() {\n \t\"\n }\n \n+parse_ifwanted_arg() {\n+\tif test \"$1\" = yes\n+\tthen\n+\t\tif_want_local_config=\n+\t\tused_if_wanted='overrides PAGER'\n+\telse\n+\t\tif_want_local_config='! '\n+\t\tused_if_wanted='is not used'\n+\tfi\n+}\n+\n test_core_pager_overrides() {\n+\ttest_core_pager yes \"$@\"\n+}\n+\n+test_local_config_ignored() {\n+\ttest_core_pager no \"$@\"\n+}\n+\n+test_core_pager() {\n+\tparse_ifwanted_arg \"$1\"\n+\tshift\n \tparse_args \"$@\"\n \n \tunset GIT_PAGER\n \trm -f core.pager_used\n-\t$test_expectation TTY \"$cmd - core.pager overrides PAGER\" \"\n+\t$test_expectation TTY \"$cmd - core.pager $used_if_wanted\" \"\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\t${if_want_local_config}test -e core.pager_used\n \t\"\n }\n \n test_core_pager_subdir() {\n+\ttest_pager_subdir_helper yes \"$@\"\n+}\n+\n+test_no_local_config_subdir() {\n+\ttest_pager_subdir_helper no \"$@\"\n+}\n+\n+test_pager_subdir_helper() {\n+\tparse_ifwanted_arg \"$1\"\n+\tshift\n \tparse_args \"$@\"\n \n \tunset GIT_PAGER\n \trm -f core.pager_used\n \trm -fr sub\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\tstampname=\\$(pwd)/core.pager_used &&\n \t\tPAGER=wc &&\n \t\texport PAGER stampname &&\n@@ -220,7 +251,7 @@ test_core_pager_subdir() {\n \t\t\tcd sub &&\n \t\t\t$full_command\n \t\t) &&\n-\t\ttest -e \\\"\\$stampname\\\"\n+\t\t${if_want_local_config}test -e \\\"\\$stampname\\\"\n \t\"\n }\n \n@@ -237,6 +268,18 @@ test_GIT_PAGER_overrides() {\n \t\"\n }\n \n+test_doesnt_paginate() {\n+\tparse_args \"$@\"\n+\n+\trm -f GIT_PAGER_used\n+\t$test_expectation TTY \"no pager for '$cmd'\" \"\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@@ -246,19 +289,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.0.4\n"},{"id":"139447","messageId":"20100414021950.GB22766@progeny.tock","threadId":"23437","inReplyTo":"20100413022505.GD4118@progeny.tock","subject":"[PATCH 4/9 v2] t7006: test pager.<cmd> configuration","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-14T02:19:50Z","receivedAt":"2010-04-14T02:19:50Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nRebased against patch 3 v2.\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 a240b15..97ca5d6 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -71,6 +71,22 @@ test_expect_success TTY 'git --paginate rev-list uses a pager' '\n \ttest -e paginated.out\n '\n \n+rm -f paginated.out\n+test_expect_success TTY 'git rev-list uses a pager if configured to' '\n+\tgit config pager.rev-list true &&\n+\ttest_terminal git rev-list HEAD &&\n+\ttest -e paginated.out\n+'\n+git config --unset pager.rev-list\n+\n+rm -f paginated.out\n+test_expect_failure TTY 'git config uses a pager if configured to' '\n+\tgit config pager.config true &&\n+\ttest_terminal git config --list &&\n+\ttest -e paginated.out\n+'\n+git --no-pager config --unset pager.config\n+\n rm -f file paginated.out\n test_expect_success 'no pager even with --paginate when stdout is a pipe' '\n \tgit --paginate log | cat &&\n@@ -300,4 +316,14 @@ 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 \n+test_doesnt_paginate expect_success 'git rev-list HEAD'\n+test_expect_success 'set up rev-list to use a pager' '\n+\tgit config pager.rev-list true\n+'\n+test_default_pager        expect_success 'git rev-list HEAD'\n+test_PAGER_overrides      expect_success 'git rev-list HEAD'\n+test_core_pager_overrides expect_success 'git rev-list HEAD'\n+test_core_pager_subdir    expect_success 'git rev-list HEAD'\n+test_GIT_PAGER_overrides  expect_success 'git rev-list HEAD'\n+\n test_done\n-- \n1.7.0.4\n"},{"id":"139449","messageId":"20100414022315.GC22766@progeny.tock","threadId":"23437","inReplyTo":"20100413023124.GI4118@progeny.tock","subject":"[PATCH 9/9 v2] config: run setup before commiting pager choice","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-14T02:23:15Z","receivedAt":"2010-04-14T02:23:15Z","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 in the first place)\nto reflect the current repository configuration, the repository\nneeds to be searched for 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---\nRebased for changes to t7006 in patches 2, 3, 4 v2.\n\n builtin/config.c |    6 ++----\n git.c            |    4 ++--\n t/t7006-pager.sh |   22 ++++++++++++++++------\n 3 files changed, 20 insertions(+), 12 deletions(-)\n\ndiff --git a/builtin/config.c b/builtin/config.c\nindex 4bc46b1..ecc8f87 100644\n--- a/builtin/config.c\n+++ b/builtin/config.c\n@@ -326,11 +326,9 @@ 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 \tchar *value;\n-\tconst char *prefix = setup_git_directory_gently(&nongit);\n \n \tconfig_exclusive_filename = getenv(CONFIG_ENVIRONMENT);\n \n@@ -409,7 +407,7 @@ int cmd_config(int argc, const char **argv, const char *unused_prefix)\n \t}\n \telse if (actions == ACTION_EDIT) {\n \t\tcheck_argc(argc, 0, 0);\n-\t\tif (!config_exclusive_filename && nongit)\n+\t\tif (!config_exclusive_filename && !startup_info->have_repository)\n \t\t\tdie(\"not in a git directory\");\n \t\tgit_config(git_default_config, NULL);\n \t\tlaunch_editor(config_exclusive_filename ?\ndiff --git a/git.c b/git.c\nindex 56e93cf..0a0d9eb 100644\n--- a/git.c\n+++ b/git.c\n@@ -309,7 +309,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@@ -366,7 +366,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 97ca5d6..d649f55 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -80,7 +80,7 @@ test_expect_success TTY 'git rev-list uses a pager if configured to' '\n git config --unset pager.rev-list\n \n rm -f paginated.out\n-test_expect_failure TTY 'git config uses a pager if configured to' '\n+test_expect_success TTY 'git config uses a pager if configured to' '\n \tgit config pager.config true &&\n \ttest_terminal git config --list &&\n \ttest -e paginated.out\n@@ -175,7 +175,7 @@ test_default_pager() {\n \tparse_args \"$@\"\n \n \tunset PAGER GIT_PAGER\n-\tgit config --unset core.pager\n+\tgit --no-pager config --unset core.pager\n \trm -f default_pager_used\n \t$test_expectation SIMPLEPAGER \"$cmd - default pager is used by default\" \"\n \t\tcat >$less <<-\\EOF &&\n@@ -196,7 +196,7 @@ test_PAGER_overrides() {\n \tparse_args \"$@\"\n \n \tunset GIT_PAGER\n-\tgit config --unset core.pager\n+\tgit --no-pager config --unset core.pager\n \trm -f PAGER_used\n \t$test_expectation TTY \"$cmd - PAGER overrides default pager\" \"\n \t\tPAGER='wc > PAGER_used' &&\n@@ -235,7 +235,7 @@ test_core_pager() {\n \t$test_expectation TTY \"$cmd - core.pager $used_if_wanted\" \"\n \t\tPAGER=wc &&\n \t\texport PAGER &&\n-\t\tgit config core.pager 'wc > core.pager_used' &&\n+\t\tgit --no-pager config core.pager 'wc > core.pager_used' &&\n \t\t$full_command &&\n \t\t${if_want_local_config}test -e core.pager_used\n \t\"\n@@ -261,7 +261,7 @@ test_pager_subdir_helper() {\n \t\tstampname=\\$(pwd)/core.pager_used &&\n \t\tPAGER=wc &&\n \t\texport PAGER stampname &&\n-\t\tgit config core.pager 'wc > \\\"\\$stampname\\\"' &&\n+\t\tgit --no-pager config core.pager 'wc > \\\"\\$stampname\\\"' &&\n \t\tmkdir sub &&\n \t\t(\n \t\t\tcd sub &&\n@@ -276,7 +276,7 @@ test_GIT_PAGER_overrides() {\n \n \trm -f GIT_PAGER_used\n \t$test_expectation TTY \"$cmd - GIT_PAGER overrides core.pager\" \"\n-\t\tgit config core.pager wc &&\n+\t\tgit --no-pager config core.pager wc &&\n \t\tGIT_PAGER='wc > GIT_PAGER_used' &&\n \t\texport GIT_PAGER &&\n \t\t$full_command &&\n@@ -326,4 +326,14 @@ test_core_pager_overrides expect_success 'git rev-list HEAD'\n test_core_pager_subdir    expect_success 'git rev-list HEAD'\n test_GIT_PAGER_overrides  expect_success 'git rev-list HEAD'\n \n+test_doesnt_paginate expect_success 'git config -l'\n+test_expect_success \"set up 'git config' to use a pager\" '\n+\tgit config pager.config true\n+'\n+test_default_pager        expect_success 'git config -l'\n+test_PAGER_overrides      expect_success 'git config -l'\n+test_core_pager_overrides expect_success 'git config -l'\n+test_core_pager_subdir    expect_success 'git config -l'\n+test_GIT_PAGER_overrides  expect_success 'git config -l'\n+\n test_done\n-- \n1.7.0.4\n"},{"id":"139451","messageId":"20100414043844.GA28864@progeny.tock","threadId":"23437","inReplyTo":"u2ufcaeb9bf1004122229l72de0e55i8dbd993d6cb16d2b@mail.gmail.com","subject":"Re: [PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-14T04:38:44Z","receivedAt":"2010-04-14T04:38:44Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n> 2010/4/13 Jonathan Nieder <jrnieder@gmail.com>:\n\n>> @@ -251,7 +251,7 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\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>\n> This still leaves a chance of going wrong: when user explicitly gives\n> \"--paginate\", use_pager will be 1, but commands like \"git init\" does\n> not have RUN_SETUP*. So when setup_pager is called later on, it will\n> mess things up.\n\nI decided not to check_pager_config() unconditionally to avoid\nbreaking ‘git diff’ (especially ‘git diff --exit-code’).  Maybe that\nis too conservative; not sure.  The commit message should be more\nexplicit, something like:\n\n   Eventually, all git commands should check their configuration at\n   start-up.  For now, reading configuration before repository discovery\n   is dangerous because it could cause a pager.<cmd> setting from the\n   current repository to be neglected.\n\n   But for commands with RUN_SETUP or RUN_SETUP_GENTLY set, it is safe.\n\n   This will not affect commands like \"git init\" that cannot have\n   RUN_SETUP* set; they will have to be helped separately later.  In\n   particular, commands such as \"git diff\" that use command-specific\n   options to decide whether to search for a repository and whether to\n   paginate output are outside the scope of this change.\n\nGuiding principle: better to leave some bugs for later than risk\nregressions.\n\n> This could be solved completely (indeed I have a patch\n> under testing), but it would require unset_git_directory(), making\n> this series a bit longer :(\n\nI agree; that’s the right way to do it.  run_builtin() ought to be\nrelatively sure about whether a repo is going to be searched for.  For\ncommands like diff and grep, I think it should be okay to search for a\nrepo unless --no-index is the first argument.\n\nThanks for your thoughtfulness.\nJonathan\n"},{"id":"139452","messageId":"20100414050643.GB28864@progeny.tock","threadId":"23437","inReplyTo":"y2yfcaeb9bf1004130312l197983cnf92371acc88464db@mail.gmail.com","subject":"Re: [PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-14T05:06:44Z","receivedAt":"2010-04-14T05:06:44Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Nguyen Thai Ngoc Duy wrote:\n\n> there's another case, when RUN_SETUP_GENTLY is\n> set, but no repository is found. git_config() will pick\n> $(cwd)/.git/config if it exists. I guess it's OK for this series\n> because the true fix will require more changes.\n\nI have claimed before that it’s better to fix a few bugs now and\nprovide a solid foundation to build on than to try to do everything\nright away.  Sounds good in principle, but in practice we have to look\nto the future to decide whether the foundation is strong enough.\n\nSo here are some ideas for future work (not necessarily in order).\n\n - Teach remaining commands that need to search for a repository to\n   use RUN_SETUP_GENTLY, with appropriate exceptions where needed\n   (for --no-index, for example).\n\n - Introduce unset_git_directory and the RUN_UNSETUP option (yes,\n   this needs a better name).  Teach commands that work without a\n   git directory to use it (this should fix the init poisoned by\n   parent repository and aliased init problems).\n\n - Teach git_config() to ignore the repository-specific configuration\n   if have_run_setup is true but have_repository is false.\n\n - Teach git_attr() to ignore .git/info/attributes if have_run_setup\n   is true but have_repository is false.\n\n - Teach git_config() to optionally die if have_run_setup is not true\n   and the setup_git_dir* to optionally die if have_run_setup is true.\n   test-lib.sh would enable this option.\n\nSane?\nJonathan\n"},{"id":"139460","messageId":"y2vfcaeb9bf1004140059j1a93bb72mb8feb33f25d9e3a7@mail.gmail.com","threadId":"23437","inReplyTo":"20100413030853.GJ4118@progeny.tock","subject":"Re: [RFC/PATCH 00/46] nd/setup remainder for convenient reference","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-04-14T07:59:55Z","receivedAt":"2010-04-14T07:59:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"2010/4/13 Jonathan Nieder <jrnieder@gmail.com>:\n> I was thinking of sending the remainder of nd/setup after this to save\n> others the trouble of rebasing, but I fear the traffic would be too\n> disruptive.  So I am putting it up by git.\n>\n> Caveats: maybe these patches make no sense.  After I last rebased\n> them, I walked away without looking.  Still, maybe they can save\n> you some time.\n\nWill go through them, but not now.\n\n> are available in the git repository at:\n>\n>  git://repo.or.cz/git/jrn.git/ nd/setup\n\nI took your tree (5d46d95), dropped \"builtin: USE_PAGER should not be\nused without RUN_SETUP*\" (it's useless), lightly modified \"alias: keep\nrepository found while collecting aliases as long as possible\" and\nreplaced \"Guard unallowed access to repository when it's not set up\".\nAvailable at:\n\ngit://repo.or.cz/git/pclouds.git tp/setup\n\nI will split the \"Guard...\" patch for easier review, later today. I\ncouldn't because it was a die() patch. Now all it does is warning(),\nso it's safe to split up. One more good point of warning().\n-- \nDuy\n"},{"id":"139516","messageId":"7v4ojdpxls.fsf@alter.siamese.dyndns.org","threadId":"23437","inReplyTo":"20100413021355.GA4118@progeny.tock","subject":"Re: [PATCH 1/9] t7006: GIT_DIR/config should be honored in subdirs of toplevel","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-14T20:50:39Z","receivedAt":"2010-04-14T20:50:39Z","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> +unset GIT_PAGER\n> +rm -f core.pager_used\n> +rm -fr sub\n\nWhy do you have these outside the test itself?\n\n> +test_expect_success TTY 'core.pager in subdir' '\n> +\tPAGER=wc &&\n> +\tstampname=$(pwd)/core.pager_used &&\n> +\texport PAGER stampname &&\n> +\tgit config core.pager \"wc > \\\"\\$stampname\\\"\" &&\n> +\tmkdir sub &&\n> +\t(\n> +\t\tcd sub &&\n> +\t\ttest_terminal git log\n> +\t) &&\n> +\ttest -e \"$stampname\"\n> +'\n\nThey are reasonable clean-up steps to start the real test (starting from\nsetting and exporting the pager) in a known good state, and as long as you\nwrite them not to fail I don't see any reason to have them outside the\ntest.  You _might_ want to \"unset GIT_PAGER\" immediately after the test\nthat does \"export PAGER\", so that it won't contaminate the environment the\ntest script itself runs, but even for that purpose, it would probably be\nbetter to run the parts that depend on the exported value in a subshell.\n"},{"id":"139517","messageId":"7vwrw9oiva.fsf@alter.siamese.dyndns.org","threadId":"23437","inReplyTo":"20100413021153.GA3978@progeny.tock","subject":"Re: [PATCH/RFC 0/9] Setup cleanup, chapter one","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-14T20:54:17Z","receivedAt":"2010-04-14T20:54:17Z","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> These patches are designed to make people who want the pager.<cmd>\n> configuration to be more reliable a little happier.  More importantly,\n> they bring the setup procedure closer to doing the Right Thing™.\n\nThanks for looking into this.\n\nBy the way, the other day I had an interesting experience after running:\n\n\tgit -p help -m cat-file\n\nIf you try this yourself, you probably need \"reset\" or \"stty sane\" to\nrecover.\n\nDoes this series address it?\n"},{"id":"139529","messageId":"20100415000448.GA14151@progeny.tock","threadId":"23437","inReplyTo":"7vwrw9oiva.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH/RFC 0/9] Setup cleanup, chapter one","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-15T00:05:09Z","receivedAt":"2010-04-15T00:05:09Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n\n> By the way, the other day I had an interesting experience after running:\n> \n> \tgit -p help -m cat-file\n> \n> If you try this yourself, you probably need \"reset\" or \"stty sane\" to\n> recover.\n> \n> Does this series address it?\n\nNo, it doesn’t.\n\nThe bug seems to be timing-related.  The two copies of ‘less’ fight over\ninitialization of the terminal and nobody wins.\n\nWhat is the right thing to do in this case?  Can we assume ‘man’ comes\nwith a pager and suppress our own?  Should we ask ‘man’ to suppress its\npager, losing the formatting and status line in the process, but setting\nMANPAGER=cat?  Probably the right thing to do would be to suppress our\npager and set MANPAGER according to git_pager() so ‘man’ can use it.\n\nMaybe something roughly like this (on top of the series)?  This does\nnot help backends that do not know how to use MANPAGER.\n\ndiff --git a/builtin/help.c b/builtin/help.c\nindex 3182a2b..d9a0307 100644\n--- a/builtin/help.c\n+++ b/builtin/help.c\n@@ -316,6 +316,40 @@ static const char *cmd_to_page(const char *git_cmd)\n \t\treturn prepend(\"git\", git_cmd);\n }\n \n+static void commit_pager_choice(void) {\n+\tswitch (startup_info->use_pager) {\n+\tcase 0:\n+\t\tsetenv(\"GIT_PAGER\", \"cat\", 1);\n+\t\tbreak;\n+\tcase 1:\n+\t\tsetup_pager();\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+}\n+\n+static void setup_man_pager(void) {\n+\tconst char *pager;\n+\n+\tswitch (startup_info->use_pager) {\n+\tcase 0:\n+\t\tsetenv(\"MANPAGER\", \"cat\", 1);\n+\t\tbreak;\n+\tcase 1:\n+\t\tpager = git_pager(isatty(1));\n+\t\tif (!pager) {\n+\t\t\tsetenv(\"MANPAGER\", \"cat\", 1);\n+\t\t} else {\n+\t\t\tsetenv(\"LESS\", \"FRSX\", 0);\n+\t\t\tsetenv(\"MANPAGER\", pager, 1);\n+\t\t}\n+\t\tbreak;\n+\tdefault:\n+\t\tbreak;\n+\t}\n+}\n+\n static void setup_man_path(void)\n {\n \tstruct strbuf new_path = STRBUF_INIT;\n@@ -358,6 +392,7 @@ static void show_man_page(const char *git_cmd)\n \tconst char *fallback = getenv(\"GIT_MAN_VIEWER\");\n \n \tsetup_man_path();\n+\tsetup_man_pager();\n \tfor (viewer = man_viewer_list; viewer; viewer = viewer->next)\n \t{\n \t\texec_viewer(viewer->name, page); /* will return when unable */\n@@ -423,20 +458,17 @@ int cmd_help(int argc, const char **argv, const char *prefix)\n \t\t\tbuiltin_help_usage, 0);\n \tparsed_help_format = help_format;\n \n-\tif (show_all) {\n+\tif (show_all || !argv[0]) {\n+\t\tcommit_pager_choice();\n \t\tprintf(\"usage: %s\\n\\n\", git_usage_string);\n-\t\tlist_commands(\"git commands\", &main_cmds, &other_cmds);\n+\t\tif (show_all)\n+\t\t\tlist_commands(\"git commands\", &main_cmds, &other_cmds);\n+\t\telse\n+\t\t\tlist_common_cmds_help();\n \t\tprintf(\"%s\\n\", git_more_info_string);\n \t\treturn 0;\n \t}\n \n-\tif (!argv[0]) {\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);\n-\t\treturn 0;\n-\t}\n-\n \tsetup_git_directory_gently(&nongit);\n \tgit_config(git_help_config, NULL);\n \ndiff --git a/cache.h b/cache.h\nindex 030ba01..8ba5727 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -1061,6 +1061,7 @@ int split_cmdline(char *cmdline, const char ***argv);\n /* git.c */\n struct startup_info {\n \tint have_repository;\n+\tint use_pager;\n };\n extern struct startup_info *startup_info;\n \ndiff --git a/git.c b/git.c\nindex 0a0d9eb..a81726e 100644\n--- a/git.c\n+++ b/git.c\n@@ -14,7 +14,6 @@ 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 \tint val;\n@@ -39,7 +38,7 @@ int check_pager_config(const char *cmd)\n }\n \n static void commit_pager_choice(void) {\n-\tswitch (use_pager) {\n+\tswitch (startup_info->use_pager) {\n \tcase 0:\n \t\tsetenv(\"GIT_PAGER\", \"cat\", 1);\n \t\tbreak;\n@@ -86,9 +85,9 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\tputs(system_path(GIT_HTML_PATH));\n \t\t\texit(0);\n \t\t} else if (!strcmp(cmd, \"-p\") || !strcmp(cmd, \"--paginate\")) {\n-\t\t\tuse_pager = 1;\n+\t\t\tstartup_info->use_pager = 1;\n \t\t} else if (!strcmp(cmd, \"--no-pager\")) {\n-\t\t\tuse_pager = 0;\n+\t\t\tstartup_info->use_pager = 0;\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"--no-replace-objects\")) {\n@@ -221,13 +220,15 @@ static int handle_alias(int *argcp, const char ***argv)\n const char git_version_string[] = GIT_VERSION;\n \n #define RUN_SETUP\t\t(1<<0)\n-#define USE_PAGER\t\t(1<<1)\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\t(1<<2)\n-#define RUN_SETUP_GENTLY\t(1<<3)\n+#define NEED_WORK_TREE\t\t(1<<1)\n+#define RUN_SETUP_GENTLY\t(1<<2)\n+#define USE_PAGER\t\t(1<<3)\n+/* do not commit_pager_choice() -- the builtin will take care of it */\n+#define NO_PAGER_SETUP\t\t(1<<4)\n \n struct cmd_struct {\n \tconst char *cmd;\n@@ -244,6 +245,8 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\n \tprefix = NULL;\n \thelp = argc == 2 && !strcmp(argv[1], \"-h\");\n \tif (!help) {\n+\t\tint use_pager = startup_info->use_pager;\n+\n \t\tif (p->option & RUN_SETUP)\n \t\t\tprefix = setup_git_directory();\n \t\tif (p->option & RUN_SETUP_GENTLY) {\n@@ -255,8 +258,10 @@ static int run_builtin(struct cmd_struct *p, int argc, const char **argv)\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+\t\tstartup_info->use_pager = use_pager;\n \t}\n-\tcommit_pager_choice();\n+\tif (!(p->option & NO_PAGER_SETUP))\n+\t\tcommit_pager_choice();\n \n \tif (!help && p->option & NEED_WORK_TREE)\n \t\tsetup_work_tree();\n@@ -328,7 +333,7 @@ static void handle_internal_command(int argc, const char **argv)\n \t\t{ \"get-tar-commit-id\", cmd_get_tar_commit_id },\n \t\t{ \"grep\", cmd_grep, USE_PAGER },\n \t\t{ \"hash-object\", cmd_hash_object },\n-\t\t{ \"help\", cmd_help },\n+\t\t{ \"help\", cmd_help, NO_PAGER_SETUP },\n \t\t{ \"index-pack\", cmd_index_pack },\n \t\t{ \"init\", cmd_init_db },\n \t\t{ \"init-db\", cmd_init_db },\n@@ -484,6 +489,7 @@ int main(int argc, const char **argv)\n \tconst char *cmd;\n \n \tmemset(&git_startup_info, 0, sizeof(git_startup_info));\n+\tgit_startup_info.use_pager = -1;\n \tstartup_info = &git_startup_info;\n \n \tcmd = git_extract_argv0_path(argv[0]);\n"},{"id":"139535","messageId":"20100415003803.GB14151@progeny.tock","threadId":"23437","inReplyTo":"7v4ojdpxls.fsf@alter.siamese.dyndns.org","subject":"[PATCH] t7006: guard cleanup with test_expect_success","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-15T00:38:07Z","receivedAt":"2010-04-15T00:38:07Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Most of these tests are removing files, environment variables, and\nconfiguration that might interfere outside the test.  Putting these\nclean-up commands in the test (in the same spirit as v1.7.1-rc0~59,\n2010-03-20) means that errors during setup will be caught quickly and\nnon-error text will be suppressed without -v.\n\nWhile at it, apply some other minor fixes:\n\n - do not rely on the shell to export variables defined with the same\n   command as a function call\n\n - avoid whitespace immediately after the > redirection operator, for\n   consistency with the style of other tests\n\nSigned-off-by: Jonathan Nieder <jrnieder@gmail.com>\n---\nJunio C Hamano wrote:\n\n> They are reasonable clean-up steps to start the real test (starting from\n> setting and exporting the pager) in a known good state, and as long as you\n> write them not to fail I don't see any reason to have them outside the\n> test.\n\nGood catch, thanks.  Here’s a patch for the existing test (against master).\n\n t/t7006-pager.sh |  149 ++++++++++++++++++++++++++++++++++++-----------------\n t/test-lib.sh    |   16 ++++++\n 2 files changed, 117 insertions(+), 48 deletions(-)\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex d9202d5..62595ab 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -4,17 +4,24 @@ test_description='Test automatic use of a pager.'\n \n . ./test-lib.sh\n \n-rm -f stdout_is_tty\n+cleanup_fail() {\n+\techo >&2 cleanup failed\n+\texit 1\n+}\n+\n test_expect_success 'set up terminal for tests' '\n+\trm -f stdout_is_tty ||\n+\tcleanup_fail &&\n+\n \tif test -t 1\n \tthen\n-\t\t: > stdout_is_tty\n+\t\t>stdout_is_tty\n \telif\n \t\ttest_have_prereq PERL &&\n \t\t\"$PERL_PATH\" \"$TEST_DIRECTORY\"/t7006/test-terminal.perl \\\n \t\t\tsh -c \"test -t 1\"\n \tthen\n-\t\t: > test_terminal_works\n+\t\t>test_terminal_works\n \tfi\n '\n \n@@ -32,53 +39,68 @@ else\n \tsay no usable terminal, so skipping some tests\n fi\n \n-unset GIT_PAGER GIT_PAGER_IN_USE\n-git config --unset core.pager\n-PAGER='cat > paginated.out'\n-export PAGER\n-\n test_expect_success 'setup' '\n+\tunset GIT_PAGER GIT_PAGER_IN_USE &&\n+\ttest_might_fail git config --unset core.pager &&\n+\n+\tPAGER=\"cat >paginated.out\" &&\n+\texport PAGER &&\n+\n \ttest_commit initial\n '\n \n-rm -f paginated.out\n test_expect_success TTY 'some commands use a pager' '\n+\trm -f paginated.out ||\n+\tcleanup_fail &&\n+\n \ttest_terminal git log &&\n \ttest -e paginated.out\n '\n \n-rm -f paginated.out\n test_expect_success TTY 'some commands do not use a pager' '\n+\trm -f paginated.out ||\n+\tcleanup_fail &&\n+\n \ttest_terminal git rev-list HEAD &&\n \t! test -e paginated.out\n '\n \n-rm -f paginated.out\n test_expect_success 'no pager when stdout is a pipe' '\n+\trm -f paginated.out ||\n+\tcleanup_fail &&\n+\n \tgit log | cat &&\n \t! test -e paginated.out\n '\n \n-rm -f paginated.out\n test_expect_success 'no pager when stdout is a regular file' '\n-\tgit log > file &&\n+\trm -f paginated.out ||\n+\tcleanup_fail &&\n+\n+\tgit log >file &&\n \t! test -e paginated.out\n '\n \n-rm -f paginated.out\n test_expect_success TTY 'git --paginate rev-list uses a pager' '\n+\trm -f paginated.out ||\n+\tcleanup_fail &&\n+\n \ttest_terminal git --paginate rev-list HEAD &&\n \ttest -e paginated.out\n '\n \n-rm -f file paginated.out\n test_expect_success 'no pager even with --paginate when stdout is a pipe' '\n+\trm -f file paginated.out ||\n+\tcleanup_fail &&\n+\n \tgit --paginate log | cat &&\n \t! test -e paginated.out\n '\n \n-rm -f paginated.out\n test_expect_success TTY 'no pager with --no-pager' '\n+\trm -f paginated.out ||\n+\tcleanup_fail &&\n+\n \ttest_terminal git --no-pager log &&\n \t! test -e paginated.out\n '\n@@ -86,88 +108,119 @@ test_expect_success TTY 'no pager with --no-pager' '\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-\tread firstline < $1\n+\tread firstline <$1\n \t! expr \"$firstline\" : \"^[a-zA-Z]\" >/dev/null\n }\n \n-rm -f colorful.log colorless.log\n test_expect_success 'tests can detect color' '\n-\tgit log --no-color > colorless.log &&\n-\tgit log --color > colorful.log &&\n+\trm -f colorful.log colorless.log ||\n+\tcleanup_fail &&\n+\n+\tgit log --no-color >colorless.log &&\n+\tgit log --color >colorful.log &&\n \t! colorful colorless.log &&\n \tcolorful colorful.log\n '\n \n-rm -f colorless.log\n-git config color.ui auto\n test_expect_success 'no color when stdout is a regular file' '\n-\tgit log > colorless.log &&\n+\trm -f colorless.log &&\n+\tgit config color.ui auto ||\n+\tcleanup_fail &&\n+\n+\tgit log >colorless.log &&\n \t! colorful colorless.log\n '\n \n-rm -f paginated.out\n-git config color.ui auto\n test_expect_success TTY 'color when writing to a pager' '\n-\tTERM=vt100 test_terminal git log &&\n+\trm -f paginated.out &&\n+\tgit config color.ui auto ||\n+\tcleanup_fail &&\n+\n+\t(\n+\t\tTERM=vt100 &&\n+\t\texport TERM &&\n+\t\ttest_terminal git log\n+\t) &&\n \tcolorful paginated.out\n '\n \n-rm -f colorful.log\n-git config color.ui auto\n test_expect_success 'color when writing to a file intended for a pager' '\n-\tTERM=vt100 GIT_PAGER_IN_USE=true git log > colorful.log &&\n+\trm -f colorful.log &&\n+\tgit config color.ui auto ||\n+\tcleanup_fail &&\n+\n+\t(\n+\t\tTERM=vt100 &&\n+\t\tGIT_PAGER_IN_USE=true &&\n+\t\texport TERM GIT_PAGER_IN_USE &&\n+\t\tgit log >colorful.log\n+\t) &&\n \tcolorful colorful.log\n '\n \n-unset PAGER GIT_PAGER\n-git config --unset core.pager\n test_expect_success 'determine default pager' '\n+\tunset PAGER GIT_PAGER &&\n+\ttest_might_fail git config --unset core.pager ||\n+\tcleanup_fail &&\n+\n \tless=$(git var GIT_PAGER) &&\n \ttest -n \"$less\"\n '\n \n-if expr \"$less\" : '^[a-z]*$' > /dev/null && test_have_prereq TTY\n+if expr \"$less\" : '^[a-z][a-z]*$' >/dev/null && test_have_prereq TTY\n then\n \ttest_set_prereq SIMPLEPAGER\n fi\n \n-unset PAGER GIT_PAGER\n-git config --unset core.pager\n-rm -f default_pager_used\n test_expect_success SIMPLEPAGER 'default pager is used by default' '\n-\tcat > $less <<-EOF &&\n-\t#!$SHELL_PATH\n-\twc > default_pager_used\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-\tPATH=.:$PATH test_terminal git log &&\n+\t(\n+\t\tPATH=.:$PATH &&\n+\t\texport PATH &&\n+\t\ttest_terminal git log\n+\t) &&\n \ttest -e default_pager_used\n '\n \n-unset GIT_PAGER\n-git config --unset core.pager\n-rm -f PAGER_used\n test_expect_success TTY 'PAGER overrides default pager' '\n-\tPAGER=\"wc > PAGER_used\" &&\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 \ttest_terminal git log &&\n \ttest -e PAGER_used\n '\n \n-unset GIT_PAGER\n-rm -f core.pager_used\n test_expect_success TTY '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+\tgit config core.pager \"wc >core.pager_used\" &&\n \ttest_terminal git log &&\n \ttest -e core.pager_used\n '\n \n-rm -f GIT_PAGER_used\n test_expect_success TTY '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 \ttest -e GIT_PAGER_used\ndiff --git a/t/test-lib.sh b/t/test-lib.sh\nindex c582964..f807625 100644\n--- a/t/test-lib.sh\n+++ b/t/test-lib.sh\n@@ -516,6 +516,22 @@ test_must_fail () {\n \ttest $? -gt 0 -a $? -le 129 -o $? -gt 192\n }\n \n+# Similar to test_must_fail, but tolerates success, too.  This is\n+# meant to be used in contexts like:\n+#\n+#\ttest_expect_success 'some command works without configuration' '\n+#\t\ttest_might_fail git config --unset all.configuration &&\n+#\t\tdo something\n+#\t'\n+#\n+# Writing \"git config --unset all.configuration || :\" would be wrong,\n+# because we want to notice if it fails due to segv.\n+\n+test_might_fail () {\n+\t\"$@\"\n+\ttest $? -ge 0 -a $? -le 129 -o $? -gt 192\n+}\n+\n # test_cmp is a helper function to compare actual and expected output.\n # You can use it like:\n #\n-- \n1.7.1.rc1.18.g08771.dirty\n"},{"id":"139539","messageId":"7v7ho9mt3a.fsf@alter.siamese.dyndns.org","threadId":"23437","inReplyTo":"20100415003803.GB14151@progeny.tock","subject":"Re: [PATCH] t7006: guard cleanup with test_expect_success","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2010-04-15T00:56:25Z","receivedAt":"2010-04-15T00:56:25Z","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> diff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\n> index d9202d5..62595ab 100755\n> --- a/t/t7006-pager.sh\n> +++ b/t/t7006-pager.sh\n> @@ -4,17 +4,24 @@ test_description='Test automatic use of a pager.'\n>  \n>  . ./test-lib.sh\n>  \n> -rm -f stdout_is_tty\n> +cleanup_fail() {\n> +\techo >&2 cleanup failed\n> +\texit 1\n> +}\n\nI think you meant to say \"false\" or \"(exit 1)\" here.  To see why...\n\n>  test_expect_success 'set up terminal for tests' '\n> +\trm -f stdout_is_tty ||\n> +\tcleanup_fail &&\n> +\n\n... try your patch with \"rm -f stdout_is_tty\" replaced with \"(exit 1)\" to\nsee how your cleanup_fail behaves.\n\nOther than that I like the general idea, especially \"might-fail\" is cute.\n"},{"id":"139542","messageId":"20100415012752.GA17132@progeny.tock","threadId":"23437","inReplyTo":"7v7ho9mt3a.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH] t7006: guard cleanup with test_expect_success","fromName":"Jonathan Nieder","fromEmail":"jrnieder@gmail.com","sentAt":"2010-04-15T01:27:52Z","receivedAt":"2010-04-15T01:27:52Z","isPatch":true,"sender":{"key":"jrnieder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/281595?v=4"},"body":"Junio C Hamano wrote:\n> Jonathan Nieder <jrnieder@gmail.com> writes:\n\n[...]\n>> +cleanup_fail() {\n>> +\techo >&2 cleanup failed\n>> +\texit 1\n>> +}\n>\n> I think you meant to say \"false\" or \"(exit 1)\" here.  To see why...\n[...]\n> ... try your patch with \"rm -f stdout_is_tty\" replaced with \"(exit 1)\" to\n> see how your cleanup_fail behaves.\n\nGood catch; thanks.  Here’s a patch for squashing in case you would\nlike one.\n\ndiff --git a/t/t7006-pager.sh b/t/t7006-pager.sh\nindex 62595ab..a3d0210 100755\n--- a/t/t7006-pager.sh\n+++ b/t/t7006-pager.sh\n@@ -6,7 +6,7 @@ test_description='Test automatic use of a pager.'\n \n cleanup_fail() {\n \techo >&2 cleanup failed\n-\texit 1\n+\treturn 1\n }\n \n test_expect_success 'set up terminal for tests' '\n"},{"id":"139564","messageId":"m2yfcaeb9bf1004150133te8af6155n63d620fef2be98a2@mail.gmail.com","threadId":"23437","inReplyTo":"20100414050643.GB28864@progeny.tock","subject":"Re: [PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-04-15T08:33:55Z","receivedAt":"2010-04-15T08:33:55Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Wed, Apr 14, 2010 at 7:06 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> So here are some ideas for future work (not necessarily in order).\n>\n>  - Teach remaining commands that need to search for a repository to\n>   use RUN_SETUP_GENTLY, with appropriate exceptions where needed\n>   (for --no-index, for example).\n\n - Two patches \"worktree setup: calculate prefix..\" and \"index-pack:\ntrust the prefix\" may form a separate series. That would unblock\nRUN_SETUP_GENTLY series.\n\n>  - Introduce unset_git_directory and the RUN_UNSETUP option (yes,\n>   this needs a better name).  Teach commands that work without a\n>   git directory to use it (this should fix the init poisoned by\n>   parent repository and aliased init problems).\n\n - Two patches that move enter_repo() to setup.c and fix it up can go\nfirst. They should have no impact on system.\n\n>\n>  - Teach git_config() to ignore the repository-specific configuration\n>   if have_run_setup is true but have_repository is false.\n>\n>  - Teach git_attr() to ignore .git/info/attributes if have_run_setup\n>   is true but have_repository is false.\n>\n>  - Teach git_config() to optionally die if have_run_setup is not true\n>   and the setup_git_dir* to optionally die if have_run_setup is true.\n>   test-lib.sh would enable this option.\n>\n\n - Introduce startup_info->prefix. I think that's a good change, but\nit's independent to this series. The reason is, prefix can change\nafter setup_git_dir is called (i.e. setup_work_tree()).\n - The fix for \"git cmd -h\" can make a separate series (4 patches)\n - Finally the soft guard patch and assorted fixups to avoid warnings.\n\nI'll reorder my tree and see if it looks good. Patches of this 9-patch\nseries will be untouched.\n-- \nDuy\n"},{"id":"139603","messageId":"q2rfcaeb9bf1004151043v5a8e5634z159b6fa01f859f7e@mail.gmail.com","threadId":"23437","inReplyTo":"20100415084925.GA14660@progeny.tock","subject":"Re: [PATCH 8/9] builtin: check pager.<cmd> configuration if RUN_SETUP_GENTLY is used","fromName":"Nguyen Thai Ngoc Duy","fromEmail":"pclouds@gmail.com","sentAt":"2010-04-15T17:43:49Z","receivedAt":"2010-04-15T17:43:49Z","isPatch":true,"sender":{"key":"pclouds@gmail.com","avatar":"https://avatars.githubusercontent.com/u/720?v=4"},"body":"On Thu, Apr 15, 2010 at 10:49 AM, Jonathan Nieder <jrnieder@gmail.com> wrote:\n> FWIW, my latest is at\n>\n>  git://repo.or.cz/git/jrn nd/setup/chapter-one\n>\n> Changes since the last series I sent to the list:\n>\n>  - test cleanups, after Junio’s feedback\n>  - clarified commit messages, I hope\n>\n> If you’ve already started cleaning up or if something in the diff looks\n> iffy, feel free to carry on with what you have.  I don’t want the test\n> changes to interfere with more productive work.\n>\n> Looking forward to watching this evolve,\n\nOK. Here is the topic breakdown into 11 sub-topics, after rebasing on\nsetup/chapter-one. Patches 1, 2-3, 4-5, 8-9, 10-12, 13-18 can go as\nseparate independent sub-topics, given that chapter-one is accepted.\nThe rest must go in sequence because they will need some of previous\ngroups. Commit messages aren't cleaned up yet, just the idea of\ngrouping.\n\nPatches available at git://repo.or.cz/git/pclouds.git tp/setup\n\n     1\trev-parse --git-dir: print relative gitdir correctly\n\nThis will become a problem when patches 37-43 (let's name it\n\"unset_git_directory\") is merged. Other than that, it's can go alone.\n\n     2\tworktree setup: calculate prefix even if no worktree is found\n     3\tindex-pack: trust the prefix returned by setup_git_directory_gently()\n\nThis is debatable, as you pointed out, because it changes \"git\nrev-parse --show-prefix\" behavior. This is a prerequisite for 19-36\n(run-setup-gently)\n\n     4\tMove enter_repo() to setup.c\n     5\tenter_repo(): initialize other variables as\nsetup_git_directory_gently() does\n\nGood thing. Quite simple. Prerequisite for 6-7 (have_run_setup)\n\n     6\tbuiltin: remember whether repository has been searched for\n     7\tbuiltins: setup repository before print unknown command error\n\nIntroduce startup_info->have_run_setup_gitdir, and a guard in command\nerror printing.\n\n     8\tsetup: save prefix (original cwd relative to toplevel) in startup_info\n     9\tbuiltin: remove prefix variable from run_builtin()\n\nIntroduce startup_info->prefix. Will be needed for 47-48 (alias fix)\nbecause setup_git_dir may be called in one place, and unset_git_dir is\ncalled in another place.\n\n    10\trun_builtin(): save \"-h\" detection result for later use\n    11\tbuiltins: utilize startup_info->help where possible\n    12\tbuiltins: check for startup_info->help, print and exit early\n\nFix \"git cmd -h\" shortcut. There will be warnings from git_config()\nonce the old \"guard unallowed access\" patch is in. It will be fixed in\npatch 45.\n\n    13\tinit/clone: turn on startup->have_repository properly\n    14\tt7002: test git grep --no-index from a bare repository\n    15\tDo not read .git/info/exclude if there is no repository\n    16\tDo not read .git/info/attributes if there is no repository\n    17\tapply: do not check sha1 if there is no repository\n    18\tconfig: do not read .git/config if there is no repository\n\nAssorted fixes wrt unconditional access to .git/. All these patches\nsimple add \"if (have_repository)\" or so.\n\n    19\tt0001: test git init when run via an alias\n    20\tt5512: test that ls-remote does not require a git repository\n    21\tt7006: expose test_terminal() for use by other tests\n    22\thelp: note why it is appropriate for this command not to use\nRUN_SETUP_GENTLY\n    23\thash-object: use RUN_SETUP_GENTLY\n    24\tshortlog: use RUN_SETUP_GENTLY\n    25\tgrep: use RUN_SETUP_GENTLY\n    26\tarchive: use RUN_SETUP_GENTLY\n    27\tmailinfo: use RUN_SETUP_GENTLY\n    28\tcheck-ref-format: use RUN_SETUP_GENTLY\n    29\tverify-pack: use RUN_SETUP_GENTLY\n    30\tapply: use RUN_SETUP_GENTLY\n    31\tbundle: use RUN_SETUP_GENTLY\n    32\tdiff: use RUN_SETUP_GENTLY\n    33\tls-remote: use RUN_SETUP_GENTLY\n    34\tvar: use RUN_SETUP_GENTLY\n    35\tmerge-file: use RUN_SETUP_GENTLY\n    36\tindex-pack: use RUN_SETUP_GENTLY\n\nThe RUN_SETUP_GENTLY series. Of course these will need to be reviewed,\nsome commands might need finer-grain setup.\n\n    37\tAdd git_config_early()\n    38\tt1300: test that scripted commands do not respect stray .git/config\n    39\tgit_config(): do not read .git/config if there is no repository\n    40\tUse git_config_early() instead of git_config() during repo setup\n    41\tworktree setup: call set_git_dir explicitly\n    42\tworktree setup: restore original state when things go wrong\n    43\tAllow to undo setup_git_directory_gently() gracefully (and fix\nalias code)\n\nThe unset_git_directory series. Make setup_git_directory() work right.\n\n    44\tGuard unallowed access to repository when it's not set up\n    45\trun_builtin: do now raise alarms\n    46\tsetup_work_tree: do not raise alarm\n\nPut unallowed access warnings in place. Also fixes false alarms.\n\n    47\talias: keep repository found while collecting aliases as long as possible\n    48\trun_builtin: respect have_run_setup_gitdir\n\nFix alias related setup problem.\n\nInsane?\n-- \nDuy\n"}]}