Merge branch 'jc/range-diff-lazy-setup'
Code clean-up. * jc/range-diff-lazy-setup: remerge-diff: clean up temporary objdir at a central place remerge-diff: lazily prepare temporary objdir on demand
This commit is contained in:
commit
be8ca2848a
@ -716,7 +716,7 @@ int cmd_describe(int argc, const char **argv, const char *prefix)
|
|||||||
BUG("malformed internal diff-index command line");
|
BUG("malformed internal diff-index command line");
|
||||||
run_diff_index(&revs, 0);
|
run_diff_index(&revs, 0);
|
||||||
|
|
||||||
if (!diff_result_code(&revs.diffopt))
|
if (!diff_result_code(&revs))
|
||||||
suffix = NULL;
|
suffix = NULL;
|
||||||
else
|
else
|
||||||
suffix = dirty;
|
suffix = dirty;
|
||||||
|
@ -82,7 +82,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix)
|
|||||||
if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0)
|
if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0)
|
||||||
die_errno("repo_read_index_preload");
|
die_errno("repo_read_index_preload");
|
||||||
run_diff_files(&rev, options);
|
run_diff_files(&rev, options);
|
||||||
result = diff_result_code(&rev.diffopt);
|
result = diff_result_code(&rev);
|
||||||
release_revisions(&rev);
|
release_revisions(&rev);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -75,7 +75,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix)
|
|||||||
return -1;
|
return -1;
|
||||||
}
|
}
|
||||||
run_diff_index(&rev, option);
|
run_diff_index(&rev, option);
|
||||||
result = diff_result_code(&rev.diffopt);
|
result = diff_result_code(&rev);
|
||||||
release_revisions(&rev);
|
release_revisions(&rev);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -167,13 +167,6 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
|
|||||||
|
|
||||||
opt->diffopt.rotate_to_strict = 1;
|
opt->diffopt.rotate_to_strict = 1;
|
||||||
|
|
||||||
if (opt->remerge_diff) {
|
|
||||||
opt->remerge_objdir = tmp_objdir_create("remerge-diff");
|
|
||||||
if (!opt->remerge_objdir)
|
|
||||||
die(_("unable to create temporary object directory"));
|
|
||||||
tmp_objdir_replace_primary_odb(opt->remerge_objdir, 1);
|
|
||||||
}
|
|
||||||
|
|
||||||
/*
|
/*
|
||||||
* NOTE! We expect "a..b" to expand to "^a b" but it is
|
* NOTE! We expect "a..b" to expand to "^a b" but it is
|
||||||
* perfectly valid for revision range parser to yield "b ^a",
|
* perfectly valid for revision range parser to yield "b ^a",
|
||||||
@ -238,10 +231,5 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
|
|||||||
diff_free(&opt->diffopt);
|
diff_free(&opt->diffopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (opt->remerge_diff) {
|
return diff_result_code(opt);
|
||||||
tmp_objdir_destroy(opt->remerge_objdir);
|
|
||||||
opt->remerge_objdir = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
return diff_result_code(&opt->diffopt);
|
|
||||||
}
|
}
|
||||||
|
@ -619,7 +619,7 @@ int cmd_diff(int argc, const char **argv, const char *prefix)
|
|||||||
builtin_diff_combined(&rev, argc, argv,
|
builtin_diff_combined(&rev, argc, argv,
|
||||||
ent.objects, ent.nr,
|
ent.objects, ent.nr,
|
||||||
first_non_parent);
|
first_non_parent);
|
||||||
result = diff_result_code(&rev.diffopt);
|
result = diff_result_code(&rev);
|
||||||
if (1 < rev.diffopt.skip_stat_unmatch)
|
if (1 < rev.diffopt.skip_stat_unmatch)
|
||||||
refresh_index_quietly();
|
refresh_index_quietly();
|
||||||
release_revisions(&rev);
|
release_revisions(&rev);
|
||||||
|
@ -504,13 +504,7 @@ static int cmd_log_walk_no_free(struct rev_info *rev)
|
|||||||
struct commit *commit;
|
struct commit *commit;
|
||||||
int saved_nrl = 0;
|
int saved_nrl = 0;
|
||||||
int saved_dcctc = 0;
|
int saved_dcctc = 0;
|
||||||
|
int result;
|
||||||
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);
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rev->early_output)
|
if (rev->early_output)
|
||||||
setup_early_output();
|
setup_early_output();
|
||||||
@ -551,16 +545,12 @@ static int cmd_log_walk_no_free(struct rev_info *rev)
|
|||||||
rev->diffopt.degraded_cc_to_c = saved_dcctc;
|
rev->diffopt.degraded_cc_to_c = saved_dcctc;
|
||||||
rev->diffopt.needed_rename_limit = saved_nrl;
|
rev->diffopt.needed_rename_limit = saved_nrl;
|
||||||
|
|
||||||
if (rev->remerge_diff) {
|
result = diff_result_code(rev);
|
||||||
tmp_objdir_destroy(rev->remerge_objdir);
|
|
||||||
rev->remerge_objdir = NULL;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&
|
if (rev->diffopt.output_format & DIFF_FORMAT_CHECKDIFF &&
|
||||||
rev->diffopt.flags.check_failed) {
|
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)
|
static int cmd_log_walk(struct rev_info *rev)
|
||||||
|
@ -974,7 +974,7 @@ static int show_stash(int argc, const char **argv, const char *prefix)
|
|||||||
}
|
}
|
||||||
log_tree_diff_flush(&rev);
|
log_tree_diff_flush(&rev);
|
||||||
|
|
||||||
ret = diff_result_code(&rev.diffopt);
|
ret = diff_result_code(&rev);
|
||||||
|
|
||||||
cleanup:
|
cleanup:
|
||||||
strvec_clear(&revision_args);
|
strvec_clear(&revision_args);
|
||||||
@ -1126,13 +1126,13 @@ static int check_changes_tracked_files(const struct pathspec *ps)
|
|||||||
diff_setup_done(&rev.diffopt);
|
diff_setup_done(&rev.diffopt);
|
||||||
|
|
||||||
run_diff_index(&rev, DIFF_INDEX_CACHED);
|
run_diff_index(&rev, DIFF_INDEX_CACHED);
|
||||||
if (diff_result_code(&rev.diffopt)) {
|
if (diff_result_code(&rev)) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
|
||||||
run_diff_files(&rev, 0);
|
run_diff_files(&rev, 0);
|
||||||
if (diff_result_code(&rev.diffopt)) {
|
if (diff_result_code(&rev)) {
|
||||||
ret = 1;
|
ret = 1;
|
||||||
goto done;
|
goto done;
|
||||||
}
|
}
|
||||||
|
@ -672,7 +672,7 @@ static void status_submodule(const char *path, const struct object_id *ce_oid,
|
|||||||
setup_revisions(diff_files_args.nr, diff_files_args.v, &rev, &opt);
|
setup_revisions(diff_files_args.nr, diff_files_args.v, &rev, &opt);
|
||||||
run_diff_files(&rev, 0);
|
run_diff_files(&rev, 0);
|
||||||
|
|
||||||
if (!diff_result_code(&rev.diffopt)) {
|
if (!diff_result_code(&rev)) {
|
||||||
print_status(flags, ' ', path, ce_oid,
|
print_status(flags, ' ', path, ce_oid,
|
||||||
displaypath);
|
displaypath);
|
||||||
} else if (!(flags & OPT_CACHED)) {
|
} else if (!(flags & OPT_CACHED)) {
|
||||||
|
@ -362,7 +362,7 @@ int diff_no_index(struct rev_info *revs,
|
|||||||
* The return code for --no-index imitates diff(1):
|
* The return code for --no-index imitates diff(1):
|
||||||
* 0 = no changes, 1 = changes, else error
|
* 0 = no changes, 1 = changes, else error
|
||||||
*/
|
*/
|
||||||
ret = diff_result_code(&revs->diffopt);
|
ret = diff_result_code(revs);
|
||||||
|
|
||||||
out:
|
out:
|
||||||
for (i = 0; i < ARRAY_SIZE(to_free); i++)
|
for (i = 0; i < ARRAY_SIZE(to_free); i++)
|
||||||
|
10
diff.c
10
diff.c
@ -12,6 +12,7 @@
|
|||||||
#include "environment.h"
|
#include "environment.h"
|
||||||
#include "gettext.h"
|
#include "gettext.h"
|
||||||
#include "tempfile.h"
|
#include "tempfile.h"
|
||||||
|
#include "revision.h"
|
||||||
#include "quote.h"
|
#include "quote.h"
|
||||||
#include "diff.h"
|
#include "diff.h"
|
||||||
#include "diffcore.h"
|
#include "diffcore.h"
|
||||||
@ -29,6 +30,7 @@
|
|||||||
#include "merge-ll.h"
|
#include "merge-ll.h"
|
||||||
#include "string-list.h"
|
#include "string-list.h"
|
||||||
#include "strvec.h"
|
#include "strvec.h"
|
||||||
|
#include "tmp-objdir.h"
|
||||||
#include "graph.h"
|
#include "graph.h"
|
||||||
#include "oid-array.h"
|
#include "oid-array.h"
|
||||||
#include "packfile.h"
|
#include "packfile.h"
|
||||||
@ -7088,10 +7090,16 @@ void diffcore_std(struct diff_options *options)
|
|||||||
options->found_follow = 0;
|
options->found_follow = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
int diff_result_code(struct diff_options *opt)
|
int diff_result_code(struct rev_info *revs)
|
||||||
{
|
{
|
||||||
|
struct diff_options *opt = &revs->diffopt;
|
||||||
int result = 0;
|
int result = 0;
|
||||||
|
|
||||||
|
if (revs->remerge_diff) {
|
||||||
|
tmp_objdir_destroy(revs->remerge_objdir);
|
||||||
|
revs->remerge_objdir = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
diff_warn_rename_limit("diff.renameLimit",
|
diff_warn_rename_limit("diff.renameLimit",
|
||||||
opt->needed_rename_limit,
|
opt->needed_rename_limit,
|
||||||
opt->degraded_cc_to_c);
|
opt->degraded_cc_to_c);
|
||||||
|
2
diff.h
2
diff.h
@ -648,7 +648,7 @@ int do_diff_cache(const struct object_id *, struct diff_options *);
|
|||||||
int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
|
int diff_flush_patch_id(struct diff_options *, struct object_id *, int);
|
||||||
void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx);
|
void flush_one_hunk(struct object_id *result, git_hash_ctx *ctx);
|
||||||
|
|
||||||
int diff_result_code(struct diff_options *);
|
int diff_result_code(struct rev_info *);
|
||||||
|
|
||||||
int diff_no_index(struct rev_info *,
|
int diff_no_index(struct rev_info *,
|
||||||
int implicit_no_index, int, const char **);
|
int implicit_no_index, int, const char **);
|
||||||
|
16
log-tree.c
16
log-tree.c
@ -1015,6 +1015,17 @@ static int do_remerge_diff(struct rev_info *opt,
|
|||||||
struct strbuf parent1_desc = STRBUF_INIT;
|
struct strbuf parent1_desc = STRBUF_INIT;
|
||||||
struct strbuf parent2_desc = STRBUF_INIT;
|
struct strbuf parent2_desc = STRBUF_INIT;
|
||||||
|
|
||||||
|
/*
|
||||||
|
* Lazily prepare a temporary object directory and rotate it
|
||||||
|
* into the alternative object store list as the primary.
|
||||||
|
*/
|
||||||
|
if (opt->remerge_diff && !opt->remerge_objdir) {
|
||||||
|
opt->remerge_objdir = tmp_objdir_create("remerge-diff");
|
||||||
|
if (!opt->remerge_objdir)
|
||||||
|
return error(_("unable to create temporary object directory"));
|
||||||
|
tmp_objdir_replace_primary_odb(opt->remerge_objdir, 1);
|
||||||
|
}
|
||||||
|
|
||||||
/* Setup merge options */
|
/* Setup merge options */
|
||||||
init_ui_merge_options(&o, the_repository);
|
init_ui_merge_options(&o, the_repository);
|
||||||
o.show_rename_progress = 0;
|
o.show_rename_progress = 0;
|
||||||
@ -1051,10 +1062,7 @@ static int do_remerge_diff(struct rev_info *opt,
|
|||||||
merge_finalize(&o, &res);
|
merge_finalize(&o, &res);
|
||||||
|
|
||||||
/* Clean up the contents of the temporary object directory */
|
/* Clean up the contents of the temporary object directory */
|
||||||
if (opt->remerge_objdir)
|
tmp_objdir_discard_objects(opt->remerge_objdir);
|
||||||
tmp_objdir_discard_objects(opt->remerge_objdir);
|
|
||||||
else
|
|
||||||
BUG("did a remerge diff without remerge_objdir?!?");
|
|
||||||
|
|
||||||
return !opt->loginfo;
|
return !opt->loginfo;
|
||||||
}
|
}
|
||||||
|
@ -2595,7 +2595,7 @@ int has_unstaged_changes(struct repository *r, int ignore_submodules)
|
|||||||
rev_info.diffopt.flags.quick = 1;
|
rev_info.diffopt.flags.quick = 1;
|
||||||
diff_setup_done(&rev_info.diffopt);
|
diff_setup_done(&rev_info.diffopt);
|
||||||
run_diff_files(&rev_info, 0);
|
run_diff_files(&rev_info, 0);
|
||||||
result = diff_result_code(&rev_info.diffopt);
|
result = diff_result_code(&rev_info);
|
||||||
release_revisions(&rev_info);
|
release_revisions(&rev_info);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
@ -2629,7 +2629,7 @@ int has_uncommitted_changes(struct repository *r,
|
|||||||
|
|
||||||
diff_setup_done(&rev_info.diffopt);
|
diff_setup_done(&rev_info.diffopt);
|
||||||
run_diff_index(&rev_info, DIFF_INDEX_CACHED);
|
run_diff_index(&rev_info, DIFF_INDEX_CACHED);
|
||||||
result = diff_result_code(&rev_info.diffopt);
|
result = diff_result_code(&rev_info);
|
||||||
release_revisions(&rev_info);
|
release_revisions(&rev_info);
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user