mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "René Scharfe" <>
To: Git Mailing List <>
Cc: Junio C Hamano <>
Subject: [PATCH 1/2] rev-parse: demonstrate overflow of N for "foo^N" and "foo~N"
Date: Sun, 15 Sep 2019 14:03:25 +0200	[thread overview]
Message-ID: <> (raw)

If the number gets too high for an int, weird things may happen, as
signed overflows are undefined.  Add a test to show this; rev-parse
"sucessfully" interprets 100000000000000000000000000000000 to be the
same as 0, at least on x64 with GCC 9.2.1 and Clang 8.0.1, which is
obviously bogus.

Signed-off-by: René Scharfe <>
 t/ | 8 ++++++++
 1 file changed, 8 insertions(+)

diff --git a/t/ b/t/
index 4ee009da66..5c4df47401 100755
--- a/t/
+++ b/t/
@@ -215,4 +215,12 @@ test_expect_success 'arg before dashdash must be a revision (ambiguous)' '
 	test_cmp expect actual

+test_expect_failure 'reject Nth parent if N is too high' '
+	test_must_fail git rev-parse HEAD^100000000000000000000000000000000
+test_expect_failure 'reject Nth ancestor if N is too high' '
+	test_must_fail git rev-parse HEAD~100000000000000000000000000000000

             reply	other threads:[~2019-09-15 12:08 UTC|newest]

Thread overview: 4+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2019-09-15 12:03 René Scharfe [this message]
2019-09-15 12:10 ` [PATCH 2/2] sha1-name: check for overflow of N in "foo^N" and "foo~N" René Scharfe
2019-09-15 15:15   ` brian m. carlson
2019-09-15 16:12     ` René Scharfe

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:

  List information:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).