git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: Nguyen Thai Ngoc Duy <pclouds@gmail.com>,
	Git Mailing List <git@vger.kernel.org>
Subject: Re: feature request: git add--interactive --patch on regex-matched hunks only
Date: Mon, 25 Jul 2011 23:03:04 -0600	[thread overview]
Message-ID: <20110726050304.GA25046@sigill.intra.peff.net> (raw)
In-Reply-To: <7vbowiq62m.fsf@alter.siamese.dyndns.org>

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

  reply	other threads:[~2011-07-26  5:03 UTC|newest]

Thread overview: 19+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-07-24  5:11 feature request: git add--interactive --patch on regex-matched hunks only Nguyen Thai Ngoc Duy
2011-07-25 21:55 ` Jeff King
2011-07-25 23:44   ` Junio C Hamano
2011-07-26  5:03     ` Jeff King [this message]
2011-07-26  3:03   ` Nguyen Thai Ngoc Duy
2011-07-26  5:14     ` Jeff King
2011-07-26  5:57       ` Nguyen Thai Ngoc Duy
2011-07-26  6:09         ` Jeff King
2011-07-26 12:44           ` Nguyen Thai Ngoc Duy
2011-07-26 13:03             ` Nguyen Thai Ngoc Duy
2011-07-27  8:10               ` Jeff King
2011-07-27  9:02                 ` Nguyen Thai Ngoc Duy
2011-07-27 17:24                   ` Jeff King
2011-07-27  8:03             ` Jeff King
2011-07-27  8:05               ` [PATCH 1/5] add--interactive: refactor patch mode argument processing Jeff King
2011-07-27  8:05               ` [PATCH 2/5] add--interactive: factor out regex error handling Jeff King
2011-07-27  8:05               ` [PATCH 3/5] add--interactive: allow hunk filtering on command line Jeff King
2011-07-27  8:05               ` [PATCH 4/5] add--interactive: allow negatation of hunk filters Jeff King
2011-07-27  8:06               ` [PATCH 5/5] add--interactive: add option to autosplit hunks Jeff King

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20110726050304.GA25046@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=pclouds@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).