Sync with 1.7.6.3
authorJunio C Hamano <gitster@pobox.com>
Mon, 12 Sep 2011 17:43:17 +0000 (10:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 12 Sep 2011 17:43:17 +0000 (10:43 -0700)
Signed-off-by: Junio C Hamano <gitster@pobox.com>
1  2 
Documentation/git.txt
submodule.c
diff --combined Documentation/git.txt
index 651e155d1de0dc7251e6592e867141d9ce841723,3562da85e9edf091a49742ae0ac1ec426a7244f9..4ae21a3cc7b6b60cec80e78361b2070c3d33e336
@@@ -10,8 -10,8 +10,8 @@@ SYNOPSI
  --------
  [verse]
  'git' [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]
 -    [-p|--paginate|--no-pager] [--no-replace-objects]
 -    [--bare] [--git-dir=<path>] [--work-tree=<path>]
 +    [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]
 +    [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]
      [-c <name>=<value>]
      [--help] <command> [<args>]
  
@@@ -44,9 -44,10 +44,10 @@@ unreleased) version of git, that is ava
  branch of the `git.git` repository.
  Documentation for older releases are available here:
  
- * link:v1.7.6.2/git.html[documentation for release 1.7.6.2]
+ * link:v1.7.6.3/git.html[documentation for release 1.7.6.3]
  
  * release notes for
+   link:RelNotes/1.7.6.3.txt[1.7.6.3],
    link:RelNotes/1.7.6.2.txt[1.7.6.2],
    link:RelNotes/1.7.6.1.txt[1.7.6.1],
    link:RelNotes/1.7.6.txt[1.7.6].
