Merge branch 'jc/maint-add-sync-stat' into maint
authorJunio C Hamano <gitster@pobox.com>
Sun, 25 Nov 2007 02:03:04 +0000 (18:03 -0800)
committerJunio C Hamano <gitster@pobox.com>
Sun, 25 Nov 2007 02:03:04 +0000 (18:03 -0800)
* jc/maint-add-sync-stat:
t2200: test more cases of "add -u"
git-add: make the entry stat-clean after re-adding the same contents
ce_match_stat, run_diff_files: use symbolic constants for readability

1  2 
builtin-add.c
cache.h
diff --combined builtin-add.c
index 850e1c23e545e8f84e5a72ea7a7bdd1a99746938,e072320d20df64e2db062009c60cb488235076a4..4fc9d6f7ccdd7b989d75ae6e24df997c4deb3505
@@@ -17,6 -17,7 +17,6 @@@ static const char builtin_add_usage[] 
  "git-add [-n] [-v] [-f] [--interactive | -i] [-u] [--refresh] [--] <filepattern>...";
  
  static int take_worktree_changes;
 -static const char *excludes_file;
  
  static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix)
  {
@@@ -56,7 -57,12 +56,7 @@@ static void fill_directory(struct dir_s
        memset(dir, 0, sizeof(*dir));
        if (!ignored_too) {
                dir->collect_ignored = 1;
 -              dir->exclude_per_dir = ".gitignore";
 -              path = git_path("info/exclude");
 -              if (!access(path, R_OK))
 -                      add_excludes_from_file(dir, path);
 -              if (excludes_file != NULL && !access(excludes_file, R_OK))
 -                      add_excludes_from_file(dir, excludes_file);
 +              setup_standard_excludes(dir);
        }
  
        /*
@@@ -117,7 -123,7 +117,7 @@@ static void update(int verbose, const c
        rev.diffopt.format_callback_data = &verbose;
        if (read_cache() < 0)
                die("index file corrupt");
-       run_diff_files(&rev, 0);
+       run_diff_files(&rev, DIFF_RACY_IS_MODIFIED);
  }
  
  static void refresh(int verbose, const char **pathspec)
          free(seen);
  }
  
 -static int git_add_config(const char *var, const char *value)
 -{
 -      if (!strcmp(var, "core.excludesfile")) {
 -              if (!value)
 -                      die("core.excludesfile without value");
 -              excludes_file = xstrdup(value);
 -              return 0;
 -      }
 -
 -      return git_default_config(var, value);
 -}
 -
  static struct lock_file lock_file;
  
  static const char ignore_error[] =
@@@ -165,7 -183,7 +165,7 @@@ int cmd_add(int argc, const char **argv
                exit(1);
        }
  
 -      git_config(git_add_config);
 +      git_config(git_default_config);
  
        newfd = hold_locked_index(&lock_file, 1);
  
diff --combined cache.h
index 60af6d35794beb67dd7165668677cfbca9334f30,31af16a7eee5e151dbcff320dca094b9c9ff17b8..c9954d78084588a1541cb45861eb9dbce9a6b7a6
+++ b/cache.h
@@@ -6,7 -6,7 +6,7 @@@
  #include SHA1_HEADER
  #include <zlib.h>
  
 -#if ZLIB_VERNUM < 0x1200
 +#if defined(NO_DEFLATE_BOUND) || ZLIB_VERNUM < 0x1200
  #define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
  #endif
  
@@@ -174,8 -174,8 +174,8 @@@ extern struct index_state the_index
  #define remove_file_from_cache(path) remove_file_from_index(&the_index, (path))
  #define add_file_to_cache(path, verbose) add_file_to_index(&the_index, (path), (verbose))
  #define refresh_cache(flags) refresh_index(&the_index, (flags), NULL, NULL)
- #define ce_match_stat(ce, st, really) ie_match_stat(&the_index, (ce), (st), (really))
- #define ce_modified(ce, st, really) ie_modified(&the_index, (ce), (st), (really))
+ #define ce_match_stat(ce, st, options) ie_match_stat(&the_index, (ce), (st), (options))
+ #define ce_modified(ce, st, options) ie_modified(&the_index, (ce), (st), (options))
  #endif
  
  enum object_type {
@@@ -266,8 -266,14 +266,14 @@@ extern int remove_file_from_index(struc
  extern int add_file_to_index(struct index_state *, const char *path, int verbose);
  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 int ie_match_stat(struct index_state *, struct cache_entry *, struct stat *, int);
- extern int ie_modified(struct index_state *, struct cache_entry *, struct stat *, int);
+ /* do stat comparison even if CE_VALID is true */
+ #define CE_MATCH_IGNORE_VALID         01
+ /* do not check the contents but report dirty on racily-clean entries */
+ #define CE_MATCH_RACY_IS_DIRTY        02
+ extern int ie_match_stat(struct index_state *, struct cache_entry *, struct stat *, unsigned int);
+ extern int ie_modified(struct index_state *, struct cache_entry *, struct stat *, unsigned int);
  extern int ce_path_match(const struct cache_entry *ce, const char **pathspec);
  extern int index_fd(unsigned char *sha1, int fd, struct stat *st, int write_object, enum object_type type, const char *path);
  extern int read_fd(int fd, char **return_buf, unsigned long *return_size);
@@@ -571,7 -577,6 +577,7 @@@ extern int pager_in_use
  extern int pager_use_color;
  
  extern char *editor_program;
 +extern char *excludes_file;
  
  /* base85 */
  int decode_85(char *dst, const char *line, int linelen);