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

Re: [PATCH] Teach git log --check to return an appropriate error code

From
PLPeter Valdemar Mørch (Lists) <4ux6as402@sneakemail.com>
Date
Aug 10, 2008, 17:05 UTC
Message-ID
<489F1FE4.6090400@sneakemail.com>
In-Reply-To
<7v8wv66l8d.fsf@gitster.siamese.dyndns.org>
Junio C Hamano gitster-at-pobox.com |Lists| wrote:
Show 12 quoted lines
> Future versions of log_tree_diff() may want to tweak opt->diffopt per
> commit, when we have options for "use larger -U<lines> value after hitting
> this commit", or "use this pathspec to limit the diff output after hitting
> this commit", for example.  But even in these cases, I think it is
> implausible to start from a freshly initialized diff_options structure.
> The code most likely would start from the copy of what was in use and
> update only the necessary fields, without disturbing the state variables.
> 
> So I think you are worried a bit too much in this case, even though it is
> a valid concern in principle.  It might warrant a comment somewhere inside
> log_tree_diff() to tell people not to re-initialize opt->diffopt per
> commit without thinking, though.

Hmm... I've looked at the code... The while loop that iterates through the revisions is in cmd_log_walk(), which calls log_tree_commit(), which in turn calls log_tree_diff().

I'm thinking that cmd_log_walk() is where one "would want" to change rev->diffopt / opt->diffopt in the future, and hence I suggest to put the comment there - given my limited understanding of connecting tissue. Something like:

/* For --check, the exit code is based on CHECK_FAILED
    being accumulated in rev->diffopt, so be careful to retain
    that state information if replacing rev->diffopt in this
    loop */

That would also be 10-15 lines above the patch I posted earlier, so the connection with retrieving the error code would be visible 15 lines below.

Would such a comment in that place constiture and acceptable patch? I've tried to follow Dscho's write up and contribute a patch, even though git-log's exit code was never my itch to begin with, because I'm exited to contribute.

> One interesting option that might be interesting to add to the log family
> would be to show only commits that fail the checkdiff tests.  I suspect
> necessary change for doing so would go to log_tree_diff() codepath.

I'm hoping that this is meant as "aside from this current patch, one interesting option..." or do you mean "in order for this patch to be accepted, I suggest this to be added ..." ?

This is growing. I originally suggested a patch to documentation to make it match the code, but took on Dscho's invitation to contribute a code patch instead. But given that this patch, although working, still isn't good enough and the new proposals : the new option above and --exit-code proposal elsewhere in this thread, I'm getting a little discouraged. I'm not saying you meant it that way.

Peter
-- 
Peter Valdemar Mørch
http://www.morch.com
Previous: Junio C HamanoNext: Junio C Hamano
Message 11 of 18 in “git diff/log --check exitcode and PAGER environment variable”
  1. Peter Valdemar Mørch (Lists)Aug 8, 2008
  2. Junio C HamanoAug 8, 2008
  3. Peter Valdemar Mørch (Lists)Aug 8, 2008
  4. Re* git diff/log --check exitcode and PAGER environment variableJunio C Hamano, Aug 8, 2008
  5. Peter Valdemar Mørch (Lists)Aug 8, 2008
  6. Johannes SchindelinAug 8, 2008
  7. Junio C HamanoAug 8, 2008
  8. Teach git log --check to return an appropriate error codePeter Valdemar Mørch, Aug 9, 2008
  9. Johannes SchindelinAug 9, 2008
  10. Junio C HamanoAug 9, 2008
  11. Peter Valdemar Mørch (Lists)Aug 10, 2008
  12. Junio C HamanoAug 10, 2008
  13. Junio C HamanoAug 9, 2008
  14. PATCH v2 0/2 Trying patch againPeter Valdemar Mørch, Aug 11, 2008
  15. 1/2 Teach git log --check to return an appropriate exit codePeter Valdemar Mørch, Aug 11, 2008
  16. 2/2 Teach git log --exit-code to return an appropriate exit codePeter Valdemar Mørch, Aug 11, 2008
  17. Jeff KingAug 8, 2008
  18. Jeff KingAug 8, 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.