@@@ -332,11 -333,6 +333,11 @@@ help ...`
        variable (see core.worktree in linkgit:git-config[1] for a
        more detailed discussion).
  
 +--namespace=<path>::
 +      Set the git namespace.  See linkgit:gitnamespaces[7] for more
 +      details.  Equivalent to setting the `GIT_NAMESPACE` environment
 +      variable.
 +
  --bare::
        Treat the repository as a bare repository.  If GIT_DIR
        environment is not set, it is set to the current working
@@@ -600,10 -596,6 +601,10 @@@ git so take care if using Cogito etc
        This can also be controlled by the '--work-tree' command line
        option and the core.worktree configuration variable.
  
 +'GIT_NAMESPACE'::
 +      Set the git namespace; see linkgit:gitnamespaces[7] for details.
 +      The '--namespace' command-line option also sets this value.
 +
  'GIT_CEILING_DIRECTORIES'::
        This should be a colon-separated list of absolute paths.
        If set, it is a list of directories that git should not chdir
diff --combined submodule.c
index 7a76edf911d941722586abb4f38284fc4e6909ec,b648927509cc4a1a663b981557f1529564121645..ad86534ba1e1e1726fd6427c65182ba954957904
@@@ -32,7 -32,7 +32,7 @@@ static int add_submodule_odb(const cha
        const char *git_dir;
  
        strbuf_addf(&objects_directory, "%s/.git", path);
 -      git_dir = read_gitfile_gently(objects_directory.buf);
 +      git_dir = read_gitfile(objects_directory.buf);
        if (git_dir) {
                strbuf_reset(&objects_directory);
                strbuf_addstr(&objects_directory, git_dir);
@@@ -308,114 -308,6 +308,114 @@@ void set_config_fetch_recurse_submodule
        config_fetch_recurse_submodules = value;
  }
  
 +static int has_remote(const char *refname, const unsigned char *sha1, int flags, void *cb_data)
 +{
 +      return 1;
 +}
 +
 +static int submodule_needs_pushing(const char *path, const unsigned char sha1[20])
 +{
 +      if (add_submodule_odb(path) || !lookup_commit_reference(sha1))
 +              return 0;
 +
 +      if (for_each_remote_ref_submodule(path, has_remote, NULL) > 0) {
 +              struct child_process cp;
 +              const char *argv[] = {"rev-list", NULL, "--not", "--remotes", "-n", "1" , NULL};
 +              struct strbuf buf = STRBUF_INIT;
 +              int needs_pushing = 0;
 +
 +              argv[1] = sha1_to_hex(sha1);
 +              memset(&cp, 0, sizeof(cp));
 +              cp.argv = argv;
 +              cp.env = local_repo_env;
 +              cp.git_cmd = 1;
 +              cp.no_stdin = 1;
 +              cp.out = -1;
 +              cp.dir = path;
 +              if (start_command(&cp))
 +                      die("Could not run 'git rev-list %s --not --remotes -n 1' command in submodule %s",
 +                              sha1_to_hex(sha1), path);
 +              if (strbuf_read(&buf, cp.out, 41))
 +                      needs_pushing = 1;
 +              finish_command(&cp);
 +              close(cp.out);
 +              strbuf_release(&buf);
 +              return needs_pushing;
 +      }
 +
 +      return 0;
 +}
 +
 +static void collect_submodules_from_diff(struct diff_queue_struct *q,
 +                                       struct diff_options *options,
 +                                       void *data)
 +{
 +      int i;
 +      int *needs_pushing = data;
 +
 +      for (i = 0; i < q->nr; i++) {
 +              struct diff_filepair *p = q->queue[i];
 +              if (!S_ISGITLINK(p->two->mode))
 +                      continue;
 +              if (submodule_needs_pushing(p->two->path, p->two->sha1)) {
 +                      *needs_pushing = 1;
 +                      break;
 +              }
 +      }
 +}
 +
 +
 +static void commit_need_pushing(struct commit *commit, struct commit_list *parent, int *needs_pushing)
 +{
 +      const unsigned char (*parents)[20];
 +      unsigned int i, n;
 +      struct rev_info rev;
 +
 +      n = commit_list_count(parent);
 +      parents = xmalloc(n * sizeof(*parents));
 +
 +      for (i = 0; i < n; i++) {
 +              hashcpy((unsigned char *)(parents + i), parent->item->object.sha1);
 +              parent = parent->next;
 +      }
 +
 +      init_revisions(&rev, NULL);
 +      rev.diffopt.output_format |= DIFF_FORMAT_CALLBACK;
 +      rev.diffopt.format_callback = collect_submodules_from_diff;
 +      rev.diffopt.format_callback_data = needs_pushing;
 +      diff_tree_combined(commit->object.sha1, parents, n, 1, &rev);
 +
 +      free(parents);
 +}
 +
 +int check_submodule_needs_pushing(unsigned char new_sha1[20], const char *remotes_name)
 +{
 +      struct rev_info rev;
 +      struct commit *commit;
 +      const char *argv[] = {NULL, NULL, "--not", "NULL", NULL};
 +      int argc = ARRAY_SIZE(argv) - 1;
 +      char *sha1_copy;
 +      int needs_pushing = 0;
 +      struct strbuf remotes_arg = STRBUF_INIT;
 +
 +      strbuf_addf(&remotes_arg, "--remotes=%s", remotes_name);
 +      init_revisions(&rev, NULL);
 +      sha1_copy = xstrdup(sha1_to_hex(new_sha1));
 +      argv[1] = sha1_copy;
 +      argv[3] = remotes_arg.buf;
 +      setup_revisions(argc, argv, &rev, NULL);
 +      if (prepare_revision_walk(&rev))
 +              die("revision walk setup failed");
 +
 +      while ((commit = get_revision(&rev)) && !needs_pushing)
 +              commit_need_pushing(commit, commit->parents, &needs_pushing);
 +
 +      free(sha1_copy);
 +      strbuf_release(&remotes_arg);
 +
 +      return needs_pushing;
 +}
 +
  static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
  {
        int is_present = 0;
@@@ -481,6 -373,10 +481,10 @@@ void check_for_new_submodule_commits(un
        const char *argv[] = {NULL, NULL, "--not", "--all", NULL};
        int argc = ARRAY_SIZE(argv) - 1;
  
+       /* No need to check if there are no submodules configured */
+       if (!config_name_for_path.nr)
+               return;
        init_revisions(&rev, NULL);
        argv[1] = xstrdup(sha1_to_hex(new_sha1));
        setup_revisions(argc, argv, &rev, NULL);
@@@ -587,7 -483,7 +591,7 @@@ int fetch_populated_submodules(int num_
                strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
                strbuf_addf(&submodule_git_dir, "%s/.git", submodule_path.buf);
                strbuf_addf(&submodule_prefix, "%s%s/", prefix, ce->name);
 -              git_dir = read_gitfile_gently(submodule_git_dir.buf);
 +              git_dir = read_gitfile(submodule_git_dir.buf);
                if (!git_dir)
                        git_dir = submodule_git_dir.buf;
                if (is_directory(git_dir)) {
@@@ -625,7 -521,7 +629,7 @@@ unsigned is_submodule_modified(const ch
        const char *git_dir;
  
        strbuf_addf(&buf, "%s/.git", path);
 -      git_dir = read_gitfile_gently(buf.buf);
 +      git_dir = read_gitfile(buf.buf);
        if (!git_dir)
                git_dir = buf.buf;
        if (!is_directory(git_dir)) {