]> git.ipfire.org Git - thirdparty/git.git/commitdiff
GIT 1.1.4 v1.1.4
authorJunio C Hamano <junkio@cox.net>
Fri, 20 Jan 2006 03:56:27 +0000 (19:56 -0800)
committerJunio C Hamano <junkio@cox.net>
Fri, 20 Jan 2006 03:56:27 +0000 (19:56 -0800)
37 files changed:
.gitignore
Documentation/fetch-options.txt
Documentation/git-clone.txt
Documentation/git-daemon.txt
Documentation/git-describe.txt [new file with mode: 0644]
Documentation/git-rev-parse.txt
Documentation/git.txt
Documentation/tutorial.txt
GIT-VERSION-GEN [new file with mode: 0755]
Makefile
cache.h
commit.c
commit.h
connect.c
daemon.c
describe.c [new file with mode: 0644]
environment.c
git-checkout.sh
git-cherry.sh
git-clone.sh
git-fetch.sh
git-merge-recursive.py
git-status.sh
git-whatchanged.sh
init-db.c
ls-files.c
ls-tree.c
pack-redundant.c
receive-pack.c
rev-parse.c
send-pack.c
setup.c
sha1_file.c
t/t3000-ls-files-others.sh
t/t3401-rebase-partial.sh [new file with mode: 0755]
t/t3500-cherry.sh [new file with mode: 0755]
t/t6022-merge-rename.sh

index dbbef06c0a3e521f24c3a67240389ed0b4a5f572..5382e742719be2ca7285898d70d9bf0fd367c247 100644 (file)
@@ -1,3 +1,4 @@
+GIT-VERSION-FILE
 git
 git-add
 git-am
@@ -27,6 +28,7 @@ git-diff-files
 git-diff-index
 git-diff-stages
 git-diff-tree
+git-describe
 git-fetch
 git-fetch-pack
 git-findtags
index 200c9b240dc3f89cd29350332447e48b53bcfdc1..1fe8423b94739e16f2ad8ec4b07ed45a2e6b964a 100644 (file)
        fetches is a descendant of `<lbranch>`.  This option
        overrides that check.
 
+\--no-tags::
+       By default, `git-fetch` fetches tags that point at
+       objects that are downloaded from the remote repository
+       and stores them locally.  This option disables this
+       automatic tag following.
+
 -t, \--tags::
-       By default, the git core utilities will not fetch and store
-       tags under the same name as the remote repository;  ask it
-       to do so using `--tags`.  Using this option will bound the
-       list of objects pulled to the remote tags.  Commits in branches
-       beyond the tags will be ignored.
+       Most of the tags are fetched automatically as branch
+       heads are downloaded, but tags that do not point at
+       objects reachable from the branch heads that are being
+       tracked will not be fetched by this mechanism.  This
+       flag lets all tags and their associated objects be
+       downloaded.
 
 -u, \--update-head-ok::
        By default `git-fetch` refuses to update the head which
        corresponds to the current branch.  This flag disables the
        check.  Note that fetching into the current branch will not
        update the index and working directory, so use it with care.
+
index ffa4fb0a03b54526743178e71b9956e50c8d298d..790b87b231d46d6e9de9d85024b25b49ee225488 100644 (file)
@@ -9,7 +9,7 @@ git-clone - Clones a repository.
 SYNOPSIS
 --------
 [verse]
-'git-clone' [-l [-s]] [-q] [-n] [-u <upload-pack>]
+'git-clone' [-l [-s]] [-q] [-n] [-o <name>] [-u <upload-pack>]
          <repository> [<directory>]
 
 DESCRIPTION
@@ -58,6 +58,13 @@ OPTIONS
 -n::
        No checkout of HEAD is performed after the clone is complete.
 
+-o <name>::
+       Instead of using the branch name 'origin' to keep track
+       of the upstream repository, use <name> instead.  Note
+       that the shorthand name stored in `remotes/origin` is
+       not affected, but the local branch name to pull the
+       remote `master` branch into is.
+
 --upload-pack <upload-pack>::
 -u <upload-pack>::
        When given, and the repository to clone from is handled
index 33f3320e287bc7eddd1a353b4468338b8f85e356..a20e0533fcfc1ed2c9940021ab65ef2967f16856 100644 (file)
@@ -9,7 +9,8 @@ SYNOPSIS
 --------
 [verse]
 'git-daemon' [--verbose] [--syslog] [--inetd | --port=n] [--export-all]
-           [--timeout=n] [--init-timeout=n] [--strict-paths] [directory...]
+             [--timeout=n] [--init-timeout=n] [--strict-paths]
+             [--base-path=path] [directory...]
 
 DESCRIPTION
 -----------
@@ -36,6 +37,14 @@ OPTIONS
        git-daemon will refuse to start when this option is enabled and no
        whitelist is specified.
 
+--base-path::
+       Remap all the path requests as relative to the given path.
+       This is sort of "GIT root" - if you run git-daemon with
+       '--base-path=/srv/git' on example.com, then if you later try to pull
+       'git://example.com/hello.git', `git-daemon` will interpret the path
+       as '/srv/git/hello.git'. Home directories (the '~login' notation)
+       access is disabled.
+
 --export-all::
        Allow pulling from all directories that look like GIT repositories
        (have the 'objects' and 'refs' subdirectories), even if they
diff --git a/Documentation/git-describe.txt b/Documentation/git-describe.txt
new file mode 100644 (file)
index 0000000..0efe82a
--- /dev/null
@@ -0,0 +1,79 @@
+git-describe(1)
+===============
+
+NAME
+----
+git-describe - Show the most recent tag that is reachable from a commit.
+
+
+SYNOPSIS
+--------
+'git-describe' [--all] [--tags] [--abbrev=<n>] <committish>...
+
+DESCRIPTION
+-----------
+The command finds the most recent tag that is reachable from a
+commit, and if the commit itself is pointed at by the tag, shows
+the tag.  Otherwise, it suffixes the tag name with abbreviated
+object name of the commit.
+
+
+OPTIONS
+-------
+<committish>::
+       The object name of the comittish. 
+
+--all::
+       Instead of using only the annotated tags, use any ref
+       found in `.git/refs/`.
+
+--tags::
+       Instead of using only the annotated tags, use any tag
+       found in `.git/refs/tags`.
+
+--abbrev=<n>::
+       Instead of using the default 8 hexadecimal digits as the
+       abbreviated object name, use <n> digits.
+
+
+EXAMPLES
+--------
+
+With something like git.git current tree, I get:
+
+       [torvalds@g5 git]$ git-describe parent
+       v1.0.4-g2414721b
+
+i.e. the current head of my "parent" branch is based on v1.0.4,
+but since it has a few commits on top of that, it has added the
+git hash of the thing to the end: "-g" + 8-char shorthand for
+the commit `2414721b194453f058079d897d13c4e377f92dc6`.
+
+Doing a "git-describe" on a tag-name will just show the tag name:
+
+       [torvalds@g5 git]$ git-describe v1.0.4
+       v1.0.4
+
+With --all, the command can use branch heads as references, so
+the output shows the reference path as well:
+
+       [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
+       tags/v1.0.0-g975b
+
+       [torvalds@g5 git]$ git describe --all HEAD^
+       heads/lt/describe-g975b
+
+
+Author
+------
+Written by Linus Torvalds <torvalds@osdl.org>, but somewhat
+butchered by Junio C Hamano <junkio@cox.net>
+
+Documentation
+--------------
+Documentation by David Greaves, Junio C Hamano and the git-list <git@vger.kernel.org>.
+
+GIT
+---
+Part of the gitlink:git[7] suite
+
index 431b8f6e06194e302aac02fdf90522e6f5c04167..d638bfc202ef9ad0386d640cbf70b9cdb2fff665 100644 (file)
@@ -68,10 +68,15 @@ OPTIONS
        Show all refs found in `$GIT_DIR/refs`.
 
 --show-prefix::
-       When the command is invoked from a directory show the
+       When the command is invoked from a subdirectory, show the
        path of the current directory relative to the top-level
        directory.
 
+--show-cdup::
+       When the command is invoked from a subdirectory, show the
+       path of the top-level directory relative to the current
+       directory (typically a sequence of "../", or an empty string).
+
 --since=datestring, --after=datestring::
        Parses the date string, and outputs corresponding
        --max-age= parameter for git-rev-list command.
index 875d4877667d8d7cc92eca7af319a29e029221d1..92cfe0ee31a3ce6fc85ac4041ae9bb17e6419a8d 100644 (file)
@@ -139,6 +139,9 @@ Interrogation commands
 gitlink:git-cat-file[1]::
        Provide content or type/size information for repository objects.
 
+gitlink:git-describe[1]::
+       Show the most recent tag that is reachable from a commit.
+
 gitlink:git-diff-index[1]::
        Compares content and mode of blobs between the index and repository.
 
index 3a5c56e24edfe7a970e6dcd346f8c0a346cdbfd8..edd91cbbe42bec1ee406dd95d82832575d89d3a6 100644 (file)
@@ -1695,6 +1695,24 @@ You still need to create UNIX user accounts for each developer,
 and put them in the same group.  Make sure that the repository
 shared among these developers is writable by that group.
 
+. Initializing the shared repository with `git-init-db --shared`
+helps somewhat.
+
+. Run the following in the shared repository:
++
+------------
+$ chgrp -R $group repo.git
+$ find repo.git -type d -print | xargs chmod ug+rwx,g+s
+$ GIT_DIR=repo.git git repo-config core.sharedrepository true
+------------
+
+The above measures make sure that directories lazily created in
+`$GIT_DIR` are writable by group members.  You, as the
+repository administrator, are still responsible to make sure
+your developers belong to that shared repository group and set
+their umask to a value no stricter than 027 (i.e. at least allow
+reading and searching by group members).
+
 You can implement finer grained branch policies using update
 hooks.  There is a document ("control access to branches") in
 Documentation/howto by Carl Baldwin and JC outlining how to (1)
diff --git a/GIT-VERSION-GEN b/GIT-VERSION-GEN
new file mode 100755 (executable)
index 0000000..73aaff0
--- /dev/null
@@ -0,0 +1,33 @@
+#!/bin/sh
+
+GVF=GIT-VERSION-FILE
+DEF_VER=v1.1.GIT
+
+# First try git-describe, then see if there is a version file
+# (included in release tarballs), then default
+VN=$(git-describe --abbrev=4 HEAD 2>/dev/null) ||
+VN=$(cat version) ||
+VN="$DEF_VER"
+
+VN=$(expr "$VN" : v*'\(.*\)')
+
+dirty=$(sh -c 'git-diff-index --name-only HEAD' 2>/dev/null) || dirty=
+case "$dirty" in
+'')
+       ;;
+*)
+       VN="$VN-dirty" ;;
+esac
+
+if test -r $GVF
+then
+       VC=$(sed -e 's/^GIT_VERSION = //' <$GVF)
+else
+       VC=unset
+fi
+test "$VN" = "$VC" || {
+       echo >&2 "GIT_VERSION = $VN"
+       echo "GIT_VERSION = $VN" >$GVF
+}
+
+
index 538d21d808b7ccc287e7bdd947f1583eadcda28b..fa0cd8315fcc855e84b8c409f88d5e1a910e8ef4 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -55,7 +55,9 @@ all:
 # Define USE_STDEV below if you want git to care about the underlying device
 # change being considered an inode change from the update-cache perspective.
 
