Code

Merge branch 'jc/maint-verify-objects-remove-pessimism' into maint-1.7.8
authorJunio C Hamano <gitster@pobox.com>
Mon, 9 Apr 2012 20:43:16 +0000 (13:43 -0700)
committerJunio C Hamano <gitster@pobox.com>
Mon, 9 Apr 2012 20:43:16 +0000 (13:43 -0700)
* jc/maint-verify-objects-remove-pessimism:
  fetch/receive: remove over-pessimistic connectivity check

26 files changed:
.gitignore
Documentation/git-rerere.txt
Documentation/gitweb.txt
Documentation/rev-list-options.txt
Documentation/technical/api-strbuf.txt
Makefile
advice.c
builtin/commit.c
builtin/reset.c
builtin/revert.c
bundle.c
cache-tree.c
cache-tree.h
gitweb/gitweb.perl
merge-recursive.c
remote-curl.c
strbuf.c
strbuf.h
t/Makefile
t/t0090-cache-tree.sh [new file with mode: 0755]
t/t5510-fetch.sh
t/t5541-http-push.sh
t/t5704-bundle.sh
t/t9500-gitweb-standalone-no-errors.sh
test-dump-cache-tree.c
test-scrap-cache-tree.c [new file with mode: 0644]

index 8572c8c0b0199589a8c1875825f5b2e7e4dc4a86..122336c50462d34851d20b5033bfde15232ed83e 100644 (file)
 /test-date
 /test-delta
 /test-dump-cache-tree
+/test-scrap-cache-tree
 /test-genrandom
 /test-index-version
 /test-line-buffer
index a6253ba617f5ebcd82e4cfb1702999c145fa346c..b43b7c8c0ed67fa37e20c41f35a703c28c4d9844 100644 (file)
@@ -8,7 +8,7 @@ git-rerere - Reuse recorded resolution of conflicted merges
 SYNOPSIS
 --------
 [verse]
-'git rerere' ['clear'|'forget' <pathspec>|'diff'|'status'|'gc']
+'git rerere' ['clear'|'forget' <pathspec>|'diff'|'remaining'|'status'|'gc']
 
 DESCRIPTION
 -----------
@@ -37,30 +37,35 @@ its working state.
 
 'clear'::
 
-This resets the metadata used by rerere if a merge resolution is to be
+Reset the metadata used by rerere if a merge resolution is to be
 aborted.  Calling 'git am [--skip|--abort]' or 'git rebase [--skip|--abort]'
 will automatically invoke this command.
 
 'forget' <pathspec>::
 
-This resets the conflict resolutions which rerere has recorded for the current
+Reset the conflict resolutions which rerere has recorded for the current
 conflict in <pathspec>.
 
 'diff'::
 
-This displays diffs for the current state of the resolution.  It is
+Display diffs for the current state of the resolution.  It is
 useful for tracking what has changed while the user is resolving
 conflicts.  Additional arguments are passed directly to the system
 'diff' command installed in PATH.
 
 'status'::
 
-Like 'diff', but this only prints the filenames that will be tracked
-for resolutions.
+Print paths with conflicts whose merge resolution rerere will record.
+
+'remaining'::
+
+Print paths with conflicts that have not been autoresolved by rerere.
+This includes paths whose resolutions cannot be tracked by rerere,
+such as conflicting submodules.
 
 'gc'::
 
-This prunes records of conflicted merges that
+Prune records of conflicted merges that
 occurred a long time ago.  By default, unresolved conflicts older
 than 15 days and resolved conflicts older than 60
 days are pruned.  These defaults are controlled via the
index 605a085326022dec46cf15c0c4e4f435a1bd12bd..168e8bfed644c5f22bfb5e45801884128e306e4a 100644 (file)
@@ -14,7 +14,7 @@ gitweb.
 
 DESCRIPTION
 -----------
-Gitweb provides a web interface to git repositories.  It's features include:
+Gitweb provides a web interface to git repositories.  Its features include:
 
 * Viewing multiple Git repositories with common root.
 * Browsing every revision of the repository.
@@ -60,7 +60,7 @@ to gitweb.  The list of projects is generated by default by scanning the
 more exact; gitweb is not interested in a working area, and is best suited
 to showing "bare" repositories).
 
-The name of repository in gitweb is path to it's `$GIT_DIR` (it's object
+The name of the repository in gitweb is the path to its `$GIT_DIR` (its object
 database) relative to `$projectroot`.  Therefore the repository $repo can be
 found at "$projectroot/$repo".
 
