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

Re: [PATCH] create_directories: simplify and avoid repeated copying

From
Junio C Hamano <junkio@cox.net>
Date
Apr 14, 2007, 14:11 UTC
Message-ID
<7vlkgv9hbx.fsf@assigned-by-dhcp.cox.net>
In-Reply-To
<20070414013003.B0B4C2F1DC3@geert-boschs-computer.local>
Geert Bosch <bosch@gnat.com> writes:
Show 6 quoted lines
> Signed-off-by: Geert Bosch <bosch@gnat.com>
> ---
> I needed to change the logic of this function a bit for
> doing some local hacks^Wmodifications and thought it might
> be a slight improvement/simplification.
> No change in functionality and passed 'make test'.

I like the removal of repeated copying, but I wonder if the denser condition is really easier to read.

I tried to like it, but I needed to reindent it first, and then I needed to read it three times to convince myself that they are equivalent.

        if (errno != EEXIST
            || ((!force || unlink(buf) || mkdir(buf, 0777))
                && (stat(buf, &st) || !S_ISDIR(st.st_mode))) )
                die("cannot create directory at %s", buf);

In the end, I managed to convince myself that this denser version is doing the same thing as the original, and it is nicer to see it in only three lines, I am not sure if it is easier to read anymore, judging from the time it took me to reach that conclusion...

Previous: Geert Bosch
Message 2 of 2 in “create_directories: simplify and avoid repeated copying”
  1. create_directories: simplify and avoid repeated copyingGeert Bosch, Apr 12, 2007
  2. Junio C HamanoApr 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.