-GIT_VERSION = 1.0.12
+GIT-VERSION-FILE: .FORCE-GIT-VERSION-FILE
+       @sh ./GIT-VERSION-GEN
+-include GIT-VERSION-FILE
 
 # CFLAGS and LDFLAGS are for the users to override from the command line.
 
@@ -135,7 +137,8 @@ PROGRAMS = \
        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-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X
+       git-name-rev$X git-pack-redundant$X git-repo-config$X git-var$X \
+       git-describe$X
 
 # what 'all' will build and 'install' will install.
 ALL_PROGRAMS = $(PROGRAMS) $(SIMPLE_PROGRAMS) $(SCRIPTS) git$X
@@ -368,7 +371,7 @@ all: $(ALL_PROGRAMS)
 all:
        $(MAKE) -C templates
 
-git$X: git.c $(LIB_FILE) Makefile
+git$X: git.c $(LIB_FILE)
        $(CC) -DGIT_EXEC_PATH='"$(bindir)"' -DGIT_VERSION='"$(GIT_VERSION)"' \
                $(CFLAGS) $(COMPAT_CFLAGS) -o $@ $(filter %.c,$^) $(LIB_FILE)
 
@@ -397,8 +400,12 @@ $(patsubst %.py,%,$(SCRIPT_PYTHON)) : % : %.py
 git-cherry-pick: git-revert
        cp $< $@
 
-# format-patch records GIT_VERSION
-git-format-patch: Makefile
+# These can record GIT_VERSION
+git$X git.spec \
+       $(patsubst %.sh,%,$(SCRIPT_SH)) \
+       $(patsubst %.perl,%,$(SCRIPT_PERL)) \
+       $(patsubst %.py,%,$(SCRIPT_PYTHON)) \
+       : GIT-VERSION-FILE
 
 %.o: %.c
        $(CC) -o $*.o -c $(ALL_CFLAGS) $<
@@ -474,7 +481,7 @@ install-doc:
 
 ### Maintainer's dist rules
 
-git.spec: git.spec.in Makefile
+git.spec: git.spec.in
        sed -e 's/@@VERSION@@/$(GIT_VERSION)/g' < $< > $@
 
 GIT_TARNAME=git-$(GIT_VERSION)
@@ -482,7 +489,9 @@ dist: git.spec git-tar-tree
        ./git-tar-tree HEAD $(GIT_TARNAME) > $(GIT_TARNAME).tar
        @mkdir -p $(GIT_TARNAME)
        @cp git.spec $(GIT_TARNAME)
-       $(TAR) rf $(GIT_TARNAME).tar $(GIT_TARNAME)/git.spec
+       @echo $(GIT_VERSION) > $(GIT_TARNAME)/version
+       $(TAR) rf $(GIT_TARNAME).tar \
+               $(GIT_TARNAME)/git.spec $(GIT_TARNAME)/version
        @rm -rf $(GIT_TARNAME)
        gzip -f -9 $(GIT_TARNAME).tar
 
@@ -501,4 +510,8 @@ clean:
        $(MAKE) -C Documentation/ clean
        $(MAKE) -C templates clean
        $(MAKE) -C t/ clean
+       rm -f GIT-VERSION-FILE
+
+.PHONY: all install clean
+.PHONY: .FORCE-GIT-VERSION-FILE
 
diff --git a/cache.h b/cache.h
index 5fd2687636026c2000b2f39e383af00b45c3627c..29c9e819d61ccb93167d5f22c8280f75014872f9 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -159,6 +159,7 @@ extern void rollback_index_file(struct cache_file *);
 extern int trust_executable_bit;
 extern int only_use_symrefs;
 extern int diff_rename_limit_default;
+extern int shared_repository;
 
 #define GIT_REPO_VERSION 0
 extern int repository_format_version;
@@ -183,6 +184,7 @@ extern const unsigned char null_sha1[20];
 
 int git_mkstemp(char *path, size_t n, const char *template);
 
+int adjust_shared_perm(const char *path);
 int safe_create_leading_directories(char *path);
 char *safe_strncpy(char *, const char *, size_t);
 char *enter_repo(char *path, int strict);
index fb02ba609b00d48a8e0e4c127cdc292a438bf9f3..b8bf35e86081a638137c49e9eabb18c466dec1e5 100644 (file)
--- a/commit.c
+++ b/commit.c
@@ -352,6 +352,21 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
        return ret;
 }
 
+void clear_commit_marks(struct commit *commit, unsigned int mark)
+{
+       struct commit_list *parents;
+
+       parents = commit->parents;
+       commit->object.flags &= ~mark;
+       while (parents) {
+               struct commit *parent = parents->item;
+               if (parent && parent->object.parsed &&
+                   (parent->object.flags & mark))
+                       clear_commit_marks(parent, mark);
+               parents = parents->next;
+       }
+}
+
 /*
  * Generic support for pretty-printing the header
  */
index 6738a696d7d7861188873cf7f7279bc8c19545d5..9c4a244bd90cd96a461a6d6774106b0e6a11fe1e 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -58,6 +58,8 @@ struct commit *pop_most_recent_commit(struct commit_list **list,
 
 struct commit *pop_commit(struct commit_list **stack);
 
+void clear_commit_marks(struct commit *commit, unsigned int mark);
+
 int count_parents(struct commit * commit);
 
 /*
index 93f6f80d3e8c5f1592353b6feadb9de2c768b649..d6f4e4c3a7748a30528dce609ae3b6db09d4bd1d 100644 (file)
--- a/connect.c
+++ b/connect.c
@@ -34,10 +34,6 @@ struct ref **get_remote_heads(int in, struct ref **list,
                        die("protocol error: expected sha/ref, got '%s'", buffer);
                name = buffer + 41;
 
-               if (ignore_funny && 45 < len && !memcmp(name, "refs/", 5) &&
-                   check_ref_format(name + 5))
-                       continue;
-
                name_len = strlen(name);
                if (len != name_len + 41) {
                        if (server_capabilities)
@@ -45,6 +41,10 @@ struct ref **get_remote_heads(int in, struct ref **list,
                        server_capabilities = strdup(name + name_len + 1);
                }
 
+               if (ignore_funny && 45 < len && !memcmp(name, "refs/", 5) &&
+                   check_ref_format(name + 5))
+                       continue;
+
                if (nr_match && !path_match(name, nr_match, match))
                        continue;
                ref = xcalloc(1, sizeof(*ref) + len - 40);
@@ -561,7 +561,8 @@ int git_connect(int fd[2], char *url, const char *prog)
 {
        char command[1024];
        char *host, *path = url;
-       char *colon = NULL;
+       char *end;
+       int c;
        int pipefd[2][2];
        pid_t pid;
        enum protocol protocol = PROTO_LOCAL;
@@ -571,15 +572,30 @@ int git_connect(int fd[2], char *url, const char *prog)
                *host = '\0';
                protocol = get_protocol(url);
                host += 3;
-               path = strchr(host, '/');
-       }
-       else {
+               c = '/';
+       } else {
                host = url;
-               if ((colon = strchr(host, ':'))) {
+               c = ':';
+       }
+
+       if (host[0] == '[') {
+               end = strchr(host + 1, ']');
+               if (end) {
+                       *end = 0;
+                       end++;
+                       host++;
+               } else
+                       end = host;
+       } else
+               end = host;
+
+       path = strchr(end, c);
+       if (c == ':') {
+               if (path) {
                        protocol = PROTO_SSH;
-                       *colon = '\0';
-                       path = colon + 1;
-               }
+                       *path++ = '\0';
+               } else
+                       path = host;
        }
 
        if (!path || !*path)
index 539f6e87af9824ea331326ade71e343698e235fe..3bd14269d7e779630c1b00a3cf8a8cdba96ffc27 100644 (file)
--- a/daemon.c
+++ b/daemon.c
@@ -15,7 +15,8 @@ static int verbose;
 
 static const char daemon_usage[] =
 "git-daemon [--verbose] [--syslog] [--inetd | --port=n] [--export-all]\n"
-"           [--timeout=n] [--init-timeout=n] [--strict-paths] [directory...]";
+"           [--timeout=n] [--init-timeout=n] [--strict-paths]\n"
+"           [--base-path=path] [directory...]";
 
 /* List of acceptable pathname prefixes */
 static char **ok_paths = NULL;
@@ -24,6 +25,9 @@ static int strict_paths = 0;
 /* If this is set, git-daemon-export-ok is not required */
 static int export_all_trees = 0;
 
+/* Take all paths relative to this one if non-NULL */
+static char *base_path = NULL;
+
 /* Timeout, and initial timeout */
 static unsigned int timeout = 0;
 static unsigned int init_timeout = 0;
@@ -138,6 +142,17 @@ static char *path_ok(char *dir)
                return NULL;
        }
 
+       if (base_path) {
+               static char rpath[PATH_MAX];
+               if (*dir != '/') {
+                       /* Forbid possible base-path evasion using ~paths. */
+                       logerror("'%s': Non-absolute path denied (base-path active)");
+                       return NULL;
+               }
+               snprintf(rpath, PATH_MAX, "%s%s", base_path, dir);
+               dir = rpath;
+       }
+
        path = enter_repo(dir, strict_paths);
 
        if (!path) {
@@ -639,6 +654,10 @@ int main(int argc, char **argv)
                        strict_paths = 1;
                        continue;
                }
