Merge branch 'jl/submodule-fetch-on-demand'
authorJunio C Hamano <gitster@pobox.com>
Mon, 4 Apr 2011 22:02:01 +0000 (15:02 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 4 Apr 2011 22:02:01 +0000 (15:02 -0700)
* 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

1  2 
Documentation/config.txt
Documentation/git-fetch.txt
Documentation/git-pull.txt
Documentation/gitmodules.txt
builtin/fetch.c
git-pull.sh
git-submodule.sh
submodule.c
t/t5526-fetch-submodules.sh
t/t7406-submodule-update.sh

Simple merge
Simple merge
Simple merge
Simple merge
diff --cc builtin/fetch.c
index 6cbb5f69ecf0946f4028b88563347332d54f65bc,f60393607691957fa3978bcc4e1f0b5676a74609..f9c41da475289b84fe849f7641406ebc94059630
@@@ -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 git-pull.sh
Simple merge
Simple merge
diff --cc submodule.c
index 0cb6d1829944b8a6d0f1a7ed1c228b61c31c7e0d,88c7488a63bf2a3280cdc536609a1d2b15541d0c..5294cef641ef74ec525d8d747c82faf0bef7352a
@@@ -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,
Simple merge
Simple merge