]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'jc/maint-apply-fix' into maint
authorJunio C Hamano <gitster@pobox.com>
Fri, 6 Feb 2009 02:06:11 +0000 (18:06 -0800)
committerJunio C Hamano <gitster@pobox.com>
Fri, 6 Feb 2009 02:06:11 +0000 (18:06 -0800)
* jc/maint-apply-fix:
  builtin-apply.c: do not set bogus mode in check_preimage() for deleted path

47 files changed:
Documentation/RelNotes-1.6.1.2.txt [new file with mode: 0644]
Documentation/config.txt
Documentation/git-ls-tree.txt
Documentation/git-push.txt
Documentation/pull-fetch-param.txt
Documentation/technical/api-strbuf.txt
Documentation/urls.txt
Documentation/user-manual.txt
GIT-VERSION-GEN
Makefile
RelNotes
builtin-apply.c
builtin-commit.c
builtin-gc.c
builtin-grep.c
builtin-log.c
builtin-ls-tree.c
builtin-mv.c
builtin-pack-objects.c
builtin-unpack-objects.c
bundle.c
cache.h
diff.c
diffcore-rename.c
git-sh-setup.sh
http-push.c
http-walker.c
index-pack.c
object.c
object.h
revision.c
setup.c
sha1_file.c
t/t1501-worktree.sh
t/t2300-cd-to-toplevel.sh
t/t4014-format-patch.sh
t/t4015-diff-whitespace.sh
t/t4030-diff-textconv.sh
t/t4114-apply-typechange.sh
t/t5701-clone-local.sh
t/t6014-rev-list-all.sh [new file with mode: 0755]
t/t7001-mv.sh
t/t7002-grep.sh
test-dump-cache-tree.c [moved from dump-cache-tree.c with 100% similarity]
unpack-trees.c
wrapper.c
xdiff/xutils.c

diff --git a/Documentation/RelNotes-1.6.1.2.txt b/Documentation/RelNotes-1.6.1.2.txt
new file mode 100644 (file)
index 0000000..230aa3d
--- /dev/null
@@ -0,0 +1,39 @@
+GIT v1.6.1.2 Release Notes
+==========================
+
+Fixes since v1.6.1.1
+--------------------
+
+* The logic for rename detectin in internal diff used by commands like
+  "git diff" and "git blame" have been optimized to avoid loading the same
+  blob repeatedly.
+
+* We did not allow writing out a blob that is larger than 2GB for no good
+  reason.
+
+* "git format-patch -o $dir", when $dir is a relative directory, used it
+  as relative to the root of the work tree, not relative to the current
+  directory.
+
+* v1.6.1 introduced an optimization for "git push" into a repository (A)
+  that borrows its objects from another repository (B) to avoid sending
+  objects that are available in repository B, when they are not yet used
+  by repository A.  However the code on the "git push" sender side was
+  buggy and did not work when repository B had new objects that are not
+  known by the sender.  This caused pushing into a "forked" repository
+  served by v1.6.1 software using "git push" from v1.6.1 sometimes did not
+  work.  The bug was purely on the "git push" sender side, and has been
+  corrected.
+
+* "git status -v" did not paint its diff output in colour even when
+  color.ui configuration was set.
+
+* "git ls-tree" learned --full-tree option to help Porcelain scripts that
+  want to always see the full path regardless of the current working
+  directory.
+
+* "git grep" incorrectly searched in work tree paths even when they are
+  marked as assume-unchanged.  It now searches in the index entries.
+
+* "git gc" with no grace period needlessly ejected packed but unreachable
+  objects in their loose form, only to delete them right away.
index 26551ea6e1bba817bc272243368e082fecaca2f1..2ed868c81a09af9176bd805f819c0b312556891a 100644 (file)
@@ -702,7 +702,9 @@ gc.packrefs::
 
 gc.pruneexpire::
        When 'git-gc' is run, it will call 'prune --expire 2.weeks.ago'.
-       Override the grace period with this config variable.
+       Override the grace period with this config variable.  The value
+       "now" may be used to disable this  grace period and always prune
+       unreachable objects immediately.
 
 gc.reflogexpire::
        'git-reflog expire' removes reflog entries older than
index 4c7262f1cd82ca8d9ea6be638d23b18d9bba3738..db6ebccd6dc51d9f1463710f29a8f821f13fd412 100644 (file)
@@ -10,7 +10,7 @@ SYNOPSIS
 --------
 [verse]
 'git ls-tree' [-d] [-r] [-t] [-l] [-z]
-           [--name-only] [--name-status] [--full-name] [--abbrev=[<n>]]
+           [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev=[<n>]]
            <tree-ish> [paths...]
 
 DESCRIPTION
@@ -30,6 +30,8 @@ in the current working directory.  Note that:
    'sub/dir' in 'HEAD').  You don't want to give a tree that is not at the
    root level (e.g. 'git ls-tree -r HEAD:sub dir') in this case, as that
    would result in asking for 'sub/sub/dir' in the 'HEAD' commit.
+   However, the current working directory can be ignored by passing
+   --full-tree option.
 
 OPTIONS
 -------
@@ -66,6 +68,10 @@ OPTIONS
        Instead of showing the path names relative to the current working
        directory, show the full path names.
 
+--full-tree::
+       Do not limit the listing to the current working directory.
+       Implies --full-name.
+
 paths::
        When paths are given, show them (note that this isn't really raw
        pathnames, but rather a list of patterns to match).  Otherwise
index 7b27dc60bd5a2e58475d39d0c32cdbd6878aa5bd..7d1eced7d22b8debf46908e39dd6b34b586effe5 100644 (file)
@@ -33,25 +33,27 @@ OPTIONS
        of a remote (see the section <<REMOTES,REMOTES>> below).
 
 <refspec>...::
-       The canonical format of a <refspec> parameter is
-       `+?<src>:<dst>`; that is, an optional plus `{plus}`, followed
-       by the source ref, followed by a colon `:`, followed by
-       the destination ref.
+       The format of a <refspec> parameter is an optional plus
+       `{plus}`, followed by the source ref <src>, followed
+       by a colon `:`, followed by the destination ref <dst>.
+       It is used to specify with what <src> object the <dst> ref
+       in the remote repository is to be updated.
 +
-The <src> side represents the source branch (or arbitrary
-"SHA1 expression", such as `master~4` (four parents before the
-tip of `master` branch); see linkgit:git-rev-parse[1]) that you
-want to push.  The <dst> side represents the destination location.
+The <src> is often the name of the branch you would want to push, but
+it can be any arbitrary "SHA-1 expression", such as `master~4` or
+`HEAD` (see linkgit:git-rev-parse[1]).
 +
-The local ref that matches <src> is used
-to fast forward the remote ref that matches <dst>.  If
-the optional leading plus `+` is used, the remote ref is updated
-even if it does not result in a fast forward update.
+The <dst> tells which ref on the remote side is updated with this
+push. Arbitrary expressions cannot be used here, an actual ref must
+be named. If `:`<dst> is omitted, the same ref as <src> will be
+updated.
 +
