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

Re: [Suggestion] Alternative way for displaying help menu of patch flow

From
Kaartic Sivaraam <kaarticsivaraam91196@gmail.com>
Date
Apr 28, 2017, 07:21 UTC
Message-ID
<4d6eb11e-f102-7695-7f4a-562407ea13c0@gmail.com>
In-Reply-To
<20170428063723.2ni2v6akosm4ldvy@sigill.intra.peff.net>
On Friday 28 April 2017 12:07 PM, Jeff King wrote:
>
> If the hunk is big, that message scrolls off the screen. We could
> probably put it after the hunk, but I'd worry that the ordering would be
> confusing (because it comes between the hunk and the "this hunk" prompt.

Probably it could be better to clear the console after each user input, before the result of that input is displayed. That could probably remove the clutter and could allow the user to easily differentiate from the current output from previous output.

Show 11 quoted lines
> Or it could just not re-display the hunk all (like what my patch does
> for help), and you'd get:
>
>    @@ -1 +1 @@
>    -old
>    +new
>    Stage this hunk [y,n,q,a,d,/,e,?]? j
>    No next hunk
>    Stage this hunk [y,n,q,a,d,/,e,?]?
>
> at which point you could "r" to redisplay it if you wanted to.

This seems good too. But, I guess, the help menu would probably hide the hunk and could make that prompt a little absurd.

Show 56 quoted lines
> I also suspect that other menus in add--interactive have the same
> issue. E.g., if you have a large number of files what does the
> file-selection menu "git add -i" look like? Perhaps the issue is less
> common there, though.
>
> ---
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 709a5f6ce..81f62331b 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -1237,6 +1237,7 @@ k - leave this hunk undecided, see previous undecided hunk
>   K - leave this hunk undecided, see previous hunk
>   s - split the current hunk into smaller hunks
>   e - manually edit the current hunk
> +r - redisplay the current hunk
>   ? - print help
>   EOF
>   }
> @@ -1385,6 +1386,7 @@ my %patch_update_prompt_modes = (
>   sub patch_update_file {
>   	my $quit = 0;
>   	my ($ix, $num);
> +	my $skip_hunk_display;
>   	my $path = shift;
>   	my ($head, @hunk) = parse_diff($path);
>   	($head, my $mode, my $deletion) = parse_diff_header($head);
> @@ -1451,8 +1453,13 @@ sub patch_update_file {
>   		if ($hunk[$ix]{TYPE} eq 'hunk') {
>   			$other .= ',e';
>   		}
> -		for (@{$hunk[$ix]{DISPLAY}}) {
> -			print;
> +
> +		if ($skip_hunk_display) {
> +			$skip_hunk_display = 0;
> +		} else {
> +			for (@{$hunk[$ix]{DISPLAY}}) {
> +				print;
> +			}
>   		}
>   		print colored $prompt_color,
>   			sprintf(__($patch_update_prompt_modes{$patch_mode}{$hunk[$ix]{TYPE}}), $other);
> @@ -1608,8 +1615,13 @@ sub patch_update_file {
>   					splice @hunk, $ix, 1, $newhunk;
>   				}
>   			}
> +			elsif ($line =~ /^r/) {
> +				# do nothing; we'll show the hunk when we loop
> +				next;
> +			}
>   			else {
>   				help_patch_cmd($other);
> +				$skip_hunk_display = 1;
>   				next;
>   			}
>   			# soft increment

Regards, Kaartic

Previous: Jeff King
Message 3 of 3 in “[Suggestion] Alternative way for displaying help menu of patch flow”
  1. Kaartic SivaraamApr 28, 2017
  2. Jeff KingApr 28, 2017
  3. Kaartic SivaraamApr 28, 2017

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.