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

[PATCH 1/3] drop casts from users EMPTY_TREE_SHA1_BIN

From
Jeff King <peff@peff.net>
Date
Mar 22, 2012, 18:53 UTC
Message-ID
<20120322185324.GA32727@sigill.intra.peff.net>
In-Reply-To
<20120322185246.GA27037@sigill.intra.peff.net>

This macro already evaluates to the correct type, as it casts the string literal to "unsigned char *" itself (and callers who want the literal can use the _LITERAL form).

Signed-off-by: Jeff King <peff@peff.net>
---
 builtin/diff.c    |    2 +-
 merge-recursive.c |    2 +-
 sequencer.c       |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)
diff --git a/builtin/diff.c b/builtin/diff.c
index 424c815..9069dc4 100644
--- a/builtin/diff.c
+++ b/builtin/diff.c
@@ -327,7 +327,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
 				add_head_to_pending(&rev);
 				if (!rev.pending.nr) {
 					struct tree *tree;
-					tree = lookup_tree((const unsigned char*)EMPTY_TREE_SHA1_BIN);
+					tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
 					add_pending_object(&rev, &tree->object, "HEAD");
 				}
 				break;
diff --git a/merge-recursive.c b/merge-recursive.c
index 6479a60..318d32e 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -1914,7 +1914,7 @@ int merge_recursive(struct merge_options *o,
 		/* if there is no common ancestor, use an empty tree */
 		struct tree *tree;
 
-		tree = lookup_tree((const unsigned char *)EMPTY_TREE_SHA1_BIN);
+		tree = lookup_tree(EMPTY_TREE_SHA1_BIN);
 		merged_common_ancestors = make_virtual_commit(tree, "ancestor");
 	}
 
diff --git a/sequencer.c b/sequencer.c
index a37846a..4307364 100644
--- a/sequencer.c
+++ b/sequencer.c
@@ -164,7 +164,7 @@ static void write_message(struct strbuf *msgbuf, const char *filename)
 
 static struct tree *empty_tree(void)
 {
-	return lookup_tree((const unsigned char *)EMPTY_TREE_SHA1_BIN);
+	return lookup_tree(EMPTY_TREE_SHA1_BIN);
 }
 
 static int error_dirty_index(struct replay_opts *opts)
-- 
1.7.10.rc0.9.gdcbe9
Previous: Jeff KingNext: Jeff King
Message 12 of 25 in “Strange effect merging empty file”
  1. Ralf NyrenMar 21, 2012
  2. Zbigniew Jędrzejewski-SzmekMar 21, 2012
  3. Junio C HamanoMar 21, 2012
  4. Randal L. SchwartzMar 22, 2012
  5. Ralf NyrenMar 22, 2012
  6. Zbigniew Jędrzejewski-SzmekMar 22, 2012
  7. Jeff KingMar 22, 2012
  8. Junio C HamanoMar 22, 2012
  9. Jeff KingMar 22, 2012
  10. Jeff KingMar 22, 2012
  11. Jeff KingMar 22, 2012
  12. 1/3 drop casts from users EMPTY_TREE_SHA1_BINJeff King, Mar 22, 2012
  13. 2/3 make is_empty_blob_sha1 available everywhereJeff King, Mar 22, 2012
  14. 3/3 merge-recursive: don't detect renames from empty filesJeff King, Mar 22, 2012
  15. Jonathan NiederMar 22, 2012
  16. Jeff KingMar 22, 2012
  17. Junio C HamanoMar 22, 2012
  18. Jeff KingMar 22, 2012
  19. Junio C HamanoMar 22, 2012
  20. 0/2 merging renames of empty filesJeff King, Mar 22, 2012
  21. 1/2 teach diffcore-rename to optionally ignore empty contentJeff King, Mar 22, 2012
  22. 2/2 merge-recursive: don't detect renames of empty filesJeff King, Mar 22, 2012
  23. Junio C HamanoMar 22, 2012
  24. Jeff KingMar 23, 2012
  25. Junio C HamanoMar 23, 2012

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.