Merge branch 'master' into next
authorJunio C Hamano <junkio@cox.net>
Sat, 18 Mar 2006 22:58:20 +0000 (14:58 -0800)
committerJunio C Hamano <junkio@cox.net>
Sat, 18 Mar 2006 22:58:20 +0000 (14:58 -0800)
* master:
  Makefile: Add TAGS and tags targets
  ls-files: Don't require exclude files to end with a newline.

1  2 
Makefile
ls-files.c

diff --combined Makefile
+++ b/Makefile
@@@ -190,7 -190,7 +190,7 @@@ PYMODULES = 
  LIB_FILE=libgit.a
  
  LIB_H = \
 -      blob.h cache.h commit.h count-delta.h csum-file.h delta.h \
 +      blob.h cache.h commit.h csum-file.h delta.h \
        diff.h object.h pack.h pkt-line.h quote.h refs.h \
        run-command.h strbuf.h tag.h tree.h git-compat-util.h revision.h
  
@@@ -200,7 -200,7 +200,7 @@@ DIFF_OBJS = 
        diffcore-delta.o
  
  LIB_OBJS = \
 -      blob.o commit.o connect.o count-delta.o csum-file.o \
 +      blob.o commit.o connect.o csum-file.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 \
@@@ -553,6 -553,13 +553,13 @@@ $(LIB_FILE): $(LIB_OBJS
  doc:
        $(MAKE) -C Documentation all
  
+ TAGS:
+       rm -f TAGS
+       find . -name '*.[hcS]' -print | xargs etags -a
+ tags:
+       rm -f tags
+       find . -name '*.[hcS]' -print | xargs ctags -a
  
  ### Testing rules
  
@@@ -617,7 -624,7 +624,7 @@@ rpm: dis
  clean:
        rm -f *.o mozilla-sha1/*.o arm/*.o ppc/*.o compat/*.o $(LIB_FILE)
        rm -f $(ALL_PROGRAMS) git$X
-       rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h
+       rm -f *.spec *.pyc *.pyo */*.pyc */*.pyo common-cmds.h TAGS tags
        rm -rf $(GIT_TARNAME)
        rm -f $(GIT_TARNAME).tar.gz git-core_$(GIT_VERSION)-*.tar.gz
        $(MAKE) -C Documentation/ clean
        rm -f GIT-VERSION-FILE
  
  .PHONY: all install clean strip
- .PHONY: .FORCE-GIT-VERSION-FILE
+ .PHONY: .FORCE-GIT-VERSION-FILE TAGS tags
  
diff --combined ls-files.c
@@@ -11,7 -11,6 +11,7 @@@
  #include "cache.h"
  #include "quote.h"
  
 +static int abbrev = 0;
  static int show_deleted = 0;
  static int show_cached = 0;
  static int show_others = 0;
@@@ -93,11 -92,12 +93,12 @@@ static int add_excludes_from_file_1(con
                close(fd);
                return 0;
        }
-       buf = xmalloc(size);
+       buf = xmalloc(size+1);
        if (read(fd, buf, size) != size)
                goto err;
        close(fd);
  
+       buf[size++] = '\n';
        entry = buf;
        for (i = 0; i < size; i++) {
                if (buf[i] == '\n') {
@@@ -489,8 -489,7 +490,8 @@@ static void show_ce_entry(const char *t
                printf("%s%06o %s %d\t",
                       tag,
                       ntohl(ce->ce_mode),
 -                     sha1_to_hex(ce->sha1),
 +                     abbrev ? find_unique_abbrev(ce->sha1,abbrev)
 +                              : sha1_to_hex(ce->sha1),
                       ce_stage(ce));
                write_name_quoted("", 0, ce->name + offset,
                                  line_terminator, stdout);
@@@ -631,8 -630,7 +632,8 @@@ static void verify_pathspec(void
  static const char ls_files_usage[] =
        "git-ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
        "[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
 -      "[ --exclude-per-directory=<filename> ] [--full-name] [--] [<file>]*";
 +      "[ --exclude-per-directory=<filename> ] [--full-name] [--abbrev] "
 +      "[--] [<file>]*";
  
  int main(int argc, const char **argv)
  {
                        error_unmatch = 1;
                        continue;
                }
 +              if (!strncmp(arg, "--abbrev=", 9)) {
 +                      abbrev = strtoul(arg+9, NULL, 10);
 +                      if (abbrev && abbrev < MINIMUM_ABBREV)
 +                              abbrev = MINIMUM_ABBREV;
 +                      else if (abbrev > 40)
 +                              abbrev = 40;
 +                      continue;
 +              }
 +              if (!strcmp(arg, "--abbrev")) {
 +                      abbrev = DEFAULT_ABBREV;
 +                      continue;
 +              }
                if (*arg == '-')
                        usage(ls_files_usage);
                break;