From patchwork Fri Jan 1 13:06: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: 11994629 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 C74B7C433E0 for ; Fri, 1 Jan 2021 13:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 8F0F220799 for ; Fri, 1 Jan 2021 13:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727032AbhAANHx (ORCPT ); Fri, 1 Jan 2021 08:07:53 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57330 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbhAANHx (ORCPT ); Fri, 1 Jan 2021 08:07:53 -0500 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 8EA29C061575 for ; Fri, 1 Jan 2021 05:07:12 -0800 (PST) Received: by mail-wr1-x42e.google.com with SMTP id y17so21948877wrr.10 for ; Fri, 01 Jan 2021 05:07:12 -0800 (PST) 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=hEvygSnZL6ttE2KBbl6h90vJppdhYj3k6Qfru0A/68c=; b=Qz7jC94nUZCVPSo6QJbwsLW8LalpWkNCZ54Ea1PyBmYQA9dMgEOfraz3LMUj/1Xkek Hk0vApmaxM0PUdrInoELWBOOsqX6tgws/Ou664Rvf9fsg3nDLU5byQThZuYOR4Ymnhc8 EgAGRk7hU8LYCuVGQyLyMZJNEJCSGv2o0CGZBfoEDaxqXakHn10uDiZhxZuoc7uXb+Da 7AcRZFUakOr86yyDuU9cQCPk87dIK5Ea3ihHrOOMiXW95jqIUJYx6FKlT6xG80ZnN752 3hoTw4O30SKu4iPnlt9qzhK8BOU3EcOd8K94yAL4a03h9L+kOkAtaQRLMS2I2cIIiYYJ G8pQ== 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=hEvygSnZL6ttE2KBbl6h90vJppdhYj3k6Qfru0A/68c=; b=cofAeOjE+Fb5SldYTBaHeL95Eje0081O8ceUlGLnpBIPyUjUSBq+9FHmc0gIVJQQGt ZBP1xcMkHUkHcjR+vACoZIG+YKOkF8g0D3oJhaKgkUYMcNMwpjuY7i8j6M4NpNa3yqny L7mRdtyX1H+WKtGZ+TA/2AHIMuvqc5SwGAgVF4g2tR7P4yJT14LXAvoFo9cExfL0Kp6f HRIHR6qDLrkZNXYaYXbzofO5RnYqcT/R8RQlHIOkuj+86TRYEkTUr8POz6H5RlGlohPh n5+x8eokB4eqFlOBwqKa48DaJZVsl3ZwdZK0kkVXBASseC7uZQSivvzTRmooMbXSZNtJ v24A== X-Gm-Message-State: AOAM533arZGpwCcKvsLf5P52Maq7hSh88yEzAdiGGXAPI2uMhSOFXifc bWWZ8C/E1C1yVThlcXlRewqe6nm9EJI= X-Google-Smtp-Source: ABdhPJxoX8eH/WuwX6vjG0SP8teIg9F67iudrsPpC55AtsJRAFQDvxeOpbSOZ5asLJFd8/Qp7+EqHQ== X-Received: by 2002:a5d:4712:: with SMTP id y18mr69172975wrq.229.1609506430962; Fri, 01 Jan 2021 05:07:10 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id y13sm71664477wrl.63.2021.01.01.05.07.10 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:10 -0800 (PST) Message-Id: <68d88b651c74659eb171e88d701b89d11e7f5f24.1609506428.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 01 Jan 2021 13:06:57 +0000 Subject: [PATCH 01/12] merge-index: drop index compatibility macros Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 Replace uses of the old macros for the_index and instead pass around a 'struct index_state' pointer. This allows dropping the compatibility flag. Signed-off-by: Derrick Stolee --- builtin/merge-index.c | 33 ++++++++++++++++++--------------- 1 file changed, 18 insertions(+), 15 deletions(-) diff --git a/builtin/merge-index.c b/builtin/merge-index.c index 38ea6ad6ca2..8c7e6b0e6a2 100644 --- a/builtin/merge-index.c +++ b/builtin/merge-index.c @@ -1,4 +1,3 @@ -#define USE_THE_INDEX_COMPATIBILITY_MACROS #include "builtin.h" #include "run-command.h" @@ -6,18 +5,19 @@ static const char *pgm; static int one_shot, quiet; static int err; -static int merge_entry(int pos, const char *path) +static int merge_entry(struct index_state *istate, + int pos, const char *path) { int found; const char *arguments[] = { pgm, "", "", "", path, "", "", "", NULL }; char hexbuf[4][GIT_MAX_HEXSZ + 1]; char ownbuf[4][60]; - if (pos >= active_nr) + if (pos >= istate->cache_nr) die("git merge-index: %s not in the cache", path); found = 0; do { - const struct cache_entry *ce = active_cache[pos]; + const struct cache_entry *ce = istate->cache[pos]; int stage = ce_stage(ce); if (strcmp(ce->name, path)) @@ -27,7 +27,7 @@ static int merge_entry(int pos, const char *path) xsnprintf(ownbuf[stage], sizeof(ownbuf[stage]), "%o", ce->ce_mode); arguments[stage] = hexbuf[stage]; arguments[stage + 4] = ownbuf[stage]; - } while (++pos < active_nr); + } while (++pos < istate->cache_nr); if (!found) die("git merge-index: %s not in the cache", path); @@ -43,32 +43,34 @@ static int merge_entry(int pos, const char *path) return found; } -static void merge_one_path(const char *path) +static void merge_one_path(struct index_state *istate, + const char *path) { - int pos = cache_name_pos(path, strlen(path)); + int pos = index_name_pos(istate, path, strlen(path)); /* * If it already exists in the cache as stage0, it's * already merged and there is nothing to do. */ if (pos < 0) - merge_entry(-pos-1, path); + merge_entry(istate, -pos - 1, path); } -static void merge_all(void) +static void merge_all(struct index_state *istate) { int i; - for (i = 0; i < active_nr; i++) { - const struct cache_entry *ce = active_cache[i]; + for (i = 0; i < istate->cache_nr; i++) { + const struct cache_entry *ce = istate->cache[i]; if (!ce_stage(ce)) continue; - i += merge_entry(i, ce->name)-1; + i += merge_entry(istate, i, ce->name)-1; } } int cmd_merge_index(int argc, const char **argv, const char *prefix) { int i, force_file = 0; + struct index_state *istate; /* Without this we cannot rely on waitpid() to tell * what happened to our children. @@ -78,7 +80,8 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix) if (argc < 3) usage("git merge-index [-o] [-q] (-a | [--] [...])"); - read_cache(); + repo_read_index(the_repository); + istate = the_repository->index; i = 1; if (!strcmp(argv[i], "-o")) { @@ -98,12 +101,12 @@ int cmd_merge_index(int argc, const char **argv, const char *prefix) continue; } if (!strcmp(arg, "-a")) { - merge_all(); + merge_all(istate); continue; } die("git merge-index: unknown option %s", arg); } - merge_one_path(arg); + merge_one_path(istate, arg); } if (err && !quiet) die("merge program failed"); From patchwork Fri Jan 1 13:06: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: 11994635 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 E306FC433E9 for ; Fri, 1 Jan 2021 13:08:10 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id BE26F22210 for ; Fri, 1 Jan 2021 13:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727058AbhAANHz (ORCPT ); Fri, 1 Jan 2021 08:07:55 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57336 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbhAANHy (ORCPT ); Fri, 1 Jan 2021 08:07:54 -0500 Received: from mail-wr1-x434.google.com (mail-wr1-x434.google.com [IPv6:2a00:1450:4864:20::434]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 78253C061757 for ; Fri, 1 Jan 2021 05:07:13 -0800 (PST) Received: by mail-wr1-x434.google.com with SMTP id i9so21971052wrc.4 for ; Fri, 01 Jan 2021 05:07:13 -0800 (PST) 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=kdqg4CyYOfAKKRHMgCjKZSdIP/XxZ73cWhV3hxpXNuY=; b=SCj8+9VwX+PgQT6P7YudEnOWAH+1UbslupGzRdCw1Ya0zAvto5VPuwJWZtOjm98P4H 4lzK4cdX3LtYXEBhDN+WDTxSsBhTjSeEVzcVcSrkaNlOpL2ymjaNHxakGJ7ySGxh+BNK ovOsr6Pw2yhqOmPc2RhOpoQXsfQpVo+o2QCvE/LPwa1GZH77UFLS5NAmhV4PsmhPGg6w EhusrF0egivC9c3YtfR/JH/O5njEjTvuEZQE83NlSn9XxMHd/DGFXZoL/EAsgZ/iIXq+ TRzpsIrgerxhh6Q+L5a1eoIjbP899J5TxLpAAM5A+gpnvyDgzdRpbwa0iVTsWaQm3k5H BMWQ== 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=kdqg4CyYOfAKKRHMgCjKZSdIP/XxZ73cWhV3hxpXNuY=; b=keCzZvHqz85lW0z39614DxmgAyOyuqKaeRAX1V+NWE/Fe4F46zBIu46UNmP7T9j7wt 9LM92kkz1HWtDhAsWyt0MfCreUVZEzQ+1sC5ro7cS672dQTJrfL6eON0Bk9mlcj+4qYF kaGLNhxls9VtSeH1qZSsMbmnSWea7xCCjwNOqI88jyjd0FRxF8IcW9tD3M5LGjqpMvxz RM5003gMAFQxQbSnvX5k3yck7Ipa4PYnTbMqHzro0urk+0M0nkJsqRKY7yqQrr/brMkI zdKGsVeJYRayDjtIzCE2ivnv59fvDfCsDuQB8fm/3jHAol5J2lU5KZp6nSZ4RsoLS6ZB gHCA== X-Gm-Message-State: AOAM5333hIKI4y2p+0pZkESoblB+0wDQrKzGy5lW4+8Vhzp/q8H5AKz7 I0Ns9jx8Q+1iUN0r8zvD/OptwS5pwAE= X-Google-Smtp-Source: ABdhPJyFE4BNGzJ2VT5bj6b0pGchC0KodXEmB9MGoZHqOKBesBYDfYsUyXflKhdmgt0gEQdO2D7QwQ== X-Received: by 2002:a05:6000:4b:: with SMTP id k11mr68872582wrx.76.1609506431854; Fri, 01 Jan 2021 05:07:11 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o3sm60124395wrc.93.2021.01.01.05.07.11 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:11 -0800 (PST) Message-Id: <84330533d4f4e203cd5d8a61495adaafd3881a4a.1609506428.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 01 Jan 2021 13:06:58 +0000 Subject: [PATCH 02/12] mv: remove index compatibility macros Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 The mv builtin uses the compatibility macros to interact with the index. Update these to use modern methods referring to a 'struct index_state' pointer. Several helper methods need to be updated to consider such a pointer, but the modifications are rudimentary. Two macros can be deleted from cache.h because these are the last uses. Signed-off-by: Derrick Stolee --- builtin/mv.c | 42 +++++++++++++++++++++++------------------- cache.h | 2 -- 2 files changed, 23 insertions(+), 21 deletions(-) diff --git a/builtin/mv.c b/builtin/mv.c index 7dac714af90..0055d49a8a7 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -3,7 +3,6 @@ * * Copyright (C) 2006 Johannes Schindelin */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS #include "builtin.h" #include "config.h" #include "pathspec.h" @@ -75,13 +74,14 @@ static const char *add_slash(const char *path) #define SUBMODULE_WITH_GITDIR ((const char *)1) -static void prepare_move_submodule(const char *src, int first, +static void prepare_move_submodule(struct index_state *istate, + const char *src, int first, const char **submodule_gitfile) { struct strbuf submodule_dotgit = STRBUF_INIT; - if (!S_ISGITLINK(active_cache[first]->ce_mode)) + if (!S_ISGITLINK(istate->cache[first]->ce_mode)) die(_("Directory %s is in index and no submodule?"), src); - if (!is_staging_gitmodules_ok(&the_index)) + if (!is_staging_gitmodules_ok(istate)) die(_("Please stage your changes to .gitmodules or stash them to proceed")); strbuf_addf(&submodule_dotgit, "%s/.git", src); *submodule_gitfile = read_gitfile(submodule_dotgit.buf); @@ -92,19 +92,20 @@ static void prepare_move_submodule(const char *src, int first, strbuf_release(&submodule_dotgit); } -static int index_range_of_same_dir(const char *src, int length, +static int index_range_of_same_dir(struct index_state *istate, + const char *src, int length, int *first_p, int *last_p) { const char *src_w_slash = add_slash(src); int first, last, len_w_slash = length + 1; - first = cache_name_pos(src_w_slash, len_w_slash); + first = index_name_pos(istate, src_w_slash, len_w_slash); if (first >= 0) die(_("%.*s is in index"), len_w_slash, src_w_slash); first = -1 - first; - for (last = first; last < active_nr; last++) { - const char *path = active_cache[last]->name; + for (last = first; last < istate->cache_nr; last++) { + const char *path = istate->cache[last]->name; if (strncmp(path, src_w_slash, len_w_slash)) break; } @@ -133,6 +134,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) struct string_list src_for_dst = STRING_LIST_INIT_NODUP; struct lock_file lock_file = LOCK_INIT; struct cache_entry *ce; + struct index_state *istate; git_config(git_default_config, NULL); @@ -141,9 +143,10 @@ int cmd_mv(int argc, const char **argv, const char *prefix) if (--argc < 1) usage_with_options(builtin_mv_usage, builtin_mv_options); - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR); - if (read_cache() < 0) + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR); + if (repo_read_index(the_repository) < 0) die(_("index file corrupt")); + istate = the_repository->index; source = internal_prefix_pathspec(prefix, argv, argc, 0); modes = xcalloc(argc, sizeof(enum update_mode)); @@ -190,12 +193,13 @@ int cmd_mv(int argc, const char **argv, const char *prefix) && lstat(dst, &st) == 0) bad = _("cannot move directory over file"); else if (src_is_dir) { - int first = cache_name_pos(src, length), last; + int first = index_name_pos(istate, src, length); + int last; if (first >= 0) - prepare_move_submodule(src, first, + prepare_move_submodule(istate, src, first, submodule_gitfile + i); - else if (index_range_of_same_dir(src, length, + else if (index_range_of_same_dir(istate, src, length, &first, &last) < 1) bad = _("source directory is empty"); else { /* last - first >= 1 */ @@ -212,7 +216,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) dst_len = strlen(dst); for (j = 0; j < last - first; j++) { - const char *path = active_cache[first + j]->name; + const char *path = istate->cache[first + j]->name; source[argc + j] = path; destination[argc + j] = prefix_path(dst, dst_len, path + length + 1); @@ -221,7 +225,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix) } argc += last - first; } - } else if (!(ce = cache_file_exists(src, length, ignore_case))) { + } else if (!(ce = index_file_exists(istate, src, length, ignore_case))) { bad = _("not under version control"); } else if (ce_stage(ce)) { bad = _("conflicted"); @@ -291,15 +295,15 @@ int cmd_mv(int argc, const char **argv, const char *prefix) if (mode == WORKING_DIRECTORY) continue; - pos = cache_name_pos(src, strlen(src)); + pos = index_name_pos(istate, src, strlen(src)); assert(pos >= 0); - rename_cache_entry_at(pos, dst); + rename_index_entry_at(istate, pos, dst); } if (gitmodules_modified) - stage_updated_gitmodules(&the_index); + stage_updated_gitmodules(istate); - if (write_locked_index(&the_index, &lock_file, + if (write_locked_index(istate, &lock_file, COMMIT_LOCK | SKIP_IF_UNCHANGED)) die(_("Unable to write new index file")); diff --git a/cache.h b/cache.h index 71097657489..7bfb8195d97 100644 --- a/cache.h +++ b/cache.h @@ -409,7 +409,6 @@ extern struct index_state the_index; #define unmerged_cache() unmerged_index(&the_index) #define cache_name_pos(name, namelen) index_name_pos(&the_index,(name),(namelen)) #define add_cache_entry(ce, option) add_index_entry(&the_index, (ce), (option)) -#define rename_cache_entry_at(pos, new_name) rename_index_entry_at(&the_index, (pos), (new_name)) #define remove_cache_entry_at(pos) remove_index_entry_at(&the_index, (pos)) #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path)) #define add_to_cache(path, st, flags) add_to_index(&the_index, (path), (st), (flags)) @@ -420,7 +419,6 @@ extern struct index_state the_index; #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options)) #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options)) #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen)) -#define cache_file_exists(name, namelen, igncase) index_file_exists(&the_index, (name), (namelen), (igncase)) #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen)) #define resolve_undo_clear() resolve_undo_clear_index(&the_index) #define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at) From patchwork Fri Jan 1 13:06: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: 11994631 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 1E49CC433E6 for ; Fri, 1 Jan 2021 13:08:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D850E20799 for ; Fri, 1 Jan 2021 13:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727085AbhAANH5 (ORCPT ); Fri, 1 Jan 2021 08:07:57 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57340 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727038AbhAANHy (ORCPT ); Fri, 1 Jan 2021 08:07:54 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4974CC0613C1 for ; Fri, 1 Jan 2021 05:07:14 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id 91so21949652wrj.7 for ; Fri, 01 Jan 2021 05:07:14 -0800 (PST) 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=0TeogiNJ7ipGmFDWNnuJH30APRPsqSsAei8/MLisySQ=; b=DiIZdUhYsfJikPnf3CQNG+G/Fbvz6HRkg5gbKe/ExctAItVvWFGkTy06YzieSTgHsm iO+IeLvXzY5sq5aeCFw10pMS1J9dcazoYEPBLJNXpPwbBj7IFnbKgvBUElV9MYXaudCa 9sLedB8okhdbD0TjN7n2oK95tMAzzPd1pqJ4WdsUn0c5U84s/HsaPoTwlB4kU1SCiD4/ Xpj5fomVsj/3H2EmS3jpzVXqeSY0DWwJJV5dWSn4CNrdx/Oa6mKsJB2z3g0wzENYvENo J5LInKRc+HIMIQCwMCU7zv1iclbjkAOgYzx4kq7LlbBpLjKF5KyLlOv85V8AZkYOmLWy i2CQ== 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=0TeogiNJ7ipGmFDWNnuJH30APRPsqSsAei8/MLisySQ=; b=P2B7Fzs2bVlHggRI//BQRgFc5fIF7TTXixHFHBUu8vVtsn3+CeTW2T8WBACVa4v/aO /qH8R7q9S9SygdfE6Wg9UYAsqD+KrRQqLDjMDWdPyewyzMXJFAFSVoqeC/dwpFnlKjYf BskG0209CvCdUN+lTTwBOg8/hXLNveGMmZq1np3xyxpu1xFb4Oj4PL62ZoLfiaOSe/zf wd/4ORZ+ftvblGMSO3+jLUH0O5bfAZz5vyDH6bHYidrdp2+1iSpV51ydFC2cbH+vrOJ4 fGZGAWrnTq1GmgPIYJDgG0YtIDJ/b1o2GvHJKMiQ0cZeHgeLFlfpHJo9/ki8uJEzlPed uN1A== X-Gm-Message-State: AOAM532HYVwZEJ9nuWwd/BBtez3bZOC3BXpEtGLtMWhEZRU26vB1vdGu kk1S4HSrC1fA5sdnyZZAQt/B+lHQLaM= X-Google-Smtp-Source: ABdhPJzWSVKSA0BdiY7y6EHOAQXcZEoFKrJPQof4nwqTLVaVjFbOZAWb8/5GRQuhkcygCxGSQqSxMg== X-Received: by 2002:a5d:4fc4:: with SMTP id h4mr66473738wrw.129.1609506432669; Fri, 01 Jan 2021 05:07:12 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id l7sm16537472wme.4.2021.01.01.05.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:12 -0800 (PST) Message-Id: <54e167d587260f79d3ce532e26de27ca5a440fd1.1609506428.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 01 Jan 2021 13:06:59 +0000 Subject: [PATCH 03/12] rm: remove compatilibity macros Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 The rm builtin still uses the antiquated compatibility macros for interacting with the index. Update these to the more modern uses by passing around a 'struct index_state' pointer. Signed-off-by: Derrick Stolee --- builtin/rm.c | 56 ++++++++++++++++++++++++++++------------------------ 1 file changed, 30 insertions(+), 26 deletions(-) diff --git a/builtin/rm.c b/builtin/rm.c index 4858631e0f0..767df8d6b25 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -3,7 +3,6 @@ * * Copyright (C) Linus Torvalds 2006 */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS #include "builtin.h" #include "config.h" #include "lockfile.h" @@ -28,12 +27,14 @@ static struct { } *entry; } list; -static int get_ours_cache_pos(const char *path, int pos) +static int get_ours_cache_pos(struct index_state *istate, + const char *path, int pos) { int i = -pos - 1; - while ((i < active_nr) && !strcmp(active_cache[i]->name, path)) { - if (ce_stage(active_cache[i]) == 2) + while ((i < istate->cache_nr) && + !strcmp(istate->cache[i]->name, path)) { + if (ce_stage(istate->cache[i]) == 2) return i; i++; } @@ -61,7 +62,7 @@ static void print_error_files(struct string_list *files_list, } } -static void submodules_absorb_gitdir_if_needed(void) +static void submodules_absorb_gitdir_if_needed(struct index_state *istate) { int i; for (i = 0; i < list.nr; i++) { @@ -69,13 +70,13 @@ static void submodules_absorb_gitdir_if_needed(void) int pos; const struct cache_entry *ce; - pos = cache_name_pos(name, strlen(name)); + pos = index_name_pos(istate, name, strlen(name)); if (pos < 0) { - pos = get_ours_cache_pos(name, pos); + pos = get_ours_cache_pos(istate, name, pos); if (pos < 0) continue; } - ce = active_cache[pos]; + ce = istate->cache[pos]; if (!S_ISGITLINK(ce->ce_mode) || !file_exists(ce->name) || @@ -88,7 +89,8 @@ static void submodules_absorb_gitdir_if_needed(void) } } -static int check_local_mod(struct object_id *head, int index_only) +static int check_local_mod(struct index_state *istate, + struct object_id *head, int index_only) { /* * Items in list are already sorted in the cache order, @@ -114,21 +116,21 @@ static int check_local_mod(struct object_id *head, int index_only) int local_changes = 0; int staged_changes = 0; - pos = cache_name_pos(name, strlen(name)); + pos = index_name_pos(istate, name, strlen(name)); if (pos < 0) { /* * Skip unmerged entries except for populated submodules * that could lose history when removed. */ - pos = get_ours_cache_pos(name, pos); + pos = get_ours_cache_pos(istate, name, pos); if (pos < 0) continue; - if (!S_ISGITLINK(active_cache[pos]->ce_mode) || + if (!S_ISGITLINK(istate->cache[pos]->ce_mode) || is_empty_dir(name)) continue; } - ce = active_cache[pos]; + ce = istate->cache[pos]; if (lstat(ce->name, &st) < 0) { if (!is_missing_file_error(errno)) @@ -165,7 +167,7 @@ static int check_local_mod(struct object_id *head, int index_only) * Is the index different from the file in the work tree? * If it's a submodule, is its work tree modified? */ - if (ce_match_stat(ce, &st, 0) || + if (ie_match_stat(istate, ce, &st, 0) || (S_ISGITLINK(ce->ce_mode) && bad_to_remove_submodule(ce->name, SUBMODULE_REMOVAL_DIE_ON_ERROR | @@ -257,6 +259,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) int i; struct pathspec pathspec; char *seen; + struct index_state *istate; git_config(git_default_config, NULL); @@ -284,24 +287,25 @@ int cmd_rm(int argc, const char **argv, const char *prefix) if (!index_only) setup_work_tree(); - hold_locked_index(&lock_file, LOCK_DIE_ON_ERROR); + repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR); - if (read_cache() < 0) + if (repo_read_index(the_repository) < 0) die(_("index file corrupt")); - refresh_index(&the_index, REFRESH_QUIET|REFRESH_UNMERGED, &pathspec, NULL, NULL); + istate = the_repository->index; + refresh_index(istate, REFRESH_QUIET|REFRESH_UNMERGED, &pathspec, NULL, NULL); seen = xcalloc(pathspec.nr, 1); - for (i = 0; i < active_nr; i++) { - const struct cache_entry *ce = active_cache[i]; - if (!ce_path_match(&the_index, ce, &pathspec, seen)) + for (i = 0; i < istate->cache_nr; i++) { + const struct cache_entry *ce = istate->cache[i]; + if (!ce_path_match(istate, ce, &pathspec, seen)) continue; ALLOC_GROW(list.entry, list.nr + 1, list.alloc); list.entry[list.nr].name = xstrdup(ce->name); list.entry[list.nr].is_submodule = S_ISGITLINK(ce->ce_mode); if (list.entry[list.nr++].is_submodule && - !is_staging_gitmodules_ok(&the_index)) + !is_staging_gitmodules_ok(istate)) die(_("please stage your changes to .gitmodules or stash them to proceed")); } @@ -329,7 +333,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) } if (!index_only) - submodules_absorb_gitdir_if_needed(); + submodules_absorb_gitdir_if_needed(istate); /* * If not forced, the file, the index and the HEAD (if exists) @@ -345,7 +349,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) struct object_id oid; if (get_oid("HEAD", &oid)) oidclr(&oid); - if (check_local_mod(&oid, index_only)) + if (check_local_mod(istate, &oid, index_only)) exit(1); } @@ -358,7 +362,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) if (!quiet) printf("rm '%s'\n", path); - if (remove_file_from_cache(path)) + if (remove_file_from_index(istate, path)) die(_("git rm: unable to remove %s"), path); } @@ -398,10 +402,10 @@ int cmd_rm(int argc, const char **argv, const char *prefix) } strbuf_release(&buf); if (gitmodules_modified) - stage_updated_gitmodules(&the_index); + stage_updated_gitmodules(istate); } - if (write_locked_index(&the_index, &lock_file, + if (write_locked_index(istate, &lock_file, COMMIT_LOCK | SKIP_IF_UNCHANGED)) die(_("Unable to write new index file")); From patchwork Fri Jan 1 13:07: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: 11994633 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 3722BC43381 for ; Fri, 1 Jan 2021 13:08:11 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 05F5020888 for ; Fri, 1 Jan 2021 13:08:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727094AbhAANH7 (ORCPT ); Fri, 1 Jan 2021 08:07:59 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57346 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbhAANHz (ORCPT ); Fri, 1 Jan 2021 08:07:55 -0500 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 23089C0613CF for ; Fri, 1 Jan 2021 05:07:15 -0800 (PST) Received: by mail-wm1-x334.google.com with SMTP id g185so9011565wmf.3 for ; Fri, 01 Jan 2021 05:07:15 -0800 (PST) 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=KHykIfsh0Vb8IWAINw3GY8cLRHHZg/Ilzg6BOGQHP74=; b=oRqJiIszrR0pHYBCeZOyTtqdWRfa2VqpAkVtKgb9ceOpASAGd0ubZ3EmDiPZIms6WJ cyOv/TNAdQQq6dCyXCa9auUekvctZ8bj2/K4XqNVDk2ysPLIsaFCDCGD4Eyf2DbEsRED IBShLgZtP3jt2AsCk4qEOlII50AFTJdYBEhJEum9wckAH4ctztr4vFyBLRcZikzGZ3iu QXc+ULO/ypiLi2hcmc0g4JRepjwYttKqGCYFV2eWif5lUQ98XNuP1ogRcw8lwKtvhoWw P4SfXW5tyy8uPTwBFY05Se9OHLQyLAA+dBaopkPMzg55PSFljglUkqtFMTSe413jiKic lnNw== 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=KHykIfsh0Vb8IWAINw3GY8cLRHHZg/Ilzg6BOGQHP74=; b=GKk7ydk5jC+PYAxA19XC35El6HAY2D7w/9tiZBSNYLEytOE/SF4mXhK7fd1555zQbd GDblpzhMXH79Jp+RwnHGqVVNbHBendZYE3zbZVYanhydCerKNdnrvA5iEDS2W7uJz8Gh K9kQVEx9Pxqodserbc9oKE4JwqSpx5V/dxH2Y7sVaAHsLIjwHn21CvsYJ9nvrf/jEHRh ceAg2e//Az1gSmHZQBqWRQVP+c95OtecFYwL1YacWt1H9t/VZ3cCPkCQ4XqPlsSyDLU8 dcSbnf/l0Ns0I5ukRrZXyWTm2xdSzTL6GtdftXn2Wqjiy5uO1WAVRs4bgdbljfzC2do7 FwKA== X-Gm-Message-State: AOAM530iYHkaQJT0wMqXgUov3ZmJZAlIqIbDb7jDAcX9HT/BbCbrdJ4x Jzwo9+HsPJBEP6XhucVWAf5tNPKdeDM= X-Google-Smtp-Source: ABdhPJxeCg2XMridIJLsRyOt91QyQ5ExhJOJrFiFvNgXEzn1WYGEAkFwWRIbDM+937QFF+HoGxTG0g== X-Received: by 2002:a1c:e246:: with SMTP id z67mr15666991wmg.166.1609506433682; Fri, 01 Jan 2021 05:07:13 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id s3sm15460568wmc.44.2021.01.01.05.07.12 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:13 -0800 (PST) Message-Id: <77f6510bb680aaf119526f75daadf8c40d22793e.1609506428.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:00 +0000 Subject: [PATCH 04/12] update-index: drop the_index, the_repository Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 To reduce the need for the index compatibility macros, we will replace their uses in update-index mechanically. This is the most interesting change, which creates global "repo" and "istate" pointers. The macros can then be mechanically replaced by instances that use the istate pointer instead of the version that autocompletes to use the_index. Signed-off-by: Derrick Stolee --- builtin/update-index.c | 59 +++++++++++++++++++++++------------------- 1 file changed, 32 insertions(+), 27 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index 79087bccea4..c9a6cde97da 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -40,6 +40,9 @@ static int ignore_skip_worktree_entries; #define UNMARK_FLAG 2 static struct strbuf mtime_dir = STRBUF_INIT; +static struct repository *repo; +static struct index_state *istate; + /* Untracked cache mode */ enum uc_mode { UC_UNSPECIFIED = -1, @@ -232,13 +235,13 @@ static int mark_ce_flags(const char *path, int flag, int mark) int namelen = strlen(path); int pos = cache_name_pos(path, namelen); if (0 <= pos) { - mark_fsmonitor_invalid(&the_index, active_cache[pos]); + mark_fsmonitor_invalid(istate, active_cache[pos]); if (mark) active_cache[pos]->ce_flags |= flag; else active_cache[pos]->ce_flags &= ~flag; active_cache[pos]->ce_flags |= CE_UPDATE_IN_BASE; - cache_tree_invalidate_path(&the_index, path); + cache_tree_invalidate_path(istate, path); active_cache_changed |= CE_ENTRY_CHANGED; return 0; } @@ -277,14 +280,14 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len if (old && !ce_stage(old) && !ce_match_stat(old, st, 0)) return 0; - ce = make_empty_cache_entry(&the_index, len); + ce = make_empty_cache_entry(istate, len); memcpy(ce->name, path, len); ce->ce_flags = create_ce_flags(0); ce->ce_namelen = len; - fill_stat_cache_info(&the_index, ce, st); + fill_stat_cache_info(istate, ce, st); ce->ce_mode = ce_mode_from_stat(old, st->st_mode); - if (index_path(&the_index, &ce->oid, path, st, + if (index_path(istate, &ce->oid, path, st, info_only ? 0 : HASH_WRITE_OBJECT)) { discard_cache_entry(ce); return -1; @@ -411,7 +414,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid, return error("Invalid path '%s'", path); len = strlen(path); - ce = make_empty_cache_entry(&the_index, len); + ce = make_empty_cache_entry(istate, len); oidcpy(&ce->oid, oid); memcpy(ce->name, path, len); @@ -603,7 +606,7 @@ static struct cache_entry *read_one_ent(const char *which, struct object_id oid; struct cache_entry *ce; - if (get_tree_entry(the_repository, ent, path, &oid, &mode)) { + if (get_tree_entry(repo, ent, path, &oid, &mode)) { if (which) error("%s: not in %s branch.", path, which); return NULL; @@ -613,7 +616,7 @@ static struct cache_entry *read_one_ent(const char *which, error("%s: not a blob in %s branch.", path, which); return NULL; } - ce = make_empty_cache_entry(&the_index, namelen); + ce = make_empty_cache_entry(istate, namelen); oidcpy(&ce->oid, &oid); memcpy(ce->name, path, namelen); @@ -751,7 +754,7 @@ static int do_reupdate(int ac, const char **av, int save_nr; char *path; - if (ce_stage(ce) || !ce_path_match(&the_index, ce, &pathspec, NULL)) + if (ce_stage(ce) || !ce_path_match(istate, ce, &pathspec, NULL)) continue; if (has_head) old = read_one_ent(NULL, &head_oid, @@ -968,7 +971,6 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) struct parse_opt_ctx_t ctx; strbuf_getline_fn getline_fn; int parseopt_state = PARSE_OPT_UNKNOWN; - struct repository *r = the_repository; struct option options[] = { OPT_BIT('q', NULL, &refresh_args.flags, N_("continue refresh even when index needs update"), @@ -1077,16 +1079,19 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); + repo = the_repository; + /* we will diagnose later if it turns out that we need to update it */ - newfd = hold_locked_index(&lock_file, 0); + newfd = repo_hold_locked_index(repo, &lock_file, 0); if (newfd < 0) lock_error = errno; - entries = read_cache(); + entries = repo_read_index(repo); if (entries < 0) die("cache corrupted"); - the_index.updated_skipworktree = 1; + istate = repo->index; + istate->updated_skipworktree = 1; /* * Custom copy of parse_options() because we want to handle @@ -1140,9 +1145,9 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) preferred_index_format, INDEX_FORMAT_LB, INDEX_FORMAT_UB); - if (the_index.version != preferred_index_format) + if (istate->version != preferred_index_format) active_cache_changed |= SOMETHING_CHANGED; - the_index.version = preferred_index_format; + istate->version = preferred_index_format; } if (read_from_stdin) { @@ -1173,28 +1178,28 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) warning(_("core.splitIndex is set to false; " "remove or change it, if you really want to " "enable split index")); - if (the_index.split_index) - the_index.cache_changed |= SPLIT_INDEX_ORDERED; + if (istate->split_index) + istate->cache_changed |= SPLIT_INDEX_ORDERED; else - add_split_index(&the_index); + add_split_index(istate); } else if (!split_index) { if (git_config_get_split_index() == 1) warning(_("core.splitIndex is set to true; " "remove or change it, if you really want to " "disable split index")); - remove_split_index(&the_index); + remove_split_index(istate); } - prepare_repo_settings(r); + prepare_repo_settings(repo); switch (untracked_cache) { case UC_UNSPECIFIED: break; case UC_DISABLE: - if (r->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE) + if (repo->settings.core_untracked_cache == UNTRACKED_CACHE_WRITE) warning(_("core.untrackedCache is set to true; " "remove or change it, if you really want to " "disable the untracked cache")); - remove_untracked_cache(&the_index); + remove_untracked_cache(istate); report(_("Untracked cache disabled")); break; case UC_TEST: @@ -1202,11 +1207,11 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) return !test_if_untracked_cache_is_supported(); case UC_ENABLE: case UC_FORCE: - if (r->settings.core_untracked_cache == UNTRACKED_CACHE_REMOVE) + if (repo->settings.core_untracked_cache == UNTRACKED_CACHE_REMOVE) warning(_("core.untrackedCache is set to false; " "remove or change it, if you really want to " "enable the untracked cache")); - add_untracked_cache(&the_index); + add_untracked_cache(istate); report(_("Untracked cache enabled for '%s'"), get_git_work_tree()); break; default: @@ -1218,14 +1223,14 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) warning(_("core.fsmonitor is unset; " "set it if you really want to " "enable fsmonitor")); - add_fsmonitor(&the_index); + add_fsmonitor(istate); report(_("fsmonitor enabled")); } else if (!fsmonitor) { if (git_config_get_fsmonitor() == 1) warning(_("core.fsmonitor is set; " "remove it if you really want to " "disable fsmonitor")); - remove_fsmonitor(&the_index); + remove_fsmonitor(istate); report(_("fsmonitor disabled")); } @@ -1235,7 +1240,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) exit(128); unable_to_lock_die(get_index_file(), lock_error); } - if (write_locked_index(&the_index, &lock_file, COMMIT_LOCK)) + if (write_locked_index(istate, &lock_file, COMMIT_LOCK)) die("Unable to write new index file"); } From patchwork Fri Jan 1 13:07: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: 11994649 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 9CF08C4332D for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 781B42223E for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727186AbhAANIk (ORCPT ); Fri, 1 Jan 2021 08:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57448 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726795AbhAANId (ORCPT ); Fri, 1 Jan 2021 08:08:33 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id EA4DAC0613ED for ; Fri, 1 Jan 2021 05:07:15 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id d26so21922601wrb.12 for ; Fri, 01 Jan 2021 05:07:15 -0800 (PST) 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=9pGFETYdqulowBLIqdiA0ZUCZfR86+rle0TskkGe5u8=; b=KzrYRFY8Ahdn21M45JdHPzyfzLbg/YJwJFao+ULjuvuuoWhyO3N6rNb4plN4Dznh8V t389wHrrWurR+hGPj6imjk6MEz/w9ahweP0wewQDK1jQEEkzEr+eorCdlIiXcKpzyyV5 whZE9PluWzULR/QLVktvyEuuiyVhSPYrQIJynChGY9Mjlc1DWt/pk+fCRIagDFkiIE1i aq0V7l/NphOiX5RJVYx58hDBLB7G5YMAVwtqzAmPpI68chPFd6u6KSqONZC0gWmVT1re A0BtQxplfEh9bApki5GezyzIJaycgcOSUm9O5mY6AUrKQ7BKshrNvX1PeuJIU+pkmDBd M3Ww== 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=9pGFETYdqulowBLIqdiA0ZUCZfR86+rle0TskkGe5u8=; b=mCe8tXMtmXYqisSmhKUzKpeaSlQf63STKMf1r/ZsbMuYF+VK3ETISbtRwG6A/TSgy5 e1qeaF7/6aJRUqnCb9I+RchOBvQ7Sf5MFgOd+3m9+OYtoU2zohM8KP2ERpUihbQA1j66 7GKxj8fY/MGaDyZB0MpKN0Y8o+Bt2mw0cSYPrHvFWdpQXhJQG3utnW2hwDdjsjKxm2HJ NlKhJLqWl/dEl1FKpVurbYcsDqJxnP81O6T4z5OavlRtICqGUaiN1VxNvkGK6qFDJipg 5JNJT48sS7ouaFtXEx2U5XJAU+U8DJ3lHNXV2+iU/CHVtJljaTMTrVQFwtkqXd+uAIYf Vkzw== X-Gm-Message-State: AOAM530ZSGsObxGHHMw2n1b+qnFCt9a3TOugFna9iZqwshc/P4ZK7oHL YsS+deuudc0BLhmrpAldhPaZZxLa798= X-Google-Smtp-Source: ABdhPJykBbDI6bDgqKhhXjF8/PokwuEwEeDX536mrYnp7c8P6NjTC6yTj4Pj/j5sOKVfORmuV6kmIg== X-Received: by 2002:a5d:4241:: with SMTP id s1mr68773377wrr.269.1609506434566; Fri, 01 Jan 2021 05:07:14 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id r13sm74632892wrt.10.2021.01.01.05.07.13 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:14 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:01 +0000 Subject: [PATCH 05/12] update-index: use istate->cache over active_cache Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 Signed-off-by: Derrick Stolee --- builtin/update-index.c | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index c9a6cde97da..0616c786410 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -235,12 +235,12 @@ static int mark_ce_flags(const char *path, int flag, int mark) int namelen = strlen(path); int pos = cache_name_pos(path, namelen); if (0 <= pos) { - mark_fsmonitor_invalid(istate, active_cache[pos]); + mark_fsmonitor_invalid(istate, istate->cache[pos]); if (mark) - active_cache[pos]->ce_flags |= flag; + istate->cache[pos]->ce_flags |= flag; else - active_cache[pos]->ce_flags &= ~flag; - active_cache[pos]->ce_flags |= CE_UPDATE_IN_BASE; + istate->cache[pos]->ce_flags &= ~flag; + istate->cache[pos]->ce_flags |= CE_UPDATE_IN_BASE; cache_tree_invalidate_path(istate, path); active_cache_changed |= CE_ENTRY_CHANGED; return 0; @@ -331,7 +331,7 @@ static int process_directory(const char *path, int len, struct stat *st) /* Exact match: file or existing gitlink */ if (pos >= 0) { - const struct cache_entry *ce = active_cache[pos]; + const struct cache_entry *ce = istate->cache[pos]; if (S_ISGITLINK(ce->ce_mode)) { /* Do nothing to the index if there is no HEAD! */ @@ -347,7 +347,7 @@ static int process_directory(const char *path, int len, struct stat *st) /* Inexact match: is there perhaps a subdirectory match? */ pos = -pos-1; while (pos < active_nr) { - const struct cache_entry *ce = active_cache[pos++]; + const struct cache_entry *ce = istate->cache[pos++]; if (strncmp(ce->name, path, len)) break; @@ -378,7 +378,7 @@ static int process_path(const char *path, struct stat *st, int stat_errno) return error("'%s' is beyond a symbolic link", path); pos = cache_name_pos(path, len); - ce = pos < 0 ? NULL : active_cache[pos]; + ce = pos < 0 ? NULL : istate->cache[pos]; if (ce && ce_skip_worktree(ce)) { /* * working directory version is assumed "good" @@ -440,7 +440,7 @@ static void chmod_path(char flip, const char *path) pos = cache_name_pos(path, strlen(path)); if (pos < 0) goto fail; - ce = active_cache[pos]; + ce = istate->cache[pos]; if (chmod_cache_entry(ce, flip) < 0) goto fail; @@ -639,7 +639,7 @@ static int unresolve_one(const char *path) /* already merged */ pos = unmerge_cache_entry_at(pos); if (pos < active_nr) { - const struct cache_entry *ce = active_cache[pos]; + const struct cache_entry *ce = istate->cache[pos]; if (ce_stage(ce) && ce_namelen(ce) == namelen && !memcmp(ce->name, path, namelen)) @@ -653,7 +653,7 @@ static int unresolve_one(const char *path) */ pos = -pos-1; if (pos < active_nr) { - const struct cache_entry *ce = active_cache[pos]; + const struct cache_entry *ce = istate->cache[pos]; if (ce_namelen(ce) == namelen && !memcmp(ce->name, path, namelen)) { fprintf(stderr, @@ -749,7 +749,7 @@ static int do_reupdate(int ac, const char **av, has_head = 0; redo: for (pos = 0; pos < active_nr; pos++) { - const struct cache_entry *ce = active_cache[pos]; + const struct cache_entry *ce = istate->cache[pos]; struct cache_entry *old = NULL; int save_nr; char *path; From patchwork Fri Jan 1 13:07: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: 11994639 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 2512AC433DB for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id ED7582222F for ; Fri, 1 Jan 2021 13:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727123AbhAANIe (ORCPT ); Fri, 1 Jan 2021 08:08:34 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57450 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726829AbhAANId (ORCPT ); Fri, 1 Jan 2021 08:08:33 -0500 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 B737BC061786 for ; Fri, 1 Jan 2021 05:07:16 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id q18so22009503wrn.1 for ; Fri, 01 Jan 2021 05:07:16 -0800 (PST) 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=d/eVKI2EvujR9IBy/Q2jjjGpNfInUroCVP4n4Dr1IoQ=; b=J1/j/w6oJNiIJD0LRhbH/89xseDvQ5GTo/otN7Wqch1o/QwjtSxN21gMxWRwj0Cc8l yehzfnKiDZbtagMuO1QZEtD0EiJF8EigIKs76Whfpcu9f7tvwnAGeYyN4VzcDPveTVIU V9ZbwHil1eR2I7yJbsat/p9dg9/zlJIRBYQZMhWhNG7QpkFQGc3epph3n/8vO/e/AKJb 9SoF9zHMehje19qoi3qd+rWjFrxwbXykolzJB8dtk2l95mjkCbC4d7NLbkGYyGlwT1JV s39/QQOkfDrSHHl7E2Y1JOl3sBW0Eu7nExlZgp/ZQMdvzOBJoIsBLaVcu936yAHT9C0+ eNmw== 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=d/eVKI2EvujR9IBy/Q2jjjGpNfInUroCVP4n4Dr1IoQ=; b=p84SsidmyzpwTByM9NuSRZrceUE/moCkTeUaS5UyTzPE7+JFlCYzaAK5VbqLm/Z7Ar 7CNwjsE/Y5o3BE0ThoEe1FeuEoHwQsY8Ez8ArQwCHpJRsWisJ2VAh2Xqpd4Lfeta14v7 xvYvwSyUrwu+l6W3gCTaXhuZ31WFE3sMVq3rTaZnsGS4/37zoYmp3/eLHXe7ztl+6Le2 +QFd3QUeUAR8DXzxf8hiuQ3ifauQUygcnkzPONtyH8EFyNGX0SxmxFCh3Fgl1RlC+geL AXXAW+EN/eGh6kjQWqaZspDl32EoZhcDtM40K2VoBHwpUi08bry0NpMeNI+Xu8ZklKJo /LLw== X-Gm-Message-State: AOAM531lcito6kBKf3DZWM9epJth3ANpkM2pcy4pdTt6JdedR1Kg+QLN nfciII150vP2uLfrz2iZCjrFd6g1kIs= X-Google-Smtp-Source: ABdhPJw1sWeyC47Z6b0kvXsnIIgxx4Ebg57rEXac7MuysSqaNrR3pxMm91PGgZDjH6MCSMin7X/D+g== X-Received: by 2002:a5d:4242:: with SMTP id s2mr68265774wrr.187.1609506435342; Fri, 01 Jan 2021 05:07:15 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id i18sm75231420wrp.74.2021.01.01.05.07.14 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:14 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:02 +0000 Subject: [PATCH 06/12] update-index: use index->cache_nr over active_nr Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 Signed-off-by: Derrick Stolee --- builtin/update-index.c | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index 0616c786410..f1657a66496 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -346,7 +346,7 @@ static int process_directory(const char *path, int len, struct stat *st) /* Inexact match: is there perhaps a subdirectory match? */ pos = -pos-1; - while (pos < active_nr) { + while (pos < istate->cache_nr) { const struct cache_entry *ce = istate->cache[pos++]; if (strncmp(ce->name, path, len)) @@ -638,7 +638,7 @@ static int unresolve_one(const char *path) if (0 <= pos) { /* already merged */ pos = unmerge_cache_entry_at(pos); - if (pos < active_nr) { + if (pos < istate->cache_nr) { const struct cache_entry *ce = istate->cache[pos]; if (ce_stage(ce) && ce_namelen(ce) == namelen && @@ -652,7 +652,7 @@ static int unresolve_one(const char *path) * want to do anything in the former case. */ pos = -pos-1; - if (pos < active_nr) { + if (pos < istate->cache_nr) { const struct cache_entry *ce = istate->cache[pos]; if (ce_namelen(ce) == namelen && !memcmp(ce->name, path, namelen)) { @@ -748,7 +748,7 @@ static int do_reupdate(int ac, const char **av, */ has_head = 0; redo: - for (pos = 0; pos < active_nr; pos++) { + for (pos = 0; pos < istate->cache_nr; pos++) { const struct cache_entry *ce = istate->cache[pos]; struct cache_entry *old = NULL; int save_nr; @@ -766,14 +766,14 @@ static int do_reupdate(int ac, const char **av, } /* Be careful. The working tree may not have the * path anymore, in which case, under 'allow_remove', - * or worse yet 'allow_replace', active_nr may decrease. + * or worse yet 'allow_replace', istate->cache_nr may decrease. */ - save_nr = active_nr; + save_nr = istate->cache_nr; path = xstrdup(ce->name); update_one(path); free(path); discard_cache_entry(old); - if (save_nr != active_nr) + if (save_nr != istate->cache_nr) goto redo; } clear_pathspec(&pathspec); From patchwork Fri Jan 1 13:07: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: 11994637 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 16746C433E0 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id D844522228 for ; Fri, 1 Jan 2021 13:08:50 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727140AbhAANIf (ORCPT ); Fri, 1 Jan 2021 08:08:35 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57452 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbhAANId (ORCPT ); Fri, 1 Jan 2021 08:08:33 -0500 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 86FCFC061799 for ; Fri, 1 Jan 2021 05:07:17 -0800 (PST) Received: by mail-wr1-x42d.google.com with SMTP id c5so21956739wrp.6 for ; Fri, 01 Jan 2021 05:07:17 -0800 (PST) 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=cXyEDQ4y0XoEX/Rqp0mjkBPWFxjOFqTN90Fo14Q4W5Q=; b=KET72I8g9eUT2N6QkpVKYIxHjYSdbksgPUKn/0E/0ClIlGJsTYshMNwRUqu9cjl/pI fUBJpNgoUyKmv+/EyXV0mvfjppoKOWOhOPkdL6YahVAzLWD1WCmddX2MxbRSl6+15Emq wRsMHN426rRvuC1T+wGFmrc2qu93ML/ocZjKzEIVybzBbHyXUrxyeLrOO2PkfAUolO1k /pmfFluLY9/Q3cJY+kRhUK5C5NLpq/UaqW+7h7RfMY15ZCGELOTnWArlNVvoVsMrqboy qMP8ufEsl5d1eX/YhCuFB1R1o7tdr/Ap9D6qLqjfGFn2S4V0B3OMlGEY6lxAL6GYvgrm YM/g== 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=cXyEDQ4y0XoEX/Rqp0mjkBPWFxjOFqTN90Fo14Q4W5Q=; b=FySCCfBi37G6XurWxJR0M1neLIb+osVbHABzQMguDApw75jp5vX5fNG4enpxRrayFI a7lyTShqd6ylOdbwNkmB08PcEH036ERmSY4G3B9a4dqUsHvj2bFresJ4OG7MX1/V0wOp sOOfyQPpLKvc12eMA8RjmCFPLfkL6uzM173wU4crYJaAkXIvrjjl14AYV0M95EcNWV37 FGFfKFWL3UmHkGci/BW0NtKU8WFFzUPF55ykQ1orpdx8rDs3apxlDqjjHWiFnGwdN5EP pkOR3+1VPmdXg2lhfdwijuAsT6+PlXg4s0Y7lc2KtOg6ncI8bALhwTsYN5YQOP0nha+M /h+A== X-Gm-Message-State: AOAM532cRljHqtf2kDJZ+e4nGoOpctGTuLgRHMCUQAXog2HFufbzgUJy g81oGTIOKCAfwTXI6VK2t6+0a7s4so8= X-Google-Smtp-Source: ABdhPJwAvR4lRT0ADO3Xc7UqkXupPc/cHJ4ydDMfOPC7AKwxLlY1iTfMGU+HMnzLcpkNjkEL2YPp1A== X-Received: by 2002:a5d:4cd1:: with SMTP id c17mr68706240wrt.49.1609506436141; Fri, 01 Jan 2021 05:07:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id o83sm16541302wme.21.2021.01.01.05.07.15 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:15 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:03 +0000 Subject: [PATCH 07/12] update-index: use istate->cache_changed Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 This is a mechanical replacement of active_cache_changed. Signed-off-by: Derrick Stolee --- builtin/update-index.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index f1657a66496..a64f2f5a8f4 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -242,7 +242,7 @@ static int mark_ce_flags(const char *path, int flag, int mark) istate->cache[pos]->ce_flags &= ~flag; istate->cache[pos]->ce_flags |= CE_UPDATE_IN_BASE; cache_tree_invalidate_path(istate, path); - active_cache_changed |= CE_ENTRY_CHANGED; + istate->cache_changed |= CE_ENTRY_CHANGED; return 0; } return -1; @@ -926,7 +926,7 @@ static enum parse_opt_result unresolve_callback( *has_errors = do_unresolve(ctx->argc, ctx->argv, prefix, prefix ? strlen(prefix) : 0); if (*has_errors) - active_cache_changed = 0; + istate->cache_changed = 0; ctx->argv += ctx->argc - 1; ctx->argc = 1; @@ -947,7 +947,7 @@ static enum parse_opt_result reupdate_callback( setup_work_tree(); *has_errors = do_reupdate(ctx->argc, ctx->argv, prefix); if (*has_errors) - active_cache_changed = 0; + istate->cache_changed = 0; ctx->argv += ctx->argc - 1; ctx->argc = 1; @@ -1146,7 +1146,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) INDEX_FORMAT_LB, INDEX_FORMAT_UB); if (istate->version != preferred_index_format) - active_cache_changed |= SOMETHING_CHANGED; + istate->cache_changed |= SOMETHING_CHANGED; istate->version = preferred_index_format; } @@ -1234,7 +1234,7 @@ int cmd_update_index(int argc, const char **argv, const char *prefix) report(_("fsmonitor disabled")); } - if (active_cache_changed || force_write) { + if (istate->cache_changed || force_write) { if (newfd < 0) { if (refresh_args.flags & REFRESH_QUIET) exit(128); From patchwork Fri Jan 1 13:07: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: 11994647 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 88EF2C4332B for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 5F37E22241 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727195AbhAANIl (ORCPT ); Fri, 1 Jan 2021 08:08:41 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57454 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727100AbhAANId (ORCPT ); Fri, 1 Jan 2021 08:08:33 -0500 Received: from mail-wr1-x42b.google.com (mail-wr1-x42b.google.com [IPv6:2a00:1450:4864:20::42b]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 5BE2FC06179B for ; Fri, 1 Jan 2021 05:07:18 -0800 (PST) Received: by mail-wr1-x42b.google.com with SMTP id 91so21949766wrj.7 for ; Fri, 01 Jan 2021 05:07:18 -0800 (PST) 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=6ehXc0eDt9V2/mPFi4FPt3yADrxebTjUhthAuSsjhZ0=; b=nBtKNn+9EPQcnpmz5ApcjT7evxByRtzCHl/+/rLFFj5Z5yZTUyYHsG97QO6ueE25M/ PoQyDjykl4cMn44GBBzDXfJXlJ8oW6Gh6TSqF7iA6a4FrVYDdmvdI59JoG+lOjn2QnQT fHBRjIRxs55MUSHn/7s5Tcd1zrHcii1xAJV8iy8KKgbabCBySw0UoIDRCwZ6Vkicav8C J/DjcaBbmlxmvPSi6nPX4QX7kScKk+LYsezFFHFG1R8oMCO5b6h8Q9plel5IL+i1zNnw nDy0H5h/UZnWM23k9qllGuNdTFqQGgQXSD2/XxZBm34sj6BcTkbVTshaLnStfD64Uqy3 SG4A== 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=6ehXc0eDt9V2/mPFi4FPt3yADrxebTjUhthAuSsjhZ0=; b=Y0eQTModH0BZAAp64rvxDDZz6y5jzMpTYI0ZkJn+QFc02kCDrXnCN+XF2/nGOTWEXP ypZBRC4VZE6PQNuXePQVxRj5RYMPIwaWCRoFrYhXmbF0MOBAWgPNEfroRYsit4uMkD+V /kVoXKDUKxDGoQp9rHZTBMBmRCoVkIsLjEhfNT+3475qXo+sEQAe9nBiWrH5czAMIC3m ORdxtCvN6TstDeKTnREnn+cHRLtdvg1mZizcbS8DlqZkTa38vGS1ovV961ddzYIgk8zC 9ztu/G3oqaMvpxVIbTZeHoKN+5G5WmliOg+Tt5vZPqkRmAYarZyrwTnECDIgQePuczq8 Yh2g== X-Gm-Message-State: AOAM530QFW4RYMT8Th7S7vDBl5tOFQ76sdPDtxoVUjZwvdCNGeNzZJQU NX0IsgZTwqG9x2wfb4fW4BFx4Y9lIvw= X-Google-Smtp-Source: ABdhPJzVGZI9dnHxEqvnLWsCZXPL7w6FQFFAazX03TtLKO/l4N1VHi643e2+AkRgaBL6bGasUSxzWQ== X-Received: by 2002:adf:cd8f:: with SMTP id q15mr66691543wrj.79.1609506436935; Fri, 01 Jan 2021 05:07:16 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id h9sm17619167wme.11.2021.01.01.05.07.16 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:16 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:04 +0000 Subject: [PATCH 08/12] update-index: use index_name_pos() over cache_name_pos() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 Signed-off-by: Derrick Stolee --- builtin/update-index.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index a64f2f5a8f4..9e57779731f 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -233,7 +233,7 @@ static int test_if_untracked_cache_is_supported(void) static int mark_ce_flags(const char *path, int flag, int mark) { int namelen = strlen(path); - int pos = cache_name_pos(path, namelen); + int pos = index_name_pos(istate, path, namelen); if (0 <= pos) { mark_fsmonitor_invalid(istate, istate->cache[pos]); if (mark) @@ -327,7 +327,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len static int process_directory(const char *path, int len, struct stat *st) { struct object_id oid; - int pos = cache_name_pos(path, len); + int pos = index_name_pos(istate, path, len); /* Exact match: file or existing gitlink */ if (pos >= 0) { @@ -377,7 +377,7 @@ static int process_path(const char *path, struct stat *st, int stat_errno) if (has_symlink_leading_path(path, len)) return error("'%s' is beyond a symbolic link", path); - pos = cache_name_pos(path, len); + pos = index_name_pos(istate, path, len); ce = pos < 0 ? NULL : istate->cache[pos]; if (ce && ce_skip_worktree(ce)) { /* @@ -437,7 +437,7 @@ static void chmod_path(char flip, const char *path) int pos; struct cache_entry *ce; - pos = cache_name_pos(path, strlen(path)); + pos = index_name_pos(istate, path, strlen(path)); if (pos < 0) goto fail; ce = istate->cache[pos]; @@ -634,7 +634,7 @@ static int unresolve_one(const char *path) struct cache_entry *ce_2 = NULL, *ce_3 = NULL; /* See if there is such entry in the index. */ - pos = cache_name_pos(path, namelen); + pos = index_name_pos(istate, path, namelen); if (0 <= pos) { /* already merged */ pos = unmerge_cache_entry_at(pos); From patchwork Fri Jan 1 13:07: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: 11994645 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 347B8C433E6 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 0E66322241 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727146AbhAANIg (ORCPT ); Fri, 1 Jan 2021 08:08:36 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57458 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727135AbhAANIf (ORCPT ); Fri, 1 Jan 2021 08:08:35 -0500 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 2B396C06179C for ; Fri, 1 Jan 2021 05:07:19 -0800 (PST) Received: by mail-wm1-x32c.google.com with SMTP id c124so8961677wma.5 for ; Fri, 01 Jan 2021 05:07:19 -0800 (PST) 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=VqEsoAWSkWPZlMY4KuBUTheEtiHnE5bdR1GomA46H8A=; b=R9EbXgNW98FH6mNlkSfuSXjI0D913U1pZ2WDf6IT3kRTkwasy/8ahaF3zHh0rXHcwS Jo+oH93zdonp50FTIsTAXUS33hcWD9/YaqivjH7HGmsdJSeWgBpSEWvgQ7lAJbbP2X9w pEqdNtb5QLftJ1xjCb+COCo9OQGrf1KthsGuxl0dSh+YZagIoTVaeEMIL6Yr4VgltHJg gM/6Y6ewwSp/wZWKVP/9GsRaVqW9WrTfGzYTsH+KwK3nCGAGEIAIv2Klm3LDmKUCOzoR Hw3MKypmXtPHvyIddKSUzFpHJ9+5Bj6v1BqPg1p5BIeVD0J5rEjgHSTndh5sXg5DhcZa hnpQ== 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=VqEsoAWSkWPZlMY4KuBUTheEtiHnE5bdR1GomA46H8A=; b=M26XCVZJakV2KRe/B0hWSne7aJ3GvbTsYsc/zPMInzDJsVwLkzfPsHPd0mY+efrntS 55jzQOA9Es14dVabbs+7D1Z/13orsPKgzCLvKCmxu4TWKx/cNMwMbCNtJW2pgy4i7CRV iz8QenWcyW2n+rr4m+FSjnaeR/r+RgCsHLJ8opoEdNq2Zk+3XOyGIXYovCXDKBMHHHlO 7gA/5PnWhuuDBPpswVfVCzSyLKXRYV1qssY/zyeo3YCgx8fwPuOZdqIOddcUhqpv901G UBh+KIADOhGVBlqwJNtXILKGjLHP/onGZKaMbt3Ypn38bmYVbB7UXc2Bf6sVjK92ksKE U6IA== X-Gm-Message-State: AOAM533E7TQzA3TTMepao/eXaVcaVCAd5t6jHMn5fEJro8GypHCxST+B Qfvh1ztRMgIabZuRK0uZGrXpLaJ9p+c= X-Google-Smtp-Source: ABdhPJwKjW2OWu5aDNJBbJgCahzohkna6ujKQbIQm7ZemgV/qqmXnRvjhenkrY1LSweFVvgbhx23kw== X-Received: by 2002:a7b:c8da:: with SMTP id f26mr16279421wml.155.1609506437792; Fri, 01 Jan 2021 05:07:17 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id j13sm15955306wmi.36.2021.01.01.05.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:17 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:05 +0000 Subject: [PATCH 09/12] update-index: use remove_file_from_index() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 This is a mechanical replacement of remove_file_from_cache(). Signed-off-by: Derrick Stolee --- builtin/update-index.c | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index 9e57779731f..6f51fb4a14e 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -252,7 +252,7 @@ static int remove_one_path(const char *path) { if (!allow_remove) return error("%s: does not exist and --remove not passed", path); - if (remove_file_from_cache(path)) + if (remove_file_from_index(istate, path)) return error("%s: cannot remove from the index", path); return 0; } @@ -386,7 +386,7 @@ static int process_path(const char *path, struct stat *st, int stat_errno) * On the other hand, removing it from index should work */ if (!ignore_skip_worktree_entries && allow_remove && - remove_file_from_cache(path)) + remove_file_from_index(istate, path)) return error("%s: cannot remove from the index", path); return 0; } @@ -484,7 +484,7 @@ static void update_one(const char *path) } if (force_remove) { - if (remove_file_from_cache(path)) + if (remove_file_from_index(istate, path)) die("git update-index: unable to remove %s", path); report("remove '%s'", path); return; @@ -567,7 +567,7 @@ static void read_index_info(int nul_term_line) if (!mode) { /* mode == 0 means there is no such path -- remove */ - if (remove_file_from_cache(path_name)) + if (remove_file_from_index(istate, path_name)) die("git update-index: unable to remove %s", ptr); } @@ -682,7 +682,7 @@ static int unresolve_one(const char *path) goto free_return; } - remove_file_from_cache(path); + remove_file_from_index(istate, path); if (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) { error("%s: cannot add our version to the index.", path); ret = -1; From patchwork Fri Jan 1 13:07: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: 11994641 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 4F3FBC433E9 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 24B2A22228 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727165AbhAANIh (ORCPT ); Fri, 1 Jan 2021 08:08:37 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57460 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727138AbhAANIf (ORCPT ); Fri, 1 Jan 2021 08:08:35 -0500 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 D4E4AC06179E for ; Fri, 1 Jan 2021 05:07:19 -0800 (PST) Received: by mail-wr1-x42f.google.com with SMTP id r3so21992068wrt.2 for ; Fri, 01 Jan 2021 05:07:19 -0800 (PST) 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=qdUNlxbyQkWFS6y/ClELc3uYoAtpYK6+Zct2IZSbBYU=; b=np2NAt/GanbOj9JBYJm8FvmxkHh+I8OstUdik96GOERaC6V9vEQqAAcsO/1uuIrFZ2 6xYXBlR27UFGJc0e4maK1+IGeiW2WlgrBHvN/hLjfh8kglvCv/un7kWTv2REKR6+CgND IaBjPm6iMUr6qFgebqo8Ecn5cD7QlHKLMWWm2hNxS5/c4AFfgAB5dFH8/BoIzhXzDbJX dPWHc3xOFaPUvAEJbe71tDLf+Xm9vlRWxP2BjeZhA/yQcnq5+cSIV2wQpN+ib6+bojYe eHfBXdvuFzyLgUxJsjW7umjmT/psgGp+cTscTT9Rv4Qk6WS7CYViQFKUxFKDUgkCWNZI GbWQ== 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=qdUNlxbyQkWFS6y/ClELc3uYoAtpYK6+Zct2IZSbBYU=; b=G0YfsPiyGjDk41yRiKhKybEPk70Rtn3E1xEe9c6R+2xmJ/x5tmssfUd1f1oTDLmucd 7i1QlEonbcve534XNGbLr7s+pfcPyUBNyBaoGPQeoXLMqDQzHKPmu31u4Miypho1x1nJ eONelAIEITrFs5ZgCfwXdVN+wepEm9suSCQ4k4U9TxpibaDxhJdb5HZ4h11cEN0Itxl0 xGkZwAl6hFRcuHlljSbJXE9NJ1AO9KT9gBx3T6lSct/U8SQ8JSzBl7NL1jQT9tsNKBee nqyMU4uxJh96x3gRYfiNBqjoNywdBqcLaqCveulEOYczZOioVI+jkb/vmQtT32yfNXfI /09A== X-Gm-Message-State: AOAM533PvN1An+pJUJlk2NKQcnlLwNpYOUoj5bXkYi+iOrk1I7XhokCz pVTZGx3zlHnRug5M+2qSTiXw2eSVXrQ= X-Google-Smtp-Source: ABdhPJwF7Ds1mcVD/P9wdTCNUsrJGl6lInn63GBEOC9qhMXGQAMHSsDqiIwtC+pBJU1nj7fIhKZ1dQ== X-Received: by 2002:a5d:6a4f:: with SMTP id t15mr70814123wrw.62.1609506438520; Fri, 01 Jan 2021 05:07:18 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id c6sm52119432wrh.7.2021.01.01.05.07.17 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:18 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:06 +0000 Subject: [PATCH 10/12] update-index: use add_index_entry() Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 This is a mechanical replacement of add_cache_entry(). Signed-off-by: Derrick Stolee --- builtin/update-index.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index 6f51fb4a14e..577ae2391b7 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -294,7 +294,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len } option = allow_add ? ADD_CACHE_OK_TO_ADD : 0; option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0; - if (add_cache_entry(ce, option)) { + if (add_index_entry(istate, ce, option)) { discard_cache_entry(ce); return error("%s: cannot add to the index - missing --add option?", path); } @@ -425,7 +425,7 @@ static int add_cacheinfo(unsigned int mode, const struct object_id *oid, ce->ce_flags |= CE_VALID; option = allow_add ? ADD_CACHE_OK_TO_ADD : 0; option |= allow_replace ? ADD_CACHE_OK_TO_REPLACE : 0; - if (add_cache_entry(ce, option)) + if (add_index_entry(istate, ce, option)) return error("%s: cannot add to the index - missing --add option?", path); report("add '%s'", path); @@ -683,12 +683,12 @@ static int unresolve_one(const char *path) } remove_file_from_index(istate, path); - if (add_cache_entry(ce_2, ADD_CACHE_OK_TO_ADD)) { + if (add_index_entry(istate, ce_2, ADD_CACHE_OK_TO_ADD)) { error("%s: cannot add our version to the index.", path); ret = -1; goto free_return; } - if (!add_cache_entry(ce_3, ADD_CACHE_OK_TO_ADD)) + if (!add_index_entry(istate, ce_3, ADD_CACHE_OK_TO_ADD)) return 0; error("%s: cannot add their version to the index.", path); ret = -1; From patchwork Fri Jan 1 13:07: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: 11994643 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 5E7B5C43381 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 3E76B2222D for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727179AbhAANIk (ORCPT ); Fri, 1 Jan 2021 08:08:40 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726897AbhAANIf (ORCPT ); Fri, 1 Jan 2021 08:08:35 -0500 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 98659C06179F for ; Fri, 1 Jan 2021 05:07:20 -0800 (PST) Received: by mail-wm1-x32a.google.com with SMTP id 3so8999720wmg.4 for ; Fri, 01 Jan 2021 05:07:20 -0800 (PST) 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=ZYUrHXcPlVY5K+6jnNEXRdluLuJzzsuNnPoeZiIYESA=; b=YuBb7JZciWCHFFWJRq0L+fZj2dx82DNC4UuZcPDc42169XRh6gVIB9rs2hwNbKY5WQ Bd76xPTa9hSunpvp7hcRYUQIv7hbYjCHbCe3LJBgxCxjhCUn7BXCwRu2LkjlZ5R5+YK4 VGNOp4yxiX7vkKGeazM8AOZvHS0JmUbePE7km/rlr3Tl0BNyPEnzcP0qqka4xldOgqSE OOHxV3ES+OLdpjT3NYzIlD1Y4o6fz/zdGejVAMFrsHYi+gKpeSNopZ1dWf4gUS4nF2o+ spfnVVML0sgPi8ncz32OVjTMrolSAtZRj+T6XtYZQKDVHOu6lBfzTsChm5/OA/Ld2SrR UImw== 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=ZYUrHXcPlVY5K+6jnNEXRdluLuJzzsuNnPoeZiIYESA=; b=tnMNPCqP0CxU+6cUBIS1vgunsD+MzTcNVU80jk3NxqSJwTEUSp2FoiO+me515kC3xJ SX9hPrV1rbzSxtU47FVO/HN+gUNlwIwaoUvB+eaXDX8A8Pd+YgbbE3B/ytEz6MIuOHwW 3gFc2gTX98qzAELKgXxpljGxDI7jvyau1Xg2G2vgWKf5bB1ZSlABED6EFnI8VAeLNctt GZzXbBKFLvHLpvm5FgHoJFsxz4/iKv1zPdLiupP8BUMyPF28NXNHH+ChhcMik2jk9Gfk KpOnfv47FrA048McSqhZp9EVyvoiLeehfM9ZAMIwskNsGv2GEY636ItKsfJmhNFKKLFD Yc7g== X-Gm-Message-State: AOAM532z4hE8rRbeGDxPrlfyOqsc0yinf0TSSbC5RFwxR3LTmG1Vf1vK U75RCCzPYoe8qyr6mSRWpUJ6esY+G1k= X-Google-Smtp-Source: ABdhPJwZ5rvqMObFrvAWa1V7URF71jTVn6QF1ZqTvYeZKSbZFHzRGyRs6kTckndpW6/vtWk8XEqYnw== X-Received: by 2002:a7b:c208:: with SMTP id x8mr15720427wmi.179.1609506439273; Fri, 01 Jan 2021 05:07:19 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id g192sm17162062wme.48.2021.01.01.05.07.18 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:18 -0800 (PST) Message-Id: In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:07 +0000 Subject: [PATCH 11/12] update-index: replace several compatibility macros Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 This is also the last usage of unmerge_cache_entry_at(), so it can be removed from cache.h. Signed-off-by: Derrick Stolee --- builtin/update-index.c | 11 ++++++----- cache.h | 1 - 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/builtin/update-index.c b/builtin/update-index.c index 577ae2391b7..4da0c169dc7 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -441,7 +441,7 @@ static void chmod_path(char flip, const char *path) if (pos < 0) goto fail; ce = istate->cache[pos]; - if (chmod_cache_entry(ce, flip) < 0) + if (chmod_index_entry(istate, ce, flip) < 0) goto fail; report("chmod %cx '%s'", flip, path); @@ -637,7 +637,7 @@ static int unresolve_one(const char *path) pos = index_name_pos(istate, path, namelen); if (0 <= pos) { /* already merged */ - pos = unmerge_cache_entry_at(pos); + pos = unmerge_index_entry_at(istate, pos); if (pos < istate->cache_nr) { const struct cache_entry *ce = istate->cache[pos]; if (ce_stage(ce) && @@ -788,8 +788,9 @@ struct refresh_params { static int refresh(struct refresh_params *o, unsigned int flag) { setup_work_tree(); - read_cache(); - *o->has_errors |= refresh_cache(o->flags | flag); + repo_read_index(repo); + *o->has_errors |= refresh_index(istate, o->flags | flag, + NULL, NULL, NULL); return 0; } @@ -825,7 +826,7 @@ static int resolve_undo_clear_callback(const struct option *opt, { BUG_ON_OPT_NEG(unset); BUG_ON_OPT_ARG(arg); - resolve_undo_clear(); + resolve_undo_clear_index(istate); return 0; } diff --git a/cache.h b/cache.h index 7bfb8195d97..dfcbc4923e2 100644 --- a/cache.h +++ b/cache.h @@ -421,7 +421,6 @@ extern struct index_state the_index; #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen)) #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen)) #define resolve_undo_clear() resolve_undo_clear_index(&the_index) -#define unmerge_cache_entry_at(at) unmerge_index_entry_at(&the_index, at) #define unmerge_cache(pathspec) unmerge_index(&the_index, pathspec) #define read_blob_data_from_cache(path, sz) read_blob_data_from_index(&the_index, (path), (sz)) #define hold_locked_index(lock_file, flags) repo_hold_locked_index(the_repository, (lock_file), (flags)) From patchwork Fri Jan 1 13:07: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: 11994651 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 BB353C43331 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 970D322210 for ; Fri, 1 Jan 2021 13:08:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1727171AbhAANIj (ORCPT ); Fri, 1 Jan 2021 08:08:39 -0500 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:57468 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727142AbhAANIf (ORCPT ); Fri, 1 Jan 2021 08:08:35 -0500 Received: from mail-wr1-x432.google.com (mail-wr1-x432.google.com [IPv6:2a00:1450:4864:20::432]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 626E8C0617A0 for ; Fri, 1 Jan 2021 05:07:21 -0800 (PST) Received: by mail-wr1-x432.google.com with SMTP id q18so22009624wrn.1 for ; Fri, 01 Jan 2021 05:07:21 -0800 (PST) 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=tfFlqYDYIPEygmGKvGhRH28V9rbc3TaFh6cEhIiC+bY=; b=AKvSkq2VKHjbunWG9y2sS2V2U8rtHHXm6UR8TUNSqTOFwHW8Ml5OeUuw5nxaqEfRs6 Bw8jmvB+OicqC90jMN5ZUfOptcCqJ8IcyxaqsUu3Q40i61XJcKvOSoItOqQrU7fX8nSP 0cjDcXhRIpzg+wxdhUW5bCPhlM1lOQgf+lV4XeAVJBE4MrZBBv75TKqwueo9sRYuN7uc upnkHo6k/paIVC9myP4ilEStx5LBg0fysO8vU0Lu3rLAKLQb2snlaJBg3jjEDkCdHGMq ADJom0u3MlIyVDTT6WrjKrgTjX38A5wI6MlBK63Y4hnDqJsAzebyswOwreFCbGUfrcXx SKMQ== 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=tfFlqYDYIPEygmGKvGhRH28V9rbc3TaFh6cEhIiC+bY=; b=Vc1Un1nAXbWD6bavFWSg+8TBa+W4T9K1bGHgN5h4O1tyNyN65TfDaVzf+eY5gdJ2mK KAT3EUhmSk1rRfMtLletIZJ/trWEZwEmiFL9UBkajsrVLlqb8+TZSG2Z0J9IOyXm6HzD PbzUgGceKuqvJDJ9zZpdSYkN5wf9WygFoRb/TAa4V4/e9bqy0HVsn3gs6UObS4ivjHj0 X/Ox3rwk9g9SZ+UNU1EuMLwnP+2EKBwuAQ9DCltX2hsMARRPPTlsKG/m483+6+DADOdk Bl6QDQsMf1UlatcA6AKeuHwtacwAZXQaCchM0YJtuLEKmntE5eIpdL0p1gHMqfqUxM7+ XIqQ== X-Gm-Message-State: AOAM530Dgin+PgEuBXSBXQjlcrKYOP2Ux8T/34ScJEOD5/0nfmKLVvly mLFWDxTZKy3MHI9FN9MqDMWNSdLBpr8= X-Google-Smtp-Source: ABdhPJzgozJHhLxe8XPjiLKSXxoUryYF8YMu0wcgQSjn+C8x3yevdnBnGnEGkCvhq2iGrcLKarYi8A== X-Received: by 2002:adf:fdce:: with SMTP id i14mr69173310wrs.58.1609506440007; Fri, 01 Jan 2021 05:07:20 -0800 (PST) Received: from [127.0.0.1] ([13.74.141.28]) by smtp.gmail.com with ESMTPSA id 125sm16717775wmc.27.2021.01.01.05.07.19 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Fri, 01 Jan 2021 05:07:19 -0800 (PST) Message-Id: <8fb307c3bee9a33ad408bba6c422e992fb1e2656.1609506428.git.gitgitgadget@gmail.com> In-Reply-To: References: Date: Fri, 01 Jan 2021 13:07:08 +0000 Subject: [PATCH 12/12] update-index: remove ce_match_stat(), all macros Fcc: Sent MIME-Version: 1.0 To: git@vger.kernel.org Cc: pclouds@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 The final index compatibility macro to remove from the update-index builtin is ce_match_state(). Further, this is the last use of that macro anywhere, so it should be removed. There are some remaining references in the racy-git.txt technical document that are updated to ie_match_stat(). Signed-off-by: Derrick Stolee --- Documentation/technical/racy-git.txt | 6 +++--- builtin/update-index.c | 3 +-- cache.h | 1 - 3 files changed, 4 insertions(+), 6 deletions(-) diff --git a/Documentation/technical/racy-git.txt b/Documentation/technical/racy-git.txt index ceda4bbfda4..65188e04559 100644 --- a/Documentation/technical/racy-git.txt +++ b/Documentation/technical/racy-git.txt @@ -26,7 +26,7 @@ information obtained from the filesystem via `lstat(2)` system call when they were last updated. When checking if they differ, Git first runs `lstat(2)` on the files and compares the result with this information (this is what was originally done by the -`ce_match_stat()` function, but the current code does it in +`ie_match_stat()` function, but the current code does it in `ce_match_stat_basic()` function). If some of these "cached stat information" fields do not match, Git can tell that the files are modified without even looking at their contents. @@ -102,7 +102,7 @@ timestamp as the index file itself. The callers that want to check if an index entry matches the corresponding file in the working tree continue to call -`ce_match_stat()`, but with this change, `ce_match_stat()` uses +`ie_match_stat()`, but with this change, `ie_match_stat()` uses `ce_modified_check_fs()` to see if racily clean ones are actually clean after comparing the cached stat information using `ce_match_stat_basic()`. @@ -128,7 +128,7 @@ Runtime penalty --------------- The runtime penalty of falling back to `ce_modified_check_fs()` -from `ce_match_stat()` can be very expensive when there are many +from `ie_match_stat()` can be very expensive when there are many racily clean entries. An obvious way to artificially create this situation is to give the same timestamp to all the files in the working tree in a large project, run `git update-index` on diff --git a/builtin/update-index.c b/builtin/update-index.c index 4da0c169dc7..256df43ecbd 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -3,7 +3,6 @@ * * Copyright (C) Linus Torvalds, 2005 */ -#define USE_THE_INDEX_COMPATIBILITY_MACROS #include "cache.h" #include "config.h" #include "lockfile.h" @@ -277,7 +276,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len struct cache_entry *ce; /* Was the old index entry already up-to-date? */ - if (old && !ce_stage(old) && !ce_match_stat(old, st, 0)) + if (old && !ce_stage(old) && !ie_match_stat(istate, old, st, 0)) return 0; ce = make_empty_cache_entry(istate, len); diff --git a/cache.h b/cache.h index dfcbc4923e2..2925bf050b8 100644 --- a/cache.h +++ b/cache.h @@ -416,7 +416,6 @@ extern struct index_state the_index; #define chmod_cache_entry(ce, flip) chmod_index_entry(&the_index, (ce), (flip)) #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL, NULL) #define refresh_and_write_cache(refresh_flags, write_flags, gentle) repo_refresh_and_write_index(the_repository, (refresh_flags), (write_flags), (gentle), NULL, NULL, NULL) -#define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options)) #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options)) #define cache_dir_exists(name, namelen) index_dir_exists(&the_index, (name), (namelen)) #define cache_name_is_other(name, namelen) index_name_is_other(&the_index, (name), (namelen))