Code

fsck.c: fix bogus "empty tree" check
[git.git] / diff.c
diff --git a/diff.c b/diff.c
index 18859a70e02b84dabd3da66defba7df1111d18c1..00e1590c6eec291c2a6b3f831b62f402768c7042 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -118,8 +118,7 @@ static int parse_funcname_pattern(const char *var, const char *ep, const char *v
                pp->next = funcname_pattern_list;
                funcname_pattern_list = pp;
        }
-       if (pp->pattern)
-               free(pp->pattern);
+       free(pp->pattern);
        pp->pattern = xstrdup(value);
        return 0;
 }
@@ -492,10 +491,8 @@ static void free_diff_words_data(struct emit_callback *ecbdata)
                                ecbdata->diff_words->plus.text.size)
                        diff_words_show(ecbdata->diff_words);
 
-               if (ecbdata->diff_words->minus.text.ptr)
-                       free (ecbdata->diff_words->minus.text.ptr);
-               if (ecbdata->diff_words->plus.text.ptr)
-                       free (ecbdata->diff_words->plus.text.ptr);
+               free (ecbdata->diff_words->minus.text.ptr);
+               free (ecbdata->diff_words->plus.text.ptr);
                free(ecbdata->diff_words);
                ecbdata->diff_words = NULL;
        }
@@ -2584,8 +2581,6 @@ const char *diff_unique_abbrev(const unsigned char *sha1, int len)
                return sha1_to_hex(sha1);
 
        abbrev = find_unique_abbrev(sha1, len);
-       if (!abbrev)
-               return sha1_to_hex(sha1);
        abblen = strlen(abbrev);
        if (abblen < 37) {
                static char hex[41];
@@ -3192,11 +3187,8 @@ static void diffcore_apply_filter(const char *filter)
 static int diff_filespec_is_identical(struct diff_filespec *one,
                                      struct diff_filespec *two)
 {
-       if (S_ISGITLINK(one->mode)) {
-               diff_fill_sha1_info(one);
-               diff_fill_sha1_info(two);
-               return !hashcmp(one->sha1, two->sha1);
-       }
+       if (S_ISGITLINK(one->mode))
+               return 0;
        if (diff_populate_filespec(one, 0))
                return 0;
        if (diff_populate_filespec(two, 0))