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

Re: [PATCH/RFC 2/4] contrib: contacts: add support for multiple patches

From
Eric Sunshine <sunshine@sunshineco.com>
Date
Jul 2, 2013, 08:52 UTC
Message-ID
<CAPig+cTO2vMg1Feb+3WGa=h89r-xAF=zpG9fxvDwR0HaUJK=jg@mail.gmail.com>
In-Reply-To
<7v7ghaglmx.fsf@alter.siamese.dyndns.org>
On Mon, Jul 1, 2013 at 2:50 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 40 quoted lines
> Eric Sunshine <sunshine@sunshineco.com> writes:
>
>> Accept multiple patch files rather than only one. For example:
>>
>>   % git contacts feature/*.patch
>>
>> Signed-off-by: Eric Sunshine <sunshine@sunshineco.com>
>
>> @@ -93,6 +96,7 @@ sub commits_from_patch {
>>       while (<$f>) {
>>               if (/^From ($id_rx) /o) {
>>                       $id = $1;
>> +                     $seen{$id} = 1;
>>                       last;
>>               }
>>       }
>
> This looks less useful than it could be.
>
>         $ git format-patch --stdout -4 >P.mbox
>         $ git contacts P.mbox
>
> would have the same number of patches but in a single file.
>
> Wouldn't it be more useful to do something like
>
>         $id = undef;
>         while (<$f>) {
>                 if (/^From ([0-9a-f]{40}) Mon Sep 17 00:00:00 2001$/) {
>                         # beginning of a patch
>                         $id = $1;
>                 }
>                 next if (!defined $id);
>                 # inline the body of scan_hunks here...
>                 if (m{^--- (a/.*|/dev/null)$}) {
>                         $source = ...
>                 } elsif (/^@@ -(\d+)...) {
>                         get_blame();
>                 }
>         }

Good point. It did not occur to me that a single file might contain multiple patches. Felipe's script handled this case correctly.

Show 20 quoted lines
>> @@ -100,10 +104,8 @@ sub commits_from_patch {
>>       close $f;
>>  }
>>
>> -exit 1 unless @ARGV == 1;
>> -
>>  my %commits;
>> -commits_from_patch(\%commits, $ARGV[0]);
>> +commits_from_patch(\%commits, $_) for (@ARGV);
>
> This change does not seem to account for an invocation without any
> argument.  Perhaps write it like so to make it more readable?
>
>         if (!@ARGV) {
>                 die "No input file?\n";
>         }
>
>         for (@ARGV) {
>                 commits_from_patch(\%commits, $_);
>         }
Emitting a diagnostic about missing input makes sense.
Previous: Junio C HamanoNext: Eric Sunshine
Message 11 of 15 in “Perl rewrite of Ruby git-related”
  1. 0/4 Perl rewrite of Ruby git-relatedEric Sunshine, Jun 30, 2013
  2. 1/4 contrib: add git-contacts helperEric Sunshine, Jun 30, 2013
  3. Junio C HamanoJul 1, 2013
  4. Junio C HamanoJul 1, 2013
  5. Eric SunshineJul 2, 2013
  6. Junio C HamanoJul 2, 2013
  7. Eric SunshineJul 2, 2013
  8. 2/4 contrib: contacts: add support for multiple patchesEric Sunshine, Jun 30, 2013
  9. Junio C HamanoJul 1, 2013
  10. Junio C HamanoJul 1, 2013
  11. Eric SunshineJul 2, 2013
  12. 3/4 contrib: contacts: add ability to parse from committishEric Sunshine, Jun 30, 2013
  13. 4/4 contrib: contacts: interpret committish akin to format-patchEric Sunshine, Jun 30, 2013
  14. Junio C HamanoJul 1, 2013
  15. Eric SunshineJul 2, 2013

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.