Re: [PATCH v3 05/12] refs: move submodule slash stripping code to get_submodule_ref_store
- From
Johannes Sixt <j6t@kdbg.org>
- Date
- Apr 19, 2017, 22:02 UTC
- Message-ID
- <a74cf309-fb16-2f45-8189-d1d0c655dea4@kdbg.org>
- In-Reply-To
- <20170419110145.5086-6-pclouds@gmail.com>
Am 19.04.2017 um 13:01 schrieb Nguyễn Thái Ngọc Duy:
Show 11 quoted lines
> @@ -1558,7 +1543,17 @@ struct ref_store *get_submodule_ref_store(const char *submodule)
> {
> struct strbuf submodule_sb = STRBUF_INIT;
> struct ref_store *refs;
> + char *to_free = NULL;
> int ret;
> + size_t len;
> +
> + if (submodule) {
> + len = strlen(submodule);
> + while (len && submodule[len - 1] == '/')What is the source of the value of 'submodule'? Is it an index entry? Or did it pass through parse_pathspec? In these cases it is correct to compare against literal '/'. Otherwise, is_dir_sep() is preferred.
Show 7 quoted lines
> + len--;
> + if (!len)
> + submodule = NULL;
> + }
>
> if (!submodule || !*submodule) {
> /*-- Hannes