{"thread":{"id":"34093","subject":"[PATCH v3 2/2] status:introduce status.branch to enable --branch by default","startedAt":"2013-06-10T15:27:47Z","lastAt":"2013-06-10T18:29:14Z","messageCount":5,"participants":["Jorge Juan Garcia Garcia","Junio C Hamano","Matthieu Moy"],"isPatch":true,"patchVersion":3,"patchTotal":2},"messages":[{"id":"220303","messageId":"1370878068-7643-1-git-send-email-Jorge-Juan.Garcia-Garcia@ensimag.imag.fr","threadId":"34093","inReplyTo":null,"subject":"[PATCH v3 1/2] status: introduce status.short to enable --short by default","fromName":"Jorge Juan Garcia Garcia","fromEmail":"jorge-juan.garcia-garcia@ensimag.imag.fr","sentAt":"2013-06-10T15:27:47Z","receivedAt":"2013-06-10T15:27:47Z","isPatch":true,"sender":{"key":"jorge-juan.garcia-garcia@ensimag.imag.fr","avatar":null},"body":"Some people always run 'git status -s'.\nThe configuration variable status.short allows to set it by default.\n\nSigned-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>\nSigned-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\n---\n\nChanges since v2:\n -removal of double quotes in test\n -use of git config --unset to clean up test environment\n\n Documentation/config.txt |    4 ++++\n builtin/commit.c         |    5 +++++\n t/t7508-status.sh        |   35 +++++++++++++++++++++++++++++++++++\n 3 files changed, 44 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 6e53fc5..1983bf7 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2066,6 +2066,10 @@ status.relativePaths::\n \trelative to the repository root (this was the default for Git\n \tprior to v1.5.4).\n \n+status.short::\n+\tSet to true to enable --short by default in linkgit:git-status[1].\n+\tThe option --no-short takes precedence over this variable.\n+\n status.showUntrackedFiles::\n \tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n \tfiles which are not currently tracked by Git. Directories which\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 1621dfc..287f1cb 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1112,6 +1112,11 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\t\ts->submodule_summary = -1;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"status.short\")) {\n+\t\tif (git_config_bool(k, v))\n+\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n \t\ts->use_color = git_config_colorbool(k, v);\n \t\treturn 0;\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex e2ffdac..d99ca9f 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1335,4 +1335,39 @@ test_expect_failure '.git/config ignore=all suppresses submodule summary' '\n \tgit config -f .gitmodules  --remove-section submodule.subname\n '\n \n+test_expect_success 'Setup of test environment' '\n+\tgit config status.showUntrackedFiles no\n+'\n+\n+test_expect_success '\"status.short=true\" same as \"-s\"' '\n+\tgit -c status.short=true status >actual &&\n+\tgit status -s >expected_short &&\n+\ttest_cmp actual expected_short\n+'\n+\n+test_expect_success '\"status.short=true\" different from \"--no-short\"' '\n+\tgit status --no-short >expected_noshort &&\n+\ttest_must_fail test_cmp actual expected_noshort\n+'\n+\n+test_expect_success '\"status.short=true\" weaker than \"--no-short\"' '\n+\tgit -c status.short=true status --no-short >actual &&\n+\ttest_cmp actual expected_noshort\n+'\n+\n+test_expect_success '\"status.short=false\" same as \"--no-short\"' '\n+\tgit -c status.short=false status >actual &&\n+\tgit status -s >expected_short &&\n+\ttest_cmp actual expected_noshort\n+'\n+\n+test_expect_success '\"status.short=false\" weaker than \"-s\"' '\n+\tgit -c status.short=false status -s >actual &&\n+\ttest_cmp actual expected_short\n+'\n+\n+test_expect_success 'Restore default test environment' '\n+\tgit config --unset status.showUntrackedFiles\n+'\n+\n test_done\n-- \n1.7.8\n"},{"id":"220302","messageId":"1370878068-7643-2-git-send-email-Jorge-Juan.Garcia-Garcia@ensimag.imag.fr","threadId":"34093","inReplyTo":"1370878068-7643-1-git-send-email-Jorge-Juan.Garcia-Garcia@ensimag.imag.fr","subject":"[PATCH v3 2/2] status:introduce status.branch to enable --branch by default","fromName":"Jorge Juan Garcia Garcia","fromEmail":"jorge-juan.garcia-garcia@ensimag.imag.fr","sentAt":"2013-06-10T15:27:48Z","receivedAt":"2013-06-10T15:27:48Z","isPatch":true,"sender":{"key":"jorge-juan.garcia-garcia@ensimag.imag.fr","avatar":null},"body":"Some people often run 'git status -b'.\nThe config variable status.branch allows to set it by default.\n\nSigned-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>\nSigned-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>\nSigned-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\n---\n\nChanges since v2:\n -removal of double quotes in test\n\n Documentation/config.txt |    4 ++++\n builtin/commit.c         |    4 ++++\n t/t7508-status.sh        |   27 +++++++++++++++++++++++++++\n 3 files changed, 35 insertions(+), 0 deletions(-)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 1983bf7..ecdcd6d 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -2070,6 +2070,10 @@ status.short::\n \tSet to true to enable --short by default in linkgit:git-status[1].\n \tThe option --no-short takes precedence over this variable.\n \n+status.branch::\n+\tSet to true to enable --branch by default in linkgit:git-status[1].\n+\tThe option --no-branch takes precedence over this variable.\n+\n status.showUntrackedFiles::\n \tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n \tfiles which are not currently tracked by Git. Directories which\ndiff --git a/builtin/commit.c b/builtin/commit.c\nindex 287f1cb..f2b5d44 100644\n--- a/builtin/commit.c\n+++ b/builtin/commit.c\n@@ -1117,6 +1117,10 @@ static int git_status_config(const char *k, const char *v, void *cb)\n \t\t\tstatus_format = STATUS_FORMAT_SHORT;\n \t\treturn 0;\n \t}\n+\tif (!strcmp(k, \"status.branch\")) {\n+\t\ts->show_branch = git_config_bool(k, v);\n+\t\treturn 0;\n+\t}\n \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n \t\ts->use_color = git_config_colorbool(k, v);\n \t\treturn 0;\ndiff --git a/t/t7508-status.sh b/t/t7508-status.sh\nindex d99ca9f..5e6df95 100755\n--- a/t/t7508-status.sh\n+++ b/t/t7508-status.sh\n@@ -1366,6 +1366,33 @@ test_expect_success '\"status.short=false\" weaker than \"-s\"' '\n \ttest_cmp actual expected_short\n '\n \n+test_expect_success '\"status.branch=true\" same as \"-b\"' '\n+\tgit -c status.branch=true status -s >actual &&\n+\tgit status -sb >expected_branch &&\n+\ttest_cmp actual expected_branch\n+'\n+\n+test_expect_success '\"status.branch=true\" different from \"--no-branch\"' '\n+\tgit -c status.branch=true status -s >actual &&\n+\tgit status -s --no-branch  >expected_nobranch &&\n+\ttest_must_fail test_cmp actual expected_nobranch\n+'\n+\n+test_expect_success '\"status.branch=true\" weaker than \"--no-branch\"' '\n+\tgit -c status.branch=true status -s --no-branch >actual &&\n+\ttest_cmp actual expected_nobranch\n+'\n+\n+test_expect_success '\"status.branch=false\" same as \"--no-branch\"' '\n+\tgit -c status.branch=false status -s >actual &&\n+\ttest_cmp actual expected_nobranch\n+'\n+\n+test_expect_success '\"status.branch=false\" weaker than \"-b\"' '\n+\tgit -c status.branch=false status -sb >actual &&\n+\ttest_cmp actual expected_branch\n+'\n+\n test_expect_success 'Restore default test environment' '\n \tgit config --unset status.showUntrackedFiles\n '\n-- \n1.7.8\n"},{"id":"220338","messageId":"7vr4g9j0gh.fsf@alter.siamese.dyndns.org","threadId":"34093","inReplyTo":"1370878068-7643-1-git-send-email-Jorge-Juan.Garcia-Garcia@ensimag.imag.fr","subject":"Re: [PATCH v3 1/2] status: introduce status.short to enable --short by default","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-10T18:16:14Z","receivedAt":"2013-06-10T18:16:14Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jorge Juan Garcia Garcia  <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>\nwrites:\n\n> Some people always run 'git status -s'.\n> The configuration variable status.short allows to set it by default.\n>\n> Signed-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>\n> Signed-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\n> ---\n>\n> Changes since v2:\n>  -removal of double quotes in test\n>  -use of git config --unset to clean up test environment\n>\n>  Documentation/config.txt |    4 ++++\n>  builtin/commit.c         |    5 +++++\n>  t/t7508-status.sh        |   35 +++++++++++++++++++++++++++++++++++\n>  3 files changed, 44 insertions(+), 0 deletions(-)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 6e53fc5..1983bf7 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -2066,6 +2066,10 @@ status.relativePaths::\n>  \trelative to the repository root (this was the default for Git\n>  \tprior to v1.5.4).\n>  \n> +status.short::\n> +\tSet to true to enable --short by default in linkgit:git-status[1].\n> +\tThe option --no-short takes precedence over this variable.\n> +\n>  status.showUntrackedFiles::\n>  \tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n>  \tfiles which are not currently tracked by Git. Directories which\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index 1621dfc..287f1cb 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1112,6 +1112,11 @@ static int git_status_config(const char *k, const char *v, void *cb)\n>  \t\t\ts->submodule_summary = -1;\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(k, \"status.short\")) {\n> +\t\tif (git_config_bool(k, v))\n> +\t\t\tstatus_format = STATUS_FORMAT_SHORT;\n\nAnd if the user has\n\n\t[status]\n        \tshort = no\n\nin $GIT_DIR/config for this particular project, perhaps in order to\noverride a blanket setting\n\n\t[status]\n\t\tshort\n\nthat is in $HOME/.gitconfig, what should happen?\n\nPerhaps you need\n\n\tif (git_config_bool(...))\n        \tstatus_format = STATUS_FORMAT_SHORT;\n\telse        \t\n        \tstatus_format = STATUS_FORMAT_NONE; /* default */\n\nor something here?\n\n> +\t\treturn 0;\n> +\t}\n>  \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n>  \t\ts->use_color = git_config_colorbool(k, v);\n>  \t\treturn 0;\n> diff --git a/t/t7508-status.sh b/t/t7508-status.sh\n> index e2ffdac..d99ca9f 100755\n> --- a/t/t7508-status.sh\n> +++ b/t/t7508-status.sh\n> @@ -1335,4 +1335,39 @@ test_expect_failure '.git/config ignore=all suppresses submodule summary' '\n>  \tgit config -f .gitmodules  --remove-section submodule.subname\n>  '\n>  \n> +test_expect_success 'Setup of test environment' '\n> +\tgit config status.showUntrackedFiles no\n> +'\n> +\n> +test_expect_success '\"status.short=true\" same as \"-s\"' '\n> +\tgit -c status.short=true status >actual &&\n> +\tgit status -s >expected_short &&\n> +\ttest_cmp actual expected_short\n> +'\n> +\n> +test_expect_success '\"status.short=true\" different from \"--no-short\"' '\n> +\tgit status --no-short >expected_noshort &&\n> +\ttest_must_fail test_cmp actual expected_noshort\n> +'\n> +\n> +test_expect_success '\"status.short=true\" weaker than \"--no-short\"' '\n> +\tgit -c status.short=true status --no-short >actual &&\n> +\ttest_cmp actual expected_noshort\n> +'\n> +\n> +test_expect_success '\"status.short=false\" same as \"--no-short\"' '\n> +\tgit -c status.short=false status >actual &&\n> +\tgit status -s >expected_short &&\n> +\ttest_cmp actual expected_noshort\n> +'\n> +\n> +test_expect_success '\"status.short=false\" weaker than \"-s\"' '\n> +\tgit -c status.short=false status -s >actual &&\n> +\ttest_cmp actual expected_short\n> +'\n> +\n> +test_expect_success 'Restore default test environment' '\n> +\tgit config --unset status.showUntrackedFiles\n> +'\n\nA few observations.\n\n * It is very good that you check not just positive cases that show\n   off how well this new feature works (i.e. status.short set\n   without command line override gives a short output) but also\n   negative cases that make sure the new feature does not kick in\n   when it should not.  You test all four combinations, which is\n   good.\n\n * If any of the first three fails, you may not have the correct\n   string in expected_short or expected_noshort when running later\n   tests that depend on them.\n\n * Similarly, if the first one to set showUntrackedFiles fails, the\n   last one to --unset would also fail.\n\nPerhaps limiting the number of tests that must pass (otherwise the\nremainder becomes useless) by doing something like this is a better\nalternative:\n\n\n\ttest_expect_success 'setup for status.short' '\n\t\tgit status --short >expected_short &&\n                git status --no-short >expected_noshort\n\t'\n\n\ttest_expect_success '-c status.short=true == status -s' '\n        \ttest_config status.showUntrackedFile no &&\n        \ttest_config status.short yes &&\n                git status >actual &&\n                test_cmp expected_short actual\n\t'\n\n\ttest_expect_success 'status --no-short defeats status.short=true' '\n        \ttest_config status.showUntrackedFile no &&\n        \ttest_config status.short yes &&\n                git status --no-short >actual &&\n                test_cmp expected_noshort actual\n\t'\n\n\t... other two combinations here ...\n\nPoints to note:\n\n * test_config takes care of setting configuration variables and\n   then unsetting them when the test is done.\n\n * test_cmp should compare expected with actual, not the other way,\n   so that \"./t7508-status.sh -v\" shows the diff between the two \n   shows how the actual output differs from what is expected.\n"},{"id":"220339","messageId":"7vmwqxj0dt.fsf@alter.siamese.dyndns.org","threadId":"34093","inReplyTo":"1370878068-7643-2-git-send-email-Jorge-Juan.Garcia-Garcia@ensimag.imag.fr","subject":"Re: [PATCH v3 2/2] status:introduce status.branch to enable --branch by default","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2013-06-10T18:17:50Z","receivedAt":"2013-06-10T18:17:50Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Jorge Juan Garcia Garcia  <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>\nwrites:\n\n> Some people often run 'git status -b'.\n> The config variable status.branch allows to set it by default.\n>\n> Signed-off-by: Jorge Juan Garcia Garcia <Jorge-Juan.Garcia-Garcia@ensimag.imag.fr>\n> Signed-off-by: Mathieu Lienard--Mayor <Mathieu.Lienard--Mayor@ensimag.imag.fr>\n> Signed-off-by: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>\n> ---\n>\n> Changes since v2:\n>  -removal of double quotes in test\n>\n>  Documentation/config.txt |    4 ++++\n>  builtin/commit.c         |    4 ++++\n>  t/t7508-status.sh        |   27 +++++++++++++++++++++++++++\n>  3 files changed, 35 insertions(+), 0 deletions(-)\n>\n> diff --git a/Documentation/config.txt b/Documentation/config.txt\n> index 1983bf7..ecdcd6d 100644\n> --- a/Documentation/config.txt\n> +++ b/Documentation/config.txt\n> @@ -2070,6 +2070,10 @@ status.short::\n>  \tSet to true to enable --short by default in linkgit:git-status[1].\n>  \tThe option --no-short takes precedence over this variable.\n>  \n> +status.branch::\n> +\tSet to true to enable --branch by default in linkgit:git-status[1].\n> +\tThe option --no-branch takes precedence over this variable.\n> +\n>  status.showUntrackedFiles::\n>  \tBy default, linkgit:git-status[1] and linkgit:git-commit[1] show\n>  \tfiles which are not currently tracked by Git. Directories which\n> diff --git a/builtin/commit.c b/builtin/commit.c\n> index 287f1cb..f2b5d44 100644\n> --- a/builtin/commit.c\n> +++ b/builtin/commit.c\n> @@ -1117,6 +1117,10 @@ static int git_status_config(const char *k, const char *v, void *cb)\n>  \t\t\tstatus_format = STATUS_FORMAT_SHORT;\n>  \t\treturn 0;\n>  \t}\n> +\tif (!strcmp(k, \"status.branch\")) {\n> +\t\ts->show_branch = git_config_bool(k, v);\n\nThis one, unlike 1/2, acts correctly when status.branch is set to\nno.  Good.\n\nThe same comments as 1/2 apply to the test script additions in this\npatch.\n\n> +\t\treturn 0;\n> +\t}\n>  \tif (!strcmp(k, \"status.color\") || !strcmp(k, \"color.status\")) {\n>  \t\ts->use_color = git_config_colorbool(k, v);\n>  \t\treturn 0;\n> diff --git a/t/t7508-status.sh b/t/t7508-status.sh\n> index d99ca9f..5e6df95 100755\n> --- a/t/t7508-status.sh\n> +++ b/t/t7508-status.sh\n> @@ -1366,6 +1366,33 @@ test_expect_success '\"status.short=false\" weaker than \"-s\"' '\n>  \ttest_cmp actual expected_short\n>  '\n>  \n> +test_expect_success '\"status.branch=true\" same as \"-b\"' '\n> +\tgit -c status.branch=true status -s >actual &&\n> +\tgit status -sb >expected_branch &&\n> +\ttest_cmp actual expected_branch\n> +'\n> +\n> +test_expect_success '\"status.branch=true\" different from \"--no-branch\"' '\n> +\tgit -c status.branch=true status -s >actual &&\n> +\tgit status -s --no-branch  >expected_nobranch &&\n> +\ttest_must_fail test_cmp actual expected_nobranch\n> +'\n> +\n> +test_expect_success '\"status.branch=true\" weaker than \"--no-branch\"' '\n> +\tgit -c status.branch=true status -s --no-branch >actual &&\n> +\ttest_cmp actual expected_nobranch\n> +'\n> +\n> +test_expect_success '\"status.branch=false\" same as \"--no-branch\"' '\n> +\tgit -c status.branch=false status -s >actual &&\n> +\ttest_cmp actual expected_nobranch\n> +'\n> +\n> +test_expect_success '\"status.branch=false\" weaker than \"-b\"' '\n> +\tgit -c status.branch=false status -sb >actual &&\n> +\ttest_cmp actual expected_branch\n> +'\n> +\n>  test_expect_success 'Restore default test environment' '\n>  \tgit config --unset status.showUntrackedFiles\n>  '\n"},{"id":"220342","messageId":"vpq1u89ddl1.fsf@anie.imag.fr","threadId":"34093","inReplyTo":"7vr4g9j0gh.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCH v3 1/2] status: introduce status.short to enable --short by default","fromName":"Matthieu Moy","fromEmail":"matthieu.moy@grenoble-inp.fr","sentAt":"2013-06-10T18:29:14Z","receivedAt":"2013-06-10T18:29:14Z","isPatch":true,"sender":{"key":"matthieu.moy@grenoble-inp.fr","avatar":"https://gravatar.com/avatar/72c8a2705971a25dfaff23cece15130d405685845d911aedd5667ace277f3fc5?d=mp&s=160"},"body":"Junio C Hamano <gitster@pobox.com> writes:\n\n> \ttest_expect_success '-c status.short=true == status -s' '\n>         \ttest_config status.showUntrackedFile no &&\n\nThat's an option, but having status.showUntrackedFile set in a separate\nsetup test makes the actual tests shorter. The setup test has no reason\nto fail, so I find it OK.\n\n-- \nMatthieu Moy\nhttp://www-verimag.imag.fr/~moy/\n"}]}