From patchwork Thu Oct 17 09:35:28 2024 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 8bit X-Patchwork-Submitter: =?utf-8?q?Wolfgang_M=C3=BCller?= X-Patchwork-Id: 13839688 Received: from coleridge.oriole.systems (coleridge.oriole.systems [89.238.76.34]) (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 C6E331D8E0F for ; Thu, 17 Oct 2024 09:35:51 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=89.238.76.34 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729157755; cv=none; b=Nw/P7o9hCbiOM9H9ZQddRHRWws1QnkLl8gJDneRQHB8KPr5EQvlreRGEqM6ycpEsxoclHC1QY4NppxZHQzo+uunLTnhhSvtSQVjLkVhbyzTUtW5btFz94DCrCuG7CxrybcQ3yU4WhuE6Wx5hv03NctZZ/Ki3t3eHBJqijjoCB1s= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1729157755; c=relaxed/simple; bh=UAXIEy++EtM2B6+wDCJDm3+40GR1/46vX7VMluhlOkE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type; b=OxNPCeZNkMkCzenqcFbWFt7JgmLYUfezMtxNJTx9GbarU+Oox4LIhKP8rZ1MCeVYeaYzx/i0XVOsghLpH0O8/HG9jQpq1KqI7UegJFQseAF1+sONSq4UrLCjVVCLrqiP/OMEcJ9M/yuYAORYO6xjcxfeUxxEm+I4UXQa7hBGQQw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oriole.systems; spf=pass smtp.mailfrom=oriole.systems; dkim=pass (2048-bit key) header.d=oriole.systems header.i=@oriole.systems header.b=n4FmPUaO; arc=none smtp.client-ip=89.238.76.34 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=oriole.systems Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=oriole.systems Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=oriole.systems header.i=@oriole.systems header.b="n4FmPUaO" From: =?utf-8?q?Wolfgang_M=C3=BCller?= DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=oriole.systems; s=canary-202303; t=1729157749; bh=UAXIEy++EtM2B6+wDCJDm3+40GR1/46vX7VMluhlOkE=; h=From:To:Subject:Date:Message-ID:In-Reply-To:References: MIME-Version:Content-Type:Content-Transfer-Encoding:From:Sender: Reply-To:Subject:Date:Message-Id:To:Cc:Mime-Version:Content-Type: Content-Transfer-Encoding:In-Reply-To:References; b=n4FmPUaO4mGtZN42NSn8yK1StgalaAdb1uZop4bkdnYp7xRZgbtE/3H5SZcrfH8Fw qxzY0EtlDZiVRwIiR0ckJ4oQ7gJeQdGvWzfwH91i8gnk9zhezb+6iERhsS1514kDYD c2Pqh0ee5qg69UbitNEsXX9znXT+CFn8jBq5lI1M6myL6DDTKp3S0BDEEAKbW4lsyi YAj4ibeX20qvP07tErSJIHqi5cQ9+fRjDLdo8dFcESxyjh5Xtx7A3SvUKl7lNbvaku 6KLF7lPoSsujmwkwuVwWlkwzuKLcKirveh+N4ultMoYnnJCBU7z/V7OiiNfmov5Lns 6DECFutsR9iIA== To: git@vger.kernel.org Subject: [PATCH v4] builtin/shortlog: explicitly set hash algo when there is no repo Date: Thu, 17 Oct 2024 11:35:28 +0200 Message-ID: <20241017093528.18157-1-wolf@oriole.systems> X-Mailer: git-send-email 2.47.0 In-Reply-To: <20241011183445.229228-1-wolf@oriole.systems> References: <20241011183445.229228-1-wolf@oriole.systems> Precedence: bulk X-Mailing-List: git@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Whilst git-shortlog(1) does not explicitly need any repository information when run without reference to one, it still parses some of its arguments with parse_revision_opt() which assumes that the hash algorithm is set. However, in c8aed5e8da (repository: stop setting SHA1 as the default object hash, 2024-05-07) we stopped setting up a default hash algorithm and instead require commands to set it up explicitly. This was done for most other commands like in ab274909d4 (builtin/diff: explicitly set hash algo when there is no repo, 2024-05-07) but was missed for builtin/shortlog, making git-shortlog(1) segfault outside of a repository when given arguments like --author that trigger a call to parse_revision_opt(). Fix this for now by explicitly setting the hash algorithm to SHA1. Also add a regression test for the segfault. Thanks-to: Eric Sunshine Signed-off-by: Wolfgang Müller --- Here's v4 with the trailers fixed and a small improvement to the test. The commit including the additional test has been dropped. Thanks! builtin/shortlog.c | 12 ++++++++++++ t/t4201-shortlog.sh | 4 ++++ 2 files changed, 16 insertions(+) Range-diff against v3: 1: 4813b458ac ! 1: 1a2959c0de builtin/shortlog: explicitly set hash algo when there is no repo @@ Commit message Fix this for now by explicitly setting the hash algorithm to SHA1. Also add a regression test for the segfault. - Signed-off-by: Wolfgang Müller Thanks-to: Eric Sunshine + Signed-off-by: Wolfgang Müller ## builtin/shortlog.c ## @@ builtin/shortlog.c: int cmd_shortlog(int argc, @@ t/t4201-shortlog.sh: fuzz() ' +test_expect_success 'shortlog --author from non-git directory does not segfault' ' -+ echo | nongit git shortlog --author=author ++ nongit git shortlog --author=author expect <<\EOF && A U Thor (2):