From patchwork Thu Apr 30 19:48:43 2020 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 11521389 Return-Path: Received: from mail.kernel.org (pdx-korg-mail-1.web.codeaurora.org [172.30.200.123]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 3A91415AB for ; Thu, 30 Apr 2020 19:48:49 +0000 (UTC) Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by mail.kernel.org (Postfix) with ESMTP id 193FA20731 for ; Thu, 30 Apr 2020 19:48:49 +0000 (UTC) Authentication-Results: mail.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20150623.gappssmtp.com header.i=@ttaylorr-com.20150623.gappssmtp.com header.b="HN+xFQvy" Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbgD3Tss (ORCPT ); Thu, 30 Apr 2020 15:48:48 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:54802 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726318AbgD3Tsr (ORCPT ); Thu, 30 Apr 2020 15:48:47 -0400 Received: from mail-pf1-x441.google.com (mail-pf1-x441.google.com [IPv6:2607:f8b0:4864:20::441]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 8C449C035494 for ; Thu, 30 Apr 2020 12:48:46 -0700 (PDT) Received: by mail-pf1-x441.google.com with SMTP id x15so391788pfa.1 for ; Thu, 30 Apr 2020 12:48:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20150623.gappssmtp.com; s=20150623; h=date:from:to:cc:subject:message-id:mime-version:content-disposition; bh=zHABMtSO+HkuOGmD9w0Q4DVklBXduWsS/Age8ky7Hio=; b=HN+xFQvyiOCKKRFEoOn6pM093Rp1Ca9RuFb21v5d1Q7+5eyKXrP1BvjP3MT55NxZMd LizZC2g4pyIf4XTAsKd/9E+zaeet1HKqON4lmIycObaeg/thZC1bGsrRkrvsRUNo7V3l T2jTp6N7nJN1aMUMdpibQwurWe/WJVDpRV584JMV7MPx9oVloig+dY7QUHBUEjf47EJU KJplQb5NpZIl4hc8rihuAqq1KgPOiAEyEFJyx/Xv7hXclDwcQxyZoHlesEny5hDYuP21 r6QEojA+PbqH4aRZsbWQfRTDl8jiaMy8gpHQ5/IA+q8QdENJtSCpccwEejZqcvI9ahqo QY3Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:date:from:to:cc:subject:message-id:mime-version :content-disposition; bh=zHABMtSO+HkuOGmD9w0Q4DVklBXduWsS/Age8ky7Hio=; b=mhJAEVl/0Clg8gbANEgoNYXafs7oMw0De63oVTxQvlIWi23axkSJD0ahx/WPDYLEGS 6xi0h2bpL7ilFnN4YRzOf3xh9taXICik+xGDb4KzzqDV8RjGQi/LcFSskDxt/1OtOxrm Z7+VNxHxGxlzXr/u36pEEp2/q6xJ90Wzzu1C1Z3ijzVzl6zK2J9WyaBPULOPjR4IsL/G 593ORFq3ACNy5lYBNDhDkea61zwdK/hugQGjUlkCfvD9CJcIO0tsjSVyPdCdveuI8OqZ 9PREF3KBq9deOlNREz5pxQ/Stc3ZZcUgK2ZxEif0tFjYkGeLMNKs72BOwtmqgwenM1Pr uJ5A== X-Gm-Message-State: AGi0PuZRylezTDUDBIYM0He4DOz2RNBYTmDesHxC+7AirMKWUWAq9LeJ nlCurjZ5s+7Dn1tSMZsOh2P4hGS41q8r4Q== X-Google-Smtp-Source: APiQypInD/u9fFGRCbGGUiYazwVHVSG8OgR7RGVuRwOtqAstDRjqKmGWPYgozknom4VxzJOS/O9W5A== X-Received: by 2002:a63:9d8c:: with SMTP id i134mr575092pgd.152.1588276125433; Thu, 30 Apr 2020 12:48:45 -0700 (PDT) Received: from localhost ([8.44.146.30]) by smtp.gmail.com with ESMTPSA id e196sm503654pfh.43.2020.04.30.12.48.43 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Thu, 30 Apr 2020 12:48:44 -0700 (PDT) Date: Thu, 30 Apr 2020 13:48:43 -0600 From: Taylor Blau To: git@vger.kernel.org Cc: gitster@pobox.com, jonathantanmy@google.com, jrnieder@gmail.com, sunshine@sunshineco.com Subject: [PATCH v2 0/4] shallow: extract a header file Message-ID: MIME-Version: 1.0 Content-Disposition: inline Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org Hi, Here's a reroll of my series to introduce 'shallow.h' after some very helpful review from yesterday evening and early this morning. Not a ton has changed since last time, but here are the main points. A range-diff since v1 is included below for a more detailed look at the changes. * The #include in 'builtin.h' was dropped and instead the burden of including 'shallow.h' falls on the callers. Six builtins needed to be updated to include 'shallow.h', so this seems a net positive for the others that don't need to include it. * Comments were updated in the final two patches for increased readability and helpfulness. * The third patch was folded into the second patch to make the refactoring occur in a single step. * A comment was added to 'commit_graft_pos' to indicate what position is being returned. Like last time, this is based on my earlier series 'tb/reset-shallow', which should be on master shortly (perhaps in the next push-out? Not sure.). Thanks in advance for a re-review :). Taylor Blau (4): commit: make 'commit_graft_pos' non-static shallow: extract a header file for shallow-related functions shallow.h: document '{commit,rollback}_shallow_file' shallow: use struct 'shallow_lock' for additional safety builtin/fetch.c | 1 + builtin/pack-objects.c | 1 + builtin/prune.c | 1 + builtin/receive-pack.c | 3 +- builtin/repack.c | 1 + builtin/rev-parse.c | 1 + commit-graph.c | 1 + commit.c | 16 ++------- commit.h | 49 +------------------------ environment.c | 1 + fetch-pack.c | 3 +- git.c | 1 + send-pack.c | 1 + shallow.c | 36 +++++++++++++------ shallow.h | 81 ++++++++++++++++++++++++++++++++++++++++++ upload-pack.c | 1 + 16 files changed, 123 insertions(+), 75 deletions(-) create mode 100644 shallow.h Range-diff against v1: 1: 8ac4c63735 = 1: cb8dde2ae2 commit: make 'commit_graft_pos' non-static 2: 8ee7ed0666 < -: ---------- shallow: take 'unregister_shallow' from 'commit.c' 3: 3fb71045b6 ! 2: 0631e2a87d shallow: extract a header file for shallow-related functions @@ Commit message But, now there are a good number of shallow-related functions, and placing them all in 'commit.h' doesn't make sense. - This patch extracts a 'shallow.h', which takes all of the headers from - 'commit.h' for functions which already exist in 'shallow.c'. We will - bring the remaining shallow-related functions defined in 'commit.c' in a - subsequent patch. + This patch extracts a 'shallow.h', which takes all of the declarations + from 'commit.h' for functions which already exist in 'shallow.c'. We + will bring the remaining shallow-related functions defined in 'commit.c' + in a subsequent patch. For now, move only the ones that already are implemented in 'shallow.c', and update the necessary includes. Signed-off-by: Taylor Blau - ## builtin.h ## + ## builtin/fetch.c ## @@ - #include "strbuf.h" - #include "cache.h" - #include "commit.h" + #include "branch.h" + #include "promisor-remote.h" + #include "commit-graph.h" +#include "shallow.h" - /* - * builtin API + #define FORCED_UPDATES_DELAY_WARNING_IN_MS (10 * 1000) + + + ## builtin/pack-objects.c ## +@@ + #include "dir.h" + #include "midx.h" + #include "trace2.h" ++#include "shallow.h" + + #define IN_PACK(obj) oe_in_pack(&to_pack, obj) + #define SIZE(obj) oe_size(&to_pack, obj) + + ## builtin/prune.c ## +@@ + #include "parse-options.h" + #include "progress.h" + #include "object-store.h" ++#include "shallow.h" + + static const char * const prune_usage[] = { + N_("git prune [-n] [-v] [--progress] [--expire