Merge branch 'xx/diff-tree-remerge-diff-fix'
"git rev-list ... | git diff-tree -p --remerge-diff --stdin" should behave more or less like "git log -p --remerge-diff" but instead it crashed, forgetting to prepare a temporary object store needed. * xx/diff-tree-remerge-diff-fix: diff-tree: fix crash when used with --remerge-diffmaint
commit
0da7673a51
|
@ -8,6 +8,7 @@
|
||||||
#include "read-cache-ll.h"
|
#include "read-cache-ll.h"
|
||||||
#include "repository.h"
|
#include "repository.h"
|
||||||
#include "revision.h"
|
#include "revision.h"
|
||||||
|
#include "tmp-objdir.h"
|
||||||
#include "tree.h"
|
#include "tree.h"
|
||||||
|
|
||||||
static struct rev_info log_tree_opt;
|
static struct rev_info log_tree_opt;
|
||||||
|
@ -166,6 +167,13 @@ 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",
|
||||||
|
@ -230,5 +238,10 @@ int cmd_diff_tree(int argc, const char **argv, const char *prefix)
|
||||||
diff_free(&opt->diffopt);
|
diff_free(&opt->diffopt);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (opt->remerge_diff) {
|
||||||
|
tmp_objdir_destroy(opt->remerge_objdir);
|
||||||
|
opt->remerge_objdir = NULL;
|
||||||
|
}
|
||||||
|
|
||||||
return diff_result_code(&opt->diffopt);
|
return diff_result_code(&opt->diffopt);
|
||||||
}
|
}
|
||||||
|
|
|
@ -110,6 +110,41 @@ test_expect_success 'can filter out additional headers with pickaxe' '
|
||||||
test_must_be_empty actual
|
test_must_be_empty actual
|
||||||
'
|
'
|
||||||
|
|
||||||
|
test_expect_success 'remerge-diff also works for git-diff-tree' '
|
||||||
|
# With a clean merge
|
||||||
|
git diff-tree -r -p --remerge-diff --no-commit-id bc_resolution >actual &&
|
||||||
|
test_must_be_empty actual &&
|
||||||
|
|
||||||
|
# With both a resolved conflict and an unrelated change
|
||||||
|
cat <<-EOF >tmp &&
|
||||||
|
diff --git a/numbers b/numbers
|
||||||
|
remerge CONFLICT (content): Merge conflict in numbers
|
||||||
|
index a1fb731..6875544 100644
|
||||||
|
--- a/numbers
|
||||||
|
+++ b/numbers
|
||||||
|
@@ -1,13 +1,9 @@
|
||||||
|
1
|
||||||
|
2
|
||||||
|
-<<<<<<< b0ed5cb (change_a)
|
||||||
|
-three
|
||||||
|
-=======
|
||||||
|
-tres
|
||||||
|
->>>>>>> 6cd3f82 (change_b)
|
||||||
|
+drei
|
||||||
|
4
|
||||||
|
5
|
||||||
|
6
|
||||||
|
7
|
||||||
|
-eight
|
||||||
|
+acht
|
||||||
|
9
|
||||||
|
EOF
|
||||||
|
sed -e "s/[0-9a-f]\{7,\}/HASH/g" tmp >expect &&
|
||||||
|
git diff-tree -r -p --remerge-diff --no-commit-id ab_resolution >tmp &&
|
||||||
|
sed -e "s/[0-9a-f]\{7,\}/HASH/g" tmp >actual &&
|
||||||
|
test_cmp expect actual
|
||||||
|
'
|
||||||
|
|
||||||
test_expect_success 'setup non-content conflicts' '
|
test_expect_success 'setup non-content conflicts' '
|
||||||
git switch --orphan base &&
|
git switch --orphan base &&
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue