Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.kernel.org/pub/scm/git/git.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/t
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2020-08-18 17:25:22 +0300
committerJunio C Hamano <gitster@pobox.com>2020-08-18 22:56:57 +0300
commit887952b8c680626f4721cb5fa57704478801aca4 (patch)
treee7cb5dd64843558d9cd4eb2e374a28e1464fb2c7 /t
parent2befe97201e1f3175cce557866c5822793624b5a (diff)
fetch: optionally allow disabling FETCH_HEAD update
If you run fetch but record the result in remote-tracking branches, and either if you do nothing with the fetched refs (e.g. you are merely mirroring) or if you always work from the remote-tracking refs (e.g. you fetch and then merge origin/branchname separately), you can get away with having no FETCH_HEAD at all. Teach "git fetch" a command line option "--[no-]write-fetch-head". The default is to write FETCH_HEAD, and the option is primarily meant to be used with the "--no-" prefix to override this default, because there is no matching fetch.writeFetchHEAD configuration variable to flip the default to off (in which case, the positive form may become necessary to defeat it). Note that under "--dry-run" mode, FETCH_HEAD is never written; otherwise you'd see list of objects in the file that you do not actually have. Passing `--write-fetch-head` does not force `git fetch` to write the file. Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 't')
-rwxr-xr-xt/t5510-fetch.sh15
-rwxr-xr-xt/t5521-pull-options.sh7
2 files changed, 20 insertions, 2 deletions
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 25695dfe22..2a1abe91f0 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -543,13 +543,24 @@ test_expect_success 'fetch into the current branch with --update-head-ok' '
'
-test_expect_success 'fetch --dry-run' '
-
+test_expect_success 'fetch --dry-run does not touch FETCH_HEAD' '
rm -f .git/FETCH_HEAD &&
git fetch --dry-run . &&
! test -f .git/FETCH_HEAD
'
+test_expect_success '--no-write-fetch-head does not touch FETCH_HEAD' '
+ rm -f .git/FETCH_HEAD &&
+ git fetch --no-write-fetch-head . &&
+ ! test -f .git/FETCH_HEAD
+'
+
+test_expect_success '--write-fetch-head gets defeated by --dry-run' '
+ rm -f .git/FETCH_HEAD &&
+ git fetch --dry-run --write-fetch-head . &&
+ ! test -f .git/FETCH_HEAD
+'
+
test_expect_success "should be able to fetch with duplicate refspecs" '
mkdir dups &&
(
diff --git a/t/t5521-pull-options.sh b/t/t5521-pull-options.sh
index 159afa7ac8..db1a381cd9 100755
--- a/t/t5521-pull-options.sh
+++ b/t/t5521-pull-options.sh
@@ -85,6 +85,13 @@ test_expect_success 'git pull --cleanup errors early on invalid argument' '
test -s err)
'
+test_expect_success 'git pull --no-write-fetch-head fails' '
+ mkdir clonedwfh &&
+ (cd clonedwfh && git init &&
+ test_expect_code 129 git pull --no-write-fetch-head "../parent" >out 2>err &&
+ test_must_be_empty out &&
+ test_i18ngrep "no-write-fetch-head" err)
+'
test_expect_success 'git pull --force' '
mkdir clonedoldstyle &&