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

Re: [PATCH 7/9] bundle.c: convert leaf functions to struct object_id

From
Michael Haggerty <mhagger@alum.mit.edu>
Date
May 6, 2014, 14:42 UTC
Message-ID
<5368F4C8.2060604@alum.mit.edu>
In-Reply-To
<1399147942-165308-8-git-send-email-sandals@crustytoothpaste.net>
On 05/03/2014 10:12 PM, brian m. carlson wrote:
Show 54 quoted lines
> Signed-off-by: brian m. carlson <sandals@crustytoothpaste.net>
> ---
>  bundle.c | 38 +++++++++++++++++++-------------------
>  1 file changed, 19 insertions(+), 19 deletions(-)
> 
> diff --git a/bundle.c b/bundle.c
> index 1222952..798ba28 100644
> --- a/bundle.c
> +++ b/bundle.c
> @@ -11,11 +11,11 @@
>  
>  static const char bundle_signature[] = "# v2 git bundle\n";
>  
> -static void add_to_ref_list(const unsigned char *sha1, const char *name,
> +static void add_to_ref_list(const struct object_id *sha1, const char *name,
>  		struct ref_list *list)
>  {
>  	ALLOC_GROW(list->list, list->nr + 1, list->alloc);
> -	hashcpy(list->list[list->nr].sha1, sha1);
> +	hashcpy(list->list[list->nr].sha1, sha1->oid);
>  	list->list[list->nr].name = xstrdup(name);
>  	list->nr++;
>  }
> @@ -39,7 +39,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
>  	/* The bundle header ends with an empty line */
>  	while (!strbuf_getwholeline_fd(&buf, fd, '\n') &&
>  	       buf.len && buf.buf[0] != '\n') {
> -		unsigned char sha1[20];
> +		struct object_id sha1;
>  		int is_prereq = 0;
>  
>  		if (*buf.buf == '-') {
> @@ -53,9 +53,9 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
>  		 * Prerequisites have object name that is optionally
>  		 * followed by SP and subject line.
>  		 */
> -		if (get_sha1_hex(buf.buf, sha1) ||
> -		    (buf.len > 40 && !isspace(buf.buf[40])) ||
> -		    (!is_prereq && buf.len <= 40)) {
> +		if (get_sha1_hex(buf.buf, sha1.oid) ||
> +		    (buf.len > GIT_OID_HEXSZ && !isspace(buf.buf[GIT_OID_HEXSZ])) ||
> +		    (!is_prereq && buf.len <= GIT_OID_HEXSZ)) {
>  			if (report_path)
>  				error(_("unrecognized header: %s%s (%d)"),
>  				      (is_prereq ? "-" : ""), buf.buf, (int)buf.len);
> @@ -63,9 +63,9 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
>  			break;
>  		} else {
>  			if (is_prereq)
> -				add_to_ref_list(sha1, "", &header->prerequisites);
> +				add_to_ref_list(&sha1, "", &header->prerequisites);
>  			else
> -				add_to_ref_list(sha1, buf.buf + 41, &header->references);
> +				add_to_ref_list(&sha1, buf.buf + 41, &header->references);
I think that 41 here is GIT_OID_HEXSZ + 1.
> [...]
Michael
-- 
Michael Haggerty
mhagger@alum.mit.edu
http://softwareswirl.blogspot.com/
Previous: brian m. carlsonNext: brian m. carlson
Message 30 of 39 in “Use a structure for object IDs.”
  1. 0/9 Use a structure for object IDs.brian m. carlson, May 3, 2014
  2. 1/9 Define a structure for object IDs.brian m. carlson, May 3, 2014
  3. Michael HaggertyMay 4, 2014
  4. Johannes SixtMay 4, 2014
  5. David KastrupMay 4, 2014
  6. Andreas SchwabMay 4, 2014
  7. Johannes SixtMay 4, 2014
  8. Andreas SchwabMay 4, 2014
  9. David KastrupMay 5, 2014
  10. Andreas SchwabMay 5, 2014
  11. James DenholmMay 5, 2014
  12. David KastrupMay 5, 2014
  13. Michael HaggertyMay 5, 2014
  14. Andreas SchwabMay 5, 2014
  15. David KastrupMay 5, 2014
  16. Felipe ContrerasMay 5, 2014
  17. Duy NguyenMay 4, 2014
  18. brian m. carlsonMay 4, 2014
  19. Andreas SchwabMay 4, 2014
  20. David KastrupMay 4, 2014
  21. Andreas SchwabMay 4, 2014
  22. David KastrupMay 4, 2014
  23. Andreas SchwabMay 4, 2014
  24. 2/9 bisect.c: convert to use struct object_idbrian m. carlson, May 3, 2014
  25. 3/9 archive.c: convert to use struct object_idbrian m. carlson, May 3, 2014
  26. 4/9 zip: use GIT_OID_HEXSZ for trailersbrian m. carlson, May 3, 2014
  27. 5/9 branch.c: convert to use struct object_idbrian m. carlson, May 3, 2014
  28. 6/9 bulk-checkin.c: convert to use struct object_idbrian m. carlson, May 3, 2014
  29. 7/9 bundle.c: convert leaf functions to struct object_idbrian m. carlson, May 3, 2014
  30. Michael HaggertyMay 6, 2014
  31. 8/9 cache-tree: convert struct cache_tree to use object_idbrian m. carlson, May 3, 2014
  32. Michael HaggertyMay 6, 2014
  33. Michael HaggertyMay 6, 2014
  34. 9/9 diff: convert struct combine_diff_path to object_idbrian m. carlson, May 3, 2014
  35. Michael HaggertyMay 6, 2014
  36. brian m. carlsonMay 3, 2014
  37. Michael HaggertyMay 4, 2014
  38. Johannes SixtMay 4, 2014
  39. brian m. carlsonMay 4, 2014

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.