From patchwork Wed Apr 3 11:34:28 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883495 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id E03F417E0 for ; Wed, 3 Apr 2019 11:35:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CA690289A5 for ; Wed, 3 Apr 2019 11:35:26 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BF104289B4; Wed, 3 Apr 2019 11:35:26 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-8.0 required=2.0 tests=BAYES_00,DKIM_SIGNED, DKIM_VALID,DKIM_VALID_AU,FREEMAIL_FROM,MAILING_LIST_MULTI,RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 6FAFE289A5 for ; Wed, 3 Apr 2019 11:35:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726549AbfDCLfZ (ORCPT ); Wed, 3 Apr 2019 07:35:25 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:38934 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfZ (ORCPT ); Wed, 3 Apr 2019 07:35:25 -0400 Received: by mail-pf1-f195.google.com with SMTP id i17so8022545pfo.6 for ; Wed, 03 Apr 2019 04:35:24 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20161025; h=from:to:cc:subject:date:message-id:in-reply-to:references :mime-version:content-transfer-encoding; bh=SILCV0xL0rMhdc8DRhCUAEY33mnaNDt1h5vVG3Tug14=; b=mjBUDmRBZJIOdzY+h7iqVz/18Fx77a3pBwDAIX6m14zaEkLhkBfpB8bqGADsqlZuDE n/CE398GcMeFzGIJg1R+GKd7PWHzEmXqoc11mgWWZt6mCszhg6uTzAhgMtmfEqDvKOpg LKxu7sRZ33SnTpNAon0sMtwg7IXYGJ8+/IUXfdNSMpebsb6FuiluY8UwfHhbuk9YkF8s YILn8rAIEXC4hf7jeeMSVEZfFhIJz2Oy2f4wRjHv0yku15p+13Ghf84Wsiw2GqRq+1Xm CPQGJXke4ZOoDOxOhSgAQMJfkGbG859JIUJ4jG7ZwQ1FipC85t5wkN9CS57SK1HB3iwt cCJQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to :references:mime-version:content-transfer-encoding; bh=SILCV0xL0rMhdc8DRhCUAEY33mnaNDt1h5vVG3Tug14=; b=X1sDiTM3a5m9zfthwUZ/vX2LV7Eu6gc1wXrbeTbM4EEkYYjG2AJyaj3K3vgpqUy0GK majPH6ng2R6hiIemjLqnWrw2rj7SqXTWdAifhI/TGqWshorxrXkkcQIr5zOm7whC0MqP 4x3zA1uliDwes9NNlQEQowI5fmLHIHTeQvC7+7fmGAzAO6vmsUT+88qPG55l+oUUoedg xdVNM70KddBfzX3mFT8lS2AwBzk7j7xXqsMIkqeDq0eQIKrjIAveIGvIZ741ZVYqgH4N ZKv3ejx8bZQLizkjEd0pUErPmG23j6/zFM2fGe5qTgDm2u8mQ4/LKVCcyOp7DTNGMkOY ONQQ== X-Gm-Message-State: APjAAAVfUPyBB84KFfLM9hsZehD1E0VyWpsmeaNEnhA983UQOVyUsgE+ R5D5gOjvPSmd/HGRtbCPWUY= X-Google-Smtp-Source: APXvYqx0PpAT9P0CWVRgldaQuGK3ce5Yo97UUdZGE6jyg80DyKgiJkaMJrf9H3IouNSFvyoK2GohEg== X-Received: by 2002:a63:2c55:: with SMTP id s82mr64970241pgs.356.1554291324625; Wed, 03 Apr 2019 04:35:24 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id x24sm21774389pfn.128.2019.04.03.04.35.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:24 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:19 +0700 From: =?utf-8?b?Tmd1eeG7hW4gVGjDoWkgTmfhu41jIER1eQ==?= To: pclouds@gmail.com Cc: git@vger.kernel.org, gitster@pobox.com, stefanbeller@gmail.com, =?utf-8?q?SZEDER_G=C3=A1bor?= Subject: [PATCH v2 03/32] refs.c: add refs_ref_exists() Date: Wed, 3 Apr 2019 18:34:28 +0700 Message-Id: <20190403113457.20399-4-pclouds@gmail.com> X-Mailer: git-send-email 2.21.0.479.g47ac719cd3 In-Reply-To: <20190403113457.20399-1-pclouds@gmail.com> References: <20190330111927.18645-1-pclouds@gmail.com> <20190403113457.20399-1-pclouds@gmail.com> MIME-Version: 1.0 Sender: git-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: git@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP Signed-off-by: Nguyễn Thái Ngọc Duy --- refs.c | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 142888a40a..b869f32d8b 100644 --- a/refs.c +++ b/refs.c @@ -241,9 +241,14 @@ int read_ref(const char *refname, struct object_id *oid) return read_ref_full(refname, RESOLVE_REF_READING, oid, NULL); } +static int refs_ref_exists(struct ref_store *refs, const char *refname) +{ + return !!refs_resolve_ref_unsafe(refs, refname, RESOLVE_REF_READING, NULL, NULL); +} + int ref_exists(const char *refname) { - return !!resolve_ref_unsafe(refname, RESOLVE_REF_READING, NULL, NULL); + return refs_ref_exists(get_main_ref_store(the_repository), refname); } static int match_ref_pattern(const char *refname,