Atharva Raykar [off-list ref] writes:
Naming things is hard...
Absolutely.
Maybe the right phrase would be 'target directory'? We are creating a
target directory name by looking at the "humanish" part of the Git URL.
I think the intention of all callers of this function is to get a
"default" directory name which will be used as the target of some
operation in the absence of the user providing one.
So maybe the name could be: 'guess_target_dir_from_git_url()'
I have no immediate objection to the name.
Just to see how people (including you) may react to a name from a
completely different line of thinking, let me throw this, though.
How does git_url_basename() sound?
Instead of saying what we'd use it for (i.e. as the name for the
directory getting created), we say what we compute. We take a
URL-looking thing that is used by Git, and we compute something like
basename() but that is tailored for Git (e.g. unlike "basename
a/b/c.git" that yields "c.git", we give "c" for "a/b/c.git".
Likewise "<scheme>://a/b/c/.git" won't yield ".git", we compute
"c").
Having said that, I think guess_target_dir_from_git_url() is clear
enough.
This would make sense for any operation now or in the future that wants
to reuse this functionality.
That is mostly for you to decide. I can help you sanity check the
proposed name(s) with existing callers, but you'd be a better judge
for callers you'll be adding ;-)
Junio C Hamano [off-list ref] writes:
Atharva Raykar [off-list ref] writes:
quoted
Naming things is hard...
Absolutely.
quoted
Maybe the right phrase would be 'target directory'? We are creating a
target directory name by looking at the "humanish" part of the Git URL.
I think the intention of all callers of this function is to get a
"default" directory name which will be used as the target of some
operation in the absence of the user providing one.
So maybe the name could be: 'guess_target_dir_from_git_url()'
I have no immediate objection to the name.
Just to see how people (including you) may react to a name from a
completely different line of thinking, let me throw this, though.
How does git_url_basename() sound?
Instead of saying what we'd use it for (i.e. as the name for the
directory getting created), we say what we compute. We take a
URL-looking thing that is used by Git, and we compute something like
basename() but that is tailored for Git (e.g. unlike "basename
a/b/c.git" that yields "c.git", we give "c" for "a/b/c.git".
Likewise "<scheme>://a/b/c/.git" won't yield ".git", we compute
"c").
Having said that, I think guess_target_dir_from_git_url() is clear
enough.
Even though the name I suggested is clear enough, I liked your
suggestion a lot more. Not only is it more succinct, but it also opens
up the future possibility that the basename of a Git URL might be used
for purposes other than finding a directory name.
quoted
This would make sense for any operation now or in the future that wants
to reuse this functionality.
That is mostly for you to decide. I can help you sanity check the
proposed name(s) with existing callers, but you'd be a better judge
for callers you'll be adding ;-)