1
0
Fork 0
mirror of https://github.com/git/git.git synced 2024-05-26 19:56:11 +02:00

Merge branch 'nd/reject-empty-shallow-request'

"git fetch --shallow-since=<cutoff>" that specifies the cut-off
point that is newer than the existing history used to end up
grabbing the entire history.  Such a request now errors out.

* nd/reject-empty-shallow-request:
  upload-pack: reject shallow requests that would return nothing
This commit is contained in:
Junio C Hamano 2018-06-25 13:22:40 -07:00
commit 208ee59861
2 changed files with 14 additions and 0 deletions

View File

@ -191,6 +191,9 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
die("revision walk setup failed");
traverse_commit_list(&revs, show_commit, NULL, &not_shallow_list);
if (!not_shallow_list)
die("no commits selected for shallow requests");
/* Mark all reachable commits as NOT_SHALLOW */
for (p = not_shallow_list; p; p = p->next)
p->item->object.flags |= not_shallow_flag;

View File

@ -711,6 +711,17 @@ test_expect_success 'fetch shallow since ...' '
test_cmp expected actual
'
test_expect_success 'clone shallow since selects no commits' '
test_create_repo shallow-since-the-future &&
(
cd shallow-since-the-future &&
GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
test_must_fail git clone --shallow-since "900000000 +0700" "file://$(pwd)/." ../shallow111
)
'
test_expect_success 'shallow clone exclude tag two' '
test_create_repo shallow-exclude &&
(