{"thread":{"id":"51898","subject":"[PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt","startedAt":"2019-09-23T07:26:56Z","lastAt":"2019-10-04T05:52:42Z","messageCount":11,"participants":["Kunal Tyagi via GitGitGadget","Johannes Schindelin","Junio C Hamano"],"isPatch":true,"patchVersion":1,"patchTotal":1},"messages":[{"id":"382746","messageId":"pull.349.git.gitgitgadget@gmail.com","threadId":"51898","inReplyTo":null,"subject":"[PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Kunal Tyagi via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-23T07:26:53Z","receivedAt":"2019-09-23T07:26:56Z","isPatch":true,"sender":{"key":"name:Kunal Tyagi","avatar":null},"body":"Hi git contributors!\n\nI'm Kunal Tyagi. While I was choosing the relevant patches for a commit\nusing the git add -p command, I found that there was no feedback regarding\nhow many hunks from the current file had been processed and how many were\nleft. So I decided to add a small change to the prompt which basically just\ndisplays (${current-hunk-id} + 1/${total-hunks}) before displaying the\nprompt during user interaction. This patch doesn't account for all total\nhunks, only per file.\n\nI don't know perl so even this one liner might have mistakes. I did test\nthis locally and hope this works for others. Personally, this change feels\nhelpful to me when I have to separate a long list of changes after an\nerroneous commit.\n\nOn the #git-devel freenode channel, I was informed that @dscho is rewriting\ngit-add in C. If so, perhaps a similar change could be added in the rewrite.\nI haven't seen his patches in detail so I can't comment if it'll be as\ntrivial as in perl.\n\nRegards Kunal Tyagi\n\nKunal Tyagi (1):\n  git-add--interactive.perl: Add progress counter in the prompt\n\n git-add--interactive.perl  | 2 +-\n t/t3701-add-interactive.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n\nbase-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v1\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v1\nPull-Request: https://github.com/gitgitgadget/git/pull/349\n-- \ngitgitgadget\n"},{"id":"382747","messageId":"8edf23f816dc0546fb3b5812573d7a759184206b.1569223612.git.gitgitgadget@gmail.com","threadId":"51898","inReplyTo":"pull.349.git.gitgitgadget@gmail.com","subject":"[PATCH 1/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Kunal Tyagi via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-23T07:26:54Z","receivedAt":"2019-09-23T07:26:58Z","isPatch":true,"sender":{"key":"name:Kunal Tyagi","avatar":null},"body":"From: Kunal Tyagi <tyagi.kunal@live.com>\n\nSigned-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n---\n git-add--interactive.perl  | 2 +-\n t/t3701-add-interactive.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex c20ae9e210..3951c25a28 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1541,7 +1541,7 @@ sub patch_update_file {\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color,\n+\t\tprint colored $prompt_color,\"(\", $ix+1, \"/$num) \",\n \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n \n \t\tmy $line = prompt_single_character;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 69991a3168..3a2d9fb607 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '\n \tgit commit -am \"clear local changes\" &&\n \tgit apply patch &&\n \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n-\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n+\t\tsed -n -e \"s/^(.*) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n \ttest_must_be_empty error &&\n \tgit diff --cached >diff &&\n-- \ngitgitgadget\n"},{"id":"382933","messageId":"nycvar.QRO.7.76.6.1909251728370.15067@tvgsbejvaqbjf.bet","threadId":"51898","inReplyTo":"pull.349.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-09-25T15:35:01Z","receivedAt":"2019-09-25T15:35:23Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 23 Sep 2019, Kunal Tyagi via GitGitGadget wrote:\n\n> Hi git contributors!\n>\n> I'm Kunal Tyagi. While I was choosing the relevant patches for a commit\n> using the git add -p command, I found that there was no feedback regarding\n> how many hunks from the current file had been processed and how many were\n> left. So I decided to add a small change to the prompt which basically just\n> displays (${current-hunk-id} + 1/${total-hunks}) before displaying the\n> prompt during user interaction. This patch doesn't account for all total\n> hunks, only per file.\n\nI like this idea!\n\n> I don't know perl so even this one liner might have mistakes. I did test\n> this locally and hope this works for others. Personally, this change feels\n> helpful to me when I have to separate a long list of changes after an\n> erroneous commit.\n>\n> On the #git-devel freenode channel, I was informed that @dscho is rewriting\n> git-add in C. If so, perhaps a similar change could be added in the rewrite.\n> I haven't seen his patches in detail so I can't comment if it'll be as\n> trivial as in perl.\n\nI bet it will be trivial to implement it in C. Don't let this stop you,\nyour change should go in before built-in add -i.\n\nThanks,\nJohannes\n\n>\n> Regards Kunal Tyagi\n>\n> Kunal Tyagi (1):\n>   git-add--interactive.perl: Add progress counter in the prompt\n>\n>  git-add--interactive.perl  | 2 +-\n>  t/t3701-add-interactive.sh | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n>\n>\n> base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a\n> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v1\n> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v1\n> Pull-Request: https://github.com/gitgitgadget/git/pull/349\n> --\n> gitgitgadget\n>\n"},{"id":"382934","messageId":"nycvar.QRO.7.76.6.1909251736190.15067@tvgsbejvaqbjf.bet","threadId":"51898","inReplyTo":"8edf23f816dc0546fb3b5812573d7a759184206b.1569223612.git.gitgitgadget@gmail.com","subject":"Re: [PATCH 1/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-09-25T15:38:56Z","receivedAt":"2019-09-25T15:39:20Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"Hi,\n\nOn Mon, 23 Sep 2019, Kunal Tyagi via GitGitGadget wrote:\n\n> From: Kunal Tyagi <tyagi.kunal@live.com>\n>\n> Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n\nCould you move most (if not all) of the explanation from the cover\nletter (read: the PR description) into the commit message?\n\nThe patch looks good, I just have one suggestion:\n\n> ---\n>  git-add--interactive.perl  | 2 +-\n>  t/t3701-add-interactive.sh | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index c20ae9e210..3951c25a28 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -1541,7 +1541,7 @@ sub patch_update_file {\n>  \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n>  \t\t\tprint;\n>  \t\t}\n> -\t\tprint colored $prompt_color,\n> +\t\tprint colored $prompt_color,\"(\", $ix+1, \"/$num) \",\n\nIt would probably make sense to use `.` rather than `,`, the dot is the\nconcatenation operator in Perl.\n\nThanks,\nJohannes\n\n>  \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n>\n>  \t\tmy $line = prompt_single_character;\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index 69991a3168..3a2d9fb607 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '\n>  \tgit commit -am \"clear local changes\" &&\n>  \tgit apply patch &&\n>  \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n> -\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n> +\t\tsed -n -e \"s/^(.*) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n>  \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n>  \ttest_must_be_empty error &&\n>  \tgit diff --cached >diff &&\n> --\n> gitgitgadget\n>\n"},{"id":"383095","messageId":"pull.349.v2.git.gitgitgadget@gmail.com","threadId":"51898","inReplyTo":"pull.349.git.gitgitgadget@gmail.com","subject":"[PATCH v2 0/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Kunal Tyagi via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-29T01:30:17Z","receivedAt":"2019-09-29T01:30:22Z","isPatch":true,"sender":{"key":"name:Kunal Tyagi","avatar":null},"body":"Hi git contributors!\n\nI'm Kunal Tyagi. While I was choosing the relevant patches for a commit\nusing the git add -p command, I found that there was no feedback regarding\nhow many hunks from the current file had been processed and how many were\nleft. So I decided to add a small change to the prompt which basically just\ndisplays (${current-hunk-id} + 1/${total-hunks}) before displaying the\nprompt during user interaction. This patch doesn't account for all total\nhunks, only per file.\n\nI don't know perl so even this one liner might have mistakes. I did test\nthis locally and hope this works for others. Personally, this change feels\nhelpful to me when I have to separate a long list of changes after an\nerroneous commit.\n\nOn the #git-devel freenode channel, I was informed that @dscho is rewriting\ngit-add in C. If so, perhaps a similar change could be added in the rewrite.\nI haven't seen his patches in detail so I can't comment if it'll be as\ntrivial as in perl.\n\nRegards Kunal Tyagi\n\nKunal Tyagi (1):\n  git-add--interactive.perl: Add progress counter in the prompt\n\n git-add--interactive.perl  | 2 +-\n t/t3701-add-interactive.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n\nbase-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v2\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v2\nPull-Request: https://github.com/gitgitgadget/git/pull/349\n\nRange-diff vs v1:\n\n 1:  8edf23f816 ! 1:  a9c5906899 git-add--interactive.perl: Add progress counter in the prompt\n     @@ -2,6 +2,14 @@\n      \n          git-add--interactive.perl: Add progress counter in the prompt\n      \n     +    Adds a feedback regarding how many hunks from the current file have been\n     +    processed and total number of hunks\n     +    Also included: changes to the test script due to change in expected\n     +    output string\n     +\n     +    Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before\n     +    displaying the current prompt during user interaction\n     +\n          Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n      \n       diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n     @@ -12,7 +20,7 @@\n       \t\t\tprint;\n       \t\t}\n      -\t\tprint colored $prompt_color,\n     -+\t\tprint colored $prompt_color,\"(\", $ix+1, \"/$num) \",\n     ++\t\tprint colored $prompt_color,\"(\". ($ix+1) .\"/$num) \",\n       \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n       \n       \t\tmy $line = prompt_single_character;\n\n-- \ngitgitgadget\n"},{"id":"383096","messageId":"a9c590689931ebc49e91c56d8a095f66193801c2.1569720616.git.gitgitgadget@gmail.com","threadId":"51898","inReplyTo":"pull.349.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Kunal Tyagi via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-29T01:30:19Z","receivedAt":"2019-09-29T01:30:25Z","isPatch":true,"sender":{"key":"name:Kunal Tyagi","avatar":null},"body":"From: Kunal Tyagi <tyagi.kunal@live.com>\n\nAdds a feedback regarding how many hunks from the current file have been\nprocessed and total number of hunks\nAlso included: changes to the test script due to change in expected\noutput string\n\nChange in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before\ndisplaying the current prompt during user interaction\n\nSigned-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n---\n git-add--interactive.perl  | 2 +-\n t/t3701-add-interactive.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex c20ae9e210..51c30e08cb 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1541,7 +1541,7 @@ sub patch_update_file {\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color,\n+\t\tprint colored $prompt_color,\"(\". ($ix+1) .\"/$num) \",\n \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n \n \t\tmy $line = prompt_single_character;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 69991a3168..3a2d9fb607 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '\n \tgit commit -am \"clear local changes\" &&\n \tgit apply patch &&\n \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n-\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n+\t\tsed -n -e \"s/^(.*) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n \ttest_must_be_empty error &&\n \tgit diff --cached >diff &&\n-- \ngitgitgadget\n"},{"id":"383110","messageId":"xmqqeezyin3e.fsf@gitster-ct.c.googlers.com","threadId":"51898","inReplyTo":"a9c590689931ebc49e91c56d8a095f66193801c2.1569720616.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-09-30T01:34:13Z","receivedAt":"2019-09-30T01:34:22Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kunal Tyagi via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Kunal Tyagi <tyagi.kunal@live.com>\n> Subject: Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt\n\nEither of these two, perhaps (I'd use the former if I were writing\nthis patch):\n\n\tadd -i: show progress counter in the prompt\n\tadd -i: add progress counter to the prompt\n\nGive an order to the codebase to \"become like so\".  E.g.\n\n\tReport how many hunks have been processed and the total\n\tnumber of hunks in the current file in the prompt, and\n\tadjust the expected output in some tests.\n\n\tSigned-off-by: ...\n\n> Adds a feedback regarding how many hunks from the current file have been\n> processed and total number of hunks\n> Also included: changes to the test script due to change in expected\n> output string\n>\n> Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before\n> displaying the current prompt during user interaction\n>\n> Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n> ---\n>  git-add--interactive.perl  | 2 +-\n>  t/t3701-add-interactive.sh | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n>\n> diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> index c20ae9e210..51c30e08cb 100755\n> --- a/git-add--interactive.perl\n> +++ b/git-add--interactive.perl\n> @@ -1541,7 +1541,7 @@ sub patch_update_file {\n>  \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n>  \t\t\tprint;\n>  \t\t}\n> -\t\tprint colored $prompt_color,\n> +\t\tprint colored $prompt_color,\"(\". ($ix+1) .\"/$num) \",\n\nDon't omit space after comma. or around the \".\" operators---if you\nwant to use \".\" here, that is.  I am not convinced it makes the code\nbetter to use \".\", though.\n\n\tprint colored $prompt_color, \"(\", ($ix+1), \"/$num) \",\n\nis probably how I would write this, as I expect those writing Perl\nwould know that elements of a comma separated list fed to 'print'\nare shown without any extra space in between.\n\n>  \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n>  \n>  \t\tmy $line = prompt_single_character;\n> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> index 69991a3168..3a2d9fb607 100755\n> --- a/t/t3701-add-interactive.sh\n> +++ b/t/t3701-add-interactive.sh\n> @@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '\n>  \tgit commit -am \"clear local changes\" &&\n>  \tgit apply patch &&\n>  \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n> -\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n> +\t\tsed -n -e \"s/^(.*) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n\nShouldn't this pattern be a bit tighter than \"(.*)\" (i.e. anything\ncan come between paren)?\n\n>  \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n>  \ttest_must_be_empty error &&\n>  \tgit diff --cached >diff &&\n"},{"id":"383124","messageId":"b351c74a3fc5787e8a41c12342b592d38ef0dede.1569820977.git.gitgitgadget@gmail.com","threadId":"51898","inReplyTo":"pull.349.v3.git.gitgitgadget@gmail.com","subject":"[PATCH v3 1/1] add -i: Show progress counter in the prompt","fromName":"Kunal Tyagi via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-30T05:22:59Z","receivedAt":"2019-09-30T05:23:03Z","isPatch":true,"sender":{"key":"name:Kunal Tyagi","avatar":null},"body":"From: Kunal Tyagi <tyagi.kunal@live.com>\n\nReport the current hunk count and total number of hunks for the current\nfile in the prompt\nAdjust the expected output in some tests to account for new data on the prompt\n\nSigned-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n---\n git-add--interactive.perl  | 2 +-\n t/t3701-add-interactive.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\ndiff --git a/git-add--interactive.perl b/git-add--interactive.perl\nindex c20ae9e210..52659bb74c 100755\n--- a/git-add--interactive.perl\n+++ b/git-add--interactive.perl\n@@ -1541,7 +1541,7 @@ sub patch_update_file {\n \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n \t\t\tprint;\n \t\t}\n-\t\tprint colored $prompt_color,\n+\t\tprint colored $prompt_color, \"(\", ($ix+1), \"/$num) \",\n \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n \n \t\tmy $line = prompt_single_character;\ndiff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\nindex 69991a3168..d50e165ca8 100755\n--- a/t/t3701-add-interactive.sh\n+++ b/t/t3701-add-interactive.sh\n@@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '\n \tgit commit -am \"clear local changes\" &&\n \tgit apply patch &&\n \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n-\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n+\t\tsed -n -e \"s/^([1-2]\\/[1-2]) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n \ttest_must_be_empty error &&\n \tgit diff --cached >diff &&\n-- \ngitgitgadget\n"},{"id":"383125","messageId":"pull.349.v3.git.gitgitgadget@gmail.com","threadId":"51898","inReplyTo":"pull.349.v2.git.gitgitgadget@gmail.com","subject":"[PATCH v3 0/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Kunal Tyagi via GitGitGadget","fromEmail":"gitgitgadget@gmail.com","sentAt":"2019-09-30T05:22:58Z","receivedAt":"2019-09-30T05:24:00Z","isPatch":true,"sender":{"key":"name:Kunal Tyagi","avatar":null},"body":"Hi git contributors!\n\nI'm Kunal Tyagi. While I was choosing the relevant patches for a commit\nusing the git add -p command, I found that there was no feedback regarding\nhow many hunks from the current file had been processed and how many were\nleft. So I decided to add a small change to the prompt which basically just\ndisplays (${current-hunk-id} + 1/${total-hunks}) before displaying the\nprompt during user interaction. This patch doesn't account for all total\nhunks, only per file.\n\nI don't know perl so even this one liner might have mistakes. I did test\nthis locally and hope this works for others. Personally, this change feels\nhelpful to me when I have to separate a long list of changes after an\nerroneous commit.\n\nOn the #git-devel freenode channel, I was informed that @dscho is rewriting\ngit-add in C. If so, perhaps a similar change could be added in the rewrite.\nI haven't seen his patches in detail so I can't comment if it'll be as\ntrivial as in perl.\n\nRegards Kunal Tyagi\n\nKunal Tyagi (1):\n  add -i: Show progress counter in the prompt\n\n git-add--interactive.perl  | 2 +-\n t/t3701-add-interactive.sh | 2 +-\n 2 files changed, 2 insertions(+), 2 deletions(-)\n\n\nbase-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a\nPublished-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v3\nFetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v3\nPull-Request: https://github.com/gitgitgadget/git/pull/349\n\nRange-diff vs v2:\n\n 1:  a9c5906899 ! 1:  b351c74a3f git-add--interactive.perl: Add progress counter in the prompt\n     @@ -1,14 +1,10 @@\n      Author: Kunal Tyagi <tyagi.kunal@live.com>\n      \n     -    git-add--interactive.perl: Add progress counter in the prompt\n     +    add -i: Show progress counter in the prompt\n      \n     -    Adds a feedback regarding how many hunks from the current file have been\n     -    processed and total number of hunks\n     -    Also included: changes to the test script due to change in expected\n     -    output string\n     -\n     -    Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before\n     -    displaying the current prompt during user interaction\n     +    Report the current hunk count and total number of hunks for the current\n     +    file in the prompt\n     +    Adjust the expected output in some tests to account for new data on the prompt\n      \n          Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n      \n     @@ -20,7 +16,7 @@\n       \t\t\tprint;\n       \t\t}\n      -\t\tprint colored $prompt_color,\n     -+\t\tprint colored $prompt_color,\"(\". ($ix+1) .\"/$num) \",\n     ++\t\tprint colored $prompt_color, \"(\", ($ix+1), \"/$num) \",\n       \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n       \n       \t\tmy $line = prompt_single_character;\n     @@ -33,7 +29,7 @@\n       \tgit apply patch &&\n       \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n      -\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n     -+\t\tsed -n -e \"s/^(.*) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n     ++\t\tsed -n -e \"s/^([1-2]\\/[1-2]) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n       \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n       \ttest_must_be_empty error &&\n       \tgit diff --cached >diff &&\n\n-- \ngitgitgadget\n"},{"id":"383181","messageId":"nycvar.QRO.7.76.6.1909301929270.46@tvgsbejvaqbjf.bet","threadId":"51898","inReplyTo":"xmqqeezyin3e.fsf@gitster-ct.c.googlers.com","subject":"Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt","fromName":"Johannes Schindelin","fromEmail":"johannes.schindelin@gmx.de","sentAt":"2019-09-30T17:30:11Z","receivedAt":"2019-09-30T21:40:50Z","isPatch":true,"sender":{"key":"johannes.schindelin@gmx.de","avatar":"https://avatars.githubusercontent.com/u/127790?v=4"},"body":"For completeness: this is what the contributor wrote in\nhttps://github.com/gitgitgadget/git/pull/349#issuecomment-536405428\n\nThanks for your comments. I've modified the patch and I hope it is more\nsuitable now.\n\nI just used a repl to get the output and sent that as a patch. I don't\nreally know perl (though printf syntax is almost universal).\n\nCheers\nKunal Tyagi\n\nOn Mon, 30 Sep 2019, Junio C Hamano wrote:\n\n> \"Kunal Tyagi via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n>\n> > From: Kunal Tyagi <tyagi.kunal@live.com>\n> > Subject: Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt\n>\n> Either of these two, perhaps (I'd use the former if I were writing\n> this patch):\n>\n> \tadd -i: show progress counter in the prompt\n> \tadd -i: add progress counter to the prompt\n>\n> Give an order to the codebase to \"become like so\".  E.g.\n>\n> \tReport how many hunks have been processed and the total\n> \tnumber of hunks in the current file in the prompt, and\n> \tadjust the expected output in some tests.\n>\n> \tSigned-off-by: ...\n>\n> > Adds a feedback regarding how many hunks from the current file have been\n> > processed and total number of hunks\n> > Also included: changes to the test script due to change in expected\n> > output string\n> >\n> > Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before\n> > displaying the current prompt during user interaction\n> >\n> > Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n> > ---\n> >  git-add--interactive.perl  | 2 +-\n> >  t/t3701-add-interactive.sh | 2 +-\n> >  2 files changed, 2 insertions(+), 2 deletions(-)\n> >\n> > diff --git a/git-add--interactive.perl b/git-add--interactive.perl\n> > index c20ae9e210..51c30e08cb 100755\n> > --- a/git-add--interactive.perl\n> > +++ b/git-add--interactive.perl\n> > @@ -1541,7 +1541,7 @@ sub patch_update_file {\n> >  \t\tfor (@{$hunk[$ix]{DISPLAY}}) {\n> >  \t\t\tprint;\n> >  \t\t}\n> > -\t\tprint colored $prompt_color,\n> > +\t\tprint colored $prompt_color,\"(\". ($ix+1) .\"/$num) \",\n>\n> Don't omit space after comma. or around the \".\" operators---if you\n> want to use \".\" here, that is.  I am not convinced it makes the code\n> better to use \".\", though.\n>\n> \tprint colored $prompt_color, \"(\", ($ix+1), \"/$num) \",\n>\n> is probably how I would write this, as I expect those writing Perl\n> would know that elements of a comma separated list fed to 'print'\n> are shown without any extra space in between.\n>\n> >  \t\t\tsprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);\n> >\n> >  \t\tmy $line = prompt_single_character;\n> > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh\n> > index 69991a3168..3a2d9fb607 100755\n> > --- a/t/t3701-add-interactive.sh\n> > +++ b/t/t3701-add-interactive.sh\n> > @@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '\n> >  \tgit commit -am \"clear local changes\" &&\n> >  \tgit apply patch &&\n> >  \tprintf \"%s\\n\" s y y | git add -p file 2>error |\n> > -\t\tsed -n -e \"s/^Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n> > +\t\tsed -n -e \"s/^(.*) Stage this hunk[^@]*\\(@@ .*\\)/\\1/\" \\\n>\n> Shouldn't this pattern be a bit tighter than \"(.*)\" (i.e. anything\n> can come between paren)?\n>\n> >  \t\t       -e \"/^[-+@ \\\\\\\\]\"/p  >output &&\n> >  \ttest_must_be_empty error &&\n> >  \tgit diff --cached >diff &&\n>\n"},{"id":"383399","messageId":"xmqqzhih6ord.fsf@gitster-ct.c.googlers.com","threadId":"51898","inReplyTo":"b351c74a3fc5787e8a41c12342b592d38ef0dede.1569820977.git.gitgitgadget@gmail.com","subject":"Re: [PATCH v3 1/1] add -i: Show progress counter in the prompt","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2019-10-04T05:52:38Z","receivedAt":"2019-10-04T05:52:42Z","isPatch":true,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"\"Kunal Tyagi via GitGitGadget\" <gitgitgadget@gmail.com> writes:\n\n> From: Kunal Tyagi <tyagi.kunal@live.com>\n>\n> Report the current hunk count and total number of hunks for the current\n> file in the prompt\n> Adjust the expected output in some tests to account for new data on the prompt\n>\n> Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>\n> ---\n>  git-add--interactive.perl  | 2 +-\n>  t/t3701-add-interactive.sh | 2 +-\n>  2 files changed, 2 insertions(+), 2 deletions(-)\n\nThanks; queued.\n"}]}