git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "Kunal Tyagi via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, Kunal Tyagi <tyagi.kunal@live.com>
Subject: Re: [PATCH v2 1/1] git-add--interactive.perl: Add progress counter in the prompt
Date: Mon, 30 Sep 2019 10:34:13 +0900	[thread overview]
Message-ID: <xmqqeezyin3e.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <a9c590689931ebc49e91c56d8a095f66193801c2.1569720616.git.gitgitgadget@gmail.com> (Kunal Tyagi via GitGitGadget's message of "Sat, 28 Sep 2019 18:30:19 -0700 (PDT)")

"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 &&

  reply	other threads:[~2019-09-30  1:34 UTC|newest]

Thread overview: 11+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
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 [this message]
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

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqeezyin3e.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=tyagi.kunal@live.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
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).