]> git.ipfire.org Git - thirdparty/git.git/blobdiff - diff.c
Upcast size_t variables to uintmax_t when printing
[thirdparty/git.git] / diff.c
diff --git a/diff.c b/diff.c
index 96833c8e81b5d6a7babb523c7ceec0e22ccdab33..88aaed7d49010e38fcf3f3fee726c18de99ddb36 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1217,10 +1217,11 @@ static void dim_moved_lines(struct diff_options *o)
 static void emit_line_ws_markup(struct diff_options *o,
                                const char *set_sign, const char *set,
                                const char *reset,
-                               char sign, const char *line, int len,
+                               int sign_index, const char *line, int len,
                                unsigned ws_rule, int blank_at_eof)
 {
        const char *ws = NULL;
+       int sign = o->output_indicators[sign_index];
 
        if (o->ws_error_highlight & ws_rule) {
                ws = diff_get_color_opt(o, DIFF_WHITESPACE);
@@ -1300,8 +1301,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
                                set = diff_get_color_opt(o, DIFF_FILE_OLD);
                }
                emit_line_ws_markup(o, set_sign, set, reset,
-                                   o->output_indicators[OUTPUT_INDICATOR_CONTEXT],
-                                   line, len,
+                                   OUTPUT_INDICATOR_CONTEXT, line, len,
                                    flags & (DIFF_SYMBOL_CONTENT_WS_MASK), 0);
                break;
        case DIFF_SYMBOL_PLUS:
@@ -1345,8 +1345,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
                        flags &= ~DIFF_SYMBOL_CONTENT_WS_MASK;
                }
                emit_line_ws_markup(o, set_sign, set, reset,
-                                   o->output_indicators[OUTPUT_INDICATOR_NEW],
-                                   line, len,
+                                   OUTPUT_INDICATOR_NEW, line, len,
                                    flags & DIFF_SYMBOL_CONTENT_WS_MASK,
                                    flags & DIFF_SYMBOL_CONTENT_BLANK_LINE_EOF);
                break;
@@ -1390,8 +1389,7 @@ static void emit_diff_symbol_from_struct(struct diff_options *o,
                                set = diff_get_color_opt(o, DIFF_CONTEXT_DIM);
                }
                emit_line_ws_markup(o, set_sign, set, reset,
-                                   o->output_indicators[OUTPUT_INDICATOR_OLD],
-                                   line, len,
+                                   OUTPUT_INDICATOR_OLD, line, len,
                                    flags & DIFF_SYMBOL_CONTENT_WS_MASK, 0);
                break;
        case DIFF_SYMBOL_WORDS_PORCELAIN:
@@ -3229,7 +3227,7 @@ static void emit_binary_diff_body(struct diff_options *o,
        }
 
        if (delta && delta_size < deflate_size) {
-               char *s = xstrfmt("%lu", orig_size);
+               char *s = xstrfmt("%"PRIuMAX , (uintmax_t)orig_size);
                emit_diff_symbol(o, DIFF_SYMBOL_BINARY_DIFF_HEADER_DELTA,
                                 s, strlen(s), 0);
                free(s);
@@ -4304,12 +4302,12 @@ static void diff_fill_oid_info(struct diff_filespec *one, struct index_state *is
 static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
 {
        /* Strip the prefix but do not molest /dev/null and absolute paths */
-       if (*namep && **namep != '/') {
+       if (*namep && !is_absolute_path(*namep)) {
                *namep += prefix_length;
                if (**namep == '/')
                        ++*namep;
        }
-       if (*otherp && **otherp != '/') {
+       if (*otherp && !is_absolute_path(*otherp)) {
                *otherp += prefix_length;
                if (**otherp == '/')
                        ++*otherp;