git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Junio C Hamano <gitster@pobox.com>
To: "John Lin via GitGitGadget" <gitgitgadget@gmail.com>
Cc: git@vger.kernel.org, John Lin <johnlinp@gmail.com>
Subject: Re: [PATCH 1/1] refactor: rename is_directory() to dir_exists() and use it in clone.c
Date: Wed, 06 Nov 2019 19:59:27 +0900	[thread overview]
Message-ID: <xmqqbltptgmo.fsf@gitster-ct.c.googlers.com> (raw)
In-Reply-To: <b36fdf6a92b3e5392ae45bf5e8a9132c54675d27.1573025315.git.gitgitgadget@gmail.com> (John Lin via GitGitGadget's message of "Wed, 06 Nov 2019 07:28:35 +0000")

"John Lin via GitGitGadget" <gitgitgadget@gmail.com> writes:

> From: John Lin <johnlinp@gmail.com>
>
> The original is_directory() checks whether the given path exists as
> a directory, which makes dir_exists() a more suitable name.

Why?  For a function that takes a path and asked "is this a
directory" that returns "yes/no", "is_directory(path)" is just as a
natural name as, if not more than, "dir_exists(path)".

IOW, "a more suitable name" needs a lot stronger justification than
"it subjectively sounds better to me".

> However, there is already an existing function called dir_exists(),
> while it doesn't check if the path is a directory.

Have you considered the possibility that it is deliberate (iow,
making it check may break the existing callers)?

bultin/clone.c wants to use its dir_exists() to see if *anything*
exists at the path already, so that it can issue an error message
and die when there is a non directory (e.g. a regular file), or a
non-empty directory, when it is told to create a repository.

It is a misnomer, sure, but that does not mean it is OK to break the
existing callers by suddenly saying "no there is not" when a user
tries to say "git clone $URL ~/.bashrc" (which used to fail because
the given destination is a file and it's "dir_exists()" said "oh,
there is something there already so you cannot mkdir there", but
with this patch it would say "nah, that thing is a file, so there is
no directory tehre").

> We decided to do the following:
> - remove the original dir_exists()
> - rename the original is_directory() to dir_exists()
> - use the new dir_exists() where the original dir_exists() is called

For a patch that touches all over the code like this, a summary of
what was done, like the above, is useful in evaluating how sensible
it is that the author wanted to do.  But it should also need to come
with "WHY".  Why does this patch do these three things?  Or, why
"we" (who are they?) decided to do so?

"We decided to do the following" does not answer that question, and
we can see from the patch text that the author decided to do them;
otherwise this patch would not exist ;-).

Thanks.

      reply	other threads:[~2019-11-06 10:59 UTC|newest]

Thread overview: 3+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-11-06  7:28 [PATCH 0/1] refactor: rename is_directory() to dir_exists() and use it in clone.c John Lin via GitGitGadget
2019-11-06  7:28 ` [PATCH 1/1] " John Lin via GitGitGadget
2019-11-06 10:59   ` Junio C Hamano [this message]

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=xmqqbltptgmo.fsf@gitster-ct.c.googlers.com \
    --to=gitster@pobox.com \
    --cc=git@vger.kernel.org \
    --cc=gitgitgadget@gmail.com \
    --cc=johnlinp@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).