summary | shortlog | log | commit | commitdiff | tree
raw | patch | inline | side by side (parent: 2efb3b0)
raw | patch | inline | side by side (parent: 2efb3b0)
author | Junio C Hamano <gitster@pobox.com> | |
Sun, 2 Mar 2008 08:57:26 +0000 (00:57 -0800) | ||
committer | Junio C Hamano <gitster@pobox.com> | |
Sun, 2 Mar 2008 09:00:30 +0000 (01:00 -0800) |
The internal implementation of diff-index codepath used to use non const
pointer to pass sha1 around, but it did not have to. With this, we can
also lose the private no_sha1[] array, as we can use the public null_sha1[]
array that exists exactly for the same purpose.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
pointer to pass sha1 around, but it did not have to. With this, we can
also lose the private no_sha1[] array, as we can use the public null_sha1[]
array that exists exactly for the same purpose.
Signed-off-by: Junio C Hamano <gitster@pobox.com>
diff-lib.c | patch | blob | history |
diff --git a/diff-lib.c b/diff-lib.c
index 94b150e830c5d9bd828a5e050166eed27e0b0e62..4581b594d0a65d5bbe782b1db5d69f33189a0e50 100644 (file)
--- a/diff-lib.c
+++ b/diff-lib.c
static void diff_index_show_file(struct rev_info *revs,
const char *prefix,
struct cache_entry *ce,
- unsigned char *sha1, unsigned int mode)
+ const unsigned char *sha1, unsigned int mode)
{
diff_addremove(&revs->diffopt, prefix[0], mode,
sha1, ce->name, NULL);
}
static int get_stat_data(struct cache_entry *ce,
- unsigned char **sha1p,
+ const unsigned char **sha1p,
unsigned int *modep,
int cached, int match_missing)
{
- unsigned char *sha1 = ce->sha1;
+ const unsigned char *sha1 = ce->sha1;
unsigned int mode = ce->ce_mode;
if (!cached) {
- static unsigned char no_sha1[20];
int changed;
struct stat st;
if (lstat(ce->name, &st) < 0) {
changed = ce_match_stat(ce, &st, 0);
if (changed) {
mode = ce_mode_from_stat(ce, st.st_mode);
- sha1 = no_sha1;
+ sha1 = null_sha1;
}
}
struct cache_entry *new,
int cached, int match_missing)
{
- unsigned char *sha1;
+ const unsigned char *sha1;
unsigned int mode;
/* New file in the index: it might actually be different in
int cached, int match_missing)
{
unsigned int mode, oldmode;
- unsigned char *sha1;
+ const unsigned char *sha1;
if (get_stat_data(new, &sha1, &mode, cached, match_missing) < 0) {
if (report_missing)