Merge branch 'da/user-useconfigonly'
[gitweb.git] / builtin / fetch.c
index 586840d761a9c14142ee35cdd53e2e4f96648209..8e742135f049c2792bfc5a20299dac88518929cc 100644 (file)
@@ -840,7 +840,7 @@ static void check_not_current_branch(struct ref *ref_map)
 static int truncate_fetch_head(void)
 {
        const char *filename = git_path_fetch_head();
-       FILE *fp = fopen(filename, "w");
+       FILE *fp = fopen_for_writing(filename);
 
        if (!fp)
                return error(_("cannot open %s: %s\n"), filename, strerror(errno));
@@ -1225,6 +1225,8 @@ int cmd_fetch(int argc, const char **argv, const char *prefix)
        list.strdup_strings = 1;
        string_list_clear(&list, 0);
 
+       close_all_packs();
+
        argv_array_pushl(&argv_gc_auto, "gc", "--auto", NULL);
        if (verbosity < 0)
                argv_array_push(&argv_gc_auto, "--quiet");