Merge branch 'jc/index-output'
authorJunio C Hamano <junkio@cox.net>
Sat, 7 Apr 2007 09:26:24 +0000 (02:26 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 7 Apr 2007 09:26:24 +0000 (02:26 -0700)
* jc/index-output:
git-read-tree --index-output=<file>
_GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file.

Conflicts:

builtin-apply.c

1  2 
builtin-add.c
builtin-apply.c
builtin-mv.c
builtin-update-index.c
cache.h
merge-recursive.c
diff --combined builtin-add.c
index 7d1d5dc2448ef3049de30fdba1f78c49506030db,54422d84a7f61fe2674555734f885872c7156c0b..9ec292590c49574dfd2a698772a406b5ccdc419e
@@@ -87,7 -87,7 +87,7 @@@ static void fill_directory(struct dir_s
        }
  
        /* Read the directory and prune it */
 -      read_directory(dir, path, base, baselen);
 +      read_directory(dir, path, base, baselen, pathspec);
        if (pathspec)
                prune_directory(dir, pathspec, baselen);
  }
@@@ -133,7 -133,7 +133,7 @@@ int cmd_add(int argc, const char **argv
  
        git_config(git_add_config);
  
-       newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);
+       newfd = hold_locked_index(&lock_file, 1);
  
        for (i = 1; i < argc; i++) {
                const char *arg = argv[i];
        }
  
        for (i = 0; i < dir.nr; i++)
 -              add_file_to_index(dir.entries[i]->name, verbose);
 +              add_file_to_cache(dir.entries[i]->name, verbose);
  
        if (active_cache_changed) {
                if (write_cache(newfd, active_cache, active_nr) ||
-                   close(newfd) || commit_lock_file(&lock_file))
+                   close(newfd) || commit_locked_index(&lock_file))
                        die("Unable to write new index file");
        }
  
diff --combined builtin-apply.c
index 4b8311b4de3f5c5d93352dac62856d67acfb143f,12011c1c9ef866c6c8dedc2df3f5b39034918c54..fd92ef7174dae1586921ebd34233c93b381106de
@@@ -30,7 -30,7 +30,7 @@@ static int unidiff_zero
  static int p_value = 1;
  static int p_value_known;
  static int check_index;
 -static int write_index;
 +static int update_index;
  static int cached;
  static int diffstat;
  static int numstat;