+               if (!strncmp(arg, "--base-path=", 12)) {
+                       base_path = arg+12;
+                       continue;
+               }
                if (!strcmp(arg, "--")) {
                        ok_paths = &argv[i+1];
                        break;
diff --git a/describe.c b/describe.c
new file mode 100644 (file)
index 0000000..cc95eb0
--- /dev/null
@@ -0,0 +1,166 @@
+#include "cache.h"
+#include "commit.h"
+#include "tag.h"
+#include "refs.h"
+
+#define SEEN (1u << 0)
+
+static const char describe_usage[] =
+"git-describe [--all] [--tags] [--abbrev=<n>] <committish>*";
+
+static int all = 0;    /* Default to annotated tags only */
+static int tags = 0;   /* But allow any tags if --tags is specified */
+
+#define DEFAULT_ABBREV 8 /* maybe too many */
+static int abbrev = DEFAULT_ABBREV;
+
+static int names = 0, allocs = 0;
+static struct commit_name {
+       const struct commit *commit;
+       int prio; /* annotated tag = 2, tag = 1, head = 0 */
+       char path[FLEX_ARRAY]; /* more */
+} **name_array = NULL;
+
+static struct commit_name *match(struct commit *cmit)
+{
+       int i = names;
+       struct commit_name **p = name_array;
+
+       while (i-- > 0) {
+               struct commit_name *n = *p++;
+               if (n->commit == cmit)
+                       return n;
+       }
+       return NULL;
+}
+
+static void add_to_known_names(const char *path,
+                              const struct commit *commit,
+                              int prio)
+{
+       int idx;
+       int len = strlen(path)+1;
+       struct commit_name *name = xmalloc(sizeof(struct commit_name) + len);
+
+       name->commit = commit;
+       name->prio = prio; 
+       memcpy(name->path, path, len);
+       idx = names;
+       if (idx >= allocs) {
+               allocs = (idx + 50) * 3 / 2;
+               name_array = xrealloc(name_array, allocs*sizeof(*name_array));
+       }
+       name_array[idx] = name;
+       names = ++idx;
+}
+
+static int get_name(const char *path, const unsigned char *sha1)
+{
+       struct commit *commit = lookup_commit_reference_gently(sha1, 1);
+       struct object *object;
+       int prio;
+
+       if (!commit)
+               return 0;
+       object = parse_object(sha1);
+       /* If --all, then any refs are used.
+        * If --tags, then any tags are used.
+        * Otherwise only annotated tags are used.
+        */
+       if (!strncmp(path, "refs/tags/", 10)) {
+               if (object->type == tag_type)
+                       prio = 2;
+               else
+                       prio = 1;
+       }
+       else
+               prio = 0;
+
+       if (!all) {
+               if (!prio)
+                       return 0;
+               if (!tags && prio < 2)
+                       return 0;
+       }
+       add_to_known_names(all ? path + 5 : path + 10, commit, prio);
+       return 0;
+}
+
+static int compare_names(const void *_a, const void *_b)
+{
+       struct commit_name *a = *(struct commit_name **)_a;
+       struct commit_name *b = *(struct commit_name **)_b;
+       unsigned long a_date = a->commit->date;
+       unsigned long b_date = b->commit->date;
+
+       if (a->prio != b->prio)
+               return b->prio - a->prio;
+       return (a_date > b_date) ? -1 : (a_date == b_date) ? 0 : 1;
+}
+
+static void describe(struct commit *cmit, int last_one)
+{
+       struct commit_list *list;
+       static int initialized = 0;
+       struct commit_name *n;
+
+       if (!initialized) {
+               initialized = 1;
+               for_each_ref(get_name);
+               qsort(name_array, names, sizeof(*name_array), compare_names);
+       }
+
+       n = match(cmit);
+       if (n) {
+               printf("%s\n", n->path);
+               return;
+       }
+
+       list = NULL;
+       commit_list_insert(cmit, &list);
+       while (list) {
+               struct commit *c = pop_most_recent_commit(&list, SEEN);
+               n = match(c);
+               if (n) {
+                       printf("%s-g%s\n", n->path,
+                              find_unique_abbrev(cmit->object.sha1, abbrev));
+                       if (!last_one)
+                               clear_commit_marks(cmit, SEEN);
+                       return;
+               }
+       }
+       die("cannot describe '%s'", sha1_to_hex(cmit->object.sha1));
+}
+
+int main(int argc, char **argv)
+{
+       int i;
+
+       for (i = 1; i < argc; i++) {
+               const char *arg = argv[i];
+               unsigned char sha1[20];
+               struct commit *cmit;
+
+               if (!strcmp(arg, "--all")) {
+                       all = 1;
+                       continue;
+               }
+               if (!strcmp(arg, "--tags")) {
+                       tags = 1;
+                       continue;
+               }
+               if (!strncmp(arg, "--abbrev=", 9)) {
+                       abbrev = strtoul(arg + 9, NULL, 10);
+                       if (abbrev < 4 || 40 <= abbrev)
+                               abbrev = DEFAULT_ABBREV;
+                       continue;
+               }
+               if (get_sha1(arg, sha1) < 0)
+                       usage(describe_usage);
+               cmit = lookup_commit_reference(sha1);
+               if (!cmit)
+                       usage(describe_usage);
+               describe(cmit, i == argc - 1);
+       }
+       return 0;
+}
index 0886ad38f94ddb897629d832160333921ac89481..0596fc647be37343371ae5a266906dab35707076 100644 (file)
@@ -15,6 +15,7 @@ int trust_executable_bit = 1;
 int only_use_symrefs = 0;
 int repository_format_version = 0;
 char git_commit_encoding[MAX_ENCODING_LENGTH] = "utf-8";
+int shared_repository = 0;
 
 static char *git_dir, *git_object_dir, *git_index_file, *git_refs_dir,
        *git_graft_file;
index 36308d22c6a72b9ad53ced60bd3c70a2e17520b6..3bbd1117739b02572aece86030bb9f02f3110d34 100755 (executable)
@@ -1,6 +1,7 @@
 #!/bin/sh
 
 USAGE='[-f] [-b <new_branch>] [<branch>] [<paths>...]'
+SUBDIRECTORY_OK=Sometimes
 . git-sh-setup
 
 old=$(git-rev-parse HEAD)
@@ -79,7 +80,7 @@ then
                # from a specific tree-ish; note that this is for
                # rescuing paths and is never meant to remove what
                # is not in the named tree-ish.
-               git-ls-tree -r "$new" "$@" |
+               git-ls-tree --full-name -r "$new" "$@" |
                git-update-index --index-info || exit $?
        fi
        git-checkout-index -f -u -- "$@"
@@ -95,6 +96,14 @@ else
        fi
 fi
 
+# We are switching branches and checking out trees, so
+# we *NEED* to be at the toplevel.
+cdup=$(git-rev-parse --show-cdup)
+if test ! -z "$cdup"
+then
+       cd "$cdup"
+fi
+
 [ -z "$new" ] && new=$old
 
 # If we don't have an old branch that we're switching to,
index 5e9bd0caf2e1141e3045ea6c3a1f0e9d9285c492..1a6232013b471d9a3df6ab10705c263aa740c2f7 100755 (executable)
@@ -3,17 +3,17 @@
 # Copyright (c) 2005 Junio C Hamano.
 #
 
-USAGE='[-v] <upstream> [<head>]'
+USAGE='[-v] <upstream> [<head>] [<limit>]'
 LONG_USAGE='             __*__*__*__*__> <upstream>
             /
   fork-point
             \__+__+__+__+__+__+__+__> <head>
 
-Each commit between the fork-point and <head> is examined, and
-compared against the change each commit between the fork-point and
-<upstream> introduces.  If the change seems to be in the upstream,
-it is shown on the standard output with prefix "+".  Otherwise
-it is shown with prefix "-".'
+Each commit between the fork-point (or <limit> if given) and <head> is
+examined, and compared against the change each commit between the
+fork-point and <upstream> introduces.  If the change seems to be in
+the upstream, it is shown on the standard output with prefix "+".
+Otherwise it is shown with prefix "-".'
 . git-sh-setup
 
 case "$1" in -v) verbose=t; shift ;; esac 
@@ -28,9 +28,15 @@ esac
 case "$#" in
 1) upstream=`git-rev-parse --verify "$1"` &&
    ours=`git-rev-parse --verify HEAD` || exit
+   limit="$upstream"
    ;;
 2) upstream=`git-rev-parse --verify "$1"` &&
    ours=`git-rev-parse --verify "$2"` || exit
+   limit="$upstream"
+   ;;
+3) upstream=`git-rev-parse --verify "$1"` &&
+   ours=`git-rev-parse --verify "$2"` &&
+   limit=`git-rev-parse --verify "$3"` || exit
    ;;
 *) usage ;;
 esac
@@ -38,7 +44,7 @@ esac
 # Note that these list commits in reverse order;
 # not that the order in inup matters...
 inup=`git-rev-list ^$ours $upstream` &&
-ours=`git-rev-list $ours ^$upstream` || exit
+ours=`git-rev-list $ours ^$limit` || exit
 
 tmp=.cherry-tmp$$
 patch=$tmp-patch
index 280cc2e81e98c5fe69e8528ca97069dd0b0e59f5..377d59e62cecd305fc7cf69aa927b13225fdb3eb 100755 (executable)
@@ -9,7 +9,7 @@
 unset CDPATH
 
 usage() {
-       echo >&2 "Usage: $0 [-l [-s]] [-q] [-u <upload-pack>] [-n] <repo> [<dir>]"
+       echo >&2 "Usage: $0 [-l [-s]] [-q] [-u <upload-pack>] [-o <name>] [-n] <repo> [<dir>]"
        exit 1
 }
 
@@ -31,25 +31,11 @@ clone_dumb_http () {
        cd "$2" &&
        clone_tmp='.git/clone-tmp' &&
        mkdir -p "$clone_tmp" || exit 1
-       http_fetch "$1/info/refs" "$clone_tmp/refs" &&
-       http_fetch "$1/objects/info/packs" "$clone_tmp/packs" || {
+       http_fetch "$1/info/refs" "$clone_tmp/refs" || {
                echo >&2 "Cannot get remote repository information.
 Perhaps git-update-server-info needs to be run there?"
                exit 1;
        }
-       while read type name
-       do
-               case "$type" in
-               P) ;;
-               *) continue ;;
-               esac &&
-
-               idx=`expr "$name" : '\(.*\)\.pack'`.idx
-               http_fetch "$1/objects/pack/$name" ".git/objects/pack/$name" &&
-               http_fetch "$1/objects/pack/$idx" ".git/objects/pack/$idx" &&
-               git-verify-pack ".git/objects/pack/$idx" || exit 1
-       done <"$clone_tmp/packs"
-
        while read sha1 refname
        do
                name=`expr "$refname" : 'refs/\(.*\)'` &&
@@ -67,6 +53,7 @@ use_local=no
 local_shared=no
 no_checkout=
 upload_pack=
+origin=origin
 while
        case "$#,$1" in
        0,*) break ;;
@@ -75,6 +62,14 @@ while
         *,-s|*,--s|*,--sh|*,--sha|*,--shar|*,--share|*,--shared) 
           local_shared=yes; use_local=yes ;;
        *,-q|*,--quiet) quiet=-q ;;
+       1,-o) usage;;
+       *,-o)
+               git-check-ref-format "$2" || {
+                   echo >&2 "'$2' is not suitable for a branch name"
+                   exit 1
+               }
+               origin="$2"; shift
+               ;;
        1,-u|1,--upload-pack) usage ;;
        *,-u|*,--upload-pack)
                shift
