]> git.ipfire.org Git - thirdparty/git.git/commitdiff
Merge branch 'jc/add-2.0-ignore-removal'
authorJunio C Hamano <gitster@pobox.com>
Fri, 7 Mar 2014 23:14:47 +0000 (15:14 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 7 Mar 2014 23:14:47 +0000 (15:14 -0800)
"git add <pathspec>" is the same as "git add -A <pathspec>" now,
i.e. it does not ignore removals from the directory specified.

1  2 
Documentation/git-add.txt
builtin/add.c

Simple merge
diff --cc builtin/add.c
index de79f35efcb7fff541557f6d0d02ed768c602fbf,22c5ff57964d4397a8e3cd14055722d1feb9e375..4b045bace12c1fa951785dc09c05a46b09cd9fc7
@@@ -26,10 -26,52 +26,8 @@@ static int take_worktree_changes
  struct update_callback_data {
        int flags;
        int add_errors;
-       /* only needed for 2.0 transition preparation */
-       int warn_add_would_remove;
 -      const char *implicit_dot;
 -      size_t implicit_dot_len;
  };
  
 -static const char *option_with_implicit_dot;
 -static const char *short_option_with_implicit_dot;
 -
 -static void warn_pathless_add(void)
 -{
 -      static int shown;
 -      assert(option_with_implicit_dot && short_option_with_implicit_dot);
 -
 -      if (shown)
 -              return;
 -      shown = 1;
 -
 -      /*
 -       * To be consistent with "git add -p" and most Git
 -       * commands, we should default to being tree-wide, but
 -       * this is not the original behavior and can't be
 -       * changed until users trained themselves not to type
 -       * "git add -u" or "git add -A". For now, we warn and
 -       * keep the old behavior. Later, the behavior can be changed
 -       * to tree-wide, keeping the warning for a while, and
 -       * eventually we can drop the warning.
 -       */
 -      warning(_("The behavior of 'git add %s (or %s)' with no path argument from a\n"
 -                "subdirectory of the tree will change in Git 2.0 and should not be used anymore.\n"
 -                "To add content for the whole tree, run:\n"
 -                "\n"
 -                "  git add %s :/\n"
 -                "  (or git add %s :/)\n"
 -                "\n"
 -                "To restrict the command to the current directory, run:\n"
 -                "\n"
 -                "  git add %s .\n"
 -                "  (or git add %s .)\n"
 -                "\n"
 -                "With the current Git version, the command is restricted to "
 -                "the current directory.\n"
 -                ""),
 -              option_with_implicit_dot, short_option_with_implicit_dot,
 -              option_with_implicit_dot, short_option_with_implicit_dot,
 -              option_with_implicit_dot, short_option_with_implicit_dot);
 -}
 -
  static int fix_unmerged_status(struct diff_filepair *p,
                               struct update_callback_data *data)
  {
@@@ -105,31 -141,28 +81,24 @@@ static void update_callback(struct diff
        }
  }
  
- static void update_files_in_cache(const char *prefix,
-                                 const struct pathspec *pathspec,
 -static void update_files_in_cache(const char *prefix, const char **pathspec,
--                                struct update_callback_data *data)
++int add_files_to_cache(const char *prefix,
++                     const struct pathspec *pathspec, int flags)
  {
++      struct update_callback_data data;
        struct rev_info rev;
  
++      memset(&data, 0, sizeof(data));
++      data.flags = flags;
++
        init_revisions(&rev, prefix);
        setup_revisions(0, NULL, &rev, NULL);
 -      init_pathspec(&rev.prune_data, pathspec);
 +      if (pathspec)
 +              copy_pathspec(&rev.prune_data, pathspec);
        rev.diffopt.output_format = DIFF_FORMAT_CALLBACK;
        rev.diffopt.format_callback = update_callback;
--      rev.diffopt.format_callback_data = data;
++      rev.diffopt.format_callback_data = &data;
        rev.max_count = 0; /* do not compare unmerged paths with stage #2 */
        run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
--}
--
- int add_files_to_cache(const char *prefix,
-                      const struct pathspec *pathspec, int flags)
 -int add_files_to_cache(const char *prefix, const char **pathspec, int flags)
--{
--      struct update_callback_data data;
--
--      memset(&data, 0, sizeof(data));
--      data.flags = flags;
--      update_files_in_cache(prefix, pathspec, &data);
        return !!data.add_errors;
  }
  
@@@ -338,7 -426,8 +307,6 @@@ int cmd_add(int argc, const char **argv
        int add_new_files;
        int require_pathspec;
        char *seen = NULL;
 -      int implicit_dot = 0;
--      struct update_callback_data update_data;
  
        git_config(add_config, NULL);
  
  
        if (!show_only && ignore_missing)
                die(_("Option --ignore-missing can only be used together with --dry-run"));
 -      if (addremove) {
 -              option_with_implicit_dot = "--all";
 -              short_option_with_implicit_dot = "-A";
 -      }
 -      if (take_worktree_changes) {
 -              option_with_implicit_dot = "--update";
 -              short_option_with_implicit_dot = "-u";
 -      }
 -      if (option_with_implicit_dot && !argc) {
 -              static const char *here[2] = { ".", NULL };
 +
-       if ((addremove || take_worktree_changes) && !argc) {
++      if ((0 < addremove_explicit || take_worktree_changes) && !argc) {
 +              static const char *whole[2] = { ":/", NULL };
                argc = 1;
 -              argv = here;
 -              implicit_dot = 1;
 +              argv = whole;
        }
  
        add_new_files = !take_worktree_changes && !refresh_only;
  
        plug_bulk_checkin();
  
-       update_data.flags = flags;
-       update_files_in_cache(prefix, &pathspec, &update_data);
 -      memset(&update_data, 0, sizeof(update_data));
 -      if ((flags & ADD_CACHE_IMPLICIT_DOT) && prefix) {
 -              /*
 -               * Check for modified files throughout the worktree so
 -               * update_callback has a chance to warn about changes
 -               * outside the cwd.
 -               */
 -              update_data.implicit_dot = prefix;
 -              update_data.implicit_dot_len = strlen(prefix);
 -              pathspec = NULL;
 -      }
 -      update_data.flags = flags & ~ADD_CACHE_IMPLICIT_DOT;
 -      update_files_in_cache(prefix, pathspec, &update_data);
++      exit_status |= add_files_to_cache(prefix, &pathspec, flags);
  
--      exit_status |= !!update_data.add_errors;
        if (add_new_files)
                exit_status |= add_files(&dir, flags);