index 39e62072691d408519ff377cb6e91e8d95175ec4..6a4b6355ba91d60ebf2279903a25032256f2063b 100644 (file)
@@ -117,27 +117,27 @@ parents) and `--max-parents=-1` (negative numbers denote no upper limit).
        Pretend as if all the refs in `refs/heads` are listed
        on the command line as '<commit>'. If '<pattern>' is given, limit
        branches to ones matching given shell glob. If pattern lacks '?',
-       '*', or '[', '/*' at the end is implied.
+       '{asterisk}', or '[', '/{asterisk}' at the end is implied.
 
 --tags[=<pattern>]::
 
        Pretend as if all the refs in `refs/tags` are listed
        on the command line as '<commit>'. If '<pattern>' is given, limit
-       tags to ones matching given shell glob. If pattern lacks '?', '*',
-       or '[', '/*' at the end is implied.
+       tags to ones matching given shell glob. If pattern lacks '?', '{asterisk}',
+       or '[', '/{asterisk}' at the end is implied.
 
 --remotes[=<pattern>]::
 
        Pretend as if all the refs in `refs/remotes` are listed
        on the command line as '<commit>'. If '<pattern>' is given, limit
        remote-tracking branches to ones matching given shell glob.
-       If pattern lacks '?', '*', or '[', '/*' at the end is implied.
+       If pattern lacks '?', '{asterisk}', or '[', '/{asterisk}' at the end is implied.
 
 --glob=<glob-pattern>::
        Pretend as if all the refs matching shell glob '<glob-pattern>'
        are listed on the command line as '<commit>'. Leading 'refs/',
-       is automatically prepended if missing. If pattern lacks '?', '*',
-       or '[', '/*' at the end is implied.
+       is automatically prepended if missing. If pattern lacks '?', '{asterisk}',
+       or '[', '/{asterisk}' at the end is implied.
 
 --ignore-missing::
 
index afe27599511c5f6bab6e4f799fd18e7d83bdd454..95a8bf3846b30650f3ee089a4fbadfcc5a42da20 100644 (file)
@@ -255,8 +255,24 @@ same behaviour as well.
 
 `strbuf_getline`::
 
-       Read a line from a FILE* pointer. The second argument specifies the line
+       Read a line from a FILE *, overwriting the existing contents
+       of the strbuf. The second argument specifies the line
        terminator character, typically `'\n'`.
+       Reading stops after the terminator or at EOF.  The terminator
+       is removed from the buffer before returning.  Returns 0 unless
+       there was nothing left before EOF, in which case it returns `EOF`.
+
+`strbuf_getwholeline`::
+
+       Like `strbuf_getline`, but keeps the trailing terminator (if
+       any) in the buffer.
+
+`strbuf_getwholeline_fd`::
+
+       Like `strbuf_getwholeline`, but operates on a file descriptor.
+       It reads one character at a time, so it is very slow.  Do not
+       use it unless you need the correct position in the file
+       descriptor.
 
 `stripspace`::
 
index 3031be5ee63facad10da45271ab04a4be4f3bb68..6295422e10d0ee6440925569617e3d75142d702c 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -435,6 +435,7 @@ TEST_PROGRAMS_NEED_X += test-ctype
 TEST_PROGRAMS_NEED_X += test-date
 TEST_PROGRAMS_NEED_X += test-delta
 TEST_PROGRAMS_NEED_X += test-dump-cache-tree
+TEST_PROGRAMS_NEED_X += test-scrap-cache-tree
 TEST_PROGRAMS_NEED_X += test-genrandom
 TEST_PROGRAMS_NEED_X += test-index-version
 TEST_PROGRAMS_NEED_X += test-line-buffer
