From patchwork Tue Nov 7 18:22:55 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13449183 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id CAC34358B3 for ; Tue, 7 Nov 2023 18:22:58 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="ghr7xAQa" Received: from mail-qt1-x82a.google.com (mail-qt1-x82a.google.com [IPv6:2607:f8b0:4864:20::82a]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 4D9DC120 for ; Tue, 7 Nov 2023 10:22:58 -0800 (PST) Received: by mail-qt1-x82a.google.com with SMTP id d75a77b69052e-41feb963f60so22308961cf.1 for ; Tue, 07 Nov 2023 10:22:58 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1699381377; x=1699986177; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=SOtY+mWAf67a4+JINx10ktWSKIT7UYqgd3eoaYX1ORI=; b=ghr7xAQaZBfHYNLJez9oBj6Nx6pNKtd7TN5SZKbPdnCCPoKexFdDP1nW8jAk6e6x8q xzq4eSpd7sHVSqDnWUweBcvEp/uEu8mIJELn7OtewCnUVfiuWt2Ss7GQNr0O0tFX1UZM DFIJF4WmRwKFzw1ibN7OoUDe5YjFF2DZyMgGsalvwP3f0OtX3jBzP0iR886QNFgMtFhw l5ZjNcHKz1QG/jwZ/bXwd1/jmLucz3V38n+IWkwnYpBXDDYW7yFX0cSfIUsxzIlGbWlW FEyAyJKtfwcm1o29AgQa4E8ZIT7Y4OEy9XRlooAq518eB49T7BJElcow8yeEKqzf8e9K s5SA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699381377; x=1699986177; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=SOtY+mWAf67a4+JINx10ktWSKIT7UYqgd3eoaYX1ORI=; b=MEJQlX+Fgv6IFe3YW9ESYUCtNb8+NQFjtiYl7O+7NVPqhCTGadABn//FQcm7O1QMmE /wHp6ma8H2JO26rR89PkA8QZffmisebUl7tnjyy1LYF2FiCxS3x1gMBoHXYSXqlk7KMz HztrQCJByon7MjwksRDM5RXqpNDooSPuQ6qtaUTPSV6Sr86NFNE9oCkRNw99rzVyTXFI UrjZxzP/JEG/gmmncOZBU3SGeYPsIhdjnTa77xbzPwClXy1EjV7tcGXEVSxDjVfhFox9 uCUpRfnclkGTc1nxT+umAuvCtd2cpuTSzu9mNA9s9MZdz51s6HuMGuh3ia8tTUCRku3Q vaig== X-Gm-Message-State: AOJu0Yz6EQdPaspho9jlGK+7vOlQIZa4ShbrCLVrndhy69nAOGKb8xWm r7ZitDkMbZUvp3WQ7Lh4srqy/4aZs8LUbU8iXAsSPQ== X-Google-Smtp-Source: AGHT+IH//mQEZJY+A7Z2TJpZ5pXpPDGAUVTJJBr6XXDxJ7EJ15lba846LKt3JzIvDH7QL8FqrMolZg== X-Received: by 2002:a05:622a:24b:b0:41c:c045:2c86 with SMTP id c11-20020a05622a024b00b0041cc0452c86mr5271947qtx.31.1699381377135; Tue, 07 Nov 2023 10:22:57 -0800 (PST) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id i24-20020ac871d8000000b0041eef6cacf4sm139380qtp.81.2023.11.07.10.22.56 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 10:22:56 -0800 (PST) Date: Tue, 7 Nov 2023 13:22:55 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Patrick Steinhardt , Elijah Newren , Junio C Hamano , Johannes Schindelin Subject: [RFC PATCH 1/3] merge-ort.c: finalize ODB transactions after each step Message-ID: References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: In a previous commit, the ORT merge backend learned how to use the bulk-checkin mechanism to emit a single pack containing any new objects created during the merge. This functionality was implemented by setting up a new ODB transaction, and finalizing it at the end of the merge via `process_entries()`. In a future commit, we will extend this functionality to the new `git replay` command, which needs to see objects from previous steps in order to replay each commit. As a step towards implementing this, teach the ORT backend to flush the ODB transaction at the end of each step in `process_entries()`, and then finalize the result with `end_odb_transaction()` when calling `merge_finalize()`. For normal `merge-tree --write-pack` invocations, this produces no functional change: the pack is written out at the end of `process_entries()`, and then the `end_odb_transaction()` call is a noop. Signed-off-by: Taylor Blau --- merge-ort.c | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/merge-ort.c b/merge-ort.c index 523577d71e..7b352451cc 100644 --- a/merge-ort.c +++ b/merge-ort.c @@ -4354,7 +4354,7 @@ static int process_entries(struct merge_options *opt, ret = -1; if (opt->write_pack) - end_odb_transaction(); + flush_odb_transaction(); cleanup: string_list_clear(&plist, 0); @@ -4726,6 +4726,9 @@ void merge_switch_to_result(struct merge_options *opt, void merge_finalize(struct merge_options *opt, struct merge_result *result) { + if (opt->write_pack) + end_odb_transaction(); + if (opt->renormalize) git_attr_set_direction(GIT_ATTR_CHECKIN); assert(opt->priv == NULL); From patchwork Tue Nov 7 18:22:58 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13449184 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 81AF436AE3 for ; Tue, 7 Nov 2023 18:23:02 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="uqIFg28b" Received: from mail-qk1-x72c.google.com (mail-qk1-x72c.google.com [IPv6:2607:f8b0:4864:20::72c]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 9F643B0 for ; Tue, 7 Nov 2023 10:23:01 -0800 (PST) Received: by mail-qk1-x72c.google.com with SMTP id af79cd13be357-7788ebea620so382931185a.3 for ; Tue, 07 Nov 2023 10:23:01 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1699381380; x=1699986180; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=uAIHW7rhds10ZgTT7ADJK5wsRDifl8IBm77/et8Wzgc=; b=uqIFg28bAUH6RWP5kIE/mY8RegPqFCIeOkjfjkHth0FiBeO/PlV5jqDCkdGm1yRdZT 945xRlPra2ZDbrAasGB5//CjouHiPw4PqhufwlwWknvzVzNy/TJkFJ8B7ZfITdHTt7BD U2uC5pBUYRjNUArLM/qp81LeWER3koG9B5UQ8aOstm8xxMyNjUQ1UAZlLh6HQBsw8FlW mwQa5xCsjuAikuLGpvOysBdUOUE9VwVwoPtDJ7Fm5r0CBTUcGJvPajxrrOos1IYvFLyC 9fFHH+RC+AhL7t2AfNXTfurazRfiZ6ZRU/ZOACnlbxCpJ2QKwtCBtHbs6OIduxPY3c26 kGAA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699381380; x=1699986180; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=uAIHW7rhds10ZgTT7ADJK5wsRDifl8IBm77/et8Wzgc=; b=uGQMIjxFFlfoXnbKb4pVtNgMWmFHnkX5Crmw8SJiY2peA6RVLDmcxkEeDRjhLWkypx i4TpKkp+ECqcruJHu19Q/mVDXwDEgk7EgQwi5sF+mx9MApWIq20/NZbHPa+kB37H+dkx MKlr4q22ze8/Zba8aC0af2zNwGckJ7JBjr1WTbwpthoIbF8Tk0SbCkY74IKzRnllyOEg rc1FC0shjcWw4FaHWXtay84HcPpCxv0uMes5Nb6kcyCdQNEvtNQ1xN1mH4TA0kbSf+Ts MKvfyhTKLcPN8IK4exVk9HnQUt7j1Thk5zuthVXpKbSdpItFUhIkgCwPtSNPA/dJHpp8 VTvw== X-Gm-Message-State: AOJu0Yz1uIJHzvG3B9/MdVhasXTtntgBRQgPB7s8pVcOQmBdze/YfNxG TtlqLxT2Rvfonq2S4lilleSNvxX023kQUTZBwlqqlQ== X-Google-Smtp-Source: AGHT+IHrC+kj5waeXedKFUnaMXy7H2XxlUAdV6yLaiMs+41pRVPaQWHP/BKHhoPGTr5WW+z4NNxDyg== X-Received: by 2002:ad4:5ca2:0:b0:66d:3723:294b with SMTP id q2-20020ad45ca2000000b0066d3723294bmr35165507qvh.64.1699381380429; Tue, 07 Nov 2023 10:23:00 -0800 (PST) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id mn22-20020a0562145ed600b006655cc8f872sm141393qvb.99.2023.11.07.10.22.59 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 10:23:00 -0800 (PST) Date: Tue, 7 Nov 2023 13:22:58 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Patrick Steinhardt , Elijah Newren , Junio C Hamano , Johannes Schindelin Subject: [RFC PATCH 2/3] tmp-objdir: introduce `tmp_objdir_repack()` Message-ID: <0f19c139ba9bb5105747f545038825d0c89f2e42.1699381371.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: In the following commit, we will teach `git replay` how to write a pack containing the set of new objects created as a result of the `replay` operation. Since `replay` needs to be able to see the object(s) written from previous steps in order to replay each commit, the ODB transaction may have multiple pending packs. Migrating multiple packs back into the main object store has a couple of downsides: - It is error-prone to do so: each pack must be migrated in the correct order (with the ".idx" file staged last), and the set of packs themselves must be moved over in the correct order to avoid racy behavior. - It is a (potentially significant) performance degradation to migrate a large number of packs back into the main object store. Introduce a new function that combines the set of all packs in the temporary object store to produce a single pack which is the logical concatenation of all packs created during that level of the ODB transaction. Signed-off-by: Taylor Blau --- tmp-objdir.c | 13 +++++++++++++ tmp-objdir.h | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/tmp-objdir.c b/tmp-objdir.c index 5f9074ad1c..ef53180b47 100644 --- a/tmp-objdir.c +++ b/tmp-objdir.c @@ -12,6 +12,7 @@ #include "strvec.h" #include "quote.h" #include "object-store-ll.h" +#include "run-command.h" struct tmp_objdir { struct strbuf path; @@ -277,6 +278,18 @@ int tmp_objdir_migrate(struct tmp_objdir *t) return ret; } +int tmp_objdir_repack(struct tmp_objdir *t) +{ + struct child_process cmd = CHILD_PROCESS_INIT; + + cmd.git_cmd = 1; + + strvec_pushl(&cmd.args, "repack", "-a", "-d", "-k", "-l", NULL); + strvec_pushv(&cmd.env, tmp_objdir_env(t)); + + return run_command(&cmd); +} + const char **tmp_objdir_env(const struct tmp_objdir *t) { if (!t) diff --git a/tmp-objdir.h b/tmp-objdir.h index 237d96b660..d00e3b3e27 100644 --- a/tmp-objdir.h +++ b/tmp-objdir.h @@ -36,6 +36,12 @@ struct tmp_objdir *tmp_objdir_create(const char *prefix); */ const char **tmp_objdir_env(const struct tmp_objdir *); +/* + * Combines all packs in the tmp_objdir into a single pack before migrating. + * Removes original pack(s) after installing the combined pack into place. + */ +int tmp_objdir_repack(struct tmp_objdir *); + /* * Finalize a temporary object directory by migrating its objects into the main * object database, removing the temporary directory, and freeing any From patchwork Tue Nov 7 18:23:02 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Taylor Blau X-Patchwork-Id: 13449185 Received: from lindbergh.monkeyblade.net (lindbergh.monkeyblade.net [23.128.96.19]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 4748B36AEB for ; Tue, 7 Nov 2023 18:23:05 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=ttaylorr-com.20230601.gappssmtp.com header.i=@ttaylorr-com.20230601.gappssmtp.com header.b="WRkqp4Bv" Received: from mail-qv1-xf33.google.com (mail-qv1-xf33.google.com [IPv6:2607:f8b0:4864:20::f33]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id A431213A for ; Tue, 7 Nov 2023 10:23:04 -0800 (PST) Received: by mail-qv1-xf33.google.com with SMTP id 6a1803df08f44-67131800219so40915506d6.3 for ; Tue, 07 Nov 2023 10:23:04 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=ttaylorr-com.20230601.gappssmtp.com; s=20230601; t=1699381383; x=1699986183; darn=vger.kernel.org; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:from:to:cc:subject:date:message-id:reply-to; bh=fI+D4IMqk4r9R7LsBjQLBvIeLqQkjS+RkfVlR2YZTiA=; b=WRkqp4BvGEBYeAH7oXCBTGtqjvWsf8HU6ICW6yd5/fQDEwUWYnyy36vcWEHnVa46To MvTQpJMXFXgXD7FcEaioXr6Oea80ZfPRNgQMqOTAUfzsTCC6dFOhj/0nF3+ssPciHOV5 pXVsQT0lcgb8OkqAgRxXrgeuHPdbJFVFmh/QW+ofWoxTBDMKjWwaqO5UZiOnq0uTE73O VPemtfnd939gbBSu4ah7sRlKc/TiAvLy7SLCDqDLrMuImHYhMcNqZbbh9x3r6a3XY4LB vVd8WPl7PMNFhVBKsCwRaS65AGGXsHGrg8uyLJY5UUpRM683ePByXH1JnjdWRbWInoNQ 0fyQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1699381383; x=1699986183; h=in-reply-to:content-disposition:mime-version:references:message-id :subject:cc:to:from:date:x-gm-message-state:from:to:cc:subject:date :message-id:reply-to; bh=fI+D4IMqk4r9R7LsBjQLBvIeLqQkjS+RkfVlR2YZTiA=; b=de94E8mS7gZ2Kkw8qFElPB+Q+HzfB+Gk2UQFUPpZ28cXzHQV0h35KuHK+kGDNGtHr8 uCG82fGJsTb4VV+ICgJVV/xq2PELh2sC33DSTqIiz4vT6GGhO1LUqk7zWJeReU6vBsu5 Z+quhZ9ZOr0ez9fRDARI5uGcOQMboLMDUg0YTL92AcscsQbqDhRf3MNERo7bMVXkYR8k yJI1++E2AIK7YsvgDcmgUK1+gNlFvimDpdQqfZP2niQaUW2JxtrkuyxEpcbrbZ9M3BW0 sRO1SyJ2YbLfo61/DoXC68sJ93ZQZJ9BF9AoZwTuuXFfp8xtaJfUQrJrZeVAvp1s64Gp NhDw== X-Gm-Message-State: AOJu0YxzXqCjPdRrN7jJ7kk51gmv1KMEduwlL7TLxIIqB+RPYJs59d2c tLUE+tupKvO2M1T8GdvauTdQ2oXSrdOKd5Njw2mSZw== X-Google-Smtp-Source: AGHT+IHeMdnqx1oZ+O1BGIprSxrjSkCZGuiaYiDaXKba1VptPiyAZn9qeZx3bDJinBF+TR/dT+dFkQ== X-Received: by 2002:ad4:5c88:0:b0:66d:1b4c:e867 with SMTP id o8-20020ad45c88000000b0066d1b4ce867mr47070683qvh.45.1699381383379; Tue, 07 Nov 2023 10:23:03 -0800 (PST) Received: from localhost (104-178-186-189.lightspeed.milwwi.sbcglobal.net. [104.178.186.189]) by smtp.gmail.com with ESMTPSA id q8-20020a05621410e800b006590d020260sm136688qvt.98.2023.11.07.10.23.03 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Tue, 07 Nov 2023 10:23:03 -0800 (PST) Date: Tue, 7 Nov 2023 13:23:02 -0500 From: Taylor Blau To: git@vger.kernel.org Cc: Jeff King , Patrick Steinhardt , Elijah Newren , Junio C Hamano , Johannes Schindelin Subject: [RFC PATCH 3/3] builtin/replay.c: introduce `--write-pack` Message-ID: <0b9ef904888d45289445638ae59817feab1dc813.1699381371.git.me@ttaylorr.com> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: Now that the prerequisites are in place, we can implement a `--write-pack` option for `git replay`, corresponding to the existing one in `git merge-tree`. The changes are mostly limited to: - introducing a new option in the builtin - replacing the main object store with the temporary one - then repacking and migrating the temporary object store back into the main object store after the replay has completed Along with tests and documentation to ensure that the new behavior matches our expectations. Signed-off-by: Taylor Blau --- Documentation/git-replay.txt | 4 ++++ builtin/replay.c | 18 ++++++++++++++++++ t/t3650-replay-basics.sh | 37 ++++++++++++++++++++++++++++++++++++ 3 files changed, 59 insertions(+) diff --git a/Documentation/git-replay.txt b/Documentation/git-replay.txt index e7551aec54..f424c1a676 100644 --- a/Documentation/git-replay.txt +++ b/Documentation/git-replay.txt @@ -42,6 +42,10 @@ When `--advance` is specified, the update-ref command(s) in the output will update the branch passed as an argument to `--advance` to point at the new commits (in other words, this mimics a cherry-pick operation). +--write-pack:: + Write any new objects into a separate packfile instead of as + individual loose objects. + :: Range of commits to replay. More than one can be passed, but in `--advance ` mode, they should have diff --git a/builtin/replay.c b/builtin/replay.c index c3d53ff0cd..72b7b7f43a 100644 --- a/builtin/replay.c +++ b/builtin/replay.c @@ -17,6 +17,7 @@ #include "strmap.h" #include #include +#include "tmp-objdir.h" static const char *short_commit_name(struct commit *commit) { @@ -272,6 +273,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix) struct commit *onto = NULL; const char *onto_name = NULL; int contained = 0; + int write_pack = 0; struct rev_info revs; struct commit *last_commit = NULL; @@ -279,6 +281,7 @@ int cmd_replay(int argc, const char **argv, const char *prefix) struct merge_options merge_opt; struct merge_result result; struct strset *update_refs = NULL; + struct tmp_objdir *tmp_objdir = NULL; kh_oid_map_t *replayed_commits; int i, ret = 0; @@ -296,6 +299,8 @@ int cmd_replay(int argc, const char **argv, const char *prefix) N_("replay onto given commit")), OPT_BOOL(0, "contained", &contained, N_("advance all branches contained in revision-range")), + OPT_BOOL(0, "write-pack", &write_pack, + N_("write new objects to a pack instead of as loose")), OPT_END() }; @@ -352,8 +357,15 @@ int cmd_replay(int argc, const char **argv, const char *prefix) init_merge_options(&merge_opt, the_repository); memset(&result, 0, sizeof(result)); merge_opt.show_rename_progress = 0; + merge_opt.write_pack = write_pack; last_commit = onto; replayed_commits = kh_init_oid_map(); + + if (merge_opt.write_pack) { + tmp_objdir = tmp_objdir_create("replay"); + tmp_objdir_replace_primary_odb(tmp_objdir, 0); + } + while ((commit = get_revision(&revs))) { const struct name_decoration *decoration; khint_t pos; @@ -417,5 +429,11 @@ int cmd_replay(int argc, const char **argv, const char *prefix) /* Return */ if (ret < 0) exit(128); + if (ret && tmp_objdir) { + if (tmp_objdir_repack(tmp_objdir) < 0) + ret = 0; + else if (tmp_objdir_migrate(tmp_objdir) < 0) + ret = 0; + } return ret ? 0 : 1; } diff --git a/t/t3650-replay-basics.sh b/t/t3650-replay-basics.sh index 389670262e..e7048748c2 100755 --- a/t/t3650-replay-basics.sh +++ b/t/t3650-replay-basics.sh @@ -67,6 +67,43 @@ test_expect_success 'using replay to rebase two branches, one on top of other' ' test_cmp expect result ' +packdir=.git/objects/pack + +test_expect_success 'using replay to rebase two branches, with --write-pack' ' + # Remove the results of the previous rebase, ensuring that they + # are pruned from the object store. + git gc --prune=now && + test_must_fail git cat-file -t "$(cut -d " " -f 3 expect)" && + + # Create an extra packfile to ensure that the tmp-objdir repack + # takes place outside of the main object store. + git checkout --detach && + test_commit unreachable && + git repack -d && + git checkout main && + + find $packdir -type f -name "*.idx" | sort >packs.before && + git replay --write-pack --onto main topic1..topic2 >result && + find $packdir -type f -name "*.idx" | sort >packs.after && + + comm -13 packs.before packs.after >packs.new && + + # Ensure that we got a single new pack. + test_line_count = 1 result && + test_line_count = 1 packs.new && + + # ... and that the rest of the results match our expeectations. + git log --format=%s $(cut -f 3 -d " " result) >actual && + test_write_lines E D M L B A >expect && + test_cmp expect actual && + + printf "update refs/heads/topic2 " >expect && + printf "%s " $(cut -f 3 -d " " result) >>expect && + git rev-parse topic2 >>expect && + + test_cmp expect result +' + test_expect_success 'using replay on bare repo to rebase two branches, one on top of other' ' git -C bare replay --onto main topic1..topic2 >result-bare && test_cmp expect result-bare