@@ -208,14 +203,14 @@ then
                mkdir -p .git/remotes &&
                echo >.git/remotes/origin \
                "URL: $repo
-Pull: $head_points_at:origin" &&
-               cp ".git/refs/heads/$head_points_at" .git/refs/heads/origin &&
+Pull: $head_points_at:$origin" &&
+               git-update-ref "refs/heads/$origin" $(git-rev-parse HEAD) &&
                find .git/refs/heads -type f -print |
                while read ref
                do
                        head=`expr "$ref" : '.git/refs/heads/\(.*\)'` &&
                        test "$head_points_at" = "$head" ||
-                       test "origin" = "$head" ||
+                       test "$origin" = "$head" ||
                        echo "Pull: ${head}:${head}"
                done >>.git/remotes/origin
        esac
index b46b3e558945a3afb783894c75ce20cede0b4eec..73e57bd784c37b950219819fb2e025da8933aab6 100755 (executable)
@@ -11,6 +11,7 @@ LF='
 '
 IFS="$LF"
 
+no_tags=
 tags=
 append=
 force=
@@ -28,6 +29,9 @@ do
        -t|--t|--ta|--tag|--tags)
                tags=t
                ;;
+       -n|--n|--no|--no-|--no-t|--no-ta|--no-tag|--no-tags)
+               no_tags=t
+               ;;
        -u|--u|--up|--upd|--upda|--updat|--update|--update-|--update-h|\
        --update-he|--update-hea|--update-head|--update-head-|\
        --update-head-o|--update-head-ok)
@@ -212,133 +216,166 @@ then
        fi
 fi
 
-for ref in $reflist
-do
-    refs="$refs$LF$ref"
+fetch_main () {
+  reflist="$1"
+  refs=
 
-    # These are relative path from $GIT_DIR, typically starting at refs/
-    # but may be HEAD
-    if expr "$ref" : '\.' >/dev/null
-    then
-       not_for_merge=t
-       ref=$(expr "$ref" : '\.\(.*\)')
-    else
-       not_for_merge=
-    fi
-    if expr "$ref" : '\+' >/dev/null
-    then
-       single_force=t
-       ref=$(expr "$ref" : '\+\(.*\)')
-    else
-       single_force=
-    fi
-    remote_name=$(expr "$ref" : '\([^:]*\):')
-    local_name=$(expr "$ref" : '[^:]*:\(.*\)')
+  for ref in $reflist
+  do
+      refs="$refs$LF$ref"
 
-    rref="$rref$LF$remote_name"
+      # These are relative path from $GIT_DIR, typically starting at refs/
+      # but may be HEAD
+      if expr "$ref" : '\.' >/dev/null
+      then
+         not_for_merge=t
+         ref=$(expr "$ref" : '\.\(.*\)')
+      else
+         not_for_merge=
+      fi
+      if expr "$ref" : '\+' >/dev/null
+      then
+         single_force=t
+         ref=$(expr "$ref" : '\+\(.*\)')
+      else
+         single_force=
+      fi
+      remote_name=$(expr "$ref" : '\([^:]*\):')
+      local_name=$(expr "$ref" : '[^:]*:\(.*\)')
 
-    # There are transports that can fetch only one head at a time...
-    case "$remote" in
-    http://* | https://*)
-       if [ -n "$GIT_SSL_NO_VERIFY" ]; then
-           curl_extra_args="-k"
-       fi
-       remote_name_quoted=$(perl -e '
-           my $u = $ARGV[0];
-           $u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
-           print "$u";
-       ' "$remote_name")
-       head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted") &&
-       expr "$head" : "$_x40\$" >/dev/null ||
-               die "Failed to fetch $remote_name from $remote"
-       echo >&2 Fetching "$remote_name from $remote" using http
-       git-http-fetch -v -a "$head" "$remote/" || exit
-       ;;
-    rsync://*)
-       TMP_HEAD="$GIT_DIR/TMP_HEAD"
-       rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1
-       head=$(git-rev-parse --verify TMP_HEAD)
-       rm -f "$TMP_HEAD"
-       test "$rsync_slurped_objects" || {
-           rsync -av --ignore-existing --exclude info \
-               "$remote/objects/" "$GIT_OBJECT_DIRECTORY/" || exit
+      rref="$rref$LF$remote_name"
 
-           # Look at objects/info/alternates for rsync -- http will
-           # support it natively and git native ones will do it on the remote
-           # end.  Not having that file is not a crime.
-           rsync -q "$remote/objects/info/alternates" \
-               "$GIT_DIR/TMP_ALT" 2>/dev/null ||
-               rm -f "$GIT_DIR/TMP_ALT"
-           if test -f "$GIT_DIR/TMP_ALT"
-           then
-               resolve_alternates "$remote" <"$GIT_DIR/TMP_ALT" |
-               while read alt
-               do
-                   case "$alt" in 'bad alternate: '*) die "$alt";; esac
-                   echo >&2 "Getting alternate: $alt"
-                   rsync -av --ignore-existing --exclude info \
-                   "$alt" "$GIT_OBJECT_DIRECTORY/" || exit
-               done
-               rm -f "$GIT_DIR/TMP_ALT"
-           fi
-           rsync_slurped_objects=t
-       }
-       ;;
-    *)
-       # We will do git native transport with just one call later.
-       continue ;;
-    esac
+      # There are transports that can fetch only one head at a time...
+      case "$remote" in
+      http://* | https://*)
+         if [ -n "$GIT_SSL_NO_VERIFY" ]; then
+             curl_extra_args="-k"
+         fi
+         remote_name_quoted=$(perl -e '
+             my $u = $ARGV[0];
+             $u =~ s{([^-a-zA-Z0-9/.])}{sprintf"%%%02x",ord($1)}eg;
+             print "$u";
+         ' "$remote_name")
+         head=$(curl -nsfL $curl_extra_args "$remote/$remote_name_quoted") &&
+         expr "$head" : "$_x40\$" >/dev/null ||
+                 die "Failed to fetch $remote_name from $remote"
+         echo >&2 Fetching "$remote_name from $remote" using http
+         git-http-fetch -v -a "$head" "$remote/" || exit
+         ;;
+      rsync://*)
+         TMP_HEAD="$GIT_DIR/TMP_HEAD"
+         rsync -L -q "$remote/$remote_name" "$TMP_HEAD" || exit 1
+         head=$(git-rev-parse --verify TMP_HEAD)
+         rm -f "$TMP_HEAD"
+         test "$rsync_slurped_objects" || {
+             rsync -av --ignore-existing --exclude info \
+                 "$remote/objects/" "$GIT_OBJECT_DIRECTORY/" || exit
 
-    append_fetch_head "$head" "$remote" \
-       "$remote_name" "$remote_nick" "$local_name" "$not_for_merge"
+             # Look at objects/info/alternates for rsync -- http will
+             # support it natively and git native ones will do it on
+             # the remote end.  Not having that file is not a crime.
+             rsync -q "$remote/objects/info/alternates" \
+                 "$GIT_DIR/TMP_ALT" 2>/dev/null ||
+                 rm -f "$GIT_DIR/TMP_ALT"
+             if test -f "$GIT_DIR/TMP_ALT"
+             then
+                 resolve_alternates "$remote" <"$GIT_DIR/TMP_ALT" |
+                 while read alt
+                 do
+                     case "$alt" in 'bad alternate: '*) die "$alt";; esac
+                     echo >&2 "Getting alternate: $alt"
+                     rsync -av --ignore-existing --exclude info \
+                     "$alt" "$GIT_OBJECT_DIRECTORY/" || exit
+                 done
+                 rm -f "$GIT_DIR/TMP_ALT"
+             fi
+             rsync_slurped_objects=t
+         }
+         ;;
+      *)
+         # We will do git native transport with just one call later.
+         continue ;;
+      esac
 
-done
+      append_fetch_head "$head" "$remote" \
+         "$remote_name" "$remote_nick" "$local_name" "$not_for_merge"
 
-case "$remote" in
-http://* | https://* | rsync://* )
-    ;; # we are already done.
-*)
-    IFS="      $LF"
-    (
-       git-fetch-pack "$remote" $rref || echo failed "$remote"
-    ) |
-    while read sha1 remote_name
-    do
-       case "$sha1" in
-       failed)
-               echo >&2 "Fetch failure: $remote"
-               exit 1 ;;
-       esac
-       found=
-       single_force=
-       for ref in $refs
+  done
+
+  case "$remote" in
+  http://* | https://* | rsync://* )
+      ;; # we are already done.
+  *)
+    ( : subshell because we muck with IFS
+      IFS="    $LF"
+      (
+         git-fetch-pack "$remote" $rref || echo failed "$remote"
+      ) |
+      while read sha1 remote_name
+      do
+         case "$sha1" in
+         failed)
+                 echo >&2 "Fetch failure: $remote"
+                 exit 1 ;;
+         esac
+         found=
+         single_force=
+         for ref in $refs
+         do
+             case "$ref" in
+             +$remote_name:*)
+                 single_force=t
+                 not_for_merge=
+                 found="$ref"
+                 break ;;
+             .+$remote_name:*)
+                 single_force=t
+                 not_for_merge=t
+                 found="$ref"
+                 break ;;
+             .$remote_name:*)
+                 not_for_merge=t
+                 found="$ref"
+                 break ;;
+             $remote_name:*)
+                 not_for_merge=
+                 found="$ref"
+                 break ;;
+             esac
+         done
+         local_name=$(expr "$found" : '[^:]*:\(.*\)')
+         append_fetch_head "$sha1" "$remote" \
+                 "$remote_name" "$remote_nick" "$local_name" "$not_for_merge"
+      done
+    ) || exit ;;
+  esac
+
+}
+
+fetch_main "$reflist"
+
+# automated tag following
+case "$no_tags$tags" in
+'')
+       taglist=$(IFS=" " &&
+       git-ls-remote --tags "$remote" |
+       sed -ne 's|^\([0-9a-f]*\)[      ]\(refs/tags/.*\)^{}$|\1 \2|p' |
+       while read sha1 name
        do
-           case "$ref" in
-           +$remote_name:*)
-               single_force=t
-               not_for_merge=
-               found="$ref"
-               break ;;
-           .+$remote_name:*)
-               single_force=t
-               not_for_merge=t
-               found="$ref"
-               break ;;
-           .$remote_name:*)
-               not_for_merge=t
-               found="$ref"
-               break ;;
-           $remote_name:*)
-               not_for_merge=
-               found="$ref"
-               break ;;
-           esac
-       done
-       local_name=$(expr "$found" : '[^:]*:\(.*\)')
-       append_fetch_head "$sha1" "$remote" \
-               "$remote_name" "$remote_nick" "$local_name" "$not_for_merge"
-    done || exit
-    ;;
+               test -f "$GIT_DIR/$name" && continue
+               git-check-ref-format "$name" || {
+                       echo >&2 "warning: tag ${name} ignored"
+                       continue
+               }
+               git-cat-file -t "$sha1" >/dev/null 2>&1 || continue
+               echo >&2 "Auto-following $name"
+               echo ".${name}:${name}"
+       done)
+       case "$taglist" in
+       '') ;;
+       ?*)
+               fetch_main "$taglist" ;;
+       esac
 esac
 
 # If the original head was empty (i.e. no "master" yet), or