-`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
+The object referenced by <src> is used to fast forward the ref <dst>
+on the remote side. If the optional leading plus `{plus}` is used, the
+remote ref is updated even if it does not result in a fast forward
+update.
 +
-A lonely <src> parameter (without a colon and a destination) pushes
-the <src> to the same name in the destination repository.
+`tag <tag>` means the same as `refs/tags/<tag>:refs/tags/<tag>`.
 +
 Pushing an empty <src> allows you to delete the <dst> ref from
 the remote repository.
@@ -190,9 +192,9 @@ git push origin master::
        with it.  If `master` did not exist remotely, it would be
        created.
 
-git push origin :experimental::
-       Find a ref that matches `experimental` in the `origin` repository
-       (e.g. `refs/heads/experimental`), and delete it.
+git push origin HEAD::
+       A handy way to push the current branch to the same name on the
+       remote.
 
 git push origin master:satellite/master dev:satellite/dev::
        Use the source ref that matches `master` (e.g. `refs/heads/master`)
@@ -200,6 +202,11 @@ git push origin master:satellite/master dev:satellite/dev::
        `refs/remotes/satellite/master`) in the `origin` repository, then
        do the same for `dev` and `satellite/dev`.
 
+git push origin HEAD:master::
+       Push the current branch to the remote ref matching `master` in the
+       `origin` repository. This form is convenient to push the current
+       branch without thinking about its local name.
+
 git push origin master:refs/heads/experimental::
        Create the branch `experimental` in the `origin` repository
        by copying the current `master` branch.  This form is only
@@ -207,6 +214,11 @@ git push origin master:refs/heads/experimental::
        the local name and the remote name are different; otherwise,
        the ref name on its own will work.
 
+git push origin :experimental::
+       Find a ref that matches `experimental` in the `origin` repository
+       (e.g. `refs/heads/experimental`), and delete it.
+
+
 Author
 ------
 Written by Junio C Hamano <gitster@pobox.com>, later rewritten in C
index ebdd948cd23931e9bbc35bb304868ce46902e464..f9811f24733bde97b76dc8e695bad82eace5586b 100644 (file)
@@ -5,15 +5,14 @@
        of a remote (see the section <<REMOTES,REMOTES>> below).
 
 <refspec>::
-       The canonical format of a <refspec> parameter is
-       `+?<src>:<dst>`; that is, an optional plus `{plus}`, followed
-       by the source ref, followed by a colon `:`, followed by
-       the destination ref.
+       The format of a <refspec> parameter is an optional plus
+       `{plus}`, followed by the source ref <src>, followed
+       by a colon `:`, followed by the destination ref <dst>.
 +
 The remote ref that matches <src>
 is fetched, and if <dst> is not empty string, the local
 ref that matches it is fast forwarded using <src>.
-Again, if the optional plus `+` is used, the local ref
+If the optional plus `+` is used, the local ref
 is updated even if it does not result in a fast forward
 update.
 +
index a8ee2fe6a1504b943ff9c3c51807bf0f839182b1..985800e43a9b91256c35df60f67c36994142b94c 100644 (file)
@@ -21,7 +21,7 @@ allocated memory or not), use `strbuf_detach()` to unwrap a memory
 buffer from its strbuf shell in a safe way. That is the sole supported
 way. This will give you a malloced buffer that you can later `free()`.
 +
-However, it it totally safe to modify anything in the string pointed by
+However, it is totally safe to modify anything in the string pointed by
 the `buf` member, between the indices `0` and `len-1` (inclusive).
 
 . The `buf` member is a byte array that has at least `len + 1` bytes
index fa34c6747194aaecf9e8124462129b8bbc9ae7d4..5355ebc0f39114823f830e0651078a99f0ac2e70 100644 (file)
@@ -6,10 +6,10 @@ to name the remote repository:
 
 ===============================================================
 - rsync://host.xz/path/to/repo.git/
-- http://host.xz/path/to/repo.git/
-- https://host.xz/path/to/repo.git/
-- git://host.xz/path/to/repo.git/
-- git://host.xz/~user/path/to/repo.git/
+- http://host.xz{startsb}:port{endsb}/path/to/repo.git/
+- https://host.xz{startsb}:port{endsb}/path/to/repo.git/
+- git://host.xz{startsb}:port{endsb}/path/to/repo.git/
+- git://host.xz{startsb}:port{endsb}/~user/path/to/repo.git/
 - ssh://{startsb}user@{endsb}host.xz{startsb}:port{endsb}/path/to/repo.git/
 - ssh://{startsb}user@{endsb}host.xz/path/to/repo.git/
 - ssh://{startsb}user@{endsb}host.xz/~user/path/to/repo.git/
index 19f571ae3bcab2fd96288dfa156062a7fbf89b5e..96af8977f6cae5382728f13116ea24ba2d130bef 100644 (file)
@@ -1507,7 +1507,7 @@ so on a different branch and then coming back), unstash the
 work-in-progress changes.
 
 ------------------------------------------------
-$ git stash "work in progress for foo feature"
+$ git stash save "work in progress for foo feature"
 ------------------------------------------------
 
 This command will save your changes away to the `stash`, and
index fe496e5fca57cba6d00b3d29589dd9c600276bfd..3697edc72e2b47c1262835be205f12f3a6ad687e 100755 (executable)
@@ -1,7 +1,7 @@
 #!/bin/sh
 
 GVF=GIT-VERSION-FILE
-DEF_VER=v1.6.1.1.GIT
+DEF_VER=v1.6.1.2.GIT
 
 LF='
 '
index aabf0130b99bee5204c8e668ba8f40caea77dae2..01242889eb888d35e28249a78d54584ebca4bb24 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1353,7 +1353,7 @@ endif
 
 ### Testing rules
 
-TEST_PROGRAMS = test-chmtime$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-parse-options$X test-path-utils$X
+TEST_PROGRAMS = test-chmtime$X test-dump-cache-tree$X test-genrandom$X test-date$X test-delta$X test-sha1$X test-match-trees$X test-parse-options$X test-path-utils$X
 
 all:: $(TEST_PROGRAMS)
 
index 2ebf251ddf3c4091ad6b55aef86bfccbd1c612f2..da6e81321a332fc7c7229c04e438f4161f27755d 120000 (symlink)
--- a/RelNotes
+++ b/RelNotes
@@ -1 +1 @@
-Documentation/RelNotes-1.6.1.1.txt
\ No newline at end of file
+Documentation/RelNotes-1.6.1.2.txt
\ No newline at end of file
index 8248e09476bafbe07971f6f447ef6677576895bf..58d998577e6d4148ddead9e57bdb0999ff026f73 100644 (file)
@@ -1253,8 +1253,9 @@ static char *inflate_it(const void *data, unsigned long size,
        stream.avail_in = size;
        stream.next_out = out = xmalloc(inflated_size);
        stream.avail_out = inflated_size;
-       inflateInit(&stream);
-       st = inflate(&stream, Z_FINISH);
+       git_inflate_init(&stream);
+       st = git_inflate(&stream, Z_FINISH);
+       git_inflate_end(&stream);
        if ((st != Z_STREAM_END) || stream.total_out != inflated_size) {
                free(out);
                return NULL;
@@ -2435,7 +2436,7 @@ static int check_preimage(struct patch *patch, struct cache_entry **ce, struct s
                return error("%s: %s", old_name, strerror(errno));
        }
 
-       if (!cached)
+       if (!cached && !tpatch)
                st_mode = ce_mode_from_stat(*ce, st->st_mode);
 
        if (patch->is_new < 0)
index 977ea09c51269e897ea09ceb4060661a0278e515..2f0b00a174ff970939d2758334cb8d1dca41cb42 100644 (file)
@@ -865,6 +865,9 @@ int cmd_status(int argc, const char **argv, const char *prefix)
        if (wt_status_use_color == -1)
                wt_status_use_color = git_use_color_default;
 
+       if (diff_use_color_default == -1)
+               diff_use_color_default = git_use_color_default;
+
        argc = parse_and_validate_options(argc, argv, builtin_status_usage, prefix);
 
        index_file = prepare_index(argc, argv, prefix);
@@ -944,6 +947,9 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
 
        git_config(git_commit_config, NULL);
 
+       if (wt_status_use_color == -1)
+               wt_status_use_color = git_use_color_default;
+
        argc = parse_and_validate_options(argc, argv, builtin_commit_usage, prefix);
 
        index_file = prepare_index(argc, argv, prefix);
index 781df601c5f95e874297e0e8bec3fddeb929cc2d..f8eae4adb41d9c338c07aa161e7305bb16742a1e 100644 (file)
@@ -188,7 +188,9 @@ static int need_to_gc(void)
         * there is no need.
         */
        if (too_many_packs())
-               append_option(argv_repack, "-A", MAX_ADD);
+               append_option(argv_repack,
+                             !strcmp(prune_expire, "now") ? "-a" : "-A",
+                             MAX_ADD);
        else if (!too_many_loose_objects())
                return 0;
 
@@ -243,7 +245,9 @@ int cmd_gc(int argc, const char **argv, const char *prefix)
                        "run \"git gc\" manually. See "
                        "\"git help gc\" for more information.\n");
        } else
-               append_option(argv_repack, "-A", MAX_ADD);
+               append_option(argv_repack,
+                             !strcmp(prune_expire, "now") ? "-a" : "-A",
+                             MAX_ADD);
 
        if (pack_refs && run_command_v_opt(argv_pack_refs, RUN_GIT_CMD))
                return error(FAILED_RUN, argv_pack_refs[0]);
index 624f86e287cf6304d122850f8258444c5f916702..3f12ba382690699d96580c3ddb1a61c79520e694 100644 (file)
@@ -20,6 +20,8 @@
 #endif
 #endif
 
+static int builtin_grep;
+
 /*
  * git grep pathspecs are somewhat different from diff-tree pathspecs;
  * pathname wildcards are allowed.
@@ -289,6 +291,8 @@ static int external_grep(struct grep_opt *opt, const char **paths, int cached)
                push_arg("-E");
        if (opt->regflags & REG_ICASE)
                push_arg("-i");
+       if (opt->binary == GREP_BINARY_NOMATCH)
+               push_arg("-I");
        if (opt->word_regexp)
                push_arg("-w");
        if (opt->name_only)
@@ -389,7 +393,7 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
         * we grep through the checked-out files. It tends to
         * be a lot more optimized
         */
-       if (!cached) {
+       if (!cached && !builtin_grep) {
                hit = external_grep(opt, paths, cached);
                if (hit >= 0)
                        return hit;
@@ -402,7 +406,12 @@ static int grep_cache(struct grep_opt *opt, const char **paths, int cached)
                        continue;
                if (!pathspec_matches(paths, ce->name))
                        continue;
-               if (cached) {
+               /*
+                * If CE_VALID is on, we assume worktree file and its cache entry
+                * are identical, even if worktree file has been modified, so use
+                * cache version instead
+                */
+               if (cached || (ce->ce_flags & CE_VALID)) {
                        if (ce_stage(ce))
                                continue;
                        hit |= grep_sha1(opt, ce->sha1, ce->name, 0);
@@ -545,6 +554,10 @@ int cmd_grep(int argc, const char **argv, const char *prefix)
                        cached = 1;
                        continue;
                }
+               if (!strcmp("--no-ext-grep", arg)) {
+                       builtin_grep = 1;
+                       continue;
+               }
                if (!strcmp("-a", arg) ||
                    !strcmp("--text", arg)) {
                        opt.binary = GREP_BINARY_TEXT;
index 4420b4fd4f871d1284b90e80fa58fbe529b61592..60f8dd86048fd3a4ec51d7296b85984a0cefd602 100644 (file)
@@ -553,6 +553,7 @@ static const char *get_oneline_for_filename(struct commit *commit,
 
 static FILE *realstdout = NULL;
 static const char *output_directory = NULL;
+static int outdir_offset;
 
 static int reopen_stdout(const char *oneline, int nr, int total)
 {
@@ -579,7 +580,7 @@ static int reopen_stdout(const char *oneline, int nr, int total)
                strcpy(filename + len, fmt_patch_suffix);
        }
 
-       fprintf(realstdout, "%s\n", filename);
+       fprintf(realstdout, "%s\n", filename + outdir_offset);
        if (freopen(filename, "w", stdout) == NULL)
                return error("Cannot open patch file %s",filename);
 
@@ -740,6 +741,27 @@ static const char *clean_message_id(const char *msg_id)
        return xmemdupz(a, z - a);
 }
 
+static const char *set_outdir(const char *prefix, const char *output_directory)
+{
+       if (output_directory && is_absolute_path(output_directory))
+               return output_directory;
+
+       if (!prefix || !*prefix) {
+               if (output_directory)
+                       return output_directory;
+               /* The user did not explicitly ask for "./" */
+               outdir_offset = 2;
+               return "./";
+       }
+
+       outdir_offset = strlen(prefix);
+       if (!output_directory)
+               return prefix;
+
+       return xstrdup(prefix_filename(prefix, outdir_offset,
+                                      output_directory));
+}
+
 int cmd_format_patch(int argc, const char **argv, const char *prefix)
 {
        struct commit *commit;
@@ -917,8 +939,8 @@ int cmd_format_patch(int argc, const char **argv, const char *prefix)
        if (!DIFF_OPT_TST(&rev.diffopt, TEXT) && !no_binary_diff)
                DIFF_OPT_SET(&rev.diffopt, BINARY);
 
-       if (!output_directory && !use_stdout)
-               output_directory = prefix;
+       if (!use_stdout)
+               output_directory = set_outdir(prefix, output_directory);
 
        if (output_directory) {
                if (use_stdout)
index cb61717685b09a2e409440206e27fce68831e04d..5b63e6eada5cd6de764acef694da624a70ce6dab 100644 (file)
@@ -23,7 +23,7 @@ static int chomp_prefix;
 static const char *ls_tree_prefix;
 
 static const char ls_tree_usage[] =
-       "git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--abbrev[=<n>]] <tree-ish> [path...]";
+       "git ls-tree [-d] [-r] [-t] [-l] [-z] [--name-only] [--name-status] [--full-name] [--full-tree] [--abbrev[=<n>]] <tree-ish> [path...]";
 
 static int show_recursive(const char *base, int baselen, const char *pathname)
 {
@@ -156,6 +156,11 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
                                chomp_prefix = 0;
                                break;
                        }
+                       if (!strcmp(argv[1]+2, "full-tree")) {
+                               ls_tree_prefix = prefix = NULL;
+                               chomp_prefix = 0;
+                               break;
+                       }
                        if (!prefixcmp(argv[1]+2, "abbrev=")) {
                                abbrev = strtoul(argv[1]+9, NULL, 10);
                                if (abbrev && abbrev < MINIMUM_ABBREV)
index bce9959293e30925c4b16c40ac33a3f2e0474e30..01270fefdfb04ed27379b1ca761a811b929ce887 100644 (file)
@@ -162,7 +162,9 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                }
                                argc += last - first;
                        }
-               } else if (lstat(dst, &st) == 0) {
+               } else if (cache_name_pos(src, length) < 0)
+                       bad = "not under version control";
+               else if (lstat(dst, &st) == 0) {
                        bad = "destination exists";
                        if (force) {
                                /*
@@ -177,9 +179,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                } else
                                        bad = "Cannot overwrite";
                        }
-               } else if (cache_name_pos(src, length) < 0)
-                       bad = "not under version control";
-               else if (string_list_has_string(&src_for_dst, dst))
+               } else if (string_list_has_string(&src_for_dst, dst))
                        bad = "multiple sources for the same target";
                else
                        string_list_insert(dst, &src_for_dst);
index cedef52fd3d62a3dd2e439a46579362b22c69642..b616994f4587b9a3d0133b7d6694020743ea0a4d 100644 (file)
@@ -195,16 +195,16 @@ static int check_pack_inflate(struct packed_git *p,
        int st;
 
        memset(&stream, 0, sizeof(stream));
-       inflateInit(&stream);
+       git_inflate_init(&stream);
        do {
                in = use_pack(p, w_curs, offset, &stream.avail_in);
                stream.next_in = in;
                stream.next_out = fakebuf;
                stream.avail_out = sizeof(fakebuf);
-               st = inflate(&stream, Z_FINISH);
+               st = git_inflate(&stream, Z_FINISH);
                offset += stream.next_in - in;
        } while (st == Z_OK || st == Z_BUF_ERROR);
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
        return (st == Z_STREAM_END &&
                stream.total_out == expect &&
                stream.total_in == len) ? 0 : -1;
index 47ed610677fe47f855beaac02f40fa84d132455e..9a773239cabab9998bcea829c0fb2abea9bdb8e8 100644 (file)
@@ -99,10 +99,10 @@ static void *get_data(unsigned long size)
        stream.avail_out = size;
        stream.next_in = fill(1);
        stream.avail_in = len;
-       inflateInit(&stream);
+       git_inflate_init(&stream);
 
        for (;;) {
-               int ret = inflate(&stream, 0);
+               int ret = git_inflate(&stream, 0);
                use(len - stream.avail_in);
                if (stream.total_out == size && ret == Z_STREAM_END)
                        break;
@@ -118,7 +118,7 @@ static void *get_data(unsigned long size)
                stream.next_in = fill(1);
                stream.avail_in = len;
        }
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
        return buf;
 }
 
index daecd8e1cad4a301e2faa3888c561746d029f09d..b20f2101f265786ed61e2ca08764aae249bad9d4 100644 (file)
--- a/bundle.c
+++ b/bundle.c
@@ -240,6 +240,8 @@ int create_bundle(struct bundle_header *header, const char *path,
                return error("unrecognized argument: %s'", argv[i]);
        }
 
+       object_array_remove_duplicates(&revs.pending);
+
        for (i = 0; i < revs.pending.nr; i++) {
                struct object_array_entry *e = revs.pending.objects + i;
                unsigned char sha1[20];
diff --git a/cache.h b/cache.h
index 231c06d7726b575f6e522d5b0c0fe43557e8c651..49e54fbe67e264d787cf98befd905faea68d6367 100644 (file)
--- a/cache.h
+++ b/cache.h
 #define deflateBound(c,s)  ((s) + (((s) + 7) >> 3) + (((s) + 63) >> 6) + 11)
 #endif
 
+void git_inflate_init(z_streamp strm);
+void git_inflate_end(z_streamp strm);
+int git_inflate(z_streamp strm, int flush);
+
 #if defined(DT_UNKNOWN) && !defined(NO_D_TYPE_IN_DIRENT)
 #define DTYPE(de)      ((de)->d_type)
 #else
diff --git a/diff.c b/diff.c
index 5b85b4077a1d3e333d6af86127bf9473b295c837..416c5aa722afc8d10e4bc910e7b297b3eb0a2760 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1999,16 +1999,86 @@ static void run_external_diff(const char *pgm,
        }
 }
 
+static int similarity_index(struct diff_filepair *p)
+{
+       return p->score * 100 / MAX_SCORE;
+}
+
+static void fill_metainfo(struct strbuf *msg,
+                         const char *name,
+                         const char *other,
+                         struct diff_filespec *one,
+                         struct diff_filespec *two,
+                         struct diff_options *o,
+                         struct diff_filepair *p)
+{
+       strbuf_init(msg, PATH_MAX * 2 + 300);
+       switch (p->status) {
+       case DIFF_STATUS_COPIED:
+               strbuf_addf(msg, "similarity index %d%%", similarity_index(p));
+               strbuf_addstr(msg, "\ncopy from ");
+               quote_c_style(name, msg, NULL, 0);
+               strbuf_addstr(msg, "\ncopy to ");
+               quote_c_style(other, msg, NULL, 0);
+               strbuf_addch(msg, '\n');
+               break;
+       case DIFF_STATUS_RENAMED:
+               strbuf_addf(msg, "similarity index %d%%", similarity_index(p));
+               strbuf_addstr(msg, "\nrename from ");
+               quote_c_style(name, msg, NULL, 0);
+               strbuf_addstr(msg, "\nrename to ");
+               quote_c_style(other, msg, NULL, 0);
+               strbuf_addch(msg, '\n');
+               break;
+       case DIFF_STATUS_MODIFIED:
+               if (p->score) {
+                       strbuf_addf(msg, "dissimilarity index %d%%\n",
+                                   similarity_index(p));
+                       break;
+               }
+               /* fallthru */
+       default:
+               /* nothing */
+               ;
+       }
+       if (one && two && hashcmp(one->sha1, two->sha1)) {
+               int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
+
+               if (DIFF_OPT_TST(o, BINARY)) {
+                       mmfile_t mf;
+                       if ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||
+                           (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
+                               abbrev = 40;
+               }
+               strbuf_addf(msg, "index %.*s..%.*s",
+                           abbrev, sha1_to_hex(one->sha1),
+                           abbrev, sha1_to_hex(two->sha1));
+               if (one->mode == two->mode)
+                       strbuf_addf(msg, " %06o", one->mode);
+               strbuf_addch(msg, '\n');
+       }
+       if (msg->len)
+               strbuf_setlen(msg, msg->len - 1);
+}
+
 static void run_diff_cmd(const char *pgm,
                         const char *name,
                         const char *other,
                         const char *attr_path,
                         struct diff_filespec *one,
                         struct diff_filespec *two,
-                        const char *xfrm_msg,
+                        struct strbuf *msg,
                         struct diff_options *o,
-                        int complete_rewrite)
+                        struct diff_filepair *p)
 {
+       const char *xfrm_msg = NULL;
+       int complete_rewrite = (p->status == DIFF_STATUS_MODIFIED) && p->score;
+
+       if (msg) {
+               fill_metainfo(msg, name, other, one, two, o, p);
+               xfrm_msg = msg->len ? msg->buf : NULL;
+       }
+
        if (!DIFF_OPT_TST(o, ALLOW_EXTERNAL))
                pgm = NULL;
        else {
@@ -2048,11 +2118,6 @@ static void diff_fill_sha1_info(struct diff_filespec *one)
                hashclr(one->sha1);
 }
 
-static int similarity_index(struct diff_filepair *p)
-{
-       return p->score * 100 / MAX_SCORE;
-}
-
 static void strip_prefix(int prefix_length, const char **namep, const char **otherp)
 {
        /* Strip the prefix but do not molest /dev/null and absolute paths */
@@ -2066,13 +2131,11 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
 {
        const char *pgm = external_diff();
        struct strbuf msg;
-       char *xfrm_msg;
        struct diff_filespec *one = p->one;
        struct diff_filespec *two = p->two;
        const char *name;
        const char *other;
        const char *attr_path;
-       int complete_rewrite = 0;
 
        name  = p->one->path;
        other = (strcmp(name, p->two->path) ? p->two->path : NULL);
@@ -2082,83 +2145,34 @@ static void run_diff(struct diff_filepair *p, struct diff_options *o)
 
        if (DIFF_PAIR_UNMERGED(p)) {
                run_diff_cmd(pgm, name, NULL, attr_path,
-                            NULL, NULL, NULL, o, 0);
+                            NULL, NULL, NULL, o, p);
                return;
        }
 
        diff_fill_sha1_info(one);
        diff_fill_sha1_info(two);
 
-       strbuf_init(&msg, PATH_MAX * 2 + 300);
-       switch (p->status) {
-       case DIFF_STATUS_COPIED:
-               strbuf_addf(&msg, "similarity index %d%%", similarity_index(p));
-               strbuf_addstr(&msg, "\ncopy from ");
-               quote_c_style(name, &msg, NULL, 0);
-               strbuf_addstr(&msg, "\ncopy to ");
-               quote_c_style(other, &msg, NULL, 0);
-               strbuf_addch(&msg, '\n');
-               break;
-       case DIFF_STATUS_RENAMED:
-               strbuf_addf(&msg, "similarity index %d%%", similarity_index(p));
-               strbuf_addstr(&msg, "\nrename from ");
-               quote_c_style(name, &msg, NULL, 0);
-               strbuf_addstr(&msg, "\nrename to ");
-               quote_c_style(other, &msg, NULL, 0);
-               strbuf_addch(&msg, '\n');
-               break;
-       case DIFF_STATUS_MODIFIED:
-               if (p->score) {
-                       strbuf_addf(&msg, "dissimilarity index %d%%\n",
-                                       similarity_index(p));
-                       complete_rewrite = 1;
-                       break;
-               }
-               /* fallthru */
-       default:
-               /* nothing */
-               ;
-       }
-
-       if (hashcmp(one->sha1, two->sha1)) {
-               int abbrev = DIFF_OPT_TST(o, FULL_INDEX) ? 40 : DEFAULT_ABBREV;
-
-               if (DIFF_OPT_TST(o, BINARY)) {
-                       mmfile_t mf;
-                       if ((!fill_mmfile(&mf, one) && diff_filespec_is_binary(one)) ||
-                           (!fill_mmfile(&mf, two) && diff_filespec_is_binary(two)))
-                               abbrev = 40;
-               }
-               strbuf_addf(&msg, "index %.*s..%.*s",
-                               abbrev, sha1_to_hex(one->sha1),
-                               abbrev, sha1_to_hex(two->sha1));
-               if (one->mode == two->mode)
-                       strbuf_addf(&msg, " %06o", one->mode);
-               strbuf_addch(&msg, '\n');
-       }
-
-       if (msg.len)
-               strbuf_setlen(&msg, msg.len - 1);
-       xfrm_msg = msg.len ? msg.buf : NULL;
-
        if (!pgm &&
            DIFF_FILE_VALID(one) && DIFF_FILE_VALID(two) &&
            (S_IFMT & one->mode) != (S_IFMT & two->mode)) {
-               /* a filepair that changes between file and symlink
+               /*
+                * a filepair that changes between file and symlink
                 * needs to be split into deletion and creation.
                 */
                struct diff_filespec *null = alloc_filespec(two->path);
                run_diff_cmd(NULL, name, other, attr_path,
-                            one, null, xfrm_msg, o, 0);
+                            one, null, &msg, o, p);
                free(null);
+               strbuf_release(&msg);
+
                null = alloc_filespec(one->path);
                run_diff_cmd(NULL, name, other, attr_path,
-                            null, two, xfrm_msg, o, 0);
+                            null, two, &msg, o, p);
                free(null);
        }
        else
                run_diff_cmd(pgm, name, other, attr_path,
-                            one, two, xfrm_msg, o, complete_rewrite);
+                            one, two, &msg, o, p);
 
        strbuf_release(&msg);
 }
index 168a95b541c2d6a4679115ebc9f30b1016645b19..0b0d6b8c8c2ab8833bb5d929ef0d3cb7891ec582 100644 (file)
@@ -153,9 +153,9 @@ static int estimate_similarity(struct diff_filespec *src,
         * is a possible size - we really should have a flag to
         * say whether the size is valid or not!)
         */
-       if (!src->cnt_data && diff_populate_filespec(src, 0))
+       if (!src->cnt_data && diff_populate_filespec(src, 1))
                return 0;
-       if (!dst->cnt_data && diff_populate_filespec(dst, 0))
+       if (!dst->cnt_data && diff_populate_filespec(dst, 1))
                return 0;
 
        max_size = ((src->size > dst->size) ? src->size : dst->size);
@@ -173,6 +173,11 @@ static int estimate_similarity(struct diff_filespec *src,
        if (base_size * (MAX_SCORE-minimum_score) < delta_size * MAX_SCORE)
                return 0;
 
+       if (!src->cnt_data && diff_populate_filespec(src, 0))
+               return 0;
+       if (!dst->cnt_data && diff_populate_filespec(dst, 0))
+               return 0;
+
        delta_limit = (unsigned long)
                (base_size * (MAX_SCORE-minimum_score) / MAX_SCORE);
        if (diffcore_count_changes(src, dst,
index f07d96b9b5e3997b21736893be39ce91950f4878..2142308bcc6d2e2c4962859d18e12070cd4c1b1d 100755 (executable)
@@ -96,7 +96,7 @@ cd_to_toplevel () {
                ..|../*|*/..|*/../*)
                        # Interpret $cdup relative to the physical, not logical, cwd.
                        # Probably /bin/pwd is more portable than passing -P to cd or pwd.
-                       phys="$(/bin/pwd)/$cdup"
+                       phys="$(unset PWD; /bin/pwd)/$cdup"
                        ;;
                *)
                        # There's no "..", so no need to make things absolute.
index 6ad853e2d01b4ee3b3ee282b30b8b7f374ae3d47..cb5bf95a736c571259aef51884cc20e4169bf707 100644 (file)
@@ -209,7 +209,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
        do {
                request->stream.next_out = expn;
                request->stream.avail_out = sizeof(expn);
-               request->zret = inflate(&request->stream, Z_SYNC_FLUSH);
+               request->zret = git_inflate(&request->stream, Z_SYNC_FLUSH);
                git_SHA1_Update(&request->c, expn,
                            sizeof(expn) - request->stream.avail_out);
        } while (request->stream.avail_in && request->zret == Z_OK);
@@ -269,7 +269,7 @@ static void start_fetch_loose(struct transfer_request *request)
 
        memset(&request->stream, 0, sizeof(request->stream));
 
-       inflateInit(&request->stream);
+       git_inflate_init(&request->stream);
 
        git_SHA1_Init(&request->c);
 
@@ -310,7 +310,7 @@ static void start_fetch_loose(struct transfer_request *request)
           file; also rewind to the beginning of the local file. */
        if (prev_read == -1) {
                memset(&request->stream, 0, sizeof(request->stream));
-               inflateInit(&request->stream);
+               git_inflate_init(&request->stream);
                git_SHA1_Init(&request->c);
                if (prev_posn>0) {
                        prev_posn = 0;
@@ -742,7 +742,7 @@ static void finish_request(struct transfer_request *request)
                        if (request->http_code == 416)
                                fprintf(stderr, "Warning: requested range invalid; we may already have all the data.\n");
 
-                       inflateEnd(&request->stream);
+                       git_inflate_end(&request->stream);
                        git_SHA1_Final(request->real_sha1, &request->c);
                        if (request->zret != Z_STREAM_END) {
                                unlink(request->tmpfile);
index 7271c7d19d3b08ef76c9c868ae57f6872f6186d0..0dbad3c888c6c9441af4d9550fd147ecb5b1aaf3 100644 (file)
@@ -82,7 +82,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
        do {
                obj_req->stream.next_out = expn;
                obj_req->stream.avail_out = sizeof(expn);
-               obj_req->zret = inflate(&obj_req->stream, Z_SYNC_FLUSH);
+               obj_req->zret = git_inflate(&obj_req->stream, Z_SYNC_FLUSH);
                git_SHA1_Update(&obj_req->c, expn,
                            sizeof(expn) - obj_req->stream.avail_out);
        } while (obj_req->stream.avail_in && obj_req->zret == Z_OK);
@@ -142,7 +142,7 @@ static void start_object_request(struct walker *walker,
 
        memset(&obj_req->stream, 0, sizeof(obj_req->stream));
 
-       inflateInit(&obj_req->stream);
+       git_inflate_init(&obj_req->stream);
 
        git_SHA1_Init(&obj_req->c);
 
@@ -183,7 +183,7 @@ static void start_object_request(struct walker *walker,
           file; also rewind to the beginning of the local file. */
        if (prev_read == -1) {
                memset(&obj_req->stream, 0, sizeof(obj_req->stream));
-               inflateInit(&obj_req->stream);
+               git_inflate_init(&obj_req->stream);
                git_SHA1_Init(&obj_req->c);
                if (prev_posn>0) {
                        prev_posn = 0;
@@ -243,7 +243,7 @@ static void finish_object_request(struct object_request *obj_req)
                return;
        }
 
-       inflateEnd(&obj_req->stream);
+       git_inflate_end(&obj_req->stream);
        git_SHA1_Final(obj_req->real_sha1, &obj_req->c);
        if (obj_req->zret != Z_STREAM_END) {
                unlink(obj_req->tmpfile);
index 60ed41a993bf9e213b7dfde5ff43528eff6b6252..c0a3d97a1276265d3f253dc396ded9c54d2caf5c 100644 (file)
@@ -275,10 +275,10 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)
        stream.avail_out = size;
        stream.next_in = fill(1);
        stream.avail_in = input_len;
-       inflateInit(&stream);
+       git_inflate_init(&stream);
 
        for (;;) {
-               int ret = inflate(&stream, 0);
+               int ret = git_inflate(&stream, 0);
                use(input_len - stream.avail_in);
                if (stream.total_out == size && ret == Z_STREAM_END)
                        break;
@@ -287,7 +287,7 @@ static void *unpack_entry_data(unsigned long offset, unsigned long size)
                stream.next_in = fill(1);
                stream.avail_in = input_len;
        }
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
        return buf;
 }
 
@@ -382,9 +382,9 @@ static void *get_data_from_pack(struct object_entry *obj)
        stream.avail_out = obj->size;
        stream.next_in = src;
        stream.avail_in = len;
-       inflateInit(&stream);
-       while ((st = inflate(&stream, Z_FINISH)) == Z_OK);
-       inflateEnd(&stream);
+       git_inflate_init(&stream);
+       while ((st = git_inflate(&stream, Z_FINISH)) == Z_OK);
+       git_inflate_end(&stream);
        if (st != Z_STREAM_END || stream.total_out != obj->size)
                die("serious inflate inconsistency");
        free(src);
index 50b6528001fe4bafdfe70126dc2078860c3d1969..7e6a92c88e7b139ec03e0ff26e97e1559a06a220 100644 (file)
--- a/object.c
+++ b/object.c
@@ -268,3 +268,22 @@ void add_object_array_with_mode(struct object *obj, const char *name, struct obj
        objects[nr].mode = mode;
        array->nr = ++nr;
 }
+
+void object_array_remove_duplicates(struct object_array *array)
+{
+       int ref, src, dst;
+       struct object_array_entry *objects = array->objects;
+
+       for (ref = 0; ref < array->nr - 1; ref++) {
+               for (src = ref + 1, dst = src;
+                    src < array->nr;
+                    src++) {
+                       if (!strcmp(objects[ref].name, objects[src].name))
+                               continue;
+                       if (src != dst)
+                               objects[dst] = objects[src];
+                       dst++;
+               }
+               array->nr = dst;
+       }
+}
index d962ff11d1b2f810e21b049c7dbfed104cc199cb..89dd0c47a6c86fd3a63370c84e574e799830e1d3 100644 (file)
--- a/object.h
+++ b/object.h
@@ -82,5 +82,6 @@ int object_list_contains(struct object_list *list, struct object *obj);
 /* Object array handling .. */
 void add_object_array(struct object *obj, const char *name, struct object_array *array);
 void add_object_array_with_mode(struct object *obj, const char *name, struct object_array *array, unsigned mode);
+void object_array_remove_duplicates(struct object_array *);
 
 #endif /* OBJECT_H */
index db60f06c98137f6e6e95727450d2842a0d4fb2a6..b0651845bf627cdfbd0aeebc4abc6366347b2433 100644 (file)
@@ -1263,6 +1263,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
 
                        if (!strcmp(arg, "--all")) {
                                handle_refs(revs, flags, for_each_ref);
+                               handle_refs(revs, flags, head_ref);
                                continue;
                        }
                        if (!strcmp(arg, "--branches")) {
diff --git a/setup.c b/setup.c
index 6b277b6a11d3d8419d79a93628b9923001a065a6..dfda532adc16f5e6d25d7cfc5add3e0e2b6a5209 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -456,7 +456,11 @@ const char *setup_git_directory_gently(int *nongit_ok)
                        inside_git_dir = 1;
                        if (!work_tree_env)
                                inside_work_tree = 0;
-                       setenv(GIT_DIR_ENVIRONMENT, ".", 1);
+                       if (offset != len) {
+                               cwd[offset] = '\0';
+                               setenv(GIT_DIR_ENVIRONMENT, cwd, 1);
+                       } else
+                               setenv(GIT_DIR_ENVIRONMENT, ".", 1);
                        check_repository_format_gently(nongit_ok);
                        return NULL;
                }
index 52d1ead15b4db62138d9cedd5fe04068bcd10461..ced33e837b0acc3863ff86d2d0151951d55f6483 100644 (file)
@@ -1196,8 +1196,8 @@ static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned lon
        stream->avail_out = bufsiz;
 
        if (legacy_loose_object(map)) {
-               inflateInit(stream);
-               return inflate(stream, 0);
+               git_inflate_init(stream);
+               return git_inflate(stream, 0);
        }
 
 
@@ -1217,7 +1217,7 @@ static int unpack_sha1_header(z_stream *stream, unsigned char *map, unsigned lon
        /* Set up the stream for the rest.. */
        stream->next_in = map;
        stream->avail_in = mapsize;
-       inflateInit(stream);
+       git_inflate_init(stream);
 
        /* And generate the fake traditional header */
        stream->total_out = 1 + snprintf(buffer, bufsiz, "%s %lu",
@@ -1254,11 +1254,11 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size
                stream->next_out = buf + bytes;
                stream->avail_out = size - bytes;
                while (status == Z_OK)
-                       status = inflate(stream, Z_FINISH);
+                       status = git_inflate(stream, Z_FINISH);
        }
        buf[size] = 0;
        if (status == Z_STREAM_END && !stream->avail_in) {
-               inflateEnd(stream);
+               git_inflate_end(stream);
                return buf;
        }
 
@@ -1348,15 +1348,15 @@ unsigned long get_size_from_delta(struct packed_git *p,
        stream.next_out = delta_head;
        stream.avail_out = sizeof(delta_head);
 
-       inflateInit(&stream);
+       git_inflate_init(&stream);
        do {
                in = use_pack(p, w_curs, curpos, &stream.avail_in);
                stream.next_in = in;
-               st = inflate(&stream, Z_FINISH);
+               st = git_inflate(&stream, Z_FINISH);
                curpos += stream.next_in - in;
        } while ((st == Z_OK || st == Z_BUF_ERROR) &&
                 stream.total_out < sizeof(delta_head));
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
        if ((st != Z_STREAM_END) && stream.total_out != sizeof(delta_head)) {
                error("delta data unpack-initial failed");
                return 0;
@@ -1585,14 +1585,14 @@ static void *unpack_compressed_entry(struct packed_git *p,
        stream.next_out = buffer;
        stream.avail_out = size;
 
-       inflateInit(&stream);
+       git_inflate_init(&stream);
        do {
                in = use_pack(p, w_curs, curpos, &stream.avail_in);
                stream.next_in = in;
-               st = inflate(&stream, Z_FINISH);
+               st = git_inflate(&stream, Z_FINISH);
                curpos += stream.next_in - in;
        } while (st == Z_OK || st == Z_BUF_ERROR);
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
        if ((st != Z_STREAM_END) || stream.total_out != size) {
                free(buffer);
                return NULL;
@@ -2017,7 +2017,7 @@ static int sha1_loose_object_info(const unsigned char *sha1, unsigned long *size
                status = error("unable to parse %s header", sha1_to_hex(sha1));
        else if (sizep)
                *sizep = size;
-       inflateEnd(&stream);
+       git_inflate_end(&stream);
        munmap(map, mapsize);
        return status;
 }
@@ -2337,7 +2337,8 @@ static int create_tmpfile(char *buffer, size_t bufsiz, const char *filename)
 static int write_loose_object(const unsigned char *sha1, char *hdr, int hdrlen,
                              void *buf, unsigned long len, time_t mtime)
 {
-       int fd, size, ret;
+       int fd, ret;
+       size_t size;
        unsigned char *compressed;
        z_stream stream;
        char *filename;
index f6a6f839a18de4c3775ea965f164d0d20f2bbe9b..27dc6c55d5f50a7fd30388b60230482bad6be2d8 100755 (executable)
@@ -92,6 +92,13 @@ cd sub/dir || exit 1
 test_rev_parse 'in repo.git/sub/dir' false true true sub/dir/
 cd ../../../.. || exit 1
 
+test_expect_success 'detecting gitdir when cwd is in a subdir of gitdir' '
+       (expected=$(pwd)/repo.git &&
+        cd repo.git/refs &&
+        unset GIT_DIR &&
+        test "$expected" = "$(git rev-parse --git-dir)")
+'
+
 test_expect_success 'repo finds its work tree' '
        (cd repo.git &&
         : > work/sub/dir/untracked &&
index beddb4e9f26cb3ade276825a204d950d3173d583..e42cbfe6c61951c6887a363cb668d26a7adcf20c 100755 (executable)
@@ -10,12 +10,12 @@ test_cd_to_toplevel () {
                        cd '"'$1'"' &&
                        . git-sh-setup &&
                        cd_to_toplevel &&
-                       [ "$(/bin/pwd)" = "$TOPLEVEL" ]
+                       [ "$(unset PWD; /bin/pwd)" = "$TOPLEVEL" ]
                )
        '
 }
 
-TOPLEVEL="$(/bin/pwd)/repo"
+TOPLEVEL="$(unset PWD; /bin/pwd)/repo"
 mkdir -p repo/sub/dir
 mv .git repo/
 SUBDIRECTORY_OK=1
index 9d99dc28879d4f7f35001e0785f97f319fe13b40..f045898fe3196b068d03a66fd9edeea6f32add30 100755 (executable)
@@ -3,7 +3,7 @@
 # Copyright (c) 2006 Junio C Hamano
 #
 
-test_description='Format-patch skipping already incorporated patches'
+test_description='various format-patch tests'
 
 . ./test-lib.sh
 
@@ -255,4 +255,54 @@ test_expect_success 'format-patch respects -U' '
 
 '
 
+test_expect_success 'format-patch from a subdirectory (1)' '
+       filename=$(
+               rm -rf sub &&
+               mkdir -p sub/dir &&
+               cd sub/dir &&
+               git format-patch -1
+       ) &&
+       case "$filename" in
+       0*)
+               ;; # ok
+       *)
+               echo "Oops? $filename"
+               false
+               ;;
+       esac &&
+       test -f "$filename"
+'
+
+test_expect_success 'format-patch from a subdirectory (2)' '
+       filename=$(
+               rm -rf sub &&
+               mkdir -p sub/dir &&
+               cd sub/dir &&
+               git format-patch -1 -o ..
+       ) &&
+       case "$filename" in
+       ../0*)
+               ;; # ok
+       *)
+               echo "Oops? $filename"
+               false
+               ;;
+       esac &&
+       basename=$(expr "$filename" : ".*/\(.*\)") &&
+       test -f "sub/$basename"
+'
+
+test_expect_success 'format-patch from a subdirectory (3)' '
+       here="$TEST_DIRECTORY/$test" &&
+       rm -f 0* &&
+       filename=$(
+               rm -rf sub &&
+               mkdir -p sub/dir &&
+               cd sub/dir &&
+               git format-patch -1 -o "$here"
+       ) &&
+       basename=$(expr "$filename" : ".*/\(.*\)") &&
+       test -f "$basename"
+'
+
 test_done
index fc2307eaa3b4e8b1481fd7aa5ae0f93d085338af..6d13da30dad5a78fb17a01e86ef33072ea9e6250 100755 (executable)
@@ -98,6 +98,12 @@ index d99af23..8b32fb5 100644
 EOF
 git diff -w > out
 test_expect_success 'another test, with -w' 'test_cmp expect out'
+git diff -w -b > out
+test_expect_success 'another test, with -w -b' 'test_cmp expect out'
+git diff -w --ignore-space-at-eol > out
+test_expect_success 'another test, with -w --ignore-space-at-eol' 'test_cmp expect out'
+git diff -w -b --ignore-space-at-eol > out
+test_expect_success 'another test, with -w -b --ignore-space-at-eol' 'test_cmp expect out'
 
 tr 'Q' '\015' << EOF > expect
 diff --git a/x b/x
@@ -116,6 +122,27 @@ index d99af23..8b32fb5 100644
 EOF
 git diff -b > out
 test_expect_success 'another test, with -b' 'test_cmp expect out'
+git diff -b --ignore-space-at-eol > out
+test_expect_success 'another test, with -b --ignore-space-at-eol' 'test_cmp expect out'
+
+tr 'Q' '\015' << EOF > expect
+diff --git a/x b/x
+index d99af23..8b32fb5 100644
+--- a/x
++++ b/x
+@@ -1,6 +1,6 @@
+-whitespace at beginning
+-whitespace change
+-whitespace in the middle
++      whitespace at beginning
++whitespace     change
++white space in the middle
+ whitespace at end
+ unchanged line
+ CR at endQ
+EOF
+git diff --ignore-space-at-eol > out
+test_expect_success 'another test, with --ignore-space-at-eol' 'test_cmp expect out'
 
 test_expect_success 'check mixed spaces and tabs in indent' '
 
index 2f27a0ba9ec002b1a6e4d3bd0ed1dc7484d4d14e..a3f0897a52ce2147388baeac6fc64d3b8501b516 100755 (executable)
@@ -104,7 +104,7 @@ cat >expect.typechange <<'EOF'
 -1
 diff --git a/file b/file
 new file mode 120000
-index ad8b3d2..67be421
+index 0000000..67be421
 --- /dev/null
 +++ b/file
 @@ -0,0 +1 @@
index 55334927abb33864a55f8ff49fd0c0c94a3c1769..0f185caa44f3a9d048a2c058d963a1e86e9984fd 100755 (executable)
@@ -25,6 +25,10 @@ test_expect_success 'setup repository and commits' '
        git update-index foo &&
        git commit -m "foo back to file" &&
        git branch foo-back-to-file &&
+       printf "\0" > foo &&
+       git update-index foo &&
+       git commit -m "foo becomes binary" &&
+       git branch foo-becomes-binary &&
        rm -f foo &&
        git update-index --remove foo &&
        mkdir foo &&
@@ -85,6 +89,20 @@ test_expect_success 'symlink becomes file' '
        '
 test_debug 'cat patch'
 
+test_expect_success 'binary file becomes symlink' '
+       git checkout -f foo-becomes-binary &&
+       git diff-tree -p --binary HEAD foo-symlinked-to-bar > patch &&
+       git apply --index < patch
+       '
+test_debug 'cat patch'
+
+test_expect_success 'symlink becomes binary file' '
+       git checkout -f foo-symlinked-to-bar &&
+       git diff-tree -p --binary HEAD foo-becomes-binary > patch &&
+       git apply --index < patch
+       '
+test_debug 'cat patch'
+
 
 test_expect_success 'symlink becomes directory' '
        git checkout -f foo-symlinked-to-bar &&
index 8dfaaa456e115e85e36c438bb998d8053534104e..fe0fda282ca4f085f506c743848966fa6bb93591 100755 (executable)
@@ -11,8 +11,8 @@ test_expect_success 'preparing origin repository' '
        git clone --bare . x &&
        test "$(GIT_CONFIG=a.git/config git config --bool core.bare)" = true &&
        test "$(GIT_CONFIG=x/config git config --bool core.bare)" = true
-       git bundle create b1.bundle --all HEAD &&
-       git bundle create b2.bundle --all &&
+       git bundle create b1.bundle --all &&
+       git bundle create b2.bundle master &&
        mkdir dir &&
        cp b1.bundle dir/b3
        cp b1.bundle b4
diff --git a/t/t6014-rev-list-all.sh b/t/t6014-rev-list-all.sh
new file mode 100755 (executable)
index 0000000..991ab4a
--- /dev/null
@@ -0,0 +1,38 @@
+#!/bin/sh
+
+test_description='--all includes detached HEADs'
+
+. ./test-lib.sh
+
+
+commit () {
+       test_tick &&
+       echo $1 > foo &&
+       git add foo &&
+       git commit -m "$1"
+}
+
+test_expect_success 'setup' '
+
+       commit one &&
+       commit two &&
+       git checkout HEAD^ &&
+       commit detached
+
+'
+
+test_expect_success 'rev-list --all lists detached HEAD' '
+
+       test 3 = $(git rev-list --all | wc -l)
+
+'
+
+test_expect_success 'repack does not lose detached HEAD' '
+
+       git gc &&
+       git prune --expire=now &&
+       git show HEAD
+
+'
+
+test_done
index ef2e78f9df951cfacf5914dfff2a218d2e6f89f7..8fb3a56838dd476b9b0923f835ce70bd95499f2b 100755 (executable)
@@ -55,9 +55,17 @@ test_expect_success \
      git mv -k untracked1 untracked2 path0 &&
      test -f untracked1 &&
      test -f untracked2 &&
-     test ! -f path0/untracked1
+     test ! -f path0/untracked1 &&
      test ! -f path0/untracked2'
 
+test_expect_success \
+    'checking -f on untracked file with existing target' \
+    'touch path0/untracked1 &&
+     git mv -f untracked1 path0
+     test ! -f .git/index.lock &&
+     test -f untracked1 &&
+     test -f path0/untracked1'
+
 # clean up the mess in case bad things happen
 rm -f idontexist untracked1 untracked2 \
      path0/idontexist path0/untracked1 path0/untracked2 \
index 18fe6f2d576d35706b1a712292b58155680cc9dc..c4938544d4ca7c5e7e886a59144c9b10b7971748 100755 (executable)
@@ -161,7 +161,14 @@ test_expect_success 'log grep (6)' '
        git log --author=-0700  --pretty=tformat:%s >actual &&
        >expect &&
        test_cmp expect actual
+'
 
+test_expect_success 'grep with CE_VALID file' '
+       git update-index --assume-unchanged t/t &&
+       rm t/t &&
+       test "$(git grep --no-ext-grep t)" = "t/t:test" &&
+       git update-index --no-assume-unchanged t/t &&
+       git checkout t/t
 '
 
 test_done
similarity index 100%
rename from dump-cache-tree.c
rename to test-dump-cache-tree.c
index 15c9ef592b393410354496c577a6e8c2dfb39940..3a4e181af43add517a7a86511c17e4198552289c 100644 (file)
@@ -240,8 +240,11 @@ static struct cache_entry *create_ce_entry(const struct traverse_info *info, con
        return ce;
 }
 
-static int unpack_nondirectories(int n, unsigned long mask, unsigned long dirmask, struct cache_entry *src[5],
-       const struct name_entry *names, const struct traverse_info *info)
+static int unpack_nondirectories(int n, unsigned long mask,
+                                unsigned long dirmask,
+                                struct cache_entry **src,
+                                const struct name_entry *names,
+                                const struct traverse_info *info)
 {
        int i;
        struct unpack_trees_options *o = info->data;
@@ -291,7 +294,7 @@ static int unpack_nondirectories(int n, unsigned long mask, unsigned long dirmas
 
 static int unpack_callback(int n, unsigned long mask, unsigned long dirmask, struct name_entry *names, struct traverse_info *info)
 {
-       struct cache_entry *src[5] = { NULL, };
+       struct cache_entry *src[MAX_UNPACK_TREES + 1] = { NULL, };
        struct unpack_trees_options *o = info->data;
        const struct name_entry *p = names;
 
index 93562f03eef21b26945d2d9bbdc96818f4de6567..c85ca52ec63a679a2da7bd8980ad4e2df4e38794 100644 (file)
--- a/wrapper.c
+++ b/wrapper.c
@@ -196,3 +196,63 @@ int xmkstemp(char *template)
                die("Unable to create temporary file: %s", strerror(errno));
        return fd;
 }
+
+/*
+ * zlib wrappers to make sure we don't silently miss errors
+ * at init time.
+ */
+void git_inflate_init(z_streamp strm)
+{
+       const char *err;
+
+       switch (inflateInit(strm)) {
+       case Z_OK:
+               return;
+
+       case Z_MEM_ERROR:
+               err = "out of memory";
+               break;
+       case Z_VERSION_ERROR:
+               err = "wrong version";
+               break;
+       default:
+               err = "error";
+       }
+       die("inflateInit: %s (%s)", err, strm->msg ? strm->msg : "no message");
+}
+
+void git_inflate_end(z_streamp strm)
+{
+       if (inflateEnd(strm) != Z_OK)
+               error("inflateEnd: %s", strm->msg ? strm->msg : "failed");
+}
+
+int git_inflate(z_streamp strm, int flush)
+{
+       int ret = inflate(strm, flush);
+       const char *err;
+
+       switch (ret) {
+       /* Out of memory is fatal. */
+       case Z_MEM_ERROR:
+               die("inflate: out of memory");
+
+       /* Data corruption errors: we may want to recover from them (fsck) */
+       case Z_NEED_DICT:
+               err = "needs dictionary"; break;
+       case Z_DATA_ERROR:
+               err = "data stream error"; break;
+       case Z_STREAM_ERROR:
+               err = "stream consistency error"; break;
+       default:
+               err = "unknown error"; break;
+
+       /* Z_BUF_ERROR: normal, needs more space in the output buffer */
+       case Z_BUF_ERROR:
+       case Z_OK:
+       case Z_STREAM_END:
+               return ret;
+       }
+       error("inflate: %s (%s)", err, strm->msg ? strm->msg : "no message");
+       return ret;
+}
index d7974d1a3e612a235b0c8adfde08ba802e782b5a..04ad468702209b77427e635370d41001986042ce 100644 (file)
@@ -245,12 +245,14 @@ static unsigned long xdl_hash_record_with_whitespace(char const **data,
                        while (ptr + 1 < top && isspace(ptr[1])
                                        && ptr[1] != '\n')
                                ptr++;
-                       if (flags & XDF_IGNORE_WHITESPACE_CHANGE
+                       if (flags & XDF_IGNORE_WHITESPACE)
+                               ; /* already handled */
+                       else if (flags & XDF_IGNORE_WHITESPACE_CHANGE
                                        && ptr[1] != '\n') {
                                ha += (ha << 5);
                                ha ^= (unsigned long) ' ';
                        }
-                       if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
+                       else if (flags & XDF_IGNORE_WHITESPACE_AT_EOL
                                        && ptr[1] != '\n') {
                                while (ptr2 != ptr + 1) {
                                        ha += (ha << 5);