Skip to content

Commit 208ee59

Browse files
committed
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
2 parents f0209e8 + e34de73 commit 208ee59

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

shallow.c

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,6 +191,9 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,
191191
die("revision walk setup failed");
192192
traverse_commit_list(&revs, show_commit, NULL, &not_shallow_list);
193193

194+
if (!not_shallow_list)
195+
die("no commits selected for shallow requests");
196+
194197
/* Mark all reachable commits as NOT_SHALLOW */
195198
for (p = not_shallow_list; p; p = p->next)
196199
p->item->object.flags |= not_shallow_flag;

t/t5500-fetch-pack.sh

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -711,6 +711,17 @@ test_expect_success 'fetch shallow since ...' '
711711
test_cmp expected actual
712712
'
713713

714+
test_expect_success 'clone shallow since selects no commits' '
715+
test_create_repo shallow-since-the-future &&
716+
(
717+
cd shallow-since-the-future &&
718+
GIT_COMMITTER_DATE="100000000 +0700" git commit --allow-empty -m one &&
719+
GIT_COMMITTER_DATE="200000000 +0700" git commit --allow-empty -m two &&
720+
GIT_COMMITTER_DATE="300000000 +0700" git commit --allow-empty -m three &&
721+
test_must_fail git clone --shallow-since "900000000 +0700" "file://$(pwd)/." ../shallow111
722+
)
723+
'
724+
714725
test_expect_success 'shallow clone exclude tag two' '
715726
test_create_repo shallow-exclude &&
716727
(

0 commit comments

Comments
 (0)