From patchwork Fri May 17 08:19:14 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13666720 Received: from wfhigh1-smtp.messagingengine.com (wfhigh1-smtp.messagingengine.com [64.147.123.152]) (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 C25442CCD0 for ; Fri, 17 May 2024 08:19:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=64.147.123.152 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715933960; cv=none; b=GHDSXKh43HlA7NA4Expv6pNQA0492Qhx2N9w2c+ea0jx/0En8RBFYOmWW8wRbCuRraYnQT9CQoDL6YCe+kfyPG61JK8oHW4XIFXx7274stairHCtb1imu64i5oJyTuG0XHu6SrruscHHgC5B4GmT2yRoNx9cb8NuEQNFMiqMFfo= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715933960; c=relaxed/simple; bh=QW+MN7/lI/Qz9BnK3HFMp8mH7MtrgiPNjvjqkK4wASE=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=UY7LbpOH6aes9MngOjyGZtZZyzNeUl9n+1GJ1pdwnnzBoiyOux/3jNym6uiFfXpkUtwct/1k8midZFpr6HuWeROuRPwokvVOxDtUY/E4ZnfaBXf7SXswkJwwwEjMHpvg1ITb0E2Sw4RewH4Rmlvb2FMya2yTHHrJwxj8EdSTxmU= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=hq0WsgSB; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=ZyO45hvR; arc=none smtp.client-ip=64.147.123.152 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="hq0WsgSB"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="ZyO45hvR" Received: from compute6.internal (compute6.nyi.internal [10.202.2.47]) by mailfhigh.west.internal (Postfix) with ESMTP id EE87B1800179; Fri, 17 May 2024 04:19:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute6.internal (MEProxy); Fri, 17 May 2024 04:19:18 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm3; t=1715933957; x=1716020357; bh=0g/qpNRPOV 0A2HwwYHRA4haGO8oOblx0WRcfXjN1s50=; b=hq0WsgSBRELO7V3HvN8WiIl60o ILMLv5YiiQ9+oApCsA8h/Oj46R0PhVm/hhPDjDYTF8kd1zasdX8COvzLjRnqtBb1 MnCfcTfvogiw93ylimh1AuCS/J0DaBhuF9AMiBoLNBpmDIm2+OpELBkcI9p38tJw kDEw6k/KWcfMqVn/PqHNiMsLE/+8DACdvwHzcxkpBzTJ3OD/Sr+YhQnfw5vFs4bH zRDsoXkTGsSx6SL5Xyg8DSPJSoWeCO0z6HGaCoeKcEzV/fswgzWOnwOOPzmvZUD7 2JitK7UXMGQrETsBBADBtxwSFKYyivDosx+PVnyW9JWuxhbtzyaRiaG8oJMA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm3; t=1715933957; x=1716020357; bh=0g/qpNRPOV0A2HwwYHRA4haGO8oO blx0WRcfXjN1s50=; b=ZyO45hvRaz8sUFKJxDCUl1zd2jfkjpA5CmV8lMQ/i9tm zRP1xuJsDUhI/IvMH4JkZR6Dr/IX4NHLm5IQEYo6NISfm8XJKwJgKB0k6gEO7xst DRB9E2f1AkOHjsbZekE/kP/b1idYZDYEfcSQjM0upCbcukyUlN9BnU3Hr3au0wIh 8xHV9Cxw2hyoaCa+w1Uh6prllNURRRrDZ4D8LO9X0nXwAOw2dH8hpghd2StngX+D c6RwJLhNjaHEoVvwHw7ocW32K52z4PlfxZ5RcDcFJ/407js03RBlxDfK5nJ1EE57 WjxPIolE+/FG3q8FrMW8FW2XBp0G55Yr33OGvGf6oQ== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehfedgheekucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucesvcftvggtihhpihgvnhhtshculddquddttddmne cujfgurhepfffhvfevuffkfhggtggujgesghdtreertddtvdenucfhrhhomheprfgrthhr ihgtkhcuufhtvghinhhhrghrughtuceophhssehpkhhsrdhimheqnecuggftrfgrthhtvg hrnhepueektdevtdffveeljeetgfehheeigeekleduvdeffeeghefgledttdehjeelffet necuvehluhhsthgvrhfuihiivgepvdenucfrrghrrghmpehmrghilhhfrhhomhepphhsse hpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Fri, 17 May 2024 04:19:16 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 06c21804 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Fri, 17 May 2024 08:18:49 +0000 (UTC) Date: Fri, 17 May 2024 10:19:14 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Karthik Nayak , Junio C Hamano Subject: [PATCH v2 13/16] refs: remove `dwim_log()` 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: Remove `dwim_log()` in favor of `repo_dwim_log()` so that we can get rid of one more dependency on `the_repository`. Signed-off-by: Patrick Steinhardt --- builtin/reflog.c | 2 +- reflog-walk.c | 4 ++-- reflog.c | 2 +- refs.c | 5 ----- refs.h | 1 - 5 files changed, 4 insertions(+), 10 deletions(-) diff --git a/builtin/reflog.c b/builtin/reflog.c index b4650cea16..0d2ff95c6e 100644 --- a/builtin/reflog.c +++ b/builtin/reflog.c @@ -378,7 +378,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix) char *ref; struct expire_reflog_policy_cb cb = { .cmd = cmd }; - if (!dwim_log(argv[i], strlen(argv[i]), NULL, &ref)) { + if (!repo_dwim_log(the_repository, argv[i], strlen(argv[i]), NULL, &ref)) { status |= error(_("%s points nowhere!"), argv[i]); continue; } diff --git a/reflog-walk.c b/reflog-walk.c index f11b97e889..5f09552c5c 100644 --- a/reflog-walk.c +++ b/reflog-walk.c @@ -191,8 +191,8 @@ int add_reflog_for_walk(struct reflog_walk_info *info, reflogs = read_complete_reflog(branch); if (!reflogs || reflogs->nr == 0) { char *b; - int ret = dwim_log(branch, strlen(branch), - NULL, &b); + int ret = repo_dwim_log(the_repository, branch, strlen(branch), + NULL, &b); if (ret > 1) free(b); else if (ret == 1) { diff --git a/reflog.c b/reflog.c index 8861c2d606..3c80950186 100644 --- a/reflog.c +++ b/reflog.c @@ -409,7 +409,7 @@ int reflog_delete(const char *rev, enum expire_reflog_flags flags, int verbose) if (!spec) return error(_("not a reflog: %s"), rev); - if (!dwim_log(rev, spec - rev, NULL, &ref)) { + if (!repo_dwim_log(the_repository, rev, spec - rev, NULL, &ref)) { status |= error(_("no reflog for '%s'"), rev); goto cleanup; } diff --git a/refs.c b/refs.c index 83cd965a26..43c5fef734 100644 --- a/refs.c +++ b/refs.c @@ -775,11 +775,6 @@ int repo_dwim_log(struct repository *r, const char *str, int len, return logs_found; } -int dwim_log(const char *str, int len, struct object_id *oid, char **log) -{ - return repo_dwim_log(the_repository, str, len, oid, log); -} - int is_per_worktree_ref(const char *refname) { return starts_with(refname, "refs/worktree/") || diff --git a/refs.h b/refs.h index e906dbb44a..82022d300c 100644 --- a/refs.h +++ b/refs.h @@ -164,7 +164,6 @@ int expand_ref(struct repository *r, const char *str, int len, struct object_id int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref, int nonfatal_dangling_mark); int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); -int dwim_log(const char *str, int len, struct object_id *oid, char **ref); /* * Retrieves the default branch name for newly-initialized repositories.