From: Junio C Hamano Date: Mon, 18 Jun 2018 17:18:45 +0000 (-0700) Subject: Merge branch 'sb/blame-color' X-Git-Tag: v2.18.0~14 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/698eb031bb163b797f90168368de1dec02a57127?ds=inline;hp=-c Merge branch 'sb/blame-color' Leakfix. * sb/blame-color: blame: release string_list after use in parse_color_fields() --- 698eb031bb163b797f90168368de1dec02a57127 diff --combined builtin/blame.c index 4202584f97,dc7870a561..3295718841 --- a/builtin/blame.c +++ b/builtin/blame.c @@@ -411,6 -411,7 +411,7 @@@ static void parse_color_fields(const ch die (_("must end with a color")); colorfield[colorfield_nr].hop = TIME_MAX; + string_list_clear(&l, 0); } static void setup_default_color_by_age(void) @@@ -584,7 -585,7 +585,7 @@@ static int read_ancestry(const char *gr static int update_auto_abbrev(int auto_abbrev, struct blame_origin *suspect) { - const char *uniq = find_unique_abbrev(suspect->commit->object.oid.hash, + const char *uniq = find_unique_abbrev(&suspect->commit->object.oid, auto_abbrev); int len = strlen(uniq); if (auto_abbrev < len) @@@ -758,15 -759,6 +759,15 @@@ static int blame_move_callback(const st return 0; } +static int is_a_rev(const char *name) +{ + struct object_id oid; + + if (get_oid(name, &oid)) + return 0; + return OBJ_NONE < oid_object_info(the_repository, &oid, NULL); +} + int cmd_blame(int argc, const char **argv, const char *prefix) { struct rev_info revs; @@@ -841,7 -833,6 +842,7 @@@ for (;;) { switch (parse_options_step(&ctx, options, blame_opt_usage)) { case PARSE_OPT_HELP: + case PARSE_OPT_ERROR: exit(129); case PARSE_OPT_DONE: if (ctx.argv[0]) @@@ -967,15 -958,16 +968,15 @@@ parse_done } else { if (argc < 2) usage_with_options(blame_opt_usage, options); - path = add_prefix(prefix, argv[argc - 1]); - if (argc == 3 && !file_exists(path)) { /* (2b) */ + if (argc == 3 && is_a_rev(argv[argc - 1])) { /* (2b) */ path = add_prefix(prefix, argv[1]); argv[1] = argv[2]; + } else { /* (2a) */ + if (argc == 2 && is_a_rev(argv[1]) && !get_git_work_tree()) + die("missing to blame"); + path = add_prefix(prefix, argv[argc - 1]); } argv[argc - 1] = "--"; - - setup_work_tree(); - if (!file_exists(path)) - die_errno("cannot stat path '%s'", path); } revs.disable_stdin = 1;