From patchwork Wed Jan 24 15:27:23 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13529327 Received: from mail-ed1-f43.google.com (mail-ed1-f43.google.com [209.85.208.43]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id EAB317A729 for ; Wed, 24 Jan 2024 15:27:34 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.43 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110056; cv=none; b=RZAolwV9objRM6OOnrZdQq0xu3mauhT1BwT31dw27CKCvyGUZeHcouB/U4fn9eZqt8tZZNEMBwMerWdbM9lm3Q/V2gHYz/1XSBzVTxBENCOU44NVCtyBhRgH8DqNDYTNlYNhMrGEslHFpQgouCVLx7Qii1V4toSedlmRocvZcHY= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110056; c=relaxed/simple; bh=EJSmtWsyCvnKDbI9eOWnZtoo0278sMK8qqNHM4lfbXA=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=W2C6a6Hu3GO5V7uK20TlkJnW6BGWoof1bCfZsb1VL/12mVa5cJSuu9dKGNT/rja0ufMjkxn2yHZBROTtklqVSAzqPPsxwYXgz2A9oAr+zeu4r7pA2r05N5pAFJB/0hgy7VNtl8ygGcm4B8NyxjtYqvirmeYqdc4eRWvysjpZJ+E= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=C4x55Qcm; arc=none smtp.client-ip=209.85.208.43 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="C4x55Qcm" Received: by mail-ed1-f43.google.com with SMTP id 4fb4d7f45d1cf-55cd798b394so743434a12.0 for ; Wed, 24 Jan 2024 07:27:34 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706110053; x=1706714853; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=Rt4nG+v9RnTzDBZBxdU5eB5Bsi1r4yUtyYzyTqHm4+U=; b=C4x55QcmEhcIfncWDRgQjbHopOOCxMUry9uJhEjJoSMR9vB/7pb53J8XawKzLrib4E 4Dg1WTp3WbdObEIRv1+a3MAM/EiPj4XlLd1gzJw30SJfA4pma6tTGmR+BcQaGVfgqCbE fmXhPuavfN/tqixQzkxHMbbYC7XEBUQiR6Q9pzrOk9jbNC6bdMuUyRVRUHdDXEFrkcoQ a53IsQF/sk3rbDSwi7fGhSzce5woJ9UTs2tZFFlDDvX45cywT0s1S5EfWuLkAmMuCB92 P0gAjrVlPBJod0YbKBx7KBKT2ULOx8aZF6h29k9sWJWVkKecKt3Z+a4VurwfXRAKyqgi bslA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706110053; x=1706714853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=Rt4nG+v9RnTzDBZBxdU5eB5Bsi1r4yUtyYzyTqHm4+U=; b=iRAKCNN/tahWLLf57LTXYGKEnQIDqe10IC43rK22jkvzKBm1/TdHClb2A1M7oCOSNo /hBIhvQYjKNXmcncKzuKhrpWqa8cJ/S7SsbMZD7BSfoo/QVyIl+UqOgpMF2iKfpF739y LJjdL/yNkg5CVAG6IhA0B7M3vh3GAM9A/Nu/Zc1tp1oF7QVi2YKu//XshriqoXHuZRYK 2JS5XQNUfTqZ9ksbB3qjytuOJZ5SREyrxogjkW50jRuL1y1jj+GccDekvgTCqY91cwGT MyQrb5tm9hT+l4WHPDSoF9cKq8XenEv8qggG0CukrP+wIwKV2rO6o74lQhhGcwSs5Ulo Oz0Q== X-Gm-Message-State: AOJu0Yxav/T5EJcSOGCLocy62aQBXlLsFQL941iG0c86xKGN1v3VtjM/ HtFfwBv219ozbDJDJ0YVin6pFZFRPCqR3e5ySjANkeCqxkaZKXp7874on1UQ X-Google-Smtp-Source: AGHT+IHYcLL0n4vvdVvCrUtjHNWDpXUOepGtdA1rat3XjeDAtWAyXaG8PcjDgEPaprz3fWK6jNFZEA== X-Received: by 2002:a17:907:77d0:b0:a28:a7cf:b014 with SMTP id kz16-20020a17090777d000b00a28a7cfb014mr1527143ejc.2.1706110052550; Wed, 24 Jan 2024 07:27:32 -0800 (PST) Received: from localhost.localdomain (h-213.61.124.196.host.de.colt.net. [213.61.124.196]) by smtp.gmail.com with ESMTPSA id vh12-20020a170907d38c00b00a2eb648cdc5sm8765225ejc.156.2024.01.24.07.27.31 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:27:32 -0800 (PST) From: Karthik Nayak To: git@vger.kernel.org Cc: gitster@pobox.com, ps@pks.im, phillip.wood123@gmail.com, Karthik Nayak Subject: [PATCH v2 1/4] refs: introduce `is_pseudoref()` and `is_headref()` Date: Wed, 24 Jan 2024 16:27:23 +0100 Message-ID: <20240124152726.124873-2-karthik.188@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124152726.124873-1-karthik.188@gmail.com> References: <20240119142705.139374-1-karthik.188@gmail.com> <20240124152726.124873-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce two new functions `is_pseudoref()` and `is_headref()`. This provides the necessary functionality for us to add pseudorefs and HEAD to the loose ref cache in the files backend, allowing us to build tooling to print these refs. The `is_pseudoref()` function internally calls `is_pseudoref_syntax()` but adds onto it by also checking to ensure that the pseudoref either ends with a "_HEAD" suffix or matches a list of exceptions. After which we also parse the contents of the pseudoref to ensure that it conforms to the ref format. We cannot directly add the new syntax checks to `is_pseudoref_syntax()` because the function is also used by `is_current_worktree_ref()` and making it stricter to match only known pseudorefs might have unintended consequences due to files like 'BISECT_START' which isn't a pseudoref but sometimes contains object ID. Keeping this in mind, we leave `is_pseudoref_syntax()` as is and create `is_pseudoref()` which is stricter. Ideally we'd want to move the new syntax checks to `is_pseudoref_syntax()` but a prerequisite for this would be to actually remove the exception list by converting those pseudorefs to also contain a '_HEAD' suffix and perhaps move bisect related files like 'BISECT_START' to a new directory similar to the 'rebase-merge' directory. Signed-off-by: Karthik Nayak --- refs.c | 32 ++++++++++++++++++++++++++++++++ refs.h | 3 +++ 2 files changed, 35 insertions(+) diff --git a/refs.c b/refs.c index 20e8f1ff1f..4b6bfc66fb 100644 --- a/refs.c +++ b/refs.c @@ -859,6 +859,38 @@ static int is_pseudoref_syntax(const char *refname) return 1; } +int is_pseudoref(struct ref_store *refs, const char *refname) +{ + static const char *const irregular_pseudorefs[] = { + "AUTO_MERGE", + "BISECT_EXPECTED_REV", + "NOTES_MERGE_PARTIAL", + "NOTES_MERGE_REF", + "MERGE_AUTOSTASH" + }; + size_t i; + + if (!is_pseudoref_syntax(refname)) + return 0; + + if (ends_with(refname, "_HEAD")) + return refs_ref_exists(refs, refname); + + for (i = 0; i < ARRAY_SIZE(irregular_pseudorefs); i++) + if (!strcmp(refname, irregular_pseudorefs[i])) + return refs_ref_exists(refs, refname); + + return 0; +} + +int is_headref(struct ref_store *refs, const char *refname) +{ + if (!strcmp(refname, "HEAD")) + return refs_ref_exists(refs, refname); + + return 0; +} + static int is_current_worktree_ref(const char *ref) { return is_pseudoref_syntax(ref) || is_per_worktree_ref(ref); } diff --git a/refs.h b/refs.h index 11b3b6ccea..46b8085d63 100644 --- a/refs.h +++ b/refs.h @@ -1021,4 +1021,7 @@ extern struct ref_namespace_info ref_namespace[NAMESPACE__COUNT]; */ void update_ref_namespace(enum ref_namespace namespace, char *ref); +int is_pseudoref(struct ref_store *refs, const char *refname); +int is_headref(struct ref_store *refs, const char *refname); + #endif /* REFS_H */ From patchwork Wed Jan 24 15:27:24 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13529328 Received: from mail-ed1-f41.google.com (mail-ed1-f41.google.com [209.85.208.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 5E8695384 for ; Wed, 24 Jan 2024 15:27:35 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.208.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110057; cv=none; b=JXA3gykNPSz2wBePDlP2He9KkaDclcRddGC7kxtigb0BbOZWaYUDPTu6JLbcFzIqIAN6spX++65/fHGP4A4GbqlqBaFgn2FUAk0z+RiWS2YcIGtOec/XDtsxuB2lMlVyBz8Rb+DvdX0x1Q0USXw8p/eAYB6rn4lctTSaQHDI6Ww= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110057; c=relaxed/simple; bh=HVrGRwlhKtHb+eMYjfeEB+V3IjJZypVoGABR0ohVoQg=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=Smfv0BOAiNNx9V5swCGNy8jHz/s24ioVdyKknL/IYRa2uZ0ktc9ecKmRQGfURi7u/miQaXjcsCF3ojlvpNH7ha09nW68SkGjoYwnyD6rpXlVD8PEE5gBUZx3EoPJ4UE0Oj2a4FR0cfXjxT7GYLFBb2BfjtCc4naZg+tG1Hjx1NM= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=ZvPo7dxD; arc=none smtp.client-ip=209.85.208.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="ZvPo7dxD" Received: by mail-ed1-f41.google.com with SMTP id 4fb4d7f45d1cf-55a356f8440so6777797a12.2 for ; Wed, 24 Jan 2024 07:27:35 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706110053; x=1706714853; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=8FxnNBtkEIr9Vr7LOwdU5jTdmDcPZNIOUxI8CHhGmXU=; b=ZvPo7dxD88UGlxxhO8uixGV5YYKoHTjmkefXG3IwRg2jlm0KozK4GZggunQw618uGR JT9EOi2u9wUdvmPUBBZqkeNNmiJpwl5NFCttO97rCcNgi0gj8w2j0gvYN+dMGJPejx5L JERCnnfxh8o2rw6ndPenN8fPa3YKuoKl8ADjzLTPz/APDZz5pbnvnYEu0ZgtDmubXWaJ 7didDwkEjEbGo+KjidfgRjHvAktGTAIPUYvRwJ/s0ugOpBwa6vezvVqA75ZBnGOFoXjo dk2Tf88vaGttk7mipfn0tuUzMXSMGykbPc6R32Bj4Bk+i0H57AfsW794oYJsj9hucPea Hy2Q== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706110053; x=1706714853; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=8FxnNBtkEIr9Vr7LOwdU5jTdmDcPZNIOUxI8CHhGmXU=; b=FLn/zDdac1H4iie3oeKOKixCibb6jR7PIbd/paWjtceNJnLY0Lwe8DqfzhUvxb2iYa m/mkS788EOttUcnqVj2Wo+cSqbNf+MUPXvlIoyi3BSCi2Cs9Q9VZRJUXUPHOq4vYSZyE rsU1nHir9xURQOGtFpmk9B8cR3BdvBM59YdmLttt6+kdfVJipwtY0e3ETdTXF7eLz1+S tOLSUiLj+B6C90VeFcnLooR8xyyXwgpnvUNMnrWC2cbbHbllrn//A9J2K3DjJjQ9kj0h kg1zGr8DobG8czDgF30att8ptdQo0BS1gUZkCeuwzWrmq7i7VeNgoqAGZN93fOEeHYjJ EE/g== X-Gm-Message-State: AOJu0Yxq6+P/NRsKZAKOIpmqUqisg+FU7J/+GV2a9Dn1wXQGrkCek+km DWowZOpSYaMsleZQ7IrSXZEQ7zh6YwG5G4bOSe3F3yxcOEU0z1+bhFrnKE3U X-Google-Smtp-Source: AGHT+IFrFokLWzXiSgbbSkgfS4lm8+TiX3+O0OWE4P6WPCjEK9KR2pDt5kT+QP+VnI1RRRY66TNJ9w== X-Received: by 2002:a17:907:619d:b0:a31:1313:fcf5 with SMTP id mt29-20020a170907619d00b00a311313fcf5mr688498ejc.121.1706110053223; Wed, 24 Jan 2024 07:27:33 -0800 (PST) Received: from localhost.localdomain (h-213.61.124.196.host.de.colt.net. [213.61.124.196]) by smtp.gmail.com with ESMTPSA id vh12-20020a170907d38c00b00a2eb648cdc5sm8765225ejc.156.2024.01.24.07.27.32 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:27:32 -0800 (PST) From: Karthik Nayak To: git@vger.kernel.org Cc: gitster@pobox.com, ps@pks.im, phillip.wood123@gmail.com, Karthik Nayak Subject: [PATCH v2 2/4] refs: extract out `loose_fill_ref_dir_regular_file()` Date: Wed, 24 Jan 2024 16:27:24 +0100 Message-ID: <20240124152726.124873-3-karthik.188@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124152726.124873-1-karthik.188@gmail.com> References: <20240119142705.139374-1-karthik.188@gmail.com> <20240124152726.124873-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Extract out the code for adding a single file to the loose ref dir as `loose_fill_ref_dir_regular_file()` from `loose_fill_ref_dir()` in `refs/files-backend.c`. This allows us to use this function independently in the following commits where we add code to also add pseudorefs to the ref dir. Signed-off-by: Karthik Nayak --- refs/files-backend.c | 62 +++++++++++++++++++++++--------------------- 1 file changed, 33 insertions(+), 29 deletions(-) diff --git a/refs/files-backend.c b/refs/files-backend.c index b288fc97db..22495a4807 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -229,6 +229,38 @@ static void add_per_worktree_entries_to_dir(struct ref_dir *dir, const char *dir } } +static void loose_fill_ref_dir_regular_file(struct files_ref_store *refs, + const char *refname, + struct ref_dir *dir) +{ + struct object_id oid; + int flag; + + if (!refs_resolve_ref_unsafe(&refs->base, refname, RESOLVE_REF_READING, + &oid, &flag)) { + oidclr(&oid); + flag |= REF_ISBROKEN; + } else if (is_null_oid(&oid)) { + /* + * It is so astronomically unlikely + * that null_oid is the OID of an + * actual object that we consider its + * appearance in a loose reference + * file to be repo corruption + * (probably due to a software bug). + */ + flag |= REF_ISBROKEN; + } + + if (check_refname_format(refname, REFNAME_ALLOW_ONELEVEL)) { + if (!refname_is_safe(refname)) + die("loose refname is dangerous: %s", refname); + oidclr(&oid); + flag |= REF_BAD_NAME | REF_ISBROKEN; + } + add_entry_to_dir(dir, create_ref_entry(refname, &oid, flag)); +} + /* * Read the loose references from the namespace dirname into dir * (without recursing). dirname must end with '/'. dir must be the @@ -257,8 +289,6 @@ static void loose_fill_ref_dir(struct ref_store *ref_store, strbuf_add(&refname, dirname, dirnamelen); while ((de = readdir(d)) != NULL) { - struct object_id oid; - int flag; unsigned char dtype; if (de->d_name[0] == '.') @@ -274,33 +304,7 @@ static void loose_fill_ref_dir(struct ref_store *ref_store, create_dir_entry(dir->cache, refname.buf, refname.len)); } else if (dtype == DT_REG) { - if (!refs_resolve_ref_unsafe(&refs->base, - refname.buf, - RESOLVE_REF_READING, - &oid, &flag)) { - oidclr(&oid); - flag |= REF_ISBROKEN; - } else if (is_null_oid(&oid)) { - /* - * It is so astronomically unlikely - * that null_oid is the OID of an - * actual object that we consider its - * appearance in a loose reference - * file to be repo corruption - * (probably due to a software bug). - */ - flag |= REF_ISBROKEN; - } - - if (check_refname_format(refname.buf, - REFNAME_ALLOW_ONELEVEL)) { - if (!refname_is_safe(refname.buf)) - die("loose refname is dangerous: %s", refname.buf); - oidclr(&oid); - flag |= REF_BAD_NAME | REF_ISBROKEN; - } - add_entry_to_dir(dir, - create_ref_entry(refname.buf, &oid, flag)); + loose_fill_ref_dir_regular_file(refs, refname.buf, dir); } strbuf_setlen(&refname, dirnamelen); } From patchwork Wed Jan 24 15:27:25 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13529329 Received: from mail-ej1-f41.google.com (mail-ej1-f41.google.com [209.85.218.41]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D64E57C082 for ; Wed, 24 Jan 2024 15:27:36 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.218.41 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110058; cv=none; b=D8GqOaj8Wd/Jm8L6uZEHVy5+SpESUswTCxbWhJQsL23B3a2DpV6t/fo2fpwgUfnyou5lBHfR4zsxnbIJYVFLjV03yP32YV2RgR3WJCeF+i8vap1eB0SUqmmYhCqKGKf9mtSHwekwoKhY2awl0H2ILGzDiBfOduhP4ThNg953f64= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110058; c=relaxed/simple; bh=kMHjm0vW4KrKL9zS5Vbb9FdcuC2jut1CePPUxv6nzy4=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=lE/gAHZdhPBbxIg73R+PA33DmUy99B9BwtZwfuIA0nTxTFjII2QipZ8vwDZc2KfzgGRWmCbl4Aejk3vVTpZ41OULnTwqQt3H08xUwqJqToO6xVaJzC6cxDcki0yrJM5iwX/Y3fmfLDMpyn8sQXGMx2Ue2C6m+QNGiF51ryJ8Uiw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=K+qkF1o4; arc=none smtp.client-ip=209.85.218.41 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="K+qkF1o4" Received: by mail-ej1-f41.google.com with SMTP id a640c23a62f3a-a27733ae1dfso585020266b.3 for ; Wed, 24 Jan 2024 07:27:36 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706110055; x=1706714855; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=7/gXFwX3SQKYntZyT+ywDtXxDQAYIr4+FKRoWw76F5A=; b=K+qkF1o4G0Hx5JTcUrkmPtghkA8/NVaJ14hwpqpGfFw+CR2dcOm0Bv9EKBSdZcaV8Z 6ldI1JaicemqmEj5HqOB/TzomHFYxaw0ymGlHVVvOUD71okBc9msa4FIWu/DpRft+UMH 6IG0yjqAFnZDN09E113ZQvISnVERDpdPrnU0IpKe3l/5/JxNUYDQvP/Huw0nAhGj9l9e LULMIpRIo3tDC+5ZTxoX41DFqdNdR3cpgpYazZrw7OTS3W4CYMJ6JbcWDIvh3MeJhJ/j aVvt+pA2+zBoYDdEcu2/Oqy5f2GMEdCm4h+JruxyyQaB14MFPZxvBcgWcAXTtPdWPxLZ ZYjQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706110055; x=1706714855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7/gXFwX3SQKYntZyT+ywDtXxDQAYIr4+FKRoWw76F5A=; b=l/Cny7eZIi5RteyJa4jT5v1rKo+kUX49+Qk7kzBFXUywDYhVoln/QtP31LDUmjNNwJ vIwIB+xsmigKuD8/2ND4JI/jNUaKBg7x6wF+VPOHPljUmAilwwZk84JEQTk8Q/zUDbMk uU7me8wVNQRn///kVElvRaf0Il+G5nBTDlsEt5qaVltd0/EUcRvDO+/r3YZvLER+UVEg Ym9J/pGPrPvCQaXXgaUlzTAIXCwNG7AVOqI57vEYk3X3oZ28Hyh/CRQ1UjxKC1Ndj3A2 EatUAZdnp+kheAbBsuxRb8/4MCzr3FQz9NMBfn058GEB7cPsJdEBRvqG2dbUJxgrUs6x q1SA== X-Gm-Message-State: AOJu0YxOCzTo7cTKHn3QS5OaGxwloryuhkgmcuFyQmPfxc32Kf5Xn0nN N0Mmx495m4v0sjAoR3OXkz17L0qSQkhsTSJmLnMr7HuaHcewtl9DAfQgZXvL X-Google-Smtp-Source: AGHT+IFMZp8VZ/gnarkYSY5Yw/vGa5WBIVTe7k+w03GSU7z9QVU6+FANPlw5qBdMITJj7CclGVTiJg== X-Received: by 2002:a17:906:8920:b0:a30:deb6:1bb7 with SMTP id fr32-20020a170906892000b00a30deb61bb7mr473558ejc.132.1706110054276; Wed, 24 Jan 2024 07:27:34 -0800 (PST) Received: from localhost.localdomain (h-213.61.124.196.host.de.colt.net. [213.61.124.196]) by smtp.gmail.com with ESMTPSA id vh12-20020a170907d38c00b00a2eb648cdc5sm8765225ejc.156.2024.01.24.07.27.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:27:33 -0800 (PST) From: Karthik Nayak To: git@vger.kernel.org Cc: gitster@pobox.com, ps@pks.im, phillip.wood123@gmail.com, Karthik Nayak Subject: [PATCH v2 3/4] refs: introduce `refs_for_each_all_refs()` Date: Wed, 24 Jan 2024 16:27:25 +0100 Message-ID: <20240124152726.124873-4-karthik.188@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124152726.124873-1-karthik.188@gmail.com> References: <20240119142705.139374-1-karthik.188@gmail.com> <20240124152726.124873-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Introduce a new ref iteration flag `DO_FOR_EACH_INCLUDE_ALL_REFS`, which will be used to iterate over all refs. In the files backend this is limited to regular refs, pseudorefs and HEAD. For other backends like the reftable this is the universal set of all refs stored in the backend. Refs which fall outside the `refs/` and aren't either pseudorefs or HEAD are more of a grey area. This is because we don't block the users from creating such refs but they are not officially supported. In the files backend, we can isolate such files from other files. Introduce `refs_for_each_all_refs()` which calls `do_for_each_ref()` with this newly introduced flag. In `refs/files-backend.c`, introduce a new function `add_pseudoref_and_head_entries()` to add pseudorefs and HEAD to the `ref_dir`. We then finally call `add_pseudoref_and_head_entries()` whenever the `DO_FOR_EACH_INCLUDE_ALL_REFS` flag is set. Any new ref backend will also have to implement similar changes on its end. Signed-off-by: Karthik Nayak --- refs.c | 7 +++++ refs.h | 6 ++++ refs/files-backend.c | 65 ++++++++++++++++++++++++++++++++++++++++---- refs/refs-internal.h | 7 +++++ 4 files changed, 80 insertions(+), 5 deletions(-) diff --git a/refs.c b/refs.c index 4b6bfc66fb..b5e63f133a 100644 --- a/refs.c +++ b/refs.c @@ -1755,6 +1755,13 @@ int for_each_rawref(each_ref_fn fn, void *cb_data) return refs_for_each_rawref(get_main_ref_store(the_repository), fn, cb_data); } +int refs_for_each_all_refs(struct ref_store *refs, each_ref_fn fn, + void *cb_data) +{ + return do_for_each_ref(refs, "", NULL, fn, 0, + DO_FOR_EACH_INCLUDE_ALL_REFS, cb_data); +} + static int qsort_strcmp(const void *va, const void *vb) { const char *a = *(const char **)va; diff --git a/refs.h b/refs.h index 46b8085d63..77ecb820f9 100644 --- a/refs.h +++ b/refs.h @@ -396,6 +396,12 @@ int for_each_namespaced_ref(const char **exclude_patterns, int refs_for_each_rawref(struct ref_store *refs, each_ref_fn fn, void *cb_data); int for_each_rawref(each_ref_fn fn, void *cb_data); +/* + * Iterates over all ref types, regular, pseudorefs and HEAD. + */ +int refs_for_each_all_refs(struct ref_store *refs, each_ref_fn fn, + void *cb_data); + /* * Normalizes partial refs to their fully qualified form. * Will prepend to the if it doesn't start with 'refs/'. diff --git a/refs/files-backend.c b/refs/files-backend.c index 22495a4807..104f2e1ac7 100644 --- a/refs/files-backend.c +++ b/refs/files-backend.c @@ -315,9 +315,59 @@ static void loose_fill_ref_dir(struct ref_store *ref_store, add_per_worktree_entries_to_dir(dir, dirname); } -static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs) +/* + * Add pseudorefs to the ref dir by parsing the directory for any files + * which follow the pseudoref syntax. + */ +static void add_pseudoref_and_head_entries(struct ref_store *ref_store, + struct ref_dir *dir, + const char *dirname) +{ + struct files_ref_store *refs = + files_downcast(ref_store, REF_STORE_READ, "fill_ref_dir"); + struct strbuf path = STRBUF_INIT, refname = STRBUF_INIT; + struct dirent *de; + size_t dirnamelen; + DIR *d; + + files_ref_path(refs, &path, dirname); + + d = opendir(path.buf); + if (!d) { + strbuf_release(&path); + return; + } + + strbuf_addstr(&refname, dirname); + dirnamelen = refname.len; + + while ((de = readdir(d)) != NULL) { + unsigned char dtype; + + if (de->d_name[0] == '.') + continue; + if (ends_with(de->d_name, ".lock")) + continue; + strbuf_addstr(&refname, de->d_name); + + dtype = get_dtype(de, &path, 1); + if (dtype == DT_REG && (is_pseudoref(ref_store, de->d_name) || + is_headref(ref_store, de->d_name))) + loose_fill_ref_dir_regular_file(refs, refname.buf, dir); + + strbuf_setlen(&refname, dirnamelen); + } + strbuf_release(&refname); + strbuf_release(&path); + closedir(d); +} + +static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs, + unsigned int flags) { if (!refs->loose) { + struct ref_dir *dir; + /* * Mark the top-level directory complete because we * are about to read the only subdirectory that can @@ -328,12 +378,17 @@ static struct ref_cache *get_loose_ref_cache(struct files_ref_store *refs) /* We're going to fill the top level ourselves: */ refs->loose->root->flag &= ~REF_INCOMPLETE; + dir = get_ref_dir(refs->loose->root); + + if (flags & DO_FOR_EACH_INCLUDE_ALL_REFS) + add_pseudoref_and_head_entries(dir->cache->ref_store, dir, + refs->loose->root->name); + /* * Add an incomplete entry for "refs/" (to be filled * lazily): */ - add_entry_to_dir(get_ref_dir(refs->loose->root), - create_dir_entry(refs->loose, "refs/", 5)); + add_entry_to_dir(dir, create_dir_entry(refs->loose, "refs/", 5)); } return refs->loose; } @@ -861,7 +916,7 @@ static struct ref_iterator *files_ref_iterator_begin( * disk, and re-reads it if not. */ - loose_iter = cache_ref_iterator_begin(get_loose_ref_cache(refs), + loose_iter = cache_ref_iterator_begin(get_loose_ref_cache(refs, flags), prefix, ref_store->repo, 1); /* @@ -1222,7 +1277,7 @@ static int files_pack_refs(struct ref_store *ref_store, packed_refs_lock(refs->packed_ref_store, LOCK_DIE_ON_ERROR, &err); - iter = cache_ref_iterator_begin(get_loose_ref_cache(refs), NULL, + iter = cache_ref_iterator_begin(get_loose_ref_cache(refs, 0), NULL, the_repository, 0); while ((ok = ref_iterator_advance(iter)) == ITER_OK) { /* diff --git a/refs/refs-internal.h b/refs/refs-internal.h index 8e9f04cc67..1cf7506435 100644 --- a/refs/refs-internal.h +++ b/refs/refs-internal.h @@ -260,6 +260,13 @@ enum do_for_each_ref_flags { * INCLUDE_BROKEN, since they are otherwise not included at all. */ DO_FOR_EACH_OMIT_DANGLING_SYMREFS = (1 << 2), + + /* + * Include all refs in the $GIT_DIR in contrast to generally only listing + * references having the "refs/" prefix. In the files-backend this is + * limited to regular refs, pseudorefs and HEAD. + */ + DO_FOR_EACH_INCLUDE_ALL_REFS = (1 << 3), }; /* From patchwork Wed Jan 24 15:27:26 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: karthik nayak X-Patchwork-Id: 13529330 Received: from mail-lf1-f42.google.com (mail-lf1-f42.google.com [209.85.167.42]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 9DCE57C0A8 for ; Wed, 24 Jan 2024 15:27:37 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.167.42 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110059; cv=none; b=M1Da2J8BlzZXOv4l6f9R14NDDP9AdiSFa5gj9CQrAkurzaJyf8nhV0J2W2HqvQmDuJMAKT+qiKdqbW4wJMlaAXLvkW9O0DcUbS4cPHH0DEHEOslmCXMR0c/nkI5sYq+lKEwY4zfrtY6+bJM1UA/77DUrvvs1tG4NHJVgwUnobi8= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1706110059; c=relaxed/simple; bh=C7vDmXLEbXtY3oiqVbuMkZJlKMjB4TZLmmsS529QZQY=; h=From:To:Cc:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version; b=EjldigVqDP2ypA18k0+aR7QQMZkmbPPlULPoRsH+KHW/44SWAG5cAE6kLMYKMU3B7z6pfKlxdfiK10+GCBlTRFyzfn5pulPsnfvXt4y7zuCSBJDa2WC3dO3vIjM0bOLoXIn+rZKhATNEUM4ZsWOBWxLnwjDp/rCxhIJC7VIo3OA= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com; spf=pass smtp.mailfrom=gmail.com; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b=WeBtmhRn; arc=none smtp.client-ip=209.85.167.42 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=gmail.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=gmail.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=gmail.com header.i=@gmail.com header.b="WeBtmhRn" Received: by mail-lf1-f42.google.com with SMTP id 2adb3069b0e04-50e72e3d435so5131238e87.2 for ; Wed, 24 Jan 2024 07:27:37 -0800 (PST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20230601; t=1706110055; x=1706714855; darn=vger.kernel.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:from:to:cc:subject:date :message-id:reply-to; bh=mZfgvTKUs0RX0aUMcHBIQZV5urECTbu3T6yTamxXDFk=; b=WeBtmhRnM9sFtoEfqkLSltp4E5QEpevYW/f0sRvD/TqUXl89WPKqX71691kCFcOFs4 7pSEiqU22ZmzS1ta8RX6UcCGL/sLp0zUGbtATqVtOfTWLYba72/4jtvJyDbU9bXAFJ0n LVdNi/iPLh1oRP4VDsW/MFFm2/KtQwGigeq3MLDA7yQ5dkUq7Q1BKLIdgsVtLRq3erKX KWzzhWMhG6yMnjt57Hmgo8fq3YM4Q4/q2bgCCyMXTMO2zqwaD2aJulumEyT9IDZGmU74 TM5JD+kefwXStaYQuxSSTH7Twm95Q1UtT5Gx+NEmzBlRzRfZGj+Xx2cQtny4Hv16IeDk QIaQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1706110055; x=1706714855; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=mZfgvTKUs0RX0aUMcHBIQZV5urECTbu3T6yTamxXDFk=; b=esjhqIqaI5fhonLo8HMBMA538GDNOChJ1EoOQiO2Wctko9QrQZzPi3YKDeIXTzlj9q jaIjz3Tfs6Xw8FD1NdOcAx/VX8xwisnMoOt9aDZgqvB+06/X4CC/L2Hr7wd44ztHw1hN +ROF3nL8DERnuqfk1YO85boJpeFI+f9bs85cno5oswzZKmdu9GyLCWoAPlQBmxt571fY a7xWoYdSFDM7s1Tc7SoQ903fFohcIYHA7fGRrivqt3U9V9o69UhzQ49OKWAcebM/ZKYY zRrhBQneM6InKxogzhAAcmBrepQNiiH82oMQvMtjTxYbgu2Cr7UeauwOshHGFVq7jM78 y7KA== X-Gm-Message-State: AOJu0YxCSDBvuykI0643E50zIffOWpGOmH1dCo2A7AP6kv3psWjjkiuT TS/JjebqseiayJjP8sO+7OPujLfRRutDzMD4ovqIlRf5RcXAZ1Vjnw1uMl96 X-Google-Smtp-Source: AGHT+IFDt3sNnXwXvyeIJivn8t5rpLR4P9yLTzWHOKwbDhmITD3lDxZU0SZ4aA2uh0FI9XexhpcGkA== X-Received: by 2002:a05:6512:33d1:b0:50e:7723:8f9a with SMTP id d17-20020a05651233d100b0050e77238f9amr2717913lfg.30.1706110055050; Wed, 24 Jan 2024 07:27:35 -0800 (PST) Received: from localhost.localdomain (h-213.61.124.196.host.de.colt.net. [213.61.124.196]) by smtp.gmail.com with ESMTPSA id vh12-20020a170907d38c00b00a2eb648cdc5sm8765225ejc.156.2024.01.24.07.27.34 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Wed, 24 Jan 2024 07:27:34 -0800 (PST) From: Karthik Nayak To: git@vger.kernel.org Cc: gitster@pobox.com, ps@pks.im, phillip.wood123@gmail.com, Karthik Nayak Subject: [PATCH v2 4/4] for-each-ref: avoid filtering on empty pattern Date: Wed, 24 Jan 2024 16:27:26 +0100 Message-ID: <20240124152726.124873-5-karthik.188@gmail.com> X-Mailer: git-send-email 2.43.0 In-Reply-To: <20240124152726.124873-1-karthik.188@gmail.com> References: <20240119142705.139374-1-karthik.188@gmail.com> <20240124152726.124873-1-karthik.188@gmail.com> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 When the user uses an empty string pattern (""), we don't match any refs in git-for-each-ref(1). This is because in git-for-each-ref(1), we use path based matching and an empty string doesn't match any path. In this commit we change this behavior by making empty string pattern match all references. This is done by introducing a new flag `FILTER_REFS_NO_FILTER` in `ref-filter.c`, which uses the newly introduced `refs_for_each_all_refs()` function to iterate over all the refs in the repository. Signed-off-by: Karthik Nayak --- Documentation/git-for-each-ref.txt | 3 ++- builtin/for-each-ref.c | 21 +++++++++++++++++- ref-filter.c | 13 ++++++++++-- ref-filter.h | 4 +++- t/t6302-for-each-ref-filter.sh | 34 ++++++++++++++++++++++++++++++ 5 files changed, 70 insertions(+), 5 deletions(-) diff --git a/Documentation/git-for-each-ref.txt b/Documentation/git-for-each-ref.txt index be9543f684..b1cb482bf5 100644 --- a/Documentation/git-for-each-ref.txt +++ b/Documentation/git-for-each-ref.txt @@ -32,7 +32,8 @@ OPTIONS If one or more patterns are given, only refs are shown that match against at least one pattern, either using fnmatch(3) or literally, in the latter case matching completely or from the - beginning up to a slash. + beginning up to a slash. If an empty string is provided all refs + are printed, including HEAD and pseudorefs. --stdin:: If `--stdin` is supplied, then the list of patterns is read from diff --git a/builtin/for-each-ref.c b/builtin/for-each-ref.c index 3885a9c28e..5aa879e8be 100644 --- a/builtin/for-each-ref.c +++ b/builtin/for-each-ref.c @@ -25,6 +25,7 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) struct ref_format format = REF_FORMAT_INIT; int from_stdin = 0; struct strvec vec = STRVEC_INIT; + unsigned int flags = FILTER_REFS_ALL; struct option opts[] = { OPT_BIT('s', "shell", &format.quote_style, @@ -93,11 +94,29 @@ int cmd_for_each_ref(int argc, const char **argv, const char *prefix) /* vec.v is NULL-terminated, just like 'argv'. */ filter.name_patterns = vec.v; } else { + size_t i; + filter.name_patterns = argv; + + /* + * Search for any empty string pattern, if it exists then we + * print all refs without any filtering. + */ + i = 0; + while (argv[i]) { + if (!argv[i][0]) { + flags = FILTER_REFS_NO_FILTER; + /* doing this removes any pattern from being matched */ + filter.name_patterns[0] = NULL; + break; + } + + i++; + } } filter.match_as_path = 1; - filter_and_format_refs(&filter, FILTER_REFS_ALL, sorting, &format); + filter_and_format_refs(&filter, flags, sorting, &format); ref_filter_clear(&filter); ref_sorting_release(sorting); diff --git a/ref-filter.c b/ref-filter.c index 35b989e1df..6dac133b87 100644 --- a/ref-filter.c +++ b/ref-filter.c @@ -2622,6 +2622,11 @@ static int for_each_fullref_in_pattern(struct ref_filter *filter, each_ref_fn cb, void *cb_data) { + if (filter->kind & FILTER_REFS_NO_FILTER) { + return refs_for_each_all_refs( + get_main_ref_store(the_repository), cb, cb_data); + } + if (!filter->match_as_path) { /* * in this case, the patterns are applied after @@ -2775,8 +2780,12 @@ static struct ref_array_item *apply_ref_filter(const char *refname, const struct /* Obtain the current ref kind from filter_ref_kind() and ignore unwanted refs. */ kind = filter_ref_kind(filter, refname); - if (!(kind & filter->kind)) + if (filter->kind & FILTER_REFS_NO_FILTER) { + if (kind == FILTER_REFS_DETACHED_HEAD) + kind = FILTER_REFS_OTHERS; + } else if (!(kind & filter->kind)) { return NULL; + } if (!filter_pattern_match(filter, refname)) return NULL; @@ -3041,7 +3050,7 @@ static int do_filter_refs(struct ref_filter *filter, unsigned int type, each_ref ret = for_each_fullref_in("refs/remotes/", fn, cb_data); else if (filter->kind == FILTER_REFS_TAGS) ret = for_each_fullref_in("refs/tags/", fn, cb_data); - else if (filter->kind & FILTER_REFS_ALL) + else if (filter->kind & FILTER_REFS_ALL || filter->kind & FILTER_REFS_NO_FILTER) ret = for_each_fullref_in_pattern(filter, fn, cb_data); if (!ret && (filter->kind & FILTER_REFS_DETACHED_HEAD)) head_ref(fn, cb_data); diff --git a/ref-filter.h b/ref-filter.h index 07cd6f6da3..1eab325ce0 100644 --- a/ref-filter.h +++ b/ref-filter.h @@ -22,7 +22,9 @@ #define FILTER_REFS_ALL (FILTER_REFS_TAGS | FILTER_REFS_BRANCHES | \ FILTER_REFS_REMOTES | FILTER_REFS_OTHERS) #define FILTER_REFS_DETACHED_HEAD 0x0020 -#define FILTER_REFS_KIND_MASK (FILTER_REFS_ALL | FILTER_REFS_DETACHED_HEAD) +#define FILTER_REFS_NO_FILTER 0x0040 +#define FILTER_REFS_KIND_MASK (FILTER_REFS_ALL | FILTER_REFS_DETACHED_HEAD | \ + FILTER_REFS_NO_FILTER) struct atom_value; struct ref_sorting; diff --git a/t/t6302-for-each-ref-filter.sh b/t/t6302-for-each-ref-filter.sh index 82f3d1ea0f..3922326cab 100755 --- a/t/t6302-for-each-ref-filter.sh +++ b/t/t6302-for-each-ref-filter.sh @@ -31,6 +31,40 @@ test_expect_success 'setup some history and refs' ' git update-ref refs/odd/spot main ' +cat >expect <<-\EOF + HEAD + ORIG_HEAD + refs/heads/main + refs/heads/side + refs/odd/spot + refs/tags/annotated-tag + refs/tags/doubly-annotated-tag + refs/tags/doubly-signed-tag + refs/tags/four + refs/tags/one + refs/tags/signed-tag + refs/tags/three + refs/tags/two +EOF + +test_expect_success 'empty pattern prints pseudorefs' ' + git update-ref ORIG_HEAD main && + git for-each-ref --format="%(refname)" "" >actual && + test_cmp expect actual +' + +test_expect_success 'empty pattern with other patterns' ' + git update-ref ORIG_HEAD main && + git for-each-ref --format="%(refname)" "" "refs/" >actual && + test_cmp expect actual +' + +test_expect_success 'empty pattern towards the end' ' + git update-ref ORIG_HEAD main && + git for-each-ref --format="%(refname)" "refs/" "" >actual && + test_cmp expect actual +' + test_expect_success 'filtering with --points-at' ' cat >expect <<-\EOF && refs/heads/main