Skip to content

Commit 61eaa54

Browse files
committed
fetch-force
1 parent 60ffb83 commit 61eaa54

File tree

2 files changed

+28
-0
lines changed

2 files changed

+28
-0
lines changed

builtin/fetch.c

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,11 @@ static int git_fetch_config(const char *k, const char *v,
152152
return 0;
153153
}
154154

155+
if (!strcmp(k, "fetch.force")) {
156+
force = git_config_bool(k, v);
157+
return 0;
158+
}
159+
155160
if (!strcmp(k, "fetch.parallel")) {
156161
fetch_config->parallel = git_config_int(k, v, ctx->kvi);
157162
if (fetch_config->parallel < 0)

t/t5510-fetch.sh

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1727,6 +1727,29 @@ test_expect_success REFFILES "HEAD is updated even with conflicts" '
17271727
)
17281728
'
17291729

1730+
1731+
test_expect_success 'fetch.force' '
1732+
git init force-test &&
1733+
(
1734+
cd force-test &&
1735+
test_commit one &&
1736+
test_commit two &&
1737+
git branch -f master one &&
1738+
git init other &&
1739+
(
1740+
cd other &&
1741+
test_commit three &&
1742+
git branch -M master
1743+
) &&
1744+
git remote add other other &&
1745+
test_must_fail git fetch other master:master &&
1746+
git -c fetch.force=true fetch other master:master &&
1747+
git rev-parse master >actual &&
1748+
git -C other rev-parse master >expect &&
1749+
test_cmp expect actual
1750+
)
1751+
'
1752+
17301753
. "$TEST_DIRECTORY"/lib-httpd.sh
17311754
start_httpd
17321755

0 commit comments

Comments
 (0)