Merge branch 'lt/dirwalk' into next
authorJunio C Hamano <junkio@cox.net>
Sat, 20 May 2006 00:30:34 +0000 (17:30 -0700)
committerJunio C Hamano <junkio@cox.net>
Sat, 20 May 2006 00:30:34 +0000 (17:30 -0700)
* lt/dirwalk:
Add builtin "git rm" command
Move pathspec matching from builtin-add.c into dir.c

1  2 
Makefile
builtin-add.c
builtin.h
git.c
diff --combined Makefile
index 53739867465186777e2fb3baa6c4b70975a2ce1d,d4a91135c33a49fcb2bd5da3f5653d72a32673a7..06b31d8a25e449b16670b5c54c83357d389252dd
+++ 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 \
  
  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:
                $(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 2afb82d6c1d745694f8457415e13f4f67b86ca19,6166f66bceb006b5ffc3834d4d77e253c7b7992e..02fe38b0c4c7c61bcc51544d1fd54c0b1641e2e8
@@@ -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] <filepattern>...";
  
- 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;
        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 78275ea45124c1f4972288b5b02f6bc18745b1fe,c1cb765deac0b83735a053cfaeb7fd41044d7ae1..d150c7ce5624e7ece666d6a639fb8e59aa018bed
+++ 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 7db5cc1a5544b1c5c96fff8e9a28cc3cf5382f32,20c0f197a355299600898a1e9ca3e20dceb14645..63aa31143563323f1318e26ce4fa9f298473c47f
--- 1/git.c
--- 2/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;