index f1320a69581500f3c70f0eb556e195a7e47e8714..56c3641abbe872bd44ec6c7745e6bc3705874869 100755 (executable)
@@ -283,12 +283,20 @@ def updateFileExt(sha, mode, path, updateCache, updateWd):
 def setIndexStages(path,
                    oSHA1, oMode,
                    aSHA1, aMode,
-                   bSHA1, bMode):
+                   bSHA1, bMode,
+                   clear=True):
+    istring = []
+    if clear:
+        istring.append("0 " + ("0" * 40) + "\t" + path + "\0")
+    if oMode:
+        istring.append("%o %s %d\t%s\0" % (oMode, oSHA1, 1, path))
+    if aMode:
+        istring.append("%o %s %d\t%s\0" % (aMode, aSHA1, 2, path))
+    if bMode:
+        istring.append("%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
+
     runProgram(['git-update-index', '-z', '--index-info'],
-               input="0 " + ("0" * 40) + "\t" + path + "\0" + \
-               "%o %s %d\t%s\0" % (oMode, oSHA1, 1, path) + \
-               "%o %s %d\t%s\0" % (aMode, aSHA1, 2, path) + \
-               "%o %s %d\t%s\0" % (bMode, bSHA1, 3, path))
+               input="".join(istring))
 
 def removeFile(clean, path):
     updateCache = cacheOnly or clean
@@ -570,7 +578,7 @@ def processRenames(renamesA, renamesB, branchNameA, branchNameB):
             continue
 
         ren1.processed = True
-        removeFile(True, ren1.srcName)
+
         if ren2:
             # Renamed in 1 and renamed in 2
             assert(ren1.srcName == ren2.srcName)
@@ -598,13 +606,19 @@ def processRenames(renamesA, renamesB, branchNameA, branchNameB):
                            'adding as', dstName2, 'instead.')
                     removeFile(False, ren2.dstName)
                 else:
-                    dstName2 = ren1.dstName
+                    dstName2 = ren2.dstName
+                setIndexStages(dstName1,
+                               None, None,
+                               ren1.dstSha, ren1.dstMode,
+                              None, None)
+                setIndexStages(dstName2,
+                               None, None,
+                               None, None,
+                               ren2.dstSha, ren2.dstMode)
 
-                # NEEDSWORK: place dstNameA at stage 2 and dstNameB at stage 3
-                # What about other stages???
-                updateFile(False, ren1.dstSha, ren1.dstMode, dstName1)
-                updateFile(False, ren2.dstSha, ren2.dstMode, dstName2)
             else:
+                removeFile(True, ren1.srcName)
+
                 [resSha, resMode, clean, merge] = \
                          mergeFile(ren1.srcName, ren1.srcSha, ren1.srcMode,
                                    ren1.dstName, ren1.dstSha, ren1.dstMode,
@@ -630,6 +644,8 @@ def processRenames(renamesA, renamesB, branchNameA, branchNameB):
 
                 updateFile(clean, resSha, resMode, ren1.dstName)
         else:
+            removeFile(True, ren1.srcName)
+
             # Renamed in 1, maybe changed in 2
             if renamesA == renames1:
                 stage = 3
index 50ccd24efb707d615e560dfbd38abec5b2b25b20..10d781c92f82197845ce30c67f796d99379e93cd 100755 (executable)
@@ -83,11 +83,11 @@ report "Changed but not updated" "use git-update-index to mark for commit"
 
 if test -f "$GIT_DIR/info/exclude"
 then
-    git-ls-files -z --others \
+    git-ls-files -z --others --directory \
        --exclude-from="$GIT_DIR/info/exclude" \
         --exclude-per-directory=.gitignore
 else
-    git-ls-files -z --others \
+    git-ls-files -z --others --directory \
         --exclude-per-directory=.gitignore
 fi |
 perl -e '$/ = "\0";
index b170f74a94e42dbf82f2e94b831f1cf6b49a2b4c..80e2500e0ea1769d9d92454c667852dd2056ef04 100755 (executable)
@@ -4,9 +4,15 @@ USAGE='[-p] [--max-count=<n>] [<since>..<limit>] [--pretty=<format>] [-m] [git-d
 SUBDIRECTORY_OK='Yes'
 . git-sh-setup
 
+diff_tree_flags=$(git-rev-parse --sq --no-revs --flags "$@")
+test -z "$diff_tree_flags" &&
+       diff_tree_flags=$(git-repo-config --get whatchanged.difftree)
+test -z "$diff_tree_flags" &&
+       diff_tree_flags='-M --abbrev'
+
 rev_list_args=$(git-rev-parse --sq --default HEAD --revs-only "$@") &&
-diff_tree_args=$(git-rev-parse --sq --no-revs "$@") &&
+diff_tree_args=$(git-rev-parse --sq --no-revs --no-flags "$@") &&
 
 eval "git-rev-list $rev_list_args" |
-eval "git-diff-tree --stdin --pretty -r $diff_tree_args" |
+eval "git-diff-tree --stdin --pretty -r $diff_tree_flags $diff_tree_args" |
 LESS="$LESS -S" ${PAGER:-less}
index ead37b5ed86e5ae96c18d081fbfffd65ed74dce8..ff294960f29c8763e34e28060dee04b799bd55fd 100644 (file)
--- a/init-db.c
+++ b/init-db.c
@@ -9,7 +9,7 @@
 #define DEFAULT_GIT_TEMPLATE_DIR "/usr/share/git-core/templates/"
 #endif
 
-static void safe_create_dir(const char *dir)
+static void safe_create_dir(const char *dir, int share)
 {
        if (mkdir(dir, 0777) < 0) {
                if (errno != EEXIST) {
@@ -17,6 +17,8 @@ static void safe_create_dir(const char *dir)
                        exit(1);
                }
        }
+       else if (share && adjust_shared_perm(dir))
+               die("Could not make %s writable by group\n", dir);
 }
 
 static int copy_file(const char *dst, const char *src, int mode)
@@ -32,6 +34,10 @@ static int copy_file(const char *dst, const char *src, int mode)
        }
        status = copy_fd(fdi, fdo);
        close(fdo);
+
+       if (!status && adjust_shared_perm(dst))
+               return -1;
+
        return status;
 }
 
@@ -48,7 +54,7 @@ static void copy_templates_1(char *path, int baselen,
         * with the way the namespace under .git/ is organized, should
         * be really carefully chosen.
         */
-       safe_create_dir(path);
+       safe_create_dir(path, 1);
        while ((de = readdir(dir)) != NULL) {
                struct stat st_git, st_template;
                int namelen;
@@ -176,11 +182,11 @@ static void create_default_files(const char *git_dir, char *template_path)
         * Create .git/refs/{heads,tags}
         */
        strcpy(path + len, "refs");
-       safe_create_dir(path);
+       safe_create_dir(path, 1);
        strcpy(path + len, "refs/heads");
-       safe_create_dir(path);
+       safe_create_dir(path, 1);
        strcpy(path + len, "refs/tags");
-       safe_create_dir(path);
+       safe_create_dir(path, 1);
 
        /* First copy the templates -- we might have the default
         * config file there, in which case we would want to read
@@ -220,7 +226,7 @@ static void create_default_files(const char *git_dir, char *template_path)
 }
 
 static const char init_db_usage[] =
-"git-init-db [--template=<template-directory>]";
+"git-init-db [--template=<template-directory>] [--shared]";
 
 /*
  * If you want to, you can share the DB area with any number of branches.
@@ -239,6 +245,8 @@ int main(int argc, char **argv)
                char *arg = argv[1];
                if (!strncmp(arg, "--template=", 11))
                        template_dir = arg+11;
+               else if (!strcmp(arg, "--shared"))
+                       shared_repository = 1;
                else
                        die(init_db_usage);
        }
@@ -251,7 +259,7 @@ int main(int argc, char **argv)
                git_dir = DEFAULT_GIT_DIR_ENVIRONMENT;
                fprintf(stderr, "defaulting to local storage area\n");
        }
-       safe_create_dir(git_dir);
+       safe_create_dir(git_dir, 0);
 
        /* Check to see if the repository version is right.
         * Note that a newly created repository does not have
@@ -270,10 +278,14 @@ int main(int argc, char **argv)
        path = xmalloc(len + 40);
        memcpy(path, sha1_dir, len);
 
-       safe_create_dir(sha1_dir);
+       safe_create_dir(sha1_dir, 1);
        strcpy(path+len, "/pack");
-       safe_create_dir(path);
+       safe_create_dir(path, 1);
        strcpy(path+len, "/info");
-       safe_create_dir(path);
+       safe_create_dir(path, 1);
+
+       if (shared_repository)
+               git_config_set("core.sharedRepository", "true");
+
        return 0;
 }
index 74ec8c0aeeb52a3bed8a0ac9da8fb9ba5ef66187..6af3b091b049d8ded1999405b4da7191f2b36a4c 100644 (file)
@@ -19,6 +19,7 @@ static int show_stage = 0;
 static int show_unmerged = 0;
 static int show_modified = 0;
 static int show_killed = 0;
+static int show_other_directories = 0;
 static int line_terminator = '\n';
 
 static int prefix_len = 0, prefix_offset = 0;
@@ -233,6 +234,17 @@ static void add_name(const char *pathname, int len)
        dir[nr_dir++] = ent;
 }
 
+static int dir_exists(const char *dirname, int len)
+{
+       int pos = cache_name_pos(dirname, len);
+       if (pos >= 0)
+               return 1;
+       pos = -pos-1;
+       if (pos >= active_nr) /* can't */
+               return 0;
+       return !strncmp(active_cache[pos]->name, dirname, len);
+}
+
 /*
  * Read a directory tree. We currently ignore anything but
  * directories, regular files and symlinks. That's because git
@@ -281,8 +293,12 @@ static void read_directory(const char *path, const char *base, int baselen)
                                /* fallthrough */
                        case DT_DIR:
                                memcpy(fullname + baselen + len, "/", 2);
+                               len++;
+                               if (show_other_directories &&
+                                   !dir_exists(fullname, baselen + len))
+                                       break;
                                read_directory(fullname, fullname,
-                                              baselen + len + 1);
+                                              baselen + len);
                                continue;
                        case DT_REG:
                        case DT_LNK:
