From patchwork Wed Feb 21 09:56:36 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13565364 Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B7B5E3D576 for ; Wed, 21 Feb 2024 09:56:40 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708509402; cv=none; b=FN77zXHa5sGd+7/oSffYttbXVME2KNqr8/6JpFxtaiCiLCs2j3nC0tdGZ1nmC+62slepSLQ81COoR5/yhKaQEkK/CjjgIA79Gu96hyNcb4RxRiQC92SAmqu2MSLMYn96QacGcRNAHV4k65DpP+UZx7WZbCfbxLwQBhuHJBSQ/Ak= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708509402; c=relaxed/simple; bh=jkpXfDrbOQqHj4UfAuSPAW2q2Bdk13NbVjzMzi+lgCU=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=qLF0hTjL1a9V5uikJyiO6M5ULXrfN7usY6ozIkRj8g/4g8yCEQfMZzWv74LIw4mEUBRRpcjeUHv3cgszei1PcWnyVc/C7Z6LA3JkSUR06pWKHSHRO6buoJxqEt084KZoIYZ9PzbhMEY/EkZgVIcJhOX+W9g5kPy+Kg6jFM8RMUQ= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=cGt5cmAl; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=YXomi1lS; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="cGt5cmAl"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="YXomi1lS" Received: from compute7.internal (compute7.nyi.internal [10.202.2.48]) by mailfhigh.nyi.internal (Postfix) with ESMTP id B519111400C4; Wed, 21 Feb 2024 04:56:39 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute7.internal (MEProxy); Wed, 21 Feb 2024 04:56:39 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1708509399; x=1708595799; bh=4MnM4HOqAY YD6Z7FBRgpkjggrp7riTLlGLOh+MOQkXE=; b=cGt5cmAlFkIS8ZZiZD/PbJrvfq cho3wTFE4uoxI56yxlINMYfpOtj9CrISMgBlYi9lXgwKeCB/8Qf54pPjbdQm+5rN ppOkxI2RAGyJTHx2b4zX8rIhqA5lApDAxBOXv7oCeCpJemcYF1DPda0PzAjsQ6+U d7JKcS8XQrdxb6IGP1G/BwWTXBaT7yVSlBvXvDkaUiMPKf65AqNhzSylJx4ANHQq hqgFJz1JQNE7tvrzp+oIkBvLwdRyJ0vckxrSjRtlH2An8VYAX5LAFk4TAKafDQVi JaC3o3jaN4wdyRoB9wzwgOqVUaLh13s8/DdVWBXCyMiMbvixkcwVez2XOgJg== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708509399; x=1708595799; bh=4MnM4HOqAYYD6Z7FBRgpkjggrp7r iTLlGLOh+MOQkXE=; b=YXomi1lSoG2j1fe4ITunF3KCbhhcTk8lVoaDaxBaLSnj R5wOewEllzfh0vTiKtd7Eo2pEGgKEa0t6HCAZeZ8oLNHaHWr9tyg5/sdkacfn0j0 S5scwquVZ9Uesy3eXRwhXeeFrylbNhXJPRuAfUvzdkVn9zoCgltgBECeZSMHAzfe Mu0LP+T9YNO6TNWitwG5IHu0xubt2oAPJC+GCYjvDUfFqyw4B8bKWWQvkRr9x4+S ASXMaet5Px+iKkFQORyiSPaDS7Cke/C8DM3eXjAv08CXeG3jazA6QsVrenTW/SYY 4vnthLWG1sKeE/Waf1YROMThaaKKVOImZw2oVs8YiA== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleffteen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesph hkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Feb 2024 04:56:38 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 207c463e (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 21 Feb 2024 09:52:34 +0000 (UTC) Date: Wed, 21 Feb 2024 10:56:36 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Yasushi SHOJI Subject: [PATCH 1/2] object-name: detect and report empty reflogs Message-ID: <0fac6ebb098c7e8cdc87cb75f2dcffdc4b1ccfaa.1708509190.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The `ref@{n}` syntax allows the user to request the n'th reflog entry for a ref. This syntax is zero-indexed, meaning that entry zero refers to the first entry in the reflog. The behaviour here is quite confusing though and depends on the state of the corresponding reflog: - If the reflog is not empty, we return the first reflog entry. - If the reflog is empty, we return the object ID of the ref. - If the reflog is missing, we return an error. This is inconsistent and quite misleading. This behaviour goes back to 6436a20284 (refs: allow @{n} to work with n-sized reflog, 2021-01-07), which fixed a bug that wouldn't allow a user to return the n'th reflog entry with an n-sized reflog. With this commit, `read_ref_at()` started to special case reading the first entry of the reflog via a separate `read_ref_at_ent_newest()` function. The problem here is that we forgot to check whether the callback was invoked at all, and thus we don't notice empty reflogs. The commit in question added a test for `ref@{0}` when the reflog is empty. But that test only works by chance: while `read_ref_at()` won't initialize the object ID passed in by the pointer, all callers of this function happen to call `repo_ref_dwim()` and thus pre-populate the object ID. Thus, the consequence is that we indeed return the object ID of the refname when the reflog is empty. This behaviour is documented nowhere, and the fact that we return a somewhat sensible result to the caller by sheer luck further stresses the point that this behaviour is only accidental, even if there is a test covering it. Furthermore, this behaviour causes problems for the git-show-branch(1) command. When executing `git show-branch --reflog` for a ref that either has no or an empty reflog we run into a segfault. This is because the `read_ref_at()` function doesn't report the error to us, and thus parts of its out-parameters are not initialized. Start to detect and report empty or missing reflogs in `read_ref_at()` and report them to the caller. This results in a change in behaviour when asking for `ref@{0}` with an empty or missing reflog because we now die instead of returning the object ID of the ref itself. This adapted behaviour should lead to less surprises as we now really only report object IDs to the caller that actually come from the reflog, thus making the user experience a whole lot more consistent. This change also fixes the segfault in git-show-branch(1). Note that this commit does not add a test yet -- this will be handled in the next commit. Reported-by: Yasushi SHOJI Signed-off-by: Patrick Steinhardt --- object-name.c | 10 ++++++---- refs.c | 3 ++- t/t1506-rev-parse-diagnosis.sh | 8 ++++++++ t/t1508-at-combinations.sh | 29 +++++++++++++++++++++++++---- 4 files changed, 41 insertions(+), 9 deletions(-) diff --git a/object-name.c b/object-name.c index 3a2ef5d680..e2a6c9d2ec 100644 --- a/object-name.c +++ b/object-name.c @@ -994,8 +994,8 @@ static int get_oid_basic(struct repository *r, const char *str, int len, if (reflog_len) { int nth, i; timestamp_t at_time; - timestamp_t co_time; - int co_tz, co_cnt; + timestamp_t co_time = 0; + int co_tz = 0, co_cnt = 0; /* Is it asking for N-th entry, or approxidate? */ for (i = nth = 0; 0 <= nth && i < reflog_len; i++) { @@ -1020,6 +1020,7 @@ static int get_oid_basic(struct repository *r, const char *str, int len, return -1; } } + if (read_ref_at(get_main_ref_store(r), real_ref, flags, at_time, nth, oid, NULL, &co_time, &co_tz, &co_cnt)) { @@ -1035,9 +1036,10 @@ static int get_oid_basic(struct repository *r, const char *str, int len, show_date(co_time, co_tz, DATE_MODE(RFC2822))); } } else { - if (flags & GET_OID_QUIETLY) { + if (flags & GET_OID_QUIETLY) exit(128); - } + if (!co_cnt) + die(_("log for '%.*s' is empty"), len, str); die(_("log for '%.*s' only has %d entries"), len, str, co_cnt); } diff --git a/refs.c b/refs.c index c633abf284..a2369e7835 100644 --- a/refs.c +++ b/refs.c @@ -1084,6 +1084,7 @@ static int read_ref_at_ent_newest(struct object_id *ooid UNUSED, struct read_ref_at_cb *cb = cb_data; set_read_ref_cutoffs(cb, timestamp, tz, message); + cb->found_it = 1; oidcpy(cb->oid, noid); /* We just want the first entry */ return 1; @@ -1123,7 +1124,7 @@ int read_ref_at(struct ref_store *refs, const char *refname, if (cb.cnt == 0) { refs_for_each_reflog_ent_reverse(refs, refname, read_ref_at_ent_newest, &cb); - return 0; + return !cb.found_it; } refs_for_each_reflog_ent_reverse(refs, refname, read_ref_at_ent, &cb); diff --git a/t/t1506-rev-parse-diagnosis.sh b/t/t1506-rev-parse-diagnosis.sh index ef40511d89..9d147c4ade 100755 --- a/t/t1506-rev-parse-diagnosis.sh +++ b/t/t1506-rev-parse-diagnosis.sh @@ -140,6 +140,14 @@ test_expect_success 'incorrect file in :path and :N:path' ' test_grep "path .disk-only.txt. exists on disk, but not in the index" error ' +test_expect_success '@{0} reference with empty reflog' ' + git checkout -B empty-reflog main && + git reflog expire --expire=now refs/heads/empty-reflog && + test_must_fail git rev-parse empty-reflog@{0} >output 2>error && + test_must_be_empty output && + test_grep "log for ${SQ}empty-reflog${SQ} is empty" error +' + test_expect_success 'invalid @{n} reference' ' test_must_fail git rev-parse main@{99999} >output 2>error && test_must_be_empty output && diff --git a/t/t1508-at-combinations.sh b/t/t1508-at-combinations.sh index e841309d0e..020106a1cc 100755 --- a/t/t1508-at-combinations.sh +++ b/t/t1508-at-combinations.sh @@ -110,10 +110,31 @@ test_expect_success '@{1} works with only one reflog entry' ' test_cmp_rev newbranch~ newbranch@{1} ' -test_expect_success '@{0} works with empty reflog' ' - git checkout -B newbranch main && - git reflog expire --expire=now refs/heads/newbranch && - test_cmp_rev newbranch newbranch@{0} +test_expect_success '@{0} fails with empty reflog' ' + git checkout -B empty-reflog main && + git reflog expire --expire=now refs/heads/empty-reflog && + cat >expect <<-EOF && + fatal: Needed a single revision + EOF + test_must_fail git rev-parse --verify missing-reflog@{0} 2>err && + test_cmp expect err +' + +test_expect_success '@{0} fails with missing reflog' ' + git -c core.logAllRefUpdates=false checkout -B missing-reflog main && + cat >expect <<-EOF && + fatal: Needed a single revision + EOF + test_must_fail git rev-parse --verify missing-reflog@{0} 2>err && + test_cmp expect err +' + +test_expect_success '@{0} favors first reflog entry with diverged reflog' ' + git checkout -B diverged-reflog main && + test_commit A && + test_commit B && + git reflog delete diverged-reflog@{0} && + test_cmp_rev diverged-reflog~ diverged-reflog@{0} ' test_done From patchwork Wed Feb 21 09:56:40 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Patrick Steinhardt X-Patchwork-Id: 13565365 Received: from fhigh3-smtp.messagingengine.com (fhigh3-smtp.messagingengine.com [103.168.172.154]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id B2DA94DA00 for ; Wed, 21 Feb 2024 09:56:44 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=103.168.172.154 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708509406; cv=none; b=BTHaY14G9mVNCn3lPZD+/5HqfsGkGq7KxgKQHQDEel/99OhgIGoGncCzeDixcbiCI9BUa/gwyAIo76KnRQ5IhysFzUo66KgQLNnFyuHfpkpgqwGCjBjoCFThjDKUVpGTv5iP4Zc4y/SfrzW/gQE/GxKx6dTB/r7qTa8ofzx0abc= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1708509406; c=relaxed/simple; bh=uyXHDKGg8uSihdM3Ef62Q+R8rBSb+i6/T7fp9kpv0uk=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=mfmBLr8pwxL6xzKvbaGf757Amd2RvxcBkjrk/R8djqkBi2+nqj/M1fwWsORv1ynDVEcsUlLB/4exWAtIVJCHPIHjdNt2sFOmB4kXFeVz+TB4tM1CwKruNX8zvYVruqOJo+jbTKrKOxhTmm3XZx4wyExasfQuFel0o7P/J2ttFUY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im; spf=pass smtp.mailfrom=pks.im; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b=EztQ6pPf; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b=Q2/tujoQ; arc=none smtp.client-ip=103.168.172.154 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=pks.im Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=pks.im Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=pks.im header.i=@pks.im header.b="EztQ6pPf"; dkim=pass (2048-bit key) header.d=messagingengine.com header.i=@messagingengine.com header.b="Q2/tujoQ" Received: from compute2.internal (compute2.nyi.internal [10.202.2.46]) by mailfhigh.nyi.internal (Postfix) with ESMTP id C6F1411400C4; Wed, 21 Feb 2024 04:56:43 -0500 (EST) Received: from mailfrontend2 ([10.202.2.163]) by compute2.internal (MEProxy); Wed, 21 Feb 2024 04:56:43 -0500 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=pks.im; h=cc:cc :content-type:content-type:date:date:from:from:in-reply-to :in-reply-to:message-id:mime-version:references:reply-to:subject :subject:to:to; s=fm1; t=1708509403; x=1708595803; bh=Oxs1QW0C2h 14dEbCMFWqNdLi8ExBe1E+d/JcqAbnaZg=; b=EztQ6pPfz6GD7lfx90LLffs87n 8QwkWeIa5q39CC5HPlaucDtM3mgVlKFBVG9B4k6BqjJ0HkHU7SFGfgVJ9WLD/4wy PMLx7rxM5oVQt2RTAXLKipdBUqU6dCcxQ6KwT28shpoHtzmox6/boZQRgiTAoYiP 0u/D25ewrANxmf0Uu9mEz9qCqrAh9aWveIL8s4bCpeZW3T4sw7LJwY19Fk6UO8kf OvyHd+hTweBGo8rTQ+R6dyI3ypyewNwc3ov9ntlnwwHXEMJfwAaCDcaa9vMeo+6O 8gWMgYxAW42XZGcQ/W5JE9SkjTcWxBo/JoN+GBEfhZqLrRncLyA3pYuJsghA== DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d= messagingengine.com; h=cc:cc:content-type:content-type:date:date :feedback-id:feedback-id:from:from:in-reply-to:in-reply-to :message-id:mime-version:references:reply-to:subject:subject:to :to:x-me-proxy:x-me-proxy:x-me-sender:x-me-sender:x-sasl-enc; s= fm1; t=1708509403; x=1708595803; bh=Oxs1QW0C2h14dEbCMFWqNdLi8ExB e1E+d/JcqAbnaZg=; b=Q2/tujoQBh2in3bv4j47IthbFty8x/EdLqa6X2K24KGp /CJ6eaKqdi8z5zZb7TxmjCOrjeLFjJWs4PxgzZKLF6HaoGS8u2SY3is+cSOVFHDk g+skjH0d+b1cl7qADLsiVaEcEoHvGQw4Q1En/h8KVxqXfyXuqMWTR+3WfJXSSsc2 2TW81YvBGf6vDZueT79Gaidh30p9D7VtFqDhvCXS2AjIVBdlAQHZOqY6Lp9A+19w q014395Sx6kRubypgWaUrYwmGCbgQmrYHZYKyLF6zbs7Ngx1mcXKLcDe/mVwlyuZ ZJJTHHDAD/F1AYscZ4QVRcrrj6IRlGfWd+0c1ULfUw== X-ME-Sender: X-ME-Received: X-ME-Proxy-Cause: gggruggvucftvghtrhhoucdtuddrgedvledrfedvgddutdcutefuodetggdotefrodftvf curfhrohhfihhlvgemucfhrghsthforghilhdpqfgfvfdpuffrtefokffrpgfnqfghnecu uegrihhlohhuthemuceftddtnecusecvtfgvtghiphhivghnthhsucdlqddutddtmdenuc fjughrpeffhffvvefukfhfgggtuggjsehgtderredttddvnecuhfhrohhmpefrrghtrhhi tghkucfuthgvihhnhhgrrhguthcuoehpshesphhkshdrihhmqeenucggtffrrghtthgvrh hnpeeukedtvedtffevleejtefgheehieegkeeluddvfeefgeehgfeltddtheejleffteen ucevlhhushhtvghrufhiiigvpedtnecurfgrrhgrmhepmhgrihhlfhhrohhmpehpshesph hkshdrihhm X-ME-Proxy: Feedback-ID: i197146af:Fastmail Received: by mail.messagingengine.com (Postfix) with ESMTPA; Wed, 21 Feb 2024 04:56:42 -0500 (EST) Received: by vm-mail (OpenSMTPD) with ESMTPSA id 38f7da90 (TLSv1.3:TLS_AES_256_GCM_SHA384:256:NO); Wed, 21 Feb 2024 09:52:38 +0000 (UTC) Date: Wed, 21 Feb 2024 10:56:40 +0100 From: Patrick Steinhardt To: git@vger.kernel.org Cc: Yasushi SHOJI Subject: [PATCH 2/2] builtin/show-branch: detect empty reflogs Message-ID: <6107efeffa3a9e87ed95f4fe592d9b480887c510.1708509190.git.ps@pks.im> References: Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: The `--reflog=n` option for git-show-branch(1) allows the user to list the reflog of a specific branch, where `n` specifies how many reflog entries to show. When there are less than `n` entries we handle this gracefully and simply report less entries. There is a special case though when the ref either has no reflog or when its reflog is empty. In this case, we end up printing nothing at all while returning successfully. This is rather confusing as there is no indicator why we didn't print anything. Adapt the behaviour so that we die instead of leaving no user visible traces. This change in behaviour should be fine given that this case used to segfault before the preceding commit. Signed-off-by: Patrick Steinhardt --- builtin/show-branch.c | 2 ++ t/t3202-show-branch.sh | 25 +++++++++++++++++++++++++ 2 files changed, 27 insertions(+) diff --git a/builtin/show-branch.c b/builtin/show-branch.c index b01ec761d2..8837415031 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -785,6 +785,8 @@ int cmd_show_branch(int ac, const char **av, const char *prefix) if (read_ref_at(get_main_ref_store(the_repository), ref, flags, 0, base + i, &oid, &logmsg, ×tamp, &tz, NULL)) { + if (!i) + die(_("log for %s is empty"), ref); reflog = i; break; } diff --git a/t/t3202-show-branch.sh b/t/t3202-show-branch.sh index 6a98b2df76..e5b74cc55f 100755 --- a/t/t3202-show-branch.sh +++ b/t/t3202-show-branch.sh @@ -264,4 +264,29 @@ test_expect_success 'error descriptions on orphan branch' ' test_branch_op_in_wt -c new-branch ' +test_expect_success 'show-branch --reflog with empty reflog' ' + git checkout -B empty-reflog && + git reflog expire --expire=now refs/heads/empty-reflog && + + cat >expect <<-EOF && + fatal: log for refs/heads/empty-reflog is empty + EOF + test_must_fail git show-branch --reflog=1 empty-reflog 2>err && + test_cmp expect err && + test_must_fail git show-branch --reflog empty-reflog 2>err && + test_cmp expect err +' + +test_expect_success 'show-branch --reflog with missing reflog' ' + git -c core.logAllRefUpdates=false checkout -B missing-reflog && + + cat >expect <<-EOF && + fatal: log for refs/heads/missing-reflog is empty + EOF + test_must_fail git show-branch --reflog=1 missing-reflog 2>err && + test_cmp expect err && + test_must_fail git show-branch --reflog missing-reflog 2>err && + test_cmp expect err +' + test_done