diff options
Diffstat (limited to 'builtin/log.c')
| -rw-r--r-- | builtin/log.c | 65 |
1 files changed, 41 insertions, 24 deletions
diff --git a/builtin/log.c b/builtin/log.c index a73a767606..368f6580a6 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -4,6 +4,7 @@ * (C) Copyright 2006 Linus Torvalds * 2006 Junio Hamano */ +#define USE_THE_REPOSITORY_VARIABLE #include "builtin.h" #include "abspath.h" #include "config.h" @@ -37,7 +38,7 @@ #include "mailmap.h" #include "progress.h" #include "commit-slab.h" -#include "repository.h" + #include "commit-reach.h" #include "range-diff.h" #include "tmp-objdir.h" @@ -504,13 +505,7 @@ static int cmd_log_walk_no_free(struct rev_info *rev) struct commit *commit; int saved_nrl = 0; int saved_dcctc = 0; - - if (rev->remerge_diff) { - rev->remerge_objdir = tmp_objdir_create("remerge-diff"); - if (!rev->remerge_objdir) - die(_("unable to create temporary object directory")); - tmp_objdir_replace_primary_odb(rev->remerge_objdir, 1); - } + int result; if (rev->early_output) setup_early_output(); @@ -551,16 +546,12 @@ static int cmd_log_walk_no_free(struct rev_info *rev) rev->diffopt.degraded_cc_to_c = saved_dcctc; rev->diffopt.needed_rename_limit = saved_nrl; - if (rev->remerge_diff) { - tmp_objdir_destroy(rev->remerge_objdir); - rev->remerge_objdir = NULL; - } - + result = diff_result_code(rev); if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF && rev->diffopt.flags.check_failed) { - return 02; + result = 02; } - return diff_result_code(&rev->diffopt); + return result; } static int cmd_log_walk(struct rev_info *rev) @@ -637,7 +628,10 @@ static int git_log_config(const char *var, const char *value, return git_diff_ui_config(var, value, ctx, cb); } -int cmd_whatchanged(int argc, const char **argv, const char *prefix) +int cmd_whatchanged(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { struct log_config cfg; struct rev_info rev; @@ -707,6 +701,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c write_or_die(1, buf, size); object_context_release(&obj_context); + free(buf); return 0; } @@ -757,7 +752,10 @@ static void show_setup_revisions_tweak(struct rev_info *rev) rev->diffopt.output_format = DIFF_FORMAT_PATCH; } -int cmd_show(int argc, const char **argv, const char *prefix) +int cmd_show(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { struct log_config cfg; struct rev_info rev; @@ -873,7 +871,10 @@ int cmd_show(int argc, const char **argv, const char *prefix) /* * This is equivalent to "git log -g --abbrev-commit --pretty=oneline" */ -int cmd_log_reflog(int argc, const char **argv, const char *prefix) +int cmd_log_reflog(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { struct log_config cfg; struct rev_info rev; @@ -915,7 +916,10 @@ static void log_setup_revisions_tweak(struct rev_info *rev) diff_merges_default_to_first_parent(rev); } -int cmd_log(int argc, const char **argv, const char *prefix) +int cmd_log(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { struct log_config cfg; struct rev_info rev; @@ -1827,12 +1831,14 @@ static struct commit *get_base_commit(const struct format_config *cfg, if (die_on_failure) { die(_("failed to find exact merge base")); } else { + free_commit_list(merge_base); free(rev); return NULL; } } rev[i] = merge_base->item; + free_commit_list(merge_base); } if (rev_nr % 2) @@ -1983,7 +1989,10 @@ static void infer_range_diff_ranges(struct strbuf *r1, } } -int cmd_format_patch(int argc, const char **argv, const char *prefix) +int cmd_format_patch(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { struct format_config cfg; struct commit *commit; @@ -2023,6 +2032,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) const char *rfc = NULL; int creation_factor = -1; const char *signature = git_version_string; + char *signature_to_free = NULL; char *signature_file_arg = NULL; struct keep_callback_data keep_callback_data = { .cfg = &cfg, @@ -2443,7 +2453,7 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) if (strbuf_read_file(&buf, signature_file, 128) < 0) die_errno(_("unable to read signature file '%s'"), signature_file); - signature = strbuf_detach(&buf, NULL); + signature = signature_to_free = strbuf_detach(&buf, NULL); } else if (cfg.signature) { signature = cfg.signature; } @@ -2548,12 +2558,13 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix) else print_signature(signature, rev.diffopt.file); } - if (output_directory) + if (output_directory) { fclose(rev.diffopt.file); + rev.diffopt.file = NULL; + } } stop_progress(&progress); free(list); - free(branch_name); if (ignore_if_in_upstream) free_patch_ids(&ids); @@ -2565,11 +2576,14 @@ done: strbuf_release(&rdiff_title); free(description_file); free(signature_file_arg); + free(signature_to_free); + free(branch_name); free(to_free); free(rev.message_id); if (rev.ref_message_ids) string_list_clear(rev.ref_message_ids, 0); free(rev.ref_message_ids); + rev.diffopt.no_free = 0; release_revisions(&rev); format_config_release(&cfg); return 0; @@ -2611,7 +2625,10 @@ static void print_commit(char sign, struct commit *commit, int verbose, } } -int cmd_cherry(int argc, const char **argv, const char *prefix) +int cmd_cherry(int argc, + const char **argv, + const char *prefix, + struct repository *repo UNUSED) { struct rev_info revs; struct patch_ids ids; |
