git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] use SHA_DIGEST_LENGTH

From
DRDavid Rientjes <rientjes@cs.washington.edu>
Date
Sep 24, 2006, 03:33 UTC
Message-ID
<Pine.LNX.4.64N.0609232028290.14996@attu4.cs.washington.edu>
In-Reply-To
<Pine.LNX.4.64N.0609232011050.14284@attu4.cs.washington.edu>
On Sat, 23 Sep 2006, David Rientjes wrote:
Show 21 quoted lines
> @@ -202,16 +202,17 @@ int cmd_name_rev(int argc, const char **
>  #define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))
>  				if (!ishex(*p))
>  					forty = 0;
> -				else if (++forty == 40 &&
> +				else if (++forty == 2 * SHA_DIGEST_LENGTH &&
>  						!ishex(*(p+1))) {
> -					unsigned char sha1[40];
> +					unsigned char sha1[2 * SHA_DIGEST_LENGTH];
>  					const char *name = "undefined";
>  					char c = *(p+1);
>  
>  					forty = 0;
>  
>  					*(p+1) = 0;
> -					if (!get_sha1(p - 39, sha1)) {
> +					if (!get_sha1(p - (SHA_DIGEST_LENGTH + 1),
> +						      sha1)) {
>  						struct object *o =
>  							lookup_object(sha1);
>  						if (o)
Off by 18 error.
Signed-off-by: David Rientjes <rientjes@cs.washington.edu>
---
 builtin-name-rev.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/builtin-name-rev.c b/builtin-name-rev.c
index f522664..ed99679 100644
--- a/builtin-name-rev.c
+++ b/builtin-name-rev.c
@@ -211,7 +211,7 @@ #define ishex(x) (isdigit((x)) || ((x) >
 					forty = 0;
 
 					*(p+1) = 0;
-					if (!get_sha1(p - (SHA_DIGEST_LENGTH + 1),
+					if (!get_sha1(p - 2 * SHA_DIGEST_LENGTH + 1,
 						      sha1)) {
 						struct object *o =
 							lookup_object(sha1);
Message 1 of 1 in “Re: [PATCH 1/2] use SHA_DIGEST_LENGTH”
  1. David RientjesSep 24, 2006

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.