diff options
author | Lukas Fleischer <git@cryptocrack.de> | 2015-01-12 20:59:26 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2015-01-13 10:05:53 -0800 |
commit | a46442f1675722eb68238b329a4a285f03f41dda (patch) | |
tree | 4e8a08097bd0bf0ce93dd5b57b9150d0d36e32c8 | |
parent | 8c53f0719b04e0b6328c2e175e3c5d2dc8a0c282 (diff) | |
download | git-a46442f1675722eb68238b329a4a285f03f41dda.tar.gz git-a46442f1675722eb68238b329a4a285f03f41dda.tar.xz |
blame.c: fix garbled error message
The helper functions prepare_final() and prepare_initial() return a
pointer to a string that is a member of an object in the revs->pending
array. This array is later rebuilt when running prepare_revision_walk()
which potentially transforms the pointer target into a bogus string. Fix
this by maintaining a copy of the original string.
Signed-off-by: Lukas Fleischer <git@cryptocrack.de>
Signed-off-by: Jeff King <peff@peff.net>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
-rw-r--r-- | builtin/blame.c | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/builtin/blame.c b/builtin/blame.c index 3838be2b0..699109b4a 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -2390,7 +2390,7 @@ static struct commit *fake_working_tree_commit(struct diff_options *opt, return commit; } -static const char *prepare_final(struct scoreboard *sb) +static char *prepare_final(struct scoreboard *sb) { int i; const char *final_commit_name = NULL; @@ -2415,10 +2415,10 @@ static const char *prepare_final(struct scoreboard *sb) sb->final = (struct commit *) obj; final_commit_name = revs->pending.objects[i].name; } - return final_commit_name; + return xstrdup_or_null(final_commit_name); } -static const char *prepare_initial(struct scoreboard *sb) +static char *prepare_initial(struct scoreboard *sb) { int i; const char *final_commit_name = NULL; @@ -2445,7 +2445,7 @@ static const char *prepare_initial(struct scoreboard *sb) } if (!final_commit_name) die("No commit to dig down to?"); - return final_commit_name; + return xstrdup(final_commit_name); } static int blame_copy_callback(const struct option *option, const char *arg, int unset) @@ -2489,7 +2489,7 @@ int cmd_blame(int argc, const char **argv, const char *prefix) struct origin *o; struct blame_entry *ent = NULL; long dashdash_pos, lno; - const char *final_commit_name = NULL; + char *final_commit_name = NULL; enum object_type type; static struct string_list range_list; @@ -2786,6 +2786,8 @@ parse_done: assign_blame(&sb, opt); + free(final_commit_name); + if (incremental) return 0; |