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

Re: [PATCH 2/3] revision: add --grep-reflog to filter commits by reflog messages

From
Nguyen Thai Ngoc Duy <pclouds@gmail.com>
Date
Sep 29, 2012, 06:13 UTC
Message-ID
<CACsJy8A1UroqCezJFjqOqBQg+puX=jc1Q-CMSB4f=CHULY=OyA@mail.gmail.com>
In-Reply-To
<7vpq55idbe.fsf@alter.siamese.dyndns.org>
On Sat, Sep 29, 2012 at 12:54 PM, Junio C Hamano <gitster@pobox.com> wrote:
Show 17 quoted lines
>> I like how callers not doing a reflog walk do not have to pay the price
>> to do the extra allocating. We could further limit it to only when
>> --grep-reflog is in effect, but I guess that would mean wading through
>> grep_filter's patterns, since it could be buried amidst ANDs and ORs?
>>
>> One alternative would be to set a bit in the grep_opt when we call
>> append_header_grep_pattern. It feels a bit like a layering violation,
>> though. I guess the bit could also go into rev_info. It may not even be
>> a measurable slowdown, though. Premature optimization and all that.
>
> I do not think it is a layering violation.  compile_grep_exp()
> should be aware of the short-cut possibilities and your "our
> expression is interested in reflog so we need to read it" is very
> similar in spirit to the existing opt->extended bit.
>
> It will obviously allow us to avoid reading reflog information
> unnecessarily here.  I think it makes perfect sense.

reflog, in terms of both the number of commits and message length, is usually short enough that slowdown does not really show, especially when used with git-log, an interactive command.

Without the changes:
$ time git log -g --grep . >/dev/null

real 0m0.480s user 0m0.451s sys 0m0.025s

With the changes:
$ time ./git log -g --grep . >/dev/null

real 0m0.490s user 0m0.471s sys 0m0.018s

> We may also want to flag the use of the --grep-reflog option when
> the --walk-reflogs option is not in effect in setup_revisions() as
> an error, or something.

That's why I put "Ignored unless --walk-reflogs is given" in the document. But an error would be fine too. I suppose an error is preferable in case users do not read document carefully?

-- 
Duy
Previous: Junio C HamanoNext: Junio C Hamano
Message 18 of 25 in “revision: add --reflog-message=<pattern> to grep reflog messages”
  1. revision: add --reflog-message=<pattern> to grep reflog messagesNguyễn Thái Ngọc Duy, Sep 26, 2012
  2. Junio C HamanoSep 26, 2012
  3. Nguyen Thai Ngoc DuySep 26, 2012
  4. Junio C HamanoSep 26, 2012
  5. revision: add --reflog-message to grep reflog messagesNguyễn Thái Ngọc Duy, Sep 27, 2012
  6. Junio C HamanoSep 27, 2012
  7. Jeff KingSep 27, 2012
  8. Junio C HamanoSep 27, 2012
  9. 1/3 grep: generalize header grep code to accept arbitrary headersNguyễn Thái Ngọc Duy, Sep 28, 2012
  10. 2/3 revision: add --grep-reflog to filter commits by reflog messagesNguyễn Thái Ngọc Duy, Sep 28, 2012
  11. Junio C HamanoSep 28, 2012
  12. Nguyễn Thái Ngọc DuySep 29, 2012
  13. 1/3 grep: prepare for new header field filterNguyễn Thái Ngọc Duy, Sep 29, 2012
  14. Jeff KingSep 29, 2012
  15. 2/3 revision: add --grep-reflog to filter commits by reflog messagesNguyễn Thái Ngọc Duy, Sep 29, 2012
  16. Jeff KingSep 29, 2012
  17. Junio C HamanoSep 29, 2012
  18. Nguyen Thai Ngoc DuySep 29, 2012
  19. Junio C HamanoSep 29, 2012
  20. Nguyen Thai Ngoc DuySep 30, 2012
  21. Jeff KingSep 29, 2012
  22. 3/3 revision: make --grep search in notes too if shownNguyễn Thái Ngọc Duy, Sep 29, 2012
  23. Junio C HamanoSep 29, 2012
  24. 3/3 revision: make --grep search in notes too if shownNguyễn Thái Ngọc Duy, Sep 28, 2012
  25. Junio C HamanoSep 28, 2012

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.