@@@ -417,7 -417,7 +417,7 @@@ static int gitdiff_hdrend(const char *l
  static char *gitdiff_verify_name(const char *line, int isnull, char *orig_name, const char *oldnew)
  {
        if (!orig_name && !isnull)
 -              return find_name(line, NULL, 1, TERM_TAB);
 +              return find_name(line, NULL, p_value, TERM_TAB);
  
        if (orig_name) {
                int len;
                len = strlen(name);
                if (isnull)
                        die("git-apply: bad git-diff - expected /dev/null, got %s on line %d", name, linenr);
 -              another = find_name(line, NULL, 1, TERM_TAB);
 +              another = find_name(line, NULL, p_value, TERM_TAB);
                if (!another || memcmp(another, name, len))
                        die("git-apply: bad git-diff - inconsistent %s filename on line %d", oldnew, linenr);
                free(another);
@@@ -2308,7 -2308,7 +2308,7 @@@ static void patch_stats(struct patch *p
  
  static void remove_file(struct patch *patch, int rmdir_empty)
  {
 -      if (write_index) {
 +      if (update_index) {
                if (remove_file_from_cache(patch->old_name) < 0)
                        die("unable to remove %s from index", patch->old_name);
                cache_tree_invalidate_path(active_cache_tree, patch->old_name);
@@@ -2335,7 -2335,7 +2335,7 @@@ static void add_index_file(const char *
        int namelen = strlen(path);
        unsigned ce_size = cache_entry_size(namelen);
  
 -      if (!write_index)
 +      if (!update_index)
                return;
  
        ce = xcalloc(1, ce_size);
@@@ -2662,10 -2662,10 +2662,10 @@@ static int apply_patch(int fd, const ch
        if (whitespace_error && (new_whitespace == error_on_whitespace))
                apply = 0;
  
 -      write_index = check_index && apply;
 -      if (write_index && newfd < 0)
 +      update_index = check_index && apply;
 +      if (update_index && newfd < 0)
-               newfd = hold_lock_file_for_update(&lock_file,
-                                                 get_index_file(), 1);
+               newfd = hold_locked_index(&lock_file, 1);
        if (check_index) {
                if (read_cache() < 0)
                        die("unable to read index file");
@@@ -2870,9 -2870,9 +2870,9 @@@ int cmd_apply(int argc, const char **ar
                                whitespace_error == 1 ? "s" : "");
        }
  
 -      if (write_index) {
 +      if (update_index) {
                if (write_cache(newfd, active_cache, active_nr) ||
-                   close(newfd) || commit_lock_file(&lock_file))
+                   close(newfd) || commit_locked_index(&lock_file))
                        die("Unable to write new index file");
        }
  
diff --combined builtin-mv.c
index c4ab4784cece771074c43580bf1874b92b11a249,820aca122e9603535e9f3393b861b91b14ecfe15..3563216acaebba668f465895fe0563e5d7113fef
@@@ -77,7 -77,7 +77,7 @@@ int cmd_mv(int argc, const char **argv
  
        git_config(git_default_config);
  
-       newfd = hold_lock_file_for_update(&lock_file, get_index_file(), 1);
+       newfd = hold_locked_index(&lock_file, 1);
        if (read_cache() < 0)
                die("index file corrupt");
  
  
                for (i = 0; i < added.nr; i++) {
                        const char *path = added.items[i].path;
 -                      add_file_to_index(path, verbose);
 +                      add_file_to_cache(path, verbose);
                }
  
                for (i = 0; i < deleted.nr; i++) {
                if (active_cache_changed) {
                        if (write_cache(newfd, active_cache, active_nr) ||
                            close(newfd) ||
-                           commit_lock_file(&lock_file))
+                           commit_locked_index(&lock_file))
                                die("Unable to write new index file");
                }
        }
diff --combined builtin-update-index.c
index d1e5cf753963b0cadc8f9ba55179a991cf759dae,84993d7c523debd598cf4ccb092e50f1fdac6976..47d42ed6450695b0502b58e6aca9dabeb96e5bf5
@@@ -60,7 -60,7 +60,7 @@@ static int mark_valid(const char *path
        return -1;
  }
  
 -static int add_file_to_cache(const char *path)
 +static int process_file(const char *path)
  {
        int size, namelen, option, status;
        struct cache_entry *ce;
@@@ -210,7 -210,7 +210,7 @@@ static void update_one(const char *path
                report("remove '%s'", path);
                goto free_return;
        }
 -      if (add_file_to_cache(p))
 +      if (process_file(p))
                die("Unable to process file %s", path);
        report("add '%s'", path);
   free_return:
@@@ -495,7 -495,7 +495,7 @@@ int cmd_update_index(int argc, const ch
        /* We can't free this memory, it becomes part of a linked list parsed atexit() */
        lock_file = xcalloc(1, sizeof(struct lock_file));
  
-       newfd = hold_lock_file_for_update(lock_file, get_index_file(), 0);
+       newfd = hold_locked_index(lock_file, 0);
        if (newfd < 0)
                lock_error = errno;
  
                            get_index_file(), strerror(lock_error));
                }
                if (write_cache(newfd, active_cache, active_nr) ||
-                   close(newfd) || commit_lock_file(lock_file))
+                   close(newfd) || commit_locked_index(lock_file))
                        die("Unable to write new index file");
        }
  
diff --combined cache.h
index ece0c041f5f4747b09bdf4300a74b5bc242a3dad,592331f70615b7ff66b9d26a947bb07878b44e82..1b50c32b139256c5d8be96a85b02f1ce9855f15a
+++ b/cache.h
@@@ -128,6 -128,7 +128,6 @@@ static inline unsigned int ce_mode_from
  extern struct cache_entry **active_cache;
  extern unsigned int active_nr, active_alloc, active_cache_changed;
  extern struct cache_tree *active_cache_tree;
 -extern int cache_errno;
  
  enum object_type {
        OBJ_BAD = -1,
@@@ -187,7 -188,7 +187,7 @@@ extern int add_cache_entry(struct cache
  extern struct cache_entry *refresh_cache_entry(struct cache_entry *ce, int really);
  extern int remove_cache_entry_at(int pos);
  extern int remove_file_from_cache(const char *path);
 -extern int add_file_to_index(const char *path, int verbose);
 +extern int add_file_to_cache(const char *path, int verbose);
  extern int ce_same_name(struct cache_entry *a, struct cache_entry *b);
  extern int ce_match_stat(struct cache_entry *ce, struct stat *st, int);
  extern int ce_modified(struct cache_entry *ce, struct stat *st, int);
@@@ -211,6 -212,11 +211,11 @@@ struct lock_file 
  };
  extern int hold_lock_file_for_update(struct lock_file *, const char *path, int);
  extern int commit_lock_file(struct lock_file *);
+ extern int hold_locked_index(struct lock_file *, int);
+ extern int commit_locked_index(struct lock_file *);
+ extern void set_alternate_index_output(const char *);
  extern void rollback_lock_file(struct lock_file *);
  extern int delete_ref(const char *, unsigned char *sha1);
  
@@@ -427,7 -433,7 +432,7 @@@ extern unsigned char* use_pack(struct p
  extern void unuse_pack(struct pack_window **);
  extern struct packed_git *add_packed_git(const char *, int, int);
  extern uint32_t num_packed_objects(const struct packed_git *p);
 -extern int nth_packed_object_sha1(const struct packed_git *, uint32_t, unsigned char*);
 +extern const unsigned char *nth_packed_object_sha1(const struct packed_git *, uint32_t);
  extern off_t find_pack_entry_one(const unsigned char *, struct packed_git *);
  extern void *unpack_entry(struct packed_git *, off_t, enum object_type *, unsigned long *);
  extern unsigned long unpack_object_header_gently(const unsigned char *buf, unsigned long len, enum object_type *type, unsigned long *sizep);
diff --combined merge-recursive.c
index 3611a2bdb7039f155287f2b706170f76cb6c5c2f,f46aaae858dcc9c613f630a7ba9c195d6d802dd1..2b614b64ba71f4006685ed1e08c300385ece5dec
@@@ -221,7 -221,7 +221,7 @@@ static int add_cacheinfo(unsigned int m
        struct cache_entry *ce;
        ce = make_cache_entry(mode, sha1 ? sha1 : null_sha1, path, stage, refresh);
        if (!ce)
 -              return error("cache_addinfo failed: %s", strerror(cache_errno));
 +              return error("addinfo_cache failed for path '%s'", path);
        return add_cache_entry(ce, options);
  }
  
@@@ -1378,7 -1378,7 +1378,7 @@@ int main(int argc, char *argv[]
        if (show(3))
                printf("Merging %s with %s\n", branch1, branch2);
  
-       index_fd = hold_lock_file_for_update(lock, get_index_file(), 1);
+       index_fd = hold_locked_index(lock, 1);
  
        for (i = 0; i < bases_count; i++) {
                struct commit *ancestor = get_ref(bases[i]);
  
        if (active_cache_changed &&
            (write_cache(index_fd, active_cache, active_nr) ||
-            close(index_fd) || commit_lock_file(lock)))
+            close(index_fd) || commit_locked_index(lock)))
                        die ("unable to write %s", get_index_file());
  
        return clean ? 0: 1;