summaryrefslogtreecommitdiffstats
path: root/builtin/blame.c
diff options
context:
space:
mode:
Diffstat (limited to 'builtin/blame.c')
-rw-r--r--builtin/blame.c23
1 files changed, 15 insertions, 8 deletions
diff --git a/builtin/blame.c b/builtin/blame.c
index e407a22da3..867032e4c1 100644
--- a/builtin/blame.c
+++ b/builtin/blame.c
@@ -4,7 +4,9 @@
* Copyright (c) 2006, 2014 by its authors
* See COPYING for licensing conditions
*/
+
#define USE_THE_REPOSITORY_VARIABLE
+
#include "builtin.h"
#include "config.h"
#include "color.h"
@@ -465,9 +467,14 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
reset = GIT_COLOR_RESET;
}
+ if (abbrev < MINIMUM_ABBREV)
+ BUG("abbreviation is smaller than minimum length: %d < %d",
+ abbrev, MINIMUM_ABBREV);
+
for (cnt = 0; cnt < ent->num_lines; cnt++) {
char ch;
- int length = (opt & OUTPUT_LONG_OBJECT_NAME) ? the_hash_algo->hexsz : abbrev;
+ size_t length = (opt & OUTPUT_LONG_OBJECT_NAME) ?
+ the_hash_algo->hexsz : (size_t) abbrev;
if (opt & OUTPUT_COLOR_LINE) {
if (cnt > 0) {
@@ -498,7 +505,7 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent, int
length--;
putchar('?');
}
- printf("%.*s", length, hex);
+ fwrite(hex, 1, length, stdout);
if (opt & OUTPUT_ANNOTATE_COMPAT) {
const char *name;
if (opt & OUTPUT_SHOW_EMAIL)
@@ -1216,12 +1223,6 @@ parse_done:
output_option &= ~(OUTPUT_COLOR_LINE | OUTPUT_SHOW_AGE_WITH_COLOR);
output(&sb, output_option);
- free((void *)sb.final_buf);
- for (ent = sb.ent; ent; ) {
- struct blame_entry *e = ent->next;
- free(ent);
- ent = e;
- }
if (show_stats) {
printf("num read blob: %d\n", sb.num_read_blob);
@@ -1230,6 +1231,12 @@ parse_done:
}
cleanup:
+ for (ent = sb.ent; ent; ) {
+ struct blame_entry *e = ent->next;
+ free(ent);
+ ent = e;
+ }
+
free(path);
cleanup_scoreboard(&sb);
release_revisions(&revs);