git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/2] In add --patch, Handle K,k,J,j slightly more gracefully.

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 26, 2008, 21:55 UTC
Message-ID
<7vej0ydue4.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<492DB6CE.3010409@gmail.com>
William Pursell <bill.pursell@gmail.com> writes:
> Instead of printing the help menu, this will print
> "No next hunk" and then process the given hunk again.
> ---
Missing sign-off.
> -			elsif ($other =~ /K/ && $line =~ /^K/) {
> -				$ix--;
> +			elsif ( $line =~ /^K/) {
> +				$other =~ /K/ ?  $ix-- : print STDERR "No previous hunk\n";
This may be cute but I think it is harder to read than necessary.
	if ($other =~ /K/) {
        	$ix--;
        } else {
		print STDERR "No previous hunk\n";
        }
Show 20 quoted lines
> +			elsif ($line =~ /^k/) {
> +				if ($other =~ /k/) {
> +					while (1) {
> +						$ix--;
> +						last if (!$ix ||
> +							 !defined $hunk[$ix]{USE});
> +					}
> +					next;
> +				}
> +				else {
> +					print STDERR "No previous hunk\n";
>  				}
> -				next;
>  			}
> +			elsif ($line =~ /^j/) {
> +				if ($other !~ /j/) {
> +					print STDERR "No next hunk\n";
> +					next;
>  				}
>  			}

Doesn't this behave differently against an unavailable 'k' and 'j'? When the user says 'j' when no next hunk is available, it will ask again about that hunk, but when the user says 'k' at the first hunk, because you discarded 'next', it will ask about the next hunk, no? Shouldn't it ask again about the same hunk, against which the user gave an erroneous input?

Previous: William Pursell
Message 2 of 2 in “In add --patch, Handle K,k,J,j slightly more gracefully.”
  1. 2/2 In add --patch, Handle K,k,J,j slightly more gracefully.William Pursell, Nov 26, 2008
  2. Junio C HamanoNov 26, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.