Re: [GSoC] [PATCH v2 4/9] dir: libify and export helper functions from clone.c
- From
Junio C Hamano <gitster@pobox.com>
- Date
- Aug 6, 2021, 16:36 UTC
- Message-ID
- <xmqq1r76jzsk.fsf@gitster.g>
- In-Reply-To
- <m235rmvnc1.fsf@gmail.com>
Atharva Raykar <raykar.ath@gmail.com> writes:
> Naming things is hard...
Absolutely.
Show 8 quoted lines
> 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 ;-)