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

Re: [PATCH 1/2] Add / command in add --patch (feature request)

From
Junio C Hamano <gitster@pobox.com>
Date
Nov 26, 2008, 21:55 UTC
Message-ID
<7vljv6duez.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<492DB6C8.7010205@gmail.com>
William Pursell <bill.pursell@gmail.com> writes:
Show 16 quoted lines
> diff --git a/git-add--interactive.perl b/git-add--interactive.perl
> index b0223c3..7ad4ee0 100755
> --- a/git-add--interactive.perl
> +++ b/git-add--interactive.perl
> @@ -876,12 +876,14 @@ sub patch_update_file {
>
>  	$num = scalar @hunk;
>  	$ix = 0;
> +	my $search_s; # User entered string to match a hunk.
>
>  	while (1) {
>  		my ($prev, $next, $other, $undecided, $i);
>  		$other = '';
>
>  		if ($num <= $ix) {
> +			$search_s = 0;
People cannot look for string "0"?
Instead, set this to 'undef' and check with:
	if (defined $search_string) {
        	...
in the later part of the code.
Show 11 quoted lines
> @@ -916,11 +918,24 @@ sub patch_update_file {
>  			$other .= '/s';
>  		}
>  		$other .= '/e';
> -		for (@{$hunk[$ix]{DISPLAY}}) {
> -			print;
> +
> +		my $line;
> +		if( $search_s ) {
> +			my $text = join( "", @{$hunk[$ix]{DISPLAY}} );
> +			if( $text !~ $search_s ) {
Style.
    (1) SP between language construct and open parenthesis, as opposed to
        no extra SP between function name and open parenthesis;
    (2) No extra SP around what is enclosed in parentheses.
No help text added to help people discover this new feature?

The interactive help prompt is hard to read because '/' is used to separate choices. I'd suggest to make this into two patches:

Patch 1/2 would change use of '/' to ',' so that this:
    Stage this hunk [y/n/a/d/j/J/e/?]?
becomes
    Stage this hunk [y,n,a,d,j,J,e,?]?
Patch 2/2 would be a fix-up of the patch you sent.
Thanks.
Previous: William PursellNext: Jeff King
Message 2 of 7 in “Add / command in add --patch (feature request)”
  1. 1/2 Add / command in add --patch (feature request)William Pursell, Nov 26, 2008
  2. Junio C HamanoNov 26, 2008
  3. Jeff KingNov 26, 2008
  4. Junio C HamanoNov 26, 2008
  5. William PursellNov 27, 2008
  6. Junio C HamanoNov 27, 2008
  7. Johannes SchindelinNov 27, 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.