[PATCH 3/3] {fetch,upload}-pack: allow --depth=0 to deepen into full repo again

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@xxxxxxxxx>
---
 The funny thing is, even with --depth=0, I still have two commit grafts
 in $GIT_DIR/shallow, which are grafts of tags. I think there is a bug somewhere..

 builtin/fetch-pack.c |    2 +-
 shallow.c            |    2 +-
 upload-pack.c        |    8 ++++----
 3 files changed, 6 insertions(+), 6 deletions(-)

diff --git a/builtin/fetch-pack.c b/builtin/fetch-pack.c
index 45d1824..7d7af2e 100644
--- a/builtin/fetch-pack.c
+++ b/builtin/fetch-pack.c
@@ -845,7 +845,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)
 			}
 			if (!prefixcmp(arg, "--depth=")) {
 				args.depth = strtol(arg + 8, NULL, 0);
-				if (args.depth <= 0)
+				if (args.depth < 0)
 					die("Invalid depth %d", args.depth);
 				args.shallow = 1;
 				continue;
diff --git a/shallow.c b/shallow.c
index 4d90eda..eab97c6 100644
--- a/shallow.c
+++ b/shallow.c
@@ -85,7 +85,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,
 					continue;
 				*pointer = cur_depth;
 			}
-			if (cur_depth < depth) {
+			if (!depth || cur_depth < depth) {
 				if (p->next)
 					add_object_array(&p->item->object,
 							NULL, &stack);
diff --git a/upload-pack.c b/upload-pack.c
index fc79dde..7b004b9 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -484,7 +484,7 @@ static void receive_needs(void)
 {
 	struct object_array shallows = {0, 0, NULL};
 	static char line[1000];
-	int len, depth = 0;
+	int len, depth = -1;
 
 	shallow_nr = 0;
 	if (debug_fd)
@@ -514,7 +514,7 @@ static void receive_needs(void)
 		if (!prefixcmp(line, "deepen ")) {
 			char *end;
 			depth = strtol(line + 7, &end, 0);
-			if (end == line + 7 || depth <= 0)
+			if (end == line + 7 || depth < 0)
 				die("Invalid deepen: %s", line);
 			continue;
 		}
@@ -562,9 +562,9 @@ static void receive_needs(void)
 	if (!use_sideband && daemon_mode)
 		no_progress = 1;
 
-	if (depth == 0 && shallows.nr == 0)
+	if (depth == -1 && shallows.nr == 0)
 		return;
-	if (depth > 0) {
+	if (depth >= 0) {
 		struct commit_list *result, *backup;
 		int i;
 		backup = result = get_shallow_commits(&want_obj, depth,
-- 
1.7.1.rc1.69.g24c2f7

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]