Re: [GSoC] [PATCH v2 4/9] dir: libify and export helper functions from clone.c

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Junio C Hamano <gitster@xxxxxxxxx> writes:

> Atharva Raykar <raykar.ath@xxxxxxxxx> writes:
>
>> These functions can be useful to other parts of Git. Let's move them to
>> dir.c, while renaming them to be make their functionality more explicit.
>
> Hmph, guess_dir_name_from_git_url() is not all that more clarifying
> than the original, at least to me.  For a file-scope static helper,
> it probably was good enough with a short name with no function doc,
> but we should describe what it does in comments in dir.h and come up
> with a suitable name, taking input from that description.
>
> [...]
>
>> @@ -1041,8 +927,8 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
>>  	if (argc == 2)
>>  		dir = xstrdup(argv[1]);
>>  	else
>> -		dir = guess_dir_name(repo_name, is_bundle, option_bare);
>> -	strip_trailing_slashes(dir);
>> +		dir = guess_dir_name_from_git_url(repo_name, is_bundle, option_bare);
>> +	strip_dir_trailing_slashes(dir);
>
> So, what does this new public helper function guess?  The name of
> the function says it guesses a directory name, but it is not just
> any directory name, but a directory with some specific meaning.
>
> Here repo_name has the URL the user gave "git clone", and even
> though there are some code before this part that computed on the
> variable, it hasn't been modified.  And "from_git_url" is a good way
> to indicate that that is one of the input the function uses to guess
> the name of "the directory with some unknown specific meaning".
>
> I think this codepath wants the new directory to create as the
> result of "git clone" operation in "dir".  So, even though I still
> do not have a good answer to the earlier "this is not just any
> directory but with some specific meaning---what is it?" question,
> adjectives that are appropriate for the "directory" to answer it
> may be along the lines of "new", "resulting", "cloned", etc.

Naming things is hard...

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()'

This would make sense for any operation now or in the future that wants
to reuse this functionality.

>> diff --git a/dir.h b/dir.h
>> index b3e1a54a97..76441dde2d 100644
>> --- a/dir.h
>> +++ b/dir.h
>> @@ -453,6 +453,9 @@ static inline int is_dot_or_dotdot(const char *name)
>>
>>  int is_empty_dir(const char *dir);
>>
>
> We would want docstring here for the function (and possibly rename
> the function to clarify what kind of "dir" we are talking about).

Okay, I will add it.

>> +char *guess_dir_name_from_git_url(const char *repo, int is_bundle, int is_bare);
>> +void strip_dir_trailing_slashes(char *dir);
>> +
>>  void setup_standard_excludes(struct dir_struct *dir);
>>
>>  char *get_sparse_checkout_filename(void);
>
> Thanks.



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]

  Powered by Linux