Merge branch 'pj/portable' into next
authorJunio C Hamano <junkio@cox.net>
Tue, 21 Feb 2006 09:07:57 +0000 (01:07 -0800)
committerJunio C Hamano <junkio@cox.net>
Tue, 21 Feb 2006 09:07:57 +0000 (01:07 -0800)
* pj/portable:
  Makefile tweaks: Solaris 9+ dont need iconv / move up uname variables
  Merge part of jc/portable branch
  git-mktree: reverse of git-ls-tree.
  Merge branch 'lt/merge-tree'
  Merge branch 'jc/ident'
  cherry-pick/revert: error-help message rewording.
  Fix fmt-merge-msg counting.

Makefile
git-fmt-merge-msg.perl
git-revert.sh
mktree.c [new file with mode: 0644]

index 4e654f0..8473281 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -77,6 +77,12 @@ GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
        @$(SHELL_PATH) ./GIT-VERSION-GEN
 -include GIT-VERSION-FILE
 
+uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
+uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
+uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
+uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
+uname_P := $(shell sh -c 'uname -p 2>/dev/null || echo not')
+
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
 CFLAGS = -g -O2 -Wall
@@ -87,7 +93,7 @@ STRIP ?= strip
 
 prefix = $(HOME)
 bindir = $(prefix)/bin
-gitexecdir = $(prefix)/bin
+gitexecdir = $(bindir)
 template_dir = $(prefix)/share/git-core/templates/
 GIT_PYTHON_DIR = $(prefix)/share/git-core/python
 # DESTDIR=
@@ -147,9 +153,9 @@ PROGRAMS = \
        git-convert-objects$X git-diff-files$X \
        git-diff-index$X git-diff-stages$X \
        git-diff-tree$X git-fetch-pack$X git-fsck-objects$X \
-       git-hash-object$X git-index-pack$X git-init-db$X git-local-fetch$X \
-       git-ls-files$X git-ls-tree$X git-mailinfo$X git-merge-base$X \
-       git-merge-index$X git-mktag$X git-pack-objects$X git-patch-id$X \
+       git-hash-object$X git-index-pack$X git-init-db$X \
+       git-local-fetch$X git-ls-files$X git-ls-tree$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-send-pack$X git-show-branch$X git-shell$X \
@@ -212,10 +218,6 @@ LIBS += -lz
 # We choose to avoid "if .. else if .. else .. endif endif"
 # because maintaining the nesting to match is a pain.  If
 # we had "elif" things would have been much nicer...
-uname_S := $(shell sh -c 'uname -s 2>/dev/null || echo not')
-uname_M := $(shell sh -c 'uname -m 2>/dev/null || echo not')
-uname_O := $(shell sh -c 'uname -o 2>/dev/null || echo not')
-uname_R := $(shell sh -c 'uname -r 2>/dev/null || echo not')
 
 ifeq ($(uname_S),Darwin)
        NEEDS_SSL_WITH_CRYPTO = YesPlease
@@ -230,10 +232,10 @@ endif
 ifeq ($(uname_S),SunOS)
        NEEDS_SOCKET = YesPlease
        NEEDS_NSL = YesPlease
-       NEEDS_LIBICONV = YesPlease
        SHELL_PATH = /bin/bash
        NO_STRCASESTR = YesPlease
        ifeq ($(uname_R),5.8)
+               NEEDS_LIBICONV = YesPlease
                NO_UNSETENV = YesPlease
                NO_SETENV = YesPlease
        endif
