summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 3cd4f5e)
raw | patch | inline | side by side (parent: 3cd4f5e)
author | David Rientjes <rientjes@google.com> | |
Tue, 15 Aug 2006 20:37:19 +0000 (13:37 -0700) | ||
committer | Junio C Hamano <junkio@cox.net> | |
Tue, 15 Aug 2006 22:06:03 +0000 (15:06 -0700) |
Replace sha1 comparisons to null_sha1 with a global inline (which previously an
unused static inline in builtin-apply.c)
[jc: with a fix from Jonas Fonseca.]
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
unused static inline in builtin-apply.c)
[jc: with a fix from Jonas Fonseca.]
Signed-off-by: David Rientjes <rientjes@google.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
builtin-apply.c | patch | blob | history | |
builtin-diff.c | patch | blob | history | |
cache.h | patch | blob | history | |
combine-diff.c | patch | blob | history | |
diff.c | patch | blob | history | |
fsck-objects.c | patch | blob | history | |
sha1_name.c | patch | blob | history |
diff --git a/builtin-apply.c b/builtin-apply.c
index 4573c9abb214c6f7b3119b6e7f594c5ddf09162b..1c1d16f756d9b4b6586ca531efb2da6753f04f9a 100644 (file)
--- a/builtin-apply.c
+++ b/builtin-apply.c
}
get_sha1_hex(patch->new_sha1_prefix, sha1);
- if (!memcmp(sha1, null_sha1, 20)) {
+ if (is_null_sha1(sha1)) {
free(desc->buffer);
desc->alloc = desc->size = 0;
desc->buffer = NULL;
return error;
}
-static inline int is_null_sha1(const unsigned char *sha1)
-{
- return !memcmp(sha1, null_sha1, 20);
-}
-
static void show_index_list(struct patch *list)
{
struct patch *patch;
diff --git a/builtin-diff.c b/builtin-diff.c
index 82afce782d88a1f773599332910982ef804aea12..40e5c96f30e3d638c09b276805158bdba3ddde58 100644 (file)
--- a/builtin-diff.c
+++ b/builtin-diff.c
{
struct diff_filespec *one, *two;
- if (memcmp(null_sha1, old_sha1, 20) &&
- memcmp(null_sha1, new_sha1, 20) &&
+ if (!is_null_sha1(old_sha1) && !is_null_sha1(new_sha1) &&
!memcmp(old_sha1, new_sha1, 20))
return;
index af7740258d8d1bf5e44d2233c1fe1c35aa62ec77..c7382996f62061f1022262fcc6e6f3f15e946d0a 100644 (file)
--- a/cache.h
+++ b/cache.h
extern char *sha1_pack_index_name(const unsigned char *sha1);
extern const char *find_unique_abbrev(const unsigned char *sha1, int);
extern const unsigned char null_sha1[20];
+static inline int is_null_sha1(const unsigned char *sha1)
+{
+ return !memcmp(sha1, null_sha1, 20);
+}
int git_mkstemp(char *path, size_t n, const char *template);
diff --git a/combine-diff.c b/combine-diff.c
index 4c6bfed56ee0fe3c84124e0b9a9c5bb80c9abcf2..ce063b4ffa48eb1db8849d5aabb6732fc98946b6 100644 (file)
--- a/combine-diff.c
+++ b/combine-diff.c
{
char *blob;
char type[20];
- if (!memcmp(sha1, null_sha1, 20)) {
+ if (is_null_sha1(sha1)) {
/* deleted blob */
*size = 0;
return xcalloc(1, 1);
struct sline *sline; /* survived lines */
int mode_differs = 0;
int i, show_hunks;
- int working_tree_file = !memcmp(elem->sha1, null_sha1, 20);
+ int working_tree_file = is_null_sha1(elem->sha1);
int abbrev = opt->full_index ? 40 : DEFAULT_ABBREV;
mmfile_t result_file;
index 2327e6065b548ffb89136bda8b054e7b61d47c46..6a8c0c9c0130579b4fb89e0444511357fe0c78ec 100644 (file)
--- a/diff.c
+++ b/diff.c
if (mode) {
spec->mode = canon_mode(mode);
memcpy(spec->sha1, sha1, 20);
- spec->sha1_valid = !!memcmp(sha1, null_sha1, 20);
+ spec->sha1_valid = !is_null_sha1(sha1);
}
}
diff --git a/fsck-objects.c b/fsck-objects.c
index 4ba3377aeffa4b0c7868943d688c9a8ed2f5ed08..b0e882a99f91eba2e5d1eb04c3a93b03db0edadb 100644 (file)
--- a/fsck-objects.c
+++ b/fsck-objects.c
if (strncmp(git_refs_heads_master + pfxlen, "refs/heads/", 11))
return error("HEAD points to something strange (%s)",
git_refs_heads_master + pfxlen);
- if (!memcmp(null_sha1, sha1, 20))
+ if (is_null_sha1(sha1))
return error("HEAD: not a valid git pointer");
return 0;
}
diff --git a/sha1_name.c b/sha1_name.c
index c5a05faeb6b2bac74f4c5e06c5e397dc103bb190..f567454d22ada41b1565f26e7136e62b70769dfa 100644 (file)
--- a/sha1_name.c
+++ b/sha1_name.c
int status, is_null;
static char hex[41];
- is_null = !memcmp(sha1, null_sha1, 20);
+ is_null = is_null_sha1(sha1);
memcpy(hex, sha1_to_hex(sha1), 40);
if (len == 40 || !len)
return hex;