# [PATCH] Print hunk number in prompt of add --patch.

2 messages from 2008-11-27 to 2008-11-27. Participants: William Pursell, Junio C Hamano.
Thread: https://gitlist.dev/t/16493

## William Pursell, 2008-11-27 06:17

Subject: [PATCH] Print hunk number in prompt of add --patch.
Message-ID: <492E3B6D.9090309@gmail.com>
URL: https://gitlist.dev/e/492E3B6D.9090309%40gmail.com

```

I'm considering adding a command to skip to a hunk, and
just generally find myself confused about which hunk I'm
looking at, so having the number in the prompt is helpful.

Signed-off-by: William Pursell <bill.pursell@gmail.com>
---
  git-add--interactive.perl |    2 +-
  1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/git-add--interactive.perl b/git-add--interactive.perl
index b0223c3..7974cd1 100755
--- a/git-add--interactive.perl
+++ b/git-add--interactive.perl
@@ -919,7 +919,7 @@ sub patch_update_file {
  		for (@{$hunk[$ix]{DISPLAY}}) {
  			print;
  		}
-		print colored $prompt_color, "Stage this hunk [y/n/a/d$other/?]? ";
+		print colored $prompt_color, "Stage hunk $ix [y/n/a/d$other/?]? ";
  		my $line = <STDIN>;
  		if ($line) {
  			if ($line =~ /^y/i) {
-- 
1.6.0.4.782.geea74.dirty


-- 
William Pursell

```

## Junio C Hamano, 2008-11-27 07:14

Subject: Re: [PATCH] Print hunk number in prompt of add --patch.
Message-ID: <7vwsepbpyl.fsf@gitster.siamese.dyndns.org>
URL: https://gitlist.dev/e/7vwsepbpyl.fsf%40gitster.siamese.dyndns.org
In-Reply-To: <492E3B6D.9090309@gmail.com>

```
William Pursell <bill.pursell@gmail.com> writes:

> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index b0223c3..7974cd1 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -919,7 +919,7 @@ sub patch_update_file {
>  		for (@{$hunk[$ix]{DISPLAY}}) {
>  			print;
>  		}
> -		print colored $prompt_color, "Stage this hunk [y/n/a/d$other/?]? ";
> +		print colored $prompt_color, "Stage hunk $ix [y/n/a/d$other/?]? ";
>  		my $line = <STDIN>;
>  		if ($line) {
>  			if ($line =~ /^y/i) {

Do we know how many hunks we have at this point (and remember we need to
adjust the number of hunks after splitting)?

The original one was unfriendly in that it asked "Do you want this or not?
We'd rather not to say where you are nor how many more there are".  Your
update is slightly better but not enough: "Do you want this one or not?
It is the second one but we still won't tell you how many more there are".

I'd prefer it to ask "Stage hunk 2 (of 35)?" if you are adding more words
here.

I doubt "jump to hunk specified by hunk number" is useful in general.  You
wouldn't know what hunk number the hunk you are interested in has, until
you scroll through them all.

"Jump to hunk around line number X in the preimage", or "jump to a hunk in
function Y" may be useful (the latter you can do with "/^@@.*funcname"
with your slash-search patch).

```