index a77e94e..c13af48 100755 (executable)
@@ -60,12 +60,12 @@ sub current_branch {
 }
 
 sub shortlog {
-       my ($tip, $limit) = @_;
+       my ($tip) = @_;
        my ($fh, @result);
        my $pid = open($fh, '-|');
        die "$!" unless defined $pid;
        if (!$pid) {
-           exec('git-log', "--max-count=$limit", '--topo-order',
+           exec('git-log', '--topo-order',
                 '--pretty=oneline', $tip, '^HEAD') or die "$!";
        }
        while (<$fh>) {
@@ -168,7 +168,7 @@ my $limit = 20;
 
 for (@origin) {
        my ($sha1, $name) = @$_;
-       my @log = shortlog($sha1, $limit + 1);
+       my @log = shortlog($sha1);
        if ($limit + 1 <= @log) {
                print "\n* $name: (" . scalar(@log) . " commits)\n";
        }
index 2c58706..c19d3a6 100755 (executable)
@@ -141,8 +141,9 @@ git-read-tree -m -u $base $head $next &&
 result=$(git-write-tree 2>/dev/null) || {
     echo >&2 "Simple $me fails; trying Automatic $me."
     git-merge-index -o git-merge-one-file -a || {
-           echo >&2 "Automatic $me failed.  After fixing it up,"
-           echo >&2 "you can use \"git commit -F .msg\""
+           echo >&2 "Automatic $me failed.  After resolving the conflicts,"
+           echo >&2 "mark the corrected paths with 'git-update-index <paths>'"
+           echo >&2 "and commit with 'git commit -F .msg'"
            case "$me" in
            cherry-pick)
                echo >&2 "You may choose to use the following when making"
diff --git a/mktree.c b/mktree.c
new file mode 100644 (file)
index 0000000..f853585
--- /dev/null
+++ b/mktree.c
@@ -0,0 +1,137 @@
+/*
+ * GIT - the stupid content tracker
+ *
+ * Copyright (c) Junio C Hamano, 2006
+ */
+#include "cache.h"
+#include "strbuf.h"
+#include "quote.h"
+
+static struct treeent {
+       unsigned mode;
+       unsigned char sha1[20];
+       int len;
+       char name[FLEX_ARRAY];
+} **entries;
+static int alloc, used;
+
+static void append_to_tree(unsigned mode, unsigned char *sha1, char *path)
+{
+       struct treeent *ent;
+       int len = strlen(path);
+       if (strchr(path, '/'))
+               die("path %s contains slash", path);
+
+       if (alloc <= used) {
+               alloc = alloc_nr(used);
+               entries = xrealloc(entries, sizeof(*entries) * alloc);
+       }
+       ent = entries[used++] = xmalloc(sizeof(**entries) + len + 1);
+       ent->mode = mode;
+       ent->len = len;
+       memcpy(ent->sha1, sha1, 20);
+       memcpy(ent->name, path, len+1);
+}
+
+static int ent_compare(const void *a_, const void *b_)
+{
+       struct treeent *a = *(struct treeent **)a_;
+       struct treeent *b = *(struct treeent **)b_;
+       return base_name_compare(a->name, a->len, a->mode,
+                                b->name, b->len, b->mode);
+}
+
+static void write_tree(unsigned char *sha1)
+{
+       char *buffer;
+       unsigned long size, offset;
+       int i;
+
+       qsort(entries, used, sizeof(*entries), ent_compare);
+       size = 100;
+       for (size = i = 0; i < used; i++)
+               size += 32 + entries[i]->len;
+       buffer = xmalloc(size);
+       offset = 0;
+
+       for (i = 0; i < used; i++) {
+               struct treeent *ent = entries[i];
+
+               if (offset + ent->len + 100 < size) {
+                       size = alloc_nr(offset + ent->len + 100);
+                       buffer = xrealloc(buffer, size);
+               }
+               offset += sprintf(buffer + offset, "%o ", ent->mode);
+               offset += sprintf(buffer + offset, "%s", ent->name);
+               buffer[offset++] = 0;
+               memcpy(buffer + offset, ent->sha1, 20);
+               offset += 20;
+       }
+       write_sha1_file(buffer, offset, "tree", sha1);
+}
+
+static const char mktree_usage[] = "mktree [-z]";
+
+int main(int ac, char **av)
+{
+       struct strbuf sb;
+       unsigned char sha1[20];
+       int line_termination = '\n';
+
+       setup_git_directory();
+
+       while ((1 < ac) && av[1][0] == '-') {
+               char *arg = av[1];
+               if (!strcmp("-z", arg))
+                       line_termination = 0;
+               else
+                       usage(mktree_usage);
+               ac--;
+               av++;
+       }
+
+       strbuf_init(&sb);
+       while (1) {
+               int len;
+               char *ptr, *ntr;
+               unsigned mode;
+               char type[20];
+               char *path;
+
+               read_line(&sb, stdin, line_termination);
+               if (sb.eof)
+                       break;
+               len = sb.len;
+               ptr = sb.buf;
+               /* Input is non-recursive ls-tree output format
+                * mode SP type SP sha1 TAB name
+                */
+               mode = strtoul(ptr, &ntr, 8);
+               if (ptr == ntr || !ntr || *ntr != ' ')
+                       die("input format error: %s", sb.buf);
+               ptr = ntr + 1; /* type */
+               ntr = strchr(ptr, ' ');
+               if (!ntr || sb.buf + len <= ntr + 41 ||
+                   ntr[41] != '\t' ||
+                   get_sha1_hex(ntr + 1, sha1))
+                       die("input format error: %s", sb.buf);
+               if (sha1_object_info(sha1, type, NULL))
+                       die("object %s unavailable", sha1_to_hex(sha1));
+               *ntr++ = 0; /* now at the beginning of SHA1 */
+               if (strcmp(ptr, type))
+                       die("object type %s mismatch (%s)", ptr, type);
+               ntr += 41; /* at the beginning of name */
+               if (line_termination && ntr[0] == '"')
+                       path = unquote_c_style(ntr, NULL);
+               else
+                       path = ntr;
+
+               append_to_tree(mode, sha1, path);
+
+               if (path != ntr)
+                       free(path);
+       }
+       write_tree(sha1);
+       puts(sha1_to_hex(sha1));
+       exit(0);
+}