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

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



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.
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.
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



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]