From: Junio C Hamano Date: Fri, 7 Mar 2014 23:14:01 +0000 (-0800) Subject: Merge branch 'jn/add-2.0-u-A-sans-pathspec' X-Git-Tag: v2.0.0-rc0~141 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/053a6b18074e12876d60da952d8a668631b21a64?ds=inline;hp=--cc Merge branch 'jn/add-2.0-u-A-sans-pathspec' "git add -u" and "git add -A" without any pathspec is a tree-wide operation now, even when they are run in a subdirectory of the working tree. --- 053a6b18074e12876d60da952d8a668631b21a64 diff --cc builtin/add.c index 672adc01ff,61f3cb49ff..de79f35efc --- a/builtin/add.c +++ b/builtin/add.c @@@ -194,35 -130,26 +133,23 @@@ int add_files_to_cache(const char *pref return !!data.add_errors; } - #define WARN_IMPLICIT_DOT (1u << 0) - static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, - int prefix, unsigned flag) -static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) ++static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, int prefix) { char *seen; - int i, specs; + int i; struct dir_entry **src, **dst; - for (specs = 0; pathspec[specs]; specs++) - /* nothing */; - seen = xcalloc(specs, 1); + seen = xcalloc(pathspec->nr, 1); src = dst = dir->entries; i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; - if (match_pathspec(pathspec, entry->name, entry->len, - prefix, seen)) + if (dir_path_match(entry, pathspec, prefix, seen)) *dst++ = entry; - else if (flag & WARN_IMPLICIT_DOT) - /* - * "git add -A" was run from a subdirectory with a - * new file outside that directory. - * - * "git add -A" will behave like "git add -A :/" - * instead of "git add -A ." in the future. - * Warn about the coming behavior change. - */ - warn_pathless_add(); } dir->nr = dst - dir->entries; - add_pathspec_matches_against_index(pathspec, seen, specs); + add_pathspec_matches_against_index(pathspec, seen); return seen; } @@@ -511,22 -459,18 +428,19 @@@ int cmd_add(int argc, const char **argv setup_standard_excludes(&dir); } + memset(&empty_pathspec, 0, sizeof(empty_pathspec)); /* This picks up the paths that are not tracked */ - baselen = fill_directory(&dir, implicit_dot ? &empty_pathspec : &pathspec); - baselen = fill_directory(&dir, pathspec); - if (pathspec) - seen = prune_directory(&dir, pathspec, baselen); ++ baselen = fill_directory(&dir, &pathspec); + if (pathspec.nr) - seen = prune_directory(&dir, &pathspec, baselen, - implicit_dot ? WARN_IMPLICIT_DOT : 0); ++ seen = prune_directory(&dir, &pathspec, baselen); } if (refresh_only) { - refresh(verbose, pathspec); + refresh(verbose, &pathspec); goto finish; } - if (implicit_dot && prefix) - refresh_cache(REFRESH_QUIET); - if (pathspec) { + if (pathspec.nr) { int i; if (!seen) @@@ -564,19 -492,8 +478,8 @@@ plug_bulk_checkin(); - 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); - free_pathspec(&pathspec); - memset(&pathspec, 0, sizeof(pathspec)); - } - update_data.flags = flags & ~ADD_CACHE_IMPLICIT_DOT; + update_data.flags = flags; - update_files_in_cache(prefix, pathspec, &update_data); + update_files_in_cache(prefix, &pathspec, &update_data); exit_status |= !!update_data.add_errors; if (add_new_files) diff --cc cache.h index b7d82e5d52,99acf80d2f..4c0043113c --- a/cache.h +++ b/cache.h @@@ -483,12 -466,10 +483,11 @@@ extern int remove_file_from_index(struc #define ADD_CACHE_IGNORE_ERRORS 4 #define ADD_CACHE_IGNORE_REMOVAL 8 #define ADD_CACHE_INTENT 16 - #define ADD_CACHE_IMPLICIT_DOT 32 /* internal to "git add -u/-A" */ extern int add_to_index(struct index_state *, const char *path, struct stat *, int flags); extern int add_file_to_index(struct index_state *, const char *path, int flags); -extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, int refresh); -extern int ce_same_name(struct cache_entry *a, struct cache_entry *b); +extern struct cache_entry *make_cache_entry(unsigned int mode, const unsigned char *sha1, const char *path, int stage, unsigned int refresh_options); +extern int ce_same_name(const struct cache_entry *a, const struct cache_entry *b); +extern void set_object_name_for_intent_to_add_entry(struct cache_entry *ce); extern int index_name_is_other(const struct index_state *, const char *, int); extern void *read_blob_data_from_index(struct index_state *, const char *, unsigned long *);