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

Recommendation for consistent update on invoke of "sha1_to_hex()"

From
牛牛旭 <niuxu16@nudt.edu.cn>
Date
Jan 5, 2018, 03:26 UTC
Message-ID
<fb56cfe.6744.160c45a9e5a.Coremail.niuxu16@nudt.edu.cn>
Our team researches on consistent update of Git during evolution. And we have figured out several spots that may be missed. 
By mining historical patches, we suggest that invokes of sha1_to_hex() should be replaced with that of oid_to_hex(). One example for recommendation and corresponding patch are listed as follows. 
One example of missed spot:
1  void assert_sha1_type(const unsigned char *sha1, enum 
  object_type expect)
2 {
3  enum object_type type = sha1_object_info(sha1, NULL);
4  if (type < 0)
5   die("%s is not a valid object",sha1_to_hex(sha1));
6  if (type != expect)
7   die("%s is not a valid '%s' object", sha1_to_hex(sha1),
8  typename(expect));
9 }

One example of historical patch: 1 * We do not want to call parse_object here, because 2 * inflating blobs and trees could be very expensive. 3 * However, we do need to know the correct type for 4 * later processing, and the revision machinery expects 5 * commits and tags to have been parsed. 6 */ 7 - type = sha1_object_info(sha1, NULL); 8 + type = sha1_object_info(oid->hash, NULL); 9 if (type < 0) 10 - die("unable to get object info for %s", sha1_to_hex(sha1)); 11 + die("unable to get object info for %s", oid_to_hex(oid)); 12 More recommendations and supporting patches are saved in attachments. It is so kind of you to reply me about the correctness of our suggestions. And thank you for your reading. 

Next: Jeff King
Message 1 of 2 in “Recommendation for consistent update on invoke of "sha1_to_hex()"”
  1. 牛旭Jan 5, 2018
  2. Jeff KingJan 5, 2018

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.