From: Junio C Hamano Date: Sat, 20 May 2006 00:30:34 +0000 (-0700) Subject: Merge branch 'lt/dirwalk' into next X-Git-Tag: v1.4.1-rc1~82 X-Git-Url: https://www.git.lorimer.id.au/gitweb.git/diff_plain/bf78d1a6cb65fe877a8d90b9d4ec95678621ff17?hp=-c Merge branch 'lt/dirwalk' into next * lt/dirwalk: Add builtin "git rm" command Move pathspec matching from builtin-add.c into dir.c --- bf78d1a6cb65fe877a8d90b9d4ec95678621ff17 diff --combined Makefile index 5373986746,d4a91135c3..06b31d8a25 --- a/Makefile +++ b/Makefile @@@ -120,12 -120,12 +120,12 @@@ SCRIPT_SH = git-merge-one-file.sh git-parse-remote.sh \ git-prune.sh git-pull.sh git-rebase.sh \ git-repack.sh git-request-pull.sh git-reset.sh \ - git-resolve.sh git-revert.sh git-rm.sh git-sh-setup.sh \ + git-resolve.sh git-revert.sh git-sh-setup.sh \ git-tag.sh git-verify-tag.sh \ git-applymbox.sh git-applypatch.sh git-am.sh \ git-merge.sh git-merge-stupid.sh git-merge-octopus.sh \ git-merge-resolve.sh git-merge-ours.sh \ - git-lost-found.sh + git-lost-found.sh git-quiltimport.sh SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ @@@ -158,19 -158,20 +158,20 @@@ PROGRAMS = git-ls-files$X git-ls-tree$X git-mailinfo$X git-merge-base$X \ git-merge-index$X git-mktag$X git-mktree$X git-pack-objects$X git-patch-id$X \ git-peek-remote$X git-prune-packed$X git-read-tree$X \ - git-receive-pack$X git-rev-list$X git-rev-parse$X \ + git-receive-pack$X git-rev-parse$X \ git-send-pack$X git-show-branch$X git-shell$X \ git-show-index$X git-ssh-fetch$X \ git-ssh-upload$X git-tar-tree$X git-unpack-file$X \ git-unpack-objects$X git-update-index$X git-update-server-info$X \ git-upload-pack$X git-verify-pack$X git-write-tree$X \ - git-update-ref$X git-symbolic-ref$X git-check-ref-format$X \ + git-update-ref$X git-symbolic-ref$X \ git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \ git-describe$X git-merge-tree$X git-blame$X git-imap-send$X BUILT_INS = git-log$X git-whatchanged$X git-show$X \ git-count-objects$X git-diff$X git-push$X \ - git-grep$X git-add$X git-rev-list$X git-check-ref-format$X + git-grep$X git-add$X git-rm$X git-rev-list$X \ + git-check-ref-format$X # what 'all' will build and 'install' will install, in gitexecdir ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS) @@@ -207,7 -208,7 +208,7 @@@ DIFF_OBJS = diffcore-delta.o log-tree.o LIB_OBJS = \ - blob.o commit.o connect.o csum-file.o base85.o \ + blob.o commit.o connect.o csum-file.o cache-tree.o base85.o \ date.o diff-delta.o entry.o exec_cmd.o ident.o index.o \ object.o pack-check.o patch-delta.o path.o pkt-line.o \ quote.o read-cache.o refs.o run-command.o dir.o \ @@@ -218,7 -219,8 +219,8 @@@ BUILTIN_OBJS = \ builtin-log.o builtin-help.o builtin-count.o builtin-diff.o builtin-push.o \ - builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o + builtin-grep.o builtin-add.o builtin-rev-list.o builtin-check-ref-format.o \ + builtin-rm.o GITLIBS = $(LIB_FILE) $(XDIFF_LIB) LIBS = $(GITLIBS) -lz @@@ -610,9 -612,6 +612,9 @@@ test-date$X: test-date.c date.o ctype. test-delta$X: test-delta.c diff-delta.o patch-delta.o $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $^ +test-dump-cache-tree$X: dump-cache-tree.o $(GITLIBS) + $(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) $(LIBS) + check: for i in *.c; do sparse $(ALL_CFLAGS) $(SPARSE_FLAGS) $$i || exit; done @@@ -655,25 -654,6 +657,25 @@@ dist: git.spec git-tar-tre rpm: dist $(RPMBUILD) -ta $(GIT_TARNAME).tar.gz +htmldocs = git-htmldocs-$(GIT_VERSION) +manpages = git-manpages-$(GIT_VERSION) +dist-doc: + rm -fr .doc-tmp-dir + mkdir .doc-tmp-dir + $(MAKE) -C Documentation WEBDOC_DEST=../.doc-tmp-dir install-webdoc + cd .doc-tmp-dir && $(TAR) cf ../$(htmldocs).tar . + gzip -n -9 -f $(htmldocs).tar + : + rm -fr .doc-tmp-dir + mkdir .doc-tmp-dir .doc-tmp-dir/man1 .doc-tmp-dir/man7 + $(MAKE) -C Documentation DESTDIR=. \ + man1=../.doc-tmp-dir/man1 \ + man7=../.doc-tmp-dir/man7 \ + install + cd .doc-tmp-dir && $(TAR) cf ../$(manpages).tar . + gzip -n -9 -f $(manpages).tar + rm -fr .doc-tmp-dir + ### Cleaning rules clean: @@@ -681,9 -661,8 +683,9 @@@ $(LIB_FILE) $(XDIFF_LIB) rm -f $(ALL_PROGRAMS) $(BUILT_INS) git$X rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags - rm -rf $(GIT_TARNAME) + rm -rf $(GIT_TARNAME) .doc-tmp-dir rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz + rm -f $(htmldocs).tar $(manpages).tar $(MAKE) -C Documentation/ clean $(MAKE) -C templates clean $(MAKE) -C t/ clean diff --combined builtin-add.c index 2afb82d6c1,6166f66bce..02fe38b0c4 --- a/builtin-add.c +++ b/builtin-add.c @@@ -8,91 -8,10 +8,11 @@@ #include "cache.h" #include "builtin.h" #include "dir.h" +#include "cache-tree.h" static const char builtin_add_usage[] = "git-add [-n] [-v] ..."; - static int common_prefix(const char **pathspec) - { - const char *path, *slash, *next; - int prefix; - - if (!pathspec) - return 0; - - path = *pathspec; - slash = strrchr(path, '/'); - if (!slash) - return 0; - - prefix = slash - path + 1; - while ((next = *++pathspec) != NULL) { - int len = strlen(next); - if (len >= prefix && !memcmp(path, next, len)) - continue; - for (;;) { - if (!len) - return 0; - if (next[--len] != '/') - continue; - if (memcmp(path, next, len+1)) - continue; - prefix = len + 1; - break; - } - } - return prefix; - } - - static int match_one(const char *match, const char *name, int namelen) - { - int matchlen; - - /* If the match was just the prefix, we matched */ - matchlen = strlen(match); - if (!matchlen) - return 1; - - /* - * If we don't match the matchstring exactly, - * we need to match by fnmatch - */ - if (strncmp(match, name, matchlen)) - return !fnmatch(match, name, 0); - - /* - * If we did match the string exactly, we still - * need to make sure that it happened on a path - * component boundary (ie either the last character - * of the match was '/', or the next character of - * the name was '/' or the terminating NUL. - */ - return match[matchlen-1] == '/' || - name[matchlen] == '/' || - !name[matchlen]; - } - - static int match(const char **pathspec, const char *name, int namelen, int prefix, char *seen) - { - int retval; - const char *match; - - name += prefix; - namelen -= prefix; - - for (retval = 0; (match = *pathspec++) != NULL; seen++) { - if (retval & *seen) - continue; - match += prefix; - if (match_one(match, name, namelen)) { - retval = 1; - *seen = 1; - } - } - return retval; - } - static void prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) { char *seen; @@@ -108,7 -27,7 +28,7 @@@ i = dir->nr; while (--i >= 0) { struct dir_entry *entry = *src++; - if (!match(pathspec, entry->name, entry->len, prefix, seen)) { + if (!match_pathspec(pathspec, entry->name, entry->len, prefix, seen)) { free(entry); continue; } @@@ -198,7 -117,6 +118,7 @@@ static int add_file_to_index(const cha die("unable to add %s to index",path); if (verbose) printf("add '%s'\n", path); + cache_tree_invalidate_path(active_cache_tree, path); return 0; } diff --combined builtin.h index 78275ea451,c1cb765dea..d150c7ce56 --- a/builtin.h +++ b/builtin.h @@@ -20,13 -20,11 +20,14 @@@ extern int cmd_whatchanged(int argc, co extern int cmd_show(int argc, const char **argv, char **envp); extern int cmd_log(int argc, const char **argv, char **envp); extern int cmd_diff(int argc, const char **argv, char **envp); +extern int cmd_format_patch(int argc, const char **argv, char **envp); extern int cmd_count_objects(int argc, const char **argv, char **envp); extern int cmd_push(int argc, const char **argv, char **envp); extern int cmd_grep(int argc, const char **argv, char **envp); + extern int cmd_rm(int argc, const char **argv, char **envp); extern int cmd_add(int argc, const char **argv, char **envp); +extern int cmd_rev_list(int argc, const char **argv, char **envp); +extern int cmd_check_ref_format(int argc, const char **argv, char **envp); #endif diff --combined git.c index 7db5cc1a55,20c0f197a3..63aa311435 --- a/git.c +++ b/git.c @@@ -47,13 -47,11 +47,14 @@@ static void handle_internal_command(in { "whatchanged", cmd_whatchanged }, { "show", cmd_show }, { "push", cmd_push }, + { "fmt-patch", cmd_format_patch }, { "count-objects", cmd_count_objects }, { "diff", cmd_diff }, { "grep", cmd_grep }, + { "rm", cmd_rm }, { "add", cmd_add }, + { "rev-list", cmd_rev_list }, + { "check-ref-format", cmd_check_ref_format } }; int i;