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.