summaryrefslogtreecommitdiff
path: root/shallow.c
diff options
context:
space:
mode:
authorNguyễn Thái Ngọc Duy <pclouds@gmail.com>2013-12-05 20:02:41 +0700
committerJunio C Hamano <gitster@pobox.com>2013-12-10 16:14:17 -0800
commit79d3a236c551ad59719a6835bee03a1446296e65 (patch)
treea23554e47b3d83df429dda8e9fbe7c33a1b8cb58 /shallow.c
parent4820a33baa963c4559736d7a1c4c35f8dcb37293 (diff)
downloadgit-79d3a236c551ad59719a6835bee03a1446296e65.tar.gz
upload-pack: make sure deepening preserves shallow roots
When "fetch --depth=N" where N exceeds the longest chain of history in the source repo, usually we just send an "unshallow" line to the client so full history is obtained. When the source repo is shallow we need to make sure to "unshallow" the current shallow point _and_ "shallow" again when the commit reaches its shallow bottom in the source repo. This should fix both cases: large <N> and --unshallow. Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'shallow.c')
-rw-r--r--shallow.c6
1 files changed, 5 insertions, 1 deletions
diff --git a/shallow.c b/shallow.c
index fb6069ba0c..52268544fd 100644
--- a/shallow.c
+++ b/shallow.c
@@ -75,6 +75,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
struct commit_list *result = NULL;
struct object_array stack = OBJECT_ARRAY_INIT;
struct commit *commit = NULL;
+ struct commit_graft *graft;
while (commit || i < heads->nr || stack.nr) {
struct commit_list *p;
@@ -99,7 +100,10 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
if (parse_commit(commit))
die("invalid commit");
cur_depth++;
- if (cur_depth >= depth) {
+ if ((depth != INFINITE_DEPTH && cur_depth >= depth) ||
+ (is_repository_shallow() && !commit->parents &&
+ (graft = lookup_commit_graft(commit->object.sha1)) != NULL &&
+ graft->nr_parent < 0)) {
commit_list_insert(commit, &result);
commit->object.flags |= shallow_flag;
commit = NULL;