🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: linux.kernel.git
Article #586

[Outreachy PATCH] merge: stop using the_repository

#586
From: Okhuomon Ajayi
Date: Thu, 15 Oct 2026 14:25
76 lines
10282 bytes
try_merge_command() and checkout_fast_forward() already receive a
repository, so use it instead of relying on global variables.

Add a repository parameter to merge_argument() and pass it
from try_merge_command(). Use the repository in
checkout_fast_forward() when parsing trees.

Remove the now-unnecessary USE_THE_REPOSITORY_VARIABLE
definition.

Signed-off-by: Okhuomon Ajayi <okhuomonajayi54@gmail.com>
---
 merge.c | 16 +++++++---------
 1 file changed, 7 insertions(+), 9 deletions(-)

diff --git a/merge.c b/merge.c
index 0f5e823e63..85dad63a94 100644
--- a/merge.c
+++ b/merge.c
@@ -1,5 +1,3 @@
-#define USE_THE_REPOSITORY_VARIABLE
-
 #include "git-compat-util.h"
 #include "gettext.h"
 #include "hash.h"
@@ -14,9 +12,9 @@
 #include "tree-walk.h"
 #include "unpack-trees.h"
 
-static const char *merge_argument(struct commit *commit)
+static const char *merge_argument(struct repository *r, struct commit *commit)
 {
-	return oid_to_hex(commit ? &commit->object.oid : the_hash_algo->empty_tree);
+	return oid_to_hex(commit ? &commit->object.oid : r->hash_algo->empty_tree);
 }
 
 int try_merge_command(struct repository *r,
@@ -32,11 +30,11 @@ int try_merge_command(struct repository *r,
 	for (size_t i = 0; i < xopts_nr; i++)
 		strvec_pushf(&cmd.args, "--%s", xopts[i]);
 	for (j = common; j; j = j->next)
-		strvec_push(&cmd.args, merge_argument(j->item));
+		strvec_push(&cmd.args, merge_argument(r, j->item));
 	strvec_push(&cmd.args, "--");
 	strvec_push(&cmd.args, head_arg);
 	for (j = remotes; j; j = j->next)
-		strvec_push(&cmd.args, merge_argument(j->item));
+		strvec_push(&cmd.args, merge_argument(r, j->item));
 
 	cmd.git_cmd = 1;
 	ret = run_command(&cmd);
@@ -68,18 +66,18 @@ int checkout_fast_forward(struct repository *r,
 	memset(&trees, 0, sizeof(trees));
 	memset(&t, 0, sizeof(t));
 
-	trees[nr_trees] = repo_parse_tree_indirect(the_repository, head);
+	trees[nr_trees] = repo_parse_tree_indirect(r, head);
 	if (!trees[nr_trees++]) {
 		rollback_lock_file(&lock_file);
 		return -1;
 	}
-	trees[nr_trees] = repo_parse_tree_indirect(the_repository, remote);
+	trees[nr_trees] = repo_parse_tree_indirect(r, remote);
 	if (!trees[nr_trees++]) {
 		rollback_lock_file(&lock_file);
 		return -1;
 	}
 	for (i = 0; i < nr_trees; i++) {
-		if (repo_parse_tree(the_repository, trees[i]) < 0) {
+		if (repo_parse_tree(r, trees[i]) < 0) {
 			rollback_lock_file(&lock_file);
 			return -1;
 		}
-- 
2.54.0
Technical Details
Message-ID: <20261015142532.48175-1-okhuomonajayi54@gmail.com>
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72134-linux-kernel-git=dewy.ru

Show Full Headers
Complete Article Headers
Path: mbox-mo1.pugleaf.net!archive.usenet.blueworldhosting.com!usenet.blueworldhosting.com!diablo1.usenet.blueworldhosting.com!usenet.network!.POSTED!vger.kernel.org!git+bounces-72134-linux-kernel-git=dewy.ru
From: okhuomonajayi54@gmail.com (Okhuomon Ajayi)
Newsgroups: linux.kernel.git
Subject: [Outreachy PATCH] merge: stop using the_repository
Date: Thu, 15 Oct 2026 15:25:32 +0100
Organization: Usenet Network
Message-ID: <20261015142532.48175-1-okhuomonajayi54@gmail.com>
MIME-Version: 1.0
Content-Transfer-Encoding: 8bit
Injection-Info: usenet.network;
	logging-data="2548000"; mail-complaints-to="abuse@usenet.network"
Cancel-Lock: sha1:YtJmOAVYQi3d6cJGSBzGDoXW8YM= sha256:JNPh0sDndOTy2NGseQ/NN8QxI+ni6SdlRdOuaocdoAI=
	sha1:SJUvhtE4KpSq6iqCYzJQIC14WJM= sha256:MiYajdFW+zP7cMG1DKvrFkiCyXPdoL3V1BEMh3HXNi8=
List-ID: <git.vger.kernel.org>
X-Mailpost-Empty-Hdrs: X-Spam-Level
X-Received: from localhost (localhost [127.0.0.1])
	by mail.dewy.ru (Postfix) with ESMTP id 1718111031F; Thu, 15 Oct 2026 17:32:34 +0300 (MSK)
X-Virus-Scanned: Debian amavisd-new at usenet.network
X-Spam-Flag: NO
X-Spam-Score: -3.048
X-Spam-Status: No, score=-3.048 tagged_above=-9999 required=6.31
	tests=[DCC_REPUT_70_89=0.1, DKIM_SIGNED=0.1, DKIM_VALID=-0.1,
	DKIM_VALID_AU=-0.1, FREEMAIL_FORGED_FROMDOMAIN=0.001,
	FREEMAIL_FROM=0.001, HEADER_FROM_DIFFERENT_DOMAINS=0.25,
	MAILING_LIST_MULTI=-1, RCVD_IN_DNSWL_MED=-2.3, SPF_HELO_NONE=0.001,
	SPF_PASS=-0.001] autolearn=ham autolearn_force=no
X-Authentication-Results: mail.dewy.ru (amavisd-new); dkim=pass (2048-bit key)
	header.d=gmail.com
X-Received: from mail.dewy.ru ([127.0.0.1])
	by localhost (mail.dewy.ru [127.0.0.1]) (amavisd-new, port 10024)
	with ESMTP id aMRiGUqSUmA3;
	Thu, 15 Oct 2026 17:32:31 +0300 (MSK)
X-Received-SPF: Pass (mailfrom) identity=mailfrom; client-ip=172.105.105.114; helo=tor.lore.kernel.org; envelope-from=git+bounces-72134-linux-kernel-git=dewy.ru@vger.kernel.org; receiver=<UNKNOWN> 
X-Authentication-Results: OpenDMARC; dmarc=fail (p=none dis=none) header.from=gmail.com
X-Received: from tor.lore.kernel.org (tor.lore.kernel.org [172.105.105.114])
	by mail.dewy.ru (Postfix) with ESMTPS id 1927E11031A; Thu, 15 Oct 2026 17:32:21 +0300 (MSK)
X-Received: from smtp.subspace.kernel.org (conduit.subspace.kernel.org [100.90.174.1])
	by tor.lore.kernel.org (Postfix) with ESMTP id E5C052BD01; Thu, 15 Oct 2026 14:25:53 +0000 (UTC)
X-Received: from localhost.localdomain (localhost.localdomain [127.0.0.1])
	by smtp.subspace.kernel.org (Postfix) with ESMTP id 064DA4F30C1;
	Thu, 15 Oct 2026 14:25:50 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org;
	dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="GGlsl7sW"
X-Received: from mail-ej1-f50.google.com (mail-ej1-f50.google.com [209.85.218.50])
	(using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits))
	(No client certificate requested)
	by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5AB8E530DE1
	for <git@vger.kernel.org>; Thu, 15 Oct 2026 14:25:43 +0000 (UTC)
X-Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.50
X-ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116;
	t=1792074348; cv=none; b=CXihCl8ibivEMJGO9Cyd7kfh4r44rOhS5hyHCQVBDtTDWtf4bTeUqL6hR+PVI10cKk288KbyGjuESR7BxGUNU/ym5MBXemBFoBlSw5t32tjLaZZrqtNifTYMYyUwtMbFawEyAcJ+XLnCZ1vmbstU3LtyEp1Nn9EDDT78LYo+GpQ=
X-ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org;
	s=arc-20240116; t=1792074348; c=relaxed/simple;
	bh=pQDSf3F8de3zNwQ8fGiiJjdIrnDRXZzlZYk+TL2snrE=;
	h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=MUNMNQ21pxPKyyeVrHkZYWh2Wzovhwy2l6VxSrXqHgs4KT3HxYl+mBf37kerGAXVvBsJ+3jWdvVDp7dG3sycL2mxTIgHcc2pqCUrNiWPdPxV2uzUBjGAKNa4NI2HHKJnL40UTTcqRYCcvRC2paB+HbuKHoqMSiokOgL85Rf3XEA=
X-ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=GGlsl7sW; arc=none smtp.client-ip=209.85.218.50
X-Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com
X-Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com
X-Received: by mail-ej1-f50.google.com with SMTP id a640c23a62f3a-c2e69aa07c3so333147866b.1
        for <git@vger.kernel.org>; Thu, 15 Oct 2026 07:25:43 -0700 (PDT)
X-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=gmail.com; s=20251104; t=1792074341; x=1792679141; darn=vger.kernel.org;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:from:to:cc:subject:date:message-id:reply-to:content-type;
        bh=y1ZwdeUh226bSuX/lFH8esK1j0ZdyZnvfyMT/XS0LTY=;
        b=GGlsl7sWS3RobzytkGOlkTMTxbaMaZAFQf9a9rHM9v1ekXKmxvU9qtGaDdJye892Hy
         xRDocT5bIZ8NlYTNgYPnQx0mYkMjKdFZrRc0wf+mUxLoWHvd+zM6AlNN6A4rfTWF7tHZ
         45U/C/2QNsipx28Qtk7NWfMxRsPjCfktdJRcFIR3V7U5YtfY/FgI8e98VxXCWR+WWJbH
         OklergaSN1gJaNV+KL6/QwD7v9oA+0+NJ1D00mOP0dGSuAtFVBmuOlXtVY6MBWF+E0JB
         lnl/n2tvtrXInL5QRHrTbMwTDe80oz7KCJyS2gljwqNP4lU1Pw/fBaxwxSRDKPBlKa49
         NEsw==
X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed;
        d=1e100.net; s=20260707; t=1792074341; x=1792679141;
        h=content-transfer-encoding:mime-version:message-id:date:subject:cc
         :to:from:x-gm-gg:x-gm-message-state:from:to:cc:subject:date
         :message-id:reply-to:content-type;
        bh=y1ZwdeUh226bSuX/lFH8esK1j0ZdyZnvfyMT/XS0LTY=;
        b=DEWeaVUTrl4TulyL1VVMXpPpEIHci9/lvvrNF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hjd8YX24lwYNrjyHSeguf5BD3N/6HF9z3odQS0CiTidzT4IOkXXFc/qLlvPx8hmQbrff
	EyPcSXEDFfg==
X-Received: by 2002:a17:906:dc8e:b0:c29:4513:f6fd with SMTP id a640c23a62f3a-c31aa081b78mr1852813766b.35.1792074341175;
        Thu, 15 Oct 2026 07:25:41 -0700 (PDT)
X-Received: from localhost.localdomain ([104.28.251.99])
        by smtp.gmail.com with ESMTPSA id a640c23a62f3a-c3f8557c767sm68631766b.50.2026.10.15.07.25.37
        (version=TLS1_3 cipher=TLS_CHACHA20_POLY1305_SHA256 bits=256/256);
        Thu, 15 Oct 2026 07:25:40 -0700 (PDT)
X-Cc: git@vger.kernel.org,
	christian.couder@gmail.com,
	usmanakinyemi202@gmail.com,
	siddharthasthana31@gmail.com,
	kaartic.sivaraam@gmail.com,
	Okhuomon Ajayi <okhuomonajayi54@gmail.com>
X-Mailer: git-send-email 2.54.0
X-Precedence: bulk
X-Mailing-List: git@vger.kernel.org
X-List-Subscribe: <mailto:git+subscribe@vger.kernel.org>
X-List-Unsubscribe: <mailto:git+unsubscribe@vger.kernel.org>