Re: [PATCH v4 09/24] ls-files.c: use index api

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

 



Antoine Pelisse <apelisse@xxxxxxxxx> writes:

> On Wed, Nov 27, 2013 at 1:00 PM, Thomas Gummerer <t.gummerer@xxxxxxxxx> wrote:
>> @@ -447,6 +463,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
>>         struct dir_struct dir;
>>         struct exclude_list *el;
>>         struct string_list exclude_list = STRING_LIST_INIT_NODUP;
>> +       struct filter_opts *opts = xmalloc(sizeof(*opts));
>>         struct option builtin_ls_files_options[] = {
>>                 { OPTION_CALLBACK, 'z', NULL, NULL, NULL,
>>                         N_("paths are separated with NUL character"),
>> @@ -512,9 +529,6 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
>>                 prefix_len = strlen(prefix);
>>         git_config(git_default_config, NULL);
>>
>> -       if (read_cache() < 0)
>> -               die("index file corrupt");
>> -
>>         argc = parse_options(argc, argv, prefix, builtin_ls_files_options,
>>                         ls_files_usage, 0);
>>         el = add_exclude_list(&dir, EXC_CMDL, "--exclude option");
>> @@ -550,6 +564,24 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix)
>>                        PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
>>                        prefix, argv);
>>
>> +       if (!with_tree && !needs_trailing_slash_stripped()) {
>> +               memset(opts, 0, sizeof(*opts));
>> +               opts->pathspec = &pathspec;
>> +               opts->read_staged = 1;
>> +               if (show_resolve_undo)
>> +                       opts->read_resolve_undo = 1;
>> +               if (read_cache_filtered(opts) < 0)
>> +                       die("index file corrupt");
>> +       } else {
>> +               if (read_cache() < 0)
>> +                       die("index file corrupt");
>> +               parse_pathspec(&pathspec, 0,
>> +                              PATHSPEC_PREFER_CWD |
>> +                              PATHSPEC_STRIP_SUBMODULE_SLASH_CHEAP,
>> +                              prefix, argv);
>> +
>> +       }
>> +
>
> Would it make sense to move the declaration of "opts" as a non-pointer
> to the block where it's used ?

Yes, I think that would make sense, will do so in the re-roll. Thanks!
--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html




[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]