From: Junio C Hamano Date: Tue, 18 Sep 2007 07:42:01 +0000 (-0700) Subject: Merge branch 'cr/reset' X-Git-Tag: v1.5.4-rc0~434 X-Git-Url: https://git.lorimer.id.au/gitweb.git/diff_plain/9346b4e1ad2d03541f18b38f7e9fb7ad0ca6434e?ds=inline;hp=-c Merge branch 'cr/reset' * cr/reset: Simplify cache API An additional test for "git-reset -- path" Make "git reset" a builtin. Move make_cache_entry() from merge-recursive.c into read-cache.c Add tests for documented features of "git reset". --- 9346b4e1ad2d03541f18b38f7e9fb7ad0ca6434e diff --combined Makefile index 40567ece14,e6740fc392..0055eef24d --- a/Makefile +++ b/Makefile @@@ -124,9 -124,6 +124,9 @@@ all: # If not set it defaults to the bare 'wish'. If it is set to the empty # string then NO_TCLTK will be forced (this is used by configure script). # +# Define THREADED_DELTA_SEARCH if you have pthreads and wish to exploit +# parallel delta searching when packing objects. +# GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE @$(SHELL_PATH) ./GIT-VERSION-GEN @@@ -211,7 -208,7 +211,7 @@@ SCRIPT_SH = git-ls-remote.sh \ git-merge-one-file.sh git-mergetool.sh git-parse-remote.sh \ git-pull.sh git-rebase.sh git-rebase--interactive.sh \ - git-repack.sh git-request-pull.sh git-reset.sh \ + git-repack.sh git-request-pull.sh \ git-sh-setup.sh \ git-am.sh \ git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \ @@@ -358,6 -355,7 +358,7 @@@ BUILTIN_OBJS = builtin-reflog.o \ builtin-config.o \ builtin-rerere.o \ + builtin-reset.o \ builtin-rev-list.o \ builtin-rev-parse.o \ builtin-revert.o \ @@@ -678,11 -676,6 +679,11 @@@ ifdef NO_MEMME COMPAT_OBJS += compat/memmem.o endif +ifdef THREADED_DELTA_SEARCH + BASIC_CFLAGS += -DTHREADED_DELTA_SEARCH + EXTLIBS += -lpthread +endif + ifeq ($(TCLTK_PATH),) NO_TCLTK=NoThanks endif diff --combined builtin-add.c index 3d8b8b4f89,866d19dd77..0d7d0ce420 --- a/builtin-add.c +++ b/builtin-add.c @@@ -95,7 -95,7 +95,7 @@@ static void update_callback(struct diff const char *path = p->one->path; switch (p->status) { default: - die("unexpacted diff status %c", p->status); + die("unexpected diff status %c", p->status); case DIFF_STATUS_UNMERGED: case DIFF_STATUS_MODIFIED: case DIFF_STATUS_TYPE_CHANGED: @@@ -103,7 -103,6 +103,6 @@@ break; case DIFF_STATUS_DELETED: remove_file_from_cache(path); - cache_tree_invalidate_path(active_cache_tree, path); if (verbose) printf("remove '%s'\n", path); break; diff --combined builtin-apply.c index 5ad371424b,79a4852bc2..05ce2205f3 --- a/builtin-apply.c +++ b/builtin-apply.c @@@ -1642,22 -1642,15 +1642,22 @@@ static int apply_line(char *output, con buf = output; if (need_fix_leading_space) { + int consecutive_spaces = 0; /* between patch[1..last_tab_in_indent] strip the * funny spaces, updating them to tab as needed. */ for (i = 1; i < last_tab_in_indent; i++, plen--) { char ch = patch[i]; - if (ch != ' ') + if (ch != ' ') { + consecutive_spaces = 0; *output++ = ch; - else if ((i % 8) == 0) - *output++ = '\t'; + } else { + consecutive_spaces++; + if (consecutive_spaces == 8) { + *output++ = '\t'; + consecutive_spaces = 0; + } + } } fixed = 1; i = last_tab_in_indent; @@@ -2234,20 -2227,6 +2234,20 @@@ static int check_patch_list(struct patc return err; } +/* This function tries to read the sha1 from the current index */ +static int get_current_sha1(const char *path, unsigned char *sha1) +{ + int pos; + + if (read_cache() < 0) + return -1; + pos = cache_name_pos(path, strlen(path)); + if (pos < 0) + return -1; + hashcpy(sha1, active_cache[pos]->sha1); + return 0; +} + static void show_index_list(struct patch *list) { struct patch *patch; @@@ -2264,16 -2243,8 +2264,16 @@@ if (0 < patch->is_new) sha1_ptr = null_sha1; else if (get_sha1(patch->old_sha1_prefix, sha1)) - die("sha1 information is lacking or useless (%s).", - name); + /* git diff has no index line for mode/type changes */ + if (!patch->lines_added && !patch->lines_deleted) { + if (get_current_sha1(patch->new_name, sha1) || + get_current_sha1(patch->old_name, sha1)) + die("mode change for %s, which is not " + "in current HEAD", name); + sha1_ptr = sha1; + } else + die("sha1 information is lacking or useless " + "(%s).", name); else sha1_ptr = sha1; @@@ -2423,7 -2394,6 +2423,6 @@@ static void remove_file(struct patch *p 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); } if (!cached) { if (S_ISGITLINK(patch->old_mode)) { @@@ -2578,7 -2548,6 +2577,6 @@@ static void create_file(struct patch *p mode = S_IFREG | 0644; create_one_file(path, mode, buf, size); add_index_file(path, mode, buf, size); - cache_tree_invalidate_path(active_cache_tree, path); } /* phase zero is to remove, phase one is to create */