{"thread":{"id":"41817","subject":"[GSoC] Proposal","startedAt":"2016-03-24T21:09:46Z","lastAt":"2016-03-25T07:01:26Z","messageCount":6,"participants":["XZS","Junio C Hamano","Dominik Fischer","Christian Couder"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"281723","messageId":"1458853787-29807-1-git-send-email-d.f.fischer@web.de","threadId":"41817","inReplyTo":null,"subject":"[GSoC] Proposal","fromName":"XZS","fromEmail":"d.f.fischer@web.de","sentAt":"2016-03-24T21:09:46Z","receivedAt":"2016-03-24T21:09:46Z","isPatch":false,"sender":{"key":"d.f.fischer@web.de","avatar":null},"body":"Greetings,\n\nI hope it is not yet too late to jump on the Summer of Code bandwagon.\n\nI would appreciate comments on my application [1] and my microproject\ncontribution, which will follow this mail as a reply.\n\nMy proposal mostly stems from what was noted under \"convert scripts to\nbuiltins\" and \"git rebase improvements\" in the ideas page. Both list no mentor,\nso please let me know if you know anyone who should be mentioned in CC.\n\nRegards,\nXZS.\n\n\n[1]: https://docs.google.com/document/d/1-BV-s5VUGTvBlcVDeo6tVqQO5D1hqeQDqaf37iYuIfU/edit?usp=sharing\n-- \n2.7.4\n"},{"id":"281724","messageId":"1458853787-29807-2-git-send-email-d.f.fischer@web.de","threadId":"41817","inReplyTo":"1458853787-29807-1-git-send-email-d.f.fischer@web.de","subject":"[PATCH/GSoC] add a add.patch config variable","fromName":"XZS","fromEmail":"d.f.fischer@web.de","sentAt":"2016-03-24T21:09:47Z","receivedAt":"2016-03-24T21:09:47Z","isPatch":true,"sender":{"key":"d.f.fischer@web.de","avatar":null},"body":"Users may like to review their changes when staging by default. It is\nalso a convenient safety feature for beginners nudging them to have a\nsecond look at their changes when composing a commit.\n\nTo this end, the config variable allows to have git-add to always act\nlike -p was passed.\n\nSigned-off-by: XZS <d.f.fischer@web.de>\n---\nThe list of microproject suggestions for the Summer of Code 2016 proposed to\n\"add configuration options for some commonly used command-line options\", so I\nadded a configuraion variable for an option I use all the time.\n\n Documentation/config.txt               | 5 +++++\n Documentation/git-add.txt              | 3 +++\n builtin/add.c                          | 3 +++\n contrib/completion/git-completion.bash | 1 +\n t/t3701-add-interactive.sh             | 9 +++++++++\n 5 files changed, 21 insertions(+)\n\ndiff --git a/Documentation/config.txt b/Documentation/config.txt\nindex 2cd6bdd..614c599 100644\n--- a/Documentation/config.txt\n+++ b/Documentation/config.txt\n@@ -752,6 +752,11 @@ add.ignore-errors (deprecated)::\n \tas it does not follow the usual naming convention for configuration\n \tvariables.\n \n+add.patch::\n+\tConfigures 'git add' to always interactively choose hunks, hinting the\n+\tuser to review changes before staging.  This is equivalent to adding the\n+\t'--patch' option to linkgit:git-add[1].\n+\n alias.*::\n \tCommand aliases for the linkgit:git[1] command wrapper - e.g.\n \tafter defining \"alias.last = cat-file commit HEAD\", the invocation\ndiff --git a/Documentation/git-add.txt b/Documentation/git-add.txt\nindex 6a96a66..cdb6663 100644\n--- a/Documentation/git-add.txt\n+++ b/Documentation/git-add.txt\n@@ -92,6 +92,9 @@ OPTIONS\n This effectively runs `add --interactive`, but bypasses the\n initial command menu and directly jumps to the `patch` subcommand.\n See ``Interactive mode'' for details.\n++\n+The configuration variable `add.patch` can be set to true to make\n+this the default behaviour.\n \n -e::\n --edit::\ndiff --git a/builtin/add.c b/builtin/add.c\nindex 145f06e..04f8b5e 100644\n--- a/builtin/add.c\n+++ b/builtin/add.c\n@@ -272,6 +272,9 @@ static int add_config(const char *var, const char *value, void *cb)\n \t    !strcmp(var, \"add.ignore-errors\")) {\n \t\tignore_add_errors = git_config_bool(var, value);\n \t\treturn 0;\n+\t} else if (!strcmp(var, \"add.patch\")) {\n+\t\tpatch_interactive = git_config_bool(var, value);\n+\t\treturn 0;\n \t}\n \treturn git_default_config(var, value, cb);\n }\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex e3918c8..597d20f 100644\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1969,6 +1969,7 @@ _git_config ()\n \tesac\n \t__gitcomp \"\n \t\tadd.ignoreErrors\n+\t\tadd.patch\n \t\tadvice.commitBeforeMerge\n \t\tadvice.detachedHead\n \t\tadvice.implicitIdentity\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex deae948..25e4b2e 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -380,4 +380,13 @@ test_expect_success 'patch mode ignores unmerged entries' '\n \ttest_cmp expected diff\n '\n \n+test_expect_success 'patch mode can be activated per option' '\n+  git config add.patch true &&\n+  git reset --hard &&\n+  echo change >test &&\n+  echo y | git add -p > output &&\n+  cat output &&\n+  grep \"Stage this hunk \\[y,n,q,a,d,/,e,?\\]?\" output\n+'\n+\n test_done\n-- \n2.7.4\n"},{"id":"281726","messageId":"xmqqvb4b7eu9.fsf@gitster.mtv.corp.google.com","threadId":"41817","inReplyTo":"1458853787-29807-2-git-send-email-d.f.fischer@web.de","subject":"Re: [PATCH/GSoC] add a add.patch config variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-03-24T21:20:30Z","receivedAt":"2016-03-24T21:20:30Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"XZS <d.f.fischer@web.de> writes:\n\n> Users may like to review their changes when staging by default. It is\n> also a convenient safety feature for beginners nudging them to have a\n> second look at their changes when composing a commit.\n>\n> To this end, the config variable allows to have git-add to always act\n> like -p was passed.\n\nNow with such a configuration in her ~/.gitconfig, how would she\never run the normal \"git add\", which perhaps is invoked by one of\nthe scripts she regularly uses?  E.g. \"git mergetool\"?\n"},{"id":"281762","messageId":"56F489C3.9050400@web.de","threadId":"41817","inReplyTo":"xmqqvb4b7eu9.fsf@gitster.mtv.corp.google.com","subject":"Re: [PATCH/GSoC] add a add.patch config variable","fromName":"Dominik Fischer","fromEmail":"d.f.fischer@web.de","sentAt":"2016-03-25T00:43:47Z","receivedAt":"2016-03-25T00:43:47Z","isPatch":true,"sender":{"key":"d.f.fischer@web.de","avatar":null},"body":"Am 24.03.2016 um 22:20 schrieb Junio C Hamano:\n> XZS <d.f.fischer@web.de> writes:\n>> Users may like to review their changes when staging by default. It is\n>> also a convenient safety feature for beginners nudging them to have a\n>> second look at their changes when composing a commit.\n>>\n>> To this end, the config variable allows to have git-add to always act\n>> like -p was passed.\n>\n> Now with such a configuration in her ~/.gitconfig, how would she\n> ever run the normal \"git add\", which perhaps is invoked by one of\n> the scripts she regularly uses?  E.g. \"git mergetool\"?\n\nAs the configuration variable can be overwritten by a command line \noption, I am tempted to amend this by replacing all occurrences of \"git \nadd\" in other scripts with \"git add --no-patch\" to ensure the expected \nbehavior.\n\nBut this would introduce changes into a vast number of points in the \ncode. Apart from that, I suspect other options may have the same reason \nnot to be available as config variables. It would be much better if \ngit-add could ignore the variable when called internally, only taking it \ninto account when used as an entrypoint.\n\nIs there already a mechanism in place to determine if git was called by \ngit? If not, I could implement one through an environment variable that \ncounts up on each git invocation, essentially providing a git recursion \ncounter.\n"},{"id":"281778","messageId":"xmqqio0b5ash.fsf@gitster.mtv.corp.google.com","threadId":"41817","inReplyTo":"56F489C3.9050400@web.de","subject":"Re: [PATCH/GSoC] add a add.patch config variable","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2016-03-25T06:30:54Z","receivedAt":"2016-03-25T06:30:54Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"Dominik Fischer <d.f.fischer@web.de> writes:\n\n> As the configuration variable can be overwritten by a command line\n> option, I am tempted to amend this by replacing all occurrences of\n> \"git add\" in other scripts with \"git add --no-patch\" to ensure the\n> expected behavior.\n\nDon't even think about it--you won't know all scripts you have to\nfix like that, as a lot more invocations of \"git add\" appear in end\nuser's scripts that we have never seen.\n"},{"id":"281780","messageId":"CAP8UFD0KZk1nTgR8gdbedsAuw2ztWZDWri6EkeEkf8FhwS9yag@mail.gmail.com","threadId":"41817","inReplyTo":"1458853787-29807-2-git-send-email-d.f.fischer@web.de","subject":"Re: [PATCH/GSoC] add a add.patch config variable","fromName":"Christian Couder","fromEmail":"christian.couder@gmail.com","sentAt":"2016-03-25T07:01:26Z","receivedAt":"2016-03-25T07:01:26Z","isPatch":true,"sender":{"key":"christian.couder@gmail.com","avatar":"https://avatars.githubusercontent.com/u/208954?v=4"},"body":"On Thu, Mar 24, 2016 at 10:09 PM, XZS <d.f.fischer@web.de> wrote:\n>\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index deae948..25e4b2e 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -380,4 +380,13 @@ test_expect_success 'patch mode ignores unmerged entries' '\n>         test_cmp expected diff\n>  '\n>\n> +test_expect_success 'patch mode can be activated per option' '\n> +  git config add.patch true &&\n> +  git reset --hard &&\n> +  echo change >test &&\n> +  echo y | git add -p > output &&\n\nWhy are you using \"-p\" if you want to test that the config option works?\n\n> +  cat output &&\n> +  grep \"Stage this hunk \\[y,n,q,a,d,/,e,?\\]?\" output\n> +'\n> +\n>  test_done\n"}]}