Merge branch 'js/ignore-submodule'
authorJunio C Hamano <gitster@pobox.com>
Sun, 25 May 2008 20:37:08 +0000 (13:37 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sun, 25 May 2008 20:37:08 +0000 (13:37 -0700)
* js/ignore-submodule:
Ignore dirty submodule states during rebase and stash
Teach update-index about --ignore-submodules
diff options: Introduce --ignore-submodules

1  2 
cache.h
read-cache.c
diff --combined cache.h
index 8db19cc253dda9b63401f7b55ffbc0d333e216a8,b753b494979728b818f2c8a75af7aeab5ee73aee..ef330b4c6b71ebf5775b9fbb889ea635c7422c30
+++ b/cache.h
@@@ -388,6 -388,7 +388,7 @@@ extern void fill_stat_cache_info(struc
  #define REFRESH_UNMERGED      0x0002  /* allow unmerged */
  #define REFRESH_QUIET         0x0004  /* be quiet about it */
  #define REFRESH_IGNORE_MISSING        0x0008  /* ignore non-existent */
+ #define REFRESH_IGNORE_SUBMODULES     0x0008  /* ignore submodules */
  extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen);
  
  struct lock_file {
@@@ -521,7 -522,6 +522,7 @@@ extern void * read_sha1_file(const unsi
  extern int hash_sha1_file(const void *buf, unsigned long len, const char *type, unsigned char *sha1);
  extern int write_sha1_file(void *buf, unsigned long len, const char *type, unsigned char *return_sha1);
  extern int pretend_sha1_file(void *, unsigned long, enum object_type, unsigned char *);
 +extern int force_object_loose(const unsigned char *sha1, time_t mtime);
  
  extern int check_sha1_signature(const unsigned char *sha1, void *buf, unsigned long size, const char *type);
  
@@@ -783,13 -783,7 +784,13 @@@ extern int convert_to_git(const char *p
  extern int convert_to_working_tree(const char *path, const char *src, size_t len, struct strbuf *dst);
  
  /* add */
 -void add_files_to_cache(int verbose, const char *prefix, const char **pathspec);
 +#define ADD_FILES_VERBOSE     01
 +#define ADD_FILES_IGNORE_ERRORS       02
 +/*
 + * return 0 if success, 1 - if addition of a file failed and
 + * ADD_FILES_IGNORE_ERRORS was specified in flags
 + */
 +int add_files_to_cache(const char *prefix, const char **pathspec, int flags);
  
  /* diff.c */
  extern int diff_auto_refresh_index;
diff --combined read-cache.c
index 8b467f8f415b68db6e6ea83720ce6ae63dedb9e4,47dd2013fb937c6aaaf9fecd156c87f44fee4780..bc039819ee24083f13fee4558e51f16dee72a918
@@@ -470,7 -470,7 +470,7 @@@ int add_to_index(struct index_state *is
        unsigned ce_option = CE_MATCH_IGNORE_VALID|CE_MATCH_RACY_IS_DIRTY;
  
        if (!S_ISREG(st_mode) && !S_ISLNK(st_mode) && !S_ISDIR(st_mode))
 -              die("%s: can only add regular files, symbolic links or git-directories", path);
 +              return error("%s: can only add regular files, symbolic links or git-directories", path);
  
        namelen = strlen(path);
        if (S_ISDIR(st_mode)) {
                return 0;
        }
        if (index_path(ce->sha1, path, st, 1))
 -              die("unable to index file %s", path);
 +              return error("unable to index file %s", path);
        if (ignore_case && alias && different_name(ce, alias))
                ce = create_alias_ce(ce, alias);
        ce->ce_flags |= CE_ADDED;
        if (add_index_entry(istate, ce, ADD_CACHE_OK_TO_ADD|ADD_CACHE_OK_TO_REPLACE))
 -              die("unable to add %s to index",path);
 +              return error("unable to add %s to index",path);
        if (verbose)
                printf("add '%s'\n", path);
        return 0;
@@@ -942,6 -942,7 +942,7 @@@ int refresh_index(struct index_state *i
        int allow_unmerged = (flags & REFRESH_UNMERGED) != 0;
        int quiet = (flags & REFRESH_QUIET) != 0;
        int not_new = (flags & REFRESH_IGNORE_MISSING) != 0;
+       int ignore_submodules = (flags & REFRESH_IGNORE_SUBMODULES) != 0;
        unsigned int options = really ? CE_MATCH_IGNORE_VALID : 0;
  
        for (i = 0; i < istate->cache_nr; i++) {
                int cache_errno = 0;
  
                ce = istate->cache[i];
+               if (ignore_submodules && S_ISGITLINK(ce->ce_mode))
+                       continue;
                if (ce_stage(ce)) {
                        while ((i < istate->cache_nr) &&
                               ! strcmp(istate->cache[i]->name, ce->name))