Merge branch 'bw/submodule-is-active'
authorJunio C Hamano <gitster@pobox.com>
Thu, 20 Apr 2017 04:37:18 +0000 (21:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Thu, 20 Apr 2017 04:37:18 +0000 (21:37 -0700)
Error message fix.

* bw/submodule-is-active:
submodule--helper: fix typo in is_active error message

1  2 
builtin/submodule--helper.c
index 6ee962207c4e38f3135f26ff8e0fdca98fa81fa1,404cef77d98e0471626ccbde027faaa9721bc8d9..36e4231821c0acbb6fe21948c752d4ee7c96405d
@@@ -619,7 -619,9 +619,7 @@@ static int module_clone(int argc, cons
        const char *name = NULL, *url = NULL, *depth = NULL;
        int quiet = 0;
        int progress = 0;
 -      FILE *submodule_dot_git;
        char *p, *path = NULL, *sm_gitdir;
 -      struct strbuf rel_path = STRBUF_INIT;
        struct strbuf sb = STRBUF_INIT;
        struct string_list reference = STRING_LIST_INIT_NODUP;
        char *sm_alternate = NULL, *error_strategy = NULL;
                strbuf_reset(&sb);
        }
  
 -      /* Write a .git file in the submodule to redirect to the superproject. */
 -      strbuf_addf(&sb, "%s/.git", path);
 -      if (safe_create_leading_directories_const(sb.buf) < 0)
 -              die(_("could not create leading directories of '%s'"), sb.buf);
 -      submodule_dot_git = fopen(sb.buf, "w");
 -      if (!submodule_dot_git)
 -              die_errno(_("cannot open file '%s'"), sb.buf);
 -
 -      fprintf_or_die(submodule_dot_git, "gitdir: %s\n",
 -                     relative_path(sm_gitdir, path, &rel_path));
 -      if (fclose(submodule_dot_git))
 -              die(_("could not close file %s"), sb.buf);
 -      strbuf_reset(&sb);
 -      strbuf_reset(&rel_path);
 +      /* Connect module worktree and git dir */
 +      connect_work_tree_and_git_dir(path, sm_gitdir);
  
 -      /* Redirect the worktree of the submodule in the superproject's config */
        p = git_pathdup_submodule(path, "config");
        if (!p)
                die(_("could not get submodule directory for '%s'"), path);
 -      git_config_set_in_file(p, "core.worktree",
 -                             relative_path(path, sm_gitdir, &rel_path));
  
        /* setup alternateLocation and alternateErrorStrategy in the cloned submodule if needed */
        git_config_get_string("submodule.alternateLocation", &sm_alternate);
        free(error_strategy);
  
        strbuf_release(&sb);
 -      strbuf_release(&rel_path);
        free(sm_gitdir);
        free(path);
        free(p);
@@@ -1105,50 -1123,6 +1105,50 @@@ static int resolve_remote_submodule_bra
        return 0;
  }
  
 +static int push_check(int argc, const char **argv, const char *prefix)
 +{
 +      struct remote *remote;
 +
 +      if (argc < 2)
 +              die("submodule--helper push-check requires at least 1 argument");
 +
 +      /*
 +       * The remote must be configured.
 +       * This is to avoid pushing to the exact same URL as the parent.
 +       */
 +      remote = pushremote_get(argv[1]);
 +      if (!remote || remote->origin == REMOTE_UNCONFIGURED)
 +              die("remote '%s' not configured", argv[1]);
 +
 +      /* Check the refspec */
 +      if (argc > 2) {
 +              int i, refspec_nr = argc - 2;
 +              struct ref *local_refs = get_local_heads();
 +              struct refspec *refspec = parse_push_refspec(refspec_nr,
 +                                                           argv + 2);
 +
 +              for (i = 0; i < refspec_nr; i++) {
 +                      struct refspec *rs = refspec + i;
 +
 +                      if (rs->pattern || rs->matching)
 +                              continue;
 +
 +                      /*
 +                       * LHS must match a single ref
 +                       * NEEDSWORK: add logic to special case 'HEAD' once
 +                       * working with submodules in a detached head state
 +                       * ceases to be the norm.
 +                       */
 +                      if (count_refspec_match(rs->src, local_refs, NULL) != 1)
 +                              die("src refspec '%s' must name a ref",
 +                                  rs->src);
 +              }
 +              free_refspec(refspec_nr, refspec);
 +      }
 +
 +      return 0;
 +}
 +
  static int absorb_git_dirs(int argc, const char **argv, const char *prefix)
  {
        int i;
  static int is_active(int argc, const char **argv, const char *prefix)
  {
        if (argc != 2)
-               die("submodule--helper is-active takes exactly 1 arguments");
+               die("submodule--helper is-active takes exactly 1 argument");
  
        gitmodules_config();
  
@@@ -1214,7 -1188,6 +1214,7 @@@ static struct cmd_struct commands[] = 
        {"resolve-relative-url-test", resolve_relative_url_test, 0},
        {"init", module_init, SUPPORT_SUPER_PREFIX},
        {"remote-branch", resolve_remote_submodule_branch, 0},
 +      {"push-check", push_check, 0},
        {"absorb-git-dirs", absorb_git_dirs, SUPPORT_SUPER_PREFIX},
        {"is-active", is_active, 0},
  };