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

Re: [PATCH v2 07/14] match-trees: convert splice_tree to object_id

From
Duy Nguyen <pclouds@gmail.com>
Date
Jan 22, 2018, 11:56 UTC
Message-ID
<20180122115642.GB5980@ash>
In-Reply-To
<b5782b135fb68b645ffea711028bd6024176005a.1516617960.git.patryk.obara@gmail.com>
On Mon, Jan 22, 2018 at 12:04:30PM +0100, Patryk Obara wrote:
Show 22 quoted lines
> Convert the definition of static recursive splice_tree function to use
> struct object_id and adjust single caller.
> 
> Signed-off-by: Patryk Obara <patryk.obara@gmail.com>
> ---
>  match-trees.c | 42 ++++++++++++++++++++----------------------
>  1 file changed, 20 insertions(+), 22 deletions(-)
> 
> diff --git a/match-trees.c b/match-trees.c
> index 396b7338df..0f899a7212 100644
> --- a/match-trees.c
> +++ b/match-trees.c
> @@ -161,19 +161,17 @@ static void match_trees(const struct object_id *hash1,
>   * A tree "hash1" has a subdirectory at "prefix".  Come up with a
>   * tree object by replacing it with another tree "hash2".
>   */
> -static int splice_tree(const unsigned char *hash1,
> -		       const char *prefix,
> -		       const unsigned char *hash2,
> -		       unsigned char *result)
> +static int splice_tree(const struct object_id *hash1, const char *prefix,
> +		       const struct object_id *hash2, struct object_id *result)

Maybe change the names to oid1 and oid2 too. I had a "what?" moment when I read hash1->hash below.

Show 10 quoted lines
> @@ -197,26 +195,26 @@ static int splice_tree(const unsigned char *hash1,
>  		if (strlen(name) == toplen &&
>  		    !memcmp(name, prefix, toplen)) {
>  			if (!S_ISDIR(mode))
> -				die("entry %s in tree %s is not a tree",
> -				    name, sha1_to_hex(hash1));
> -			rewrite_here = (unsigned char *) oid->hash;
> +				die("entry %s in tree %s is not a tree", name,
> +				    oid_to_hex(hash1));
> +			rewrite_here = (struct object_id *)oid;
You don't need the typecast here anymore, do you?

-- Duy

Previous: Patryk ObaraNext: Patryk Obara
Message 22 of 75 in “Some fixes and bunch of object_id conversions”
  1. 00/11 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 18, 2018
  2. 01/11 http-push: improve error logPatryk Obara, Jan 18, 2018
  3. 02/11 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 18, 2018
  4. 04/11 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 18, 2018
  5. 06/11 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 18, 2018
  6. 07/11 match-trees: convert splice_tree to object_idPatryk Obara, Jan 18, 2018
  7. 09/11 notes: convert combine_notes_* to object_idPatryk Obara, Jan 18, 2018
  8. 08/11 commit: convert commit_tree* to object_idPatryk Obara, Jan 18, 2018
  9. 11/11 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 18, 2018
  10. brian m. carlsonJan 20, 2018
  11. Patryk ObaraJan 21, 2018
  12. 10/11 notes: convert write_notes_tree to object_idPatryk Obara, Jan 18, 2018
  13. 05/11 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 18, 2018
  14. 03/11 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 18, 2018
  15. Jonathan TanJan 18, 2018
  16. brian m. carlsonJan 20, 2018
  17. Patryk ObaraJan 21, 2018
  18. 00/14 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 22, 2018
  19. 02/14 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 22, 2018
  20. 03/14 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 22, 2018
  21. 07/14 match-trees: convert splice_tree to object_idPatryk Obara, Jan 22, 2018
  22. Duy NguyenJan 22, 2018
  23. Patryk ObaraJan 22, 2018
  24. Duy NguyenJan 23, 2018
  25. 09/14 notes: convert combine_notes_* to object_idPatryk Obara, Jan 22, 2018
  26. 10/14 notes: convert write_notes_tree to object_idPatryk Obara, Jan 22, 2018
  27. Duy NguyenJan 22, 2018
  28. 11/14 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 22, 2018
  29. 14/14 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 22, 2018
  30. 12/14 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 22, 2018
  31. 13/14 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 22, 2018
  32. 04/14 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 22, 2018
  33. 05/14 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 22, 2018
  34. Duy NguyenJan 22, 2018
  35. Patryk ObaraJan 22, 2018
  36. Duy NguyenJan 22, 2018
  37. 08/14 commit: convert commit_tree* to object_idPatryk Obara, Jan 22, 2018
  38. 06/14 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 22, 2018
  39. 01/14 http-push: improve error logPatryk Obara, Jan 22, 2018
  40. Duy NguyenJan 22, 2018
  41. Patryk ObaraJan 22, 2018
  42. 00/14 Some fixes and bunch of object_id conversionsPatryk Obara, Jan 24, 2018
  43. 02/14 clang-format: adjust penalty for return type line breakPatryk Obara, Jan 24, 2018
  44. 07/14 match-trees: convert splice_tree to object_idPatryk Obara, Jan 24, 2018
  45. 11/14 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 24, 2018
  46. 10/14 notes: convert write_notes_tree to object_idPatryk Obara, Jan 24, 2018
  47. 08/14 commit: convert commit_tree* to object_idPatryk Obara, Jan 24, 2018
  48. 09/14 notes: convert combine_notes_* to object_idPatryk Obara, Jan 24, 2018
  49. 13/14 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 24, 2018
  50. brian m. carlsonJan 26, 2018
  51. 12/14 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 24, 2018
  52. 14/14 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 24, 2018
  53. 01/14 http-push: improve error logPatryk Obara, Jan 24, 2018
  54. 05/14 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 24, 2018
  55. 03/14 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 24, 2018
  56. 04/14 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 24, 2018
  57. Junio C HamanoJan 24, 2018
  58. 06/14 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 24, 2018
  59. Junio C HamanoJan 24, 2018
  60. Junio C HamanoJan 24, 2018
  61. Duy NguyenJan 25, 2018
  62. brian m. carlsonJan 27, 2018
  63. 00/12 A bunch of object_id conversionsPatryk Obara, Jan 28, 2018
  64. 01/12 sha1_file: convert pretend_sha1_file to object_idPatryk Obara, Jan 28, 2018
  65. 03/12 sha1_file: convert hash_sha1_file to object_idPatryk Obara, Jan 28, 2018
  66. 05/12 match-trees: convert splice_tree to object_idPatryk Obara, Jan 28, 2018
  67. 08/12 notes: convert write_notes_tree to object_idPatryk Obara, Jan 28, 2018
  68. 04/12 cache: clear whole hash buffer with oidclrPatryk Obara, Jan 28, 2018
  69. 09/12 sha1_file: convert write_sha1_file to object_idPatryk Obara, Jan 28, 2018
  70. 07/12 notes: convert combine_notes_* to object_idPatryk Obara, Jan 28, 2018
  71. 10/12 sha1_file: convert force_object_loose to object_idPatryk Obara, Jan 28, 2018
  72. 11/12 sha1_file: convert write_loose_object to object_idPatryk Obara, Jan 28, 2018
  73. 12/12 sha1_file: rename hash_sha1_file_literallyPatryk Obara, Jan 28, 2018
  74. 06/12 commit: convert commit_tree* to object_idPatryk Obara, Jan 28, 2018
  75. 02/12 dir: convert struct sha1_stat to use object_idPatryk Obara, Jan 28, 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.