Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

merge-tree: load default git config #1530

Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions builtin/merge-tree.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "merge-blobs.h"
#include "quote.h"
#include "tree.h"
#include "config.h"

static int line_termination = '\n';

Expand Down Expand Up @@ -628,6 +629,8 @@ int cmd_merge_tree(int argc, const char **argv, const char *prefix)
if (argc != expected_remaining_argc)
usage_with_options(merge_tree_usage, mt_options);

git_config(git_default_config, NULL);

/* Do the relevant type of merge */
if (o.mode == MODE_REAL)
return real_merge(&o, merge_base, argv[0], argv[1], prefix);
Expand Down
18 changes: 18 additions & 0 deletions t/t4300-merge-tree.sh
Original file line number Diff line number Diff line change
Expand Up @@ -334,4 +334,22 @@ test_expect_success 'turn tree to file' '
test_cmp expect actual
'

test_expect_success 'merge-tree respects core.useReplaceRefs=false' '
test_commit merge-to &&
test_commit valid base &&
git reset --hard HEAD^ &&
test_commit malicious base &&

test_when_finished "git replace -d $(git rev-parse valid^0)" &&
git replace valid^0 malicious^0 &&

tree=$(git -c core.useReplaceRefs=true merge-tree --write-tree merge-to valid) &&
merged=$(git cat-file -p $tree:base) &&
test malicious = $merged &&

tree=$(git -c core.useReplaceRefs=false merge-tree --write-tree merge-to valid) &&
merged=$(git cat-file -p $tree:base) &&
test valid = $merged
'

test_done