@@ -622,6 +638,10 @@ int main(int argc, const char **argv)
                        show_killed = 1;
                        continue;
                }
+               if (!strcmp(arg, "--directory")) {
+                       show_other_directories = 1;
+                       continue;
+               }
                if (!strcmp(arg, "-u") || !strcmp(arg, "--unmerged")) {
                        /* There's no point in showing unmerged unless
                         * you also show the stage information.
index dae377d99585d4e6a176f85f0101d8ae29668f2f..d585b6fc13f4b980fa237067157de96e8e7ef601 100644 (file)
--- a/ls-tree.c
+++ b/ls-tree.c
@@ -15,9 +15,11 @@ static int line_termination = '\n';
 #define LS_NAME_ONLY 8
 static int ls_options = 0;
 const char **pathspec;
+static int chomp_prefix = 0;
+static const char *prefix;
 
 static const char ls_tree_usage[] =
-       "git-ls-tree [-d] [-r] [-t] [-z] [--name-only] [--name-status] <tree-ish> [path...]";
+       "git-ls-tree [-d] [-r] [-t] [-z] [--name-only] [--name-status] [--full-name] <tree-ish> [path...]";
 
 static int show_recursive(const char *base, int baselen, const char *pathname)
 {
@@ -49,7 +51,8 @@ static int show_recursive(const char *base, int baselen, const char *pathname)
        }
 }
 
-static int show_tree(unsigned char *sha1, const char *base, int baselen, const char *pathname, unsigned mode, int stage)
+static int show_tree(unsigned char *sha1, const char *base, int baselen,
+                    const char *pathname, unsigned mode, int stage)
 {
        int retval = 0;
        const char *type = "blob";
@@ -65,21 +68,28 @@ static int show_tree(unsigned char *sha1, const char *base, int baselen, const c
        else if (ls_options & LS_TREE_ONLY)
                return 0;
 
+       if (chomp_prefix &&
+           (baselen < chomp_prefix || memcmp(prefix, base, chomp_prefix)))
+               return 0;
+
        if (!(ls_options & LS_NAME_ONLY))
                printf("%06o %s %s\t", mode, type, sha1_to_hex(sha1));
-       write_name_quoted(base, baselen, pathname, line_termination, stdout);
+       write_name_quoted(base + chomp_prefix, baselen - chomp_prefix,
+                         pathname,
+                         line_termination, stdout);
        putchar(line_termination);
        return retval;
 }
 
 int main(int argc, const char **argv)
 {
-       const char *prefix;
        unsigned char sha1[20];
        char *buf;
        unsigned long size;
 
        prefix = setup_git_directory();
+       if (prefix && *prefix)
+               chomp_prefix = strlen(prefix);
        while (1 < argc && argv[1][0] == '-') {
                switch (argv[1][1]) {
                case 'z':
@@ -100,6 +110,10 @@ int main(int argc, const char **argv)
                                ls_options |= LS_NAME_ONLY;
                                break;
                        }
+                       if (!strcmp(argv[1]+2, "full-name")) {
+                               chomp_prefix = 0;
+                               break;
+                       }
                        /* otherwise fallthru */
                default:
                        usage(ls_tree_usage);
index 0a43278924edae9d6e3ecdf4bb100bea10faef97..1869b38b726b3760f279076af43006be9f1c5acf 100644 (file)
@@ -8,6 +8,8 @@
 
 #include "cache.h"
 
+#define BLKSIZE 512
+
 static const char pack_redundant_usage[] =
 "git-pack-redundant [ --verbose ] [ --alt-odb ] < --all | <.pack filename> ...>";
 
@@ -33,29 +35,32 @@ static struct pack_list {
 struct pll {
        struct pll *next;
        struct pack_list *pl;
-       size_t pl_size;
 };
 
 static struct llist_item *free_nodes = NULL;
 
+static inline void llist_item_put(struct llist_item *item)
+{
+       item->next = free_nodes;
+       free_nodes = item;
+}
+
 static inline struct llist_item *llist_item_get()
 {
        struct llist_item *new;
        if ( free_nodes ) {
                new = free_nodes;
                free_nodes = free_nodes->next;
-       } else
-               new = xmalloc(sizeof(struct llist_item));
-
+       } else {
+               int i = 1;
+               new = xmalloc(sizeof(struct llist_item) * BLKSIZE);
+               for(;i < BLKSIZE; i++) {
+                       llist_item_put(&new[i]);
+               }
+       }
        return new;
 }
 
-static inline void llist_item_put(struct llist_item *item)
-{
-       item->next = free_nodes;
-       free_nodes = item;
-}
-
 static void llist_free(struct llist *list)
 {
        while((list->back = list->front)) {
@@ -270,77 +275,58 @@ static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
        }
 }
 
-static void pll_insert(struct pll **pll, struct pll **hint_table)
+void pll_free(struct pll *l)
 {
-       struct pll *prev;
-       int i = (*pll)->pl_size - 1;
-
-       if (hint_table[i] == NULL) {
-               hint_table[i--] = *pll;
-               for (; i >= 0; --i) {
-                       if (hint_table[i] != NULL)
-                               break;
+       struct pll *old;
+       struct pack_list *opl;
+
+       while (l) {
+               old = l;
+               while (l->pl) {
+                       opl = l->pl;
+                       l->pl = opl->next;
+                       free(opl);
                }
-               if (hint_table[i] == NULL) /* no elements in list */
-                       die("Why did this happen?");
+               l = l->next;
+               free(old);
        }
-
-       prev = hint_table[i];
-       while (prev->next && prev->next->pl_size < (*pll)->pl_size)
-               prev = prev->next;
-
-       (*pll)->next = prev->next;
-       prev->next = *pll;
 }
 
 /* all the permutations have to be free()d at the same time,
  * since they refer to each other
  */
-static struct pll * get_all_permutations(struct pack_list *list)
+static struct pll * get_permutations(struct pack_list *list, int n)
 {
-       struct pll *subset, *pll, *new_pll = NULL; /*silence warning*/
-       static struct pll **hint = NULL;
-       if (hint == NULL)
-               hint = xcalloc(pack_list_size(list), sizeof(struct pll *));
-               
-       if (list == NULL)
+       struct pll *subset, *ret = NULL, *new_pll = NULL, *pll;
+
+       if (list == NULL || pack_list_size(list) < n || n == 0)
                return NULL;
 
-       if (list->next == NULL) {
-               new_pll = xmalloc(sizeof(struct pll));
-               hint[0] = new_pll;
-               new_pll->next = NULL;
-               new_pll->pl = list;
-               new_pll->pl_size = 1;
-               return new_pll;
+       if (n == 1) {
+               while (list) {
+                       new_pll = xmalloc(sizeof(pll));
+                       new_pll->pl = NULL;
+                       pack_list_insert(&new_pll->pl, list);
+                       new_pll->next = ret;
+                       ret = new_pll;
+                       list = list->next;
+               }
+               return ret;
        }
 
-       pll = subset = get_all_permutations(list->next);
-       while (pll) {
-               if (pll->pl->pack == list->pack) {
-                       pll = pll->next;
-                       continue;
+       while (list->next) {
+               subset = get_permutations(list->next, n - 1);
+               while (subset) {
+                       new_pll = xmalloc(sizeof(pll));
+                       new_pll->pl = subset->pl;
+                       pack_list_insert(&new_pll->pl, list);
+                       new_pll->next = ret;
+                       ret = new_pll;
+                       subset = subset->next;
                }
-               new_pll = xmalloc(sizeof(struct pll));
-
-               new_pll->pl = xmalloc(sizeof(struct pack_list));
-               memcpy(new_pll->pl, list, sizeof(struct pack_list));
-               new_pll->pl->next = pll->pl;
-               new_pll->pl_size = pll->pl_size + 1;
-               
-               pll_insert(&new_pll, hint);
-
-               pll = pll->next;
-       }
-       /* add ourself */
-       new_pll = xmalloc(sizeof(struct pll));
-       new_pll->pl = xmalloc(sizeof(struct pack_list));
-       memcpy(new_pll->pl, list, sizeof(struct pack_list));
-       new_pll->pl->next = NULL;
-       new_pll->pl_size = 1;
-       pll_insert(&new_pll, hint);
-
-       return hint[0];
+               list = list->next;
+       }
+       return ret;
 }
 
 static int is_superset(struct pack_list *pl, struct llist *list)
@@ -428,6 +414,7 @@ static void minimize(struct pack_list **min)
        struct pll *perm, *perm_all, *perm_ok = NULL, *new_perm;
        struct llist *missing;
        size_t min_perm_size = (size_t)-1, perm_size;
+       int n;
 
        pl = local_packs;
        while (pl) {
@@ -441,8 +428,7 @@ static void minimize(struct pack_list **min)
        missing = llist_copy(all_objects);
        pl = unique;
        while (pl) {
-               llist_sorted_difference_inplace(missing,
-                                               pl->all_objects);
+               llist_sorted_difference_inplace(missing, pl->all_objects);
                pl = pl->next;
        }
 
@@ -453,19 +439,21 @@ static void minimize(struct pack_list **min)
        }
 
        /* find the permutations which contain all missing objects */
-       perm_all = perm = get_all_permutations(non_unique);
-       while (perm) {
-               if (perm_ok && perm->pl_size > perm_ok->pl_size)
-                       break; /* ignore all larger permutations */
-               if (is_superset(perm->pl, missing)) {
-                       new_perm = xmalloc(sizeof(struct pll));
-                       memcpy(new_perm, perm, sizeof(struct pll));
-                       new_perm->next = perm_ok;
-                       perm_ok = new_perm;
+       for (n = 1; n <= pack_list_size(non_unique) && !perm_ok; n++) {
+               perm_all = perm = get_permutations(non_unique, n);
+               while (perm) {
+                       if (is_superset(perm->pl, missing)) {
+                               new_perm = xmalloc(sizeof(struct pll));
+                               memcpy(new_perm, perm, sizeof(struct pll));
+                               new_perm->next = perm_ok;
+                               perm_ok = new_perm;
+                       }
+                       perm = perm->next;
                }
-               perm = perm->next;
+               if (perm_ok)
+                       break;
+               pll_free(perm_all);
        }
-       
        if (perm_ok == NULL)
                die("Internal error: No complete sets found!\n");
 
@@ -537,6 +525,7 @@ static void scan_alt_odb_packs(void)
                                                        alt->all_objects);
                        local = local->next;
                }
+               llist_sorted_difference_inplace(all_objects, alt->all_objects);
                alt = alt->next;
        }
 }
index ce986fe11cd8989b439f070e9bea5d68b6711758..f847ec2b54b74e2b9bee7bde8fccbaa8ee569573 100644 (file)
@@ -8,20 +8,33 @@ static const char receive_pack_usage[] = "git-receive-pack <git-dir>";
 
 static const char unpacker[] = "git-unpack-objects";
 
+static int report_status = 0;
+
+static char capabilities[] = "report-status";
+static int capabilities_sent = 0;
+
 static int show_ref(const char *path, const unsigned char *sha1)
 {
-       packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
+       if (capabilities_sent)
+               packet_write(1, "%s %s\n", sha1_to_hex(sha1), path);
+       else
+               packet_write(1, "%s %s%c%s\n",
+                            sha1_to_hex(sha1), path, 0, capabilities);
+       capabilities_sent = 1;
        return 0;
 }
 
 static void write_head_info(void)
 {
        for_each_ref(show_ref);
+       if (!capabilities_sent)
+               show_ref("capabilities^{}", null_sha1);
+
 }
 
 struct command {
        struct command *next;
-       unsigned char updated;
+       const char *error_string;
        unsigned char old_sha1[20];
        unsigned char new_sha1[20];
        char ref_name[FLEX_ARRAY]; /* more */
@@ -71,33 +84,37 @@ static int run_update_hook(const char *refname,
        case 0:
                return 0;
        case -ERR_RUN_COMMAND_FORK:
-               die("hook fork failed");
+               return error("hook fork failed");
        case -ERR_RUN_COMMAND_EXEC:
-               die("hook execute failed");
+               return error("hook execute failed");
        case -ERR_RUN_COMMAND_WAITPID:
-               die("waitpid failed");
+               return error("waitpid failed");
        case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
-               die("waitpid is confused");
+               return error("waitpid is confused");
        case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
-               fprintf(stderr, "%s died of signal\n", update_hook);
-               return -1;
+               return error("%s died of signal\n", update_hook);
        case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
-               die("%s died strangely", update_hook);
+               return error("%s died strangely", update_hook);
        default:
                error("%s exited with error code %d", update_hook, -code);
                return -code;
        }
 }
 
-static int update(const char *name,
-                 unsigned char *old_sha1, unsigned char *new_sha1)
+static int update(struct command *cmd)
 {
+       const char *name = cmd->ref_name;
+       unsigned char *old_sha1 = cmd->old_sha1;
+       unsigned char *new_sha1 = cmd->new_sha1;
        char new_hex[60], *old_hex, *lock_name;
        int newfd, namelen, written;
 
-       if (!strncmp(name, "refs/", 5) && check_ref_format(name + 5))
+       cmd->error_string = NULL;
+       if (!strncmp(name, "refs/", 5) && check_ref_format(name + 5)) {
+               cmd->error_string = "funny refname";
                return error("refusing to create funny ref '%s' locally",
                             name);
+       }
 
        namelen = strlen(name);
        lock_name = xmalloc(namelen + 10);
@@ -106,16 +123,19 @@ static int update(const char *name,
 
        strcpy(new_hex, sha1_to_hex(new_sha1));
        old_hex = sha1_to_hex(old_sha1);
-       if (!has_sha1_file(new_sha1))
+       if (!has_sha1_file(new_sha1)) {
+               cmd->error_string = "bad pack";
                return error("unpack should have generated %s, "
                             "but I can't find it!", new_hex);
-
+       }
        safe_create_leading_directories(lock_name);
 
        newfd = open(lock_name, O_CREAT | O_EXCL | O_WRONLY, 0666);
-       if (newfd < 0)
+       if (newfd < 0) {
+               cmd->error_string = "can't lock";
                return error("unable to create %s (%s)",
                             lock_name, strerror(errno));
+       }
 
        /* Write the ref with an ending '\n' */
        new_hex[40] = '\n';
@@ -127,18 +147,22 @@ static int update(const char *name,
        close(newfd);
        if (written != 41) {
                unlink(lock_name);
+               cmd->error_string = "can't write";
                return error("unable to write %s", lock_name);
        }
        if (verify_old_ref(name, old_hex) < 0) {
                unlink(lock_name);
+               cmd->error_string = "raced";
                return error("%s changed during push", name);
        }
        if (run_update_hook(name, old_hex, new_hex)) {
                unlink(lock_name);
+               cmd->error_string = "hook declined";
                return error("hook declined to update %s\n", name);
        }
        else if (rename(lock_name, name) < 0) {
                unlink(lock_name);
+               cmd->error_string = "can't rename";
                return error("unable to replace %s", name);
        }
        else {
@@ -158,7 +182,7 @@ static void run_update_post_hook(struct command *cmd)
        if (access(update_post_hook, X_OK) < 0)
                return;
        for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
-               if (!cmd_p->updated)
+               if (cmd_p->error_string)
                        continue;
                argc++;
        }
@@ -166,7 +190,7 @@ static void run_update_post_hook(struct command *cmd)
        argv[0] = update_post_hook;
 
        for (argc = 1, cmd_p = cmd; cmd_p; cmd_p = cmd_p->next) {
-               if (!cmd_p->updated)
+               if (cmd_p->error_string)
                        continue;
                argv[argc] = xmalloc(strlen(cmd_p->ref_name) + 1);
                strcpy(argv[argc], cmd_p->ref_name);
@@ -185,8 +209,7 @@ static void execute_commands(void)
        struct command *cmd = commands;
 
        while (cmd) {
-               cmd->updated = !update(cmd->ref_name,
-                                      cmd->old_sha1, cmd->new_sha1);
+               update(cmd);
                cmd = cmd->next;
        }
        run_update_post_hook(commands);
@@ -199,7 +222,8 @@ static void read_head_info(void)
                static char line[1000];
                unsigned char old_sha1[20], new_sha1[20];
                struct command *cmd;
-               int len;
+               char *refname;
+               int len, reflen;
 
                len = packet_read_line(0, line, sizeof(line));
                if (!len)
@@ -211,38 +235,66 @@ static void read_head_info(void)
                    line[81] != ' ' ||
                    get_sha1_hex(line, old_sha1) ||
                    get_sha1_hex(line + 41, new_sha1))
-                       die("protocol error: expected old/new/ref, got '%s'", line);
+                       die("protocol error: expected old/new/ref, got '%s'",
+                           line);
+
+               refname = line + 82;
+               reflen = strlen(refname);
+               if (reflen + 82 < len) {
+                       if (strstr(refname + reflen + 1, "report-status"))
+                               report_status = 1;
+               }
                cmd = xmalloc(sizeof(struct command) + len - 80);
                memcpy(cmd->old_sha1, old_sha1, 20);
                memcpy(cmd->new_sha1, new_sha1, 20);
                memcpy(cmd->ref_name, line + 82, len - 81);
+               cmd->error_string = "n/a (unpacker error)";
                cmd->next = NULL;
                *p = cmd;
                p = &cmd->next;
        }
 }
 
-static void unpack(void)
+static const char *unpack(int *error_code)
 {
        int code = run_command(unpacker, NULL);
+
+       *error_code = 0;
        switch (code) {
        case 0:
-               return;
+               return NULL;
        case -ERR_RUN_COMMAND_FORK:
-               die("unpack fork failed");
+               return "unpack fork failed";
        case -ERR_RUN_COMMAND_EXEC:
-               die("unpack execute failed");
+               return "unpack execute failed";
        case -ERR_RUN_COMMAND_WAITPID:
-               die("waitpid failed");
+               return "waitpid failed";
        case -ERR_RUN_COMMAND_WAITPID_WRONG_PID:
-               die("waitpid is confused");
+               return "waitpid is confused";
        case -ERR_RUN_COMMAND_WAITPID_SIGNAL:
-               die("%s died of signal", unpacker);
+               return "unpacker died of signal";
        case -ERR_RUN_COMMAND_WAITPID_NOEXIT:
-               die("%s died strangely", unpacker);
+               return "unpacker died strangely";
        default:
-               die("%s exited with error code %d", unpacker, -code);
+               *error_code = -code;
+               return "unpacker exited with error code";
+       }
+}
+
+static void report(const char *unpack_status)
+{
+       struct command *cmd;
+       packet_write(1, "unpack %s\n",
+                    unpack_status ? unpack_status : "ok");
+       for (cmd = commands; cmd; cmd = cmd->next) {
+               if (!cmd->error_string)
+                       packet_write(1, "ok %s\n",
+                                    cmd->ref_name);
+               else
+                       packet_write(1, "ng %s %s\n",
+                                    cmd->ref_name, cmd->error_string);
        }
+       packet_flush(1);
 }
 
 int main(int argc, char **argv)
@@ -275,8 +327,12 @@ int main(int argc, char **argv)
 
        read_head_info();
        if (commands) {
-               unpack();
-               execute_commands();
+               int code;
+               const char *unpack_status = unpack(&code);
+               if (!unpack_status)
+                       execute_commands();
+               if (report_status)
+                       report(unpack_status);
        }
        return 0;
 }
index bb4949ad70364abdf7c3bbca357e5ebc42880614..0c951af0d49da459fc6c85c32707b016bf581a57 100644 (file)
@@ -216,6 +216,18 @@ int main(int argc, char **argv)
                                        puts(prefix);
                                continue;
                        }
+                       if (!strcmp(arg, "--show-cdup")) {
+                               const char *pfx = prefix;
+                               while (pfx) {
+                                       pfx = strchr(pfx, '/');
+                                       if (pfx) {
+                                               pfx++;
+                                               printf("../");
+                                       }
+                               }
+                               putchar('\n');
+                               continue;
+                       }
                        if (!strcmp(arg, "--git-dir")) {
                                const char *gitdir = getenv(GIT_DIR_ENVIRONMENT);
                                static char cwd[PATH_MAX];
index 0d41f9a1787429a1498ce82e1af7e7d93cea5a41..cd361934449e9bdbce229febaccb8b638037b2e7 100644 (file)
@@ -176,16 +176,53 @@ static void get_local_heads(void)
        for_each_ref(one_local_ref);
 }
 
+static int receive_status(int in)
+{
+       char line[1000];
+       int ret = 0;
+       int len = packet_read_line(in, line, sizeof(line));
+       if (len < 10 || memcmp(line, "unpack ", 7)) {
+               fprintf(stderr, "did not receive status back\n");
+               return -1;
+       }
+       if (memcmp(line, "unpack ok\n", 10)) {
+               fputs(line, stderr);
+               ret = -1;
+       }
+       while (1) {
+               len = packet_read_line(in, line, sizeof(line));
+               if (!len)
+                       break;
+               if (len < 3 ||
+                   (memcmp(line, "ok", 2) && memcmp(line, "ng", 2))) {
+                       fprintf(stderr, "protocol error: %s\n", line);
+                       ret = -1;
+                       break;
+               }
+               if (!memcmp(line, "ok", 2))
+                       continue;
+               fputs(line, stderr);
+               ret = -1;
+       }
+       return ret;
+}
+
 static int send_pack(int in, int out, int nr_refspec, char **refspec)
 {
        struct ref *ref;
        int new_refs;
        int ret = 0;
+       int ask_for_status_report = 0;
+       int expect_status_report = 0;
 
        /* No funny business with the matcher */
        remote_tail = get_remote_heads(in, &remote_refs, 0, NULL, 1);
        get_local_heads();
 
+       /* Does the other end support the reporting? */
+       if (server_supports("report-status"))
+               ask_for_status_report = 1;
+
        /* match them up */
        if (!remote_tail)
                remote_tail = &remote_refs;
@@ -260,7 +297,17 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
                new_refs++;
                strcpy(old_hex, sha1_to_hex(ref->old_sha1));
                new_hex = sha1_to_hex(ref->new_sha1);
-               packet_write(out, "%s %s %s", old_hex, new_hex, ref->name);
+
+               if (ask_for_status_report) {
+                       packet_write(out, "%s %s %s%c%s",
+                                    old_hex, new_hex, ref->name, 0,
+                                    "report-status");
+                       ask_for_status_report = 0;
+                       expect_status_report = 1;
+               }
+               else
+                       packet_write(out, "%s %s %s",
+                                    old_hex, new_hex, ref->name);
                fprintf(stderr, "updating '%s'", ref->name);
                if (strcmp(ref->name, ref->peer_ref->name))
                        fprintf(stderr, " using '%s'", ref->peer_ref->name);
@@ -270,9 +317,15 @@ static int send_pack(int in, int out, int nr_refspec, char **refspec)
        packet_flush(out);
        if (new_refs)
                pack_objects(out, remote_refs);
-       else if (ret == 0)
-               fprintf(stderr, "Everything up-to-date\n");
        close(out);
+
+       if (expect_status_report) {
+               if (receive_status(in))
+                       ret = -4;
+       }
+
+       if (!new_refs && ret == 0)
+               fprintf(stderr, "Everything up-to-date\n");
        return ret;
 }
 
diff --git a/setup.c b/setup.c
index d3556edf121ba78b0b83d20fdbd9cb397e79eb2b..36ede3d87483548bb1ce6c19361d7f6584386147 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -180,6 +180,8 @@ int check_repository_format_version(const char *var, const char *value)
 {
        if (strcmp(var, "core.repositoryformatversion") == 0)
                repository_format_version = git_config_int(var, value);
+       else if (strcmp(var, "core.sharedrepository") == 0)
+               shared_repository = git_config_bool(var, value);
        return 0;
 }
 
index d451a94efed7d36d55cf1b77324eaf55e0d50d69..20f6419bde22ee81b69f02e0336ecf92aa2e1323 100644 (file)
@@ -48,6 +48,29 @@ int get_sha1_hex(const char *hex, unsigned char *sha1)
        return 0;
 }
 
+int adjust_shared_perm(const char *path)
+{
+       struct stat st;
+       int mode;
+
+       if (!shared_repository)
+               return 0;
+       if (lstat(path, &st) < 0)
+               return -1;
+       mode = st.st_mode;
+       if (mode & S_IRUSR)
+               mode |= S_IRGRP;
+       if (mode & S_IWUSR)
+               mode |= S_IWGRP;
+       if (mode & S_IXUSR)
+               mode |= S_IXGRP;
+       if (S_ISDIR(mode))
+               mode |= S_ISGID;
+       if (chmod(path, mode) < 0)
+               return -2;
+       return 0;
+}
+
 int safe_create_leading_directories(char *path)
 {
        char *pos = path;
@@ -59,11 +82,16 @@ int safe_create_leading_directories(char *path)
                if (!pos)
                        break;
                *pos = 0;
-               if (mkdir(path, 0777) < 0)
+               if (mkdir(path, 0777) < 0) {
                        if (errno != EEXIST) {
                                *pos = '/';
                                return -1;
                        }
+               }
+               else if (adjust_shared_perm(path)) {
+                       *pos = '/';
+                       return -2;
+               }
                *pos++ = '/';
        }
        return 0;
@@ -1241,6 +1269,8 @@ static int link_temp_to_file(const char *tmpfile, char *filename)
                if (dir) {
                        *dir = 0;
                        mkdir(filename, 0777);
+                       if (adjust_shared_perm(filename))
+                               return -2;
                        *dir = '/';
                        if (!link(tmpfile, filename))
                                return 0;
index 1f461e3e812a7c71ea2d4fa6ff60d07b050392db..adcbe03d561b2a7295a881d923b013bbefb9c7c7 100755 (executable)
@@ -11,24 +11,46 @@ filesystem.
     path0       - a file
     path1      - a symlink
     path2/file2 - a file in a directory
+    path3-junk  - a file to confuse things
+    path3/file3 - a file in a directory
 '
 . ./test-lib.sh
 
 date >path0
 ln -s xyzzy path1
-mkdir path2
+mkdir path2 path3
 date >path2/file2
-test_expect_success \
-    'git-ls-files --others to show output.' \
-    'git-ls-files --others >output'
-cat >expected <<EOF
+date >path2-junk
+date >path3/file3
+date >path3-junk
+git-update-index --add path3-junk path3/file3
+
+cat >expected1 <<EOF
+expected1
+expected2
 output
 path0
 path1
+path2-junk
 path2/file2
 EOF
+sed -e 's|path2/file2|path2/|' <expected1 >expected2
+
+test_expect_success \
+    'git-ls-files --others to show output.' \
+    'git-ls-files --others >output'
 
 test_expect_success \
     'git-ls-files --others should pick up symlinks.' \
-    'diff output expected'
+    'diff output expected1'
+
+test_expect_success \
+    'git-ls-files --others --directory to show output.' \
+    'git-ls-files --others --directory >output'
+
+
+test_expect_success \
+    'git-ls-files --others --directory should not get confused.' \
+    'diff output expected2'
+
 test_done
diff --git a/t/t3401-rebase-partial.sh b/t/t3401-rebase-partial.sh
new file mode 100755 (executable)
index 0000000..32dc9c5
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland
+#
+
+test_description='git rebase should detect patches integrated upstream
+
+This test cherry-picks one local change of two into master branch, and
+checks that git rebase succeeds with only the second patch in the
+local branch.
+'
+. ./test-lib.sh
+
+test_expect_success \
+    'prepare repository with topic branch' \
+    'echo First > A &&
+     git-update-index --add A &&
+     git-commit -m "Add A." &&
+
+     git-checkout -b my-topic-branch &&
+
+     echo Second > B &&
+     git-update-index --add B &&
+     git-commit -m "Add B." &&
+
+     echo AnotherSecond > C &&
+     git-update-index --add C &&
+     git-commit -m "Add C." &&
+
+     git-checkout -f master &&
+
+     echo Third >> A &&
+     git-update-index A &&
+     git-commit -m "Modify A."
+'
+
+test_expect_success \
+    'pick top patch from topic branch into master' \
+    'git-cherry-pick my-topic-branch^0 &&
+     git-checkout -f my-topic-branch
+'
+
+test_debug \
+    'git-cherry master &&
+     git-format-patch -k --stdout --full-index master >/dev/null &&
+     gitk --all & sleep 1
+'
+
+test_expect_success \
+    'rebase topic branch against new master and check git-am did not get halted' \
+    'git-rebase master && test ! -d .dotest'
+
+test_done
diff --git a/t/t3500-cherry.sh b/t/t3500-cherry.sh
new file mode 100755 (executable)
index 0000000..b141f89
--- /dev/null
@@ -0,0 +1,53 @@
+#!/bin/sh
+#
+# Copyright (c) 2006 Yann Dirson, based on t3400 by Amos Waterland
+#
+
+test_description='git-cherry should detect patches integrated upstream
+
+This test cherry-picks one local change of two into master branch, and
+checks that git-cherry only returns the second patch in the local branch
+'
+. ./test-lib.sh
+
+export GIT_AUTHOR_EMAIL=bogus_email_address
+
+test_expect_success \
+    'prepare repository with topic branch, and check cherry finds the 2 patches from there' \
+    'echo First > A &&
+     git-update-index --add A &&
+     git-commit -m "Add A." &&
+
+     git-checkout -b my-topic-branch &&
+
+     echo Second > B &&
+     git-update-index --add B &&
+     git-commit -m "Add B." &&
+
+     sleep 2 &&
+     echo AnotherSecond > C &&
+     git-update-index --add C &&
+     git-commit -m "Add C." &&
+
+     git-checkout -f master &&
+
+     echo Third >> A &&
+     git-update-index A &&
+     git-commit -m "Modify A." &&
+
+     expr "$(echo $(git-cherry master my-topic-branch) )" : "+ [^ ]* + .*"
+'
+
+test_expect_success \
+    'check that cherry with limit returns only the top patch'\
+    'expr "$(echo $(git-cherry master my-topic-branch my-topic-branch^1) )" : "+ [^ ]*"
+'
+
+test_expect_success \
+    'cherry-pick one of the 2 patches, and check cherry recognized one and only one as new' \
+    'git-cherry-pick my-topic-branch^0 &&
+     echo $(git-cherry master my-topic-branch) &&
+     expr "$(echo $(git-cherry master my-topic-branch) )" : "+ [^ ]* - .*"
+'
+
+test_done
index 153b9e49f26502ce6b9d0ceb9ae83839ecc3becc..1292cafd7f1f7fc30b462d4e07be34383e9d6be9 100755 (executable)
@@ -161,4 +161,41 @@ test_expect_success 'pull unrenaming branch into renaming one' \
        }
 '
 
+test_expect_success 'pull conflicting renames' \
+'
+       git reset --hard
+       git show-branch
+       git pull . blue && {
+               echo "BAD: should have conflicted"
+               exit 1
+       }
+       test "$(git ls-files -u A | wc -l)" -eq 1 || {
+               echo "BAD: should have left a stage"
+               exit 1  
+       }
+       test "$(git ls-files -u B | wc -l)" -eq 1 || {
+               echo "BAD: should have left a stage"
+               exit 1  
+       }
+       test "$(git ls-files -u C | wc -l)" -eq 1 || {
+               echo "BAD: should have left a stage"
+               exit 1  
+       }
+       test "$(git ls-files -s N | wc -l)" -eq 1 || {
+               echo "BAD: should have merged N"
+               exit 1  
+       }
+       sed -ne "/^g/{
+       p
+       q
+       }" B | grep red || {
+               echo "BAD: should have listed our change first"
+               exit 1
+       }
+       test "$(git diff white N | wc -l)" -eq 0 || {
+               echo "BAD: should have taken colored branch"
+               exit 1
+       }
+'
+
 test_done