From: Junio C Hamano Date: Mon, 4 Apr 2011 22:02:01 +0000 (-0700) Subject: Merge branch 'jl/submodule-fetch-on-demand' X-Git-Tag: v1.7.5-rc1~5 X-Git-Url: https://git.tokkee.org/?a=commitdiff_plain;h=2071fb015bc673d2514142d7614b56a37b3faaf2;p=git.git Merge branch 'jl/submodule-fetch-on-demand' * jl/submodule-fetch-on-demand: fetch/pull: Describe --recurse-submodule restrictions in the BUGS section submodule update: Don't fetch when the submodule commit is already present fetch/pull: Don't recurse into a submodule when commits are already present Submodules: Add 'on-demand' value for the 'fetchRecurseSubmodule' option config: teach the fetch.recurseSubmodules option the 'on-demand' value fetch/pull: Add the 'on-demand' value to the --recurse-submodules option fetch/pull: recurse into submodules when necessary Conflicts: builtin/fetch.c submodule.c --- 2071fb015bc673d2514142d7614b56a37b3faaf2 diff --cc builtin/fetch.c index 6cbb5f69e,f60393607..f9c41da47 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@@ -69,10 -78,13 +78,13 @@@ static struct option builtin_fetch_opti OPT_BOOLEAN('u', "update-head-ok", &update_head_ok, "allow updating of HEAD ref"), OPT_BOOLEAN(0, "progress", &progress, "force progress reporting"), - OPT_STRING(0, "depth", &depth, "DEPTH", + OPT_STRING(0, "depth", &depth, "depth", "deepen history of shallow clone"), - { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "DIR", + { OPTION_STRING, 0, "submodule-prefix", &submodule_prefix, "dir", "prepend this to submodule path output", PARSE_OPT_HIDDEN }, + { OPTION_STRING, 0, "recurse-submodules-default", + &recurse_submodules_default, NULL, + "default mode for recursion", PARSE_OPT_HIDDEN }, OPT_END() }; @@@ -283,7 -295,10 +295,10 @@@ static int update_local_ref(struct ref } else { msg = "storing head"; - what = "[new branch]"; + what = _("[new branch]"); + if ((recurse_submodules != RECURSE_SUBMODULES_OFF) && + (recurse_submodules != RECURSE_SUBMODULES_ON)) + check_for_new_submodule_commits(ref->new_sha1); } r = s_update_ref(msg, ref, 0); diff --cc submodule.c index 0cb6d1829,88c7488a6..5294cef64 --- a/submodule.c +++ b/submodule.c @@@ -9,10 -9,11 +9,11 @@@ #include "refs.h" #include "string-list.h" -struct string_list config_name_for_path; -struct string_list config_fetch_recurse_submodules_for_name; -struct string_list config_ignore_for_name; +static struct string_list config_name_for_path; +static struct string_list config_fetch_recurse_submodules_for_name; +static struct string_list config_ignore_for_name; - static int config_fetch_recurse_submodules; + static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND; -struct string_list changed_submodule_paths; ++static struct string_list changed_submodule_paths; static int add_submodule_odb(const char *path) { @@@ -152,60 -153,20 +153,74 @@@ void handle_ignore_submodules_arg(struc die("bad --ignore-submodules argument: %s", arg); } +static int prepare_submodule_summary(struct rev_info *rev, const char *path, + struct commit *left, struct commit *right, + int *fast_forward, int *fast_backward) +{ + struct commit_list *merge_bases, *list; + + init_revisions(rev, NULL); + setup_revisions(0, NULL, rev, NULL); + rev->left_right = 1; + rev->first_parent_only = 1; + left->object.flags |= SYMMETRIC_LEFT; + add_pending_object(rev, &left->object, path); + add_pending_object(rev, &right->object, path); + merge_bases = get_merge_bases(left, right, 1); + if (merge_bases) { + if (merge_bases->item == left) + *fast_forward = 1; + else if (merge_bases->item == right) + *fast_backward = 1; + } + for (list = merge_bases; list; list = list->next) { + list->item->object.flags |= UNINTERESTING; + add_pending_object(rev, &list->item->object, + sha1_to_hex(list->item->object.sha1)); + } + return prepare_revision_walk(rev); +} + +static void print_submodule_summary(struct rev_info *rev, FILE *f, + const char *del, const char *add, const char *reset) +{ + static const char format[] = " %m %s"; + struct strbuf sb = STRBUF_INIT; + struct commit *commit; + + while ((commit = get_revision(rev))) { + struct pretty_print_context ctx = {0}; + ctx.date_mode = rev->date_mode; + strbuf_setlen(&sb, 0); + if (commit->object.flags & SYMMETRIC_LEFT) { + if (del) + strbuf_addstr(&sb, del); + } + else if (add) + strbuf_addstr(&sb, add); + format_commit_message(commit, format, &sb, &ctx); + if (reset) + strbuf_addstr(&sb, reset); + strbuf_addch(&sb, '\n'); + fprintf(f, "%s", sb.buf); + } + strbuf_release(&sb); +} + + int parse_fetch_recurse_submodules_arg(const char *opt, const char *arg) + { + switch (git_config_maybe_bool(opt, arg)) { + case 1: + return RECURSE_SUBMODULES_ON; + case 0: + return RECURSE_SUBMODULES_OFF; + default: + if (!strcmp(arg, "on-demand")) + return RECURSE_SUBMODULES_ON_DEMAND; + die("bad %s argument: %s", opt, arg); + } + } + void show_submodule_summary(FILE *f, const char *path, unsigned char one[20], unsigned char two[20], unsigned dirty_submodule,