From patchwork Tue Mar 16 21:16:49 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144101 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C243DC43331 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A99D264F91 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233226AbhCPVRa (ORCPT ); Tue, 16 Mar 2021 17:17:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55836 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233040AbhCPVRU (ORCPT ); Tue, 16 Mar 2021 17:17:20 -0400 Received: from mail-wr1-x430.google.com (mail-wr1-x430.google.com [IPv6:2a00:1450:4864:20::430]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9AEF0C06174A for ; Tue, 16 Mar 2021 14:17:19 -0700 (PDT) Received: by mail-wr1-x430.google.com with SMTP id v4so8174190wrp.13 for ; Tue, 16 Mar 2021 14:17:19 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=6NgjP2HIjVJd9+5WKWUw24ZAuJZNBpeiVFI3QTXTaxo=; b=r5TGlictJmZTI8E/d07tO1CL1/tgJhB7+n8+HVmtfFIBBJrO9bxu318Ao5OU53021t YEAkxawhSizhtq6iW5OYz9Td9zxKSpw+9/j4hiDjH0SueCE8whmV4pOfWWGYjPuM4IMe UjeJ+6uRFsPwzJSHsrLR1tiQx7SKlZK5MExoxfsI87dpXGpEnsDaQATPPb7R1cy+ba7u 9DTtFmWiKzHljKWxlqijIQRJtwnvk3IH5E/VY8sO6P2wbTj3GJJhGkzmWuCH4Z01+f4D lXHs9rje4xlRPfzqIJ/EoVKtWfrZ75HRTH3UB3nCn3s9IGHRtHb7zTboL0CL7Ro1c8Wr zN8w== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=6NgjP2HIjVJd9+5WKWUw24ZAuJZNBpeiVFI3QTXTaxo=; b=VdUxpeC0pMBXZiCA9aARZyir4wRMaIWZPJ1/YDwAduuf8PFp8LCH8Bq5O9vyEAvJ/4 GW8JJuE6iGL0ncuNcK6dTmuh59++mYcgZHJxa0/JikUo5hL2rYxRdlyHG3+bcRKkruBO qwDIePBZqz07Ztu9fecAJxpmP/qCOVxjtDRtB0oG0kWJMOMoFxF7EF/UefKwr0ZjBIzP QEEj80Aksn7Yth5Cjcof+3GICX057BgzPYmubMVuzC+UYMF1G3xNeIW+CCZa+svetPYr TLkwCzEnEy/ER9w8xR9btt/DuaSv2NLvW0Mlsw8fO447fwWM6pq6Q0dO0j+AZaxFIwjF isWg== X-Gm-Message-State: AOAM530eNMtrAr8Imp9ppCOZ1WnbnAybKzAmjB0mzsILf3toErg2tojM LadLlZ5iThJ6UNZgB+4PEbTs5z3umbY= X-Google-Smtp-Source: ABdhPJxwlEELR7NV3mAwZP01QN7EvPadyidxwiaAAf3gebP9wOyCBGPqB1eYDVxN0jD86goAHrbRdg== X-Received: by 2002:adf:c752:: with SMTP id b18mr916687wrh.233.1615929438298; Tue, 16 Mar 2021 14:17:18 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b186sm476100wmc.44.2021.03.16.14.17.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:17 -0700 (PDT) Message-Id: <628e16dd3fc7be96d40a7b3201573a71ae7fbbd6.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:49 +0000 Subject: [PATCH 01/27] *: remove 'const' qualifier for struct index_state Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Several methods specify that they take a 'struct index_state' pointer with the 'const' qualifier because they intend to only query the data, not change it. However, we will be introducing a step very low in the method stack that might modify a sparse-index to become a full index in the case that our queries venture inside a sparse-directory entry. This change only removes the 'const' qualifiers that are necessary for the following change which will actually modify the implementation of index_name_stage_pos(). Signed-off-by: Derrick Stolee --- attr.c | 14 +++++++------- attr.h | 4 ++-- builtin/ls-files.c | 10 +++++----- cache.h | 6 +++--- convert.c | 26 +++++++++++++------------- convert.h | 20 ++++++++++---------- dir.c | 12 ++++++------ dir.h | 8 ++++---- merge-recursive.c | 2 +- pathspec.c | 6 +++--- pathspec.h | 6 +++--- read-cache.c | 10 +++++----- submodule.c | 6 +++--- submodule.h | 6 +++--- 14 files changed, 68 insertions(+), 68 deletions(-) diff --git a/attr.c b/attr.c index 4ef85d668b54..8de553293ee4 100644 --- a/attr.c +++ b/attr.c @@ -718,7 +718,7 @@ static struct attr_stack *read_attr_from_file(const char *path, int macro_ok) return res; } -static struct attr_stack *read_attr_from_index(const struct index_state *istate, +static struct attr_stack *read_attr_from_index(struct index_state *istate, const char *path, int macro_ok) { @@ -748,7 +748,7 @@ static struct attr_stack *read_attr_from_index(const struct index_state *istate, return res; } -static struct attr_stack *read_attr(const struct index_state *istate, +static struct attr_stack *read_attr(struct index_state *istate, const char *path, int macro_ok) { struct attr_stack *res = NULL; @@ -840,7 +840,7 @@ static void push_stack(struct attr_stack **attr_stack_p, } } -static void bootstrap_attr_stack(const struct index_state *istate, +static void bootstrap_attr_stack(struct index_state *istate, struct attr_stack **stack) { struct attr_stack *e; @@ -878,7 +878,7 @@ static void bootstrap_attr_stack(const struct index_state *istate, push_stack(stack, e, NULL, 0); } -static void prepare_attr_stack(const struct index_state *istate, +static void prepare_attr_stack(struct index_state *istate, const char *path, int dirlen, struct attr_stack **stack) { @@ -1078,7 +1078,7 @@ static void determine_macros(struct all_attrs_item *all_attrs, * If check->check_nr is non-zero, only attributes in check[] are collected. * Otherwise all attributes are collected. */ -static void collect_some_attrs(const struct index_state *istate, +static void collect_some_attrs(struct index_state *istate, const char *path, struct attr_check *check) { @@ -1107,7 +1107,7 @@ static void collect_some_attrs(const struct index_state *istate, fill(path, pathlen, basename_offset, check->stack, check->all_attrs, rem); } -void git_check_attr(const struct index_state *istate, +void git_check_attr(struct index_state *istate, const char *path, struct attr_check *check) { @@ -1124,7 +1124,7 @@ void git_check_attr(const struct index_state *istate, } } -void git_all_attrs(const struct index_state *istate, +void git_all_attrs(struct index_state *istate, const char *path, struct attr_check *check) { int i; diff --git a/attr.h b/attr.h index 404548f028a8..3732505edae8 100644 --- a/attr.h +++ b/attr.h @@ -190,14 +190,14 @@ void attr_check_free(struct attr_check *check); */ const char *git_attr_name(const struct git_attr *); -void git_check_attr(const struct index_state *istate, +void git_check_attr(struct index_state *istate, const char *path, struct attr_check *check); /* * Retrieve all attributes that apply to the specified path. * check holds the attributes and their values. */ -void git_all_attrs(const struct index_state *istate, +void git_all_attrs(struct index_state *istate, const char *path, struct attr_check *check); enum git_attr_direction { diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 13bcc2d84735..76a0d35c1a01 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -57,7 +57,7 @@ static const char *tag_modified = ""; static const char *tag_skip_worktree = ""; static const char *tag_resolve_undo = ""; -static void write_eolinfo(const struct index_state *istate, +static void write_eolinfo(struct index_state *istate, const struct cache_entry *ce, const char *path) { if (show_eol) { @@ -122,7 +122,7 @@ static void print_debug(const struct cache_entry *ce) } } -static void show_dir_entry(const struct index_state *istate, +static void show_dir_entry(struct index_state *istate, const char *tag, struct dir_entry *ent) { int len = max_prefix_len; @@ -139,7 +139,7 @@ static void show_dir_entry(const struct index_state *istate, write_name(ent->name); } -static void show_other_files(const struct index_state *istate, +static void show_other_files(struct index_state *istate, const struct dir_struct *dir) { int i; @@ -152,7 +152,7 @@ static void show_other_files(const struct index_state *istate, } } -static void show_killed_files(const struct index_state *istate, +static void show_killed_files(struct index_state *istate, const struct dir_struct *dir) { int i; @@ -254,7 +254,7 @@ static void show_ce(struct repository *repo, struct dir_struct *dir, } } -static void show_ru_info(const struct index_state *istate) +static void show_ru_info(struct index_state *istate) { struct string_list_item *item; diff --git a/cache.h b/cache.h index 4ca6cd7f782c..f244e6ac90fd 100644 --- a/cache.h +++ b/cache.h @@ -800,7 +800,7 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na * index_name_pos(&index, "f", 1) -> -3 * index_name_pos(&index, "g", 1) -> -5 */ -int index_name_pos(const struct index_state *, const char *name, int namelen); +int index_name_pos(struct index_state *, const char *name, int namelen); /* * Some functions return the negative complement of an insert position when a @@ -850,8 +850,8 @@ int add_file_to_index(struct index_state *, const char *path, int flags); int chmod_index_entry(struct index_state *, struct cache_entry *ce, char flip); int ce_same_name(const struct cache_entry *a, const struct cache_entry *b); void set_object_name_for_intent_to_add_entry(struct cache_entry *ce); -int index_name_is_other(const struct index_state *, const char *, int); -void *read_blob_data_from_index(const struct index_state *, const char *, unsigned long *); +int index_name_is_other(struct index_state *, const char *, int); +void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *); /* do stat comparison even if CE_VALID is true */ #define CE_MATCH_IGNORE_VALID 01 diff --git a/convert.c b/convert.c index ee360c2f07ce..20b19abffa36 100644 --- a/convert.c +++ b/convert.c @@ -138,7 +138,7 @@ static const char *gather_convert_stats_ascii(const char *data, unsigned long si } } -const char *get_cached_convert_stats_ascii(const struct index_state *istate, +const char *get_cached_convert_stats_ascii(struct index_state *istate, const char *path) { const char *ret; @@ -222,7 +222,7 @@ static void check_global_conv_flags_eol(const char *path, } } -static int has_crlf_in_index(const struct index_state *istate, const char *path) +static int has_crlf_in_index(struct index_state *istate, const char *path) { unsigned long sz; void *data; @@ -496,7 +496,7 @@ static int encode_to_worktree(const char *path, const char *src, size_t src_len, return 1; } -static int crlf_to_git(const struct index_state *istate, +static int crlf_to_git(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *buf, enum crlf_action crlf_action, int conv_flags) @@ -1307,7 +1307,7 @@ struct conv_attrs { static struct attr_check *check; -static void convert_attrs(const struct index_state *istate, +static void convert_attrs(struct index_state *istate, struct conv_attrs *ca, const char *path) { struct attr_check_item *ccheck = NULL; @@ -1369,7 +1369,7 @@ void reset_parsed_attributes(void) user_convert_tail = NULL; } -int would_convert_to_git_filter_fd(const struct index_state *istate, const char *path) +int would_convert_to_git_filter_fd(struct index_state *istate, const char *path) { struct conv_attrs ca; @@ -1388,7 +1388,7 @@ int would_convert_to_git_filter_fd(const struct index_state *istate, const char return apply_filter(path, NULL, 0, -1, NULL, ca.drv, CAP_CLEAN, NULL, NULL); } -const char *get_convert_attr_ascii(const struct index_state *istate, const char *path) +const char *get_convert_attr_ascii(struct index_state *istate, const char *path) { struct conv_attrs ca; @@ -1414,7 +1414,7 @@ const char *get_convert_attr_ascii(const struct index_state *istate, const char return ""; } -int convert_to_git(const struct index_state *istate, +int convert_to_git(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, int conv_flags) { @@ -1448,7 +1448,7 @@ int convert_to_git(const struct index_state *istate, return ret | ident_to_git(src, len, dst, ca.ident); } -void convert_to_git_filter_fd(const struct index_state *istate, +void convert_to_git_filter_fd(struct index_state *istate, const char *path, int fd, struct strbuf *dst, int conv_flags) { @@ -1466,7 +1466,7 @@ void convert_to_git_filter_fd(const struct index_state *istate, ident_to_git(dst->buf, dst->len, dst, ca.ident); } -static int convert_to_working_tree_internal(const struct index_state *istate, +static int convert_to_working_tree_internal(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, int normalizing, @@ -1510,7 +1510,7 @@ static int convert_to_working_tree_internal(const struct index_state *istate, return ret | ret_filter; } -int async_convert_to_working_tree(const struct index_state *istate, +int async_convert_to_working_tree(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, const struct checkout_metadata *meta, @@ -1519,7 +1519,7 @@ int async_convert_to_working_tree(const struct index_state *istate, return convert_to_working_tree_internal(istate, path, src, len, dst, 0, meta, dco); } -int convert_to_working_tree(const struct index_state *istate, +int convert_to_working_tree(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, const struct checkout_metadata *meta) @@ -1527,7 +1527,7 @@ int convert_to_working_tree(const struct index_state *istate, return convert_to_working_tree_internal(istate, path, src, len, dst, 0, meta, NULL); } -int renormalize_buffer(const struct index_state *istate, const char *path, +int renormalize_buffer(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst) { int ret = convert_to_working_tree_internal(istate, path, src, len, dst, 1, NULL, NULL); @@ -1964,7 +1964,7 @@ static struct stream_filter *ident_filter(const struct object_id *oid) * Note that you would be crazy to set CRLF, smudge/clean or ident to a * large binary blob you would want us not to slurp into the memory! */ -struct stream_filter *get_stream_filter(const struct index_state *istate, +struct stream_filter *get_stream_filter(struct index_state *istate, const char *path, const struct object_id *oid) { diff --git a/convert.h b/convert.h index e29d1026a686..0f7c8a1f0446 100644 --- a/convert.h +++ b/convert.h @@ -65,41 +65,41 @@ struct checkout_metadata { extern enum eol core_eol; extern char *check_roundtrip_encoding; -const char *get_cached_convert_stats_ascii(const struct index_state *istate, +const char *get_cached_convert_stats_ascii(struct index_state *istate, const char *path); const char *get_wt_convert_stats_ascii(const char *path); -const char *get_convert_attr_ascii(const struct index_state *istate, +const char *get_convert_attr_ascii(struct index_state *istate, const char *path); /* returns 1 if *dst was used */ -int convert_to_git(const struct index_state *istate, +int convert_to_git(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, int conv_flags); -int convert_to_working_tree(const struct index_state *istate, +int convert_to_working_tree(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, const struct checkout_metadata *meta); -int async_convert_to_working_tree(const struct index_state *istate, +int async_convert_to_working_tree(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst, const struct checkout_metadata *meta, void *dco); int async_query_available_blobs(const char *cmd, struct string_list *available_paths); -int renormalize_buffer(const struct index_state *istate, +int renormalize_buffer(struct index_state *istate, const char *path, const char *src, size_t len, struct strbuf *dst); -static inline int would_convert_to_git(const struct index_state *istate, +static inline int would_convert_to_git(struct index_state *istate, const char *path) { return convert_to_git(istate, path, NULL, 0, NULL, 0); } /* Precondition: would_convert_to_git_filter_fd(path) == true */ -void convert_to_git_filter_fd(const struct index_state *istate, +void convert_to_git_filter_fd(struct index_state *istate, const char *path, int fd, struct strbuf *dst, int conv_flags); -int would_convert_to_git_filter_fd(const struct index_state *istate, +int would_convert_to_git_filter_fd(struct index_state *istate, const char *path); /* @@ -133,7 +133,7 @@ void reset_parsed_attributes(void); struct stream_filter; /* opaque */ -struct stream_filter *get_stream_filter(const struct index_state *istate, +struct stream_filter *get_stream_filter(struct index_state *istate, const char *path, const struct object_id *); void free_stream_filter(struct stream_filter *); diff --git a/dir.c b/dir.c index fd8aa7c40faa..5b00dfb5b144 100644 --- a/dir.c +++ b/dir.c @@ -306,7 +306,7 @@ static int do_read_blob(const struct object_id *oid, struct oid_stat *oid_stat, * [1] Only if DO_MATCH_DIRECTORY is passed; otherwise, this is NOT a match. * [2] Only if DO_MATCH_LEADING_PATHSPEC is passed; otherwise, not a match. */ -static int match_pathspec_item(const struct index_state *istate, +static int match_pathspec_item(struct index_state *istate, const struct pathspec_item *item, int prefix, const char *name, int namelen, unsigned flags) { @@ -429,7 +429,7 @@ static int match_pathspec_item(const struct index_state *istate, * pathspec did not match any names, which could indicate that the * user mistyped the nth pathspec. */ -static int do_match_pathspec(const struct index_state *istate, +static int do_match_pathspec(struct index_state *istate, const struct pathspec *ps, const char *name, int namelen, int prefix, char *seen, @@ -500,7 +500,7 @@ static int do_match_pathspec(const struct index_state *istate, return retval; } -static int match_pathspec_with_flags(const struct index_state *istate, +static int match_pathspec_with_flags(struct index_state *istate, const struct pathspec *ps, const char *name, int namelen, int prefix, char *seen, unsigned flags) @@ -516,7 +516,7 @@ static int match_pathspec_with_flags(const struct index_state *istate, return negative ? 0 : positive; } -int match_pathspec(const struct index_state *istate, +int match_pathspec(struct index_state *istate, const struct pathspec *ps, const char *name, int namelen, int prefix, char *seen, int is_dir) @@ -529,7 +529,7 @@ int match_pathspec(const struct index_state *istate, /** * Check if a submodule is a superset of the pathspec */ -int submodule_path_match(const struct index_state *istate, +int submodule_path_match(struct index_state *istate, const struct pathspec *ps, const char *submodule_name, char *seen) @@ -892,7 +892,7 @@ void add_pattern(const char *string, const char *base, add_pattern_to_hashsets(pl, pattern); } -static int read_skip_worktree_file_from_index(const struct index_state *istate, +static int read_skip_worktree_file_from_index(struct index_state *istate, const char *path, size_t *size_out, char **data_out, struct oid_stat *oid_stat) diff --git a/dir.h b/dir.h index facfae47402a..51cb0e217247 100644 --- a/dir.h +++ b/dir.h @@ -354,7 +354,7 @@ int count_slashes(const char *s); int simple_length(const char *match); int no_wildcard(const char *string); char *common_prefix(const struct pathspec *pathspec); -int match_pathspec(const struct index_state *istate, +int match_pathspec(struct index_state *istate, const struct pathspec *pathspec, const char *name, int namelen, int prefix, char *seen, int is_dir); @@ -492,12 +492,12 @@ int git_fnmatch(const struct pathspec_item *item, const char *pattern, const char *string, int prefix); -int submodule_path_match(const struct index_state *istate, +int submodule_path_match(struct index_state *istate, const struct pathspec *ps, const char *submodule_name, char *seen); -static inline int ce_path_match(const struct index_state *istate, +static inline int ce_path_match(struct index_state *istate, const struct cache_entry *ce, const struct pathspec *pathspec, char *seen) @@ -506,7 +506,7 @@ static inline int ce_path_match(const struct index_state *istate, S_ISDIR(ce->ce_mode) || S_ISGITLINK(ce->ce_mode)); } -static inline int dir_path_match(const struct index_state *istate, +static inline int dir_path_match(struct index_state *istate, const struct dir_entry *ent, const struct pathspec *pathspec, int prefix, char *seen) diff --git a/merge-recursive.c b/merge-recursive.c index 3d9207455b3a..b8de7a704eae 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -2987,7 +2987,7 @@ static int blob_unchanged(struct merge_options *opt, struct strbuf obuf = STRBUF_INIT; struct strbuf abuf = STRBUF_INIT; int ret = 0; /* assume changed for safety */ - const struct index_state *idx = opt->repo->index; + struct index_state *idx = opt->repo->index; if (a->mode != o->mode) return 0; diff --git a/pathspec.c b/pathspec.c index 7a229d8d22f2..b6e333965cb4 100644 --- a/pathspec.c +++ b/pathspec.c @@ -20,7 +20,7 @@ * to use find_pathspecs_matching_against_index() instead. */ void add_pathspec_matches_against_index(const struct pathspec *pathspec, - const struct index_state *istate, + struct index_state *istate, char *seen) { int num_unmatched = 0, i; @@ -51,7 +51,7 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec, * given pathspecs achieves against all items in the index. */ char *find_pathspecs_matching_against_index(const struct pathspec *pathspec, - const struct index_state *istate) + struct index_state *istate) { char *seen = xcalloc(pathspec->nr, 1); add_pathspec_matches_against_index(pathspec, istate, seen); @@ -702,7 +702,7 @@ void clear_pathspec(struct pathspec *pathspec) pathspec->nr = 0; } -int match_pathspec_attrs(const struct index_state *istate, +int match_pathspec_attrs(struct index_state *istate, const char *name, int namelen, const struct pathspec_item *item) { diff --git a/pathspec.h b/pathspec.h index 454ce364fac7..2ccc8080b6cc 100644 --- a/pathspec.h +++ b/pathspec.h @@ -150,11 +150,11 @@ static inline int ps_strcmp(const struct pathspec_item *item, } void add_pathspec_matches_against_index(const struct pathspec *pathspec, - const struct index_state *istate, + struct index_state *istate, char *seen); char *find_pathspecs_matching_against_index(const struct pathspec *pathspec, - const struct index_state *istate); -int match_pathspec_attrs(const struct index_state *istate, + struct index_state *istate); +int match_pathspec_attrs(struct index_state *istate, const char *name, int namelen, const struct pathspec_item *item); diff --git a/read-cache.c b/read-cache.c index b9c08773466c..dfec221d9128 100644 --- a/read-cache.c +++ b/read-cache.c @@ -548,7 +548,7 @@ int cache_name_stage_compare(const char *name1, int len1, int stage1, const char return 0; } -static int index_name_stage_pos(const struct index_state *istate, const char *name, int namelen, int stage) +static int index_name_stage_pos(struct index_state *istate, const char *name, int namelen, int stage) { int first, last; @@ -569,7 +569,7 @@ static int index_name_stage_pos(const struct index_state *istate, const char *na return -first-1; } -int index_name_pos(const struct index_state *istate, const char *name, int namelen) +int index_name_pos(struct index_state *istate, const char *name, int namelen) { return index_name_stage_pos(istate, name, namelen, 0); } @@ -3380,8 +3380,8 @@ int repo_read_index_unmerged(struct repository *repo) * We helpfully remove a trailing "/" from directories so that * the output of read_directory can be used as-is. */ -int index_name_is_other(const struct index_state *istate, const char *name, - int namelen) +int index_name_is_other(struct index_state *istate, const char *name, + int namelen) { int pos; if (namelen && name[namelen - 1] == '/') @@ -3399,7 +3399,7 @@ int index_name_is_other(const struct index_state *istate, const char *name, return 1; } -void *read_blob_data_from_index(const struct index_state *istate, +void *read_blob_data_from_index(struct index_state *istate, const char *path, unsigned long *size) { int pos, len; diff --git a/submodule.c b/submodule.c index 9767ba9893cc..83809a4f7bd2 100644 --- a/submodule.c +++ b/submodule.c @@ -33,7 +33,7 @@ static struct oid_array ref_tips_after_fetch; * will be disabled because we can't guess what might be configured in * .gitmodules unless the user resolves the conflict. */ -int is_gitmodules_unmerged(const struct index_state *istate) +int is_gitmodules_unmerged(struct index_state *istate) { int pos = index_name_pos(istate, GITMODULES_FILE, strlen(GITMODULES_FILE)); if (pos < 0) { /* .gitmodules not found or isn't merged */ @@ -301,7 +301,7 @@ int is_submodule_populated_gently(const char *path, int *return_error_code) /* * Dies if the provided 'prefix' corresponds to an unpopulated submodule */ -void die_in_unpopulated_submodule(const struct index_state *istate, +void die_in_unpopulated_submodule(struct index_state *istate, const char *prefix) { int i, prefixlen; @@ -331,7 +331,7 @@ void die_in_unpopulated_submodule(const struct index_state *istate, /* * Dies if any paths in the provided pathspec descends into a submodule */ -void die_path_inside_submodule(const struct index_state *istate, +void die_path_inside_submodule(struct index_state *istate, const struct pathspec *ps) { int i, j; diff --git a/submodule.h b/submodule.h index 4ac6e31cf1f7..84640c49c114 100644 --- a/submodule.h +++ b/submodule.h @@ -39,7 +39,7 @@ struct submodule_update_strategy { }; #define SUBMODULE_UPDATE_STRATEGY_INIT {SM_UPDATE_UNSPECIFIED, NULL} -int is_gitmodules_unmerged(const struct index_state *istate); +int is_gitmodules_unmerged(struct index_state *istate); int is_writing_gitmodules_ok(void); int is_staging_gitmodules_ok(struct index_state *istate); int update_path_in_gitmodules(const char *oldpath, const char *newpath); @@ -60,9 +60,9 @@ int is_submodule_active(struct repository *repo, const char *path); * Otherwise the return error code is the same as of resolve_gitdir_gently. */ int is_submodule_populated_gently(const char *path, int *return_error_code); -void die_in_unpopulated_submodule(const struct index_state *istate, +void die_in_unpopulated_submodule(struct index_state *istate, const char *prefix); -void die_path_inside_submodule(const struct index_state *istate, +void die_path_inside_submodule(struct index_state *istate, const struct pathspec *ps); enum submodule_update_type parse_submodule_update_type(const char *value); int parse_submodule_update_strategy(const char *value, From patchwork Tue Mar 16 21:16:50 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144095 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 99D47C43381 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8577964FA8 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233196AbhCPVR2 (ORCPT ); Tue, 16 Mar 2021 17:17:28 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55838 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233152AbhCPVRU (ORCPT ); Tue, 16 Mar 2021 17:17:20 -0400 Received: from mail-wr1-x433.google.com (mail-wr1-x433.google.com [IPv6:2a00:1450:4864:20::433]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2C15CC061756 for ; Tue, 16 Mar 2021 14:17:20 -0700 (PDT) Received: by mail-wr1-x433.google.com with SMTP id k8so8163295wrc.3 for ; Tue, 16 Mar 2021 14:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=0iz5/2sHB8WhhqvdKiv+NkDMDD7WdLz77MP6lFCbRfo=; b=n/uOsSXSMvkAXxqOXfCF8mvkMxfY33HjP/yJ1LxnP6EiNIZ0Ahuj6E2cY+xiqQmu3k aO0ITzEi/inHkcmOf4FBQEy1lEC9UWdgbMT+7Uvxu+yYzreMWCl9Hd6Wdu757kU1srhR Hcd9U4+kvNX6iE9oX018AiDMpv9cPyF8OF0l2h/H+36TxAGg6VS914sIuwYWyDrkLbTK N4DdE4H7WYjPB/NcoMpQV3T493SgxWtQNIWbbBoyrv3qdBzaysZyNGdAGtPoGzvWzZUg 1ssX1c9V5LAA8j9ADcNA5+UmAyRI1kjWGE2xJxuks4XkkRPMXk0Xpxk0ar0ypO/Esyh4 utSQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=0iz5/2sHB8WhhqvdKiv+NkDMDD7WdLz77MP6lFCbRfo=; b=cQ+eLuNcsAI3U2wgAdkD/unrk2hj8cIIbFKu6Dvs4/8k8SODspqWSaVYq8oHSu4QSS JFZ7Iq2cC5RQlzn8wI2B6iCYk50FoGeHbDz2mUJFnciVK43j9kWFP8KGPi67IBabJ4zn 9cjl1vMh+p1Zr8xGRffSxVrdZpjaJq8VklIvZyj6lOQeWRRUsN/F1FQz3dWyBXSAj+HP ERGpgDF2ywR3VJmQEIcv2oYbS8APe6t4dntVNePZBHlonINJwbVJzQkddj9cVwAsOj2I JGEtlq7AUBH3RIYMgrg9jI2/G/JQNFd1U8cmiLzvT0m6KpHbosOFi1eZwSVdV+EAdahd MJqg== X-Gm-Message-State: AOAM531ZEtDmzYPfDIHBs+lOMhHjn6jflDF3I1vOhMs9h4VfisvkP9yA 2tvf4jRX8m/VF/Kt4aNPuzKH2Pur5HY= X-Google-Smtp-Source: ABdhPJx2TKzgfl4Slu7gGZzQJRzaIvoau82Yi/OrVlxuahTweMYmY7u+LvFJk7lj+LBhMpaAWWJA8Q== X-Received: by 2002:a5d:6c69:: with SMTP id r9mr927857wrz.11.1615929438958; Tue, 16 Mar 2021 14:17:18 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s84sm520141wme.11.2021.03.16.14.17.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:18 -0700 (PDT) Message-Id: <8e11e891701985729cd5ecd7737e59d5a18284ce.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:50 +0000 Subject: [PATCH 02/27] read-cache: expand on query into sparse-directory entry Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Callers to index_name_pos() or index_name_stage_pos() have a specific path in mind. If that happens to be a path with an ancestor being a sparse-directory entry, it can lead to unexpected results. In the case that we did not find the requested path, check to see if the position _before_ the inserted position is a sparse directory entry that matches the initial segment of the input path (including the directory separator at the end of the directory name). If so, then expand the index to be a full index and search again. This expansion will only happen once per index read. Future enhancements could be more careful to expand only the necessary sparse directory entry, but then we would have a special "not fully sparse, but also not fully expanded" mode that could affect writing the index to file. Since this only occurs if a specific file is requested outside of the sparse checkout definition, this is unlikely to be a common situation. Signed-off-by: Derrick Stolee --- read-cache.c | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/read-cache.c b/read-cache.c index dfec221d9128..b143277ed106 100644 --- a/read-cache.c +++ b/read-cache.c @@ -566,6 +566,27 @@ static int index_name_stage_pos(struct index_state *istate, const char *name, in } first = next+1; } + + if (istate->sparse_index && + first > 0) { + /* Note: first <= istate->cache_nr */ + struct cache_entry *ce = istate->cache[first - 1]; + + /* + * If we are in a sparse-index _and_ the entry before the + * insertion position is a sparse-directory entry that is + * an ancestor of 'name', then we need to expand the index + * and search again. This will only trigger once, because + * thereafter the index is fully expanded. + */ + if (S_ISSPARSEDIR(ce->ce_mode) && + ce_namelen(ce) < namelen && + !strncmp(name, ce->name, ce_namelen(ce))) { + ensure_full_index(istate); + return index_name_stage_pos(istate, name, namelen, stage); + } + } + return -first-1; } From patchwork Tue Mar 16 21:16:51 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144097 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D7938C4332E for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C2F5E64FB3 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233238AbhCPVRa (ORCPT ); Tue, 16 Mar 2021 17:17:30 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55842 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233155AbhCPVRV (ORCPT ); Tue, 16 Mar 2021 17:17:21 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 0BCAFC06174A for ; Tue, 16 Mar 2021 14:17:21 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id a132-20020a1c668a0000b029010f141fe7c2so19637wmc.0 for ; Tue, 16 Mar 2021 14:17:20 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=BI76sl3lCMYZ2muS08vHRkaeFR9DdCcz1ssru/X4414=; b=AyR+VzkFQSSnCtlGUOab0DXkPzSgxax+iJhippJaUDgwMbbTSM4MmZfgpfs4ckPbIx DD1KHwg67BF3PC6r0pQqyMN4pkviLhN7owCycrykVU7M5OXuPV3Kwn7ctrfpGBRuipSd QAIwqxM/5VxR8zSWzMXgb04qM73r5ttlUZr/JOCBer8OFy+cxgN2KGsltJKhTlAx3/kI iMnRSLHrzOK8WEWBW6QoKE+yqYWVQr2G4UYc8mZYwI+XCmazA7BCtz7tNqM7HdSC3Yx0 EegI7tp1dwbr4M8XKAxWBESlA8c/PB4bsbwIlj9poEwTeZPpCUP4tE6Ql8GPWRL51I3S Bn4Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=BI76sl3lCMYZ2muS08vHRkaeFR9DdCcz1ssru/X4414=; b=prmg670KpTCHAstgelpbAXVttFm+SCHQRqykqJR2DjsbwpOZ8ft9ocHju42WUbOAqi ImeZtsfFkXg66JF/2HaDxAwuPJXngFj17AeqM7Phnlzoz15R3xepzDb1YXB9FzmcObip UvSwgqAQ9u0osScEBCCIuSGcDcVjgFaHT1mIsku6pf5nrGhvfs7d1akUAyEVqJT1XUmU 3A39vAXrrfGDkb7+yQHwfyCqzdAxUDQ0T7yv2gkGCKvviLcxdqYp2X+p0Ik38IG3FEIN +mQqbJswJQJl2nBGHANrwPvYL441/qZsgdWookxVHOdSEwBmbkb3M0gRitLJFJHUkw6w A5gw== X-Gm-Message-State: AOAM530ffpS1Do6KbeBf4kxGU6CU2p39e7nAcBcHrC6zfB8oKSBGD0xM 9d61L2gWF5dRhpJiAQHyRIUluglNVWA= X-Google-Smtp-Source: ABdhPJwGpfhoUINjOSyNVZOl+GFMiUrDGA8USG5RDcrz863FO+ywnQ02Frr26A1Tf4/puiqMRm+m8A== X-Received: by 2002:a1c:7ed4:: with SMTP id z203mr622220wmc.89.1615929439854; Tue, 16 Mar 2021 14:17:19 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o11sm23298428wrq.74.2021.03.16.14.17.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:19 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:51 +0000 Subject: [PATCH 03/27] sparse-index: API protection strategy Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Edit and expand the sparse-index design document with the plan for guarding index operations with ensure_full_index(). Notably, the plan has changed to not have an expand_to_path() method in favor of checking for a sparse-directory hit inside of the index_path_pos() API. The changes that follow this one will incrementally add ensure_full_index() guards to iterations over all cache entries. Some iterations over the cache entries are not protected due to a few categories listed in the document. Since these are not being modified, here is a short list of the files and methods that will not receive these guards: Looking for non-zero stage: * builtin/add.c:chmod_pathspec() * builtin/merge.c:count_unmerged_entries() * read-cache.c:unmerged_index() * rerere.c:check_one_conflict(), find_conflict(), rerere_remaining() * revision.c:prepare_show_merge() * sequencer.c:append_conflicts_hint() * wt-status.c:wt_status_collect_changes_initial() Looking for submodules: * builtin/submodule--helper.c:module_list_compute() * submodule.c: several methods * worktree.c:validate_no_submodules() Part of the index API: * name-hash.c: lazy init methods * preload-index.c:preload_thread(), preload_index() * read-cache.c: file format methods Checking for correct order of cache entries: * read-cache.c:check_ce_order() Ignores SKIP_WORKTREE entries or already aware: * unpack-trees.c:mark_new_skip_worktree() * wt-status.c:wt_status_check_sparse_checkout() Signed-off-by: Derrick Stolee --- Documentation/technical/sparse-index.txt | 32 +++++++++++++++++++++--- 1 file changed, 29 insertions(+), 3 deletions(-) diff --git a/Documentation/technical/sparse-index.txt b/Documentation/technical/sparse-index.txt index aa116406a016..7ab51bf6c441 100644 --- a/Documentation/technical/sparse-index.txt +++ b/Documentation/technical/sparse-index.txt @@ -82,9 +82,35 @@ also introduce other features that have been considered for improving the index, as well. Next, consumers of the index will be guarded against operating on a -sparse-index by inserting calls to `ensure_full_index()` or -`expand_index_to_path()`. After these guards are in place, we can begin -leaving sparse-directory entries in the in-memory index structure. +sparse-index by inserting calls to `ensure_full_index()` before iterating +over all cache entries. If a specific path is requested, then those will +be protected from within the `index_file_exists()` and `index_name_pos()` +API calls: they will call `ensure_full_index()` if necessary. + +During a scan of the codebase, not every iteration of the cache entries +needs an `ensure_full_index()` check. The basic reasons include: + +1. The loop is scanning for entries with non-zero stage. These entries + are not collapsed into a sparse-directory entry. + +2. The loop is scanning for submodules. These entries are not collapsed + into a sparse-directory entry. + +3. The loop is part of the index API, especially around reading or + writing the format. + +4. The loop is checking for correct order of cache entries and that is + correct if and only if the sparse-directory entries are in the correct + location. + +5. The loop ignores entries with the `SKIP_WORKTREE` bit set, or is + otherwise already aware of sparse directory entries. + +6. The sparse-index is disabled at this point when using the split-index + feature, so no effort is made to protect the split-index API. + +After these guards are in place, we can begin leaving sparse-directory +entries in the in-memory index structure. Even after inserting these guards, we will keep expanding sparse-indexes for most Git commands using the `command_requires_full_index` repository From patchwork Tue Mar 16 21:16:52 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144099 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E8589C43333 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D2B1264F91 for ; Tue, 16 Mar 2021 21:17:56 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233255AbhCPVRc (ORCPT ); Tue, 16 Mar 2021 17:17:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233156AbhCPVRW (ORCPT ); Tue, 16 Mar 2021 17:17:22 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 986EDC06174A for ; Tue, 16 Mar 2021 14:17:21 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id o14so7425328wrm.11 for ; Tue, 16 Mar 2021 14:17:21 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=H6engud+FhFZYKQixDARUriNE0HEE07dfYRKSvEbVjc=; b=U8W/7T+IahfIGqBAN6Yxuxuw447JGUJXPzc1q1R2pqdN03CixA6kFTVjHsHTBTJQmp kWXnBIMNuBb87U3QEyzBKBkmjVb7dlhsVYbchNMRoh/842KQAREUIRcZbs9Vr38BrDUJ 3bhoHhXiwTViBeVuWpxYGMwknvvCq2Yhsf4CXhXLQxChQbep60qfz/LRxkXvvF6MOHs6 B+vBBG8TsPH0hxEgs9uVNczuvuPjO4KkbmqMwU3eUGCVbsljcQSM3jaJdSYv/g02EnLs NaGcsN70B30YYPRlfGlHcrZ5KkV9qBj21Y8zaLJVYLNwuGJNu4Yjd9/+bfkQkT7VUxFx eWXg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=H6engud+FhFZYKQixDARUriNE0HEE07dfYRKSvEbVjc=; b=ITUiPKZboVTVVOOQi9kszmlq1VMA47hh+ctBAJPLfrOZ5zbrD/7LNHm5ABrGBPeDM6 tTK7OL0j03DE7LWQ6w4i+ajQF8OtQmlaCtdS5uXMeE5ZtN0xWurI3JdNkSJ/mCPILzNO c38CtmuxzC8KQ9iUZBl6s58XKNBUBCxMJ/g12yda1WdSwNY8LmtMV2x2M0Fux8s82m3t 2IkPi6KxGyZBC2BS+NghgVGl7ERzMCnL8pw+0usaVnFuIm0RURXAGuEUojGzviGu6Z4/ HVM1fPlTAqvWVoapvU/UHV6OKu1iYsZRPKxOQqV+Bls0kzVlTT/39P4p4w1k8vwpOfxj 0Ofg== X-Gm-Message-State: AOAM533dZcW2pGO8Z+8IXZ1K1f9TEafNuxSIpNMobKkne5yiHVjhmXmi Gnks1Dc1cqgxrFTgj4a2Ku3ddWLCfRc= X-Google-Smtp-Source: ABdhPJy6iw2yamXh0FPK15krPaPWlP8gSMOp8fU2tmLe75mEJp+C0ZMqKKOIfTJQVKmzmZtVsbsUhg== X-Received: by 2002:adf:d217:: with SMTP id j23mr969560wrh.113.1615929440475; Tue, 16 Mar 2021 14:17:20 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id u15sm480787wmq.4.2021.03.16.14.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:20 -0700 (PDT) Message-Id: <7e4079c48eb2ad06a849eda8f4bd6cb14493ffdb.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:52 +0000 Subject: [PATCH 04/27] cache: move ensure_full_index() to cache.h Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Soon we will insert ensure_full_index() calls across the codebase. Instead of also adding include statements for sparse-index.h, let's just use the fact that anything that cares about the index already has cache.h in its includes. Signed-off-by: Derrick Stolee --- cache.h | 1 + sparse-index.h | 1 - 2 files changed, 1 insertion(+), 1 deletion(-) diff --git a/cache.h b/cache.h index f244e6ac90fd..9c6d254e2bae 100644 --- a/cache.h +++ b/cache.h @@ -350,6 +350,7 @@ void add_name_hash(struct index_state *istate, struct cache_entry *ce); void remove_name_hash(struct index_state *istate, struct cache_entry *ce); void free_name_hash(struct index_state *istate); +void ensure_full_index(struct index_state *istate); /* Cache entry creation and cleanup */ diff --git a/sparse-index.h b/sparse-index.h index 39dcc859735e..0268f38753c0 100644 --- a/sparse-index.h +++ b/sparse-index.h @@ -2,7 +2,6 @@ #define SPARSE_INDEX_H__ struct index_state; -void ensure_full_index(struct index_state *istate); int convert_to_sparse(struct index_state *istate); struct repository; From patchwork Tue Mar 16 21:16:53 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144109 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 36BCCC4332E for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 14ABE64F94 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232996AbhCPVSB (ORCPT ); Tue, 16 Mar 2021 17:18:01 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55852 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233158AbhCPVRW (ORCPT ); Tue, 16 Mar 2021 17:17:22 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4A43FC06174A for ; Tue, 16 Mar 2021 14:17:22 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id w203-20020a1c49d40000b029010c706d0642so4487224wma.0 for ; Tue, 16 Mar 2021 14:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=F2gqO0l9O9MrKBoUmYo1FuGCXsHs4lBM//hToPyCl/8=; b=uq0hfo9pY8so8blZ4IuPRA4EQdpFX6v7KvxJxtjy01Huw+nYlsrS3WOHU9ns1VWAq/ Ub2OyRHKZI6gRT1RgJZl+bLK+///MvvCxq6uDX265aEpFmMefhrZ+CQbLSmleGJyIxOb 9NtijcY3HEmvJ1T/C4YCMcU+Z9WukKtpEKY9lAp3+3g7RKOPqC+I9pnu0N/h+7lmKarZ NZ+P5q9X4lrSuUiEP9M5/uFsUv1LGPi4GYg9nfjAnHB2azUXnDEkEyv9n+8qrcOOAHO8 8t4Tvc9Q+nDQKbbldJF2C8lNyQoxOD+aPWtva4cgPulKQz0l9BIxlTDOsIEAipd9ziyj 3GUw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=F2gqO0l9O9MrKBoUmYo1FuGCXsHs4lBM//hToPyCl/8=; b=EEx6l+oKgo893MCzFWvtwwdq04UrZDONAP7DpVA6qSxnMaImEmjQJWX9miK+Y1TcEF zVwQh+puWQJ/AgZ0b30yHv3uwzs6lKehKRjbsZjb5DiZz7SRxpiyYdGSPGuwcxsVsmJr a1I5XLkQI7YPMNwq3P1eyL1QO8WfKbMosQ1XDErZx5wLikMtIupdIeJO7B5n5B6uJSgf X8UEow3tWKtU+asxdaDrLjaeMhlLtsn/O6egCryHrYIJ0+8SicrJiLUIux398REEWisM 1whETc0lBbTvXs+JfeOmn3Vs6C1vNqJqdw7GS2VMCab6rF3wHjg5kEHfpfvP52tPtqtw Mxcg== X-Gm-Message-State: AOAM532/+oHrf8haWDmX9dPwj9YSuHyCg//6N/xoUuHoMEuKBsrsbJq9 kkaKqoBvRMTRt6AZm6E7BzhdS2ISKQg= X-Google-Smtp-Source: ABdhPJyPfz35i7AulvOYsEQgCtNYov5tLBKCId4zM0EluHnbsAx4opbkRMcNpdXSG9ENNluDhld2WA== X-Received: by 2002:a1c:e341:: with SMTP id a62mr696197wmh.152.1615929441146; Tue, 16 Mar 2021 14:17:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i11sm22992998wro.53.2021.03.16.14.17.20 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:20 -0700 (PDT) Message-Id: <142df1ab8e3e8ea5e213f2477e271e60e5b62f84.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:53 +0000 Subject: [PATCH 05/27] add: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- builtin/add.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/add.c b/builtin/add.c index ea762a41e3a2..ab2ef4a63530 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -141,6 +141,7 @@ static int renormalize_tracked_files(const struct pathspec *pathspec, int flags) { int i, retval = 0; + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) { struct cache_entry *ce = active_cache[i]; From patchwork Tue Mar 16 21:16:54 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144121 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7B990C43603 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 60DB664F9E for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233100AbhCPVSQ (ORCPT ); Tue, 16 Mar 2021 17:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55854 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233269AbhCPVRe (ORCPT ); Tue, 16 Mar 2021 17:17:34 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id DE386C061756 for ; Tue, 16 Mar 2021 14:17:22 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id v4so8174243wrp.13 for ; Tue, 16 Mar 2021 14:17:22 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=XMPrdigUaOwO/FCayQIwQRRb3YFmU5o6ymNPf3M0zIA=; b=DS8dcE2ONJxGwDz3kC3bibcRbNZsu7vJEeuUYolpMmjJFvP5OVutLleE1LXeXz0uRt 8WGnhvDORhNiu8oeAcFJ1iSH77SEFKkV+IiHkNQo/7BG3zseHkuoNPChKmxDJkdSFhwu 2TekvlwmYFWBkfYfjQFhqSHVtVYYSpKXMbmlWNQVoIWvnwSmmnDlRyMg1hVhfoucNmA8 TYvGzvL4AOJe5aX89adAM0iH/WSsL1zVqK170T0U0HxiFcZcJinocXZm8/WFfl42qdUP jObM+L7tD89ncAWH4I2HGt2CjM93visQwLZ5s/0bOiWxQlmkybbEypw6OfvhqnhmBIBo oTeg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=XMPrdigUaOwO/FCayQIwQRRb3YFmU5o6ymNPf3M0zIA=; b=NNXvasUEFnsVllMZzcTqtUwkWty9cDghqHGsxUzArQhTRh0XrV2vpoJuRWAKjNOtOC O1m8bUgkg2uIXjJ4CqDBAHXDtzI98NyZKfwBTVfPmfNT77ZTZbAatXI/UBR/gW8/hC5H Lk9Pp6prnQvgjIOqnzzV3Fd4b17TU7Fqn3l1yqbdCBqbUcB7y1vv3rtKkT/AcyFM8ozj a2f9Im5MXFnzbw8/5Lg2nOpkX32kYB4rnDSuf7BYwoEvJ0lnVJgs9QsC8t+kWFLcPAU5 CIdMaUeGD1YIP2IGfnaq/wVmm4Y4YPAVm4m/as9iktnAo59wRpT0e43WKGsMsHGdVEfc VQWA== X-Gm-Message-State: AOAM532VrOnSaqoxi8lwI0SepiRBY3BkKMsufcKCly52gBomxeWUXmyK 37UyINW4cgSZ4cYPfYD92dZ2wcj/d8Y= X-Google-Smtp-Source: ABdhPJw9Q4Cfy+F9e5g5ioAH6T0mIyvdQVdtvstS6zPgLbKKbzrZyxxQx5RMSO5xBLJI32pfweo25w== X-Received: by 2002:a5d:44c5:: with SMTP id z5mr875503wrr.319.1615929441747; Tue, 16 Mar 2021 14:17:21 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id f126sm528082wmf.17.2021.03.16.14.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:21 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:54 +0000 Subject: [PATCH 06/27] checkout-index: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before we iterate over all cache entries, ensure that the index is not sparse. This loop in checkout_all() might be safe to iterate over a sparse index, but let's put this protection here until it can be carefully tested. Signed-off-by: Derrick Stolee --- builtin/checkout-index.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/checkout-index.c b/builtin/checkout-index.c index 023e49e271c2..ba31a036f193 100644 --- a/builtin/checkout-index.c +++ b/builtin/checkout-index.c @@ -119,6 +119,7 @@ static void checkout_all(const char *prefix, int prefix_length) int i, errs = 0; struct cache_entry *last_ce = NULL; + ensure_full_index(&the_index); for (i = 0; i < active_nr ; i++) { struct cache_entry *ce = active_cache[i]; if (ce_stage(ce) != checkout_stage From patchwork Tue Mar 16 21:16:55 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144111 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 292BDC4332B for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 04F9564F9F for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232975AbhCPVSA (ORCPT ); Tue, 16 Mar 2021 17:18:00 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55862 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232904AbhCPVRY (ORCPT ); Tue, 16 Mar 2021 17:17:24 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9340BC06175F for ; Tue, 16 Mar 2021 14:17:23 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id x13so8168127wrs.9 for ; Tue, 16 Mar 2021 14:17:23 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=oJBeNoxpm/TGvI8RBIoAjug82bLPpj6LNmOLCNgg5HE=; b=TLHko8lxtScCChPj3F4Zn1GsPichdRgaNqtlIXinelt/vBrIUbGatQAziisbHzX+N0 ZPIXtyQQBTxc+BTisZG/tmKZMGFL+jLfSM/c2dK5O05axSMzU0gY0Z3g0aHsfrP0q6gW im0sG4f5z/vuPEC4MSBk9flptp1fkUTtLHdXFuaianHTotB5EMEQoWAZPHPGuE59A/ou RkVl3+af0O//KF/EzWYQts5NffM3HtwGUDSrTT5R9ffQeuCdil6cHdSf/wlnXO2oCagJ iH0LZYnWNNo2hJP3ByOGMxtVhRz7rWUxz0zwJgTLi2DGijoFunoxXByhbLqYY/SAFUjL 1bsw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=oJBeNoxpm/TGvI8RBIoAjug82bLPpj6LNmOLCNgg5HE=; b=tl3t/QCQqLFp/0w7Cwd5neNhwEItpmY8x12wjQD5MzDXRuNNwxc+LacFn9elyIt10k CxQVvHICarH5UHOAbz4dz9OdVrgajlgCEyFoKOSMjkIXN7PTIe4ZkLdEZBu0Tt2eRKp4 JUIW2yXbbsQ1pjAj9uP/qjFd3O7IZnwmfy5afcttDoKmc1+VjSnKVbj2gTaW8wuyGkmK fBrQOuPBXoSDkWxalLo/Gw4v12jar9v2timItJJz8z2IHSd8TnWNvlnt+UkiBkCgFLTV U9YWkW1+7/QsZoymrb39rRr9ARTyWnYZxYN3XyoxV1TUz2chqxuqHo5hRQmSicQs4a1n Vi7g== X-Gm-Message-State: AOAM530ErDdq6A/x+nYoGi3PQIC1IXkNWruFrXIhwOb+MkjGtY6CADnJ JWIlGYYLYMEY6t2zgTBZ9JZlhisWd18= X-Google-Smtp-Source: ABdhPJzn7RV8VzVWj1moaFSky8k2qDLksoozXBlCzMTXpl5pW36FIFeJsk3sK0SXNHvXb6Jd14WKqg== X-Received: by 2002:adf:ef08:: with SMTP id e8mr1024566wro.200.1615929442396; Tue, 16 Mar 2021 14:17:22 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id m15sm606502wrp.96.2021.03.16.14.17.21 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:22 -0700 (PDT) Message-Id: <1bb7b6117e41ecf84afc03a29727d65606601be4.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:55 +0000 Subject: [PATCH 07/27] checkout: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries in the checkout builtin, ensure that we have a full index to avoid any unexpected behavior. Signed-off-by: Derrick Stolee --- builtin/checkout.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/checkout.c b/builtin/checkout.c index 0e6639052001..2e64569d2e13 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -368,6 +368,7 @@ static int checkout_worktree(const struct checkout_opts *opts, NULL); enable_delayed_checkout(&state); + ensure_full_index(&the_index); for (pos = 0; pos < active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; if (ce->ce_flags & CE_MATCHED) { @@ -512,6 +513,7 @@ static int checkout_paths(const struct checkout_opts *opts, * Make sure all pathspecs participated in locating the paths * to be checked out. */ + ensure_full_index(&the_index); for (pos = 0; pos < active_nr; pos++) if (opts->overlay_mode) mark_ce_for_checkout_overlay(active_cache[pos], From patchwork Tue Mar 16 21:16:56 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144105 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 17EE2C433E9 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id EA20664F91 for ; Tue, 16 Mar 2021 21:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232967AbhCPVR7 (ORCPT ); Tue, 16 Mar 2021 17:17:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55866 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232937AbhCPVRY (ORCPT ); Tue, 16 Mar 2021 17:17:24 -0400 Received: from mail-wm1-x32b.google.com (mail-wm1-x32b.google.com [IPv6:2a00:1450:4864:20::32b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 53526C061762 for ; Tue, 16 Mar 2021 14:17:24 -0700 (PDT) Received: by mail-wm1-x32b.google.com with SMTP id p19so314996wmq.1 for ; Tue, 16 Mar 2021 14:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=O6OCazjk/NCzMzL3BNHH4A8buwQiHk8IdpxHl+PrUc8=; b=BpPJ+v0FvIgfBMzHWChNT1N3qJjQQrn6M6QOq6bUNUEujK/dwsfpZbGjnczO149YML SdYz6wvUTiL36YY1E9APTNt0Te9yXV3hv9WS+Q6ugwawYd98Dee5FULM+kKcKFB600HP pKsUsVOftYAE3dZ9qvmhbF96QxvknLJGrkQrP1B4r2zfPJkeBtna4mtIXE5s0DZawdbg wpeQOfIiCX5GxfIWFxXEq2j8pHmpfqbJNDvjGN2CS5uXwbts715E73VRB3OrWdc/QeL+ PCuQLOWYh/3xX1b5pB9ETaavojZhEliV9uJ/5oUddufF7m0l58/7rbpIibXRXgoSIuZv OS0g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=O6OCazjk/NCzMzL3BNHH4A8buwQiHk8IdpxHl+PrUc8=; b=MuqbdZHcy0Un6iuhrJiHeD+Jh16tZzKccB8+A9Mn+oIzK1xVj502HZXdFsuXGKSief bOwntPG9mrWT4brZef/6KyQDcKeqW1BCRrmT4omuX4E1xgieoTw9TPLSrEghsZXzWE52 ZCfvN7v+uxQq5X6u5qz2liH4yj77+RTK0egSveqgmcRwZN5DYCuscIAs6WQcagKYwBOZ GCtsOiwmS6iaYclzrk13+9Rq+3mmcr5Z0xANY/mHoqWLoj+KVVv9p6viXkIHMwT4j3dL s1uCn6jHSj34O8ORSOQ+mILsrj8uCd8tiPTWE+UVuCkgKnqrfcB82BpkYeTTlr8mveq3 v2Pg== X-Gm-Message-State: AOAM530vKmfC2oH5ur1Ju5BJiJJA3apmkH5VwMnyNJ+UJhfVHZl8D4eY WAIQYMcLhgy6A8q8YUaR9RpZPE41P/g= X-Google-Smtp-Source: ABdhPJw6ikVCVfTlzO9Wvr7F831mcikW0JeeBKp1JYTVcUjshBowERCDmzwjRqZBP/X46Jyu1eDwqw== X-Received: by 2002:a1c:f614:: with SMTP id w20mr681991wmc.70.1615929443159; Tue, 16 Mar 2021 14:17:23 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id v2sm1032101wmj.1.2021.03.16.14.17.22 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:22 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:56 +0000 Subject: [PATCH 08/27] commit: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee These two loops iterate over all cache entries, so ensure that a sparse index is expanded to a full index before we do so. Signed-off-by: Derrick Stolee --- builtin/commit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/commit.c b/builtin/commit.c index 739110c5a7f6..9ea9e7b53390 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -251,6 +251,7 @@ static int list_paths(struct string_list *list, const char *with_tree, free(max_prefix); } + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) { const struct cache_entry *ce = active_cache[i]; struct string_list_item *item; @@ -931,6 +932,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix, if (get_oid(parent, &oid)) { int i, ita_nr = 0; + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) if (ce_intent_to_add(active_cache[i])) ita_nr++; From patchwork Tue Mar 16 21:16:57 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144113 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7D088C43331 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 6DB6B64FA5 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233194AbhCPVSE (ORCPT ); Tue, 16 Mar 2021 17:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55868 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233013AbhCPVRZ (ORCPT ); Tue, 16 Mar 2021 17:17:25 -0400 Received: from mail-wm1-x32e.google.com (mail-wm1-x32e.google.com [IPv6:2a00:1450:4864:20::32e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CD666C061763 for ; Tue, 16 Mar 2021 14:17:24 -0700 (PDT) Received: by mail-wm1-x32e.google.com with SMTP id z6-20020a1c4c060000b029010f13694ba2so141772wmf.5 for ; Tue, 16 Mar 2021 14:17:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=GcgVq9D0WJp2irecxL+BYQvHP4e45tY3nVXbkIeJp6k=; b=ASl0Umvt2uGtfIT68aLM1/3Y8SOjBZWm0cpTHlgF9ESq9aHz58dBoTvhK2nz6TfZou lrdXrc7qEbtMxb2jCcOphKltpMz2pj6ZqeD2Qgj8sCqwLF41Yebcj9UsllV5agcX6+Dz xt6IhSEJVoGm3aZrXl2q+oCfyyjO2JYgGmIJYbeqrfZCwqZGfRBfEIRZHhuEo6yzwXa6 BqBcbswEjrcU7nPja6AljT7eDvgZbJG7aVxzwbYujKHd1aMhS1KMP0yNOX/R5DvZ/WkN 329IYCQmutAhO19PIrDkbFrukIBhMKg1nAbB7gSlSj/qSlSIK8M3KKqTuWqXdanr7o+p D13Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=GcgVq9D0WJp2irecxL+BYQvHP4e45tY3nVXbkIeJp6k=; b=dxxtNFSHvQeE1Y/qMwqIDESJuUpUTQvyBBxqYYidxtKjW+4DTZb1qDVH5HWo2m7C01 aGv33ht00UG28ldVVC6jpsMCUC3hj1pZcGhwdHaALck7OeIQlJSk6AMSRB2ANYk6JY/K vlOMLw1MB8mz/Zku+2gWpeziwiFnSbw6LWHwmHgvUzB5C893FENRFFI4iR/rL7LnJ7Jo 306RVEkHqmNGCUGJ3wkuShkKuWhwDqpD2xRCYpHvAxBO6X4YPqalhXd/DNzgLmFTpszY eIXb2ZV980lnGYBc/XdRgmpHD01W0n1mXWd4HUbZjybJVVnK/1WIsaVsic4hOuW6r+lp iyfA== X-Gm-Message-State: AOAM531eNuui1wrh/PhX+Lk0eatt8mCLJ66+XhaXtZUbSQOifQ5pF7PA 4N07qYMAMrq7P34U5zVGei8cJH535n0= X-Google-Smtp-Source: ABdhPJzXGSTxOEhFpCoPUEqqzd2kQN7zjUsfOJyHfEiRlwwN2MDx9izkwQmh+Bo/ZhgOIb/93cN6UQ== X-Received: by 2002:a1c:2049:: with SMTP id g70mr663898wmg.7.1615929443686; Tue, 16 Mar 2021 14:17:23 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id z25sm583431wmi.23.2021.03.16.14.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:23 -0700 (PDT) Message-Id: <83040e7558f3effac91e76352f259a5a7d367ed8.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:57 +0000 Subject: [PATCH 09/27] difftool: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index has been expanded to a full one to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- builtin/difftool.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/difftool.c b/builtin/difftool.c index 6e18e623fddf..1d62f77efa61 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -584,6 +584,8 @@ static int run_dir_diff(const char *extcmd, int symlinks, const char *prefix, setenv("GIT_DIFFTOOL_DIRDIFF", "true", 1); rc = run_command_v_opt(helper_argv, flags); + ensure_full_index(&wtindex); + /* * If the diff includes working copy files and those * files were modified during the diff, then the changes From patchwork Tue Mar 16 21:16:58 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144119 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 7DB25C43333 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5087E64F97 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233210AbhCPVSF (ORCPT ); Tue, 16 Mar 2021 17:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233150AbhCPVR0 (ORCPT ); Tue, 16 Mar 2021 17:17:26 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6427CC061764 for ; Tue, 16 Mar 2021 14:17:25 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id g20so302925wmk.3 for ; Tue, 16 Mar 2021 14:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ZT0CBUkQNajBmstU5ybwqcXRwqQ64zM9gI8MnWWPvUM=; b=iq3rgMj3pohx42oAQLQSx5ZOU7gvQOfivzWX4gzRrPh0sXLaVPouHQpUjnlWn+8moG zQ6Gywu1MvfR4wjhrxLVLL1VKKP+wu/3XzWCUFjle9xqdqkJQvtJOeqy1S1jb6szubwN wDWI2eT3izsOT0Z4GBhH9GZmbKpRT9scBeA8rT7mQ/6bE/MaE9Af1nzjE/F3GHW3SZrY hZwbAt9O+KRNwVcupc9N1T605JqxVIZd2PJkx0cLg6nhzOL9NkidEI0IJSVXmPBwjByj dOyiD/QifrIfMbvyBrgAsger2b32C2f009B8zm4v4yjLbIWfrvwOU48GeMdpAmiAGs/C aFtA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ZT0CBUkQNajBmstU5ybwqcXRwqQ64zM9gI8MnWWPvUM=; b=cdANY7BWe0IJAIzSvdqfteERu8suwWJwFzHZkL8pheSxT3d3zTktt4RJCnJFEne1xW VQToniSxXO4iOY+EJpCuCr+L9VW6c28wMyaTC98gICerkOiPB+244mNi5IuP0cpIeWCf abkCQ8wsP7nZ7Oisc9j3fdvSw+S44fI7HKNo/3Dxy+5aP+HZw+5J3zTf+em4BG4xnTkv 06VC3z8FHwT4U4pvEoPleMl9qkUmHF+k8uuQ+9UD99SGfkHxhvtjhxhirgwGp0pnxCzl SydAIuMP7IODF6IEPuuaCPzZXLZd6mT6fv07rZIf//kwhSjqfhsJKF+ZtJoHh36PVXGC Lk2Q== X-Gm-Message-State: AOAM531Om1UUQdX1rY42oj3RFV1PGqPTHldntbuIsVsYq3EuZrHlMJOi 7n6vg8m2q3pCGPPTD4Aim1W1Td5xpSs= X-Google-Smtp-Source: ABdhPJxyF1w/dKCSGvFBaYe0D9VgMvtCuL+Tx54tqqBaK89QC/7ovJRxNDB2F3iJAoF/hLhDaCkucg== X-Received: by 2002:a1c:498b:: with SMTP id w133mr695179wma.134.1615929444254; Tue, 16 Mar 2021 14:17:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id b15sm563933wmd.41.2021.03.16.14.17.23 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:23 -0700 (PDT) Message-Id: <988f7bd2d7364970a3c192bb229a21ea77803f26.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:58 +0000 Subject: [PATCH 10/27] fsck: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee When verifying all blobs reachable from the index, ensure that a sparse index has been expanded to a full one to avoid missing some blobs. Signed-off-by: Derrick Stolee --- builtin/fsck.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/fsck.c b/builtin/fsck.c index 821e7798c706..524d3fca28f6 100644 --- a/builtin/fsck.c +++ b/builtin/fsck.c @@ -883,6 +883,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix) verify_index_checksum = 1; verify_ce_order = 1; read_cache(); + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) { unsigned int mode; struct blob *blob; From patchwork Tue Mar 16 21:16:59 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144125 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id CF313C43332 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id AEEF064F9F for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233253AbhCPVSF (ORCPT ); Tue, 16 Mar 2021 17:18:05 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55878 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233160AbhCPVR0 (ORCPT ); Tue, 16 Mar 2021 17:17:26 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id E052AC061765 for ; Tue, 16 Mar 2021 14:17:25 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id t5-20020a1c77050000b029010e62cea9deso189448wmi.0 for ; Tue, 16 Mar 2021 14:17:25 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ce+cL5L/eS+p6DqIyjHoY8Pw72agrko9sK8k5zz68K0=; b=nHSzAS565Cpe9aySV4M964MqKQ/2ebV8GbJ5LFvyW2Ne6EbAHSrChepnTLlvuBbNu2 gqyiFEnRj0oMbw/rj4LcYkveK5HitMFr8Cv1sBGjwoSI8IyhGcqIBj6nDbQK7PpJ9Rdp nB6QgLO7gXh7c1sf7k6bc1qqQciMD0Ti6SmI8Qp/nB/cgi23iAHwibajT66WY1vm4OOh pKLJDTuok7ClohfPzi5YM9Ge/XpBMfbHKN28JDxOP3cfDdttkYhVRCEUlInjl13trGKl Dxtc6ZOPWddnD0IUcvCutuaWGLLp8V92yNBQt95/H0hIHm1E5++L1zf/3xUUSy25nHi8 eO1g== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ce+cL5L/eS+p6DqIyjHoY8Pw72agrko9sK8k5zz68K0=; b=Fprfsn6ACIv7roGNnMVZIwp3iyHzVmosr2n7hNiO2nm1HKi0UlrbBI4aWptxlMbfJ2 h7arXVsqb817ZjhzP3zz11t6OxBqD1CLFIRDfPET5KC5ezQmLDs7GBFgbVw4PDsLXZ/9 5yJ5uvqLcYTyOQjpXKVf1nRkhVoJ6C5vAY4BkBFbSlPjQvMgGYJJhTHGGjsNhbPcRqWH J/UCgW7xAcitbollGzi0JvyjnGYWGGxx1U2NvKkFMtp73t4F9DN8GVw6x4cQ/0y5wi6Y EMS4721K6GGOkJPTgpKBGWAWi95/XDWygtmz+d1BUxxKuqNmIwn5i5XSudDC3H70NVdr E3EA== X-Gm-Message-State: AOAM530if3ssw/nyxxsD050jw1e7J6jSmh9HuR6w8Co+lGeMjrRMEZER gPYfHa8B0Y77LSYlqXTqGRnORAnFd/g= X-Google-Smtp-Source: ABdhPJzfRWAUFNgICqPVgECYbKrVWVbDUB9d7BIq4e1XLOGGfopquneU1OGGQAlYWH2HuPUD2CNJjQ== X-Received: by 2002:a7b:cf16:: with SMTP id l22mr678016wmg.26.1615929444759; Tue, 16 Mar 2021 14:17:24 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s18sm27000677wrr.27.2021.03.16.14.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:24 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:16:59 +0000 Subject: [PATCH 11/27] grep: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full one so we do not miss blobs to scan. Later, this can integrate more carefully with sparse indexes with proper testing. Signed-off-by: Derrick Stolee --- builtin/grep.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/grep.c b/builtin/grep.c index 4e91a253ac3b..652d6d60f644 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -504,6 +504,7 @@ static int grep_cache(struct grep_opt *opt, if (repo_read_index(repo) < 0) die(_("index file corrupt")); + ensure_full_index(repo->index); for (nr = 0; nr < repo->index->cache_nr; nr++) { const struct cache_entry *ce = repo->index->cache[nr]; From patchwork Tue Mar 16 21:17:00 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144107 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DCC44C433DB for ; Tue, 16 Mar 2021 21:18:27 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BA41764F94 for ; Tue, 16 Mar 2021 21:18:27 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232953AbhCPVR5 (ORCPT ); Tue, 16 Mar 2021 17:17:57 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233162AbhCPVR1 (ORCPT ); Tue, 16 Mar 2021 17:17:27 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 661F3C0613D7 for ; Tue, 16 Mar 2021 14:17:26 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id j7so8173647wrd.1 for ; Tue, 16 Mar 2021 14:17:26 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=5mJy/cBtDy0ry57TKts3aAMccIoiFUeW11pLCdGtBDk=; b=E08r8NueBEsoMC3AqpnH1oKVGrHIsPxqld4RqHe7dLLJBh5QHjDZQHSr/aOnTV+zhL eZmQBE9tvH04pwNMM8+2Bp8VZf7mGPapSek0o5ttOKOIeLA0ljhAqp48UPagWzFdBgGb rV+Ggh9D/wNzF7y6Xlj0lot7UH7X2+zBqjX5969t9KQCTkZ8qOQEBryEo3FsPAjO+3r/ aQLgGViTtYA7bz7c8ITWT7J1uXnK0SvYHdfStTAmPDdZvw7eEEgYiuX3N6Y6Sw7JTbQt oqDm0SvNagJZGgFn9T0XrkkEQ8MwFZU2eblLNE3lcnxJhzdlGGkHpYrL0MEzAX45q1CK pUxg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=5mJy/cBtDy0ry57TKts3aAMccIoiFUeW11pLCdGtBDk=; b=chLs/qIDvr1qWdJ1W4HNheVruvdDoq98DVAHe3LSGBRrUDAPwCIRv2xtnfijHC2U49 GTva3l8hQJ4b5nogjGZI1WJh8II3xDVnl3Sh25UOOgriPOB11+roDE4ewMgd+ypJb0Gx U/brTmwsEjiXxdFsdw7MnhkLPBAIp7v1BRMXZ1vsLHCG2ZkcybUBFBUdAL2ZFkmegiRK Iivz9idM1zgNuh1Yph6Q0Z3BSFjQUX9mJHBTZkzoAFdH8eyoTX77ksZ1M2pNpEFv90lS NsAwqzsUh0VsfyepRv9D7AADWDk6cTjqJ/VYA9lPIFyqySesGqeBP2G2Eci0OO1RWJiT aI6Q== X-Gm-Message-State: AOAM531MrJ2HJ5NhrSXNS6B8XxEGIeRV3EgtD+aTwx1wKgpHttRpbi/l oqi11wBoG8D+ApU5AH6hRJksPlD3EAQ= X-Google-Smtp-Source: ABdhPJwleCBQPLsJKTgw9JR7ycFeqFo4QNs8sw16wpx+UWSPEXPpB7HWlgdZSwT2unVqgQokwruP6Q== X-Received: by 2002:adf:b30f:: with SMTP id j15mr990530wrd.132.1615929445260; Tue, 16 Mar 2021 14:17:25 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d8sm188145wrr.35.2021.03.16.14.17.24 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:25 -0700 (PDT) Message-Id: <00c8a7e1d119fa3b403227eb415200bba01f4bda.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:00 +0000 Subject: [PATCH 12/27] ls-files: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full one to avoid missing files. Signed-off-by: Derrick Stolee --- builtin/ls-files.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 76a0d35c1a01..8fbef2b14f29 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -317,6 +317,7 @@ static void show_files(struct repository *repo, struct dir_struct *dir) if (!(show_cached || show_stage || show_deleted || show_modified)) return; + ensure_full_index(repo->index); for (i = 0; i < repo->index->cache_nr; i++) { const struct cache_entry *ce = repo->index->cache[i]; struct stat st; @@ -495,6 +496,7 @@ void overlay_tree_on_index(struct index_state *istate, die("bad tree-ish %s", tree_name); /* Hoist the unmerged entries up to stage #3 to make room */ + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce = istate->cache[i]; if (!ce_stage(ce)) From patchwork Tue Mar 16 21:17:01 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144103 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id C8561C433E0 for ; Tue, 16 Mar 2021 21:18:26 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9F18D64F96 for ; Tue, 16 Mar 2021 21:18:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S232966AbhCPVRz (ORCPT ); Tue, 16 Mar 2021 17:17:55 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233173AbhCPVR1 (ORCPT ); Tue, 16 Mar 2021 17:17:27 -0400 Received: from mail-wm1-x330.google.com (mail-wm1-x330.google.com [IPv6:2a00:1450:4864:20::330]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 360A2C06174A for ; Tue, 16 Mar 2021 14:17:27 -0700 (PDT) Received: by mail-wm1-x330.google.com with SMTP id y124-20020a1c32820000b029010c93864955so2237382wmy.5 for ; Tue, 16 Mar 2021 14:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=ie5hLTKjz7h8tXcyAD8irVVXJrCXs3DtCWQjYNbWlEg=; b=IIW1A6yLqQcwl2f0kgXz9VJJwQhTlUt7M8HQwg97sHWzzhGd8Br/JrMUNCbALSrCV/ sLnXKx6c/n64u9pKiGfmskPlKpxmMjCmX7XVAmsBFgneA+rjfE/QJGW+LdS+RMTVP60f Pb5xIeOuyKLZHmGIpRtD8G+vUqSlS3uzINTKhwMIXPtkW9ZzojdjtVPMbmsq9pwxkUlu /SZ0VPYNG4uOoY2qKIGNSv7EtRVtqa95PfVT5B5QPdbnZyy2Fe4mwwy5ajy1XMUuUfXH EMOx2bsVKPRFU44KjITyRtvd2wCv5rrydRAU9ZsfEkLgFsCyeTZ1IgxFhzFAhwpnRvWh VDpQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=ie5hLTKjz7h8tXcyAD8irVVXJrCXs3DtCWQjYNbWlEg=; b=UiD6bvbxhgVY7GWKJQCUhmrCdhS1uhzhLIzxNTomJGepqSLR+Ls3ACtv0EK5LKCKYf qYFLbHUbHRkwN00rC+pa6UIO7cVwCI0Wg+7QqEZW+lvTKPQ/FPEdsSZFsNPvseFjo6yA D7jy9m79dc+ma23NIWosl9JY/wzTSvS9gKbyoARMIFkFPdZ7vbcMASqc7247Ik9G6O/t QWPzpZx9l88ePihyn4LLMiqTXZkevEVa5a1G2mVG9oqHo2n/PvXuyceb2Aq8UGQAnQDv nhxXivX1fsOymHhaUbYHj6HBl0Y7vkMV0jh3gf3GB5nAnZXao7vFIMe2uKeZW0gaEurB bpSA== X-Gm-Message-State: AOAM533zBMsmJDqP39yQR56DeF4oHv9hk4hFZvCeSlFXSHKto8B+UEc+ 3Qp34BELeutE8kYyGJjtZVfDRMhw4A8= X-Google-Smtp-Source: ABdhPJw8Y++0w4WeKEavnc5aHB97fXkOEvxg3oFLH0kanLCs+UjZt50Cjob5tKUQIAAEDUhlof5jyg== X-Received: by 2002:a1c:650a:: with SMTP id z10mr688323wmb.154.1615929446059; Tue, 16 Mar 2021 14:17:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n6sm23812296wrt.1.2021.03.16.14.17.25 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:25 -0700 (PDT) Message-Id: <1288f02177d2275937fa4f0928b437756cdaf712.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:01 +0000 Subject: [PATCH 13/27] merge-index: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full one to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- builtin/merge-index.c | 3 +++ 1 file changed, 3 insertions(+) diff --git a/builtin/merge-index.c b/builtin/merge-index.c index 38ea6ad6ca25..c1c4409b536d 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -58,6 +58,7 @@ static void merge_one_path(const char *path) static void merge_all(void) { int i; + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) { const struct cache_entry *ce = active_cache[i]; if (!ce_stage(ce)) @@ -80,6 +81,8 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix) read_cache(); + ensure_full_index(&the_index); + i = 1; if (!strcmp(argv[i], "-o")) { one_shot = 1; From patchwork Tue Mar 16 21:17:02 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144117 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 678C8C4332D for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 338C264FAE for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233028AbhCPVSE (ORCPT ); Tue, 16 Mar 2021 17:18:04 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232816AbhCPVR2 (ORCPT ); Tue, 16 Mar 2021 17:17:28 -0400 Received: from mail-wm1-x32c.google.com (mail-wm1-x32c.google.com [IPv6:2a00:1450:4864:20::32c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 06297C06174A for ; Tue, 16 Mar 2021 14:17:28 -0700 (PDT) Received: by mail-wm1-x32c.google.com with SMTP id p19so315058wmq.1 for ; Tue, 16 Mar 2021 14:17:27 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=CVINyJ9pTo7o7JiYpdL2MVHsor9qjFpOoMICoKE7ACo=; b=PE+8QztU7n2RioKfuLEfGpx62UoHCzCbf+g61pGFDn1+jJcAChuJsZfdwTlmmZ9c7J FNYPClVVo7rTryGQQY1vMZe18Wt48DhkkTKve1uVXqgCGSOFjrr/+kd+xbQWx/46pdxZ u9jnmk7P2BEa7JAfwPkmHMGAf3a+qo1pxXewNLnh+5EhlfgByXKDVjV5iG0MRZBEZTer tZbwgYSutmmVhAPIDQCFKcVeLO++0zVv/TOfzPAfxBN0EhcZwHTkq51oiS8bgLUjKwC2 xygU8SdoDm5CaTitEVscTXBwG55gmRwE+lnynDh8YBDs+miPvXCvFAzJVGAXUQp+Jvj4 0fFg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=CVINyJ9pTo7o7JiYpdL2MVHsor9qjFpOoMICoKE7ACo=; b=Wqh4s+r5tAoIuW7BzPP9sBZ8VoRZ8e6TJOnUOZ45Asg+DzaqZLlqBMqGrMSiot5+Hv PNOTRLNzLv+RjGPonmlmcm+/wm2A79cTakhTHIssHHTu70Gvvglt0RR+r+5XroKX6qGX VJqBE9wZwe2UarBKwv1IAcm0Iet94icEuaOVESj/vVr8daqdRptAnAvLi+3N5M7ZPdKc kC4+HIVqxSA1d7mHoTv+e6hbtyD2Q0/ANtIx4t4ZyvmVomLZQRe2a9X/lI6OVlR6fSmn SwmL0pKqh9Cl93fMEUoTEnxQoG7ig0bIkttQYnjX9hY1k8LGXudB0hI1a+bFrUDF5kRa livA== X-Gm-Message-State: AOAM531z4WGk9oMrtYoT3FEXssZj04FhZ4Q/SB5wIhF0rFCThd8+3qUn rn9EiKq6A9QVVN+kB9EEhapmXh6TjpI= X-Google-Smtp-Source: ABdhPJwtzi8Cr8mwPjrz6mMkzj73gg7+YvFe/jjEPj+zsjEiPQKz2wfXIZXKVMH1jCk2Ae8zr9s01Q== X-Received: by 2002:a05:600c:4305:: with SMTP id p5mr675820wme.58.1615929446710; Tue, 16 Mar 2021 14:17:26 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id d204sm518027wmc.17.2021.03.16.14.17.26 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:26 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:02 +0000 Subject: [PATCH 14/27] rm: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- builtin/rm.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/rm.c b/builtin/rm.c index 4858631e0f02..99125ccb8424 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -293,6 +293,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) seen = xcalloc(pathspec.nr, 1); + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) { const struct cache_entry *ce = active_cache[i]; if (!ce_path_match(&the_index, ce, &pathspec, seen)) From patchwork Tue Mar 16 21:17:03 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144115 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id E2A20C433E0 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BD72964F91 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233290AbhCPVSG (ORCPT ); Tue, 16 Mar 2021 17:18:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233195AbhCPVR2 (ORCPT ); Tue, 16 Mar 2021 17:17:28 -0400 Received: from mail-wr1-x42c.google.com (mail-wr1-x42c.google.com [IPv6:2a00:1450:4864:20::42c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 813FAC06175F for ; Tue, 16 Mar 2021 14:17:28 -0700 (PDT) Received: by mail-wr1-x42c.google.com with SMTP id x16so8182891wrn.4 for ; Tue, 16 Mar 2021 14:17:28 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=QOX1SylDMZ+6fT7XkYVi8iHYwVl542h0Yhiu2bYA6t0=; b=Qh+XA3GFXAsCm76lK3To3SiyrjdMLcoAn0zdNisJuKzNjqm6mTvtk4Kh+isPd3mJsO Rdpr6AkkCZzEHgd4gf26qc07mZoLGDCYA3omrqUqwMXHOZSfeV805LDoNFv1x0RV+5C0 J9sk+8FzlZt71S629KJ8568iVFnUDB4qykzuKbvppSgKQeYZVGKNMaCncQctW7/N8atL WCP/OmDwrbOBKtKxOwC4cwwguOrhvfQxjbi5O/9FAtMBLKWgcG6nxpvny7PWhaZKBTGJ nOGMChtCCfV5V+Mtvh8sJX6fjwIjkZyUV9vRPjqp6BsdRiaq2TlY7/dBtXhSrb5367Qz SxYw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=QOX1SylDMZ+6fT7XkYVi8iHYwVl542h0Yhiu2bYA6t0=; b=RLareqE77/CV6t3qpV6kmHwvn5DFYzGJuh4Mx+sxmpdCaVBG42BW6GO5GI2MyIx+V+ rx38duDNFcqLz6VWwEKw6gKFwNPk+E1/i0deQT2fdFM1Lz7tzOKS8sHzBfjY8D1Tblum iQIsCzxmk3O6U33HFyJq/zcp4CAomv3tatC4YTH0/u6R5VaVBjyWR5ZvDhl0eXWo7Py/ 9/0Sg6bnfVBBp2UWgL3ioAim83KWRd1/91VZ22UBs/87F9Wbjv/6s1thnrwa57W3OfAJ 68QCed1Z7ZwcT3rn6l9+fdoodvONDxClECaNEfpkt1HDp2tUfmBmW2dwOZVLHuYLSImR GCMA== X-Gm-Message-State: AOAM531f04n0GaErUVSVGY6e+GSJOi8vttDUdtesCATkTjInQymOtLjk gXTxBNt0t182qYyS5viHKedc4/AAxmM= X-Google-Smtp-Source: ABdhPJwQvj6zvgYYShjYsgCHTXseWuZ2MY5g5BySMt5KCz5T0zbq9O292OgzzFiCcdgMqtpORXvmlQ== X-Received: by 2002:adf:bac8:: with SMTP id w8mr1023143wrg.68.1615929447379; Tue, 16 Mar 2021 14:17:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y205sm634637wmc.18.2021.03.16.14.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:27 -0700 (PDT) Message-Id: <92ccd31dd343c20bad4a6b8d89c50559209e7236.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:03 +0000 Subject: [PATCH 15/27] sparse-checkout: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee When adjusting the sparse-checkout definition, ensure that a sparse index is expanded to a full one to avoid unexpected behavior. This is a top candidate for later integration with the sparse-index, but requires careful testing. Signed-off-by: Derrick Stolee --- builtin/stash.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/stash.c b/builtin/stash.c index ba774cce674f..b3d4fe814b6b 100644 --- a/builtin/stash.c +++ b/builtin/stash.c @@ -1350,6 +1350,7 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q int i; char *ps_matched = xcalloc(ps->nr, 1); + ensure_full_index(&the_index); for (i = 0; i < active_nr; i++) ce_path_match(&the_index, active_cache[i], ps, ps_matched); From patchwork Tue Mar 16 21:17:04 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144135 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id F2062C4321A for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id CD75D64FB4 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233195AbhCPVSH (ORCPT ); Tue, 16 Mar 2021 17:18:07 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233203AbhCPVR3 (ORCPT ); Tue, 16 Mar 2021 17:17:29 -0400 Received: from mail-wm1-x331.google.com (mail-wm1-x331.google.com [IPv6:2a00:1450:4864:20::331]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 1D881C06174A for ; Tue, 16 Mar 2021 14:17:29 -0700 (PDT) Received: by mail-wm1-x331.google.com with SMTP id z6-20020a1c4c060000b029010f13694ba2so141846wmf.5 for ; Tue, 16 Mar 2021 14:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=YaUzrcunWYtZa7lKH40QfQZeg2Uz3GETXegzG5AwNCs=; b=mi0iQAqIE7PswHq06LDW6uuLRqlKdWmoDEDtLZNwmOMu1KbldMOhD7mqOqaVTdJgoq PtZclNhrfg7Ejm43Z3+qwdGOHfZnTZvSa0HvI703VaNKxaqQpHr/+AxljlYczRenihDn 2+L6QfLssDHh+VwxlRp0QhLaYZNm1isFO3UXwDNStqh/RT30OQ3QiOoTWGqwlmHOctgx 0DfOJ04a+5N+tjz8BntwBOWlo4q9xx6rW+KPBohqn5kFNglnzc4jul2QPBgQSTOmHGWz k/n+CmfoJk2Qcjt7eOc9gfeB1dmWtIdK3JLKMAuFiBWuT0kK1djP2Yf+NO91r82xqtWn HkXA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=YaUzrcunWYtZa7lKH40QfQZeg2Uz3GETXegzG5AwNCs=; b=a5F6WUo6m7cX7Wrojy4Rh+2N4edAycyENf6GFPJ7E+hIWM5MDDy8VvSzydK+5vyaLL eETax0ljYy0KibHRIJLjFhG/DHMWc1dhszth1gvAdzZ9U2kd3qot46uGjJDaDf/UNCet 6g22khapi/Ql4SrycIrcAII+9IQoC4Y6+ohKPtpFt5WjU3EVNMxPSzVqJLLFx43iHsEG o6HS8YdzZUgXkTyNWoLMaic41OTzm0PP0SEiYNiJ3fKXyRLOzRkrIjnH2NkTJ4UzkiVQ Zc49JGpfKv5Oy+zCR+/+CSXyFUX8fkoGnYprtW4y6ssPo3nEFmaSdKlut85psgT3OZqu Htdg== X-Gm-Message-State: AOAM532G/Zd20ibX+HLZXovgY2GoY3DuAevcyu/OVTfBJC7wRVGlaxa4 WnB9+EY5lWnqJx4SzeWKPQKLqU5eptE= X-Google-Smtp-Source: ABdhPJznnm3uS8cFWebnj9HUwpVJvvRcpMHjUUHRzUdRIGvAXqDyVGnpM9kg7qmHWqMqcohsbBrDkw== X-Received: by 2002:a7b:c112:: with SMTP id w18mr681493wmi.28.1615929447951; Tue, 16 Mar 2021 14:17:27 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s20sm484363wmj.36.2021.03.16.14.17.27 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:27 -0700 (PDT) Message-Id: <796449758a08ad9f2038f16c7d157edf27ca3cc4.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:04 +0000 Subject: [PATCH 16/27] update-index: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- builtin/update-index.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin/update-index.c b/builtin/update-index.c index 79087bccea4b..8eb654ddc754 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -745,6 +745,7 @@ static int do_reupdate(int ac, const char **av, */ has_head = 0; redo: + ensure_full_index(&the_index); for (pos = 0; pos < active_nr; pos++) { const struct cache_entry *ce = active_cache[pos]; struct cache_entry *old = NULL; From patchwork Tue Mar 16 21:17:05 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144129 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id D2D18C2BA1E for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id A3CD764FAE for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233311AbhCPVSR (ORCPT ); Tue, 16 Mar 2021 17:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233227AbhCPVRa (ORCPT ); Tue, 16 Mar 2021 17:17:30 -0400 Received: from mail-wm1-x32a.google.com (mail-wm1-x32a.google.com [IPv6:2a00:1450:4864:20::32a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D499CC06175F for ; Tue, 16 Mar 2021 14:17:29 -0700 (PDT) Received: by mail-wm1-x32a.google.com with SMTP id b2-20020a7bc2420000b029010be1081172so163938wmj.1 for ; Tue, 16 Mar 2021 14:17:29 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=nVR9QIt3G8SqS33LGo7OBuLf5EVGbwLAPJdPR9tVwV4=; b=ez4xsoMuLJL9keWqUztvzQK9hyRvnUyKG5RmzIZFleQC+NgrLLWuNv+NPk35nF8dtj CspHjznwSq9+SMwKNWYbnek2fWYN+j2BQ8uMEecEkAPa0yaTVvzM+iFR9v+UwP2O/QWx fMIfWrkWAKlc3YAm4yAZIrWdrktS3wRUI1NWgDIn/ZUBC/ki5kE5YYFg7Hxz3mJrmICF XtrsS3hNL5G0W3VAY2PL6JCI7Vm5AmXpa/mBZUeY8UxBM46UhmRVvSvLve5dEZgoJh+N Wa2V3NENHugLHm7c5pDXFmTiGD7ZY5pj79NhsBW9G9l72+GdMTsZ3h0sGLybaiKXOXWg PfZg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=nVR9QIt3G8SqS33LGo7OBuLf5EVGbwLAPJdPR9tVwV4=; b=AnG0JFLRIMMQXsDYCAUcLD0u6wH7YiY8x2dabyHTD1JVVaPr/7x0uHa315pVHwcxAq pUkXCjRsv3q5h/vwRlT1WLjZ4Dk19LlxiEWjYYEhdCC26bKBNCUEkLOLk0j88Ldl0563 KsParr1JpWeWybrKMnsPC7oxt931G6+Awdn+PcZlKHybLbRzF9sUt/zDR8Yb8xxmC2kB WnfDgbLivGEoGakaeHGFVo8kXhYovct0bPOm5jzKAvVf6RAHBHl7wpB0T81OcfIcwIuN DMPO0EMX4Q2hyR5kAIcWEQpx/QTeIiQoS8rrXHiF2Grq4dSYsKorFWESdQ3YOjyRE5/l H8Tw== X-Gm-Message-State: AOAM530cQYa2m2f298uebxgHfOAYTbBnUfYNzdIRpJGyOol/gVv1Yu1i m1lk5lllkBErAO511byX045mCYzImYg= X-Google-Smtp-Source: ABdhPJwu/7h7iSC3PXswmc9+MH6GHcPX+MSoVcPp2cFLnrH2AVuAlyxswgx6YG3ATdR9edhZAh0ppQ== X-Received: by 2002:a05:600c:1548:: with SMTP id f8mr653379wmg.81.1615929448635; Tue, 16 Mar 2021 14:17:28 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s3sm476894wmd.21.2021.03.16.14.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:28 -0700 (PDT) Message-Id: <45bbed6150a2a9f9e9446edc9a613f027da73957.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:05 +0000 Subject: [PATCH 17/27] diff-lib: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- diff-lib.c | 1 + 1 file changed, 1 insertion(+) diff --git a/diff-lib.c b/diff-lib.c index b73cc1859a49..41d6fcec1a81 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -102,6 +102,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option) if (diff_unmerged_stage < 0) diff_unmerged_stage = 2; + entries = istate->cache_nr; for (i = 0; i < entries; i++) { unsigned int oldmode, newmode; From patchwork Tue Mar 16 21:17:06 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144123 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id A53DFC4361B for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 9053A64F91 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233313AbhCPVSS (ORCPT ); Tue, 16 Mar 2021 17:18:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55896 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233075AbhCPVRa (ORCPT ); Tue, 16 Mar 2021 17:17:30 -0400 Received: from mail-wr1-x42d.google.com (mail-wr1-x42d.google.com [IPv6:2a00:1450:4864:20::42d]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 7616BC061762 for ; Tue, 16 Mar 2021 14:17:30 -0700 (PDT) Received: by mail-wr1-x42d.google.com with SMTP id 61so8174746wrm.12 for ; Tue, 16 Mar 2021 14:17:30 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=7e4AcoLdYIle2Qt79qB+DRM6EytEgeiSq2MMKySkgrI=; b=Kz+U+wbUn1/30e4cy0veTJzuUzb56snUBhXqHOYpIioPBAMFr69BGILvjW+srKh7AC +c492hY4mknwbX7X69OX5lSkJ4jXOKxeHtt+BmJ1V2O4FTTzX/ptsgO8MdsnGpS5xQFX rnDih4KHXdcwmIjJkDI3xBXJrXxaDwhiOCXRk5QLrzosvJr17YVtUAk9ZeYeajVmQLFP 8cmJjEDsJ23HoXjisqdSOljT6xirt/yXBiJnFogxg6FHABJ0lM9HB26Ju3594XhikrfQ 45D8NNhTFs4+IDkaF7+LNmj9aB4FV7Qbx1AVeZQi8c4iofuzRB/NrESJPgWfnP9U1sjW p9IQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=7e4AcoLdYIle2Qt79qB+DRM6EytEgeiSq2MMKySkgrI=; b=suPYzqIC+LeOywU/9mggBPsJCfncrrAEdCnZ+6Ws1P/9F72+dCzJ8riDav61ptSQN5 I/oWKGhBK6pvUEt9gep5WqNnHk1f1PJKeZH5UrkjfZgkziHUIF4OTBkOt+rQVQ22gDop sxdXXg5wAHizZ7JwTjY9DmfLxjiWtcvaG95ahVqEqT0pIjzfYpsJrUWcpRzNVRjJovBp QqhfTbUNrFE5sHzjRjzQrlrzbzx/D8ePl0CDZy0GuatUdLVfZrLwoMwjTko/tFznSqEx OwHAfzdUp6wLc1FWnnC8vLwaDNTVmarZEua24FuqfRRhacWlLHDc6fFgEUwAFlrj98z1 4lxA== X-Gm-Message-State: AOAM53217PAcfpKSxqYcM+W0mqP6DwcEwY5lHPlF9HdMcA7WNMHIC6hV VyoXxQkSXLcvCERuNrvVc0r2qY9F894= X-Google-Smtp-Source: ABdhPJyyZnziEI1ticPWegcOujyLst/1yPGQW+R333YRyz4zvEbFqdKtEbzs4mo7i/UBSBLTvtY4Rw== X-Received: by 2002:a5d:404f:: with SMTP id w15mr1030290wrp.106.1615929449244; Tue, 16 Mar 2021 14:17:29 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c8sm9739595wrd.55.2021.03.16.14.17.28 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:28 -0700 (PDT) Message-Id: <8ce1f80985a441b430f8e86b18586f60137d0805.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:06 +0000 Subject: [PATCH 18/27] dir: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- dir.c | 1 + 1 file changed, 1 insertion(+) diff --git a/dir.c b/dir.c index 5b00dfb5b144..1c9f61566e66 100644 --- a/dir.c +++ b/dir.c @@ -3533,6 +3533,7 @@ static void connect_wt_gitdir_in_nested(const char *sub_worktree, if (repo_read_index(&subrepo) < 0) die(_("index file corrupt in repo %s"), subrepo.gitdir); + ensure_full_index(subrepo.index); for (i = 0; i < subrepo.index->cache_nr; i++) { const struct cache_entry *ce = subrepo.index->cache[i]; From patchwork Tue Mar 16 21:17:07 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144141 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFEE1C4160E for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D99F864FC2 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233117AbhCPVST (ORCPT ); Tue, 16 Mar 2021 17:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55898 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233251AbhCPVRb (ORCPT ); Tue, 16 Mar 2021 17:17:31 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 24AC1C061763 for ; Tue, 16 Mar 2021 14:17:31 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id u5-20020a7bcb050000b029010e9316b9d5so161778wmj.2 for ; Tue, 16 Mar 2021 14:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=uWFiWZazMc1ep/99DAdd+eR2g4kuGtDSHhnvoXTfuXc=; b=KH5rz5/mXRLqP6ZJrT+Od+9ovANHnBXRig7vdXCFU+ukVuHpiW6mlNYwQ4l7WMuY7P tWE/0vUxi7ZbZiQq5F+EW5GX3hC79DDOAZcy07DK2VRLNwVj21sdBTcggTqzVOhtGCBo i9R3GkBbZfHnW1jWFmK+KtJRLCvyzmnZxzINUWTiXpmHF5F5pSlu85Tzi9Vx4J5vu6l4 o50iBAaWiQxdDqTN0eh1ujQJ30WFcmA4ilTauHkYwiGLaRnW9PNfe8E3SHIX+twtDMrE NsvBY9FQffSBp3vPEn8cr74MwtU9IpPqFWkQQdSfFX+5CMYAhHKEjP6GihqFMFsc0pCb rTIg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=uWFiWZazMc1ep/99DAdd+eR2g4kuGtDSHhnvoXTfuXc=; b=TND6ZGO3A7R6QLMX0wtlTvH4vuS2VRBwN4m8SQOKw6mJ4M7ZJmQOiXKrIKeSUflxko 159C+oSy2R8a4IP62Ykz2ZB8cLkLgO/qaYTcdxzfd4Ix/ACl+WPo/vtPoflNS9Ygi18Z 3h5cNM+k296OVpVNMWMlVNSOtR5IZg3Mrh+bJ0wbN3+0ilRumOHdzTONy2hmEFz257Tc CuV9ejIsxZNrGA8FkYx88/D0Asz6fbcgMaMktQr4FlnHadYZR3X4kaEpj4cyQ+cTN5J1 pfiBORx/2nTcSRIGAr7Dhfo3BGMk7tS/bk0u2Jn29O5B6CGKswLRrQ65wVILqQ3nU968 Qn0Q== X-Gm-Message-State: AOAM530gKpHm4rDlSM5zTFDqoF/1p/+Htqm7h4vI6DcQGmluEIfmbXZJ a+NJO1k4guVJnfV7WgUPfYEn+TyiOP4= X-Google-Smtp-Source: ABdhPJzwhSK83z5DWgm3Aa4+B8PMQ3peX8stTXDUONTeRkTpEMG1re38j6D/zqFMOJhlGz2KQTpzwg== X-Received: by 2002:a7b:c188:: with SMTP id y8mr676640wmi.76.1615929449870; Tue, 16 Mar 2021 14:17:29 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l5sm522481wmh.0.2021.03.16.14.17.29 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:29 -0700 (PDT) Message-Id: <6e0b452f44c1b8f8a5f9c0478b05a7d9248f69ad.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:07 +0000 Subject: [PATCH 19/27] entry: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- entry.c | 1 + 1 file changed, 1 insertion(+) diff --git a/entry.c b/entry.c index 7b9f43716f76..e55a2af867cf 100644 --- a/entry.c +++ b/entry.c @@ -412,6 +412,7 @@ static void mark_colliding_entries(const struct checkout *state, ce->ce_flags |= CE_MATCHED; + ensure_full_index(state->istate); for (i = 0; i < state->istate->cache_nr; i++) { struct cache_entry *dup = state->istate->cache[i]; From patchwork Tue Mar 16 21:17:08 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144147 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id DDB21C2BA2B for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id B7B4664FC0 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233102AbhCPVST (ORCPT ); Tue, 16 Mar 2021 17:18:19 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233256AbhCPVRc (ORCPT ); Tue, 16 Mar 2021 17:17:32 -0400 Received: from mail-wm1-x332.google.com (mail-wm1-x332.google.com [IPv6:2a00:1450:4864:20::332]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AC69CC061764 for ; Tue, 16 Mar 2021 14:17:31 -0700 (PDT) Received: by mail-wm1-x332.google.com with SMTP id g8so300237wmd.4 for ; Tue, 16 Mar 2021 14:17:31 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=5S+boZPxZe9aIuGKULqdZDqc05UAmbuh62BruURpn5w=; b=VAVn6JncjtQKmdOvlruaicJWQHhTZNxPAisprxr2q0lKIf8oX3OEBqXNl/a1cI7vDW cPL5x0pXvjsp6gKVSOlgfjhhQDVSRGXpzDYNQPnYO+jolA4Y2uTz+EVIHdVoYwdaAFd/ AfZ/9v4G+5m47bQvHkcASdP7B3BNl5b5GX+tEs2+8ccA9/199fAugYAGSKBLGBLlfhHo 5XoS5Gxqe21IkHk3UqxChCwy7NjeY7fX09IyR9nu06fzX5UQ1Dtz1Srim6rDhPOPQ/dQ nyB+d2XoxAMzQkDQdGVYn4wFUZ2cOSdDdGXwekhZoc9USx011fagMJYek3zPA5EyRgad D3aw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=5S+boZPxZe9aIuGKULqdZDqc05UAmbuh62BruURpn5w=; b=jXeslrfNJH7Visns81oC79zTjSyxk9jbTJqozf1jFvmLOxymqnMOETi5z/ZZNT6Bpo kprBPNW9FUdJ9GE01A8Hv4sSKASt/Tz+MM4zasSYazvPJ416XXIbheIrGK9r85e3r457 7obBGbSxIMJ0dYXFJwUf8e0zbLJnrHeYGqDoAL3mIwgxQXB1gTAAepB4NCZYl2dtEc6W hTmfB5x9giWscvwLsnFRiKji8LNPZah/F85tOuhYNCbyjweBfmqjnEtUsRuGosjrAL6m NmAdYVVuvP+kj7WESwtBIPbihEArEurv07c7QI37CtkF7T0pjybwy6Gf0uuiApZbSNM2 tovg== X-Gm-Message-State: AOAM533vx2tbkuTXJQKmeAfmgy5zsWZKfyNtgEf/u2PxruzFMgTOOCdl X3q21TNqxBEx6Xj540KwZVKncpUFmV4= X-Google-Smtp-Source: ABdhPJwM8H4S7TmBaFLrz7nFhyU3UHbZfe48A7uKXAxRuM29WM1pAp7+4NmnuUaIpAN7w0VYP+kv6A== X-Received: by 2002:a1c:7d4e:: with SMTP id y75mr670868wmc.168.1615929450555; Tue, 16 Mar 2021 14:17:30 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id n6sm27202279wrw.63.2021.03.16.14.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:30 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:08 +0000 Subject: [PATCH 20/27] merge-ort: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full one to avoid unexpected behavior. This is a top candidate for updating later with a proper integration with the sparse index, since we will likely enable the ORT strategy by default when the sparse index is enabled. This appears to be the only place where the ORT strategy interacts with the index in such a global way, so that integration should be clear once the ORT strategy and the sparse index topics stabilize. Signed-off-by: Derrick Stolee --- merge-ort.c | 1 + 1 file changed, 1 insertion(+) diff --git a/merge-ort.c b/merge-ort.c index 603d30c52170..9f737212555d 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -3112,6 +3112,7 @@ static int record_conflicted_index_entries(struct merge_options *opt, if (strmap_empty(conflicted)) return 0; + ensure_full_index(index); original_cache_nr = index->cache_nr; /* Put every entry from paths into plist, then sort */ From patchwork Tue Mar 16 21:17:09 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144139 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id ED44FC2BA4C for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id C64E664F9F for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233321AbhCPVSU (ORCPT ); Tue, 16 Mar 2021 17:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55910 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S229907AbhCPVRn (ORCPT ); Tue, 16 Mar 2021 17:17:43 -0400 Received: from mail-wr1-x436.google.com (mail-wr1-x436.google.com [IPv6:2a00:1450:4864:20::436]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 3514BC061765 for ; Tue, 16 Mar 2021 14:17:32 -0700 (PDT) Received: by mail-wr1-x436.google.com with SMTP id y16so11250459wrw.3 for ; Tue, 16 Mar 2021 14:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=hu0/iar66qUjlCaAn1Eiz2QQN3SmGd2tkTGGsb/YzAM=; b=itdFatmk6nsuxyyeXZZC0d31qMBK7w/frmTjQwF4dIjz/Juis75ocGewAKhXkYAdEg aBGyw/0ha2Coq5Vos23QL0/my+ecNtH1iwRs83sIxlv0ddXXVa2JFhVSAxY+JBqJ231f aEQ3wMJnkztjK/EtVVg1iQBfYcJ/AJuDo3ra/9nNyu5dnNEBuz/PoYRf0s00K+906ATJ RAUulHvKenN+v0gv/kvcY3pBq+n2lASSShw6zFirLVvioMnCGk/R5crEUFMmYhLmOJMi pmRzXS78FuLh7bvxsMCbDGCfXmfKG1h8cTapJ6JRvmVxAQKW3LKmQo8GzuvcXXtjHt+7 EmAg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=hu0/iar66qUjlCaAn1Eiz2QQN3SmGd2tkTGGsb/YzAM=; b=TO231VtNrJ0OLJZNjezQoAaryH1ZmmysR05GanDvzUXEJf19j+3d682BSVe5aTzXmo z2yFLOavoLI1dCFoWYKn3MGaLZKPpO2xHVk16W+AqEDme6IHiJyBfVHKfcHQX1RookaL d8Jia/3xdx/egtVF+IujPqsbi9s/7F5l8K1eRqm55TU0eHJRS8Iw4dQYohsFP1fhP6jn 7HJJwZHsD9qk3+LkwO/FG5oxRynDn001IbKUi9Ctv32kkDu7G+bwID4jKr6qSubfIPv6 YM7Jm+Y8JYHhR7hwpffkTndaiS0O08yi+DboQ5gOYcrnLLmUWl/IUHqh+LTKQcsd5YOg 4zSA== X-Gm-Message-State: AOAM531dbgfRqaP7M/mtnKcpXZKf2RIIdhwe0+4T1/8p9+yyBkHm4NMK qRN5vO+6haCAgaKDqRCj+NAbxkFM9jQ= X-Google-Smtp-Source: ABdhPJxg4MKaUqOvxwURivuLq8m6OWiSOZGOoTu4O4uM2eljKSD1Cc4gINu+cSpB2Fg7AEd4KgkUrQ== X-Received: by 2002:a5d:4884:: with SMTP id g4mr915589wrq.191.1615929451065; Tue, 16 Mar 2021 14:17:31 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q17sm18191181wrv.25.2021.03.16.14.17.30 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:30 -0700 (PDT) Message-Id: <57d59825627f10c4383c2c4ee8ee449e2c50f865.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:09 +0000 Subject: [PATCH 21/27] merge-recursive: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- merge-recursive.c | 1 + 1 file changed, 1 insertion(+) diff --git a/merge-recursive.c b/merge-recursive.c index b8de7a704eae..7954c7829d27 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -522,6 +522,7 @@ static struct string_list *get_unmerged(struct index_state *istate) unmerged->strdup_strings = 1; + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { struct string_list_item *item; struct stage_data *e; From patchwork Tue Mar 16 21:17:10 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144145 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 1EBA0C2BA57 for ; Tue, 16 Mar 2021 21:18:30 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ECE2C64FC0 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233329AbhCPVSU (ORCPT ); Tue, 16 Mar 2021 17:18:20 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55912 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S232951AbhCPVRo (ORCPT ); Tue, 16 Mar 2021 17:17:44 -0400 Received: from mail-wr1-x42e.google.com (mail-wr1-x42e.google.com [IPv6:2a00:1450:4864:20::42e]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id CA9C5C0613D7 for ; Tue, 16 Mar 2021 14:17:32 -0700 (PDT) Received: by mail-wr1-x42e.google.com with SMTP id x16so8182985wrn.4 for ; Tue, 16 Mar 2021 14:17:32 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=HEagPIBqKlz8JdRl77MY6+preXIwSsIGVX5BufOQHCs=; b=qceenLI3uEht3noV4YcwZVOVD8aLrDf2p3O9YyxCCfB7malb+75H8mua1r9JPCHfmK X6mONC2M0VZAW/47JbF9Twkpyj/71kMgapzAdxtRT/uZZc9k7rVtCWkT4DcxNkvQ8Yga 1yuzdNO9xqJta86f7Xo0IdpKKShIY2pN/+KAbXjpHhJMu99LzofZPwemojfktLf65m3D dCBfJPJ/RwjOdTgCIbfHDwhJf0/KYplz2cZ5ZtqwbzSdAGOXTmmlB3NG7yNBsm9Kg/RO C2DavS5Zs4XptFpxEYhLBBoiPnS31+zQNWpZBvR/K7etGSNiuAVVScQPs9qjsym0S8tY GwWg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=HEagPIBqKlz8JdRl77MY6+preXIwSsIGVX5BufOQHCs=; b=TArcsuM1hlUMClmsjSnlO5ADhwqfFsPpRXoL/hQ5StUm8/WbE4f51IY0ALhs94YYym 9z+QOMYRUv0TA8pU08JjpogDdgmWlXMPbNYaXn23hARXoVYb29laFh5/B8hxC7JZ9/nB iIa7O3b7sdZmwjP3nr2kRW3ljZYQC+kr9kVFsqnsfTrjji2uon26DdTPNThLTQOPjUg2 7/S2paqEKMTCEhA1hfyLDDYVhBpXsxg8VpRRq7BPGZO4FyPOejdmrS3hqoz1Quj4mSwE Y4MX/3KPAoFMk6+TcdQc1/X366g7Ep6vE8ZDTlWT/neDhej3FT5C1Bl6WPmUILCeJUNG tr6A== X-Gm-Message-State: AOAM5317xRLqcuD8jKsuI4X4N4ECLa7l883IqcIDeQHVGGLtXNOciUYa Xxlk0k9ADqVw5qx8m391VSTevW+N+JQ= X-Google-Smtp-Source: ABdhPJzhX0gSMqxXFsegQWYOeYWd4KVfc3GwfzXQlxDcrjnd4q88kY1HPiXROaq+Ob0aH8uU6h4DPw== X-Received: by 2002:adf:9261:: with SMTP id 88mr945611wrj.270.1615929451670; Tue, 16 Mar 2021 14:17:31 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id x11sm602441wme.9.2021.03.16.14.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:31 -0700 (PDT) Message-Id: In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:10 +0000 Subject: [PATCH 22/27] pathspec: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- pathspec.c | 1 + 1 file changed, 1 insertion(+) diff --git a/pathspec.c b/pathspec.c index b6e333965cb4..08736ab368d9 100644 --- a/pathspec.c +++ b/pathspec.c @@ -36,6 +36,7 @@ void add_pathspec_matches_against_index(const struct pathspec *pathspec, num_unmatched++; if (!num_unmatched) return; + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { const struct cache_entry *ce = istate->cache[i]; ce_path_match(istate, ce, pathspec, seen); From patchwork Tue Mar 16 21:17:11 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144133 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 8E3F8C4361A for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 70FAC64FAE for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233112AbhCPVSR (ORCPT ); Tue, 16 Mar 2021 17:18:17 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55920 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233266AbhCPVRe (ORCPT ); Tue, 16 Mar 2021 17:17:34 -0400 Received: from mail-wm1-x335.google.com (mail-wm1-x335.google.com [IPv6:2a00:1450:4864:20::335]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 77FE2C0613D8 for ; Tue, 16 Mar 2021 14:17:33 -0700 (PDT) Received: by mail-wm1-x335.google.com with SMTP id n11-20020a05600c4f8bb029010e5cf86347so4483240wmq.1 for ; Tue, 16 Mar 2021 14:17:33 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=9VXqIdq+Sb0A+QKYOzZ+nfEqPsMqEM+6C2lTnqiptME=; b=K5WAIS1N8AmEvDQY9IRcSm18tpHKSI7RlZIJ0eGC0hQ14iKmtk4CFvcFJbpkn9b2cO U+H5yXjoxAPOInspEKjxBhTl0lYOR1onBIBWr0u2SU1ohVmlPzZeRk+eFj+c+jMEwvJC lybqy8AFArryGqKiNP5d+ZBS9kjlU+WQz5rDNj+C7OwOz3r2mnXxaqO58473j6M+o2sc UuLBIJWJ76rLDSCu9QEpEDNdmtSvx34YFjA7sLUJD+okgevu21nT+4xM96WAdSVmOKYm PF4DfZtS+up/16wB0CaBtg6pDRvKD3Riua7uEG54YVMXlcOOMUyBJ+wBblx5Ui032WB2 M8Qg== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=9VXqIdq+Sb0A+QKYOzZ+nfEqPsMqEM+6C2lTnqiptME=; b=ihLkWNlX0o7otvRcbEcxBtH3fGHKS/3wxO2c5QdYwOm13zzzYg5MeppMkwQtYTJe5a nsvF0/YWI5xDt1pPYK65fd7L8RvZ/lkQuKc2M+kGLcLSXr/XYKafHZmAGDadMo0Qcu6v U0mCjnJO77uUdttj3vFAcqrkMt5gOS/59CQxo/PuZCbE5pCmbxVRUZzfqgA6AJtzf3+i IPJL67r8pa6Z8IEu7YeUDMigCb1kWO3I3ZHFTs6BNtI55SGYQEH1axWmTF/cQNZwFiak zMd6RZLRzR8FfNPONl9S0UQObbE+stzuvKYu+JLgn1Y7aK0QviyGqZTWzOfenQegN/95 SPfg== X-Gm-Message-State: AOAM532y3Z2T2LsptvB0dA00robvxdYLoY09wSy3EtKVtcB/TZJw0Uwc 1Nr+Gk+nh4C6JhiQa5PDojoh33SkpEM= X-Google-Smtp-Source: ABdhPJxB9mS3s7nNE+ruGogLcMo752nVrzAnPaSlA0LZmlHk3OZKmYc59T46RhV0cf6GXrJ2a/rBhw== X-Received: by 2002:a1c:8041:: with SMTP id b62mr725050wmd.0.1615929452272; Tue, 16 Mar 2021 14:17:32 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 91sm24466708wrl.20.2021.03.16.14.17.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:31 -0700 (PDT) Message-Id: <81519782d4b233790ddf773b088db1e2cd260c4d.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:11 +0000 Subject: [PATCH 23/27] read-cache: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- read-cache.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/read-cache.c b/read-cache.c index b143277ed106..7449f31381cf 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1576,6 +1576,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, */ preload_index(istate, pathspec, 0); trace2_region_enter("index", "refresh", NULL); + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce, *new_entry; int cache_errno = 0; @@ -2493,6 +2494,7 @@ int repo_index_has_changes(struct repository *repo, diff_flush(&opt); return opt.flags.has_changes != 0; } else { + ensure_full_index(istate); for (i = 0; sb && i < istate->cache_nr; i++) { if (i) strbuf_addch(sb, ' '); From patchwork Tue Mar 16 21:17:12 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144137 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 931E1C43142 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 81CF164FB5 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233309AbhCPVSQ (ORCPT ); Tue, 16 Mar 2021 17:18:16 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55880 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233087AbhCPVRf (ORCPT ); Tue, 16 Mar 2021 17:17:35 -0400 Received: from mail-wm1-x334.google.com (mail-wm1-x334.google.com [IPv6:2a00:1450:4864:20::334]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 12781C0613D9 for ; Tue, 16 Mar 2021 14:17:34 -0700 (PDT) Received: by mail-wm1-x334.google.com with SMTP id d191so313317wmd.2 for ; Tue, 16 Mar 2021 14:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=5C1rmeTZHP1Dom+BXHxQl5q3ACMKAOcfZGQJrPmzVp0=; b=XLdLxkk+f0CLYXKteKl+tqR03mGWr+fQvc853kQHksCFnVWBAbMisxXZiObmylA8u1 uBAjLqHIOt1Mmy3849zJWCn0P56VoehEcpZxSBKCI91dvT0H/dp1LCivvv+6M002W4UH jrPWIuN8TjWBb4WDTEVYfm2Nq1r8A8bQGtgVLUs3R96wQ8n6wfd4RhOl4oyYUtoNZCGU I0Ie5W9IUIhit+gI2eIVoRcCTDGkJ6YJ4tjbCPA7cPiJ6G9FQvvBcHa/rA0MTmCbj1Fj uiO/yRuSAdR9fDvzKUuThvhM7vsQAMF7BAYd0Kr6XP4Eir5ETO1bY8fNrTJFwsvNIDNJ cNdQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=5C1rmeTZHP1Dom+BXHxQl5q3ACMKAOcfZGQJrPmzVp0=; b=Ge1nBNJACAJi816X9iQPlb1k9xZdUAwDPrleSjXOExGKQdOHNt2GemB/OIkkBwtZcY 4rAPlCeiwU857vmKYLjw5lDUbkb+mm7Og09az/moI4mDWUfdmfzJ8Qly76ibSejPCpJ1 2W8AkLbsD1Ffy0/n8wh7yQmz02oHtYpDdCIBT5Cd77Fj9Lo7hVKXvREUPwiigFkX0Lma RCIBvORF8L355ps1fQxRO2EALMTMvMziEHJNFGphn97EO8w3JDhVFKTFjx6I1SSI5Hnd rDmUT/mVEUsQGYN6SfpJ2c9HLGlU+RVjJIkBoIkAduOVQjKdVwsb8xOrMRBPCbrumb8g cGbA== X-Gm-Message-State: AOAM533xdbfuN9KSxUWUzPOxRWejrMK1kxpgWZve1qsX2DdgD+a9k1mw ATIv4YZyHg+FY83yLL+T/jBs3s2RDvE= X-Google-Smtp-Source: ABdhPJywSCPoGqp5+gjEE6mUKFwp2UMlj8VfPNL7xud6hq66sfaGbV84q6UuyBbLNZDGbOyrcIeTpw== X-Received: by 2002:a7b:cc0c:: with SMTP id f12mr655938wmh.111.1615929452852; Tue, 16 Mar 2021 14:17:32 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h20sm505047wmm.19.2021.03.16.14.17.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:32 -0700 (PDT) Message-Id: <39e8bea0c1cadaf2a59760bea13025415569476f.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:12 +0000 Subject: [PATCH 24/27] resolve-undo: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all cache entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. Signed-off-by: Derrick Stolee --- resolve-undo.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/resolve-undo.c b/resolve-undo.c index 236320f179cb..3ccd3f66f80f 100644 --- a/resolve-undo.c +++ b/resolve-undo.c @@ -172,6 +172,7 @@ void unmerge_marked_index(struct index_state *istate) if (!istate->resolve_undo) return; + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { const struct cache_entry *ce = istate->cache[i]; if (ce->ce_flags & CE_MATCHED) @@ -186,6 +187,7 @@ void unmerge_index(struct index_state *istate, const struct pathspec *pathspec) if (!istate->resolve_undo) return; + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { const struct cache_entry *ce = istate->cache[i]; if (!ce_path_match(istate, ce, pathspec, NULL)) From patchwork Tue Mar 16 21:17:13 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144143 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 27047C4360C for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0060664FBC for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233302AbhCPVSP (ORCPT ); Tue, 16 Mar 2021 17:18:15 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55922 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233286AbhCPVRf (ORCPT ); Tue, 16 Mar 2021 17:17:35 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A88EAC0613DA for ; Tue, 16 Mar 2021 14:17:34 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id v11so8177414wro.7 for ; Tue, 16 Mar 2021 14:17:34 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=Pou/gpUa9pETGZK+kjLjxjTxUYn5JTnG63neWaT1igc=; b=iNvdMlZmWJPGbZRhtMcfw65pQ25l0Oeeb5cArg26+AzWAwOwwoHUaPn6ozBtBzMeEV cZE8spU1x1OraT7rfHL2uFEuwF98mea833LtksxjHr1ftD/ST18KsbPzjHpeoQbO5lLj WNH29NG8xTZHSoVeBGlKJdNCSH/alAIPjXtgmEYVPcaZejD55ELfEbK+V0oaN+FpP7cM o7W3B1n8S2UwWVVOB954FpckpKvneyuPv/pNdteZutKKti1QBrWhIDcigYviF4KPjoBA GSbzShlZ/q4EDBSo8dq0FNyBybRsqyO4DF4Zy3yqDxyQva5fBxhfwI3ScemskbjFNhnz 0Ldw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=Pou/gpUa9pETGZK+kjLjxjTxUYn5JTnG63neWaT1igc=; b=obX841wc/R+pyJg3xexjG10A+QFYgOvHF7nQDa/Gxn0XpOLn1CL1uHYP/Jb7pFS2iu ilJSa47z3n8GzivFpqyro8kLT5p9VDcjtiTVX9+HuCwQcd1+SFVHwJ4BtqskKfq6siIz T4dC2gRFBT24SSP4cAqTodfjgKgiKqW1nneygqY7TK+cxOSxgjn8tvnoTwLX8ZszqHJg eL+0+mLbls4ebP4GwKANwYu9DME1eBwTCXOmmeaDiG+zG4DKLu0qNOYCm5kBPI17b5EB Vxv4pgY9NBp2fvZPfWDWGh9+rWUJh0afr3X0iXiDxIBPr7euRyjZgp56r+GVAcJfXWyE VY8A== X-Gm-Message-State: AOAM532j16R29qcOgBX+gQ/nRJl4QcJrdmDmJP6wuRTdl76j2cyF54xQ U50Xh7PdWywEUzKX6RVzI/gU9j7nQRk= X-Google-Smtp-Source: ABdhPJyEdOks5I8I9d4JX5eNuz9zKXfCrtiy9mc8+tE4gGWD+p9Ddm2FCYz3/GQfbKlz3eAwHtOzqg== X-Received: by 2002:a5d:58e8:: with SMTP id f8mr1004196wrd.102.1615929453478; Tue, 16 Mar 2021 14:17:33 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o188sm551455wme.7.2021.03.16.14.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:33 -0700 (PDT) Message-Id: <6abb1813ae109f4be991aac7ab8897d35110aa36.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:13 +0000 Subject: [PATCH 25/27] revision: ensure full index Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Before iterating over all index entries, ensure that a sparse index is expanded to a full index to avoid unexpected behavior. This case could be integrated later by ensuring that we walk the tree in the sparse-directory entry, but the current behavior is only expecting blobs. Save this integration for later when it can be properly tested. Signed-off-by: Derrick Stolee --- revision.c | 1 + 1 file changed, 1 insertion(+) diff --git a/revision.c b/revision.c index b78733f5089b..1eee55934c08 100644 --- a/revision.c +++ b/revision.c @@ -1680,6 +1680,7 @@ static void do_add_index_objects_to_pending(struct rev_info *revs, { int i; + ensure_full_index(istate); for (i = 0; i < istate->cache_nr; i++) { struct cache_entry *ce = istate->cache[i]; struct blob *blob; From patchwork Tue Mar 16 21:17:14 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144131 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3E588C43619 for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 19BDA64F9F for ; Tue, 16 Mar 2021 21:18:29 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233306AbhCPVSN (ORCPT ); Tue, 16 Mar 2021 17:18:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233302AbhCPVRi (ORCPT ); Tue, 16 Mar 2021 17:17:38 -0400 Received: from mail-wm1-x336.google.com (mail-wm1-x336.google.com [IPv6:2a00:1450:4864:20::336]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 41431C06174A for ; Tue, 16 Mar 2021 14:17:35 -0700 (PDT) Received: by mail-wm1-x336.google.com with SMTP id n11-20020a05600c4f8bb029010e5cf86347so4483271wmq.1 for ; Tue, 16 Mar 2021 14:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=qHSWMVUd/JaRV1PnjZne6/VJzK+dPwaEdwERLlOy/zI=; b=Q6VowZqHhyiNgBlX0LQi09FPw+u4KEgZFGLiXQN/xv8XPkNc9gAX1CMgu/awG1Jfcr +qDyyQaSn9NCC06LqZ9qOSl/F45LJ/dneoZOQMW1LnsXqbKIXMm2th5pimEptoXXCP4q xDFRV3qhYfRUcaXIZ4idva7qcm06MgmxMVKS84ctmr8d6mMH4QoTMmwUYOSdwmtJmICz NxUnQgquNCBuoywRcv4rjFlm7OvQDkkFZo0unbYOp9KZJa804KeT1O5jB+mawx/7vgBr 7PDAmAjCRMJxfzF0T5RWsTxnPfJgiAErZ2K0Z5a58pbB9u/WkdvhPXmq+7bboWJOcC2h t0zw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=qHSWMVUd/JaRV1PnjZne6/VJzK+dPwaEdwERLlOy/zI=; b=sBjJ1rZjciFIRPEPsU0zT3OorvmjWu9ik7P0giWBwHRo2JshP30cUyz09/XqmSh8fx 1dqdAEa56RVKIsDQqke5XLcGJ+vQoeRmYXG7eieGUGkxwbWMU32yMBsGJ67DLWUeHdfN wYanxoqztjCNnySneNMA8Vc/AiaQOJ2B4lSZfvPAqVuC6qniMyFyTAKG8MCzKeH0YKkZ SX/ShU4J59BJ3Cl4zTLrWlYAjvhhafHurNvjfXmnxKW0RMXC5QR3tQC8zz846uZ9XRNk wFo0Sw3Cuqq3xzGQJ/aXZ41QI1zjgZM8nC4mxsxDDBPJn4EEuXnFTpfImpX+JatHKl0c Mh7A== X-Gm-Message-State: AOAM531IGBsjAxapRGUBAPlaThrnr/qLYSBydcMBAsstnb6LOYL9j+Cw OYL79Mai4R6EVHWC5LDVhRLox48FJjQ= X-Google-Smtp-Source: ABdhPJyXavbbU1TFzZr7CSB57aT99XDPuX+3jkxKEf5UYtUBujZSMKW/wOO4+WBDzo0zjKBRWN5PAQ== X-Received: by 2002:a1c:3d46:: with SMTP id k67mr665690wma.188.1615929454058; Tue, 16 Mar 2021 14:17:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id w6sm24590199wrl.49.2021.03.16.14.17.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:33 -0700 (PDT) Message-Id: <1690d33c11e0008c437eadfcef80de0dd870a86e.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:14 +0000 Subject: [PATCH 26/27] sparse-index: expand_to_path() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee Some users of the index API have a specific path they are looking for, but choose to use index_file_exists() to rely on the name-hash hashtable instead of doing binary search with index_name_pos(). These users only need to know a yes/no answer, not a position within the cache array. When the index is sparse, the name-hash hash table does not contain the full list of paths within sparse directories. It _does_ contain the directory names for the sparse-directory entries. Create a helper function, expand_to_path(), for intended use with the name-hash hashtable functions. The integration with name-hash.c will follow in a later change. The solution here is to use ensure_full_index() when we determine that the requested path is within a sparse directory entry. This will populate the name-hash hashtable as the index is recomputed from scratch. There may be cases where the caller is trying to find an untracked path that is not in the index but also is not within a sparse directory entry. We want to minimize the overhead for these requests. If we used index_name_pos() to find the insertion order of the path, then we could determine from that position if a sparse-directory exists. (In fact, just calling index_name_pos() in that case would lead to expanding the index to a full index.) However, this takes O(log N) time where N is the number of cache entries. To keep the performance of this call based mostly on the input string, use index_file_exists() to look for the ancestors of the path. Using the heuristic that a sparse directory is likely to have a small number of parent directories, we start from the bottom and build up. Use a string buffer to allow mutating the path name to terminate after each slash for each hashset test. Signed-off-by: Derrick Stolee --- sparse-index.c | 72 ++++++++++++++++++++++++++++++++++++++++++++++++++ sparse-index.h | 13 +++++++++ 2 files changed, 85 insertions(+) diff --git a/sparse-index.c b/sparse-index.c index 56313e805d9d..e5712d98d8b9 100644 --- a/sparse-index.c +++ b/sparse-index.c @@ -291,3 +291,75 @@ void ensure_full_index(struct index_state *istate) trace2_region_leave("index", "ensure_full_index", istate->repo); } + +/* + * This static global helps avoid infinite recursion between + * expand_to_path() and index_file_exists(). + */ +static int in_expand_to_path = 0; + +void expand_to_path(struct index_state *istate, + const char *path, size_t pathlen, int icase) +{ + struct strbuf path_mutable = STRBUF_INIT; + size_t substr_len; + + /* prevent extra recursion */ + if (in_expand_to_path) + return; + + if (!istate || !istate->sparse_index) + return; + + if (!istate->repo) + istate->repo = the_repository; + + in_expand_to_path = 1; + + /* + * We only need to actually expand a region if the + * following are both true: + * + * 1. 'path' is not already in the index. + * 2. Some parent directory of 'path' is a sparse directory. + */ + + if (index_file_exists(istate, path, pathlen, icase)) + goto cleanup; + + strbuf_add(&path_mutable, path, pathlen); + strbuf_addch(&path_mutable, '/'); + + /* Check the name hash for all parent directories */ + substr_len = 0; + while (substr_len < pathlen) { + char temp; + char *replace = strchr(path_mutable.buf + substr_len, '/'); + + if (!replace) + break; + + /* replace the character _after_ the slash */ + replace++; + temp = *replace; + *replace = '\0'; + if (index_file_exists(istate, path_mutable.buf, + path_mutable.len, icase)) { + /* + * We found a parent directory in the name-hash + * hashtable, which means that this entry could + * exist within a sparse-directory entry. Expand + * accordingly. + */ + ensure_full_index(istate); + break; + } + + *replace = temp; + substr_len = replace - path_mutable.buf; + } + +cleanup: + strbuf_release(&path_mutable); + in_expand_to_path = 0; +} diff --git a/sparse-index.h b/sparse-index.h index 0268f38753c0..1115a0d7dd98 100644 --- a/sparse-index.h +++ b/sparse-index.h @@ -4,6 +4,19 @@ struct index_state; int convert_to_sparse(struct index_state *istate); +/* + * Some places in the codebase expect to search for a specific path. + * This path might be outside of the sparse-checkout definition, in + * which case a sparse-index may not contain a path for that index. + * + * Given an index and a path, check to see if a leading directory for + * 'path' exists in the index as a sparse directory. In that case, + * expand that sparse directory to a full range of cache entries and + * populate the index accordingly. + */ +void expand_to_path(struct index_state *istate, + const char *path, size_t pathlen, int icase); + struct repository; int set_sparse_index_config(struct repository *repo, int enable); From patchwork Tue Mar 16 21:17:15 2021 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Derrick Stolee X-Patchwork-Id: 12144127 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-12.8 required=3.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FORGED_FROMDOMAIN,FREEMAIL_FROM, HEADER_FROM_DIFFERENT_DOMAINS,INCLUDES_CR_TRAILER,INCLUDES_PATCH, MAILING_LIST_MULTI,SPF_HELO_NONE,SPF_PASS autolearn=ham autolearn_force=no version=3.4.0 Received: from mail.kernel.org (mail.kernel.org [198.145.29.99]) by smtp.lore.kernel.org (Postfix) with ESMTP id EDBFDC432C3 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id DD16664FA5 for ; Tue, 16 Mar 2021 21:18:28 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S233072AbhCPVSK (ORCPT ); Tue, 16 Mar 2021 17:18:10 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:55906 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S233301AbhCPVRi (ORCPT ); Tue, 16 Mar 2021 17:17:38 -0400 Received: from mail-wr1-x42f.google.com (mail-wr1-x42f.google.com [IPv6:2a00:1450:4864:20::42f]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D3DFAC0613DB for ; Tue, 16 Mar 2021 14:17:35 -0700 (PDT) Received: by mail-wr1-x42f.google.com with SMTP id x13so8168355wrs.9 for ; Tue, 16 Mar 2021 14:17:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=message-id:in-reply-to:references:from:date:subject:fcc :content-transfer-encoding:mime-version:to:cc; bh=bFOrvSw80zbNP+4EnPIiQiVg9EM0jRAPgsEPYaxvRlQ=; b=NQhz+jMVUW7XyJOaSafcoaKrQtaRyIPxaRc37NM91J8vKoE2QPDN2iAAg5t/6rY9yy qu1EmKYcy9eZDPX4ci7XXamXaFfdsMh/7g/wb5u1sX156HJa2UOxJwrYGEbx5TioGv0n 9Eq5ub5tSyP8Nlh6yehfJA+IkpukVyvLxYi1I0opgn5KeiUhneT1U0GeJ2XwINJgxFro fbZGlthVOoqTAmWwHXMdCBhNFDHz8lTviYeA/a+nwRhFGR1NEt0RD159beFxnwLWLMCV ahisUexjSopCsa8QdKEvOqcGVD1Exuko3c6M4hmBTRM4zq299+gz0d3yx+YVub4RXzJx eEmw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:message-id:in-reply-to:references:from:date :subject:fcc:content-transfer-encoding:mime-version:to:cc; bh=bFOrvSw80zbNP+4EnPIiQiVg9EM0jRAPgsEPYaxvRlQ=; b=ZlZiP8FxRHsAcpIGzzsvz7s9kfDNAfZ7Z3H5pU6ogsu2Vww5rC5YVm9YZyah7OmAh1 tPrORJ6SJy7TvUpA85eaIYTtOxiM9asuhGT+LROuz5+sWb/3XPNGz/4PrW1G51upi2VW ySKU4CrVC14bkmGqr9YzL+8qQobYWjvEfnkrdLjv+NZtfYAzAbQ1Jn3pXeiebubQ+U7w 87sBCA2ICpnEy5cl4VC2KSLLVOmwR+s/OQEfxtRB0USVW5HUG2hyJHeTafNPPGta7u0P fjPYpDBdUzAFzJVQjnaLIjoagsKc6gfo4bwzUYrYi8C1cPHJMuXb5jsuPlS47Rw0ZlHr Uypw== X-Gm-Message-State: AOAM533xlbFRZBmB+CcY0lLlNIV89TrZPQuSEp2CiMUewdZqXPOfSrvI EH8lir+qttx1TF6CJYY6uXquJNA/Nco= X-Google-Smtp-Source: ABdhPJzTyzcromlvDLywDZYIRit50BENBIvMVNAMd4xUlgrX7+ILtT5ywj+R7ZD+42O9nuccJS5deg== X-Received: by 2002:a5d:6d0c:: with SMTP id e12mr954783wrq.136.1615929454613; Tue, 16 Mar 2021 14:17:34 -0700 (PDT) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id q19sm24394480wrg.80.2021.03.16.14.17.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 16 Mar 2021 14:17:34 -0700 (PDT) Message-Id: <40cfc59f695a6069277d4744a12c9f607e9aa35f.1615929436.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Tue, 16 Mar 2021 21:17:15 +0000 Subject: [PATCH 27/27] name-hash: use expand_to_path() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: newren@gmail.com, gitster@pobox.com, Derrick Stolee , Derrick Stolee Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org From: Derrick Stolee From: Derrick Stolee A sparse-index loads the name-hash data for its entries, including the sparse-directory entries. If a caller asks for a path that is contained within a sparse-directory entry, we need to expand to a full index and recalculate the name hash table before returning the result. Insert calls to expand_to_path() to protect against this case. Signed-off-by: Derrick Stolee --- name-hash.c | 10 ++++++++++ 1 file changed, 10 insertions(+) diff --git a/name-hash.c b/name-hash.c index 4e03fac9bb12..75c159e06eeb 100644 --- a/name-hash.c +++ b/name-hash.c @@ -8,6 +8,7 @@ #include "cache.h" #include "thread-utils.h" #include "trace2.h" +#include "sparse-index.h" struct dir_entry { struct hashmap_entry ent; @@ -109,6 +110,12 @@ static void hash_index_entry(struct index_state *istate, struct cache_entry *ce) if (ce->ce_flags & CE_HASHED) return; ce->ce_flags |= CE_HASHED; + + if (S_ISSPARSEDIR(ce->ce_mode)) { + add_dir_entry(istate, ce); + return; + } + hashmap_entry_init(&ce->ent, memihash(ce->name, ce_namelen(ce))); hashmap_add(&istate->name_hash, &ce->ent); @@ -680,6 +687,7 @@ int index_dir_exists(struct index_state *istate, const char *name, int namelen) struct dir_entry *dir; lazy_init_name_hash(istate); + expand_to_path(istate, name, namelen, 0); dir = find_dir_entry(istate, name, namelen); return dir && dir->nr; } @@ -690,6 +698,7 @@ void adjust_dirname_case(struct index_state *istate, char *name) const char *ptr = startPtr; lazy_init_name_hash(istate); + expand_to_path(istate, name, strlen(name), 0); while (*ptr) { while (*ptr && *ptr != '/') ptr++; @@ -713,6 +722,7 @@ struct cache_entry *index_file_exists(struct index_state *istate, const char *na unsigned int hash = memihash(name, namelen); lazy_init_name_hash(istate); + expand_to_path(istate, name, namelen, icase); ce = hashmap_get_entry_from_hash(&istate->name_hash, hash, NULL, struct cache_entry, ent);