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

config.c fixes

From
Kristian Høgsberg <krh@redhat.com>
Date
Dec 14, 2007, 19:22 UTC
Message-ID
<1197660157-24109-1-git-send-email-krh@redhat.com>
Hi,
While strace'ing builtin-clone I saw this horror:

... write(3, "remote", 6) = 6 write(3, " = ", 3) = 3 write(3, "o", 1) = 1 write(3, "r", 1) = 1 write(3, "i", 1) = 1 write(3, "g", 1) = 1 write(3, "i", 1) = 1 write(3, "n", 1) = 1 write(3, "\n", 1) = 1 munmap(0xb7f72000, 102) = 0 close(3) = 0 close(3) = -1 EBADF (Bad file descriptor) ...

That's just terrible. And hey, it turns out the code is terrible too. I think the best solution is to just parse up the entire config file up front and keep it in a data structure, make the changes and then write it all out at the end. That makes it cheap to make a series of changes too:

	config = open_config(file);
	set_key(config, key1, value1);
	set_key(config, key2, value2);
	set_key(config, key3, value3);
	commit_config(config);

Or something. Anyway, for 1.5.4 I wrote the following two patches that fixes the 1-bytes writes and the double close.

 config.c |  113 +++++++++++++++++++++++--------------------------------------
 1 files changed, 43 insertions(+), 70 deletions(-)

cheers, Kristian

Next: Kristian Høgsberg
Message 1 of 8 in “config.c fixes”
  1. Kristian HøgsbergDec 14, 2007
  2. 1/2 Fix config lockfile handling.Kristian Høgsberg, Dec 14, 2007
  3. 2/2 Use a strbuf for building up section header and key/value pair strings.Kristian Høgsberg, Dec 14, 2007
  4. Johannes SchindelinDec 14, 2007
  5. Junio C HamanoDec 14, 2007
  6. Johannes SchindelinDec 14, 2007
  7. Junio C HamanoDec 14, 2007
  8. Johannes SixtDec 14, 2007

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.