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

Re: [PATCH v3 4/4] wt-status.c: Set the committable flag in the collect phase.

From
SSStephen Smith <ischis2@cox.net>
Date
Sep 24, 2018, 03:15 UTC
Message-ID
<2295579.U4Xb9QnJqG@thunderbird>
In-Reply-To
<xmqqworxufuv.fsf@gitster-ct.c.googlers.com>
On Friday, September 7, 2018 3:31:55 PM MST Junio C Hamano wrote:
Show 8 quoted lines
> For example, I noticed that both of the old
> callsites of wt_status_get_state() have free() of a few fiedls in
> the structure, and I kept the code as close to the original, but I
> suspect they should not be freed there in the functions in the
> "print" phase, but rather the caller of the "collect" and "print"
> should be made responsible for deciding when to dispose the entire
> wt_status (and wt_status_state as part of it).  This illustration
> patch does not address that kind of details (yet).

I followed the call tree back to original callers run_status() and cmd_status() in commit.c

This leads to a philosophical question. We want to move the state information out of the print functions because it doesn't seem correct. For the case in question this includes the calls to free() . By doing this we seem go have traded one location that shouldn't be touching the state variables for another.

I can see three solutions and could support any of the three:
1) Move the free calls to run_status() and cmd_status().
2) Move the calls calls to wt_status_print since that is the last function 
from wt_status.c that is called befor the structure goes out of scope in  
run_status() and cmd_status().
3) Add a new wt_collect*() function to free the variables. This would have an 
advantage that the free calls could be grouped in on place and not done in to 
functions.  A second advantage is that the free calls would be located where 
the pointers are initialized.  

Personally I like solutions 1 and 3 over 2. What do others think?

sps
Previous: Junio C HamanoNext: Junio C Hamano
Message 21 of 25 in “wt-status.c: commitable flag”
  1. 0/4 wt-status.c: commitable flagStephen P. Smith, Sep 6, 2018
  2. 1/4 Move has_unmerged earlier in the file.Stephen P. Smith, Sep 6, 2018
  3. 3/4 t7501: add test of "commit --dry-run --short"Stephen P. Smith, Sep 6, 2018
  4. 2/4 wt-status: rename commitable to committableStephen P. Smith, Sep 6, 2018
  5. Junio C HamanoSep 7, 2018
  6. 4/4 wt-status.c: Set the committable flag in the collect phase.Stephen P. Smith, Sep 6, 2018
  7. Junio C HamanoSep 7, 2018
  8. Junio C HamanoSep 7, 2018
  9. 0/1 wt-status-state-cleanupStephen P. Smith, Sep 28, 2018
  10. 1/1 roll wt_status_state into wt_status and populate in the collect phaseStephen P. Smith, Sep 28, 2018
  11. Taylor BlauSep 28, 2018
  12. Junio C HamanoSep 28, 2018
  13. 0/1 wt-status-state-cleanupStephen P. Smith, Sep 29, 2018
  14. 1/1 roll wt_status_state into wt_status and populate in the collect phaseStephen P. Smith, Sep 29, 2018
  15. Eric SunshineSep 30, 2018
  16. 0/1 wt-status-state-cleanupStephen P. Smith, Sep 30, 2018
  17. 1/1 roll wt_status_state into wt_status and populate in the collect phaseStephen P. Smith, Sep 30, 2018
  18. Eric SunshineSep 30, 2018
  19. Stephen P. SmithSep 7, 2018
  20. Junio C HamanoSep 11, 2018
  21. Stephen SmithSep 24, 2018
  22. Junio C HamanoSep 24, 2018
  23. Ævar Arnfjörð BjarmasonSep 6, 2018
  24. Stephen & Linda SmithSep 6, 2018
  25. Junio C HamanoSep 7, 2018

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.