git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
* [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt
@ 2019-09-23  7:26 Kunal Tyagi via GitGitGadget
  2019-09-23  7:26 ` [PATCH 1/1] " Kunal Tyagi via GitGitGadget
                   ` (2 more replies)
  0 siblings, 3 replies; 11+ messages in thread
From: Kunal Tyagi via GitGitGadget @ 2019-09-23  7:26 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano

Hi git contributors!

I'm Kunal Tyagi. While I was choosing the relevant patches for a commit
using the git add -p command, I found that there was no feedback regarding
how many hunks from the current file had been processed and how many were
left. So I decided to add a small change to the prompt which basically just
displays (${current-hunk-id} + 1/${total-hunks}) before displaying the
prompt during user interaction. This patch doesn't account for all total
hunks, only per file.

I don't know perl so even this one liner might have mistakes. I did test
this locally and hope this works for others. Personally, this change feels
helpful to me when I have to separate a long list of changes after an
erroneous commit.

On the #git-devel freenode channel, I was informed that @dscho is rewriting
git-add in C. If so, perhaps a similar change could be added in the rewrite.
I haven't seen his patches in detail so I can't comment if it'll be as
trivial as in perl.

Regards Kunal Tyagi

Kunal Tyagi (1):
  git-add--interactive.perl: Add progress counter in the prompt

 git-add--interactive.perl  | 2 +-
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v1
Pull-Request: https://github.com/gitgitgadget/git/pull/349
-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH 1/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-23  7:26 [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt Kunal Tyagi via GitGitGadget
@ 2019-09-23  7:26 ` Kunal Tyagi via GitGitGadget
  2019-09-25 15:38   ` Johannes Schindelin
  2019-09-25 15:35 ` [PATCH 0/1] " Johannes Schindelin
  2019-09-29  1:30 ` [PATCH v2 " Kunal Tyagi via GitGitGadget
  2 siblings, 1 reply; 11+ messages in thread
From: Kunal Tyagi via GitGitGadget @ 2019-09-23  7:26 UTC (permalink / raw)
  To: git; +Cc: Junio C Hamano, Kunal Tyagi

From: Kunal Tyagi <tyagi.kunal@live.com>

Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
---
 git-add--interactive.perl  | 2 +-
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index c20ae9e210..3951c25a28 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1541,7 +1541,7 @@ sub patch_update_file {
 		for (@{$hunk[$ix]{DISPLAY}}) {
 			print;
 		}
-		print colored $prompt_color,
+		print colored $prompt_color,"(", $ix+1, "/$num) ",
 			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
 
 		my $line = prompt_single_character;
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 69991a3168..3a2d9fb607 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
 	git commit -am "clear local changes" &&
 	git apply patch &&
 	printf "%s\n" s y y | git add -p file 2>error |
-		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
+		sed -n -e "s/^(.*) Stage this hunk[^@]*\(@@ .*\)/\1/" \
 		       -e "/^[-+@ \\\\]"/p  >output &&
 	test_must_be_empty error &&
 	git diff --cached >diff &&
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-23  7:26 [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt Kunal Tyagi via GitGitGadget
  2019-09-23  7:26 ` [PATCH 1/1] " Kunal Tyagi via GitGitGadget
@ 2019-09-25 15:35 ` Johannes Schindelin
  2019-09-29  1:30 ` [PATCH v2 " Kunal Tyagi via GitGitGadget
  2 siblings, 0 replies; 11+ messages in thread
From: Johannes Schindelin @ 2019-09-25 15:35 UTC (permalink / raw)
  To: Kunal Tyagi via GitGitGadget; +Cc: git, Junio C Hamano

Hi,

On Mon, 23 Sep 2019, Kunal Tyagi via GitGitGadget wrote:

> Hi git contributors!
>
> I'm Kunal Tyagi. While I was choosing the relevant patches for a commit
> using the git add -p command, I found that there was no feedback regarding
> how many hunks from the current file had been processed and how many were
> left. So I decided to add a small change to the prompt which basically just
> displays (${current-hunk-id} + 1/${total-hunks}) before displaying the
> prompt during user interaction. This patch doesn't account for all total
> hunks, only per file.

I like this idea!

> I don't know perl so even this one liner might have mistakes. I did test
> this locally and hope this works for others. Personally, this change feels
> helpful to me when I have to separate a long list of changes after an
> erroneous commit.
>
> On the #git-devel freenode channel, I was informed that @dscho is rewriting
> git-add in C. If so, perhaps a similar change could be added in the rewrite.
> I haven't seen his patches in detail so I can't comment if it'll be as
> trivial as in perl.

I bet it will be trivial to implement it in C. Don't let this stop you,
your change should go in before built-in add -i.

Thanks,
Johannes

>
> Regards Kunal Tyagi
>
> Kunal Tyagi (1):
>   git-add--interactive.perl: Add progress counter in the prompt
>
>  git-add--interactive.perl  | 2 +-
>  t/t3701-add-interactive.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
>
> base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a
> Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v1
> Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v1
> Pull-Request: https://github.com/gitgitgadget/git/pull/349
> --
> gitgitgadget
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH 1/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-23  7:26 ` [PATCH 1/1] " Kunal Tyagi via GitGitGadget
@ 2019-09-25 15:38   ` Johannes Schindelin
  0 siblings, 0 replies; 11+ messages in thread
From: Johannes Schindelin @ 2019-09-25 15:38 UTC (permalink / raw)
  To: Kunal Tyagi via GitGitGadget; +Cc: git, Junio C Hamano, Kunal Tyagi

Hi,

On Mon, 23 Sep 2019, Kunal Tyagi via GitGitGadget wrote:

> From: Kunal Tyagi <tyagi.kunal@live.com>
>
> Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>

Could you move most (if not all) of the explanation from the cover
letter (read: the PR description) into the commit message?

The patch looks good, I just have one suggestion:

> ---
>  git-add--interactive.perl  | 2 +-
>  t/t3701-add-interactive.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index c20ae9e210..3951c25a28 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -1541,7 +1541,7 @@ sub patch_update_file {
>  		for (@{$hunk[$ix]{DISPLAY}}) {
>  			print;
>  		}
> -		print colored $prompt_color,
> +		print colored $prompt_color,"(", $ix+1, "/$num) ",

It would probably make sense to use `.` rather than `,`, the dot is the
concatenation operator in Perl.

Thanks,
Johannes

>  			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
>
>  		my $line = prompt_single_character;
> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> index 69991a3168..3a2d9fb607 100755
> --- a/t/t3701-add-interactive.sh
> +++ b/t/t3701-add-interactive.sh
> @@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
>  	git commit -am "clear local changes" &&
>  	git apply patch &&
>  	printf "%s\n" s y y | git add -p file 2>error |
> -		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
> +		sed -n -e "s/^(.*) Stage this hunk[^@]*\(@@ .*\)/\1/" \
>  		       -e "/^[-+@ \\\\]"/p  >output &&
>  	test_must_be_empty error &&
>  	git diff --cached >diff &&
> --
> gitgitgadget
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 0/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-23  7:26 [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt Kunal Tyagi via GitGitGadget
  2019-09-23  7:26 ` [PATCH 1/1] " Kunal Tyagi via GitGitGadget
  2019-09-25 15:35 ` [PATCH 0/1] " Johannes Schindelin
@ 2019-09-29  1:30 ` Kunal Tyagi via GitGitGadget
  2019-09-29  1:30   ` [PATCH v2 1/1] " Kunal Tyagi via GitGitGadget
  2019-09-30  5:22   ` [PATCH v3 0/1] " Kunal Tyagi via GitGitGadget
  2 siblings, 2 replies; 11+ messages in thread
From: Kunal Tyagi via GitGitGadget @ 2019-09-29  1:30 UTC (permalink / raw)
  To: git; +Cc: Kunal Tyagi, Junio C Hamano

Hi git contributors!

I'm Kunal Tyagi. While I was choosing the relevant patches for a commit
using the git add -p command, I found that there was no feedback regarding
how many hunks from the current file had been processed and how many were
left. So I decided to add a small change to the prompt which basically just
displays (${current-hunk-id} + 1/${total-hunks}) before displaying the
prompt during user interaction. This patch doesn't account for all total
hunks, only per file.

I don't know perl so even this one liner might have mistakes. I did test
this locally and hope this works for others. Personally, this change feels
helpful to me when I have to separate a long list of changes after an
erroneous commit.

On the #git-devel freenode channel, I was informed that @dscho is rewriting
git-add in C. If so, perhaps a similar change could be added in the rewrite.
I haven't seen his patches in detail so I can't comment if it'll be as
trivial as in perl.

Regards Kunal Tyagi

Kunal Tyagi (1):
  git-add--interactive.perl: Add progress counter in the prompt

 git-add--interactive.perl  | 2 +-
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v2
Pull-Request: https://github.com/gitgitgadget/git/pull/349

Range-diff vs v1:

 1:  8edf23f816 ! 1:  a9c5906899 git-add--interactive.perl: Add progress counter in the prompt
     @@ -2,6 +2,14 @@
      
          git-add--interactive.perl: Add progress counter in the prompt
      
     +    Adds a feedback regarding how many hunks from the current file have been
     +    processed and total number of hunks
     +    Also included: changes to the test script due to change in expected
     +    output string
     +
     +    Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before
     +    displaying the current prompt during user interaction
     +
          Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
      
       diff --git a/git-add--interactive.perl b/git-add--interactive.perl
     @@ -12,7 +20,7 @@
       			print;
       		}
      -		print colored $prompt_color,
     -+		print colored $prompt_color,"(", $ix+1, "/$num) ",
     ++		print colored $prompt_color,"(". ($ix+1) ."/$num) ",
       			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
       
       		my $line = prompt_single_character;

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-29  1:30 ` [PATCH v2 " Kunal Tyagi via GitGitGadget
@ 2019-09-29  1:30   ` Kunal Tyagi via GitGitGadget
  2019-09-30  1:34     ` Junio C Hamano
  2019-09-30  5:22   ` [PATCH v3 0/1] " Kunal Tyagi via GitGitGadget
  1 sibling, 1 reply; 11+ messages in thread
From: Kunal Tyagi via GitGitGadget @ 2019-09-29  1:30 UTC (permalink / raw)
  To: git; +Cc: Kunal Tyagi, Junio C Hamano, Kunal Tyagi

From: Kunal Tyagi <tyagi.kunal@live.com>

Adds a feedback regarding how many hunks from the current file have been
processed and total number of hunks
Also included: changes to the test script due to change in expected
output string

Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before
displaying the current prompt during user interaction

Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
---
 git-add--interactive.perl  | 2 +-
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index c20ae9e210..51c30e08cb 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1541,7 +1541,7 @@ sub patch_update_file {
 		for (@{$hunk[$ix]{DISPLAY}}) {
 			print;
 		}
-		print colored $prompt_color,
+		print colored $prompt_color,"(". ($ix+1) ."/$num) ",
 			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
 
 		my $line = prompt_single_character;
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 69991a3168..3a2d9fb607 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
 	git commit -am "clear local changes" &&
 	git apply patch &&
 	printf "%s\n" s y y | git add -p file 2>error |
-		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
+		sed -n -e "s/^(.*) Stage this hunk[^@]*\(@@ .*\)/\1/" \
 		       -e "/^[-+@ \\\\]"/p  >output &&
 	test_must_be_empty error &&
 	git diff --cached >diff &&
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-29  1:30   ` [PATCH v2 1/1] " Kunal Tyagi via GitGitGadget
@ 2019-09-30  1:34     ` Junio C Hamano
  2019-09-30 17:30       ` Johannes Schindelin
  0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2019-09-30  1:34 UTC (permalink / raw)
  To: Kunal Tyagi via GitGitGadget; +Cc: git, Kunal Tyagi

"Kunal Tyagi via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Kunal Tyagi <tyagi.kunal@live.com>
> Subject: Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt

Either of these two, perhaps (I'd use the former if I were writing
this patch):

	add -i: show progress counter in the prompt
	add -i: add progress counter to the prompt

Give an order to the codebase to "become like so".  E.g.

	Report how many hunks have been processed and the total
	number of hunks in the current file in the prompt, and
	adjust the expected output in some tests.

	Signed-off-by: ...

> Adds a feedback regarding how many hunks from the current file have been
> processed and total number of hunks
> Also included: changes to the test script due to change in expected
> output string
>
> Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before
> displaying the current prompt during user interaction
>
> Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
> ---
>  git-add--interactive.perl  | 2 +-
>  t/t3701-add-interactive.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)
>
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index c20ae9e210..51c30e08cb 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -1541,7 +1541,7 @@ sub patch_update_file {
>  		for (@{$hunk[$ix]{DISPLAY}}) {
>  			print;
>  		}
> -		print colored $prompt_color,
> +		print colored $prompt_color,"(". ($ix+1) ."/$num) ",

Don't omit space after comma. or around the "." operators---if you
want to use "." here, that is.  I am not convinced it makes the code
better to use ".", though.

	print colored $prompt_color, "(", ($ix+1), "/$num) ",

is probably how I would write this, as I expect those writing Perl
would know that elements of a comma separated list fed to 'print'
are shown without any extra space in between.

>  			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
>  
>  		my $line = prompt_single_character;
> diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> index 69991a3168..3a2d9fb607 100755
> --- a/t/t3701-add-interactive.sh
> +++ b/t/t3701-add-interactive.sh
> @@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
>  	git commit -am "clear local changes" &&
>  	git apply patch &&
>  	printf "%s\n" s y y | git add -p file 2>error |
> -		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
> +		sed -n -e "s/^(.*) Stage this hunk[^@]*\(@@ .*\)/\1/" \

Shouldn't this pattern be a bit tighter than "(.*)" (i.e. anything
can come between paren)?

>  		       -e "/^[-+@ \\\\]"/p  >output &&
>  	test_must_be_empty error &&
>  	git diff --cached >diff &&

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 0/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-29  1:30 ` [PATCH v2 " Kunal Tyagi via GitGitGadget
  2019-09-29  1:30   ` [PATCH v2 1/1] " Kunal Tyagi via GitGitGadget
@ 2019-09-30  5:22   ` Kunal Tyagi via GitGitGadget
  2019-09-30  5:22     ` [PATCH v3 1/1] add -i: Show " Kunal Tyagi via GitGitGadget
  1 sibling, 1 reply; 11+ messages in thread
From: Kunal Tyagi via GitGitGadget @ 2019-09-30  5:22 UTC (permalink / raw)
  To: git; +Cc: Kunal Tyagi, Junio C Hamano

Hi git contributors!

I'm Kunal Tyagi. While I was choosing the relevant patches for a commit
using the git add -p command, I found that there was no feedback regarding
how many hunks from the current file had been processed and how many were
left. So I decided to add a small change to the prompt which basically just
displays (${current-hunk-id} + 1/${total-hunks}) before displaying the
prompt during user interaction. This patch doesn't account for all total
hunks, only per file.

I don't know perl so even this one liner might have mistakes. I did test
this locally and hope this works for others. Personally, this change feels
helpful to me when I have to separate a long list of changes after an
erroneous commit.

On the #git-devel freenode channel, I was informed that @dscho is rewriting
git-add in C. If so, perhaps a similar change could be added in the rewrite.
I haven't seen his patches in detail so I can't comment if it'll be as
trivial as in perl.

Regards Kunal Tyagi

Kunal Tyagi (1):
  add -i: Show progress counter in the prompt

 git-add--interactive.perl  | 2 +-
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)


base-commit: 4c86140027f4a0d2caaa3ab4bd8bfc5ce3c11c8a
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-349%2Fkunaltyagi%2Fmaster-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-349/kunaltyagi/master-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/349

Range-diff vs v2:

 1:  a9c5906899 ! 1:  b351c74a3f git-add--interactive.perl: Add progress counter in the prompt
     @@ -1,14 +1,10 @@
      Author: Kunal Tyagi <tyagi.kunal@live.com>
      
     -    git-add--interactive.perl: Add progress counter in the prompt
     +    add -i: Show progress counter in the prompt
      
     -    Adds a feedback regarding how many hunks from the current file have been
     -    processed and total number of hunks
     -    Also included: changes to the test script due to change in expected
     -    output string
     -
     -    Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before
     -    displaying the current prompt during user interaction
     +    Report the current hunk count and total number of hunks for the current
     +    file in the prompt
     +    Adjust the expected output in some tests to account for new data on the prompt
      
          Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
      
     @@ -20,7 +16,7 @@
       			print;
       		}
      -		print colored $prompt_color,
     -+		print colored $prompt_color,"(". ($ix+1) ."/$num) ",
     ++		print colored $prompt_color, "(", ($ix+1), "/$num) ",
       			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
       
       		my $line = prompt_single_character;
     @@ -33,7 +29,7 @@
       	git apply patch &&
       	printf "%s\n" s y y | git add -p file 2>error |
      -		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
     -+		sed -n -e "s/^(.*) Stage this hunk[^@]*\(@@ .*\)/\1/" \
     ++		sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
       		       -e "/^[-+@ \\\\]"/p  >output &&
       	test_must_be_empty error &&
       	git diff --cached >diff &&

-- 
gitgitgadget

^ permalink raw reply	[flat|nested] 11+ messages in thread

* [PATCH v3 1/1] add -i: Show progress counter in the prompt
  2019-09-30  5:22   ` [PATCH v3 0/1] " Kunal Tyagi via GitGitGadget
@ 2019-09-30  5:22     ` Kunal Tyagi via GitGitGadget
  2019-10-04  5:52       ` Junio C Hamano
  0 siblings, 1 reply; 11+ messages in thread
From: Kunal Tyagi via GitGitGadget @ 2019-09-30  5:22 UTC (permalink / raw)
  To: git; +Cc: Kunal Tyagi, Junio C Hamano, Kunal Tyagi

From: Kunal Tyagi <tyagi.kunal@live.com>

Report the current hunk count and total number of hunks for the current
file in the prompt
Adjust the expected output in some tests to account for new data on the prompt

Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
---
 git-add--interactive.perl  | 2 +-
 t/t3701-add-interactive.sh | 2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index c20ae9e210..52659bb74c 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -1541,7 +1541,7 @@ sub patch_update_file {
 		for (@{$hunk[$ix]{DISPLAY}}) {
 			print;
 		}
-		print colored $prompt_color,
+		print colored $prompt_color, "(", ($ix+1), "/$num) ",
 			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
 
 		my $line = prompt_single_character;
diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
index 69991a3168..d50e165ca8 100755
--- a/t/t3701-add-interactive.sh
+++ b/t/t3701-add-interactive.sh
@@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
 	git commit -am "clear local changes" &&
 	git apply patch &&
 	printf "%s\n" s y y | git add -p file 2>error |
-		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
+		sed -n -e "s/^([1-2]\/[1-2]) Stage this hunk[^@]*\(@@ .*\)/\1/" \
 		       -e "/^[-+@ \\\\]"/p  >output &&
 	test_must_be_empty error &&
 	git diff --cached >diff &&
-- 
gitgitgadget

^ permalink raw reply related	[flat|nested] 11+ messages in thread

* Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt
  2019-09-30  1:34     ` Junio C Hamano
@ 2019-09-30 17:30       ` Johannes Schindelin
  0 siblings, 0 replies; 11+ messages in thread
From: Johannes Schindelin @ 2019-09-30 17:30 UTC (permalink / raw)
  To: Junio C Hamano; +Cc: Kunal Tyagi via GitGitGadget, git, Kunal Tyagi

For completeness: this is what the contributor wrote in
https://github.com/gitgitgadget/git/pull/349#issuecomment-536405428

Thanks for your comments. I've modified the patch and I hope it is more
suitable now.

I just used a repl to get the output and sent that as a patch. I don't
really know perl (though printf syntax is almost universal).

Cheers
Kunal Tyagi

On Mon, 30 Sep 2019, Junio C Hamano wrote:

> "Kunal Tyagi via GitGitGadget" <gitgitgadget@gmail.com> writes:
>
> > From: Kunal Tyagi <tyagi.kunal@live.com>
> > Subject: Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt
>
> Either of these two, perhaps (I'd use the former if I were writing
> this patch):
>
> 	add -i: show progress counter in the prompt
> 	add -i: add progress counter to the prompt
>
> Give an order to the codebase to "become like so".  E.g.
>
> 	Report how many hunks have been processed and the total
> 	number of hunks in the current file in the prompt, and
> 	adjust the expected output in some tests.
>
> 	Signed-off-by: ...
>
> > Adds a feedback regarding how many hunks from the current file have been
> > processed and total number of hunks
> > Also included: changes to the test script due to change in expected
> > output string
> >
> > Change in UI: displays '(${current-hunk-id} + 1/${total-hunks-in-file})' before
> > displaying the current prompt during user interaction
> >
> > Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
> > ---
> >  git-add--interactive.perl  | 2 +-
> >  t/t3701-add-interactive.sh | 2 +-
> >  2 files changed, 2 insertions(+), 2 deletions(-)
> >
> > diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> > index c20ae9e210..51c30e08cb 100755
> > --- a/git-add--interactive.perl
> > +++ b/git-add--interactive.perl
> > @@ -1541,7 +1541,7 @@ sub patch_update_file {
> >  		for (@{$hunk[$ix]{DISPLAY}}) {
> >  			print;
> >  		}
> > -		print colored $prompt_color,
> > +		print colored $prompt_color,"(". ($ix+1) ."/$num) ",
>
> Don't omit space after comma. or around the "." operators---if you
> want to use "." here, that is.  I am not convinced it makes the code
> better to use ".", though.
>
> 	print colored $prompt_color, "(", ($ix+1), "/$num) ",
>
> is probably how I would write this, as I expect those writing Perl
> would know that elements of a comma separated list fed to 'print'
> are shown without any extra space in between.
>
> >  			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
> >
> >  		my $line = prompt_single_character;
> > diff --git a/t/t3701-add-interactive.sh b/t/t3701-add-interactive.sh
> > index 69991a3168..3a2d9fb607 100755
> > --- a/t/t3701-add-interactive.sh
> > +++ b/t/t3701-add-interactive.sh
> > @@ -314,7 +314,7 @@ test_expect_success C_LOCALE_OUTPUT 'add first line works' '
> >  	git commit -am "clear local changes" &&
> >  	git apply patch &&
> >  	printf "%s\n" s y y | git add -p file 2>error |
> > -		sed -n -e "s/^Stage this hunk[^@]*\(@@ .*\)/\1/" \
> > +		sed -n -e "s/^(.*) Stage this hunk[^@]*\(@@ .*\)/\1/" \
>
> Shouldn't this pattern be a bit tighter than "(.*)" (i.e. anything
> can come between paren)?
>
> >  		       -e "/^[-+@ \\\\]"/p  >output &&
> >  	test_must_be_empty error &&
> >  	git diff --cached >diff &&
>

^ permalink raw reply	[flat|nested] 11+ messages in thread

* Re: [PATCH v3 1/1] add -i: Show progress counter in the prompt
  2019-09-30  5:22     ` [PATCH v3 1/1] add -i: Show " Kunal Tyagi via GitGitGadget
@ 2019-10-04  5:52       ` Junio C Hamano
  0 siblings, 0 replies; 11+ messages in thread
From: Junio C Hamano @ 2019-10-04  5:52 UTC (permalink / raw)
  To: Kunal Tyagi via GitGitGadget; +Cc: git, Kunal Tyagi

"Kunal Tyagi via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: Kunal Tyagi <tyagi.kunal@live.com>
>
> Report the current hunk count and total number of hunks for the current
> file in the prompt
> Adjust the expected output in some tests to account for new data on the prompt
>
> Signed-off-by: Kunal Tyagi <tyagi.kunal@live.com>
> ---
>  git-add--interactive.perl  | 2 +-
>  t/t3701-add-interactive.sh | 2 +-
>  2 files changed, 2 insertions(+), 2 deletions(-)

Thanks; queued.

^ permalink raw reply	[flat|nested] 11+ messages in thread

end of thread, other threads:[~2019-10-04  5:52 UTC | newest]

Thread overview: 11+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-09-23  7:26 [PATCH 0/1] git-add--interactive.perl: Add progress counter in the prompt Kunal Tyagi via GitGitGadget
2019-09-23  7:26 ` [PATCH 1/1] " Kunal Tyagi via GitGitGadget
2019-09-25 15:38   ` Johannes Schindelin
2019-09-25 15:35 ` [PATCH 0/1] " Johannes Schindelin
2019-09-29  1:30 ` [PATCH v2 " Kunal Tyagi via GitGitGadget
2019-09-29  1:30   ` [PATCH v2 1/1] " Kunal Tyagi via GitGitGadget
2019-09-30  1:34     ` Junio C Hamano
2019-09-30 17:30       ` Johannes Schindelin
2019-09-30  5:22   ` [PATCH v3 0/1] " Kunal Tyagi via GitGitGadget
2019-09-30  5:22     ` [PATCH v3 1/1] add -i: Show " Kunal Tyagi via GitGitGadget
2019-10-04  5:52       ` Junio C Hamano

Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).