From patchwork Thu May 16 08:05: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: 13665816 Received: from fhigh2-smtp.messagingengine.com (fhigh2-smtp.messagingengine.com [103.168.172.153]) (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 B580F6EB7A for ; Thu, 16 May 2024 08:05:18 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.153 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846720; cv=none; b=oRRs32ga3GwDZ4tlAvx9spdcxAYMLSDCg0kjDuZqBdcM78JufsV6X7B+lmaYtKXNRSs2bgF2z+fqrM9SuXDb1CtSGp0DKrLyDD4ufw4tvH3yIfF8UF2SF8mtoSIQHfvYyNxJxYHZk/l3y5pjduVUzwSggZOseIRiI2iiVOu29Vw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1715846720; c=relaxed/simple; bh=UkcZLLGo6apXJ+9UVKOEn/mYkigcX9mekUsCpbGztDE=; h=Date:From:To:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=RFGKveJme0OWMK70dbCV8tDBjjyL+SREe1eQeeFSCffJqb7Mt1rLZQIa9/DllAsE2bGE6QOdNK6P7h53B0eocf62Ht7R9zVtmOtlAc6nftkE8/grDQIUBEBy+858OleYm6X3bmIrha6YNIttVlxhPiJG7tXRN987zk74rqfp4Q4= 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=kXdYXAWy; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=hOUo75Wj; arc=none smtp.client-ip=103.168.172.153 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="kXdYXAWy"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="hOUo75Wj" Received: from compute1.internal (compute1.nyi.internal [10.202.2.41]) by mailfhigh.nyi.internal (Postfix) with ESMTP id DE1F3114006F for ; Thu, 16 May 2024 04:05:17 -0400 (EDT) Received: from mailfrontend1 ([10.202.2.162]) by compute1.internal (MEProxy); Thu, 16 May 2024 04:05:17 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=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=1715846717; x=1715933117; bh=wp53xAXT2z 7YH2gofho6DPDe69XaV3HuEPogUPr4QAo=; b=kXdYXAWyQ0FUAZaHgAiNRPllHE Eo0xn5k70n9s7f2jSkNqtTum9EXLCdBZHNBV0vqgrWDKxXUwj5ZUaR3hAb5GgMmx 7HLKK0tOikOYIs2g/9KlmFW3JUcyRv0ZI5cLMh2+CYcd59F/ncgvTshEK/g73tPx 4vnVLqQv9Fl9Fmv12GEuVuxIFYZIBoZhg1znA8gzbxx/fbUfOa3MyilYnxNB07TS PS5RSE8dvvsh+AD5L8mPPQBnlHWdys8a6S+g2BCueQ9j3A7rCxPpY6jY0plb8wE5 4Vx9F2+4KQlH/Ukg64/xCmY+/HZeoEXKvQIjPlI7clhlRY2m1SB/n4WMVpNA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=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=1715846717; x=1715933117; bh=wp53xAXT2z7YH2gofho6DPDe69Xa V3HuEPogUPr4QAo=; b=hOUo75WjDJ5f/iHl2kY6r+NpyPd2a5jOIfunjDfIK0BA 57HLyykMFWuoLPRNUAhAR3w3zE2bmWDSnKx5AbN73EcOP6MKieuBwEhcL1SIge9I eJxPT8QMGR4YqHvrXdOSKrZTOKqh1rhudBI08WkbrMUUV/LnB6HZ8yeA/T02jXy2 0UR0TggalJOSfa5obufH2T5JVHu4OV4rzNVkBXkD1pxMnmF+BZeWre/KuUE1MBww FVgmHRd1fQgvybQAkTOBUbzlI82vhKut1I4OWujNcHKOdJ/FZViG7EqcqJFyMz+D W+/aGYjT+eUXIJPsBBPHvivKqQSfgDZ3aLrDhTmV+A== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrvdehtddgtdegucetufdoteggodetrfdotf fvucfrrhhofhhilhgvmecuhfgrshhtofgrihhlpdfqfgfvpdfurfetoffkrfgpnffqhgen uceurghilhhouhhtmecufedttdenucenucfjughrpeffhffvuffkfhggtggujgesghdtre ertddtvdenucfhrhhomheprfgrthhrihgtkhcuufhtvghinhhhrghrughtuceophhssehp khhsrdhimheqnecuggftrfgrthhtvghrnhepheeghfdtfeeuffehkefgffduleffjedthf dvjeektdfhhedvlefgtefgvdettdfhnecuvehluhhsthgvrhfuihiivgepgeenucfrrghr rghmpehmrghilhhfrhhomhepphhssehpkhhsrdhimh X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA for ; Thu, 16 May 2024 04:05:17 -0400 (EDT) Received: by localhost (OpenSMTPD) with ESMTPSA id 7129f1b0 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO) for ; Thu, 16 May 2024 08:04:52 +0000 (UTC) Date: Thu, 16 May 2024 10:05:14 +0200 From: Patrick Steinhardt To: git@vger.kernel.org Subject: [PATCH 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 3618c8f7a4..723bf7af20 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 95c3437443..fe0b6b44c5 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.