Code

apply: run setup_git_directory_gently() sooner
[git.git] / builtin / apply.c
index 562e5345fc969a5ad03b3ade4952668bcec09136..f005ba1e8934d4383f6181737a53a388d8b03a61 100644 (file)
@@ -2628,7 +2628,7 @@ static struct patch *in_fn_table(const char *name)
        if (name == NULL)
                return NULL;
 
-       item = string_list_lookup(name, &fn_table);
+       item = string_list_lookup(&fn_table, name);
        if (item != NULL)
                return (struct patch *)item->util;
 
@@ -2664,7 +2664,7 @@ static void add_to_fn_table(struct patch *patch)
         * file creations and copies
         */
        if (patch->new_name != NULL) {
-               item = string_list_insert(patch->new_name, &fn_table);
+               item = string_list_insert(&fn_table, patch->new_name);
                item->util = patch;
        }
 
@@ -2673,7 +2673,7 @@ static void add_to_fn_table(struct patch *patch)
         * later chunks shouldn't patch old names
         */
        if ((patch->new_name == NULL) || (patch->is_rename)) {
-               item = string_list_insert(patch->old_name, &fn_table);
+               item = string_list_insert(&fn_table, patch->old_name);
                item->util = PATH_WAS_DELETED;
        }
 }
@@ -2686,7 +2686,7 @@ static void prepare_fn_table(struct patch *patch)
        while (patch) {
                if ((patch->new_name == NULL) || (patch->is_rename)) {
                        struct string_list_item *item;
-                       item = string_list_insert(patch->old_name, &fn_table);
+                       item = string_list_insert(&fn_table, patch->old_name);
                        item->util = PATH_TO_BE_DELETED;
                }
                patch = patch->next;
@@ -3394,7 +3394,7 @@ static void add_name_limit(const char *name, int exclude)
 {
        struct string_list_item *it;
 
-       it = string_list_append(name, &limit_by_name);
+       it = string_list_append(&limit_by_name, name);
        it->util = exclude ? NULL : (void *) 1;
 }
 
@@ -3607,11 +3607,11 @@ static int option_parse_directory(const struct option *opt,
        return 0;
 }
 
-int cmd_apply(int argc, const char **argv, const char *unused_prefix)
+int cmd_apply(int argc, const char **argv, const char *prefix_)
 {
        int i;
        int errs = 0;
-       int is_not_gitdir;
+       int is_not_gitdir = !startup_info->have_repository;
        int binary;
        int force_apply = 0;
 
@@ -3684,7 +3684,7 @@ int cmd_apply(int argc, const char **argv, const char *unused_prefix)
                OPT_END()
        };
 
-       prefix = setup_git_directory_gently(&is_not_gitdir);
+       prefix = prefix_;
        prefix_length = prefix ? strlen(prefix) : 0;
        git_config(git_apply_config, NULL);
        if (apply_default_whitespace)