More flexibility in making shallow clones
Get series with b4
b4 am [email protected]Versions newest first · linked by author and title
- v3 Latest25 patches 0 repliesNew
- v225 patches 37 repliesSuperseded
- v120 patches 3 repliesSuperseded
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/25 | remote-curl.c: convert fetch_git() to use argv_arrayremote-curl.c | +17 | 0 replies | |
| 2/25 | transport-helper.c: refactor set_helper_option()transport-helper.c | +23 | 0 replies | |
| 3/25 | upload-pack: move shallow deepen code out of receive_needs()upload-pack.c | +52 | 0 replies | |
| 4/25 | upload-pack: move "shallow" sending code out of deepen()upload-pack.c | +15 | 0 replies | |
| 5/25 | upload-pack: remove unused variable "backup"upload-pack.c | +4 | 0 replies | |
| 6/25 | upload-pack: move "unshallow" sending code out of deepen()upload-pack.c | +26 | 0 replies | |
| 7/25 | upload-pack: use skip_prefix() instead of starts_with()upload-pack.c | +15 | 0 replies | |
| 8/25 | upload-pack: tighten number parsing at "deepen" linesupload-pack.c | +2 | 0 replies | |
| 9/25 | upload-pack: move rev-list code out of check_non_tip()upload-pack.c | +25 | 0 replies | |
| 10/25 | fetch-pack: use skip_prefix() instead of starts_with()builtin/ | +6 | 0 replies | |
| 11/25 | fetch-pack: use a common function for verbose printingfetch-pack.c | +42 | 0 replies | |
| 12/25 | fetch-pack: use a separate flag for fetch in deepening modefetch-pack.c fetch-pack.h | +9 | 0 replies | |
| 13/25 | shallow.c: implement a generic shallow boundary finder based on rev-listcommit.h shallow.c | +79 | 0 replies | |
| 14/25 | upload-pack: add deepen-since to cut shallow repos based on timeDocumentation/ Documentation/ upload-pack.c | +54 | 0 replies | |
| 15/25 | fetch: define shallow boundary with --shallow-sinceDocumentation/ Documentation/ Documentation/ +7 more | +67 | 0 replies | |
| 16/25 | clone: define shallow clone boundary based on time with --shallow-sinceDocumentation/ builtin/ | +16 | 0 replies | |
| 17/25 | t5500, t5539: tests for shallow depth since a specific datet/ t/ | +50 | 0 replies | |
| 18/25 | refs: add expand_ref()refs.c refs.h | +8 | 0 replies | |
| 19/25 | upload-pack: support define shallow boundary by excluding revisionsDocumentation/ Documentation/ upload-pack.c | +32 | 0 replies | |
| 20/25 | fetch: define shallow boundary with --shallow-excludeDocumentation/ Documentation/ Documentation/ +8 more | +97 | 0 replies | |
| 21/25 | clone: define shallow clone boundary with --shallow-excludeDocumentation/ builtin/ | +22 | 0 replies | |
| 22/25 | t5500, t5539: tests for shallow depth excluding a reft/ t/ | +44 | 0 replies | |
| 23/25 | upload-pack: split check_unreachable() in two, prep for get_reachable_list()upload-pack.c | +26 | 0 replies | |
| 24/25 | upload-pack: add get_reachable_list()object.h upload-pack.c | +50 | 0 replies | |
| 25/25 | fetch, upload-pack: --deepen=N extends shallow boundary by N commitsDocumentation/ Documentation/ Documentation/ +12 more | +129 | 0 replies |
Reviews trailers per patch
None of the 25 patches has a Reviewed-by or Acked-by.
| Patch | Duy Nguyen | Eric Sunshine | Junio C Hamano |
|---|---|---|---|
| 1/25 | |||
| 2/25 | |||
| 3/25 | |||
| 4/25 | |||
| 5/25 | |||
| 6/25 | |||
| 7/25 | |||
| 8/25 | |||
| 9/25 | |||
| 10/25 | |||
| 11/25 | |||
| 12/25 | |||
| 13/25 | |||
| 14/25 | |||
| 15/25 | |||
| 16/25 | |||
| 17/25 | |||
| 18/25 | |||
| 19/25 | |||
| 20/25 | |||
| 21/25 | |||
| 22/25 | |||
| 23/25 | |||
| 24/25 | |||
| 25/25 | Helped-by | Helped-by | Helped-by |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes. Scroll the table sideways for all 3 reviewers.
Cover letter [PATCH v3 00/25] More flexibility in making shallow clones
Changes since v2 [1]
- PATCH v2 03/25, transport-helper.c: do not send null option to remote, is dropped. It's just a hack. Even if we want to set NULL to a transport option to say "reset to defaults", we need to tell remote helper about it, not silently ignore it. 15/25 solves it without the old patch.
- get_shallow_commits_by_rev_list() avoids going through all in-core objects in 13/25
- split check_unreachable()'s double usage, 23/25 (new) and 24/25. 23/25 actually makes interdiff a bit messy to read.
- move --not arguments before revs in 19/25
- some more small changes for other comments, see interdiff.
[1] http://thread.gmane.org/gmane.comp.version-control.git/285414
Interdiff
builtin/fetch-pack.c +13 -17
@@ -50,6 +50,7 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)struct child_process *conn;struct fetch_pack_args args;struct sha1_array shallow =SHA1_ARRAY_INIT ; +struct string_list deepen_not =STRING_LIST_INIT_DUP ;packet_trace_identity ("fetch-pack" );
@@ -58,14 +59,13 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix)for (i =1 ; i < argc && *argv[i] =='-' ; i++) {const char *arg = argv[i]; -const char *value; -if (skip_prefix (arg,"--upload-pack=" , &value)) { - args.uploadpack = value; +if (skip_prefix (arg,"--upload-pack=" , &arg)) { + args.uploadpack = arg;continue ; } -if (skip_prefix (arg,"--exec=" , &value)) { - args.uploadpack = value; +if (skip_prefix (arg,"--exec=" , &arg)) { + args.uploadpack = arg;continue ; }if (!strcmp ("--quiet" , arg) || !strcmp ("-q" , arg)) {
@@ -101,22 +101,16 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) args.verbose =1 ;continue ; } -if (skip_prefix (arg,"--depth=" , &value)) { - args.depth =strtol (value,NULL ,0 ); +if (skip_prefix (arg,"--depth=" , &arg)) { + args.depth =strtol (arg,NULL ,0 );continue ; } -if (skip_prefix (arg,"--shallow-since=" , &value)) { - args.deepen_since =xstrdup (value); +if (skip_prefix (arg,"--shallow-since=" , &arg)) { + args.deepen_since =xstrdup (arg);continue ; } -if (skip_prefix (arg,"--shallow-exclude=" , &value)) { -static struct string_list *deepen_not; -if (!deepen_not) { - deepen_not =xmalloc (sizeof (*deepen_not)); -string_list_init (deepen_not,1 ); - args.deepen_not = deepen_not; - } -string_list_append (deepen_not, value); +if (skip_prefix (arg,"--shallow-exclude=" , &arg)) { +string_list_append (&deepen_not, arg);continue ; }if (!strcmp (arg,"--deepen-relative" )) {
@@ -150,6 +144,8 @@ int cmd_fetch_pack(int argc, const char **argv, const char *prefix) }usage (fetch_pack_usage); } +if (deepen_not.nr) + args.deepen_not = &deepen_not;if (i < argc) dest = argv[i++];
builtin/fetch.c +17 -8
@@ -875,7 +875,7 @@ static void set_option(struct transport *transport, const char *name, const char name, transport->url); } -static struct transport *prepare_transport (struct remote *remote) +static struct transport *prepare_transport (struct remote *remote,int deepen) {struct transport *transport; transport =transport_get (remote,NULL );
@@ -886,9 +886,9 @@ static struct transport *prepare_transport(struct remote *remote)set_option (transport,TRANS_OPT_KEEP ,"yes" );if (depth)set_option (transport,TRANS_OPT_DEPTH , depth); -if (deepen_since) +if (deepen && deepen_since)set_option (transport,TRANS_OPT_DEEPEN_SINCE , deepen_since); -if (deepen_not.nr) +if (deepen && deepen_not.nr)set_option (transport,TRANS_OPT_DEEPEN_NOT , (const char *)&deepen_not);if (deepen_relative)
@@ -900,15 +900,24 @@ static struct transport *prepare_transport(struct remote *remote)static void backfill_tags (struct transport *transport,struct ref *ref_map) { -if (transport->cannot_reuse) { - gsecondary =prepare_transport (transport->remote); +int cannot_reuse; + +/* +* Once we have set TRANS_OPT_DEEPEN_SINCE, we can't unset it +* when remote helper is used (setting it to an empty string +* is not unsetting). We could extend the remote helper +* protocol for that, but for now, just force a new connection +* without deepen-since. Similar story for deepen-not. +*/ + cannot_reuse = transport->cannot_reuse || + deepen_since || deepen_not.nr; +if (cannot_reuse) { + gsecondary =prepare_transport (transport->remote,0 ); transport = gsecondary; }transport_set_option (transport,TRANS_OPT_FOLLOWTAGS ,NULL );transport_set_option (transport,TRANS_OPT_DEPTH ,"0" ); -transport_set_option (transport,TRANS_OPT_DEEPEN_SINCE ,NULL ); -transport_set_option (transport,TRANS_OPT_DEEPEN_NOT ,NULL );transport_set_option (transport,TRANS_OPT_DEEPEN_RELATIVE ,NULL );fetch_refs (transport, ref_map);
@@ -1121,7 +1130,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv)die (_ ("No remote repository specified. Please, specify either a URL or a\n" "remote name from which new revisions should be fetched." )); - gtransport =prepare_transport (remote); + gtransport =prepare_transport (remote,1 );if (prune <0 ) {/* no command line request */
fetch-pack.c +1 -1
@@ -857,7 +857,7 @@ static struct ref *do_fetch_pack(struct fetch_pack_args *args, allow_unadvertised_object_request |=ALLOW_TIP_SHA1 ; }if (server_supports ("allow-reachable-sha1-in-want" )) { -print_verbose (args,"Server supports allow-reachable-sha1-in-want\n" ); +print_verbose (args,"Server supports allow-reachable-sha1-in-want" ); allow_unadvertised_object_request |=ALLOW_REACHABLE_SHA1 ; }if (!server_supports ("thin-pack" ))
remote-curl.c +1 -2
@@ -750,8 +750,7 @@ static int fetch_git(struct discovery *heads,struct argv_array args =ARGV_ARRAY_INIT ;argv_array_pushl (&args,"fetch-pack" ,"--stateless-rpc" , -"--stdin" ,"--lock-pack" , -NULL ); +"--stdin" ,"--lock-pack" ,NULL );if (options.followtags)argv_array_push (&args,"--include-tag" );if (options.thin)
shallow.c +16 -24
@@ -141,7 +141,7 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth,static void show_commit (struct commit *commit,void *data) { - commit->object.flags |= *(int *)data; +commit_list_insert (commit, data); }/*
@@ -155,20 +155,15 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av, int not_shallow_flag) {struct commit_list *result =NULL , *p; +struct commit_list *not_shallow_list =NULL ;struct rev_info revs; -unsigned int i, nr; +int both_flags = shallow_flag | not_shallow_flag;/* * SHALLOW (excluded) and NOT_SHALLOW (included) should not be * set at this point. But better be safe than sorry. */ - nr =get_max_object_index (); -for (i =0 ; i < nr; i++) { -struct object *o =get_indexed_object (i); -if (!o || o->type !=OBJ_COMMIT ) -continue ; - o->flags &= ~(shallow_flag | not_shallow_flag); - } +clear_object_flags (both_flags);is_repository_shallow ();/* make sure shallows are read */
@@ -176,10 +171,13 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av, save_commit_buffer =0 ;setup_revisions (ac, av, &revs,NULL ); -/* Mark all reachable commits as NOT_SHALLOW */ if (prepare_revision_walk (&revs))die ("revision walk setup failed" ); -traverse_commit_list (&revs, show_commit,NULL , ¬_shallow_flag); +traverse_commit_list (&revs, show_commit,NULL , ¬_shallow_list); + +/* Mark all reachable commits as NOT_SHALLOW */ +for (p = not_shallow_list; p; p = p->next) + p->item->object.flags |= not_shallow_flag;/* * mark border commits SHALLOW + NOT_SHALLOW.
@@ -188,14 +186,8 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,* A, later. If NOT_SHALLOW on A is cleared at step 1, B * itself is considered border at step 2, which is incorrect. */ - nr =get_max_object_index (); -for (i =0 ; i < nr; i++) { -struct object *o =get_indexed_object (i); -struct commit *c = (struct commit *)o; - -if (!o || o->type !=OBJ_COMMIT || - !(o->flags & not_shallow_flag)) -continue ; +for (p = not_shallow_list; p; p = p->next) { +struct commit *c = p->item;if (parse_commit (c)) die("unable to parse commit %s",
@@ -203,21 +195,21 @@ struct commit_list *get_shallow_commits_by_rev_list(int ac, const char **av,for (p = c->parents; p; p = p->next)if (!(p->item->object.flags & not_shallow_flag)) { - o->flags |= shallow_flag; + c->object.flags |= shallow_flag;commit_list_insert (c, &result);break ; } } +free_commit_list (not_shallow_list);/* * Now we can clean up NOT_SHALLOW on border commits. Having * both flags set can confuse the caller. */ for (p = result; p; p = p->next) { -struct object *ro = &p->item->object; -if ((ro->flags & not_shallow_flag) && - (ro->flags & shallow_flag)) - ro->flags &= ~not_shallow_flag; +struct object *o = &p->item->object; +if ((o->flags & both_flags) == both_flags) + o->flags &= ~not_shallow_flag; }return result; }
t/t5500-fetch-pack.sh +4 -2
@@ -654,8 +654,10 @@ test_expect_success 'clone shallow since ...' ' test_expect_success 'fetch shallow since ...' ' git -C shallow11 fetch --shallow-since "200000000 +0700" origin && git -C shallow11 log --pretty=tformat:%s origin/master >actual && - echo three >expected && - echo two >>expected && + cat >expected <<-\EOF && + three + two + EOF test_cmp expected actual '
t/t5539-fetch-http-shallow.sh +4 -2
@@ -91,8 +91,10 @@ test_expect_success 'clone shallow since ...' ' test_expect_success 'fetch shallow since ...' ' git -C shallow11 fetch --shallow-since "200000000 +0700" origin && git -C shallow11 log --pretty=tformat:%s origin/master >actual && - echo three >expected && - echo two >>expected && + cat >expected <<-\EOF && + three + two + EOF test_cmp expected actual '
transport-helper.c +1 -8
@@ -290,9 +290,6 @@ static int string_list_set_helper_option(struct helper_data *data,struct strbuf buf =STRBUF_INIT ;int i, ret =0 ; -if (!list) -return 0 ; -for (i =0 ; i < list->nr; i++) {strbuf_addf (&buf,"option %s " , name);quote_c_style (list->items[i].string, &buf,NULL ,0 );
@@ -337,12 +334,8 @@ static int set_helper_option(struct transport *transport,strbuf_addf (&buf,"option %s " , name);if (is_bool)strbuf_addstr (&buf, value ?"true" :"false" ); -else if (value) +else quote_c_style (value, &buf,NULL ,0 ); -else { -strbuf_release (&buf); -return 0 ; - }strbuf_addch (&buf,'\n' ); ret =strbuf_set_helper_option (data, &buf);
transport.c +1 -0
@@ -482,6 +482,7 @@ static int set_git_option(struct git_transport_options *opts,return 0 ; }else if (!strcmp (name,TRANS_OPT_DEEPEN_NOT )) { opts->deepen_not = (const struct string_list *)value; +return 0 ; }else if (!strcmp (name,TRANS_OPT_DEEPEN_RELATIVE )) { opts->deepen_relative = !!value;return 0 ;
upload-pack.c +64 -43
186 lines not on this page · raw message
Nguyễn Thái Ngọc Duy (25):
remote-curl.c: convert fetch_git() to use argv_array transport-helper.c: refactor set_helper_option()
upload-pack: move shallow deepen code out of receive_needs()
upload-pack: move "shallow" sending code out of deepen()
upload-pack: remove unused variable "backup"
upload-pack: move "unshallow" sending code out of deepen()
upload-pack: use skip_prefix() instead of starts_with()
upload-pack: tighten number parsing at "deepen" lines
upload-pack: move rev-list code out of check_non_tip()
fetch-pack: use skip_prefix() instead of starts_with()
fetch-pack: use a common function for verbose printing
fetch-pack: use a separate flag for fetch in deepening mode shallow.c: implement a generic shallow boundary finder based on
rev-list
upload-pack: add deepen-since to cut shallow repos based on time
fetch: define shallow boundary with --shallow-since
clone: define shallow clone boundary based on time with
--shallow-since
t5500, t5539: tests for shallow depth since a specific date
refs: add expand_ref()
upload-pack: support define shallow boundary by excluding revisions
fetch: define shallow boundary with --shallow-exclude
clone: define shallow clone boundary with --shallow-exclude t5500, t5539: tests for shallow depth excluding a ref
upload-pack: split check_unreachable() in two, prep for
get_reachable_list()
upload-pack: add get_reachable_list()
fetch, upload-pack: --deepen=N extends shallow boundary by N commits
Documentation/fetch-options.txt | 14 + Documentation/git-clone.txt | 8 + Documentation/git-fetch-pack.txt | 14 + Documentation/gitremote-helpers.txt | 11 + Documentation/technical/pack-protocol.txt | 4 +- Documentation/technical/protocol-capabilities.txt | 25 ++ builtin/clone.c | 32 +- builtin/fetch-pack.c | 27 +- builtin/fetch.c | 58 +++- commit.h | 2 + fetch-pack.c | 128 ++++---- fetch-pack.h | 4 + object.h | 2 +- refs.c | 8 +- refs.h | 1 + remote-curl.c | 74 +++-- shallow.c | 77 +++++ t/t5500-fetch-pack.sh | 69 +++++ t/t5539-fetch-http-shallow.sh | 74 +++++ transport-helper.c | 62 +++- transport.c | 12 + transport.h | 14 + upload-pack.c | 338 ++++++++++++++++------ 23 files changed, 858 insertions(+), 200 deletions(-)
Signature · 1 line
2.7.1.532.gd9e3aaa