From patchwork Wed Apr 3 11:34:26 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883491 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 6032C922 for ; Wed, 3 Apr 2019 11:35:17 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 4AEBA289AF for ; Wed, 3 Apr 2019 11:35:17 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D2A4289A5; Wed, 3 Apr 2019 11:35:17 +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 D1974289A5 for ; Wed, 3 Apr 2019 11:35:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726468AbfDCLfP (ORCPT ); Wed, 3 Apr 2019 07:35:15 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:36738 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726206AbfDCLfO (ORCPT ); Wed, 3 Apr 2019 07:35:14 -0400 Received: by mail-pf1-f194.google.com with SMTP id z5so6998554pfn.3 for ; Wed, 03 Apr 2019 04:35:14 -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=RkJkXS0Ch+9mIL4ix59KiJ6ZOaCsTq/O/PJ91VgU4Jk=; b=FlvM+FOTjxj6c7sbEuvXLSqHGjwDosoBH2K8z/gF0lPUv6/yghQldFsuKKORAqx1iH vLphchBnGXWuYG/XhEBqrGpA9AnGW6D/Bm6lRknNwbKGKdtNSDBAwft2NrdIGbi7Ylrt uT6G86LxzbrXzvX82Q/YjmKOyTfHPvDPz2V0YgCutTOqjBzJMiDR2aLNoaclJ5NxIs7L cHBOvvtHTeiAjVMoHLgwnBfkZmZZstRx/tbq8O7vM9j2F3BB8x99zf0wxtSPh1xvDL8M +nNDf4g2zeJ34uXpee8hUDhvBIebWm7ihQusbI0E/7eKhy59oJXJQ8NDIq27y8pQkPDn +81A== 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=RkJkXS0Ch+9mIL4ix59KiJ6ZOaCsTq/O/PJ91VgU4Jk=; b=ZitkuZuI+J74W9ORs+uEcrmO0U1ovntyBOZmyP80AnNpOobIoYtE5qySxBE9gVXHbu geAvCqtgz0GqLSCmjnEnsegreeku1reyjZoaY9bul0ZjxQi9ZGCq2LR0EkQZv6pewcus sPAgz5bQI1rZCeX+mLOX15cbyqEunxV+xyGY3T/Uj1JiFr5mwy1bKw1OgrRR7IiRHW0e pTSYPCHJrHdUjkhzZwtmqtCg2oTgHE9Mpd3nSmJKkwDHL4ghkajmAfMksGY2jHL2w381 sEg8lZjpQChou/ygRGPHFm34gKuATejW7R5Rqkl+KGCXwOer3U2Yklv0arp5Lawff9gx yA6w== X-Gm-Message-State: APjAAAUb+eHGPcW9EXoUYLFaP1LIEAEglstfD94SvXwTMWzB/YOGhJmN PHdWcMxGuOs6rSpAlOvGT74= X-Google-Smtp-Source: APXvYqyTASh6he9zNgfADXTIi4C+wmphxI2/MxY8PdWITIckfEiL+Uugm7CNMK8/HwR25rvNQP+WQg== X-Received: by 2002:a62:5ec2:: with SMTP id s185mr8383181pfb.16.1554291314300; Wed, 03 Apr 2019 04:35:14 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id z13sm15664017pgc.25.2019.04.03.04.35.11 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:13 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:09 +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 01/32] rebase: 'make coccicheck' cleanup Date: Wed, 3 Apr 2019 18:34:26 +0700 Message-Id: <20190403113457.20399-2-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 --- builtin/rebase.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin/rebase.c b/builtin/rebase.c index 77deebc65c..c064909329 100644 --- a/builtin/rebase.c +++ b/builtin/rebase.c @@ -1592,8 +1592,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) branch_name = options.head_name; } else { - free(options.head_name); - options.head_name = NULL; + FREE_AND_NULL(options.head_name); branch_name = "HEAD"; } if (get_oid("HEAD", &options.orig_head)) @@ -1793,7 +1792,7 @@ int cmd_rebase(int argc, const char **argv, const char *prefix) * we just fast-forwarded. */ strbuf_reset(&msg); - if (!oidcmp(&merge_base, &options.orig_head)) { + if (oideq(&merge_base, &options.orig_head)) { printf(_("Fast-forwarded %s to %s.\n"), branch_name, options.onto_name); strbuf_addf(&msg, "rebase finished: %s onto %s", From patchwork Wed Apr 3 11:34:27 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883493 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 186DC17E0 for ; Wed, 3 Apr 2019 11:35:22 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 0363A289A5 for ; Wed, 3 Apr 2019 11:35:22 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id EC046289B4; Wed, 3 Apr 2019 11:35:21 +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 8ED70289A5 for ; Wed, 3 Apr 2019 11:35:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726547AbfDCLfU (ORCPT ); Wed, 3 Apr 2019 07:35:20 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:38573 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfU (ORCPT ); Wed, 3 Apr 2019 07:35:20 -0400 Received: by mail-pf1-f194.google.com with SMTP id 10so8022253pfo.5 for ; Wed, 03 Apr 2019 04:35:19 -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=9Hh1qjhIYgsEJ1RAvKb6URhIj4fZF8d7gLklPr6lwvk=; b=ZCQv4k+HoTA9jn8e5BB/KGcPrJa5/U9sKhBWCp975EXwdQEZ1uxZouxPlng/nJMc5P +sJoXLSxQ07UxLnaUNGTdC+LI7zzAQgEtWYBnbakNATcIrFkouin03Kv+rE0/Ift+94w Muouaht0JUfitfc727U/7kbTJ3w98DGZYsCZa5fURr7KoMWIqi0QkqNR6/AUK+IJ1uqB bz3xPPg+o0RsPAllCQAkBzPDBCvyIUk3Bowmr/7/xJOCzBXbmIHDjkPvhhg0ylMXx8BL t5pvaLyRyAd9jqYNkYU6qBdD4JBovGVegszJQuDwvXoTcxXjaiES8zrqOMZl3U4sG1GD 2AsQ== 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=9Hh1qjhIYgsEJ1RAvKb6URhIj4fZF8d7gLklPr6lwvk=; b=oCz3U5On81WXC4RZv7ZcoJ0kFKWQjfFX4mJ273/zpjge4mPwPg4QQXyqhMTNHc8ySN pimipL38ayAz6F1VqF6pA9G2XBGQSCekoAu25WIrmp31uNcYb71qeRY/PZq1gfqvKnvy JkoDo2T7yZ0+G2nMLG6aUwfWGYb/8fDnGZNcRcRz0Fa6LfzytsRm1nLTvOuzrFLuGOc4 bzxpYjYYijzrLesQ+kFHbSCuA5T9D4h5E/5esZQ/kpBvDQY94h+cf5Fxv3yp6lLRYgnf duPeJIlZYaapPMuWwfTeUWstVLVab0hgPT91vrngVphcAKfsN9MBU/xqihtUQtza6KmF ns2Q== X-Gm-Message-State: APjAAAViqc+ky+Ow81pZxtckNKO5hDOdyjzfbh534VSC75RZg6Qg2OZU 56IFcFI048GMUYPweEDaK0dRSmtt X-Google-Smtp-Source: APXvYqyogTVdheJKxIhp346F050wy1sP80PRQvBZXMY0ubT+DxDWFkkgL9shtqHOxMchCL2hCiDv3Q== X-Received: by 2002:a65:6259:: with SMTP id q25mr44640064pgv.103.1554291319557; Wed, 03 Apr 2019 04:35:19 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id f63sm10260899pfc.180.2019.04.03.04.35.16 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:18 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:14 +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 02/32] packfile.c: add repo_approximate_object_count() Date: Wed, 3 Apr 2019 18:34:27 +0700 Message-Id: <20190403113457.20399-3-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 --- packfile.c | 14 +++++++------- packfile.h | 3 ++- 2 files changed, 9 insertions(+), 8 deletions(-) diff --git a/packfile.c b/packfile.c index 16bcb75262..2ad4fab2f8 100644 --- a/packfile.c +++ b/packfile.c @@ -893,25 +893,25 @@ static void prepare_packed_git(struct repository *r); * all unreachable objects about to be pruned, in which case they're not really * interesting as a measure of repo size in the first place. */ -unsigned long approximate_object_count(void) +unsigned long repo_approximate_object_count(struct repository *r) { - if (!the_repository->objects->approximate_object_count_valid) { + if (!r->objects->approximate_object_count_valid) { unsigned long count; struct multi_pack_index *m; struct packed_git *p; - prepare_packed_git(the_repository); + prepare_packed_git(r); count = 0; - for (m = get_multi_pack_index(the_repository); m; m = m->next) + for (m = get_multi_pack_index(r); m; m = m->next) count += m->num_objects; - for (p = the_repository->objects->packed_git; p; p = p->next) { + for (p = r->objects->packed_git; p; p = p->next) { if (open_pack_index(p)) continue; count += p->num_objects; } - the_repository->objects->approximate_object_count = count; + r->objects->approximate_object_count = count; } - return the_repository->objects->approximate_object_count; + return r->objects->approximate_object_count; } static void *get_next_packed_git(const void *p) diff --git a/packfile.h b/packfile.h index d70c6d9afb..f04440f984 100644 --- a/packfile.h +++ b/packfile.h @@ -57,7 +57,8 @@ struct packed_git *get_all_packs(struct repository *r); * Give a rough count of objects in the repository. This sacrifices accuracy * for speed. */ -unsigned long approximate_object_count(void); +unsigned long repo_approximate_object_count(struct repository *r); +#define approximate_object_count() repo_approximate_object_count(the_repository) extern struct packed_git *find_sha1_pack(const unsigned char *sha1, struct packed_git *packs); 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, From patchwork Wed Apr 3 11:34:29 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883497 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 8FE70922 for ; Wed, 3 Apr 2019 11:35:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7A572289A5 for ; Wed, 3 Apr 2019 11:35:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6EF16289B4; Wed, 3 Apr 2019 11:35:32 +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 1D54B289A5 for ; Wed, 3 Apr 2019 11:35:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726574AbfDCLfb (ORCPT ); Wed, 3 Apr 2019 07:35:31 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:44906 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfa (ORCPT ); Wed, 3 Apr 2019 07:35:30 -0400 Received: by mail-pl1-f195.google.com with SMTP id g12so7899844pll.11 for ; Wed, 03 Apr 2019 04:35:30 -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=QNHEfU5Es+iTRROnoumQYR2DGfc6CnyeuJUutLTjvtc=; b=I0VTESrFTAtDVbdsD5ZeQzIoVPlQZFOLEBEIqx1WRAGdMsNdagZQdjzjp2G/ExsB/F v+1o/9PypTJmojK/txqJio87pnL9/c5FBbSIBwHPubpV0ZkPWWhoDz1krnToB3VBP0sR pq//qZBMQqsoziZK9vGu7PgLh+OcvBuO2ZdbaMN7N77CXkScJ0YOXmNw/pEJcfhEeWZg kcqxaViidHgwsX5knQqkYc1zXi2d1v9vFIXronbQ+44ExS43FTkHbhSHC/4FjzqDRwQ9 Pnar6eRAeXbwK7fRU8g83QvqNnw+3e6L2bJvVs2CjPQXOM6UyPOOLYMkQwxLLwIr8s7M wPkA== 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=QNHEfU5Es+iTRROnoumQYR2DGfc6CnyeuJUutLTjvtc=; b=dBiK/EfUv1C51dvXbyECMFh4p0q+nPwmCEOJM3Xs7Hl6BrTX51x2OZDANsXfpI6jsY nB4D3dzcGvPmrvNpS7mPOt/zhd9sz2IiKFVtKqgt7ik+VTcVA9XvFD/PKiS3tFyh7HJw CqnypJ3Q2NlX3iyR94bq2+ICkUx3JLgMWXwYk8GtA7+Waum5FHWI28OkWkVNjkri/FD7 jQ29hxC9bDXQJtLNflMw3vStZSheyFWHoYikRiV7iT41o7iGhSys26H69bA7vT7BblZU XMseXnLlYiyANuz7C9k7lPkEG+7rWDfyilU6O5KT8s7gxU1opQcuK7wM8lpuVYZ0WGNq 8IdQ== X-Gm-Message-State: APjAAAW7sTNkUVFsqqeqXMYCOI2QJUUmN3p6Mb/QD+U4Z/S6AZmqvQhc PDPtJxY2MGM0aA7sTRxLDH4= X-Google-Smtp-Source: APXvYqxVsp/wTAxqzmDgFluNPx2tFy6xSf1Pul2C2x7XNQ3hbV4I9VtsI/dlFBvshOcaBTwn0vIPzA== X-Received: by 2002:a17:902:403:: with SMTP id 3mr75924379ple.48.1554291329965; Wed, 03 Apr 2019 04:35:29 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id r87sm15063774pfa.71.2019.04.03.04.35.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:29 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:24 +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 04/32] refs.c: add refs_shorten_unambiguous_ref() Date: Wed, 3 Apr 2019 18:34:29 +0700 Message-Id: <20190403113457.20399-5-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 | 11 +++++++++-- refs.h | 2 ++ 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/refs.c b/refs.c index b869f32d8b..3dde824aab 100644 --- a/refs.c +++ b/refs.c @@ -1169,7 +1169,8 @@ int update_ref(const char *msg, const char *refname, old_oid, flags, onerr); } -char *shorten_unambiguous_ref(const char *refname, int strict) +char *refs_shorten_unambiguous_ref(struct ref_store *refs, + const char *refname, int strict) { int i; static char **scanf_fmts; @@ -1247,7 +1248,7 @@ char *shorten_unambiguous_ref(const char *refname, int strict) strbuf_reset(&resolved_buf); strbuf_addf(&resolved_buf, rule, short_name_len, short_name); - if (ref_exists(resolved_buf.buf)) + if (refs_ref_exists(refs, resolved_buf.buf)) break; } @@ -1266,6 +1267,12 @@ char *shorten_unambiguous_ref(const char *refname, int strict) return xstrdup(refname); } +char *shorten_unambiguous_ref(const char *refname, int strict) +{ + return refs_shorten_unambiguous_ref(get_main_ref_store(the_repository), + refname, strict); +} + static struct string_list *hide_refs; int parse_hide_refs_config(const char *var, const char *value, const char *section) diff --git a/refs.h b/refs.h index 308fa1f03b..5627570241 100644 --- a/refs.h +++ b/refs.h @@ -462,6 +462,8 @@ int check_refname_format(const char *refname, int flags); const char *prettify_refname(const char *refname); +char *refs_shorten_unambiguous_ref(struct ref_store *refs, + const char *refname, int strict); char *shorten_unambiguous_ref(const char *refname, int strict); /** rename ref, return 0 on success **/ From patchwork Wed Apr 3 11:34:30 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883505 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 5DF9C922 for ; Wed, 3 Apr 2019 11:35:39 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48861289A5 for ; Wed, 3 Apr 2019 11:35:39 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3D0D5289B4; Wed, 3 Apr 2019 11:35:39 +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 2AD78289A5 for ; Wed, 3 Apr 2019 11:35:38 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726582AbfDCLfh (ORCPT ); Wed, 3 Apr 2019 07:35:37 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:45513 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfg (ORCPT ); Wed, 3 Apr 2019 07:35:36 -0400 Received: by mail-pg1-f194.google.com with SMTP id y3so8175746pgk.12 for ; Wed, 03 Apr 2019 04:35:36 -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=0PazlTtVfhEjw1y44qBaTCCffQGEbZCrOeMwdGeo05I=; b=izHnoUcrjeIrf++/iQQ6msjNZu87Dyzavp0t2wnGFuLclmxxXdUEJPtWXODwK1KH+h 6E/vte11k1bZqCdlAPercnoTIHwOM1DfLkOHytvCa+RqsqDPd4Rahc7V95QS8aQnGHlK d3V8booDZgKYr8zcj3QmyJdKI9S52s6uZGQyBc5tTbsxxWIwZ8YzfnQLk/FCJ8kP0YBh gOGtTlV5puw/aQlnK++SI79bgbb3X7wIG5TPyYU4LjDj15YsKeyow//5mFAJK9k9Udnn iW0KUllToqNJJBUH0RxW3Iscr2NudZ9PmhLxdEookGvRukxNkvH2kUFBZ/vuNgC2V+gZ 1oWg== 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=0PazlTtVfhEjw1y44qBaTCCffQGEbZCrOeMwdGeo05I=; b=IUJHUoDKzIjIaUmnJY2mfuli03wpP53/mrta+iYF2hUiouvB16nfS5MrQlWPe4ET+5 VJk0KuaQ+W1MTurdAIEjBxdJbCJm/sSt1CEFRNIbMPtAS7M4qvrJa18gPjuj8z6Bl+pf 1+tF7mxcnCBmYnjtOWOQE+je0o8i/BPW56FKhjHJPdGSrCCZpaB7Z0Idv7JEGU7796Lb ZtDEIu9M0JPv9Y5hCP/0oaD/LU52l6u46LWi2fWCSHsoEFsCzG2kqTYTcO+N0taSLTcD vIMO/Vt9IUELXx96wkUQwj5lmZDItyzhKHu+2GZQJMyRlwQepNVOku8WZRU8D+db/PrU e5fg== X-Gm-Message-State: APjAAAU4Mn6nYjqxn2NJPeNhNdXx5uPwtiSk7mX608yJWa7Vr3l+yA9o bHPyka3A4smX+WAB0VgN1ko= X-Google-Smtp-Source: APXvYqwKopDwoBoJb1FWDF8LUOlPsDlE5xQEZXt1I3keJPYYv+4bclS2cz05BcJf0sg4xtEwxqjKGg== X-Received: by 2002:a63:54b:: with SMTP id 72mr71579503pgf.323.1554291336040; Wed, 03 Apr 2019 04:35:36 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id x9sm29070765pfn.60.2019.04.03.04.35.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:34 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:30 +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 05/32] refs.c: remove the_repo from substitute_branch_name() Date: Wed, 3 Apr 2019 18:34:30 +0700 Message-Id: <20190403113457.20399-6-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 --- cache.h | 8 ++++++-- refs.c | 9 +++++---- sha1-name.c | 8 ++++++-- 3 files changed, 17 insertions(+), 8 deletions(-) diff --git a/cache.h b/cache.h index ac92421f3a..fcb24b5781 100644 --- a/cache.h +++ b/cache.h @@ -1468,8 +1468,12 @@ extern int parse_oid_hex(const char *hex, struct object_id *oid, const char **en #define INTERPRET_BRANCH_LOCAL (1<<0) #define INTERPRET_BRANCH_REMOTE (1<<1) #define INTERPRET_BRANCH_HEAD (1<<2) -extern int interpret_branch_name(const char *str, int len, struct strbuf *, - unsigned allowed); +int repo_interpret_branch_name(struct repository *r, + const char *str, int len, + struct strbuf *buf, + unsigned allowed); +#define interpret_branch_name(str, len, buf, allowed) \ + repo_interpret_branch_name(the_repository, str, len, buf, allowed) extern int get_oid_mb(const char *str, struct object_id *oid); extern int validate_headref(const char *ref); diff --git a/refs.c b/refs.c index 3dde824aab..44df049796 100644 --- a/refs.c +++ b/refs.c @@ -539,10 +539,11 @@ void expand_ref_prefix(struct argv_array *prefixes, const char *prefix) * later free()ing) if the string passed in is a magic short-hand form * to name a branch. */ -static char *substitute_branch_name(const char **string, int *len) +static char *substitute_branch_name(struct repository *r, + const char **string, int *len) { struct strbuf buf = STRBUF_INIT; - int ret = interpret_branch_name(*string, *len, &buf, 0); + int ret = repo_interpret_branch_name(r, *string, *len, &buf, 0); if (ret == *len) { size_t size; @@ -556,7 +557,7 @@ static char *substitute_branch_name(const char **string, int *len) int dwim_ref(const char *str, int len, struct object_id *oid, char **ref) { - char *last_branch = substitute_branch_name(&str, &len); + char *last_branch = substitute_branch_name(the_repository, &str, &len); int refs_found = expand_ref(str, len, oid, ref); free(last_branch); return refs_found; @@ -596,7 +597,7 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref) int dwim_log(const char *str, int len, struct object_id *oid, char **log) { - char *last_branch = substitute_branch_name(&str, &len); + char *last_branch = substitute_branch_name(the_repository, &str, &len); const char **p; int logs_found = 0; struct strbuf path = STRBUF_INIT; diff --git a/sha1-name.c b/sha1-name.c index 6dda2c16df..d535bb82f7 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1427,13 +1427,17 @@ static int interpret_branch_mark(const char *name, int namelen, return len + at; } -int interpret_branch_name(const char *name, int namelen, struct strbuf *buf, - unsigned allowed) +int repo_interpret_branch_name(struct repository *r, + const char *name, int namelen, + struct strbuf *buf, + unsigned allowed) { char *at; const char *start; int len; + if (r != the_repository) + BUG("interpret_branch_name() does not really use 'r' yet"); if (!namelen) namelen = strlen(name); From patchwork Wed Apr 3 11:34:31 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883507 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 6AD3E17E0 for ; Wed, 3 Apr 2019 11:35:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5539A289A5 for ; Wed, 3 Apr 2019 11:35:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 497FB289B4; Wed, 3 Apr 2019 11:35:43 +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 DE01B289A5 for ; Wed, 3 Apr 2019 11:35:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726591AbfDCLfm (ORCPT ); Wed, 3 Apr 2019 07:35:42 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:34039 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfl (ORCPT ); Wed, 3 Apr 2019 07:35:41 -0400 Received: by mail-pl1-f193.google.com with SMTP id y6so7916719plt.1 for ; Wed, 03 Apr 2019 04:35:41 -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=DLHFfdnN0jx4Qdk7kWZsPEECXBZdnTGBSUUpleGoRQ8=; b=UWJDhLB41qCyAEsmPhI/+7bHTzLVmuVCoJ8NkWvdPCpdkMAhVlDZ3cyWHf7y8m3G00 aioi2r3ZYPTxab6GYA+kvp4DVDv70iTCIKoGnwecgzSBj0CjCz45wsAtlVQIFzx7C62c Jus62+FtEs2MNxAPtOCwFrdZCDzkztYGa/j0fxEuMSxZA4fIC/xU6j2a0idyhZsOktim 0eJu4QZi6Lao1I47sX7nUknJnjGswKKgK7vdQ0fEcrnAtGpRXgnCE/65HoMVrE2EsAse yRaBHOSiR0XLhu90n+0ni9BisjjsSAs8A7GuHA73cj25aPv+SIywqBqYs6f7+Ou8WpSN QgmA== 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=DLHFfdnN0jx4Qdk7kWZsPEECXBZdnTGBSUUpleGoRQ8=; b=sS0zft8DSuwCVt8003hMW7Y4c45JPwhABWymnX1nrUgnys1l2I9CNpiLy6V2aj6o4h di1MXrlwC4IuMACBx0WBZAqfQ1B47zaGa9kCT9I7RQayvHCEWY3GR78lhiMOPL+xmTJD HbbjoKXi08NkTYJV0+fCkrgbpVN83aRaEuBtO2KednibIPt2iOs2awiJh+dPHcA8zgVX ZKwZ/Fqsdnx2KRd3Omde27+JP7ruISCliq8xfMyuvEEjxLtsa0dTPMtfebjyuRnFdRVB ehFUDFoMw/9z5FVQtIm97DoLBpp2Jullw0la7lEUkwpIuo5m2wG25CeS1+4tc3NDjEZq j6IA== X-Gm-Message-State: APjAAAWfXceBoNBiqMAWUORRpj2YuFgWm0v7eFNwyKkQb1VRn6co2F+E 71LIfjQ3pOmIoM4HvIfagMHylyjq X-Google-Smtp-Source: APXvYqwgwuK4gKPXELthcJ4MRbs8rCBagfRmwHpV2ZOZ11JBe1lL4n9/qA49mOaz8s3KckAZ1lKUhw== X-Received: by 2002:a17:902:b717:: with SMTP id d23mr57400969pls.260.1554291341160; Wed, 03 Apr 2019 04:35:41 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id r145sm13528663pgr.84.2019.04.03.04.35.38 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:40 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:36 +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 06/32] refs.c: remove the_repo from expand_ref() Date: Wed, 3 Apr 2019 18:34:31 +0700 Message-Id: <20190403113457.20399-7-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 | 10 ++++++---- refs.h | 2 +- upload-pack.c | 2 +- 3 files changed, 8 insertions(+), 6 deletions(-) diff --git a/refs.c b/refs.c index 44df049796..1f5864aa36 100644 --- a/refs.c +++ b/refs.c @@ -558,12 +558,13 @@ static char *substitute_branch_name(struct repository *r, int dwim_ref(const char *str, int len, struct object_id *oid, char **ref) { char *last_branch = substitute_branch_name(the_repository, &str, &len); - int refs_found = expand_ref(str, len, oid, ref); + int refs_found = expand_ref(the_repository, str, len, oid, ref); free(last_branch); return refs_found; } -int expand_ref(const char *str, int len, struct object_id *oid, char **ref) +int expand_ref(struct repository *repo, const char *str, int len, + struct object_id *oid, char **ref) { const char **p, *r; int refs_found = 0; @@ -578,8 +579,9 @@ int expand_ref(const char *str, int len, struct object_id *oid, char **ref) this_result = refs_found ? &oid_from_ref : oid; strbuf_reset(&fullref); strbuf_addf(&fullref, *p, len, str); - r = resolve_ref_unsafe(fullref.buf, RESOLVE_REF_READING, - this_result, &flag); + r = refs_resolve_ref_unsafe(get_main_ref_store(repo), + fullref.buf, RESOLVE_REF_READING, + this_result, &flag); if (r) { if (!refs_found++) *ref = xstrdup(r); diff --git a/refs.h b/refs.h index 5627570241..b630d5bde7 100644 --- a/refs.h +++ b/refs.h @@ -148,7 +148,7 @@ int refname_match(const char *abbrev_name, const char *full_name); struct argv_array; void expand_ref_prefix(struct argv_array *prefixes, const char *prefix); -int expand_ref(const char *str, int len, struct object_id *oid, char **ref); +int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); int dwim_ref(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); diff --git a/upload-pack.c b/upload-pack.c index d098ef5982..56505d60c3 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -834,7 +834,7 @@ static int process_deepen_not(const char *line, struct string_list *deepen_not, if (skip_prefix(line, "deepen-not ", &arg)) { char *ref = NULL; struct object_id oid; - if (expand_ref(arg, strlen(arg), &oid, &ref) != 1) + if (expand_ref(the_repository, arg, strlen(arg), &oid, &ref) != 1) die("git upload-pack: ambiguous deepen-not: %s", line); string_list_append(deepen_not, ref); free(ref); From patchwork Wed Apr 3 11:34:32 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883509 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 BD95B17E0 for ; Wed, 3 Apr 2019 11:35:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A645E289A5 for ; Wed, 3 Apr 2019 11:35:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 9AE6A289B4; Wed, 3 Apr 2019 11:35:48 +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 49D9A289A5 for ; Wed, 3 Apr 2019 11:35:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726600AbfDCLfr (ORCPT ); Wed, 3 Apr 2019 07:35:47 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:42278 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfq (ORCPT ); Wed, 3 Apr 2019 07:35:46 -0400 Received: by mail-pl1-f195.google.com with SMTP id cv12so7903327plb.9 for ; Wed, 03 Apr 2019 04:35:46 -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=10ZYZz/KCtQq+hTWl+4RRZs4YFEAPYAluyqXGvx5xco=; b=I0azJqg+2RC9DmG78QAbQk9P7cs6vpbf6iJqsD9PLDL0bP4kBTRIk8+ED9R0p3NcWF xIiqz5jypGgcJrXL9SNTzkRVPk3dX/VNumcRvYo+BKRESOmMPQDvFUXBtoNeO8i3IXMi YBGpNPhXXgPll6AXy43EgdaLhrSq0/N0jIasUCFIv/qMHPOOW1IG25hGSjaJiICf2Sh2 B4nJnYYJevmSk6yCzxvph5zMXFtfReAeGDoXl+YK6CDj9qyukONqPFUGPMj7Csv0J//g +V0CouctnwczcXztOZvUZ4JGUFe7kZ2osJgwOZI4qQ9Uht5L8V4XSs9v7txbHL2VlhhA OyoQ== 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=10ZYZz/KCtQq+hTWl+4RRZs4YFEAPYAluyqXGvx5xco=; b=oTv7hQE1Ufoi5jKVHTfQXRvrFostZ1hkaQqcYI7VjEqtmeYiJMVaWNQXVwxooOnyRW ie+OVMzpltgbDjUnppgugFe43bsneudaVW1cvJhH/UMtgkUs321TUe/3UzNGN+clcrWy tocR/yG/jY51vUcLDK6ULFTgGwuuRyCXkDF5MwUX4PmEesFbdl4jc9Ahs4x99JI6kvxO /tAgG6ve+xjjcFUgbqO66i4vl2WJMW5lILJ6KymQamqoVbJNGnW1bsbi+WBc2ukimLqZ tdc6S+82MkEBjniUJdUTd4Suw0RKha5wwkDMX7Kv1micMrcI3XL5n8ndWx60b8qOZAVR rGsg== X-Gm-Message-State: APjAAAVgVyq7jOBioNXQJ+CsZgrqOHPkBm9HgwnXZJgHDQq07AMDxBGw mkCrNqLD1R0lcEZhSQie5z4= X-Google-Smtp-Source: APXvYqxmhNOUw5Bd6L9zJKIdLWXEtOaAWknnp5fx+Ey0dQGElCmMm4KQixO+ox2XMTgg3wniu6oazw== X-Received: by 2002:a17:902:b715:: with SMTP id d21mr47825420pls.103.1554291346327; Wed, 03 Apr 2019 04:35:46 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id h64sm24660324pfj.40.2019.04.03.04.35.43 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:45 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:41 +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 07/32] refs.c: add repo_dwim_ref() Date: Wed, 3 Apr 2019 18:34:32 +0700 Message-Id: <20190403113457.20399-8-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 | 12 +++++++++--- refs.h | 1 + 2 files changed, 10 insertions(+), 3 deletions(-) diff --git a/refs.c b/refs.c index 1f5864aa36..bd0fec5776 100644 --- a/refs.c +++ b/refs.c @@ -555,14 +555,20 @@ static char *substitute_branch_name(struct repository *r, return NULL; } -int dwim_ref(const char *str, int len, struct object_id *oid, char **ref) +int repo_dwim_ref(struct repository *r, const char *str, int len, + struct object_id *oid, char **ref) { - char *last_branch = substitute_branch_name(the_repository, &str, &len); - int refs_found = expand_ref(the_repository, str, len, oid, ref); + char *last_branch = substitute_branch_name(r, &str, &len); + int refs_found = expand_ref(r, str, len, oid, ref); free(last_branch); return refs_found; } +int dwim_ref(const char *str, int len, struct object_id *oid, char **ref) +{ + return repo_dwim_ref(the_repository, str, len, oid, ref); +} + int expand_ref(struct repository *repo, const char *str, int len, struct object_id *oid, char **ref) { diff --git a/refs.h b/refs.h index b630d5bde7..fd3dc1d0f4 100644 --- a/refs.h +++ b/refs.h @@ -149,6 +149,7 @@ struct argv_array; void expand_ref_prefix(struct argv_array *prefixes, const char *prefix); int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); +int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); int dwim_ref(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); From patchwork Wed Apr 3 11:34:33 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883511 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 CDB14922 for ; Wed, 3 Apr 2019 11:35:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id B8D24289A5 for ; Wed, 3 Apr 2019 11:35:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id AD567289B4; Wed, 3 Apr 2019 11:35:53 +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 505DF289A5 for ; Wed, 3 Apr 2019 11:35:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726602AbfDCLfw (ORCPT ); Wed, 3 Apr 2019 07:35:52 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40958 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726078AbfDCLfw (ORCPT ); Wed, 3 Apr 2019 07:35:52 -0400 Received: by mail-pf1-f195.google.com with SMTP id c207so8024675pfc.7 for ; Wed, 03 Apr 2019 04:35:51 -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=szpMHP8EhvpaCOO0W8tVbc6AFYjGROhwwjWwnfbVc9o=; b=DBsjsY/gD8mkVNuv9pXhCUdijz0ZrJAbebRnBzuhTRF86TTEp8wP9g54SpwJOvRT7w h9/Jn2jFIpCEqS3Kk5uh4tVx5z7PtlfCijn6FVl5+Bc9154+ATRlb6y5/5i09mlMH5LB 6K5eabEDfmpuVIqmVb1tU9LJjury/qS+DFaVkeXKfN/jUHKNLEOVw0hkte7B3ECVocq0 cgpY8DkbEw8sderbYZRUEworDcDW1fYz8Xf4x8fXnU8jwXCh5aDph0PR4Fs4s0lbZn5F 4MPbzH7um3gvrE59Cb8cELZezixkPc0YroNzvb+yZEiomBfy1/BhUEmL4132U+3ris// 4+4Q== 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=szpMHP8EhvpaCOO0W8tVbc6AFYjGROhwwjWwnfbVc9o=; b=uM4q9xtYGkh5nFeEte03fZYg/EWJxHoWec6J4akMwcUYnounY8YTDMaNCWAqumVSwa HkZSK6NVjz425x54Fr3CFSKXmHToTGzAfu0Qz+mRbxaCCUCJ454LI8Ztxhvb2kPRWyL5 pEv2+yeWvmpQK0HLYPan7vstvDaweobk4/7dTj2DWIpF9uU1EJ50v/Ueh0uyUhPjwpfj fiDohOuRQWH0CpczO69v8wXHK/fanh1PIdPcUy6sVpBTSGUFoWWlFr/Mojzx+N+5AgL9 kKY5PPXPqWib2HiRNOBBv/sCryTwV3a13TJOTbJmtnhAUqrU0g9xA8lDC8NKVrTMGLq6 zmqQ== X-Gm-Message-State: APjAAAWKHXsQTXOSm8PfYLSToekdoQlauTRWYwggyT3+1YeS8/oxLKSt A3Mx7einPqZ7sxUHN/9EQBk= X-Google-Smtp-Source: APXvYqwioMhrj1km6XSJ1fsCbKYVsdORYz07NpF9m0p2g4OZSN6eaDHeewLsVVlCdoSShYTdKH/KAg== X-Received: by 2002:a63:1f61:: with SMTP id q33mr72053526pgm.325.1554291351457; Wed, 03 Apr 2019 04:35:51 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id t22sm19222215pgu.45.2019.04.03.04.35.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:50 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:46 +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 08/32] refs.c: add repo_dwim_log() Date: Wed, 3 Apr 2019 18:34:33 +0700 Message-Id: <20190403113457.20399-9-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 | 21 +++++++++++++++------ refs.h | 1 + 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/refs.c b/refs.c index bd0fec5776..edea001446 100644 --- a/refs.c +++ b/refs.c @@ -603,9 +603,11 @@ int expand_ref(struct repository *repo, const char *str, int len, return refs_found; } -int dwim_log(const char *str, int len, struct object_id *oid, char **log) +int repo_dwim_log(struct repository *r, const char *str, int len, + struct object_id *oid, char **log) { - char *last_branch = substitute_branch_name(the_repository, &str, &len); + struct ref_store *refs = get_main_ref_store(r); + char *last_branch = substitute_branch_name(r, &str, &len); const char **p; int logs_found = 0; struct strbuf path = STRBUF_INIT; @@ -617,13 +619,15 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log) strbuf_reset(&path); strbuf_addf(&path, *p, len, str); - ref = resolve_ref_unsafe(path.buf, RESOLVE_REF_READING, - &hash, NULL); + ref = refs_resolve_ref_unsafe(refs, path.buf, + RESOLVE_REF_READING, + &hash, NULL); if (!ref) continue; - if (reflog_exists(path.buf)) + if (refs_reflog_exists(refs, path.buf)) it = path.buf; - else if (strcmp(ref, path.buf) && reflog_exists(ref)) + else if (strcmp(ref, path.buf) && + refs_reflog_exists(refs, ref)) it = ref; else continue; @@ -639,6 +643,11 @@ int dwim_log(const char *str, int len, struct object_id *oid, char **log) 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); +} + static int is_per_worktree_ref(const char *refname) { return !strcmp(refname, "HEAD") || diff --git a/refs.h b/refs.h index fd3dc1d0f4..859dffe691 100644 --- a/refs.h +++ b/refs.h @@ -150,6 +150,7 @@ void expand_ref_prefix(struct argv_array *prefixes, const char *prefix); int expand_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); int repo_dwim_ref(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); +int repo_dwim_log(struct repository *r, const char *str, int len, struct object_id *oid, char **ref); int dwim_ref(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); From patchwork Wed Apr 3 11:34:34 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883513 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 B27DB922 for ; Wed, 3 Apr 2019 11:35:59 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 9C81C289A5 for ; Wed, 3 Apr 2019 11:35:59 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 90EA5289B4; Wed, 3 Apr 2019 11:35:59 +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 290AF289A5 for ; Wed, 3 Apr 2019 11:35:59 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726605AbfDCLf6 (ORCPT ); Wed, 3 Apr 2019 07:35:58 -0400 Received: from mail-pg1-f195.google.com ([209.85.215.195]:37846 "EHLO mail-pg1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLf5 (ORCPT ); Wed, 3 Apr 2019 07:35:57 -0400 Received: by mail-pg1-f195.google.com with SMTP id e6so3831298pgc.4 for ; Wed, 03 Apr 2019 04:35:57 -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=LaAroo8H6l5o6UF7G2ggzqIjs+ycGdPBE3mfbGzd8Qc=; b=VFk8cx1ZrhHh7VDn8V1fnKDdtTDSA6oVoXBY7OYH5cyQblqipr1qgZA8HwPaJusLC5 NZhdmtCfC59PHy3Wx8DyJKT/EY+W/B0W2zHpqCZE6Bq/zNkt0apWCAsqdC5O7iogEKA0 azytjXDUTjbJ+5h5nkCg6+laiRnDglG0nsMTXtOYpHH+TNaG+YbG5ceZ0V94clDLE+A0 waGpl3hJ5WBEwHOfFEhL7Ez4JBZ4NSlOJ4FZYprkSltLHQaCvUv01NcPNE4R60pqsas9 srPn/+catrR7sl5/pLiEkOqSmSX9F7xjb6h8xOmk7lO8F6+ihvNjTPALoU+pDPL4zQ+2 UXeA== 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=LaAroo8H6l5o6UF7G2ggzqIjs+ycGdPBE3mfbGzd8Qc=; b=EaGLoLkbWlv1zb9mJZzV51h96bIfEdm/SBli9S3k7TDQMY4NngD6+wDgjdTXY8Gmm/ TkajRrcK7pweZje4WeJQMVgsqT+VB9rpNzioR4km79BMnLdaV0GjZG+T4nGU085eO/nx 1wp7aYIkrR7O8MvyeKCrOEO0u/oBjYYxZh0bJbX5l1+p/JImHKawNf65PjHUBvL2PNMw 0LdvNv/kSHCGeJIWpqgtYBYcCaukPw/+pWGSnrVJ88wpwTlfFGBpIlmAujuuFx6xYXaz 0iUCjxGg8eAg+lhCfyDi3TimF5CYO11cn3L3gzZtZnRpSqu8E8WMHoDBYglBR6jhHADn m73Q== X-Gm-Message-State: APjAAAVR0OKtd7gx29kfVH4gjegzIOSe4geDFrYNc3yQNL418zwFXMyc MafHmgG2nAIfVWxkAQsGEfw= X-Google-Smtp-Source: APXvYqz+Nk/SJWpNjXHIQsQPqvUC1Eflq3LcYcYGrTGJ6fAkao++anN9bP9NDomljep3dO0YsMuVIw== X-Received: by 2002:a63:3185:: with SMTP id x127mr72136869pgx.299.1554291357209; Wed, 03 Apr 2019 04:35:57 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id i13sm19354706pgq.17.2019.04.03.04.35.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:35:56 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:51 +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 09/32] refs.c: remove the_repo from read_ref_at() Date: Wed, 3 Apr 2019 18:34:34 +0700 Message-Id: <20190403113457.20399-10-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 --- builtin/show-branch.c | 6 ++++-- refs.c | 7 ++++--- refs.h | 3 ++- sha1-name.c | 3 ++- 4 files changed, 12 insertions(+), 7 deletions(-) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index 934e514944..082daeac32 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -753,7 +753,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) /* Ah, that is a date spec... */ timestamp_t at; at = approxidate(reflog_base); - read_ref_at(ref, flags, at, -1, &oid, NULL, + read_ref_at(get_main_ref_store(the_repository), + ref, flags, at, -1, &oid, NULL, NULL, NULL, &base); } } @@ -765,7 +766,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) timestamp_t timestamp; int tz; - if (read_ref_at(ref, flags, 0, base + i, &oid, &logmsg, + if (read_ref_at(get_main_ref_store(the_repository), + ref, flags, 0, base + i, &oid, &logmsg, ×tamp, &tz, NULL)) { reflog = i; break; diff --git a/refs.c b/refs.c index edea001446..92d1f6dbdd 100644 --- a/refs.c +++ b/refs.c @@ -967,7 +967,8 @@ static int read_ref_at_ent_oldest(struct object_id *ooid, struct object_id *noid return 1; } -int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, int cnt, +int read_ref_at(struct ref_store *refs, const char *refname, + unsigned int flags, timestamp_t at_time, int cnt, struct object_id *oid, char **msg, timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt) { @@ -983,7 +984,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in cb.cutoff_cnt = cutoff_cnt; cb.oid = oid; - for_each_reflog_ent_reverse(refname, read_ref_at_ent, &cb); + refs_for_each_reflog_ent_reverse(refs, refname, read_ref_at_ent, &cb); if (!cb.reccnt) { if (flags & GET_OID_QUIETLY) @@ -994,7 +995,7 @@ int read_ref_at(const char *refname, unsigned int flags, timestamp_t at_time, in if (cb.found_it) return 0; - for_each_reflog_ent(refname, read_ref_at_ent_oldest, &cb); + refs_for_each_reflog_ent(refs, refname, read_ref_at_ent_oldest, &cb); return 1; } diff --git a/refs.h b/refs.h index 859dffe691..8f9cbf8a93 100644 --- a/refs.h +++ b/refs.h @@ -388,7 +388,8 @@ int refs_create_reflog(struct ref_store *refs, const char *refname, int safe_create_reflog(const char *refname, int force_create, struct strbuf *err); /** Reads log for the value of ref during at_time. **/ -int read_ref_at(const char *refname, unsigned int flags, +int read_ref_at(struct ref_store *refs, + const char *refname, unsigned int flags, timestamp_t at_time, int cnt, struct object_id *oid, char **msg, timestamp_t *cutoff_time, int *cutoff_tz, int *cutoff_cnt); diff --git a/sha1-name.c b/sha1-name.c index d535bb82f7..15a1107998 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -849,7 +849,8 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, return -1; } } - if (read_ref_at(real_ref, flags, at_time, nth, oid, NULL, + if (read_ref_at(get_main_ref_store(the_repository), + real_ref, flags, at_time, nth, oid, NULL, &co_time, &co_tz, &co_cnt)) { if (!len) { if (starts_with(real_ref, "refs/heads/")) { From patchwork Wed Apr 3 11:34:35 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883515 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 95BAF17E0 for ; Wed, 3 Apr 2019 11:36:05 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 7DE76289A5 for ; Wed, 3 Apr 2019 11:36:05 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 6F4F2289B4; Wed, 3 Apr 2019 11:36:05 +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 5CA56289A5 for ; Wed, 3 Apr 2019 11:36:04 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726263AbfDCLgD (ORCPT ); Wed, 3 Apr 2019 07:36:03 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:34499 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgD (ORCPT ); Wed, 3 Apr 2019 07:36:03 -0400 Received: by mail-pf1-f195.google.com with SMTP id b3so8023365pfd.1 for ; Wed, 03 Apr 2019 04:36:02 -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=D/Adi1r61sibAZ06FAoFtOkjnokXL4vXDquRsCSKByU=; b=a/ZrNOp/y5823DKdvffo09NRn76Kv+JSnRIm5i14SMg84Rk2qawGnKNoxnH/cOndys T/MnViKFWu/DEGHImF/YK4NcEJcXPME5cMvg0vIUnyLxMQtXvyQ5vmAa0FXZ4rvb1Wpj KUBFAgeux2sgf1BPeKtk5/Io08sGVMZhqGY8fiQ9xQARmhOSo6MVQdFDDIgcx4aBtTkW T69f1j8nHjxQfFe5/4NIUCDtP17QGEgyg1a2ntEvNR4Ke8jYEKczuxIgy9mJTxEwyIBR uiUye1pF3xB7rxPrpx0QOo1BwVtGcbpaLA2bO07pAaQKodXdJHIdWV5ym9e/Hs5IeRCx Go1A== 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=D/Adi1r61sibAZ06FAoFtOkjnokXL4vXDquRsCSKByU=; b=hnSilQaPs2gcsnsK/NO5PrGfjTnDLqRkKHCorSVtHXgHOF5m5oECMUrI/fX5RqUxU5 uIGhVA5nyXhg6hz1hHS+HUXoySBUSJwA+AlNHkQYD9IImPJXxSUTIQA68P74r25EF2kR +O2P93tCtNG/QVW/fUgxv0LL9wsybqnApNrczsgRf3HkaNdYZfdE2i5+gPef/PbWR4Xr PjKlJYH48Q8CCEo7qNEtGmlSCGOzEisbHLzHOhMN1JXpTCfxVweDWNFs4dbUC7RS+mXk GAa4z1W+goPikASSc7kLcdt0se/eF8FmEXvg2ha+7bwG2NJTh0JcZNoUaR8WsH079CmN 3f1g== X-Gm-Message-State: APjAAAXT92ZYTCqMJP5uUq6tb8uE52CxzvIPXbJR9Tztkho6ITfyFw2c O5EYumKO2RSVvDJInT4dNOc= X-Google-Smtp-Source: APXvYqz36pa8Inl8IQUHusp+3dJ7bWVScmGkogfdq++u/OGMMJu8oBOJNa9VZBfPHwW3pQIF1FUc8A== X-Received: by 2002:a63:3d4c:: with SMTP id k73mr55812737pga.154.1554291362501; Wed, 03 Apr 2019 04:36:02 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id d3sm24241332pfn.113.2019.04.03.04.35.59 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:01 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:35:57 +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 10/32] commit.c: add repo_get_commit_tree() Date: Wed, 3 Apr 2019 18:34:35 +0700 Message-Id: <20190403113457.20399-11-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 Signed-off-by: Johannes Schindelin --- commit.c | 5 +++-- commit.h | 3 ++- contrib/coccinelle/commit.cocci | 4 ++-- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/commit.c b/commit.c index a5333c7ac6..f0a5506f04 100644 --- a/commit.c +++ b/commit.c @@ -340,7 +340,8 @@ void free_commit_buffer(struct parsed_object_pool *pool, struct commit *commit) } } -struct tree *get_commit_tree(const struct commit *commit) +struct tree *repo_get_commit_tree(struct repository *r, + const struct commit *commit) { if (commit->maybe_tree || !commit->object.parsed) return commit->maybe_tree; @@ -348,7 +349,7 @@ struct tree *get_commit_tree(const struct commit *commit) if (commit->graph_pos == COMMIT_NOT_FROM_GRAPH) BUG("commit has NULL tree, but was not loaded from commit-graph"); - return get_commit_tree_in_graph(the_repository, commit); + return get_commit_tree_in_graph(r, commit); } struct object_id *get_commit_tree_oid(const struct commit *commit) diff --git a/commit.h b/commit.h index 42728c2906..b576201be8 100644 --- a/commit.h +++ b/commit.h @@ -143,7 +143,8 @@ void repo_unuse_commit_buffer(struct repository *r, */ void free_commit_buffer(struct parsed_object_pool *pool, struct commit *); -struct tree *get_commit_tree(const struct commit *); +struct tree *repo_get_commit_tree(struct repository *, const struct commit *); +#define get_commit_tree(c) repo_get_commit_tree(the_repository, c) struct object_id *get_commit_tree_oid(const struct commit *); /* diff --git a/contrib/coccinelle/commit.cocci b/contrib/coccinelle/commit.cocci index c49aa558f0..f5bc639981 100644 --- a/contrib/coccinelle/commit.cocci +++ b/contrib/coccinelle/commit.cocci @@ -12,12 +12,12 @@ expression c; // These excluded functions must access c->maybe_tree direcly. @@ -identifier f !~ "^(get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit)$"; +identifier f !~ "^(repo_get_commit_tree|get_commit_tree_in_graph_one|load_tree_for_commit)$"; expression c; @@ f(...) {<... - c->maybe_tree -+ get_commit_tree(c) ++ repo_get_commit_tree(the_repository, c) ...>} @@ From patchwork Wed Apr 3 11:34:36 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883517 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 45FE617E0 for ; Wed, 3 Apr 2019 11:36:11 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2EDF5289A5 for ; Wed, 3 Apr 2019 11:36:11 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 233E5289D0; Wed, 3 Apr 2019 11:36:11 +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 C28EC289A5 for ; Wed, 3 Apr 2019 11:36:10 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726614AbfDCLgJ (ORCPT ); Wed, 3 Apr 2019 07:36:09 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43354 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgI (ORCPT ); Wed, 3 Apr 2019 07:36:08 -0400 Received: by mail-pf1-f194.google.com with SMTP id c8so8012912pfd.10 for ; Wed, 03 Apr 2019 04:36:07 -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=aTA8uZjHYmU6mFrJRdjj2PyQx8+QjT2oIRRXCztOqnU=; b=MEb+WwOLBxK/06qx28qxXXa2s1b5HOex5/3ABt+LjdJ6Cq3BQ7zzu0zW2LuVxW0dlD G7k7AF+nw3+c8AFzg4Hm52ua70GzDcW7enLkOcT/9Uy7hFbf2gXSjxLgolqiYvLOLEhe XjvwpbZzrlQ8+XrOn7wsKWKG9cW76uh07nCNP8Te147NwvtsnY7DcMcSpWHB2drsneCg m9bojM3Vvr1Xgw/kwGbXbCkUHZ45K/LR0zaIddnraAgkezBhBjcJadrCmpYNFnWfwF3N +HhHXBrfI07Ey0i2uCYYjkAbo+OYC4hSwGGasDMEga4ZsCev071WctJdulGX1f9ozrTx Mfag== 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=aTA8uZjHYmU6mFrJRdjj2PyQx8+QjT2oIRRXCztOqnU=; b=JshuOcxflG3zrFlLMgj2YLmqCMq/VQYiwmHeBi6uEsgTN/opK24SyUTIfa8HdrErvF gp2HUm9rPfZOK8+m/dAxMiC0wIwCrz3ZVeT3HaGQkKWnER7we0U+2egMpvpBOVeJMHlS ZxxjMEhmJguUxGfr5SGnCPdHI7Kb47kI1DuKPkvU3mSsCmQXcxRmUi5gZtRiBqPM9Bh2 0W8M2RlXFY4BwCCxdlrzOhT6HPiupUaNs+7ZVlCSE3tOhkUs1xLHFXy7UlqWrXgA+p1N /FvckNh8cdYK9nvfFaphaPMqCcKH6ncKl4Ka4KE5O0z1W7krVz3fdYjT478doJRGyJnr Mq0w== X-Gm-Message-State: APjAAAWOMp6kE2aZZ9H96SFbdtcTndJtz1LOxbGOVkkYw8xiv8N3Hq3t p9Pfuk/tMLaPsZ83CA7umLs= X-Google-Smtp-Source: APXvYqxAegG51H1MAAdlADCyAUDQnkNVrzjtwCyBxQ/bp+PXNFFK2+o0hD+V6ep3evFX9l3u+HerAw== X-Received: by 2002:a63:2015:: with SMTP id g21mr48802444pgg.226.1554291367622; Wed, 03 Apr 2019 04:36:07 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id l74sm25042238pfi.174.2019.04.03.04.36.04 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:07 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:02 +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 11/32] sha1-name.c: remove the_repo from sort_ambiguous() Date: Wed, 3 Apr 2019 18:34:36 +0700 Message-Id: <20190403113457.20399-12-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 --- sha1-name.c | 15 ++++++++++++--- 1 file changed, 12 insertions(+), 3 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 15a1107998..7558ce51a3 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -383,10 +383,11 @@ static int collect_ambiguous(const struct object_id *oid, void *data) return 0; } +static struct repository *sort_ambiguous_repo; static int sort_ambiguous(const void *a, const void *b) { - int a_type = oid_object_info(the_repository, a, NULL); - int b_type = oid_object_info(the_repository, b, NULL); + int a_type = oid_object_info(sort_ambiguous_repo, a, NULL); + int b_type = oid_object_info(sort_ambiguous_repo, b, NULL); int a_type_sort; int b_type_sort; @@ -411,6 +412,14 @@ static int sort_ambiguous(const void *a, const void *b) return a_type_sort > b_type_sort ? 1 : -1; } +static void sort_ambiguous_oid_array(struct repository *r, struct oid_array *a) +{ + /* mutex will be needed if this code is to be made thread safe */ + sort_ambiguous_repo = r; + QSORT(a->oid, a->nr, sort_ambiguous); + sort_ambiguous_repo = NULL; +} + static enum get_oid_result get_short_oid(const char *name, int len, struct object_id *oid, unsigned flags) @@ -458,7 +467,7 @@ static enum get_oid_result get_short_oid(const char *name, int len, advise(_("The candidates are:")); for_each_abbrev(ds.hex_pfx, collect_ambiguous, &collect); - QSORT(collect.oid, collect.nr, sort_ambiguous); + sort_ambiguous_oid_array(the_repository, &collect); if (oid_array_for_each(&collect, show_ambiguous_object, &ds)) BUG("show_ambiguous_object shouldn't return non-zero"); From patchwork Wed Apr 3 11:34:37 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883519 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 73C1517E0 for ; Wed, 3 Apr 2019 11:36:15 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5EBD8289A5 for ; Wed, 3 Apr 2019 11:36:15 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5358C289C0; Wed, 3 Apr 2019 11:36:15 +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 034A1289A5 for ; Wed, 3 Apr 2019 11:36:15 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726624AbfDCLgO (ORCPT ); Wed, 3 Apr 2019 07:36:14 -0400 Received: from mail-pl1-f196.google.com ([209.85.214.196]:43334 "EHLO mail-pl1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgN (ORCPT ); Wed, 3 Apr 2019 07:36:13 -0400 Received: by mail-pl1-f196.google.com with SMTP id m10so7897684plt.10 for ; Wed, 03 Apr 2019 04:36:13 -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=0Sww8ndWyCxak9+iI+JOYHneVIA0yT5/XJ9VtPjuYpA=; b=KFr4lhcGDuVhrk/38+h/AtbYQP0nD8CEYcr1NamEFWFrP4SCoIswGQlXYs0QvlBKyf vEQ9D0cn4c11WRHJTDByb01r30NC6nfiSXpfmjALgifrkOQxw1dxKvuVRf9EEMABXZRf ia00+CwLk3kVLCp66OC7Nb5I4qm+uIdEFiPxL9HjUlA6oTjZZ54fP4MGnjLOkwcIjHK1 TNIfpHthAgNGscbqjSrxLgHF++G328cgJWYGSisuF+aQb1CLxOmMfDUQ/wLfJLmnWgXE IZ0+4pV4Omgiwdpa4YnWPktnzeti+89TQ6PbUXJjlOJcVlzBdl2/dAzPqU5XEC82tVck BCKA== 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=0Sww8ndWyCxak9+iI+JOYHneVIA0yT5/XJ9VtPjuYpA=; b=lysLMJtWd2RvL/f4qGOI1IzfGqDaftkUVxwyyOassHdmSz6KIIDoD3ViVZyNY8962p xb/teYIRLciqo+WMvji3XwFEwFaDD1lbtRNs00aeyNIoZ/qGrjeBi5FDJ+gCixq3tA9L E+yBhHFACbvLBgLE+h9MtMbDwzxCsyIsNIFOKj8RUGlljNWkqzQciql77WM+Nao5zAjO 4LpQMEeZ9nYmQN69XsQw7SUA47mRoNuTSlmQOv/OBdRq3asqwiiobOIsRK8rhgrTaOU6 eoB38038t7wsuUBY6GhyRUkDO6wGkGw3XNIDmBfaDaMnX5U9LXZZHq/gyXWdCwyLeUvO irlw== X-Gm-Message-State: APjAAAXCJwgit3CH6oIYw5+y7zXenVd9ohz0rr4H/R0q/CWbMmV4FAP5 anFznskRpUahoqTL3E21rm8= X-Google-Smtp-Source: APXvYqz1LSCqGBiWN/5aMeaSH3ePCblXUbD+1JDewZ7verqc1Ke7mWiUdDxIDZdolQ84g7GjNEfjbg== X-Received: by 2002:a17:902:2b88:: with SMTP id l8mr24150393plb.262.1554291372757; Wed, 03 Apr 2019 04:36:12 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id 75sm28611618pfr.55.2019.04.03.04.36.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:12 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:07 +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 12/32] sha1-name.c: remove the_repo from find_abbrev_len_packed() Date: Wed, 3 Apr 2019 18:34:37 +0700 Message-Id: <20190403113457.20399-13-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 --- sha1-name.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 7558ce51a3..b9381aaba6 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -514,6 +514,7 @@ struct min_abbrev_data { unsigned int init_len; unsigned int cur_len; char *hex; + struct repository *repo; const struct object_id *oid; }; @@ -619,9 +620,9 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad) struct multi_pack_index *m; struct packed_git *p; - for (m = get_multi_pack_index(the_repository); m; m = m->next) + for (m = get_multi_pack_index(mad->repo); m; m = m->next) find_abbrev_len_for_midx(m, mad); - for (p = get_packed_git(the_repository); p; p = p->next) + for (p = get_packed_git(mad->repo); p; p = p->next) find_abbrev_len_for_pack(p, mad); } @@ -658,6 +659,7 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len) if (len == hexsz || !len) return hexsz; + mad.repo = the_repository; mad.init_len = len; mad.cur_len = len; mad.hex = hex; From patchwork Wed Apr 3 11:34:38 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883521 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 972A4922 for ; Wed, 3 Apr 2019 11:36:21 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 816A1289A5 for ; Wed, 3 Apr 2019 11:36:21 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 75E85289C0; Wed, 3 Apr 2019 11:36:21 +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 1334B289A5 for ; Wed, 3 Apr 2019 11:36:21 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726630AbfDCLgU (ORCPT ); Wed, 3 Apr 2019 07:36:20 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:44109 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgT (ORCPT ); Wed, 3 Apr 2019 07:36:19 -0400 Received: by mail-pg1-f196.google.com with SMTP id i2so8179901pgj.11 for ; Wed, 03 Apr 2019 04:36:19 -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=Z3tl6C17iYwwBOSBKh5AtgHHBV5w/wvyG2a5No1/lCw=; b=L1eEl/42XtHRVUa4ZQukAtR2EAQVs3vgb/tK/OKJ/jBBhSum7Tr+hyZs+KLx8zoEoI 6nR5aJQxLoFUWXbYoWmmDL0uJzXlbAIc3/RHuTWBa8BXskrRgKmyPk1AP4fPdZI7kCa4 fMMGwLPIRaKMJGSDpE5/Dm8gYFL3YUPghvxRmGG+sMKKHJj0bWvVrMIxP3aVEJbHTpVj yV3nQPPQNX+0L+1mjNAG455WYGuDesQNvdmE4+a9tLukPWPkgmt5KWxYurT7XNuZrNTk ujj537NSZnMOUop09KCPi16F4ZoiwJJ5Ik7bIOu//3CydBf1tdftbesecT400W7bDkWu pJww== 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=Z3tl6C17iYwwBOSBKh5AtgHHBV5w/wvyG2a5No1/lCw=; b=fKskH4nz98ujnAL9Tl62mU/vZ5XNUkbc90vPn0icRv2PaBRvwc9nR7JsTaF4p6Co0T ekL3erOaH+gti3CovsF1gum4rgde1dISoNdKg0HOdaXJfVJVyYNPQ/mbgRYB2Ncn7dib tGtWWFITcQsQ2Bf+4KxOkzLSwkP00JBH1UcDCAl+4v3STyNYskKjuh7an939aqcUszbQ REJ8iY8CdWxaDHy/KUwCRORoezRyZ1ADRUeupIeghaUWIZNZge4+x6oVuSv50jD7aai7 Uku+nm+Du7pBluS4kTYKz/oazdAkCHkQ02tk14IoNCOQYdZhG0SB31MqaONnh9/PZJdq UfMA== X-Gm-Message-State: APjAAAV5pAMtigJkrzSn7BjltoDMe1xUfESMIeLq8MOvPcacVD8IUD3W dJRStgFepnmg8yPoXK8W+dE= X-Google-Smtp-Source: APXvYqz+r5ZBeQh7gdpWpBYGUf6Xd5x9zBkTLI31SI+W+dX9b+t7DwqEnqVkTWmaSaSrDTyGZtF07Q== X-Received: by 2002:a63:360e:: with SMTP id d14mr58972259pga.188.1554291379167; Wed, 03 Apr 2019 04:36:19 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id a12sm17881795pgq.21.2019.04.03.04.36.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:17 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:13 +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 13/32] sha1-name.c: add repo_find_unique_abbrev_r() Date: Wed, 3 Apr 2019 18:34:38 +0700 Message-Id: <20190403113457.20399-14-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 --- cache.h | 6 ++++-- sha1-name.c | 15 +++++++++------ 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cache.h b/cache.h index fcb24b5781..4f8ebb0a67 100644 --- a/cache.h +++ b/cache.h @@ -1045,8 +1045,10 @@ extern void check_repository_format(void); * Note that while this version avoids the static buffer, it is not fully * reentrant, as it calls into other non-reentrant git code. */ -extern const char *find_unique_abbrev(const struct object_id *oid, int len); -extern int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len); +const char *repo_find_unique_abbrev(struct repository *r, const struct object_id *oid, int len); +#define find_unique_abbrev(oid, len) repo_find_unique_abbrev(the_repository, oid, len) +int repo_find_unique_abbrev_r(struct repository *r, char *hex, const struct object_id *oid, int len); +#define find_unique_abbrev_r(hex, oid, len) repo_find_unique_abbrev_r(the_repository, hex, oid, len) extern const unsigned char null_sha1[GIT_MAX_RAWSZ]; extern const struct object_id null_oid; diff --git a/sha1-name.c b/sha1-name.c index b9381aaba6..9b57787b76 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -626,15 +626,16 @@ static void find_abbrev_len_packed(struct min_abbrev_data *mad) find_abbrev_len_for_pack(p, mad); } -int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len) +int repo_find_unique_abbrev_r(struct repository *r, char *hex, + const struct object_id *oid, int len) { struct disambiguate_state ds; struct min_abbrev_data mad; struct object_id oid_ret; - const unsigned hexsz = the_hash_algo->hexsz; + const unsigned hexsz = r->hash_algo->hexsz; if (len < 0) { - unsigned long count = approximate_object_count(); + unsigned long count = repo_approximate_object_count(r); /* * Add one because the MSB only tells us the highest bit set, * not including the value of all the _other_ bits (so "15" @@ -659,7 +660,7 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len) if (len == hexsz || !len) return hexsz; - mad.repo = the_repository; + mad.repo = r; mad.init_len = len; mad.cur_len = len; mad.hex = hex; @@ -681,13 +682,15 @@ int find_unique_abbrev_r(char *hex, const struct object_id *oid, int len) return mad.cur_len; } -const char *find_unique_abbrev(const struct object_id *oid, int len) +const char *repo_find_unique_abbrev(struct repository *r, + const struct object_id *oid, + int len) { static int bufno; static char hexbuffer[4][GIT_MAX_HEXSZ + 1]; char *hex = hexbuffer[bufno]; bufno = (bufno + 1) % ARRAY_SIZE(hexbuffer); - find_unique_abbrev_r(hex, oid, len); + repo_find_unique_abbrev_r(r, hex, oid, len); return hex; } From patchwork Wed Apr 3 11:34:39 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883523 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 A486117E0 for ; Wed, 3 Apr 2019 11:36:27 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8E9B7289A5 for ; Wed, 3 Apr 2019 11:36:27 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 827CC289C0; Wed, 3 Apr 2019 11:36:27 +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 AC791289A5 for ; Wed, 3 Apr 2019 11:36:26 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726640AbfDCLgZ (ORCPT ); Wed, 3 Apr 2019 07:36:25 -0400 Received: from mail-pl1-f195.google.com ([209.85.214.195]:40299 "EHLO mail-pl1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgZ (ORCPT ); Wed, 3 Apr 2019 07:36:25 -0400 Received: by mail-pl1-f195.google.com with SMTP id b3so4926034plr.7 for ; Wed, 03 Apr 2019 04:36: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=Zkk+sKvuQ3qNLst7Ye1UEl3IZh2DQklA0UBtoCRshnY=; b=J+yb5am9X/eRjZ6nILOLT9ByxGz7sR4dwxaslFiLOpkMpvVTs1JYvAhlKqLtbw99Jy pHwDmLdwWlOlkOB+GFz2Fma7uZYRUbZJivixJ2rY8zNdyOEOYXF29TFdcs8/eXSmKin2 pp8kaESS4pxY7tqhMnryZJYJK0CP2dqSO24ExYT63arC24rDt+zf/qcizDbi8sgE0iZB LApFGnAym+VLCxS1Fmg3PP4UEiaRe/egdJcbV+DxbnTH0M+PsDzEsZRZHDw2Ffpq1uND LXCbtoYFk+EiDZqvh72p27B9+cmrIRIud+E/yIFduU/m5cloScUQy/1+dxxe4aJRgGUf vezA== 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=Zkk+sKvuQ3qNLst7Ye1UEl3IZh2DQklA0UBtoCRshnY=; b=DrvOTu+p7bEbrpHwZcOJmTuGXhZjFo+feNK82g+h9Qig9JqsWy3p07sgAug1srsa53 mPYzkCNgoRHpoBxT9FtI/PeAAGFyzPWjvmQO7z8evT6r/tnYvkD+orA6/pbhwkrYjEOp ZOWFptTAdzPEHGHdDuIyiZ8wZJXu6rVzXL/gfaZJrW/kHhlIHkMVDzAnPwl0wYsJy5oF 3fLEgqLAA9ZL+rNnZNMUtjt04vQDv3ALYz/62ZVNeDKgF4K0jkqVulR0ONzlpEiMFm5Z HiQMDlqAXvd0AX7A04M4PxS7+IF/0UqTqZjKnHur02bXOI/IUSg0FqfBwNMhFN/fxM6x XkAw== X-Gm-Message-State: APjAAAXRtA/fin1ZhF+Sb05Cccyth3fZIO+S4xczq1O/y+CE2MF8OJwE MNZ5k3y354ZfDsrLHKkg9AI= X-Google-Smtp-Source: APXvYqxt5Rpzd0r17M5MQETxvM+dqu0Qb/LmLICe3MUbDnJNtLEwtP4A1eK5yHGKMmuzlqZl4R9O9g== X-Received: by 2002:a17:902:407:: with SMTP id 7mr76686752ple.62.1554291384489; Wed, 03 Apr 2019 04:36:24 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id e22sm21675386pfi.126.2019.04.03.04.36.21 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:23 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36: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 14/32] sha1-name.c: store and use repo in struct disambiguate_state Date: Wed, 3 Apr 2019 18:34:39 +0700 Message-Id: <20190403113457.20399-15-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 --- sha1-name.c | 95 +++++++++++++++++++++++++++++++++-------------------- 1 file changed, 59 insertions(+), 36 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 9b57787b76..a75992eb54 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -17,13 +17,14 @@ static int get_oid_oneline(const char *, struct object_id *, struct commit_list *); -typedef int (*disambiguate_hint_fn)(const struct object_id *, void *); +typedef int (*disambiguate_hint_fn)(struct repository *, const struct object_id *, void *); struct disambiguate_state { int len; /* length of prefix in hex chars */ char hex_pfx[GIT_MAX_HEXSZ + 1]; struct object_id bin_pfx; + struct repository *repo; disambiguate_hint_fn fn; void *cb_data; struct object_id candidate; @@ -38,7 +39,7 @@ struct disambiguate_state { static void update_candidates(struct disambiguate_state *ds, const struct object_id *current) { if (ds->always_call_fn) { - ds->ambiguous = ds->fn(current, ds->cb_data) ? 1 : 0; + ds->ambiguous = ds->fn(ds->repo, current, ds->cb_data) ? 1 : 0; return; } if (!ds->candidate_exists) { @@ -58,7 +59,7 @@ static void update_candidates(struct disambiguate_state *ds, const struct object } if (!ds->candidate_checked) { - ds->candidate_ok = ds->fn(&ds->candidate, ds->cb_data); + ds->candidate_ok = ds->fn(ds->repo, &ds->candidate, ds->cb_data); ds->disambiguate_fn_used = 1; ds->candidate_checked = 1; } @@ -71,7 +72,7 @@ static void update_candidates(struct disambiguate_state *ds, const struct object } /* if we reach this point, we know ds->candidate satisfies fn */ - if (ds->fn(current, ds->cb_data)) { + if (ds->fn(ds->repo, current, ds->cb_data)) { /* * if both current and candidate satisfy fn, we cannot * disambiguate. @@ -89,9 +90,7 @@ static void find_short_object_filename(struct disambiguate_state *ds) { struct object_directory *odb; - for (odb = the_repository->objects->odb; - odb && !ds->ambiguous; - odb = odb->next) { + for (odb = ds->repo->objects->odb; odb && !ds->ambiguous; odb = odb->next) { int pos; struct oid_array *loose_objects; @@ -182,10 +181,10 @@ static void find_short_packed_object(struct disambiguate_state *ds) struct multi_pack_index *m; struct packed_git *p; - for (m = get_multi_pack_index(the_repository); m && !ds->ambiguous; + for (m = get_multi_pack_index(ds->repo); m && !ds->ambiguous; m = m->next) unique_in_midx(m, ds); - for (p = get_packed_git(the_repository); p && !ds->ambiguous; + for (p = get_packed_git(ds->repo); p && !ds->ambiguous; p = p->next) unique_in_pack(p, ds); } @@ -215,7 +214,7 @@ static int finish_object_disambiguation(struct disambiguate_state *ds, * same repository! */ ds->candidate_ok = (!ds->disambiguate_fn_used || - ds->fn(&ds->candidate, ds->cb_data)); + ds->fn(ds->repo, &ds->candidate, ds->cb_data)); if (!ds->candidate_ok) return SHORT_NAME_AMBIGUOUS; @@ -224,59 +223,67 @@ static int finish_object_disambiguation(struct disambiguate_state *ds, return 0; } -static int disambiguate_commit_only(const struct object_id *oid, void *cb_data_unused) +static int disambiguate_commit_only(struct repository *r, + const struct object_id *oid, + void *cb_data_unused) { - int kind = oid_object_info(the_repository, oid, NULL); + int kind = oid_object_info(r, oid, NULL); return kind == OBJ_COMMIT; } -static int disambiguate_committish_only(const struct object_id *oid, void *cb_data_unused) +static int disambiguate_committish_only(struct repository *r, + const struct object_id *oid, + void *cb_data_unused) { struct object *obj; int kind; - kind = oid_object_info(the_repository, oid, NULL); + kind = oid_object_info(r, oid, NULL); if (kind == OBJ_COMMIT) return 1; if (kind != OBJ_TAG) return 0; /* We need to do this the hard way... */ - obj = deref_tag(the_repository, parse_object(the_repository, oid), - NULL, 0); + obj = deref_tag(r, parse_object(r, oid), NULL, 0); if (obj && obj->type == OBJ_COMMIT) return 1; return 0; } -static int disambiguate_tree_only(const struct object_id *oid, void *cb_data_unused) +static int disambiguate_tree_only(struct repository *r, + const struct object_id *oid, + void *cb_data_unused) { - int kind = oid_object_info(the_repository, oid, NULL); + int kind = oid_object_info(r, oid, NULL); return kind == OBJ_TREE; } -static int disambiguate_treeish_only(const struct object_id *oid, void *cb_data_unused) +static int disambiguate_treeish_only(struct repository *r, + const struct object_id *oid, + void *cb_data_unused) { struct object *obj; int kind; - kind = oid_object_info(the_repository, oid, NULL); + kind = oid_object_info(r, oid, NULL); if (kind == OBJ_TREE || kind == OBJ_COMMIT) return 1; if (kind != OBJ_TAG) return 0; /* We need to do this the hard way... */ - obj = deref_tag(the_repository, parse_object(the_repository, oid), - NULL, 0); + obj = deref_tag(r, parse_object(r, oid), NULL, 0); if (obj && (obj->type == OBJ_TREE || obj->type == OBJ_COMMIT)) return 1; return 0; } -static int disambiguate_blob_only(const struct object_id *oid, void *cb_data_unused) +static int disambiguate_blob_only(struct repository *r, + const struct object_id *oid, + void *cb_data_unused) { - int kind = oid_object_info(the_repository, oid, NULL); + int kind = oid_object_info(r, oid, NULL); return kind == OBJ_BLOB; } @@ -310,7 +317,8 @@ int set_disambiguate_hint_config(const char *var, const char *value) return error("unknown hint type for '%s': %s", var, value); } -static int init_object_disambiguation(const char *name, int len, +static int init_object_disambiguation(struct repository *r, + const char *name, int len, struct disambiguate_state *ds) { int i; @@ -341,7 +349,8 @@ static int init_object_disambiguation(const char *name, int len, ds->len = len; ds->hex_pfx[len] = '\0'; - prepare_alt_odb(the_repository); + ds->repo = r; + prepare_alt_odb(r); return 0; } @@ -351,25 +360,25 @@ static int show_ambiguous_object(const struct object_id *oid, void *data) struct strbuf desc = STRBUF_INIT; int type; - if (ds->fn && !ds->fn(oid, ds->cb_data)) + if (ds->fn && !ds->fn(ds->repo, oid, ds->cb_data)) return 0; - type = oid_object_info(the_repository, oid, NULL); + type = oid_object_info(ds->repo, oid, NULL); if (type == OBJ_COMMIT) { - struct commit *commit = lookup_commit(the_repository, oid); + struct commit *commit = lookup_commit(ds->repo, oid); if (commit) { struct pretty_print_context pp = {0}; pp.date_mode.type = DATE_SHORT; format_commit_message(commit, " %ad - %s", &desc, &pp); } } else if (type == OBJ_TAG) { - struct tag *tag = lookup_tag(the_repository, oid); + struct tag *tag = lookup_tag(ds->repo, oid); if (!parse_tag(tag) && tag->tag) strbuf_addf(&desc, " %s", tag->tag); } advise(" %s %s%s", - find_unique_abbrev(oid, DEFAULT_ABBREV), + repo_find_unique_abbrev(ds->repo, oid, DEFAULT_ABBREV), type_name(type) ? type_name(type) : "unknown type", desc.buf); @@ -383,6 +392,13 @@ static int collect_ambiguous(const struct object_id *oid, void *data) return 0; } +static int repo_collect_ambiguous(struct repository *r, + const struct object_id *oid, + void *data) +{ + return collect_ambiguous(oid, data); +} + static struct repository *sort_ambiguous_repo; static int sort_ambiguous(const void *a, const void *b) { @@ -428,7 +444,7 @@ static enum get_oid_result get_short_oid(const char *name, int len, struct disambiguate_state ds; int quietly = !!(flags & GET_OID_QUIETLY); - if (init_object_disambiguation(name, len, &ds) < 0) + if (init_object_disambiguation(the_repository, name, len, &ds) < 0) return -1; if (HAS_MULTI_BITS(flags & GET_OID_DISAMBIGUATORS)) @@ -483,11 +499,11 @@ int for_each_abbrev(const char *prefix, each_abbrev_fn fn, void *cb_data) struct disambiguate_state ds; int ret; - if (init_object_disambiguation(prefix, strlen(prefix), &ds) < 0) + if (init_object_disambiguation(the_repository, prefix, strlen(prefix), &ds) < 0) return -1; ds.always_call_fn = 1; - ds.fn = collect_ambiguous; + ds.fn = repo_collect_ambiguous; ds.cb_data = &collect; find_short_object_filename(&ds); find_short_packed_object(&ds); @@ -543,6 +559,13 @@ static int extend_abbrev_len(const struct object_id *oid, void *cb_data) return 0; } +static int repo_extend_abbrev_len(struct repository *r, + const struct object_id *oid, + void *cb_data) +{ + return extend_abbrev_len(oid, cb_data); +} + static void find_abbrev_len_for_midx(struct multi_pack_index *m, struct min_abbrev_data *mad) { @@ -668,10 +691,10 @@ int repo_find_unique_abbrev_r(struct repository *r, char *hex, find_abbrev_len_packed(&mad); - if (init_object_disambiguation(hex, mad.cur_len, &ds) < 0) + if (init_object_disambiguation(r, hex, mad.cur_len, &ds) < 0) return -1; - ds.fn = extend_abbrev_len; + ds.fn = repo_extend_abbrev_len; ds.always_call_fn = 1; ds.cb_data = (void *)&mad; From patchwork Wed Apr 3 11:34:40 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883525 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 E37C817E0 for ; Wed, 3 Apr 2019 11:36:32 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CD1DB289A5 for ; Wed, 3 Apr 2019 11:36:32 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C1A93289C0; Wed, 3 Apr 2019 11:36:32 +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 A0A73289A5 for ; Wed, 3 Apr 2019 11:36:31 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726654AbfDCLga (ORCPT ); Wed, 3 Apr 2019 07:36:30 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:40991 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLga (ORCPT ); Wed, 3 Apr 2019 07:36:30 -0400 Received: by mail-pg1-f193.google.com with SMTP id f6so8184741pgs.8 for ; Wed, 03 Apr 2019 04:36:30 -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=YLC/zHqD4nZfCBSwlO+lsrWxWfpYZdPdK2PMT6BBWgM=; b=rXMQ1zaBy0FwMKGyFvk+uVYq94uj2VjaRam+R7zJW/umSc0wgO+nTpdafe5TkJ8Bc/ 9ezTjRoSrGYi1+DNOmbqYruEuIh5SaRiottu3viTRcoIMlM+ttcdwIOiHN/NBupnrsTG 7GMM0Gc/O0owEBfh0jTBIdfn9sowN8PTm5RSuR19b9mOKemR6W4mp5yQwMdxNoa97C/+ +NBkpZOrTdFnIM7TPpjOh3vAvzByl7hSdPhLX+0MSzHX8B28Pf+EJv10doZDm64M8u19 gcUYfYi/nlTpn7+1U8hyU+DmReznXJ2X7U+GSTSIvYHZ37FwvY2U9UTsNJ6rxGPK80sF 4zpA== 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=YLC/zHqD4nZfCBSwlO+lsrWxWfpYZdPdK2PMT6BBWgM=; b=ajfnsPdRrnk17wwHe5VnsSRumqM1UvxY/30wujafQj+lvUsXBD4lXXIHxH6p0Fn4Yr Dl2etXOgyifURTTrGarqN0fp3znnKYHPWuk3hYy9+VLSHukeq+fFuFR7ReTciWEK1vUp gFmUuKaE173sidsIUtrGSv69xbGRmNOjumAXnm/0TX30dL9slFnnmzBCNdGHgyf8ntWB Kur7IPfF1eSIio3Duxy/IWEtn+fsGyDw+pSgNMyDOHtJOcSb2GhBMI/Cu1X7NBy7FBWo z+9u/IhVa3wU4yCwIh4j3jIgTEopeIQHlxJzaa5iThm9Bbp+wydtrDo9tAXz5Ir8drxh umyg== X-Gm-Message-State: APjAAAW6EDAe5zGLFbBorQt5cnkPtUQr62QQE+vnSUygTNoI38SgOhFp iSA088gNryYL8X2cYRUN4Bw3GMeT X-Google-Smtp-Source: APXvYqxkJd0m3fTco7/AfMlzttJfziNH1LrGFY1luS6u7a2aSnqehR3jxkhFMLDmOgiy2x+nDk4n+w== X-Received: by 2002:aa7:8453:: with SMTP id r19mr47326397pfn.44.1554291389682; Wed, 03 Apr 2019 04:36:29 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id k17sm20371759pfk.166.2019.04.03.04.36.26 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:29 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:24 +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 15/32] sha1-name.c: add repo_for_each_abbrev() Date: Wed, 3 Apr 2019 18:34:40 +0700 Message-Id: <20190403113457.20399-16-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 --- cache.h | 3 ++- sha1-name.c | 5 +++-- 2 files changed, 5 insertions(+), 3 deletions(-) diff --git a/cache.h b/cache.h index 4f8ebb0a67..0cb95c0d4f 100644 --- a/cache.h +++ b/cache.h @@ -1392,7 +1392,8 @@ extern enum get_oid_result get_oid_with_context(struct repository *repo, const c struct object_context *oc); typedef int each_abbrev_fn(const struct object_id *oid, void *); -extern int for_each_abbrev(const char *prefix, each_abbrev_fn, void *); +int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *); +#define for_each_abbrev(prefix, fn, data) repo_for_each_abbrev(the_repository, prefix, fn, data) extern int set_disambiguate_hint_config(const char *var, const char *value); diff --git a/sha1-name.c b/sha1-name.c index a75992eb54..cdcf84b826 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -493,13 +493,14 @@ static enum get_oid_result get_short_oid(const char *name, int len, return status; } -int for_each_abbrev(const char *prefix, each_abbrev_fn fn, void *cb_data) +int repo_for_each_abbrev(struct repository *r, const char *prefix, + each_abbrev_fn fn, void *cb_data) { struct oid_array collect = OID_ARRAY_INIT; struct disambiguate_state ds; int ret; - if (init_object_disambiguation(the_repository, prefix, strlen(prefix), &ds) < 0) + if (init_object_disambiguation(r, prefix, strlen(prefix), &ds) < 0) return -1; ds.always_call_fn = 1; From patchwork Wed Apr 3 11:34:41 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883527 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 7C569922 for ; Wed, 3 Apr 2019 11:36:37 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 66523289A5 for ; Wed, 3 Apr 2019 11:36:37 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 5A392289C0; Wed, 3 Apr 2019 11:36:37 +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 EF8ED289A5 for ; Wed, 3 Apr 2019 11:36:36 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726656AbfDCLgg (ORCPT ); Wed, 3 Apr 2019 07:36:36 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:35229 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgf (ORCPT ); Wed, 3 Apr 2019 07:36:35 -0400 Received: by mail-pl1-f194.google.com with SMTP id w24so1511509plp.2 for ; Wed, 03 Apr 2019 04:36:35 -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=mk/AggNO03fk2G0u4xF9XXptVhBAQp2iIFzsp49nKTY=; b=fDDhqgQOqpkN+tEIBiysroGDC/2PQrup/QWBa8YgumquoqEhJhSysyiyOkfGJ/x3+N EuVqQcNhVpSzr/8yf92jCxkiWCIQxrwmi/HIEuxEcdb5idzRRnwDwopraWjYv2dVFsFK ytHgyNPbXIL2mGgCbUe6BtqEFWnD2wvegSEHakZ+pv5rLKI8DNGzyqwAaSJNhZ3CMYux y1r7XqrbhS+gsXsLQmgWIiSVa6Zllj7Fx1HvEhvcQYUiwgpTkeFSproX3RVHn40pesFx PaNttCeLdxUv+viLYJ+199CvObCO2yrzLHaMNQ+d1r7X5Ds+JdPR0ACSJtSxDa3BEUGS Vyvw== 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=mk/AggNO03fk2G0u4xF9XXptVhBAQp2iIFzsp49nKTY=; b=ZUG64T65QusH71McZDUXrJCuzQ5LI7X6+uS7gv9xbGB3pXMhjF6E+xCsVFKOuPUXKx q+NqompQyyY1GSbgTZmyiyNpNcsL+kqxbv6MCsDSrBUs+Xz/igDJD1l+yHF3iagUs7Te UwwObMx00jd8kRAfI+l0GY32/fbNOcq4yg13BKWvXUGBiD7YLj8x/Em8Hilpt265m9qR sbZcAqv1wMCB9Kb/q1mPp3qpmSHnomURcQZn9+a4z6PsY1delSLp2NNhLvjk5JzoRmrz 6CQzPplaAFQh1gKLvlgBTBEnYrUcyodpZXRGRfpRW1w/grMUKbUXzf05TVcKhjJ/V7Ts WsiQ== X-Gm-Message-State: APjAAAV+RgCt5iM916BTaouL9LQBPLByyxn4wpcxW55MqSaRqYhLagSY xeMcdUYdiW+7CTlRYBxGYYM= X-Google-Smtp-Source: APXvYqzZlgS1LuCwmxHOaPiUgrqaB3IgDiptnRt/3p/MCIttcT1Z6LwWLmn7jeVhCAhbVwNFlLzUiQ== X-Received: by 2002:a17:902:8a4:: with SMTP id 33mr75258921pll.7.1554291395202; Wed, 03 Apr 2019 04:36:35 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id x28sm8850002pgl.38.2019.04.03.04.36.32 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:34 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:30 +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 16/32] sha1-name.c: remove the_repo from get_short_oid() Date: Wed, 3 Apr 2019 18:34:41 +0700 Message-Id: <20190403113457.20399-17-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 --- sha1-name.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index cdcf84b826..2643b75b54 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -436,7 +436,8 @@ static void sort_ambiguous_oid_array(struct repository *r, struct oid_array *a) sort_ambiguous_repo = NULL; } -static enum get_oid_result get_short_oid(const char *name, int len, +static enum get_oid_result get_short_oid(struct repository *r, + const char *name, int len, struct object_id *oid, unsigned flags) { @@ -444,7 +445,7 @@ static enum get_oid_result get_short_oid(const char *name, int len, struct disambiguate_state ds; int quietly = !!(flags & GET_OID_QUIETLY); - if (init_object_disambiguation(the_repository, name, len, &ds) < 0) + if (init_object_disambiguation(r, name, len, &ds) < 0) return -1; if (HAS_MULTI_BITS(flags & GET_OID_DISAMBIGUATORS)) @@ -482,8 +483,8 @@ static enum get_oid_result get_short_oid(const char *name, int len, ds.fn = NULL; advise(_("The candidates are:")); - for_each_abbrev(ds.hex_pfx, collect_ambiguous, &collect); - sort_ambiguous_oid_array(the_repository, &collect); + repo_for_each_abbrev(r, ds.hex_pfx, collect_ambiguous, &collect); + sort_ambiguous_oid_array(r, &collect); if (oid_array_for_each(&collect, show_ambiguous_object, &ds)) BUG("show_ambiguous_object shouldn't return non-zero"); @@ -855,7 +856,8 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, if (warn_ambiguous_refs && !(flags & GET_OID_QUIETLY) && (refs_found > 1 || - !get_short_oid(str, len, &tmp_oid, GET_OID_QUIETLY))) + !get_short_oid(the_repository, + str, len, &tmp_oid, GET_OID_QUIETLY))) warning(warn_msg, len, str); if (reflog_len) { @@ -1109,7 +1111,8 @@ static int get_describe_name(const char *name, int len, struct object_id *oid) if (ch == 'g' && cp[-1] == '-') { cp++; len -= cp - name; - return get_short_oid(cp, len, oid, flags); + return get_short_oid(the_repository, + cp, len, oid, flags); } } } @@ -1163,7 +1166,7 @@ static enum get_oid_result get_oid_1(const char *name, int len, if (!ret) return FOUND; - return get_short_oid(name, len, oid, lookup_flags); + return get_short_oid(the_repository, name, len, oid, lookup_flags); } /* From patchwork Wed Apr 3 11:34:42 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883529 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 5A2EF922 for ; Wed, 3 Apr 2019 11:36:43 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 44624289A5 for ; Wed, 3 Apr 2019 11:36:43 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 389E5289C0; Wed, 3 Apr 2019 11:36:43 +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 CFE8C289A5 for ; Wed, 3 Apr 2019 11:36:42 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726671AbfDCLgl (ORCPT ); Wed, 3 Apr 2019 07:36:41 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43407 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgl (ORCPT ); Wed, 3 Apr 2019 07:36:41 -0400 Received: by mail-pf1-f194.google.com with SMTP id c8so8013570pfd.10 for ; Wed, 03 Apr 2019 04:36:41 -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=9UDdC6QudJc1/9WbTZNYgF9nZ77a17Sjj1O8i1ENOk8=; b=nFbdjKc2MTLF9mImY1V1yIj0msIW91BKY7G4bufT097YhfSBsFHQrXlFNySoamJI0m 0lezgwasXKF1D2kDJFehF9cjBaw5hGGvheCZnkiuu1OCbmNhz72AjSf4nUxDcRYLWX9e AL2Uep5e9dixrTSW73wDNb7BKdxQEB7r4vyRXh3SuZl04da1JtFwZKCRCPA2U3WZXWem l2PWiF8G7+/G0VAt5yiIyN727Tzbk0Ysb4pMvgKtuVwe/e8cCjsItPdGU+wSP6UbYqFR s1Md2L0XjTbGoSwqdtQQLlU0UOf0ICpDrQHjQdYBxuwpi7Da9V6AEM4UvDqn14VD50gY 9zpw== 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=9UDdC6QudJc1/9WbTZNYgF9nZ77a17Sjj1O8i1ENOk8=; b=gkGt5CkWpPvmZDM65WH0Drw8J1RTYr21Uigosus78omasro7COtcv3l/i5EGOppARg PSiGOTpjGk4uM3FMTHfYmUWh5qnFmY1TdfA/iy83pjmctf0JUbOWrzAK8dzAEfSWqLw5 3bhA7ZbS+LuGz7LMCn6JwnBcId/u8VmBTeVd8t6WwKUA4tGWzAFOtx0J5vxFvp6SCspR q6n15bxY8M0Ku2XTaAAx/l/nH/Xbk9Zlic+mK89jFBatwZ/ZSweJdeOyFuIl1Nla0WUz BL0thSBkXg/TXfctsosz2iQuNZ1/xwJUr8w1IMQ+0MTlJeCkVwTmwxYX4ktc+aAQYrNo +XHg== X-Gm-Message-State: APjAAAWyCojcfm5Hu1X3PXqMr/k+tFoSZeqiRCzlVLCgVjZ5HAumsZ2q vXZ2hiI1+Yu7uR5n6AmBhMmr6G/k X-Google-Smtp-Source: APXvYqzDdf/52ahXao0Ezae7udlAZHcvZwgrBj9/K8usEIo7pp2EITvrojQLRdqKYYy7RQjKx3q4Lg== X-Received: by 2002:aa7:8289:: with SMTP id s9mr61355515pfm.208.1554291400864; Wed, 03 Apr 2019 04:36:40 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id h11sm18330409pgq.57.2019.04.03.04.36.37 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:39 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:35 +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 17/32] sha1-name.c: remove the_repo from interpret_nth_prior_checkout() Date: Wed, 3 Apr 2019 18:34:42 +0700 Message-Id: <20190403113457.20399-18-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 --- sha1-name.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 2643b75b54..af8bf5b351 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -771,7 +771,7 @@ static inline int push_mark(const char *string, int len) } static enum get_oid_result get_oid_1(const char *name, int len, struct object_id *oid, unsigned lookup_flags); -static int interpret_nth_prior_checkout(const char *name, int namelen, struct strbuf *buf); +static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf); static int get_oid_basic(const char *str, int len, struct object_id *oid, unsigned int flags) @@ -835,7 +835,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, struct strbuf buf = STRBUF_INIT; int detached; - if (interpret_nth_prior_checkout(str, len, &buf) > 0) { + if (interpret_nth_prior_checkout(the_repository, str, len, &buf) > 0) { detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid)); strbuf_release(&buf); if (detached) @@ -1288,7 +1288,8 @@ static int grab_nth_branch_switch(struct object_id *ooid, struct object_id *noid * Parse @{-N} syntax, return the number of characters parsed * if successful; otherwise signal an error with negative value. */ -static int interpret_nth_prior_checkout(const char *name, int namelen, +static int interpret_nth_prior_checkout(struct repository *r, + const char *name, int namelen, struct strbuf *buf) { long nth; @@ -1312,12 +1313,14 @@ static int interpret_nth_prior_checkout(const char *name, int namelen, cb.remaining = nth; strbuf_init(&cb.buf, 20); - retval = 0; - if (0 < for_each_reflog_ent_reverse("HEAD", grab_nth_branch_switch, &cb)) { + retval = refs_for_each_reflog_ent_reverse(get_main_ref_store(r), + "HEAD", grab_nth_branch_switch, &cb); + if (0 < retval) { strbuf_reset(buf); strbuf_addbuf(buf, &cb.buf); retval = brace - name + 1; - } + } else + retval = 0; strbuf_release(&cb.buf); return retval; @@ -1484,7 +1487,7 @@ int repo_interpret_branch_name(struct repository *r, namelen = strlen(name); if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL)) { - len = interpret_nth_prior_checkout(name, namelen, buf); + len = interpret_nth_prior_checkout(the_repository, name, namelen, buf); if (!len) { return len; /* syntax Ok, not enough switches */ } else if (len > 0) { From patchwork Wed Apr 3 11:34:43 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883531 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 B76B8922 for ; Wed, 3 Apr 2019 11:36:48 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A1E12289A5 for ; Wed, 3 Apr 2019 11:36:48 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 963C0289C0; Wed, 3 Apr 2019 11:36:48 +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 3A4E4289A5 for ; Wed, 3 Apr 2019 11:36:48 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726685AbfDCLgr (ORCPT ); Wed, 3 Apr 2019 07:36:47 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:47061 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgq (ORCPT ); Wed, 3 Apr 2019 07:36:46 -0400 Received: by mail-pg1-f194.google.com with SMTP id q1so8174141pgv.13 for ; Wed, 03 Apr 2019 04:36:46 -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=zgl4uDGQElqhR/nr1PaRxHFgma6jHwWws1kyZLI+8nw=; b=KbdUYv8k6zRL7gxjzUy7iAkwZ6+U49TSh/+RGBtwRNrccpDQMIdTybe+O+sYyfK6DR 9I32qf6dmWxa7pzELoLLvKTZQTsFDx8oRCapA7HVB0GKL5hq1De1Pe4v3zFFKYiI/rma WNuqOIfy5ZFJ0a5nDQGRlepJw1YeDF1dnZoU/x67CVv/y3MmrOzAvQnDZpbrpv17Fe2L oLnc0bi08qLsaNFXPkm8dX1BNUIlfez5tbb1TTz5XZXdor+NLZJjg5K8rcWSJiGz8E3k 1laGYzn/wJKwlXQQXUgrXOoF7lIqdNMzOiewjeP5UsLjrxRg+0n7+s45evwIUB+0MV+m jX/w== 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=zgl4uDGQElqhR/nr1PaRxHFgma6jHwWws1kyZLI+8nw=; b=L2vVMXeuQ5sQ2GW6HZTUXs+pw/JXIjU6Rl+3wHuoybP6q4fKX7Brr6ZAx4F7j5PxnC AJPRn4WnnVZzEYgzFAUTXB5Tzc20c+/d6pGh8Xiwg1xlnxJoEMh+nQgkn5qLORsVs1aG BVnjraPHZ+cPH18qkVIuXER62gjEWUPPPiwbR9Xwz9vdfYFmrQXyAFpGuz2S2RmK335Z /sNBMACyJ1yjGwSEazfQ6Y5P9XmpAzVUiiu6f5CcK/Mg2/AnQbTqNCD3JW0vnaQmzNBr oGGzOVhs7l/Pkxg3P0/VzUhEDSabQ9Kh0XzQJsNlAZHzBcpKe91eMbgVCFIDeguYI56f usVg== X-Gm-Message-State: APjAAAUlLUNd6tl0+G7Afh5KWikgZ41CgnG1uCZRSpKVb0Ldh2mP52z0 f7f4aCV1fU1QTScwegirZjs= X-Google-Smtp-Source: APXvYqwLtDGc8oPcQt/hRsA25hU+eaqvm98UoIM7YOQKMQNwbRB+J/gsgbzvECw399l1lt+hg5Npkw== X-Received: by 2002:a63:e051:: with SMTP id n17mr71901948pgj.19.1554291406202; Wed, 03 Apr 2019 04:36:46 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id l63sm23382148pfc.89.2019.04.03.04.36.42 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:45 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:41 +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 18/32] sha1-name.c: remove the_repo from interpret_branch_mark() Date: Wed, 3 Apr 2019 18:34:43 +0700 Message-Id: <20190403113457.20399-19-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 --- sha1-name.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index af8bf5b351..7d9512ac44 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1412,9 +1412,9 @@ static int reinterpret(const char *name, int namelen, int len, return ret - used + len; } -static void set_shortened_ref(struct strbuf *buf, const char *ref) +static void set_shortened_ref(struct repository *r, struct strbuf *buf, const char *ref) { - char *s = shorten_unambiguous_ref(ref, 0); + char *s = refs_shorten_unambiguous_ref(get_main_ref_store(r), ref, 0); strbuf_reset(buf); strbuf_addstr(buf, s); free(s); @@ -1435,7 +1435,8 @@ static int branch_interpret_allowed(const char *refname, unsigned allowed) return 0; } -static int interpret_branch_mark(const char *name, int namelen, +static int interpret_branch_mark(struct repository *r, + const char *name, int namelen, int at, struct strbuf *buf, int (*get_mark)(const char *, int), const char *(*get_data)(struct branch *, @@ -1468,7 +1469,7 @@ static int interpret_branch_mark(const char *name, int namelen, if (!branch_interpret_allowed(value, allowed)) return -1; - set_shortened_ref(buf, value); + set_shortened_ref(r, buf, value); return len + at; } @@ -1509,13 +1510,13 @@ int repo_interpret_branch_name(struct repository *r, allowed); } - len = interpret_branch_mark(name, namelen, at - name, buf, + len = interpret_branch_mark(the_repository, name, namelen, at - name, buf, upstream_mark, branch_get_upstream, allowed); if (len > 0) return len; - len = interpret_branch_mark(name, namelen, at - name, buf, + len = interpret_branch_mark(the_repository, name, namelen, at - name, buf, push_mark, branch_get_push, allowed); if (len > 0) From patchwork Wed Apr 3 11:34:44 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883533 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 A34F217E0 for ; Wed, 3 Apr 2019 11:36:53 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 8D223289A5 for ; Wed, 3 Apr 2019 11:36:53 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 81696289C0; Wed, 3 Apr 2019 11:36:53 +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 25AA3289A5 for ; Wed, 3 Apr 2019 11:36:53 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726705AbfDCLgw (ORCPT ); Wed, 3 Apr 2019 07:36:52 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:45303 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLgv (ORCPT ); Wed, 3 Apr 2019 07:36:51 -0400 Received: by mail-pl1-f194.google.com with SMTP id bf11so7889336plb.12 for ; Wed, 03 Apr 2019 04:36:51 -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=/5XiUNgZOyJMfbfBOhs6OmmQ4I37YwDc4n2auyrKfdQ=; b=uUGvAydiVd7AzBn0SKA6Y30lWY9qdQB4Cn6VV+/msTtktZnhG1e0/+3y/iIAdmdo/p 3JUJ2Pep6l60LVtHnxbeF7/5ROjCgJVAh/PjAbXRKnoZUFrA3xcyRmwOqtW7bRy+jPl4 ZHgXbd/Jiv7PJJ70syHE+yi675WfbnS/VPtCzPoBg7a5NH4q/RGA1Q3ZCHkY4l0OmX6l eniA/Du+4NMEw+y5PVQM/y3RHMdIZIWtlTOpcrPPCTKHSbIhG1HCPdPcxd+6DcvIFmxK 8lPJe6F7uuQS3qtqc162SdHpFq+TEPx3HSg2Px+jDNWvhXsOYj5c7hStVd1YP2pfskS7 XSkg== 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=/5XiUNgZOyJMfbfBOhs6OmmQ4I37YwDc4n2auyrKfdQ=; b=mmVi2XdL8Pn9HoAn17wKynYbvZv5HjthiA8twNeqCdgAf13NU1mTuHv+kwNqw4aiRC CVm26DF+3HlaF3BoZH18wutIWm4ecNsRsRIfJ2NJ29MGbVJPkbfZSdweMZ2EZb9G1/PH NLNeNxCYhEmVe3F74lRXeqEgtdXcW88oST74vvRUmAxC7SMDDEfIoMP9221Akgr3M9lw yMOhygOoVJ6Sv0Db9d6eg7YzlzRqWUa+fjcUEZpZpO0pQmXyU0z9sSINlvydJYT9V8JU c3nvizTrm5LcYb9KEPrs4jnit4OT4MOv3ShWsa8nAk1g4aPQePG8OWab+kV4mmG89/7T k5eg== X-Gm-Message-State: APjAAAV2pyyzb+Gin97VKlkI0C/kX94Um2B6VbdSALP43qRlusvfxYaM 5HUiaTb0Jw8JQfOGDDyUXR8= X-Google-Smtp-Source: APXvYqxi/41bTq6X9gznHiE2khI+uFQ41a5JZBbGAVyzWPTC/7/habZEeuZb5hZtPLzFNLo9KSNyuQ== X-Received: by 2002:a17:902:8d83:: with SMTP id v3mr18513490plo.283.1554291411231; Wed, 03 Apr 2019 04:36:51 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id r87sm15084038pfa.71.2019.04.03.04.36.48 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:50 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:46 +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 19/32] sha1-name.c: add repo_interpret_branch_name() Date: Wed, 3 Apr 2019 18:34:44 +0700 Message-Id: <20190403113457.20399-20-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 --- sha1-name.c | 17 ++++++++--------- 1 file changed, 8 insertions(+), 9 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 7d9512ac44..49c62d5254 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1390,7 +1390,8 @@ static int interpret_empty_at(const char *name, int namelen, int len, struct str return 1; } -static int reinterpret(const char *name, int namelen, int len, +static int reinterpret(struct repository *r, + const char *name, int namelen, int len, struct strbuf *buf, unsigned allowed) { /* we have extra data, which might need further processing */ @@ -1399,7 +1400,7 @@ static int reinterpret(const char *name, int namelen, int len, int ret; strbuf_add(buf, name + len, namelen - len); - ret = interpret_branch_name(buf->buf, buf->len, &tmp, allowed); + ret = repo_interpret_branch_name(r, buf->buf, buf->len, &tmp, allowed); /* that data was not interpreted, remove our cruft */ if (ret < 0) { strbuf_setlen(buf, used); @@ -1482,20 +1483,18 @@ int repo_interpret_branch_name(struct repository *r, const char *start; int len; - if (r != the_repository) - BUG("interpret_branch_name() does not really use 'r' yet"); if (!namelen) namelen = strlen(name); if (!allowed || (allowed & INTERPRET_BRANCH_LOCAL)) { - len = interpret_nth_prior_checkout(the_repository, name, namelen, buf); + len = interpret_nth_prior_checkout(r, name, namelen, buf); if (!len) { return len; /* syntax Ok, not enough switches */ } else if (len > 0) { if (len == namelen) return len; /* consumed all */ else - return reinterpret(name, namelen, len, buf, allowed); + return reinterpret(r, name, namelen, len, buf, allowed); } } @@ -1506,17 +1505,17 @@ int repo_interpret_branch_name(struct repository *r, if (!allowed || (allowed & INTERPRET_BRANCH_HEAD)) { len = interpret_empty_at(name, namelen, at - name, buf); if (len > 0) - return reinterpret(name, namelen, len, buf, + return reinterpret(r, name, namelen, len, buf, allowed); } - len = interpret_branch_mark(the_repository, name, namelen, at - name, buf, + len = interpret_branch_mark(r, name, namelen, at - name, buf, upstream_mark, branch_get_upstream, allowed); if (len > 0) return len; - len = interpret_branch_mark(the_repository, name, namelen, at - name, buf, + len = interpret_branch_mark(r, name, namelen, at - name, buf, push_mark, branch_get_push, allowed); if (len > 0) From patchwork Wed Apr 3 11:34:45 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883535 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 C41A317E0 for ; Wed, 3 Apr 2019 11:36:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id ADD2B289A5 for ; Wed, 3 Apr 2019 11:36:58 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id A1A7B289C0; Wed, 3 Apr 2019 11:36:58 +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 495B3289A5 for ; Wed, 3 Apr 2019 11:36:58 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726396AbfDCLg5 (ORCPT ); Wed, 3 Apr 2019 07:36:57 -0400 Received: from mail-pl1-f194.google.com ([209.85.214.194]:37930 "EHLO mail-pl1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLg5 (ORCPT ); Wed, 3 Apr 2019 07:36:57 -0400 Received: by mail-pl1-f194.google.com with SMTP id g37so7901475plb.5 for ; Wed, 03 Apr 2019 04:36:56 -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=hvY2S7a8efdubnqZ497rHTpt8jwV5naQZUHDCe65xZU=; b=iLHaeJNRy8jkVVzfq4/eBi2/KrCAc8jL9wfmLOEP9gK8rPGu7ZkWN/8Zj3PZsvDE9j Us8ZhIY+ww9xuDNh3fqDVgmBzEMvR5pfa/jYO/u7i9M62V+UgKDM1te32JnPqyrXoXBa 9IwZhB/R15mB4HqOnRqhcpmsyUYOWZwqgx00tz8zHF8ygIzRkQhAX1cVsFpYp0HHVVvP M7SyPb67uh84aRBfB8FWmdi1PnQp7QyH32TkdU1OI1Q1+ji99KssioNuFRZ2yxFShrFb 29dquJ2fxhfhUVhzlUmDhnhBZuXt+uNETy8WSDL18Jiwu3svqfIs+cA80UGi+ohdKoyl c8Ag== 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=hvY2S7a8efdubnqZ497rHTpt8jwV5naQZUHDCe65xZU=; b=o4YpPlDpyamrUTuJhD/7ntzrGMRtIsS8YCzmik/hU9pRQ+ahGaB10hOOqPZ17UtKPq SokVE4p8WkZ4JFDBIvYhMWHI0BvjrKzP03TG8FKm2YGllw4vX6ccR2VId6lp8aPdTPaf jGr7f3Miexe1Wf9G+W3cWAwAbPlfZEjnWStWINr1R42c8ddUVbP4//51ATD8vWeuOeN/ 3xCXSSAjVcUoMT1gFOiplbIkPb8W8ngdUzSZqJjRWLWxCHEWOGnPLwuAef6NLS+nj3v6 wDzZQw28IXlSGRuFEG6UtJ+LCfIo4phC/Wn1BgiPq1IoVPM5h2wFSeWHeyXwQwCw/sHk TKfQ== X-Gm-Message-State: APjAAAWdZocGccQPoWVBMwSWrT5ifVaUOyPo8Orvmj3RuIJaUI1irvO+ +ffyXh7QXFOC7EFf+H7Al5k= X-Google-Smtp-Source: APXvYqz5tIFd5wlHJH+ZGZmRSdWbCGw7RL2I6ivbuaK+Z2198xdomBEHaUlHM1lXWAQjbeQplfk+KA== X-Received: by 2002:a17:902:523:: with SMTP id 32mr74674991plf.249.1554291416360; Wed, 03 Apr 2019 04:36:56 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id b9sm9580969pfd.32.2019.04.03.04.36.53 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:36:55 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:51 +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 20/32] sha1-name.c: remove the_repo from get_oid_oneline() Date: Wed, 3 Apr 2019 18:34:45 +0700 Message-Id: <20190403113457.20399-21-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 --- sha1-name.c | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 49c62d5254..fb80306f1a 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -15,7 +15,7 @@ #include "midx.h" #include "commit-reach.h" -static int get_oid_oneline(const char *, struct object_id *, struct commit_list *); +static int get_oid_oneline(struct repository *r, const char *, struct object_id *, struct commit_list *); typedef int (*disambiguate_hint_fn)(struct repository *, const struct object_id *, void *); @@ -1090,7 +1090,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid, prefix = xstrndup(sp + 1, name + len - 1 - (sp + 1)); commit_list_insert((struct commit *)o, &list); - ret = get_oid_oneline(prefix, oid, list); + ret = get_oid_oneline(the_repository, prefix, oid, list); free(prefix); return ret; } @@ -1204,8 +1204,9 @@ static int handle_one_ref(const char *path, const struct object_id *oid, return 0; } -static int get_oid_oneline(const char *prefix, struct object_id *oid, - struct commit_list *list) +static int get_oid_oneline(struct repository *r, + const char *prefix, struct object_id *oid, + struct commit_list *list) { struct commit_list *backup = NULL, *l; int found = 0; @@ -1236,7 +1237,7 @@ static int get_oid_oneline(const char *prefix, struct object_id *oid, int matches; commit = pop_most_recent_commit(&list, ONELINE_SEEN); - if (!parse_object(the_repository, &commit->object.oid)) + if (!parse_object(r, &commit->object.oid)) continue; buf = get_commit_buffer(commit, NULL); p = strstr(buf, "\n\n"); @@ -1760,7 +1761,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, for_each_ref(handle_one_ref, &list); head_ref(handle_one_ref, &list); commit_list_sort_by_date(&list); - return get_oid_oneline(name + 2, oid, list); + return get_oid_oneline(repo, name + 2, oid, list); } if (namelen < 3 || name[2] != ':' || From patchwork Wed Apr 3 11:34:46 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883537 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 9C48C922 for ; Wed, 3 Apr 2019 11:37:04 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 86513289A5 for ; Wed, 3 Apr 2019 11:37:04 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 78E3B289C0; Wed, 3 Apr 2019 11:37:04 +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 672AB289A5 for ; Wed, 3 Apr 2019 11:37:03 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726706AbfDCLhC (ORCPT ); Wed, 3 Apr 2019 07:37:02 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:43438 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725941AbfDCLhC (ORCPT ); Wed, 3 Apr 2019 07:37:02 -0400 Received: by mail-pf1-f194.google.com with SMTP id c8so8013938pfd.10 for ; Wed, 03 Apr 2019 04:37:01 -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=IHO0+//mUhxK1MPr5Z2K783mNYx8bk2aaztVe1lrmyQ=; b=CRE4XDqDRBy0MogF7cZ1THiUp9U+iswV1lqbUnVXxWhl9DxQPjiffiUBUJkMzhoTN7 Z3WcdOQ7k4ejffHe1lkAExhfSYh1G9I7emWt52FnW6eesrPUCz5I4Nq462HXRpox/KKo L6pwxE7XtJ+hNMsYij5aB8GJ1Fezqy7DdBbw45up5R5YmxI8Xa2GBqsHAM3sYxUfrzMp IL7E1ZPU0TQ6GLVcfMkL8V9efTIjolhUm957FaVJR7X+kszTddmePs+KSwFZMBMj5ND1 n+MIkg8NQ8lRLqq0XozZjrtLWK6dtFcnQ/DH9D0Hnk+JBTVKf2V9RDlB2hyE4tg3xmSX G56A== 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=IHO0+//mUhxK1MPr5Z2K783mNYx8bk2aaztVe1lrmyQ=; b=jrYrrBd5Xwk//iBh0VpjAa4leCnkLhL3q25NubVxNslW0HJWm7EFAAs8mV9nhU9kok IUj4EVFFPfAo1oGapzQm64peQPoG5bLboXYZIZ7+bnUfDjALSSA6JxhuLSHips4k2Uio wLWxEbIit5joZ3f0nr550SDgdQiLxPOjIwXh43c6BI/ECphGkYaZ1H9D6VJYpJxoGC/1 SP+BucdNdy9OyUuoy/GeyOjBbVW63GuSbLGewidGJt5FSiPjcfaNZufw0Nyq7JOI1tuU gFJCy+wx134+vHFujTVtEHwfke0Gn6oRMPY061WEEnWmyRyLdgL7jLi2xmGONjituaX/ x2vA== X-Gm-Message-State: APjAAAWo8i/2Jy0QTmvUB0OSx3uczqrrU2DFh/VvhlAz93jxAOtJc2LF nK5eXQAOjhD7DN1o8MnVTqs= X-Google-Smtp-Source: APXvYqyNPa/LC12DKVOMqND40cIp+5PrPXx7mhtB0FdlHfSbcaPBhVFOzsFkMVjeFcHxV8h4c8m3nA== X-Received: by 2002:a63:360e:: with SMTP id d14mr58975289pga.188.1554291421612; Wed, 03 Apr 2019 04:37:01 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id k6sm8513439pfj.173.2019.04.03.04.36.58 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:01 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:36:56 +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 21/32] sha1-name.c: remove the_repo from get_describe_name() Date: Wed, 3 Apr 2019 18:34:46 +0700 Message-Id: <20190403113457.20399-22-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 --- sha1-name.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index fb80306f1a..1cda854f02 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1097,7 +1097,9 @@ static int peel_onion(const char *name, int len, struct object_id *oid, return 0; } -static int get_describe_name(const char *name, int len, struct object_id *oid) +static int get_describe_name(struct repository *r, + const char *name, int len, + struct object_id *oid) { const char *cp; unsigned flags = GET_OID_QUIETLY | GET_OID_COMMIT; @@ -1111,7 +1113,7 @@ static int get_describe_name(const char *name, int len, struct object_id *oid) if (ch == 'g' && cp[-1] == '-') { cp++; len -= cp - name; - return get_short_oid(the_repository, + return get_short_oid(r, cp, len, oid, flags); } } @@ -1162,7 +1164,7 @@ static enum get_oid_result get_oid_1(const char *name, int len, return FOUND; /* It could be describe output that is "SOMETHING-gXXXX" */ - ret = get_describe_name(name, len, oid); + ret = get_describe_name(the_repository, name, len, oid); if (!ret) return FOUND; From patchwork Wed Apr 3 11:34:47 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883539 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 6250F17E0 for ; Wed, 3 Apr 2019 11:37:09 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 48B59289A5 for ; Wed, 3 Apr 2019 11:37:09 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 39467289C0; Wed, 3 Apr 2019 11:37:09 +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 C52C1289A5 for ; Wed, 3 Apr 2019 11:37:08 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726415AbfDCLhH (ORCPT ); Wed, 3 Apr 2019 07:37:07 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:41044 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfDCLhH (ORCPT ); Wed, 3 Apr 2019 07:37:07 -0400 Received: by mail-pg1-f196.google.com with SMTP id f6so8185479pgs.8 for ; Wed, 03 Apr 2019 04:37:07 -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=tV7Pu8ExeeZC83xGO7zNWhu0P7oJAV/3/iczI9tiSeE=; b=H+WN6w8OTlURnJBL+DxrfbAAPe93OEO0WueejNU+f4vywqMf995IWhzO9mfx0fjcUm ByuHDjH6jCgBkTeRxY4kFG6ZHbNT8DE9ph+Y8ac5lte4BgZ5gIFEqFG2sHcGxj295uVd ZsXlFSIgvB/+B795iZScqxIbMpCO9Qb6jDIz/53yaeUJR3TgBczYKTscR/sZ+fm0Zb8n 5ug891B9khH7P46TArxNgmEn89HPTGYvck2RZbSZgyRpRy/8ITShHWLhZ00vJXIzBeDe fkwlQU4Z2pOn6IcTetmafUlNdtkxoVvHIC1dlO+vY4WWdqQWraJm03KgGySLUOnrFc9c NdQQ== 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=tV7Pu8ExeeZC83xGO7zNWhu0P7oJAV/3/iczI9tiSeE=; b=XkYYP+r53KhXIoIdqKzELjtVakuk/fswEckHoREp5PMbH2LO7To9+hnv+J/fscU1YW a/RO7h2kMmw8h183dV2m4n3MioIa1ymaL4HxKBbcKwHadYuMtcqyI+0BnBjm47BV+6DZ UjFsD17kya34LEgSU09K88mfwM24ydB7smJJnBPnr/nJyaWAGaqghRiIAC4i746cEK4F TRQQAxSkg5NsWATRNg3bzOHHQVEoQiwOIhr4zorzVEzIXfov5FUOEmJb7V6H55yeuj5j BWChA4c1z6HKQyKlF4NiT9WfR2vSZosWX6VV8EnCJ1R/QyGiRD+U7jv5RHnFj3M/8Q/4 r6GA== X-Gm-Message-State: APjAAAVJp2D1XAckgWMe1g7t780XADcCOdZAs/QgSBURRBRI95LeKpSx Jkrs/TlbqF08ttkI3cCTJy8= X-Google-Smtp-Source: APXvYqzVTn2ieeBnn7O+3PQTnIgabYywK5uoHfXB/EZcNFeRQzqTpSDL/ga7vUXeEr+GPLZS1df41w== X-Received: by 2002:a63:fb16:: with SMTP id o22mr70172203pgh.209.1554291426875; Wed, 03 Apr 2019 04:37:06 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id j1sm900515pgp.91.2019.04.03.04.37.03 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:06 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:01 +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 22/32] sha1-name.c: remove the_repo from get_oid_basic() Date: Wed, 3 Apr 2019 18:34:47 +0700 Message-Id: <20190403113457.20399-23-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 --- sha1-name.c | 25 ++++++++++++------------- 1 file changed, 12 insertions(+), 13 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 1cda854f02..d4c135aea8 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -773,8 +773,8 @@ static inline int push_mark(const char *string, int len) static enum get_oid_result get_oid_1(const char *name, int len, struct object_id *oid, unsigned lookup_flags); static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf); -static int get_oid_basic(const char *str, int len, struct object_id *oid, - unsigned int flags) +static int get_oid_basic(struct repository *r, const char *str, int len, + struct object_id *oid, unsigned int flags) { static const char *warn_msg = "refname '%.*s' is ambiguous."; static const char *object_name_msg = N_( @@ -792,9 +792,9 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, int refs_found = 0; int at, reflog_len, nth_prior = 0; - if (len == the_hash_algo->hexsz && !get_oid_hex(str, oid)) { + if (len == r->hash_algo->hexsz && !get_oid_hex(str, oid)) { if (warn_ambiguous_refs && warn_on_object_refname_ambiguity) { - refs_found = dwim_ref(str, len, &tmp_oid, &real_ref); + refs_found = repo_dwim_ref(r, str, len, &tmp_oid, &real_ref); if (refs_found > 0) { warning(warn_msg, len, str); if (advice_object_name_warning) @@ -835,8 +835,8 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, struct strbuf buf = STRBUF_INIT; int detached; - if (interpret_nth_prior_checkout(the_repository, str, len, &buf) > 0) { - detached = (buf.len == the_hash_algo->hexsz && !get_oid_hex(buf.buf, oid)); + if (interpret_nth_prior_checkout(r, str, len, &buf) > 0) { + detached = (buf.len == r->hash_algo->hexsz && !get_oid_hex(buf.buf, oid)); strbuf_release(&buf); if (detached) return 0; @@ -845,19 +845,18 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, if (!len && reflog_len) /* allow "@{...}" to mean the current branch reflog */ - refs_found = dwim_ref("HEAD", 4, oid, &real_ref); + refs_found = repo_dwim_ref(r, "HEAD", 4, oid, &real_ref); else if (reflog_len) - refs_found = dwim_log(str, len, oid, &real_ref); + refs_found = repo_dwim_log(r, str, len, oid, &real_ref); else - refs_found = dwim_ref(str, len, oid, &real_ref); + refs_found = repo_dwim_ref(r, str, len, oid, &real_ref); if (!refs_found) return -1; if (warn_ambiguous_refs && !(flags & GET_OID_QUIETLY) && (refs_found > 1 || - !get_short_oid(the_repository, - str, len, &tmp_oid, GET_OID_QUIETLY))) + !get_short_oid(r, str, len, &tmp_oid, GET_OID_QUIETLY))) warning(warn_msg, len, str); if (reflog_len) { @@ -889,7 +888,7 @@ static int get_oid_basic(const char *str, int len, struct object_id *oid, return -1; } } - if (read_ref_at(get_main_ref_store(the_repository), + if (read_ref_at(get_main_ref_store(r), real_ref, flags, at_time, nth, oid, NULL, &co_time, &co_tz, &co_cnt)) { if (!len) { @@ -1159,7 +1158,7 @@ static enum get_oid_result get_oid_1(const char *name, int len, if (!ret) return FOUND; - ret = get_oid_basic(name, len, oid, lookup_flags); + ret = get_oid_basic(the_repository, name, len, oid, lookup_flags); if (!ret) return FOUND; From patchwork Wed Apr 3 11:34:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883541 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 EC8A517E0 for ; Wed, 3 Apr 2019 11:37:14 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id D6603289A5 for ; Wed, 3 Apr 2019 11:37:14 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CAEBB289C0; Wed, 3 Apr 2019 11:37:14 +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 20495289A5 for ; Wed, 3 Apr 2019 11:37:14 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726486AbfDCLhN (ORCPT ); Wed, 3 Apr 2019 07:37:13 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:39095 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfDCLhN (ORCPT ); Wed, 3 Apr 2019 07:37:13 -0400 Received: by mail-pf1-f196.google.com with SMTP id i17so8024680pfo.6 for ; Wed, 03 Apr 2019 04:37:12 -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=1VrGbTQQ9UY3cc5ZVT/2Jzavz0lrpN5XvZvKzS958UI=; b=H3jGPzik/jEKXVkocx6j5b6/OlxwGjArzuUIteeyeDp+uHmKk7DYCMlfNNGh0piZk9 wrKpzcnAlUVJ3lftZ1T9+e0dAK/k8v6d3iIyuyAtNyNio7mMrKegZ92i9mS3WG8MTdHE YMIQ36IRNErWR/cbucmB3de9Ydx7O9BdVbYWUuKbCFGugxyhGz79B8V860NBzYuWvVtW PxmiDOs9aWZ7yOb5G94MHmaFhPlRMG9Gqvc5DbIg65KqaRGSwJZ9xqr2Yw3E8SQRrp1w gEDfpvw+Ymdzzi9w7YxiqVgJCLQED6WgLKdXwMnw1fyI3phcRGmAWqhh6QBNKOSNoIIS ZWRg== 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=1VrGbTQQ9UY3cc5ZVT/2Jzavz0lrpN5XvZvKzS958UI=; b=dN1Vk0wkGclP1PR8ne2waRol82yMONVu32wA1Vw5yQVq4UMDgzMF7Va2sZMQnXM0pz lXiuJm7MwWsR8JoEia+j3Vp0z+SFFYEoOezJKNSlnB3LY+Pt20OVUIOa8saZn/C6kh8x abRQA1LbJAlTvs7Fydl22EIFTdEYSBrX5XnN/06maVm9/9w6Ztpy3khfmxPygZDLuFBn EjR9ZEzKqDfIeJbOWSiuiHdQCvNsKKmkhbs9UjLOHJsKwcU9laOeiO91DFlpLml08mvp vsF7Xj8cTlzrz2IRJh2Esc/sCSH3X3G//ZUwZS5x288nldHL/o7n71I+5JDzC1aGYHM2 lmyQ== X-Gm-Message-State: APjAAAUzlmzLDnZ7C/JY5q1yF4FUIaqz1qfjwwuEGduZ2O3vIQDMjduC jeyMIx+GNENGsGafppX9OHE= X-Google-Smtp-Source: APXvYqxhc7mt3tji0DZTyypbtNISPOoWCrGbrrPn+eLr66lcBrFHsI3nPcwdgMs0q3N0aurWoVgAJw== X-Received: by 2002:a65:6105:: with SMTP id z5mr42622652pgu.378.1554291432124; Wed, 03 Apr 2019 04:37:12 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id 18sm18274152pfp.18.2019.04.03.04.37.09 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:11 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:07 +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 23/32] sha1-name.c: remove the_repo from get_oid_1() Date: Wed, 3 Apr 2019 18:34:48 +0700 Message-Id: <20190403113457.20399-24-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 There is a cyclic dependency between one of these functions so they cannot be converted one by one, so all related functions are converted at once. Signed-off-by: Nguyễn Thái Ngọc Duy --- cache.h | 7 +++++-- sha1-name.c | 59 ++++++++++++++++++++++++++++------------------------- 2 files changed, 36 insertions(+), 30 deletions(-) diff --git a/cache.h b/cache.h index 0cb95c0d4f..2149dc4f56 100644 --- a/cache.h +++ b/cache.h @@ -1491,8 +1491,11 @@ extern void *read_object_with_reference(const struct object_id *oid, unsigned long *size, struct object_id *oid_ret); -extern struct object *peel_to_type(const char *name, int namelen, - struct object *o, enum object_type); +struct object *repo_peel_to_type(struct repository *r, + const char *name, int namelen, + struct object *o, enum object_type); +#define peel_to_type(name, namelen, obj, type) \ + repo_peel_to_type(the_repository, name, namelen, obj, type) enum date_mode_type { DATE_NORMAL = 0, diff --git a/sha1-name.c b/sha1-name.c index d4c135aea8..5741a9f821 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -770,7 +770,7 @@ static inline int push_mark(const char *string, int len) return at_mark(string, len, suffix, ARRAY_SIZE(suffix)); } -static enum get_oid_result get_oid_1(const char *name, int len, struct object_id *oid, unsigned lookup_flags); +static enum get_oid_result get_oid_1(struct repository *r, const char *name, int len, struct object_id *oid, unsigned lookup_flags); static int interpret_nth_prior_checkout(struct repository *r, const char *name, int namelen, struct strbuf *buf); static int get_oid_basic(struct repository *r, const char *str, int len, @@ -921,18 +921,19 @@ static int get_oid_basic(struct repository *r, const char *str, int len, return 0; } -static enum get_oid_result get_parent(const char *name, int len, +static enum get_oid_result get_parent(struct repository *r, + const char *name, int len, struct object_id *result, int idx) { struct object_id oid; - enum get_oid_result ret = get_oid_1(name, len, &oid, + enum get_oid_result ret = get_oid_1(r, name, len, &oid, GET_OID_COMMITTISH); struct commit *commit; struct commit_list *p; if (ret) return ret; - commit = lookup_commit_reference(the_repository, &oid); + commit = lookup_commit_reference(r, &oid); if (parse_commit(commit)) return MISSING_OBJECT; if (!idx) { @@ -950,7 +951,8 @@ static enum get_oid_result get_parent(const char *name, int len, return MISSING_OBJECT; } -static enum get_oid_result get_nth_ancestor(const char *name, int len, +static enum get_oid_result get_nth_ancestor(struct repository *r, + const char *name, int len, struct object_id *result, int generation) { @@ -958,10 +960,10 @@ static enum get_oid_result get_nth_ancestor(const char *name, int len, struct commit *commit; int ret; - ret = get_oid_1(name, len, &oid, GET_OID_COMMITTISH); + ret = get_oid_1(r, name, len, &oid, GET_OID_COMMITTISH); if (ret) return ret; - commit = lookup_commit_reference(the_repository, &oid); + commit = lookup_commit_reference(r, &oid); if (!commit) return MISSING_OBJECT; @@ -974,20 +976,20 @@ static enum get_oid_result get_nth_ancestor(const char *name, int len, return FOUND; } -struct object *peel_to_type(const char *name, int namelen, - struct object *o, enum object_type expected_type) +struct object *repo_peel_to_type(struct repository *r, const char *name, int namelen, + struct object *o, enum object_type expected_type) { if (name && !namelen) namelen = strlen(name); while (1) { - if (!o || (!o->parsed && !parse_object(the_repository, &o->oid))) + if (!o || (!o->parsed && !parse_object(r, &o->oid))) return NULL; if (expected_type == OBJ_ANY || o->type == expected_type) return o; if (o->type == OBJ_TAG) o = ((struct tag*) o)->tagged; else if (o->type == OBJ_COMMIT) - o = &(get_commit_tree(((struct commit *)o))->object); + o = &(repo_get_commit_tree(r, ((struct commit *)o))->object); else { if (name) error("%.*s: expected %s type, but the object " @@ -999,8 +1001,8 @@ struct object *peel_to_type(const char *name, int namelen, } } -static int peel_onion(const char *name, int len, struct object_id *oid, - unsigned lookup_flags) +static int peel_onion(struct repository *r, const char *name, int len, + struct object_id *oid, unsigned lookup_flags) { struct object_id outer; const char *sp; @@ -1050,15 +1052,15 @@ static int peel_onion(const char *name, int len, struct object_id *oid, else if (expected_type == OBJ_TREE) lookup_flags |= GET_OID_TREEISH; - if (get_oid_1(name, sp - name - 2, &outer, lookup_flags)) + if (get_oid_1(r, name, sp - name - 2, &outer, lookup_flags)) return -1; - o = parse_object(the_repository, &outer); + o = parse_object(r, &outer); if (!o) return -1; if (!expected_type) { - o = deref_tag(the_repository, o, name, sp - name - 2); - if (!o || (!o->parsed && !parse_object(the_repository, &o->oid))) + o = deref_tag(r, o, name, sp - name - 2); + if (!o || (!o->parsed && !parse_object(r, &o->oid))) return -1; oidcpy(oid, &o->oid); return 0; @@ -1069,7 +1071,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid, * if we do not get the needed object, we should * barf. */ - o = peel_to_type(name, len, o, expected_type); + o = repo_peel_to_type(r, name, len, o, expected_type); if (!o) return -1; @@ -1089,7 +1091,7 @@ static int peel_onion(const char *name, int len, struct object_id *oid, prefix = xstrndup(sp + 1, name + len - 1 - (sp + 1)); commit_list_insert((struct commit *)o, &list); - ret = get_oid_oneline(the_repository, prefix, oid, list); + ret = get_oid_oneline(r, prefix, oid, list); free(prefix); return ret; } @@ -1120,7 +1122,8 @@ static int get_describe_name(struct repository *r, return -1; } -static enum get_oid_result get_oid_1(const char *name, int len, +static enum get_oid_result get_oid_1(struct repository *r, + const char *name, int len, struct object_id *oid, unsigned lookup_flags) { @@ -1149,25 +1152,25 @@ static enum get_oid_result get_oid_1(const char *name, int len, if (!num && len1 == len - 1) num = 1; if (has_suffix == '^') - return get_parent(name, len1, oid, num); + return get_parent(r, name, len1, oid, num); /* else if (has_suffix == '~') -- goes without saying */ - return get_nth_ancestor(name, len1, oid, num); + return get_nth_ancestor(r, name, len1, oid, num); } - ret = peel_onion(name, len, oid, lookup_flags); + ret = peel_onion(r, name, len, oid, lookup_flags); if (!ret) return FOUND; - ret = get_oid_basic(the_repository, name, len, oid, lookup_flags); + ret = get_oid_basic(r, name, len, oid, lookup_flags); if (!ret) return FOUND; /* It could be describe output that is "SOMETHING-gXXXX" */ - ret = get_describe_name(the_repository, name, len, oid); + ret = get_describe_name(r, name, len, oid); if (!ret) return FOUND; - return get_short_oid(the_repository, name, len, oid, lookup_flags); + return get_short_oid(r, name, len, oid, lookup_flags); } /* @@ -1741,7 +1744,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, memset(oc, 0, sizeof(*oc)); oc->mode = S_IFINVALID; strbuf_init(&oc->symlink_path, 0); - ret = get_oid_1(name, namelen, oid, flags); + ret = get_oid_1(repo, name, namelen, oid, flags); if (!ret) return ret; /* @@ -1822,7 +1825,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, sub_flags &= ~GET_OID_DISAMBIGUATORS; sub_flags |= GET_OID_TREEISH; - if (!get_oid_1(name, len, &tree_oid, sub_flags)) { + if (!get_oid_1(repo, name, len, &tree_oid, sub_flags)) { const char *filename = cp+1; char *new_filename = NULL; From patchwork Wed Apr 3 11:34:49 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883543 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 E4029922 for ; Wed, 3 Apr 2019 11:37:19 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBDE8289A5 for ; Wed, 3 Apr 2019 11:37:19 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id C06E0289C0; Wed, 3 Apr 2019 11:37:19 +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 6C951289A5 for ; Wed, 3 Apr 2019 11:37:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726539AbfDCLhS (ORCPT ); Wed, 3 Apr 2019 07:37:18 -0400 Received: from mail-pg1-f196.google.com ([209.85.215.196]:36949 "EHLO mail-pg1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1726264AbfDCLhS (ORCPT ); Wed, 3 Apr 2019 07:37:18 -0400 Received: by mail-pg1-f196.google.com with SMTP id e6so3832922pgc.4 for ; Wed, 03 Apr 2019 04:37:17 -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=J/RUO8ACXrqeLwgRI/QX11nIxHpfBgPfHg/OeHAlD+4=; b=jH6gFFONPQm8cQ49fRS5s5BHb01OpQVNIdvbfC4EVTY1BoikLlerDFU0Gw/o2+1Qgr weFZG1pbRsed+ZQHyUYYnmXAmlWj+0PZ6QT0uC5RPtSgHalDM2+QXMmuytJOMrZ6Sujm NBWjxQFbPvhYZSFso2SM1bPX7PDVkjVdf3nF3IRf3EDnOzIYBw4c4GsaLRnZ1eRHgtFq fjYV+VksPRCOMNLLRiiQgjF/AhGn0A6KaikhIxx4bV/k9dK01caWL08A1kNag4d3W18X X4ws+QA0j/rPYIcWGOpfGSKxdqOSJaNEy1G1N4MdeIuVno9xlEhT5RDbhaq4fEgT7l2j fjSg== 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=J/RUO8ACXrqeLwgRI/QX11nIxHpfBgPfHg/OeHAlD+4=; b=ak6tux4Vqe1VZljcpNSCzfU3NoPX7CFuxb+OK1HZf7NEezwKCPqUa0qLqzxrWMH4Du rQj+EnOyDZudvtPpdekzl10w8m2SWMPSi8yZ0MAVDnkQlc2d9473wcLml2YdrO7sRNCq zvzL1UWBla6e+9gs5ShYm1ZC691ocKK38VWte3ocvVjTyFqa2l/aBiDRIdr71k4ew2T7 WdX0ph6BB53zxCYCXSEMmrqQ0jdh2c5hsd1mIPLpk2Imge3bhBmZ2iwGrB+g13YYm6RU 8CHwJup1oqaBk41S704OltgW3XSnLiWKghxT57ZNhQxZJM0Lcu6e14H5xaEDnu7m7A6s EM/g== X-Gm-Message-State: APjAAAWt0ZKEl7GYNxYb/P4ZE39oApP/IxOWR7lQS5wZPhjk2E5vNiX+ v5RxRzV77wO/FpIFDQBoc0I= X-Google-Smtp-Source: APXvYqwBAM7E6O/aVMqDWd1ATg3ySAQdhbXQ4Xz+OAgpoDZyWZnsVYOZh6bYZa1q+24pje335tvIxg== X-Received: by 2002:a63:7e10:: with SMTP id z16mr19051026pgc.40.1554291437636; Wed, 03 Apr 2019 04:37:17 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id 25sm19654657pfo.96.2019.04.03.04.37.14 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:16 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:12 +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 24/32] sha1-name.c: remove the_repo from handle_one_ref() Date: Wed, 3 Apr 2019 18:34:49 +0700 Message-Id: <20190403113457.20399-25-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 --- sha1-name.c | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 5741a9f821..d9050776dd 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1189,15 +1189,21 @@ static enum get_oid_result get_oid_1(struct repository *r, /* Remember to update object flag allocation in object.h */ #define ONELINE_SEEN (1u<<20) +struct handle_one_ref_cb { + struct repository *repo; + struct commit_list **list; +}; + static int handle_one_ref(const char *path, const struct object_id *oid, int flag, void *cb_data) { - struct commit_list **list = cb_data; - struct object *object = parse_object(the_repository, oid); + struct handle_one_ref_cb *cb = cb_data; + struct commit_list **list = cb->list; + struct object *object = parse_object(cb->repo, oid); if (!object) return 0; if (object->type == OBJ_TAG) { - object = deref_tag(the_repository, object, path, + object = deref_tag(cb->repo, object, path, strlen(path)); if (!object) return 0; @@ -1760,10 +1766,13 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, char *new_path = NULL; int pos; if (!only_to_die && namelen > 2 && name[1] == '/') { + struct handle_one_ref_cb cb; struct commit_list *list = NULL; - for_each_ref(handle_one_ref, &list); - head_ref(handle_one_ref, &list); + cb.repo = repo; + cb.list = &list; + refs_for_each_ref(repo->refs, handle_one_ref, &cb); + refs_head_ref(repo->refs, handle_one_ref, &cb); commit_list_sort_by_date(&list); return get_oid_oneline(repo, name + 2, oid, list); } From patchwork Wed Apr 3 11:34:50 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883545 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 4981D17E0 for ; Wed, 3 Apr 2019 11:37:25 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 3193C27FA1 for ; Wed, 3 Apr 2019 11:37:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 25B64289AF; Wed, 3 Apr 2019 11:37:25 +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 BB9F027FA1 for ; Wed, 3 Apr 2019 11:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726105AbfDCLhX (ORCPT ); Wed, 3 Apr 2019 07:37:23 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:33281 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLhX (ORCPT ); Wed, 3 Apr 2019 07:37:23 -0400 Received: by mail-pg1-f193.google.com with SMTP id k19so1521344pgh.0 for ; Wed, 03 Apr 2019 04:37:23 -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=1HRwL2T7MODfcXrlBYA8wLAi07ntXHgzSLd7OPKp/jk=; b=TAE0l0JSl52773Syvht+Aekoo+10iC/+wqWBK/86seg0T5Ows2N+ab6AJKlGb51+DY M3aNzjg0DJLstSvWfIc72J3QkLcwIl8mwvlXYiGRO6MormH0Bl6A6ls/qfOeIfy4MuKe lgvfVpFvOlsfRrdDUfbDFYJcIaZXuu1eiZWGg/cMDhRaERChbpnoZljaXwWSRv61yOir HRiZf8H42A47z0ofItJPVy78sAXbqYQYlevOMeErY+L6JwLIfJOcNtCWXf9vIgwwlZV3 bBzKvQwDUpjyU+67mFihnWquJWIpL3bZ8G5zhjFUxSCrihyS3y+/AjryPq94//ebIoE/ LzkA== 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=1HRwL2T7MODfcXrlBYA8wLAi07ntXHgzSLd7OPKp/jk=; b=GTPUuUhDwbgqGisdCR3P6WkDadP65CISJneyje+fwj2BZPklXNkUqtn8y1q1VadMXk HqcyJ5nZqnxJKIkC161XD0wtXHSA92EQqxtjvBa4qJtr9Vh/075X8TLBz8vNt9xmKjxT pLG2YqqwkB0Vm560KrgT3H1zcjNHyYOTo06TfTBdS+DFbjz8+7j4bgZ2gJNAP32l+jLS 2vBBnZvzn32l4k+CdznbnGnr+qjQFoYvlem+npOhZfPwOMDogywLMudZZyiMEuta6z3Q aLqNULRSyfxTv6SW5ImzBKgHFBAfUhYhgphH4kovW2X1g57HHRu2RwSDodoxOwbUwmFE c/YA== X-Gm-Message-State: APjAAAXmBnk5zAlVS7IKUI6MspQsn4OEmM3Y0GPXZHXVv2vre4EqnqDa sFnJOnqLXPjtwVC6t1EUEG4= X-Google-Smtp-Source: APXvYqzhRXk5hYxBSCcRkdkY1+qW5nAx4uWDrLMqT/gkXWwMu2BZoZ2kB0XNHhFXPBMxJU7tHFyjHg== X-Received: by 2002:aa7:818a:: with SMTP id g10mr73363686pfi.178.1554291442922; Wed, 03 Apr 2019 04:37:22 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id w3sm39941393pfn.179.2019.04.03.04.37.19 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:22 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:17 +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 25/32] sha1-name.c: remove the_repo from diagnose_invalid_index_path() Date: Wed, 3 Apr 2019 18:34:50 +0700 Message-Id: <20190403113457.20399-26-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 --- dir.c | 8 ++++++++ dir.h | 4 +++- sha1-name.c | 7 ++++--- 3 files changed, 15 insertions(+), 4 deletions(-) diff --git a/dir.c b/dir.c index b2cabadf25..e6d97343f4 100644 --- a/dir.c +++ b/dir.c @@ -2315,6 +2315,14 @@ int file_exists(const char *f) return lstat(f, &sb) == 0; } +int repo_file_exists(struct repository *repo, const char *path) +{ + if (repo != the_repository) + BUG("do not know how to check file existence in arbitrary repo"); + + return file_exists(path); +} + static int cmp_icase(char a, char b) { if (a == b) diff --git a/dir.h b/dir.h index e3ec26143d..47c5409ced 100644 --- a/dir.h +++ b/dir.h @@ -269,7 +269,9 @@ extern void add_exclude(const char *string, const char *base, int baselen, struct exclude_list *el, int srcpos); extern void clear_exclude_list(struct exclude_list *el); extern void clear_directory(struct dir_struct *dir); -extern int file_exists(const char *); + +int repo_file_exists(struct repository *repo, const char *path); +int file_exists(const char *); extern int is_inside_dir(const char *dir); extern int dir_inside_of(const char *subdir, const char *dir); diff --git a/sha1-name.c b/sha1-name.c index d9050776dd..6caf3f4e3a 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1664,11 +1664,12 @@ static void diagnose_invalid_oid_path(const char *prefix, } /* Must be called only when :stage:filename doesn't exist. */ -static void diagnose_invalid_index_path(struct index_state *istate, +static void diagnose_invalid_index_path(struct repository *r, int stage, const char *prefix, const char *filename) { + struct index_state *istate = r->index; const struct cache_entry *ce; int pos; unsigned namelen = strlen(filename); @@ -1708,7 +1709,7 @@ static void diagnose_invalid_index_path(struct index_state *istate, ce_stage(ce), filename); } - if (file_exists(filename)) + if (repo_file_exists(r, filename)) die("Path '%s' exists on disk, but not in the index.", filename); if (is_missing_file_error(errno)) die("Path '%s' does not exist (neither on disk nor in the index).", @@ -1814,7 +1815,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, pos++; } if (only_to_die && name[1] && name[1] != '/') - diagnose_invalid_index_path(repo->index, stage, prefix, cp); + diagnose_invalid_index_path(repo, stage, prefix, cp); free(new_path); return -1; } From patchwork Wed Apr 3 11:34:51 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883547 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 B9EA317E0 for ; Wed, 3 Apr 2019 11:37:30 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id A412E27FA1 for ; Wed, 3 Apr 2019 11:37:30 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 98759289AF; Wed, 3 Apr 2019 11:37:30 +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 423E827FA1 for ; Wed, 3 Apr 2019 11:37:30 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726167AbfDCLh3 (ORCPT ); Wed, 3 Apr 2019 07:37:29 -0400 Received: from mail-pl1-f193.google.com ([209.85.214.193]:37672 "EHLO mail-pl1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLh2 (ORCPT ); Wed, 3 Apr 2019 07:37:28 -0400 Received: by mail-pl1-f193.google.com with SMTP id w23so4960776ply.4 for ; Wed, 03 Apr 2019 04:37:28 -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=1353qhiBFkvg4CjMPjTgaQAM7MfVk9j47bxGFKrEJdQ=; b=k8yr8qbwV5EeljhROVOlPglqvIsjIfQp57qFMTFzot69uo+eD/4ok72euUyKQUnVet K3+fqTBzU2AaMhDIFcIArMU1oESYbGgkMqQoC+4+ClulUBm5SYc7r1SFNRlA86hMLkys 8mQp2hsCBYqRBJUca74UIqyeNNAZTK4d+pz1MYSlCFeg1h/+8rfRjn13rex/qzeXHgH1 4AQ9z+ab6kGGJVoaMBfRYXwQl4k0TB/C7GxFvcoHVBHKvHdfhjXXBf7DRv5eU0Afa/7L Z2DL7tmkEaOp9s7lXL9q95GE/zrjk3Y4EONAmLxl75AkhN5R5CexpB4Sss1tcI+fQhgK Y59Q== 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=1353qhiBFkvg4CjMPjTgaQAM7MfVk9j47bxGFKrEJdQ=; b=GteyuMeOUYSS8v+D2ffjuC4dVplz56CnoX/QDzeMB+l7xIHN2QOefh+wBpclibw68K qT7g0TVEBdkb0P7vsYBbQDpiwIJNA8SRPToJS1puFFFqwdgY7oyvGtcK3iTq+Ab+kKD0 K7UlkLVyzfcjH7ynH+a+Qr1dbGH0wk5LovaGkJhWBmhrFbzqUNU0ElP1OGqbnk68/Z/B SWJMnrpBHIhsml/8I/hsLwaYxEJTAqg8+/GOc28KbR8DBCXuajILQiaqt3uXn5OSXozT OZtLkqYFv2IWk9MoiCm9pQzDFqEofHh5JcLIrxLV8E7rIllhiWGOw6duOXJy1A50lLVA Ne2g== X-Gm-Message-State: APjAAAWoGnh++T5ruPpJ2A7f+77TUVSa5TPofTSaBRrttTnyyMepIl9t DXRyjQV8lxu0sUkagfTCcjs= X-Google-Smtp-Source: APXvYqxMNFjdKJUuZ6G/F4LXuEJp1jguo6JJrpzwFjbKLpWXKVeJ8Ec+Vc3nIf0wF/igP6e+DWeFIg== X-Received: by 2002:a17:902:526:: with SMTP id 35mr72629541plf.276.1554291448205; Wed, 03 Apr 2019 04:37:28 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id h65sm43295625pfd.108.2019.04.03.04.37.25 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:27 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:23 +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 26/32] sha1-name.c: remove the_repo from resolve_relative_path() Date: Wed, 3 Apr 2019 18:34:51 +0700 Message-Id: <20190403113457.20399-27-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 "remove" is not entirely correct. But at least the function is aware that if the given repo is not the_repository, then $CWD and is_inside_work_tree() means nothing. Signed-off-by: Nguyễn Thái Ngọc Duy --- sha1-name.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sha1-name.c b/sha1-name.c index 6caf3f4e3a..6b53ea2eeb 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1719,12 +1719,12 @@ static void diagnose_invalid_index_path(struct repository *r, } -static char *resolve_relative_path(const char *rel) +static char *resolve_relative_path(struct repository *r, const char *rel) { if (!starts_with(rel, "./") && !starts_with(rel, "../")) return NULL; - if (!is_inside_work_tree()) + if (r != the_repository || !is_inside_work_tree()) die("relative path syntax can't be used outside working tree."); /* die() inside prefix_path() if resolved path is outside worktree */ @@ -1785,7 +1785,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, stage = name[1] - '0'; cp = name + 3; } - new_path = resolve_relative_path(cp); + new_path = resolve_relative_path(repo, cp); if (!new_path) { namelen = namelen - (cp - name); } else { @@ -1839,7 +1839,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, const char *filename = cp+1; char *new_filename = NULL; - new_filename = resolve_relative_path(filename); + new_filename = resolve_relative_path(repo, filename); if (new_filename) filename = new_filename; if (flags & GET_OID_FOLLOW_SYMLINKS) { From patchwork Wed Apr 3 11:34:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883549 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 A048A922 for ; Wed, 3 Apr 2019 11:37:35 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 89B6D27FA1 for ; Wed, 3 Apr 2019 11:37:35 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 7DE22289AF; Wed, 3 Apr 2019 11:37:35 +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 27AB927FA1 for ; Wed, 3 Apr 2019 11:37:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726264AbfDCLhe (ORCPT ); Wed, 3 Apr 2019 07:37:34 -0400 Received: from mail-pf1-f195.google.com ([209.85.210.195]:40086 "EHLO mail-pf1-f195.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLhd (ORCPT ); Wed, 3 Apr 2019 07:37:33 -0400 Received: by mail-pf1-f195.google.com with SMTP id c207so8026812pfc.7 for ; Wed, 03 Apr 2019 04:37:33 -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=Vod4aOH+wA+JD7yNprXuqsVCLUsUss9P8ReeepwUd1o=; b=gM//HBHwSpGDsu10L6vYBKxP3cBSbMiLAKl6kvHixVgiTlFDOjKOEslCCApNjEmQ9P muOW/L1Ya5ulBQHxmQqR4W4iiJ3PGo+9g38KC5WE8VdwSUIc8xkGuqmEGHPCVh9EQCcx diZvFirFnCCMxJpdk1pr1rTIhWjqojTwCCoYJAGKZi2eZ2Xz1w+s3w2wIkMt8shUGkK9 MJ7DrhXfN+3+U2ZyNTom/jivPl+oP11ILWQvT5kJ108E/in8I8bYXBT88ScAD2ELGTEl aVDPmkh6gXocOH8qdK/TYUaIlJ6URAnGEt9EoRP8gxTzNXAVzwGP5G8Fn1IB4CMKhYyO 85Bg== 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=Vod4aOH+wA+JD7yNprXuqsVCLUsUss9P8ReeepwUd1o=; b=Gdk3KwkiR25AFziifjsIcHRD6OqNuu/WU7FFN6Xg7owBW9PQgpZgJrndJxBycdki31 hQx6c9KaZeYM2z7P1vP6y+DiOOsKTUdtuFCDsUeKF7gWLP9Oqy1WVvgqjIuxULWZk/QV iwEtAEaqaZeARNhZDK+iDGXKFnOSoW0mtoLWahtAsuWqCJcBfkKza0YQrSGXWdCN/Ma0 AOmkOVQbcQmoIzXOGmKddJ73BF1w9Hgi2AkFr/7geMRVm2Z0gV0NlDi7cfAFNTUam+4/ b57u8aVtCqTo+A5lvmY1Co+Y11CshT9i0t8d8Ol4Ecr0yT9vWow+JtZsoO2t+LuGIDO+ zjaQ== X-Gm-Message-State: APjAAAW8+Fi0J+DtdUfrAzS5fsrXcTCqwMEjmMoeU6uNVEgvmElzBW69 +LfgNiHDyf+Ird4/di7PojY= X-Google-Smtp-Source: APXvYqwSY4rpweMT+pCMYFKi/FkWkBHpOGTXBDX0dClAM4XU47XGV+X3eMOtFldgAORWXZlKwh9/tg== X-Received: by 2002:a65:6210:: with SMTP id d16mr22802248pgv.110.1554291453283; Wed, 03 Apr 2019 04:37:33 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id k10sm509555pgo.82.2019.04.03.04.37.30 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:32 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:28 +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 27/32] sha1-name.c: remove the_repo from get_oid_with_context_1() Date: Wed, 3 Apr 2019 18:34:52 +0700 Message-Id: <20190403113457.20399-28-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 --- sha1-name.c | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/sha1-name.c b/sha1-name.c index 6b53ea2eeb..64a50d1291 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -12,6 +12,7 @@ #include "packfile.h" #include "object-store.h" #include "repository.h" +#include "submodule.h" #include "midx.h" #include "commit-reach.h" @@ -1797,7 +1798,7 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, oc->path = xstrdup(cp); if (!repo->index->cache) - repo_read_index(the_repository); + repo_read_index(repo); pos = index_name_pos(repo->index, cp, namelen); if (pos < 0) pos = -pos - 1; @@ -1842,6 +1843,14 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, new_filename = resolve_relative_path(repo, filename); if (new_filename) filename = new_filename; + /* + * NEEDSWORK: Eventually get_tree_entry*() should + * learn to take struct repository directly and we + * would not need to inject submodule odb to the + * in-core odb. + */ + if (repo != the_repository) + add_to_alternates_memory(repo->objects->odb->path); if (flags & GET_OID_FOLLOW_SYMLINKS) { ret = get_tree_entry_follow_symlinks(&tree_oid, filename, oid, &oc->symlink_path, From patchwork Wed Apr 3 11:34:53 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883551 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 66766922 for ; Wed, 3 Apr 2019 11:37:41 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 50D1D289A5 for ; Wed, 3 Apr 2019 11:37:41 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 45443289C0; Wed, 3 Apr 2019 11:37:41 +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 E8E98289A5 for ; Wed, 3 Apr 2019 11:37:40 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726337AbfDCLhj (ORCPT ); Wed, 3 Apr 2019 07:37:39 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:32989 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLhj (ORCPT ); Wed, 3 Apr 2019 07:37:39 -0400 Received: by mail-pf1-f196.google.com with SMTP id i19so8022482pfd.0 for ; Wed, 03 Apr 2019 04:37:39 -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=hKjJIvSfH8MGf6h4/kuMUZwGHNx2sxD8tRhAQUc8aZA=; b=klwp09bGu5XuUgu9xXjUMXoNR0wnvh/7Z8aodbTsRg1xHc88Cf7R+JdvX6nEYT33DH sMg3Kf42BdFIVLfyOzkzB6RtlZduJfLWO4cYqGlN/daPY1RYidJRYkNEckZppHthYDv4 OTHHxfMpzwu10tCGjCji510DoWFEqfMIsc2UZGTaRA9b/JVKElOA3xLhjUujdYejaG7M Sfy/B/ZhUoiXQQVwvHDI8e2VJ30xByzVecr+ivOGLIHVcpTIMHXxmh7c4kxg2sTyMxoU dXMOtyxXkV5x4sn1104xSt+IRGh+zUqBq4yXwC6qnGUNbgR6ULaOo3J5NyWZ0CzvkVCI ck4w== 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=hKjJIvSfH8MGf6h4/kuMUZwGHNx2sxD8tRhAQUc8aZA=; b=e7ZIvVKtYMy6sSN52g1vyGmO4nbbFzumhhhfdWMt+8r36Pb4pjf2YWjyFfjE/EuA9C kRoiCeb52ey/HhsKZKImDhd3FwjSdKxnl+UpRUbwjHhylsvO7dKGK60FqBotTDMQhETG VVk7G2f1UFn/izm6wkHu1d09U1u2eCeT9P6sDO+aRfxR4HHvme0V5AU03OOg3bxMUaWH xhKUD/3KIaQMW9/UZRSxtaImzL0HuAR3FcBy9uLaVxv58/n7RTyaHCq9TdvmrR7JnU32 izcJn3x2MBE6IIChBpik4NmAc5OTC/R8kFrqihA0CY7hDrDDaFjswEr//ZfuIK8C7Heu AXTQ== X-Gm-Message-State: APjAAAWeer+iSUAm6WZTzB4GVFea/w91IwG0EkWlOwtEZUNlS/TxRMNu MDR0fujR9Df7W2//LlRVphEad/Bu X-Google-Smtp-Source: APXvYqxaLxgx+E5rYmgQjNp8jTcHhZi29jAPue5QfKOVv50NPmw7mLMip4stn5MfwMDgVz5aqxn9Ew== X-Received: by 2002:a63:6cc7:: with SMTP id h190mr39345609pgc.350.1554291458966; Wed, 03 Apr 2019 04:37:38 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id e184sm24525887pfc.143.2019.04.03.04.37.35 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:38 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:33 +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 28/32] sha1-name.c: add repo_get_oid() Date: Wed, 3 Apr 2019 18:34:53 +0700 Message-Id: <20190403113457.20399-29-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 --- cache.h | 3 ++- sha1-name.c | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/cache.h b/cache.h index 2149dc4f56..f6e87194d0 100644 --- a/cache.h +++ b/cache.h @@ -1380,7 +1380,8 @@ enum get_oid_result { */ }; -extern int get_oid(const char *str, struct object_id *oid); +int repo_get_oid(struct repository *r, const char *str, struct object_id *oid); +#define get_oid(str, oid) repo_get_oid(the_repository, str, oid) extern int get_oid_commit(const char *str, struct object_id *oid); extern int get_oid_committish(const char *str, struct object_id *oid); extern int get_oid_tree(const char *str, struct object_id *oid); diff --git a/sha1-name.c b/sha1-name.c index 64a50d1291..953df0d692 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1573,10 +1573,10 @@ int strbuf_check_branch_ref(struct strbuf *sb, const char *name) * This is like "get_oid_basic()", except it allows "object ID expressions", * notably "xyz^" for "parent of xyz" */ -int get_oid(const char *name, struct object_id *oid) +int repo_get_oid(struct repository *r, const char *name, struct object_id *oid) { struct object_context unused; - return get_oid_with_context(the_repository, name, 0, oid, &unused); + return get_oid_with_context(r, name, 0, oid, &unused); } From patchwork Wed Apr 3 11:34:54 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883553 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 F2AD6922 for ; Wed, 3 Apr 2019 11:37:46 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DC702289A5 for ; Wed, 3 Apr 2019 11:37:46 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id D0948289C0; Wed, 3 Apr 2019 11:37:46 +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 67257289A5 for ; Wed, 3 Apr 2019 11:37:46 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726456AbfDCLhp (ORCPT ); Wed, 3 Apr 2019 07:37:45 -0400 Received: from mail-pg1-f193.google.com ([209.85.215.193]:41107 "EHLO mail-pg1-f193.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLhp (ORCPT ); Wed, 3 Apr 2019 07:37:45 -0400 Received: by mail-pg1-f193.google.com with SMTP id f6so8186240pgs.8 for ; Wed, 03 Apr 2019 04:37:44 -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=kMiXl1MxKUOko0eG2ftuaNwMJYbmJV8Dmae7pks8mVA=; b=ZfYFHJcnzGZEp6M94/DwARrSp68tLMfuURg52pQav6n5cy7dIkgfYXCfIAE3KWFcHw Dh/kq8jytNMb9jDU8MUJ47pCmKWun3o/rcT5JSrdlN2QY4I67jKAH0HSkQqESKzeaAyS UTMnErXWYxsX1oO22HxzRk/AGO7sdeTBzEcMDcpBtnpsEqcE7uo8WShs70z163WRTwlb 27yHoB9m87Bg1rP1Ha/mbsM6m19tbp92lfMBf06jfjt52egGkCY6ByTPY1oPXmUo8f4C /1sP6T9IR7KeIoZzRkbeib5N9Jia8TDtTwuzPWHHLH97ObdUNGzdL4gn2z0tIwjbg45W Ak8A== 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=kMiXl1MxKUOko0eG2ftuaNwMJYbmJV8Dmae7pks8mVA=; b=F8rAerDPk4RtB2j/iBU9E/6VLzztsegXO7l71PP/WScCaiBuCPy+Vvh/kOyt9HSZ2y vBkrokFqi0wM5s+fkcMk0dYBw0gIxaY9FLUhQmtr3B5bAlwxxnTRF+Y77NgFtXNT1Juq NDaUTvBRTHF7rKlLK1ZPXHbY2pnBO7RLYwW+0bHAkbgBMzWjAS8hX3Pk/MaqLs3B7nNG g0vR2QNR79wb8TB39njI7ZuKLgF2ipHI7IUHKLxiOreAkP+srZImNsT6RtYota03yWG9 uyBxzq73vVMt5TEpqqh5zNvKU64lW16stmrQDqUPi2rZjAcD7YrvM5xco07BM4EhTfUr KHEA== X-Gm-Message-State: APjAAAXl9WISH7han/W0WVfQtJ/64i69leTOY4JNLlGKpfOQC13ZCwlk 2Vk3we52oxrdMfAA8KwPQlI= X-Google-Smtp-Source: APXvYqyy8i4lerx7/ZqWDnEtIJhhdiwtwoX/oD/vCr4Y08w9g/Ihz47/f7K9o1gDBpdmXyfJuvS9ig== X-Received: by 2002:aa7:87c5:: with SMTP id i5mr35483494pfo.20.1554291464231; Wed, 03 Apr 2019 04:37:44 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id s15sm19097055pga.71.2019.04.03.04.37.41 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:43 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:39 +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 29/32] submodule-config.c: use repo_get_oid for reading .gitmodules Date: Wed, 3 Apr 2019 18:34:54 +0700 Message-Id: <20190403113457.20399-30-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 Since 76e9bdc437 (submodule: support reading .gitmodules when it's not in the working tree - 2018-10-25), every time you do git grep --recurse-submodules you are likely to see one warning line per submodule (unless all those submodules also have submodules). On a superproject with plenty of submodules (I've seen one with 67) this is really annoying. The warning was there because we could not resolve extended SHA-1 syntax on a submodule. We can now. Make use of the new API and get rid of the warning. It would be even better if config_with_options() supports multiple repositories too. But one step at a time. Signed-off-by: Nguyễn Thái Ngọc Duy --- submodule-config.c | 20 +++++++------------- t/t7814-grep-recurse-submodules.sh | 6 +----- 2 files changed, 8 insertions(+), 18 deletions(-) diff --git a/submodule-config.c b/submodule-config.c index 66653e86b9..4264ee216f 100644 --- a/submodule-config.c +++ b/submodule-config.c @@ -625,23 +625,16 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void const struct config_options opts = { 0 }; struct object_id oid; char *file; + char *oidstr = NULL; file = repo_worktree_path(repo, GITMODULES_FILE); if (file_exists(file)) { config_source.file = file; - } else if (repo->submodule_prefix) { - /* - * When get_oid and config_with_options, used below, - * become able to work on a specific repository, this - * warning branch can be removed. - */ - warning("nested submodules without %s in the working tree are not supported yet", - GITMODULES_FILE); - goto out; - } else if (get_oid(GITMODULES_INDEX, &oid) >= 0) { - config_source.blob = GITMODULES_INDEX; - } else if (get_oid(GITMODULES_HEAD, &oid) >= 0) { - config_source.blob = GITMODULES_HEAD; + } else if (repo_get_oid(repo, GITMODULES_INDEX, &oid) >= 0 || + repo_get_oid(repo, GITMODULES_HEAD, &oid) >= 0) { + config_source.blob = oidstr = xstrdup(oid_to_hex(&oid)); + if (repo != the_repository) + add_to_alternates_memory(repo->objects->odb->path); } else { goto out; } @@ -649,6 +642,7 @@ static void config_from_gitmodules(config_fn_t fn, struct repository *repo, void config_with_options(fn, data, &config_source, &opts); out: + free(oidstr); free(file); } } diff --git a/t/t7814-grep-recurse-submodules.sh b/t/t7814-grep-recurse-submodules.sh index fa475d52fa..134a694516 100755 --- a/t/t7814-grep-recurse-submodules.sh +++ b/t/t7814-grep-recurse-submodules.sh @@ -380,11 +380,7 @@ test_expect_success 'grep --recurse-submodules should pass the pattern type alon fi ' -# Recursing down into nested submodules which do not have .gitmodules in their -# working tree does not work yet. This is because config_from_gitmodules() -# uses get_oid() and the latter is still not able to get objects from an -# arbitrary repository (the nested submodule, in this case). -test_expect_failure 'grep --recurse-submodules with submodules without .gitmodules in the working tree' ' +test_expect_success 'grep --recurse-submodules with submodules without .gitmodules in the working tree' ' test_when_finished "git -C submodule checkout .gitmodules" && rm submodule/.gitmodules && git grep --recurse-submodules -e "(.|.)[\d]" >actual && From patchwork Wed Apr 3 11:34:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883557 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 6F53D17E0 for ; Wed, 3 Apr 2019 11:37:52 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 5820E27FA1 for ; Wed, 3 Apr 2019 11:37:52 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 4C904289AF; Wed, 3 Apr 2019 11:37:52 +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 D64C327FA1 for ; Wed, 3 Apr 2019 11:37:51 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726515AbfDCLhu (ORCPT ); Wed, 3 Apr 2019 07:37:50 -0400 Received: from mail-pf1-f194.google.com ([209.85.210.194]:42679 "EHLO mail-pf1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLhu (ORCPT ); Wed, 3 Apr 2019 07:37:50 -0400 Received: by mail-pf1-f194.google.com with SMTP id r15so8005308pfn.9 for ; Wed, 03 Apr 2019 04:37:49 -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=WiTcqjXHjS0GDmkL0Ayotb8v1V1CzkGfFwAIuM5mr9Q=; b=rRZ7WEGpiG4gEpbx85OphNAYR1I0V+WoF6J5IE57zcEGkYMhlxo3oA9YYmNtwC2hmf fk4waJ+hk/eX0D/mylHkbTRLkYMf5U0ikdNmbcEm19SUZJ8SvGOc1T9qTL0c8GTRWgRm eSczc9azZzHSAgiCItvc0aO0+BxnBdOi+PnVY67HLdhl+aOBstIThyuglFo6TaygC6n7 ksPzXEWXAsXYlnb2CHAJxcQ0NeQSw4yAEOwr7+L4ldvOrLYFyvis2J59gIJia88E1SQR 5YR6pyWYcu2ZnEw0tx/Iyi9LVJ1Ijt1flbNUk5/vl4gQZ4kh5ZwKyWi6zr7YFH/HQHd5 HeqA== 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=WiTcqjXHjS0GDmkL0Ayotb8v1V1CzkGfFwAIuM5mr9Q=; b=kJSX9/yRshxZ7gDGlt9XI1EC7rauEInwic1Lr/o5qR6jke+mDQ8zFl3GeZozI3RL46 aiNekdIpiLOa6Z6wMDmA3O2MEwDsp5XC0C2J2TiTodg3t+1wNaGs4jMo/CKrQRJABS77 IbvIWzAuRZKUyFPziVHhQLh4TrCLfkleDd+wIR7FbRGdcehbw3aHw0ALLFyxodgg5On6 LwL2CppoRB8SSPjaWKgqlvAtPX7NIAzs7Fgh3TH55lrQ0RPGsxcolcDTMCGpiZkGsKlh CSGjLDIVhW9uvVWtNJYNJbksouurClQI4WQwjSORVsQ9vFoZfgfb6fcr6riobGTQy9c5 xO4A== X-Gm-Message-State: APjAAAUqsNYiDWQc/kdokz615xqCBaIXak8IVqWlcELwPNzlCgN0qvYI zgp+wJK5qgW7immXbJTgEVY= X-Google-Smtp-Source: APXvYqxYAGZl5LVM6hGVWMjENzHR2hlpwjGoljgteMBU+WFMF3yI1lOJbzBSb84WlCFg2shygJAMxg== X-Received: by 2002:aa7:91d5:: with SMTP id z21mr43314056pfa.222.1554291469541; Wed, 03 Apr 2019 04:37:49 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id u26sm22756423pfn.5.2019.04.03.04.37.46 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:48 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:44 +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 30/32] sha1-name.c: remove the_repo from maybe_die_on_misspelt_object_name Date: Wed, 3 Apr 2019 18:34:55 +0700 Message-Id: <20190403113457.20399-31-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 --- cache.h | 4 +++- setup.c | 7 ++++--- sha1-name.c | 6 ++++-- 3 files changed, 11 insertions(+), 6 deletions(-) diff --git a/cache.h b/cache.h index f6e87194d0..3718b3db8a 100644 --- a/cache.h +++ b/cache.h @@ -1387,7 +1387,9 @@ extern int get_oid_committish(const char *str, struct object_id *oid); extern int get_oid_tree(const char *str, struct object_id *oid); extern int get_oid_treeish(const char *str, struct object_id *oid); extern int get_oid_blob(const char *str, struct object_id *oid); -extern void maybe_die_on_misspelt_object_name(const char *name, const char *prefix); +void maybe_die_on_misspelt_object_name(struct repository *repo, + const char *name, + const char *prefix); extern enum get_oid_result get_oid_with_context(struct repository *repo, const char *str, unsigned flags, struct object_id *oid, struct object_context *oc); diff --git a/setup.c b/setup.c index d0c958c3b2..8dcb4631f7 100644 --- a/setup.c +++ b/setup.c @@ -164,7 +164,8 @@ int check_filename(const char *prefix, const char *arg) die_errno(_("failed to stat '%s'"), arg); } -static void NORETURN die_verify_filename(const char *prefix, +static void NORETURN die_verify_filename(struct repository *r, + const char *prefix, const char *arg, int diagnose_misspelt_rev) { @@ -179,7 +180,7 @@ static void NORETURN die_verify_filename(const char *prefix, * let maybe_die_on_misspelt_object_name() even trigger. */ if (!(arg[0] == ':' && !isalnum(arg[1]))) - maybe_die_on_misspelt_object_name(arg, prefix); + maybe_die_on_misspelt_object_name(r, arg, prefix); /* ... or fall back the most general message. */ die(_("ambiguous argument '%s': unknown revision or path not in the working tree.\n" @@ -234,7 +235,7 @@ void verify_filename(const char *prefix, die(_("option '%s' must come before non-option arguments"), arg); if (looks_like_pathspec(arg) || check_filename(prefix, arg)) return; - die_verify_filename(prefix, arg, diagnose_misspelt_rev); + die_verify_filename(the_repository, prefix, arg, diagnose_misspelt_rev); } /* diff --git a/sha1-name.c b/sha1-name.c index 953df0d692..b94d381bef 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1885,11 +1885,13 @@ static enum get_oid_result get_oid_with_context_1(struct repository *repo, * exist in 'HEAD'" when given "HEAD:doc", or it may return in which case * you have a chance to diagnose the error further. */ -void maybe_die_on_misspelt_object_name(const char *name, const char *prefix) +void maybe_die_on_misspelt_object_name(struct repository *r, + const char *name, + const char *prefix) { struct object_context oc; struct object_id oid; - get_oid_with_context_1(the_repository, name, GET_OID_ONLY_TO_DIE, + get_oid_with_context_1(r, name, GET_OID_ONLY_TO_DIE, prefix, &oid, &oc); } From patchwork Wed Apr 3 11:34:56 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883559 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 0336A922 for ; Wed, 3 Apr 2019 11:37:58 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id DE38227FA1 for ; Wed, 3 Apr 2019 11:37:57 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id CF56E289B4; Wed, 3 Apr 2019 11:37:57 +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 4494E27FA1 for ; Wed, 3 Apr 2019 11:37:57 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726534AbfDCLh4 (ORCPT ); Wed, 3 Apr 2019 07:37:56 -0400 Received: from mail-pf1-f196.google.com ([209.85.210.196]:35954 "EHLO mail-pf1-f196.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLh4 (ORCPT ); Wed, 3 Apr 2019 07:37:56 -0400 Received: by mail-pf1-f196.google.com with SMTP id z5so7001784pfn.3 for ; Wed, 03 Apr 2019 04:37:55 -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=h4UsmkkHNE/w67i9pZNTRUVeoBYpvfa1184swHxAb98=; b=DzouFIVJ+KpfZIQijvvRCtgteSsosNNE1m7TAphDbLGg4Ja/bNClsCGN3addHuNl/U rjKLDTRMKGO89Z8oxaFnNj/6wH7EoXRR36OlV6jMEsXSD555hx3vYU62euaDBMn51PIU r00+C7I5nKPKm433pbOfZpeOIbdmSEDRiOgBGsdaKeHHvhUDjCLBNt5lo+4fH69U7OMW e5no6/X3dLwv1uy+GaC+JMLIvPuo+ZMM2HthaLmvkQ1i5FbhmVKPGg7OyI1EBRVFvVVl 2eoEvQjWS+10uVEXb9azC3mAhEoWg8ZCEaGYMcPNho2ttJhp0Qoi2cVUDdWNpPlSlDOV iP2w== 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=h4UsmkkHNE/w67i9pZNTRUVeoBYpvfa1184swHxAb98=; b=YRDdBXUkLPXeljnWjRF77rEcTTz7NpyDPjgZ9TZe4+it7iYaC8v07/aV6Rra6qrywb qbXx0KB6jH783S13rm2zYxFwMz/8bvgJH9Y7GiJQvCS60n2plA5SjLPjCjilEc3tAbvr rVnyyIEGb39PTU3IHl3nbtEOKrsWlSoQLqQTyUot6NEkg0wIdtmKNWOkXBV5lL8gUgeY gH9HeK399yIZCrFJUu3siiq+2Hf9cw9aOY5fsmJjhFhJ0xV4B8M1EPlCbCVoWwgPmQJ4 vLWG1Tfx0qJze72gm/1Lp3LNDYDHEptXflx+siLO0iilJ6CQw1+bOFv+25bFqjdXFDRY KxbQ== X-Gm-Message-State: APjAAAUAIHJipGa0DLJHpN/WPpZDE3azqIvkfIdHVk2q2ZMryaUMKQXw X2+HMaSBRH5axa00U9NqeUQ= X-Google-Smtp-Source: APXvYqxZnf7wuvsYx6rc7n9LV+ak+Y5ZgJ6tGFna3vUyQJDsA0U1kdpxoRZG+Ga+NTvx5PN9JuwfgA== X-Received: by 2002:a65:6259:: with SMTP id q25mr44651901pgv.103.1554291475107; Wed, 03 Apr 2019 04:37:55 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id t5sm17360276pfh.141.2019.04.03.04.37.51 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:54 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:49 +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 31/32] sha1-name.c: remove the_repo from other get_oid_* Date: Wed, 3 Apr 2019 18:34:56 +0700 Message-Id: <20190403113457.20399-32-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 --- cache.h | 18 ++++++++++++------ sha1-name.c | 35 ++++++++++++++++++++--------------- 2 files changed, 32 insertions(+), 21 deletions(-) diff --git a/cache.h b/cache.h index 3718b3db8a..871a167bf8 100644 --- a/cache.h +++ b/cache.h @@ -1381,12 +1381,11 @@ enum get_oid_result { }; int repo_get_oid(struct repository *r, const char *str, struct object_id *oid); -#define get_oid(str, oid) repo_get_oid(the_repository, str, oid) -extern int get_oid_commit(const char *str, struct object_id *oid); -extern int get_oid_committish(const char *str, struct object_id *oid); -extern int get_oid_tree(const char *str, struct object_id *oid); -extern int get_oid_treeish(const char *str, struct object_id *oid); -extern int get_oid_blob(const char *str, struct object_id *oid); +int repo_get_oid_commit(struct repository *r, const char *str, struct object_id *oid); +int repo_get_oid_committish(struct repository *r, const char *str, struct object_id *oid); +int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid); +int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid); +int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid); void maybe_die_on_misspelt_object_name(struct repository *repo, const char *name, const char *prefix); @@ -1394,6 +1393,13 @@ extern enum get_oid_result get_oid_with_context(struct repository *repo, const c unsigned flags, struct object_id *oid, struct object_context *oc); +#define get_oid(str, oid) repo_get_oid(the_repository, str, oid) +#define get_oid_commit(str, oid) repo_get_oid_commit(the_repository, str, oid) +#define get_oid_committish(str, oid) repo_get_oid_committish(the_repository, str, oid) +#define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid) +#define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid) +#define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid) + typedef int each_abbrev_fn(const struct object_id *oid, void *); int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *); #define for_each_abbrev(prefix, fn, data) repo_for_each_abbrev(the_repository, prefix, fn, data) diff --git a/sha1-name.c b/sha1-name.c index b94d381bef..d49496397d 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1590,43 +1590,48 @@ int repo_get_oid(struct repository *r, const char *name, struct object_id *oid) * commit-ish. It is merely to give a hint to the disambiguation * machinery. */ -int get_oid_committish(const char *name, struct object_id *oid) +int repo_get_oid_committish(struct repository *r, + const char *name, + struct object_id *oid) { struct object_context unused; - return get_oid_with_context(the_repository, - name, GET_OID_COMMITTISH, + return get_oid_with_context(r, name, GET_OID_COMMITTISH, oid, &unused); } -int get_oid_treeish(const char *name, struct object_id *oid) +int repo_get_oid_treeish(struct repository *r, + const char *name, + struct object_id *oid) { struct object_context unused; - return get_oid_with_context(the_repository, - name, GET_OID_TREEISH, + return get_oid_with_context(r, name, GET_OID_TREEISH, oid, &unused); } -int get_oid_commit(const char *name, struct object_id *oid) +int repo_get_oid_commit(struct repository *r, + const char *name, + struct object_id *oid) { struct object_context unused; - return get_oid_with_context(the_repository, - name, GET_OID_COMMIT, + return get_oid_with_context(r, name, GET_OID_COMMIT, oid, &unused); } -int get_oid_tree(const char *name, struct object_id *oid) +int repo_get_oid_tree(struct repository *r, + const char *name, + struct object_id *oid) { struct object_context unused; - return get_oid_with_context(the_repository, - name, GET_OID_TREE, + return get_oid_with_context(r, name, GET_OID_TREE, oid, &unused); } -int get_oid_blob(const char *name, struct object_id *oid) +int repo_get_oid_blob(struct repository *r, + const char *name, + struct object_id *oid) { struct object_context unused; - return get_oid_with_context(the_repository, - name, GET_OID_BLOB, + return get_oid_with_context(r, name, GET_OID_BLOB, oid, &unused); } From patchwork Wed Apr 3 11:34:57 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: Duy Nguyen X-Patchwork-Id: 10883561 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 E137D17E0 for ; Wed, 3 Apr 2019 11:38:02 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CBA2627FA1 for ; Wed, 3 Apr 2019 11:38:02 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id BFBA2289B4; Wed, 3 Apr 2019 11:38:02 +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 55B7127FA1 for ; Wed, 3 Apr 2019 11:38:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1726558AbfDCLiB (ORCPT ); Wed, 3 Apr 2019 07:38:01 -0400 Received: from mail-pg1-f194.google.com ([209.85.215.194]:34106 "EHLO mail-pg1-f194.google.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1725990AbfDCLiB (ORCPT ); Wed, 3 Apr 2019 07:38:01 -0400 Received: by mail-pg1-f194.google.com with SMTP id v12so8209852pgq.1 for ; Wed, 03 Apr 2019 04:38:00 -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=xHihulZqB9t7pgfq8tjomSTv/8DEfubw/edGbtbh7Pk=; b=lMeUAY81DfcCU6fIUyriJQyQrvs3U6GvtDaefrnyXBimYlodSt6FpX6+VdhXBjimVc UK+fdoazW/jfw9h/0KBqWzB+dtqNxgxZz7yCRNfpsEjayZ96w28OJGtA7A5kPawMEy+Z WDWbRN/tlyfPW3CJ+OrmKW85NjtF+fxOCnE+8fQdVwruD7phnCvQyg6O3hE+c9djH67W nl1ARvIzVhQjedEAcoRHGpM58HGf5SfAVz6YFEcAPbSLYnjx3WM2B/mm0GuzJ1wUYu99 Ubfb4F6+Kl/EdlI61tSNFhzN4v404kI+wHeyOYb3vmT/LQZ7HZRwivpSN9LizlihtTDn 8FDg== 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=xHihulZqB9t7pgfq8tjomSTv/8DEfubw/edGbtbh7Pk=; b=qZHBWaeG1Hv70fR7SH8ysamEgPNx93Ba9NhTL7+K1wqjUf1ypxloMVAf0cgoKIKVXu UZS9CgSOvFnGFB+17oCYJ3tYDDf1frBaZFmUFROLHaA9fKzc0CtJf5Pr8jmS233OvXdn mVSslFJn7Sl7XVJzySoTrpCcVw9PQ6le4O0PSvH6pZmjuuEJSmJojn0vEtebPX26XIRr 86WwiGPGVoO/k+WhTpbYVFTiydwHqy2af2tpKZbD5/LQ6a07ZlMU83N+Iw956cYte658 +kDofml6470vf1qPF98eEv9QkrQI9XSIKxppd7A5AUz6eoYuRMY25uLdu7QaeTGZFQwx ltqA== X-Gm-Message-State: APjAAAW+/Hl91wboQ7q9dpyyKt5zLd+NM14NauA9U5TmRz1vxrxbde5D jspebqxYUonSV9A796NxQwDYF019 X-Google-Smtp-Source: APXvYqxtD3QzF99nj59kfzCW7phd9XMjtlHcZ1tBjdlbxFgRSgeZ37BWCK1H02UWOikkcB/xf9Lgsg== X-Received: by 2002:a65:62c3:: with SMTP id m3mr12640544pgv.159.1554291480551; Wed, 03 Apr 2019 04:38:00 -0700 (PDT) Received: from ash ([27.75.136.26]) by smtp.gmail.com with ESMTPSA id s85sm17768687pfa.23.2019.04.03.04.37.57 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 03 Apr 2019 04:37:59 -0700 (PDT) Received: by ash (sSMTP sendmail emulation); Wed, 03 Apr 2019 18:37:55 +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 32/32] sha1-name.c: remove the_repo from get_oid_mb() Date: Wed, 3 Apr 2019 18:34:57 +0700 Message-Id: <20190403113457.20399-33-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 --- cache.h | 3 ++- sha1-name.c | 18 +++++++++++------- 2 files changed, 13 insertions(+), 8 deletions(-) diff --git a/cache.h b/cache.h index 871a167bf8..9a600a8b50 100644 --- a/cache.h +++ b/cache.h @@ -1386,6 +1386,7 @@ int repo_get_oid_committish(struct repository *r, const char *str, struct object int repo_get_oid_tree(struct repository *r, const char *str, struct object_id *oid); int repo_get_oid_treeish(struct repository *r, const char *str, struct object_id *oid); int repo_get_oid_blob(struct repository *r, const char *str, struct object_id *oid); +int repo_get_oid_mb(struct repository *r, const char *str, struct object_id *oid); void maybe_die_on_misspelt_object_name(struct repository *repo, const char *name, const char *prefix); @@ -1399,6 +1400,7 @@ extern enum get_oid_result get_oid_with_context(struct repository *repo, const c #define get_oid_tree(str, oid) repo_get_oid_tree(the_repository, str, oid) #define get_oid_treeish(str, oid) repo_get_oid_treeish(the_repository, str, oid) #define get_oid_blob(str, oid) repo_get_oid_blob(the_repository, str, oid) +#define get_oid_mb(str, oid) repo_get_oid_mb(the_repository, str, oid) typedef int each_abbrev_fn(const struct object_id *oid, void *); int repo_for_each_abbrev(struct repository *r, const char *prefix, each_abbrev_fn, void *); @@ -1486,7 +1488,6 @@ int repo_interpret_branch_name(struct repository *r, unsigned allowed); #define interpret_branch_name(str, len, buf, allowed) \ repo_interpret_branch_name(the_repository, str, len, buf, allowed) -extern int get_oid_mb(const char *str, struct object_id *oid); extern int validate_headref(const char *ref); diff --git a/sha1-name.c b/sha1-name.c index d49496397d..cf314ebb29 100644 --- a/sha1-name.c +++ b/sha1-name.c @@ -1338,7 +1338,9 @@ static int interpret_nth_prior_checkout(struct repository *r, return retval; } -int get_oid_mb(const char *name, struct object_id *oid) +int repo_get_oid_mb(struct repository *r, + const char *name, + struct object_id *oid) { struct commit *one, *two; struct commit_list *mbs; @@ -1348,27 +1350,29 @@ int get_oid_mb(const char *name, struct object_id *oid) dots = strstr(name, "..."); if (!dots) - return get_oid(name, oid); + return repo_get_oid(r, name, oid); if (dots == name) - st = get_oid("HEAD", &oid_tmp); + st = repo_get_oid(r, "HEAD", &oid_tmp); else { struct strbuf sb; strbuf_init(&sb, dots - name); strbuf_add(&sb, name, dots - name); - st = get_oid_committish(sb.buf, &oid_tmp); + st = repo_get_oid_committish(r, sb.buf, &oid_tmp); strbuf_release(&sb); } if (st) return st; - one = lookup_commit_reference_gently(the_repository, &oid_tmp, 0); + one = lookup_commit_reference_gently(r, &oid_tmp, 0); if (!one) return -1; - if (get_oid_committish(dots[3] ? (dots + 3) : "HEAD", &oid_tmp)) + if (repo_get_oid_committish(r, dots[3] ? (dots + 3) : "HEAD", &oid_tmp)) return -1; - two = lookup_commit_reference_gently(the_repository, &oid_tmp, 0); + two = lookup_commit_reference_gently(r, &oid_tmp, 0); if (!two) return -1; + if (r != the_repository) + BUG("sorry get_merge_bases() can't take struct repository yet"); mbs = get_merge_bases(one, two); if (!mbs || mbs->next) st = -1;