index e02e632df380a8e9772d9cd9b1282204c56a7d4e..65a07859f261e12e88d638a1f4546583e0133d4c 100644 (file)
--- a/advice.c
+++ b/advice.c
@@ -21,11 +21,21 @@ static struct {
 
 void advise(const char *advice, ...)
 {
+       struct strbuf buf = STRBUF_INIT;
        va_list params;
+       const char *cp, *np;
 
        va_start(params, advice);
-       vreportf("hint: ", advice, params);
+       strbuf_addf(&buf, advice, params);
        va_end(params);
+
+       for (cp = buf.buf; *cp; cp = np) {
+               np = strchrnul(cp, '\n');
+               fprintf(stderr, _("hint: %.*s\n"), (int)(np - cp), cp);
+               if (*np)
+                       np++;
+       }
+       strbuf_release(&buf);
 }
 
 int git_default_advice_config(const char *var, const char *value)
@@ -46,16 +56,15 @@ int git_default_advice_config(const char *var, const char *value)
 int error_resolve_conflict(const char *me)
 {
        error("'%s' is not possible because you have unmerged files.", me);
-       if (advice_resolve_conflict) {
+       if (advice_resolve_conflict)
                /*
                 * Message used both when 'git commit' fails and when
                 * other commands doing a merge do.
                 */
-               advise("Fix them up in the work tree,");
-               advise("and then use 'git add/rm <file>' as");
-               advise("appropriate to mark resolution and make a commit,");
-               advise("or use 'git commit -a'.");
-       }
+               advise(_("Fix them up in the work tree,\n"
+                        "and then use 'git add/rm <file>' as\n"
+                        "appropriate to mark resolution and make a commit,\n"
+                        "or use 'git commit -a'."));
        return -1;
 }
 
index d8d6dd5eaaa5691a0b5059b9a43dd69761dcf72f..d749cb112a0cff945528cbbfb303bc38db6b69e8 100644 (file)
@@ -394,6 +394,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
                fd = hold_locked_index(&index_lock, 1);
                add_files_to_cache(also ? prefix : NULL, pathspec, 0);
                refresh_cache_or_die(refresh_flags);
+               update_main_cache_tree(1);
                if (write_cache(fd, active_cache, active_nr) ||
                    close_lock_file(&index_lock))
                        die(_("unable to write new_index file"));
@@ -414,6 +415,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix,
                fd = hold_locked_index(&index_lock, 1);
                refresh_cache_or_die(refresh_flags);
                if (active_cache_changed) {
+                       update_main_cache_tree(1);
                        if (write_cache(fd, active_cache, active_nr) ||
                            commit_locked_index(&index_lock))
                                die(_("unable to write new_index file"));
@@ -862,10 +864,7 @@ static int prepare_to_commit(const char *index_file, const char *prefix,
         */
        discard_cache();
        read_cache_from(index_file);
-       if (!active_cache_tree)
-               active_cache_tree = cache_tree();
-       if (cache_tree_update(active_cache_tree,
-                             active_cache, active_nr, 0, 0) < 0) {
+       if (update_main_cache_tree(0)) {
                error(_("Error building trees"));
                return 0;
        }
index 811e8e252c1c6a54e65179557203daf2bc42bdb9..8c2c1d52a227334a3d6456bf0989cd561628ffa0 100644 (file)
@@ -43,6 +43,7 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
        int nr = 1;
        int newfd;
        struct tree_desc desc[2];
+       struct tree *tree;
        struct unpack_trees_options opts;
        struct lock_file *lock = xcalloc(1, sizeof(struct lock_file));
 
@@ -84,6 +85,12 @@ static int reset_index_file(const unsigned char *sha1, int reset_type, int quiet
                return error(_("Failed to find tree of %s."), sha1_to_hex(sha1));
        if (unpack_trees(nr, desc, &opts))
                return -1;
+
+       if (reset_type == MIXED || reset_type == HARD) {
+               tree = parse_tree_indirect(sha1);
+               prime_cache_tree(&active_cache_tree, tree);
+       }
+
        if (write_cache(newfd, active_cache, active_nr) ||
            commit_locked_index(lock))
                return error(_("Could not write new index file."));
index 028bcbcd75d21ada2bc0406ff74e3073014bb41f..00df5266d574ea1f8c9ab745ed606bac566392b5 100644 (file)
@@ -343,11 +343,10 @@ static void print_advice(int show_hint)
                return;
        }
 
-       if (show_hint) {
-               advise("after resolving the conflicts, mark the corrected paths");
-               advise("with 'git add <paths>' or 'git rm <paths>'");
-               advise("and commit the result with 'git commit'");
-       }
+       if (show_hint)
+               advise(_("after resolving the conflicts, mark the corrected paths\n"
+                        "with 'git add <paths>' or 'git rm <paths>'\n"
+                        "and commit the result with 'git commit'"));
 }
 
 static void write_message(struct strbuf *msgbuf, const char *filename)
index 8a1d53ba29a434139123bd7d4e37db47ba8728cb..6c4695eb9103efe3e825ce20303bd220bc6f8827 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -23,23 +23,6 @@ static void add_to_ref_list(const unsigned char *sha1, const char *name,
        list->nr++;
 }
 
-/* Eventually this should go to strbuf.[ch] */
-static int strbuf_readline_fd(struct strbuf *sb, int fd)
-{
-       strbuf_reset(sb);
-
-       while (1) {
-               char ch;
-               ssize_t len = xread(fd, &ch, 1);
-               if (len <= 0)
-                       return len;
-               strbuf_addch(sb, ch);
-               if (ch == '\n')
-                       break;
-       }
-       return 0;
-}
-
 static int parse_bundle_header(int fd, struct bundle_header *header,
                               const char *report_path)
 {
@@ -47,7 +30,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
        int status = 0;
 
        /* The bundle header begins with the signature */
-       if (strbuf_readline_fd(&buf, fd) ||
+       if (strbuf_getwholeline_fd(&buf, fd, '\n') ||
            strcmp(buf.buf, bundle_signature)) {
                if (report_path)
                        error("'%s' does not look like a v2 bundle file",
@@ -57,7 +40,7 @@ static int parse_bundle_header(int fd, struct bundle_header *header,
        }
 
        /* The bundle header ends with an empty line */
-       while (!strbuf_readline_fd(&buf, fd) &&
+       while (!strbuf_getwholeline_fd(&buf, fd, '\n') &&
               buf.len && buf.buf[0] != '\n') {
                unsigned char sha1[20];
                int is_prereq = 0;
@@ -251,7 +234,7 @@ int create_bundle(struct bundle_header *header, const char *path,
        const char **argv_boundary = xmalloc((argc + 4) * sizeof(const char *));
        const char **argv_pack = xmalloc(6 * sizeof(const char *));
        int i, ref_count = 0;
-       char buffer[1024];
+       struct strbuf buf = STRBUF_INIT;
        struct rev_info revs;
        struct child_process rls;
        FILE *rls_fout;
@@ -283,20 +266,21 @@ int create_bundle(struct bundle_header *header, const char *path,
        if (start_command(&rls))
                return -1;
        rls_fout = xfdopen(rls.out, "r");
-       while (fgets(buffer, sizeof(buffer), rls_fout)) {
+       while (strbuf_getwholeline(&buf, rls_fout, '\n') != EOF) {
                unsigned char sha1[20];
-               if (buffer[0] == '-') {
-                       write_or_die(bundle_fd, buffer, strlen(buffer));
-                       if (!get_sha1_hex(buffer + 1, sha1)) {
+               if (buf.len > 0 && buf.buf[0] == '-') {
+                       write_or_die(bundle_fd, buf.buf, buf.len);
+                       if (!get_sha1_hex(buf.buf + 1, sha1)) {
                                struct object *object = parse_object(sha1);
                                object->flags |= UNINTERESTING;
-                               add_pending_object(&revs, object, buffer);
+                               add_pending_object(&revs, object, xstrdup(buf.buf));
                        }
-               } else if (!get_sha1_hex(buffer, sha1)) {
+               } else if (!get_sha1_hex(buf.buf, sha1)) {
                        struct object *object = parse_object(sha1);
                        object->flags |= SHOWN;
                }
        }
+       strbuf_release(&buf);
        fclose(rls_fout);
        if (finish_command(&rls))
                return error("rev-list died");
index f755590da827234830d8b4359720cfbfd87a3dea..8de39590d57e14d08ee4d04b74965191aa905b29 100644 (file)
@@ -150,7 +150,7 @@ void cache_tree_invalidate_path(struct cache_tree *it, const char *path)
 }
 
 static int verify_cache(struct cache_entry **cache,
-                       int entries)
+                       int entries, int silent)
 {
        int i, funny;
 
@@ -159,6 +159,8 @@ static int verify_cache(struct cache_entry **cache,
        for (i = 0; i < entries; i++) {
                struct cache_entry *ce = cache[i];
                if (ce_stage(ce) || (ce->ce_flags & CE_INTENT_TO_ADD)) {
+                       if (silent)
+                               return -1;
                        if (10 < ++funny) {
                                fprintf(stderr, "...\n");
                                break;
@@ -370,10 +372,11 @@ int cache_tree_update(struct cache_tree *it,
                      struct cache_entry **cache,
                      int entries,
                      int missing_ok,
-                     int dryrun)
+                     int dryrun,
+                     int silent)
 {
        int i;
-       i = verify_cache(cache, entries);
+       i = verify_cache(cache, entries, silent);
        if (i)
                return i;
        i = update_one(it, cache, entries, "", 0, missing_ok, dryrun);
@@ -573,7 +576,7 @@ int write_cache_as_tree(unsigned char *sha1, int flags, const char *prefix)
 
                if (cache_tree_update(active_cache_tree,
                                      active_cache, active_nr,
-                                     missing_ok, 0) < 0)
+                                     missing_ok, 0, 0) < 0)
                        return WRITE_TREE_UNMERGED_INDEX;
                if (0 <= newfd) {
                        if (!write_cache(newfd, active_cache, active_nr) &&
@@ -668,3 +671,11 @@ int cache_tree_matches_traversal(struct cache_tree *root,
                return it->entry_count;
        return 0;
 }
+
+int update_main_cache_tree (int silent)
+{
+       if (!the_index.cache_tree)
+               the_index.cache_tree = cache_tree();
+       return cache_tree_update(the_index.cache_tree,
+                                the_index.cache, the_index.cache_nr, 0, 0, silent);
+}
index 3df641f59311f43aa951a2cdfa9f110b97b13a45..0ec0b2a159dfd352ca621322a9ce3715328ab2d0 100644 (file)
@@ -29,7 +29,9 @@ void cache_tree_write(struct strbuf *, struct cache_tree *root);
 struct cache_tree *cache_tree_read(const char *buffer, unsigned long size);
 
 int cache_tree_fully_valid(struct cache_tree *);
-int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int);
+int cache_tree_update(struct cache_tree *, struct cache_entry **, int, int, int, int);
+
+int update_main_cache_tree(int);
 
 /* bitmasks to write_cache_as_tree flags */
 #define WRITE_TREE_MISSING_OK 1
index 874023a33e9162b99bfa5b0e4038b102c129f6f1..6cf38853b5a1577ae0c7df80c39a98f44b22915e 100755 (executable)
@@ -1122,8 +1122,10 @@ sub dispatch {
        if (!defined $action) {
                if (defined $hash) {
                        $action = git_get_type($hash);
+                       $action or die_error(404, "Object does not exist");
                } elsif (defined $hash_base && defined $file_name) {
                        $action = git_get_type("$hash_base:$file_name");
+                       $action or die_error(404, "File or directory does not exist");
                } elsif (defined $project) {
                        $action = 'summary';
                } else {
@@ -2364,7 +2366,7 @@ sub get_feed_info {
        return unless (defined $project);
        # some views should link to OPML, or to generic project feed,
        # or don't have specific feed yet (so they should use generic)
-       return if ($action =~ /^(?:tags|heads|forks|tag|search)$/x);
+       return if (!$action || $action =~ /^(?:tags|heads|forks|tag|search)$/x);
 
        my $branch;
        # branches refs uses 'refs/heads/' prefix (fullname) to differentiate
index cc664c39b66b0bb499dec13a22880a6096423fa6..e22a5195f65cac2872933b668180ceb3c80d3e7c 100644 (file)
@@ -265,7 +265,7 @@ struct tree *write_tree_from_memory(struct merge_options *o)
 
        if (!cache_tree_fully_valid(active_cache_tree) &&
            cache_tree_update(active_cache_tree,
-                             active_cache, active_nr, 0, 0) < 0)
+                             active_cache, active_nr, 0, 0, 0) < 0)
                die("error building trees");
 
        result = lookup_tree(active_cache_tree->sha1);
index 48c20b86f3cfc6c189972718046a6890aaefacf3..25c1af7ab7d0f92321106466cbab3b6632b98252 100644 (file)
@@ -805,7 +805,7 @@ static int push(int nr_spec, char **specs)
 static void parse_push(struct strbuf *buf)
 {
        char **specs = NULL;
-       int alloc_spec = 0, nr_spec = 0, i;
+       int alloc_spec = 0, nr_spec = 0, i, ret;
 
        do {
                if (!prefixcmp(buf->buf, "push ")) {
@@ -822,12 +822,13 @@ static void parse_push(struct strbuf *buf)
                        break;
        } while (1);
 
-       if (push(nr_spec, specs))
-               exit(128); /* error already reported */
-
+       ret = push(nr_spec, specs);
        printf("\n");
        fflush(stdout);
 
+       if (ret)
+               exit(128); /* error already reported */
+
  free_specs:
        for (i = 0; i < nr_spec; i++)
                free(specs[i]);
index 3ad2cc00160fbf24e1e4904bb37ce44e8c414ce5..692cf1bd9a5e7d97d68eb44722afbdd1b59d2cda 100644 (file)
--- a/strbuf.c
+++ b/strbuf.c
@@ -383,6 +383,22 @@ int strbuf_getline(struct strbuf *sb, FILE *fp, int term)
        return 0;
 }
 
+int strbuf_getwholeline_fd(struct strbuf *sb, int fd, int term)
+{
+       strbuf_reset(sb);
+
+       while (1) {
+               char ch;
+               ssize_t len = xread(fd, &ch, 1);
+               if (len <= 0)
+                       return EOF;
+               strbuf_addch(sb, ch);
+               if (ch == term)
+                       break;
+       }
+       return 0;
+}
+
 int strbuf_read_file(struct strbuf *sb, const char *path, size_t hint)
 {
        int fd, len;
index 46a33f8c46985c4377071011d6ea48d6d3fe5331..e42dbe5ac8e632d268916bfbfc2f830159f4a760 100644 (file)
--- a/strbuf.h
+++ b/strbuf.h
@@ -108,6 +108,7 @@ extern int strbuf_readlink(struct strbuf *sb, const char *path, size_t hint);
 
 extern int strbuf_getwholeline(struct strbuf *, FILE *, int);
 extern int strbuf_getline(struct strbuf *, FILE *, int);
+extern int strbuf_getwholeline_fd(struct strbuf *, int, int);
 
 extern void stripspace(struct strbuf *buf, int skip_comments);
 extern int launch_editor(const char *path, struct strbuf *buffer, const char *const *env);
index 9046ec98164f44811b67124e869353db4050ec06..66ceefefccac693d29077ef8020fc4f9dbe7a0bc 100644 (file)
@@ -17,9 +17,9 @@ DEFAULT_TEST_TARGET ?= test
 # Shell quote;
 SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH))
 
-T = $(wildcard t[0-9][0-9][0-9][0-9]-*.sh)
-TSVN = $(wildcard t91[0-9][0-9]-*.sh)
-TGITWEB = $(wildcard t95[0-9][0-9]-*.sh)
+T = $(sort $(wildcard t[0-9][0-9][0-9][0-9]-*.sh))
+TSVN = $(sort $(wildcard t91[0-9][0-9]-*.sh))
+TGITWEB = $(sort $(wildcard t95[0-9][0-9]-*.sh))
 
 all: $(DEFAULT_TEST_TARGET)
 
diff --git a/t/t0090-cache-tree.sh b/t/t0090-cache-tree.sh
new file mode 100755 (executable)
index 0000000..6c33e28
--- /dev/null
@@ -0,0 +1,93 @@
+#!/bin/sh
+
+test_description="Test whether cache-tree is properly updated
+
+Tests whether various commands properly update and/or rewrite the
+cache-tree extension.
+"
+ . ./test-lib.sh
+
+cmp_cache_tree () {
+       test-dump-cache-tree >actual &&
+       sed "s/$_x40/SHA/" <actual >filtered &&
+       test_cmp "$1" filtered
+}
+
+# We don't bother with actually checking the SHA1:
+# test-dump-cache-tree already verifies that all existing data is
+# correct.
+test_shallow_cache_tree () {
+       printf "SHA  (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >expect &&
+       cmp_cache_tree expect
+}
+
+test_invalid_cache_tree () {
+       echo "invalid                                   (0 subtrees)" >expect &&
+       printf "SHA #(ref)  (%d entries, 0 subtrees)\n" $(git ls-files|wc -l) >>expect &&
+       cmp_cache_tree expect
+}
+
+test_no_cache_tree () {
+       : >expect &&
+       cmp_cache_tree expect
+}
+
+test_expect_failure 'initial commit has cache-tree' '
+       test_commit foo &&
+       test_shallow_cache_tree
+'
+
+test_expect_success 'read-tree HEAD establishes cache-tree' '
+       git read-tree HEAD &&
+       test_shallow_cache_tree
+'
+
+test_expect_success 'git-add invalidates cache-tree' '
+       test_when_finished "git reset --hard; git read-tree HEAD" &&
+       echo "I changed this file" > foo &&
+       git add foo &&
+       test_invalid_cache_tree
+'
+
+test_expect_success 'update-index invalidates cache-tree' '
+       test_when_finished "git reset --hard; git read-tree HEAD" &&
+       echo "I changed this file" > foo &&
+       git update-index --add foo &&
+       test_invalid_cache_tree
+'
+
+test_expect_success 'write-tree establishes cache-tree' '
+       test-scrap-cache-tree &&
+       git write-tree &&
+       test_shallow_cache_tree
+'
+
+test_expect_success 'test-scrap-cache-tree works' '
+       git read-tree HEAD &&
+       test-scrap-cache-tree &&
+       test_no_cache_tree
+'
+
+test_expect_success 'second commit has cache-tree' '
+       test_commit bar &&
+       test_shallow_cache_tree
+'
+
+test_expect_success 'reset --hard gives cache-tree' '
+       test-scrap-cache-tree &&
+       git reset --hard &&
+       test_shallow_cache_tree
+'
+
+test_expect_success 'reset --hard without index gives cache-tree' '
+       rm -f .git/index &&
+       git reset --hard &&
+       test_shallow_cache_tree
+'
+
+test_expect_failure 'checkout gives cache-tree' '
+       git checkout HEAD^ &&
+       test_shallow_cache_tree
+'
+
+test_done
index e0af4c4e62c40a563f692361944cc58e2c8e38e2..9d72b16393e3cbee30d16519ae641e84d7485f39 100755 (executable)
@@ -14,6 +14,14 @@ test_bundle_object_count () {
        test "$2" = $(grep '^[0-9a-f]\{40\} ' verify.out | wc -l)
 }
 
+convert_bundle_to_pack () {
+       while read x && test -n "$x"
+       do
+               :;
+       done
+       cat
+}
+
 test_expect_success setup '
        echo >file original &&
        git add file &&
@@ -207,13 +215,7 @@ test_expect_success 'unbundle 1' '
 
 test_expect_success 'bundle 1 has only 3 files ' '
        cd "$D" &&
-       (
-               while read x && test -n "$x"
-               do
-                       :;
-               done
-               cat
-       ) <bundle1 >bundle.pack &&
+       convert_bundle_to_pack <bundle1 >bundle.pack &&
        git index-pack bundle.pack &&
        test_bundle_object_count bundle.pack 3
 '
@@ -230,13 +232,7 @@ test_expect_success 'bundle does not prerequisite objects' '
        git add file2 &&
        git commit -m add.file2 file2 &&
        git bundle create bundle3 -1 HEAD &&
-       (
-               while read x && test -n "$x"
-               do
-                       :;
-               done
-               cat
-       ) <bundle3 >bundle.pack &&
+       convert_bundle_to_pack <bundle3 >bundle.pack &&
        git index-pack bundle.pack &&
        test_bundle_object_count bundle.pack 3
 '
@@ -434,14 +430,31 @@ test_expect_success 'fetch --dry-run' '
 '
 
 test_expect_success "should be able to fetch with duplicate refspecs" '
-        mkdir dups &&
-        cd dups &&
-        git init &&
-        git config branch.master.remote three &&
-        git config remote.three.url ../three/.git &&
-        git config remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
-        git config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
-        git fetch three
+       mkdir dups &&
+       (
+               cd dups &&
+               git init &&
+               git config branch.master.remote three &&
+               git config remote.three.url ../three/.git &&
+               git config remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
+               git config --add remote.three.fetch +refs/heads/*:refs/remotes/origin/* &&
+               git fetch three
+       )
+'
+
+test_expect_success 'all boundary commits are excluded' '
+       test_commit base &&
+       test_commit oneside &&
+       git checkout HEAD^ &&
+       test_commit otherside &&
+       git checkout master &&
+       test_tick &&
+       git merge otherside &&
+       ad=$(git log --no-walk --format=%ad HEAD) &&
+       git bundle create twoside-boundary.bdl master --since="$ad" &&
+       convert_bundle_to_pack <twoside-boundary.bdl >twoside-boundary.pack &&
+       pack=$(git index-pack --fix-thin --stdin <twoside-boundary.pack) &&
+       test_bundle_object_count .git/objects/pack/pack-${pack##pack    }.pack 3
 '
 
 test_done
index 9b85d420c39a0f2192b6b829a6c7912ae28d8e92..d37bc1dc58b320d8ec823bba1c232f191467b195 100755 (executable)
@@ -95,6 +95,32 @@ test_expect_success 'create and delete remote branch' '
        test_must_fail git show-ref --verify refs/remotes/origin/dev
 '
 
+cat >"$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update" <<EOF
+#!/bin/sh
+exit 1
+EOF
+chmod a+x "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
+
+cat >exp <<EOF
+remote: error: hook declined to update refs/heads/dev2
+To http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git
+ ! [remote rejected] dev2 -> dev2 (hook declined)
+error: failed to push some refs to 'http://127.0.0.1:$LIB_HTTPD_PORT/smart/test_repo.git'
+EOF
+
+test_expect_success 'rejected update prints status' '
+       cd "$ROOT_PATH"/test_repo_clone &&
+       git checkout -b dev2 &&
+       : >path4 &&
+       git add path4 &&
+       test_tick &&
+       git commit -m dev2 &&
+       test_must_fail git push origin dev2 2>act &&
+       sed -e "/^remote: /s/ *$//" <act >cmp &&
+       test_cmp exp cmp
+'
+rm -f "$HTTPD_DOCUMENT_ROOT_PATH/test_repo.git/hooks/update"
+
 cat >exp <<EOF
 
 GET  /smart/test_repo.git/info/refs?service=git-upload-pack HTTP/1.1 200
@@ -106,6 +132,8 @@ GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
 GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
 POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
+GET  /smart/test_repo.git/info/refs?service=git-receive-pack HTTP/1.1 200
+POST /smart/test_repo.git/git-receive-pack HTTP/1.1 200
 EOF
 test_expect_success 'used receive-pack service' '
        sed -e "
index 4ae127d106c4a8ada0cea928affeff933bf0dbaa..a51c8b0560f85d31dc73d40a58ae3e4c6655f140 100755 (executable)
@@ -4,59 +4,58 @@ test_description='some bundle related tests'
 . ./test-lib.sh
 
 test_expect_success 'setup' '
-
-       : > file &&
-       git add file &&
-       test_tick &&
-       git commit -m initial &&
+       test_commit initial &&
        test_tick &&
        git tag -m tag tag &&
-       : > file2 &&
-       git add file2 &&
-       : > file3 &&
-       test_tick &&
-       git commit -m second &&
-       git add file3 &&
-       test_tick &&
-       git commit -m third
-
+       test_commit second &&
+       test_commit third &&
+       git tag -d initial &&
+       git tag -d second &&
+       git tag -d third
 '
 
 test_expect_success 'tags can be excluded by rev-list options' '
-
        git bundle create bundle --all --since=7.Apr.2005.15:16:00.-0700 &&
        git ls-remote bundle > output &&
        ! grep tag output
-
 '
 
 test_expect_success 'die if bundle file cannot be created' '
-
        mkdir adir &&
        test_must_fail git bundle create adir --all
-
 '
 
 test_expect_failure 'bundle --stdin' '
-
        echo master | git bundle create stdin-bundle.bdl --stdin &&
        git ls-remote stdin-bundle.bdl >output &&
        grep master output
-
 '
 
 test_expect_failure 'bundle --stdin <rev-list options>' '
-
        echo master | git bundle create hybrid-bundle.bdl --stdin tag &&
        git ls-remote hybrid-bundle.bdl >output &&
        grep master output
-
 '
 
 test_expect_success 'empty bundle file is rejected' '
+       : >empty-bundle &&
+       test_must_fail git fetch empty-bundle
+'
 
-    >empty-bundle && test_must_fail git fetch empty-bundle
-
+# This triggers a bug in older versions where the resulting line (with
+# --pretty=oneline) was longer than a 1024-char buffer.
+test_expect_success 'ridiculously long subject in boundary' '
+       : >file4 &&
+       test_tick &&
+       git add file4 &&
+       printf "%01200d\n" 0 | git commit -F - &&
+       test_commit fifth &&
+       git bundle create long-subject-bundle.bdl HEAD^..HEAD &&
+       git bundle list-heads long-subject-bundle.bdl >heads &&
+       test -s heads &&
+       git fetch long-subject-bundle.bdl &&
+       sed -n "/^-/{p;q}" long-subject-bundle.bdl >boundary &&
+       grep "^-$_x40 " boundary
 '
 
 test_done
index 53297156a314a5b5e03385a3ad887eff959359c4..94365bb0068661d0a964199f91878decb983b986 100755 (executable)
@@ -403,6 +403,14 @@ test_expect_success \
        'path_info: project/branch:dir/' \
        'gitweb_run "" "/.git/master:foo/"'
 
+test_expect_success \
+       'path_info: project/branch (non-existent)' \
+       'gitweb_run "" "/.git/non-existent"'
+
+test_expect_success \
+       'path_info: project/branch:filename (non-existent branch)' \
+       'gitweb_run "" "/.git/non-existent:non-existent"'
+
 test_expect_success \
        'path_info: project/branch:file (non-existent)' \
        'gitweb_run "" "/.git/master:non-existent"'
index 1f73f1ea7dfa6a14dedf384c99751e86c8121ff4..e6c292385f9492ab8a58a693e854025a11b9b045 100644 (file)
@@ -59,6 +59,6 @@ int main(int ac, char **av)
        struct cache_tree *another = cache_tree();
        if (read_cache() < 0)
                die("unable to read index file");
-       cache_tree_update(another, active_cache, active_nr, 0, 1);
+       cache_tree_update(another, active_cache, active_nr, 0, 1, 0);
        return dump_cache_tree(active_cache_tree, another, "");
 }
diff --git a/test-scrap-cache-tree.c b/test-scrap-cache-tree.c
new file mode 100644 (file)
index 0000000..4728013
--- /dev/null
@@ -0,0 +1,17 @@
+#include "cache.h"
+#include "tree.h"
+#include "cache-tree.h"
+
+static struct lock_file index_lock;
+
+int main(int ac, char **av)
+{
+       int fd = hold_locked_index(&index_lock, 1);
+       if (read_cache() < 0)
+               die("unable to read index file");
+       active_cache_tree = NULL;
+       if (write_cache(fd, active_cache, active_nr)
+           || commit_lock_file(&index_lock))
+               die("unable to write index file");
+       return 0;
+}