From: Junio C Hamano Date: Sat, 7 Apr 2007 09:26:24 +0000 (-0700) Subject: Merge branch 'jc/index-output' X-Git-Tag: v1.5.2-rc0~75 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/ee9693e246669f48f6b058a1044cefa973a44c22?ds=inline;hp=-c Merge branch 'jc/index-output' * jc/index-output: git-read-tree --index-output= _GIT_INDEX_OUTPUT: allow plumbing to output to an alternative index file. Conflicts: builtin-apply.c --- ee9693e246669f48f6b058a1044cefa973a44c22 diff --combined builtin-add.c index 7d1d5dc244,54422d84a7..9ec292590c --- a/builtin-add.c +++ b/builtin-add.c @@@ -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]; @@@ -205,11 -205,11 +205,11 @@@ } 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 4b8311b4de,12011c1c9e..fd92ef7174 --- a/builtin-apply.c +++ b/builtin-apply.c @@@ -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; @@@ -427,7 -427,7 +427,7 @@@ 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 c4ab4784ce,820aca122e..3563216aca --- a/builtin-mv.c +++ b/builtin-mv.c @@@ -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"); @@@ -273,7 -273,7 +273,7 @@@ 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++) { @@@ -285,7 -285,7 +285,7 @@@ 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 d1e5cf7539,84993d7c52..47d42ed645 --- a/builtin-update-index.c +++ b/builtin-update-index.c @@@ -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; @@@ -661,7 -661,7 +661,7 @@@ 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 ece0c041f5,592331f706..1b50c32b13 --- a/cache.h +++ 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 3611a2bdb7,f46aaae858..2b614b64ba --- a/merge-recursive.c +++ b/merge-recursive.c @@@ -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]); @@@ -1388,7 -1388,7 +1388,7 @@@ 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;