summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 9971d6d)
raw | patch | inline | side by side (parent: 9971d6d)
author | Jonathan Nieder <jrnieder@gmail.com> | |
Mon, 7 Feb 2011 08:17:27 +0000 (02:17 -0600) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Mon, 14 Feb 2011 18:48:06 +0000 (10:48 -0800) |
Functions such as hashcmp that expect a binary SHA-1 value take
parameters of type "unsigned char *" to avoid accepting a textual
SHA-1 passed by mistake. Unfortunately, this means passing the string
literal EMPTY_TREE_SHA1_BIN requires an ugly cast. Tweak the
definition of EMPTY_TREE_SHA1_BIN to produce a value of more
convenient type.
In the future the definition might change to
extern const unsigned char empty_tree_sha1_bin[20];
#define EMPTY_TREE_SHA1_BIN empty_tree_sha1_bin
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
parameters of type "unsigned char *" to avoid accepting a textual
SHA-1 passed by mistake. Unfortunately, this means passing the string
literal EMPTY_TREE_SHA1_BIN requires an ugly cast. Tweak the
definition of EMPTY_TREE_SHA1_BIN to produce a value of more
convenient type.
In the future the definition might change to
extern const unsigned char empty_tree_sha1_bin[20];
#define EMPTY_TREE_SHA1_BIN empty_tree_sha1_bin
Signed-off-by: Jonathan Nieder <jrnieder@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
builtin/checkout.c | patch | blob | history | |
cache.h | patch | blob | history | |
notes-merge.c | patch | blob | history | |
sha1_file.c | patch | blob | history |
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 757f9a08ddbaf102726a781b06d7294a4638984e..cd7f56e6c4b6e1b1059ffa0eae91b46e579b9e97 100644 (file)
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
topts.dir->exclude_per_dir = ".gitignore";
tree = parse_tree_indirect(old->commit ?
old->commit->object.sha1 :
- (unsigned char *)EMPTY_TREE_SHA1_BIN);
+ EMPTY_TREE_SHA1_BIN);
init_tree_desc(&trees[0], tree->buffer, tree->size);
tree = parse_tree_indirect(new->commit->object.sha1);
init_tree_desc(&trees[1], tree->buffer, tree->size);
index d83d68c859904fadbe2501cabd8575be09131d7b..3abf8950bdd9f950b65ee4544e0cfe6517f1912a 100644 (file)
--- a/cache.h
+++ b/cache.h
#define EMPTY_TREE_SHA1_HEX \
"4b825dc642cb6eb9a060e54bf8d69288fbee4904"
-#define EMPTY_TREE_SHA1_BIN \
+#define EMPTY_TREE_SHA1_BIN_LITERAL \
"\x4b\x82\x5d\xc6\x42\xcb\x6e\xb9\xa0\x60" \
"\xe5\x4b\xf8\xd6\x92\x88\xfb\xee\x49\x04"
+#define EMPTY_TREE_SHA1_BIN \
+ ((const unsigned char *) EMPTY_TREE_SHA1_BIN_LITERAL)
int git_mkstemp(char *path, size_t n, const char *template);
diff --git a/notes-merge.c b/notes-merge.c
index 71c4d45fcd1ac49630bdb8bc7b0aec658011c21b..1467ad31795ae21896f1e608e7cb032df2bc94a8 100644 (file)
--- a/notes-merge.c
+++ b/notes-merge.c
bases = get_merge_bases(local, remote, 1);
if (!bases) {
base_sha1 = null_sha1;
- base_tree_sha1 = (unsigned char *)EMPTY_TREE_SHA1_BIN;
+ base_tree_sha1 = EMPTY_TREE_SHA1_BIN;
OUTPUT(o, 4, "No merge base found; doing history-less merge");
} else if (!bases->next) {
base_sha1 = bases->item->object.sha1;
diff --git a/sha1_file.c b/sha1_file.c
index 0b830c8642fa2b141c9888c68713a29fc4df2ef2..27730c334cb433ef749a0efc5353a7f38032559c 100644 (file)
--- a/sha1_file.c
+++ b/sha1_file.c
static int cached_object_nr, cached_object_alloc;
static struct cached_object empty_tree = {
- EMPTY_TREE_SHA1_BIN,
+ EMPTY_TREE_SHA1_BIN_LITERAL,
OBJ_TREE,
"",
0