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

Re: [PATCH] commit: ensure correct permissions of the commit message

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 5, 2016, 19:39 UTC
Message-ID
<xmqq37ubke8q.fsf@gitster.mtv.corp.google.com>
In-Reply-To
<alpine.DEB.2.20.1601051342050.14434@virtualbox>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
Show 15 quoted lines
> Hi Junio,
>
> On Mon, 4 Jan 2016, Junio C Hamano wrote:
>
>> Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
>> 
>> >> I do not know fcreate_or_truncate() is a good name, though.
>> >
>> > So what would be a good name?
>> 
>> Have been thinking about it, but I did not come up with anything.  I
>> just know fcreate_or_truncate() is not a good name for multiple
>> reasons I already explained X-<.  sane_fopen_for_writing() perhaps?
>
> That implies that fopen() is insane, though ;-)

Well, sane_X() does not imply X() is "insane". The reason why we introduce sane_X() wrapper often is because X is inconvenient to use sanely as-is.

Look at sane_istest(), sane_case(), etc. We have one byte and want to see if that is space, digit, etc., but we have to cast (possibly signed) char to unsigned char and always doing so in the callers is inconvenient. Look at sane_grep. We have a string and want to see that appears in its input, but some implementations of "grep" can be configured in an inconvenient/unsuitable way to be used in scripts via environment variables, so we disable it not in the callers but in a wrapper.

All we want to do here is to get a writable filehandle FILE * for a path and store the contents we will generate without having to worry about the possibility that the path is already there and we may have to first unlink it to use fopen(3) to do so.

So in the sense, fopen(3) is inconvenient to use sanely as-is. You can call it insane, too ;-)

If we want to follow the X_or_Y() pattern, fopen_or_create() may describe what it does better. I do not have strong preference either way, but again I am not good at naming things (and I suspect you aren't either), so...

Previous: Johannes SchindelinNext: Johannes Schindelin
Message 14 of 45 in “commit: ensure correct permissions of the commit message”
  1. commit: ensure correct permissions of the commit messageJohannes Schindelin, Dec 19, 2015
  2. Jeff KingDec 20, 2015
  3. Johannes SchindelinDec 20, 2015
  4. Torsten BögershausenDec 20, 2015
  5. Johannes SchindelinDec 30, 2015
  6. Junio C HamanoDec 21, 2015
  7. Jeff KingDec 21, 2015
  8. Junio C HamanoDec 21, 2015
  9. Johannes SchindelinDec 30, 2015
  10. Junio C HamanoDec 30, 2015
  11. Johannes SchindelinJan 1, 2016
  12. Junio C HamanoJan 4, 2016
  13. Johannes SchindelinJan 5, 2016
  14. Junio C HamanoJan 5, 2016
  15. Johannes SchindelinJan 6, 2016
  16. Jeff KingJan 6, 2016
  17. Johannes SchindelinJan 6, 2016
  18. SZEDER GáborJan 15, 2016
  19. Junio C HamanoJan 15, 2016
  20. Johannes SchindelinJan 15, 2016
  21. SZEDER GáborJan 15, 2016
  22. Johannes SchindelinJan 15, 2016
  23. 0/2 Correctly handle transient files in shared repositoriesJohannes Schindelin, Jan 6, 2016
  24. 1/2 commit: allow editing the commit message even in shared reposJohannes Schindelin, Jan 6, 2016
  25. Jeff KingJan 7, 2016
  26. Junio C HamanoJan 7, 2016
  27. 2/2 Handle more file writes correctly in shared reposJohannes Schindelin, Jan 6, 2016
  28. Jeff KingJan 7, 2016
  29. Johannes SchindelinJan 8, 2016
  30. Junio C HamanoJan 7, 2016
  31. Johannes SchindelinJan 8, 2016
  32. Junio C HamanoJan 8, 2016
  33. Johannes SchindelinJan 11, 2016
  34. Junio C HamanoJan 11, 2016
  35. Junio C HamanoJan 11, 2016
  36. 0/2 Correctly handle transient files in shared repositoriesJohannes Schindelin, Jan 11, 2016
  37. 1/2 commit: allow editing the commit message even in shared reposJohannes Schindelin, Jan 11, 2016
  38. 2/2 Handle more file writes correctly in shared reposJohannes Schindelin, Jan 11, 2016
  39. Jeff KingJan 11, 2016
  40. Junio C HamanoJan 11, 2016
  41. Junio C HamanoJan 11, 2016
  42. Jeff KingJan 11, 2016
  43. Junio C HamanoJan 11, 2016
  44. Jeff KingJan 11, 2016
  45. Johannes SchindelinJan 12, 2016

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.