Re: feature request: git add--interactive --patch on regex-matched hunks only

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

 



On Mon, Jul 25, 2011 at 04:44:01PM -0700, Junio C Hamano wrote:

> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index 8f0839d..0b6f8a6 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -1257,7 +1257,7 @@ sub display_hunks {
>  
>  sub patch_update_file {
>  	my $quit = 0;
> -	my ($ix, $num);
> +	my ($ix, $num, $last_search_string);
>  	my $path = shift;
>  	my ($head, @hunk) = parse_diff($path);
>  	($head, my $mode, my $deletion) = parse_diff_header($head);
> @@ -1395,11 +1395,12 @@ sub patch_update_file {
>  			}
>  			elsif ($line =~ m|^/(.*)|) {
>  				my $regex = $1;
> -				if ($1 eq "") {
> -					print colored $prompt_color, "search for regex? ";
> -					$regex = <STDIN>;
> -					if (defined $regex) {
> -						chomp $regex;
> +				if ($regex eq "") {
> +					if ($last_search_string) {
> +						$regex = $last_search_string;
> +					} else {
> +						error_msg "Need a regexp to search\n";
> +						next;

How does this interact with single-key mode? I imagine we just get the
"/" at that point and have to read the rest of the regex manually. Which
is probably why this code was here in the first place.

So I think we might have to do something like:

  my $regex = $1;
  if ($use_readkey) {
    print colored $prompt_color, "search for regex?";
    $regex = <STDIN>;
    chomp $regex;
  }
  if ($regex eq "") {
    ...
  }

And then that would give single-key people an opportunity to input a new
regex, or to hit enter to just use the last one.

-Peff
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[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]