]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'np/verify-pack' into maint
authorJunio C Hamano <gitster@pobox.com>
Sat, 30 Aug 2008 04:48:02 +0000 (21:48 -0700)
committerJunio C Hamano <gitster@pobox.com>
Sat, 30 Aug 2008 04:48:02 +0000 (21:48 -0700)
* np/verify-pack:
  discard revindex data when pack list changes

40 files changed:
Documentation/RelNotes-1.6.0.1.txt
Documentation/config.txt
Documentation/git.txt
Documentation/gitk.txt
Documentation/gittutorial.txt
Documentation/pretty-formats.txt
Makefile
archive.c
builtin-commit.c
builtin-fast-export.c
builtin-for-each-ref.c
builtin-merge.c
builtin-pack-objects.c
builtin-rev-list.c
cache.h
combine-diff.c
commit.h
contrib/completion/git-completion.bash
contrib/fast-import/git-p4
contrib/fast-import/git-p4.txt
ctype.c
diff.c
help.c
index-pack.c
pack-write.c
pretty.c
read-cache.c
revision.c
revision.h
shell.c
t/t3030-merge-recursive.sh
t/t3300-funny-names.sh
t/t3902-quoted.sh
t/t4015-diff-whitespace.sh
t/t4016-diff-quote.sh
t/t4202-log.sh
t/t6006-rev-list-format.sh
t/t7600-merge.sh
t/t7605-merge-resolve.sh
unpack-trees.c

index bac117e89d5553710d203a2c5adfb12a67962ff2..49d7a1cafabd129e392b48b85a9641b7f5ddb828 100644 (file)
@@ -4,6 +4,9 @@ GIT v1.6.0.1 Release Notes
 Fixes since v1.6.0
 ------------------
 
+* "git diff --cc" did not honor content mangling specified by
+  gitattributes and core.autocrlf when reading from the work tree.
+
 * "git diff --check" incorrectly detected new trailing blank lines when
   whitespace check was in effect.
 
@@ -13,6 +16,8 @@ Fixes since v1.6.0
 * "git format-patch" peeked before the beginning of a string when
   "format.headers" variable is empty (a misconfiguration).
 
+* "git help help" did not work correctly.
+
 * "git mailinfo" (hence "git am") was unhappy when MIME multipart message
   contained garbage after the finishing boundary.
 
@@ -22,10 +27,10 @@ Fixes since v1.6.0
 * "git merge" did not refresh the index correctly when a merge resulted in
   a fast-forward.
 
-Contains other various documentation fixes.
+* "git merge" did not resolve a truly trivial merges that can be done
+  without content level merges.
 
---
-exec >/var/tmp/1
-O=v1.6.0-14-g3a634dc
-echo O=$(git describe maint)
-git shortlog --no-merges $O..maint
+* "git svn dcommit" to a repository with URL that has embedded usernames
+  did not work correctly.
+
+Contains other various documentation fixes.
index 676c39bb8436f35e1471b8dd50fd888ae1ac5c6b..81f981509a2b9c129b31772dee5b859b3f1a2315 100644 (file)
@@ -358,8 +358,13 @@ core.editor::
        `EDITOR` environment variables and then finally `vi`.
 
 core.pager::
-       The command that git will use to paginate output.  Can be overridden
-       with the `GIT_PAGER` environment variable.
+       The command that git will use to paginate output.  Can
+       be overridden with the `GIT_PAGER` environment
+       variable.  Note that git sets the `LESS` environment
+       variable to `FRSX` if it is unset when it runs the
+       pager.  One can change these settings by setting the
+       `LESS` variable to some other value or by giving the
+       `core.pager` option a value such as "`less -+FRSX`".
 
 core.whitespace::
        A comma separated list of common whitespace problems to
@@ -979,9 +984,11 @@ pack.packSizeLimit::
        linkgit:git-repack[1].
 
 pager.<cmd>::
-       Allows to set your own pager preferences for each command, overriding
-       the default. If `\--pager` or `\--no-pager` is specified on the command
-       line, it takes precedence over this option.
+       Allows turning on or off pagination of the output of a
+       particular git subcommand when writing to a tty.  If
+       `\--paginate` or `\--no-pager` is specified on the command line,
+       it takes precedence over this option.  To disable pagination for
+       all commands, set `core.pager` or 'GIT_PAGER' to "`cat`".
 
 pull.octopus::
        The default merge strategy to use when pulling multiple branches
index 1bc295dd547b5375fb7c915efbc91de9130aea2c..363a785452ec13c3e8bd8bd744eb4a4db7fcc991 100644 (file)
@@ -497,7 +497,8 @@ other
 'GIT_PAGER'::
        This environment variable overrides `$PAGER`. If it is set
        to an empty string or to the value "cat", git will not launch
-       a pager.
+       a pager.  See also the `core.pager` option in
+       linkgit:git-config[1].
 
 'GIT_SSH'::
        If this environment variable is set then 'git-fetch'
index 6e827cd11c6d464e1369bf1ca23af0dd53b9be32..ae29a00d591289b0b2534402599fa7a6fe1e3266 100644 (file)
@@ -49,6 +49,13 @@ frequently used options.
        the history between two branches (i.e. the HEAD and the MERGE_HEAD)
        that modify the conflicted files.
 
+--argscmd=<command>::
+       Command to be run each time gitk has to determine the list of
+       <revs> to show.  The command is expected to print on its standard
+       output a list of additional revs to be shown, one per line.
+       Use this instead of explicitly specifying <revs> if the set of
+       commits to show may vary between refreshes.
+
 <revs>::
 
        Limit the revisions to show. This can be either a single revision
index 48d1454a90cf9453e5e3c9fa01b3dbc369a58f1f..384972cb9bb4a04c55bd8c4796bcd3408e44d5e9 100644 (file)
@@ -321,10 +321,37 @@ pulling, like this:
 
 ------------------------------------------------
 alice$ git fetch /home/bob/myrepo master
-alice$ git log -p ..FETCH_HEAD
+alice$ git log -p HEAD..FETCH_HEAD
 ------------------------------------------------
 
 This operation is safe even if Alice has uncommitted local changes.
+The range notation HEAD..FETCH_HEAD" means "show everything that is reachable
+from the FETCH_HEAD but exclude anything that is reachable from HEAD.
+Alice already knows everything that leads to her current state (HEAD),
+and reviewing what Bob has in his state (FETCH_HEAD) that she has not
+seen with this command
+
+If Alice wants to visualize what Bob did since their histories forked
+she can issue the following command:
+
+------------------------------------------------
+$ gitk HEAD..FETCH_HEAD
+------------------------------------------------
+
+This uses the same two-dot range notation we saw earlier with 'git log'.
+
+Alice may want to view what both of them did since they forked.
+She can use three-dot form instead of the two-dot form:
+
+------------------------------------------------
+$ gitk HEAD...FETCH_HEAD
+------------------------------------------------
+
+This means "show everything that is reachable from either one, but
+exclude anything that is reachable from both of them".
+
+Please note that these range notation can be used with both gitk
+and "git log".
 
 After inspecting what Bob did, if there is nothing urgent, Alice may
 decide to continue working without pulling from Bob.  If Bob's history
index c11d4957714db202a012209e2437b9e050a28ae0..388d4925e6bc4bacb708f75437e9aaa216fcb9cc 100644 (file)
@@ -103,7 +103,7 @@ The placeholders are:
 - '%an': author name
 - '%aN': author name (respecting .mailmap)
 - '%ae': author email
-- '%ad': author date
+- '%ad': author date (format respects --date= option)
 - '%aD': author date, RFC2822 style
 - '%ar': author date, relative
 - '%at': author date, UNIX timestamp
index 53ab4b55369652ecbcbd7b2655a9dfc6aeb08336..2cef0187d1d28ef2b466c1231499409f5cc1532f 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -727,6 +727,7 @@ ifeq ($(uname_S),HP-UX)
        NO_UNSETENV = YesPlease
        NO_HSTRERROR = YesPlease
        NO_SYS_SELECT_H = YesPlease
+       SNPRINTF_RETURNS_BOGUS = YesPlease
 endif
 ifneq (,$(findstring MINGW,$(uname_S)))
        NO_MMAP = YesPlease
index 5b40e261f10e42b9f9ee9b4dbfe231765156bf64..e2280df56723809c5af1d566f0721e2639fff10c 100644 (file)
--- a/archive.c
+++ b/archive.c
@@ -48,7 +48,7 @@ static void format_subst(const struct commit *commit,
                strbuf_add(&fmt, b + 8, c - b - 8);
 
                strbuf_add(buf, src, b - src);
-               format_commit_message(commit, fmt.buf, buf);
+               format_commit_message(commit, fmt.buf, buf, DATE_NORMAL);
                len -= c + 1 - src;
                src  = c + 1;
        }
index 649c8beb3e716dd5797787ced61d2fee23b7140f..c870037b07ca00aeeeb369fdae98c9b828be0af2 100644 (file)
@@ -882,7 +882,7 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
 
        if (!log_tree_commit(&rev, commit)) {
                struct strbuf buf = STRBUF_INIT;
-               format_commit_message(commit, "%h: %s", &buf);
+               format_commit_message(commit, "%h: %s", &buf, DATE_NORMAL);
                printf("%s\n", buf.buf);
                strbuf_release(&buf);
        }
index 070971616dbb12d005c5c9a1f82cc5b0c5391f62..7c93eb878d7da87b39959fb9599e4b7b6b81570b 100644 (file)
@@ -417,7 +417,8 @@ static void export_marks(char *file)
        for (i = 0; i < idnums.size; i++) {
                if (deco->base && deco->base->type == 1) {
                        mark = ptr_to_mark(deco->decoration);
-                       fprintf(f, ":%u %s\n", mark, sha1_to_hex(deco->base->sha1));
+                       fprintf(f, ":%"PRIu32" %s\n", mark,
+                               sha1_to_hex(deco->base->sha1));
                }
                deco++;
        }
index 4d25ec51d009bf18f95c60ca9ccd641ac5792db6..21e92bbcb577c0361df51bd81e6fb5ab546619ea 100644 (file)
@@ -652,7 +652,8 @@ static int grab_single_ref(const char *refname, const unsigned char *sha1, int f
                        if ((plen <= namelen) &&
                            !strncmp(refname, p, plen) &&
                            (refname[plen] == '\0' ||
-                            refname[plen] == '/'))
+                            refname[plen] == '/' ||
+                            p[plen-1] == '/'))
                                break;
                        if (!fnmatch(p, refname, FNM_PATHNAME))
                                break;
index a201c6628d6b2c736e53d69ef75accec7d73b4b6..b280444e10d67355da6fd0d9e1a2dd2d7a29d440 100644 (file)
@@ -564,8 +564,6 @@ static int checkout_fast_forward(unsigned char *head, unsigned char *remote)
        struct dir_struct dir;
        struct lock_file *lock_file = xcalloc(1, sizeof(struct lock_file));
 
-       if (read_cache_unmerged())
-               die("you need to resolve your current index first");
        refresh_cache(REFRESH_QUIET);
 
        fd = hold_locked_index(lock_file, 1);
@@ -651,13 +649,15 @@ static void add_strategies(const char *string, unsigned attr)
 static int merge_trivial(void)
 {
        unsigned char result_tree[20], result_commit[20];
-       struct commit_list parent;
+       struct commit_list *parent = xmalloc(sizeof(struct commit_list *));
 
        write_tree_trivial(result_tree);
        printf("Wonderful.\n");
-       parent.item = remoteheads->item;
-       parent.next = NULL;
-       commit_tree(merge_msg.buf, result_tree, &parent, result_commit);
+       parent->item = lookup_commit(head);
+       parent->next = xmalloc(sizeof(struct commit_list *));
+       parent->next->item = remoteheads->item;
+       parent->next->next = NULL;
+       commit_tree(merge_msg.buf, result_tree, parent, result_commit);
        finish(result_commit, "In-index merge");
        drop_save();
        return 0;
@@ -743,6 +743,7 @@ static int evaluate_result(void)
        int cnt = 0;
        struct rev_info rev;
 
+       discard_cache();
        if (read_cache() < 0)
                die("failed to read the cache");
 
@@ -776,7 +777,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
        struct commit_list **remotes = &remoteheads;
 
        setup_work_tree();
-       if (unmerged_cache())
+       if (read_cache_unmerged())
                die("You are in the middle of a conflicted merge.");
 
        /*
@@ -1073,6 +1074,7 @@ int cmd_merge(int argc, const char **argv, const char *prefix)
                }
 
                /* Automerge succeeded. */
+               discard_cache();
                write_tree_trivial(result_tree);
                automerge_was_ok = 1;
                break;
index 2dadec1630c266bbaf42e84810f7059ed5c43b1e..d394c494a55d45a7af6506371f3432374dffe424 100644 (file)
@@ -499,7 +499,6 @@ static void write_pack_file(void)
                } else {
                        int fd = sha1close(f, NULL, 0);
                        fixup_pack_header_footer(fd, sha1, pack_tmp_name, nr_written);
-                       fsync_or_die(fd, pack_tmp_name);
                        close(fd);
                }
 
index 893762c80f4910fadf2d6df414bd835cccb7faaa..c023003b2bb6402f2e8d68c00b9e3a675c0065cd 100644 (file)
@@ -645,7 +645,8 @@ int cmd_rev_list(int argc, const char **argv, const char *prefix)
            revs.diff)
                usage(rev_list_usage);
 
-       save_commit_buffer = revs.verbose_header || revs.grep_filter;
+       save_commit_buffer = revs.verbose_header ||
+               revs.grep_filter.pattern_list;
        if (bisect_list)
                revs.limited = 1;
 
diff --git a/cache.h b/cache.h
index 2475de9fa837596303284157e08b3080d64351ee..884fae826cb8c296520aecbc8c23d9848dacb606 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -222,7 +222,8 @@ struct index_state {
        struct cache_tree *cache_tree;
        time_t timestamp;
        void *alloc;
-       unsigned name_hash_initialized : 1;
+       unsigned name_hash_initialized : 1,
+                initialized : 1;
        struct hash_table name_hash;
 };
 
index 9f80a1c5e3a461afd11966625589684d61187911..4dfc33086755e7ae03310baabd0060149f323f4c 100644 (file)
@@ -727,6 +727,18 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
                                die("early EOF '%s'", elem->path);
 
                        result[len] = 0;
+
+                       /* If not a fake symlink, apply filters, e.g. autocrlf */
+                       if (is_file) {
+                               struct strbuf buf;
+
+                               strbuf_init(&buf, 0);
+                               if (convert_to_git(elem->path, result, len, &buf, safe_crlf)) {
+                                       free(result);
+                                       result = strbuf_detach(&buf, &len);
+                                       result_size = len;
+                               }
+                       }
                }
                else {
                deleted_file:
index 77de9621d9c926c6fb8a2bf9ca81c6c376a2ad41..ecdd5733f989f5931a0af05b387321da7068e9f9 100644 (file)
--- a/commit.h
+++ b/commit.h
@@ -67,7 +67,8 @@ extern int non_ascii(int);
 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
 extern void get_commit_format(const char *arg, struct rev_info *);
 extern void format_commit_message(const struct commit *commit,
-                                  const void *format, struct strbuf *sb);
+                                 const void *format, struct strbuf *sb,
+                                 enum date_mode dmode);
 extern void pretty_print_commit(enum cmit_fmt fmt, const struct commit*,
                                 struct strbuf *,
                                 int abbrev, const char *subject,
index a31004088a969a231972267333ee1cafa1d47233..89858c237eaca5a5fb7e89d716577c0ef84dd086 100755 (executable)
@@ -771,7 +771,7 @@ _git_diff ()
                __gitcomp "--cached --stat --numstat --shortstat --summary
                        --patch-with-stat --name-only --name-status --color
                        --no-color --color-words --no-renames --check
-                       --full-index --binary --abbrev --diff-filter
+                       --full-index --binary --abbrev --diff-filter=
                        --find-copies-harder --pickaxe-all --pickaxe-regex
                        --text --ignore-space-at-eol --ignore-space-change
                        --ignore-all-space --exit-code --quiet --ext-diff
index f9865b444fdf8b21211b04e9dba2999dd90cbc23..46136d49bf99f61a5c85a548bec055742ed140f8 100755 (executable)
@@ -76,7 +76,7 @@ def write_pipe(c, str):
 
 def p4_write_pipe(c, str):
     real_cmd = p4_build_cmd(c)
-    return write_pipe(c, str)
+    return write_pipe(real_cmd, str)
 
 def read_pipe(c, ignore_error=False):
     if verbose:
index ac551d45f10a96a262e8603e72d09c22ade1e40e..49b335921a3871d82a2c0110170a6e66d71561ee 100644 (file)
@@ -3,14 +3,16 @@ git-p4 - Perforce <-> Git converter using git-fast-import
 Usage
 =====
 
-git-p4 supports two main modes: Importing from Perforce to a Git repository is
-done using "git-p4 sync" or "git-p4 rebase". Submitting changes from Git back
-to Perforce is done using "git-p4 submit".
+git-p4 can be used in two different ways:
+
+1) To import changes from Perforce to a Git repository, using "git-p4 sync".
+
+2) To submit changes from Git back to Perforce, using "git-p4 submit".
 
 Importing
 =========
 
-You can simply start with
+Simply start with
 
   git-p4 clone //depot/path/project
 
@@ -18,11 +20,18 @@ or
 
   git-p4 clone //depot/path/project myproject
 
-This will create an empty git repository in a subdirectory called "project" (or
-"myproject" with the second command), import the head revision from the
-specified perforce path into a git "p4" branch (remotes/p4 actually), create a
-master branch off it and check it out. If you want the entire history (not just
-the head revision) then you can simply append a "@all" to the depot path:
+This will:
+
+1) Create an empty git repository in a subdirectory called "project" (or
+"myproject" with the second command)
+
+2) Import the head revision from the given Perforce path into a git branch
+called "p4" (remotes/p4 actually)
+
+3) Create a master branch based on it and check it out.
+
+If you want the entire history (not just the head revision) then you can simply
+append a "@all" to the depot path:
 
   git-p4 clone //depot/project/main@all myproject
 
@@ -37,31 +46,40 @@ If you want more control you can also use the git-p4 sync command directly:
 
 This will import the current head revision of the specified depot path into a
 "remotes/p4/master" branch of your git repository. You can use the
---branch=mybranch option to use a different branch.
+--branch=mybranch option to import into a different branch.
 
-If you want to import the entire history of a given depot path just use
+If you want to import the entire history of a given depot path simply use:
 
   git-p4 sync //path/in/depot@all
 
+
+Note:
+
 To achieve optimal compression you may want to run 'git repack -a -d -f' after
 a big import. This may take a while.
 
-Support for Perforce integrations is still work in progress. Don't bother
-trying it unless you want to hack on it :)
-
 Incremental Imports
 ===================
 
-After an initial import you can easily synchronize your git repository with
-newer changes from the Perforce depot by just calling
+After an initial import you can continue to synchronize your git repository
+with newer changes from the Perforce depot by just calling
 
   git-p4 sync
 
 in your git repository. By default the "remotes/p4/master" branch is updated.
 
-It is recommended to run 'git repack -a -d -f' from time to time when using
-incremental imports to optimally combine the individual git packs that each
-incremental import creates through the use of git-fast-import.
+Advanced Setup
+==============
+
+Suppose you have a periodically updated git repository somewhere, containing a
+complete import of a Perforce project. This repository can be cloned and used
+with git-p4. When updating the cloned repository with the "sync" command,
+git-p4 will try to fetch changes from the original repository first. The git
+protocol used with this is usually faster than importing from Perforce
+directly.
+
+This behaviour can be disabled by setting the "git-p4.syncFromOrigin" git
+configuration variable to "false".
 
 Updating
 ========
@@ -79,7 +97,7 @@ Submitting
 ==========
 
 git-p4 has support for submitting changes from a git repository back to the
-Perforce depot. This requires a Perforce checkout separate to your git
+Perforce depot. This requires a Perforce checkout separate from your git
 repository. To submit all changes that are in the current git branch but not in
 the "p4" branch (or "origin" if "p4" doesn't exist) simply call
 
@@ -97,17 +115,6 @@ continue importing the remaining changes with
 
   git-p4 submit --continue
 
-After submitting you should sync your perforce import branch ("p4" or "origin")
-from Perforce using git-p4's sync command.
-
-If you have changes in your working directory that you haven't committed into
-git yet but that you want to commit to Perforce directly ("quick fixes") then
-you do not have to go through the intermediate step of creating a git commit
-first but you can just call
-
-  git-p4 submit --direct
-
-
 Example
 =======
 
diff --git a/ctype.c b/ctype.c
index ee06eb7f48f1d3e818b3037369b4e056fe7e5be7..d2bd38e9013cdf5c4ab15dbb1770e94e5d6ed2cb 100644 (file)
--- a/ctype.c
+++ b/ctype.c
@@ -5,6 +5,11 @@
  */
 #include "cache.h"
 
+/* Just so that no insane platform contaminate namespace with these symbols */
+#undef SS
+#undef AA
+#undef DD
+
 #define SS GIT_SPACE
 #define AA GIT_ALPHA
 #define DD GIT_DIGIT
diff --git a/diff.c b/diff.c
index f70e6b4912911bd3f3a1d385fce7119a4a8107f6..7b4300a74ab116bdf96ef015322a7533204fd18f 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -1054,6 +1054,13 @@ static long gather_dirstat(FILE *file, struct dirstat_dir *dir, unsigned long ch
        return this_dir;
 }
 
+static int dirstat_compare(const void *_a, const void *_b)
+{
+       const struct dirstat_file *a = _a;
+       const struct dirstat_file *b = _b;
+       return strcmp(a->name, b->name);
+}
+
 static void show_dirstat(struct diff_options *options)
 {
        int i;
@@ -1113,6 +1120,7 @@ static void show_dirstat(struct diff_options *options)
                return;
 
        /* Show all directories with more than x% of the changes */
+       qsort(dir.files, dir.nr, sizeof(dir.files[0]), dirstat_compare);
        gather_dirstat(options->file, &dir, changed, "", 0);
 }
 
diff --git a/help.c b/help.c
index 3cb19628965685ce59a5377b81bef975851996e8..dc0786d8002ef633cae4485eb5b25cdb6cf17df4 100644 (file)
--- a/help.c
+++ b/help.c
@@ -555,7 +555,8 @@ static int is_git_command(const char *s)
 {
        load_command_list();
        return is_in_cmdlist(&main_cmds, s) ||
-               is_in_cmdlist(&other_cmds, s);
+               is_in_cmdlist(&other_cmds, s) ||
+               !strcmp(s, "help");
 }
 
 static const char *prepend(const char *prefix, const char *cmd)
index 52064befdbbbdf671bd08e369a133d4f1fee03c1..728af7da9c87646a869af5da5444943c0c66f89e 100644 (file)
@@ -876,7 +876,9 @@ int main(int argc, char **argv)
        char *index_name_buf = NULL, *keep_name_buf = NULL;
        struct pack_idx_entry **idx_objects;
        unsigned char sha1[20];
+       int nongit = 0;
 
+       setup_git_directory_gently(&nongit);
        git_config(git_index_pack_config, NULL);
 
        for (i = 1; i < argc; i++) {
index a8f02699366c87de960d7637e9f69c26c2241693..ddcfd37af263a5fe1009473cba879b00f4b6692d 100644 (file)
@@ -179,6 +179,7 @@ void fixup_pack_header_footer(int pack_fd,
 
        SHA1_Final(pack_file_sha1, &c);
        write_or_die(pack_fd, pack_file_sha1, 20);
+       fsync_or_die(pack_fd, pack_name);
 }
 
 char *index_pack_lockfile(int ip_out)
index 33ef34a4119812674726254fee3f391fb5734fdb..a29c290009587a12cdc6aec335d508d29481e697 100644 (file)
--- a/pretty.c
+++ b/pretty.c
@@ -310,7 +310,7 @@ static int mailmap_name(struct strbuf *sb, const char *email)
 }
 
 static size_t format_person_part(struct strbuf *sb, char part,
-                               const char *msg, int len)
+                                const char *msg, int len, enum date_mode dmode)
 {
        /* currently all placeholders have same length */
        const int placeholder_len = 2;
@@ -377,7 +377,7 @@ static size_t format_person_part(struct strbuf *sb, char part,
 
        switch (part) {
        case 'd':       /* date */
-               strbuf_addstr(sb, show_date(date, tz, DATE_NORMAL));
+               strbuf_addstr(sb, show_date(date, tz, dmode));
                return placeholder_len;
        case 'D':       /* date, RFC2822 style */
                strbuf_addstr(sb, show_date(date, tz, DATE_RFC2822));
@@ -409,6 +409,7 @@ struct chunk {
 
 struct format_commit_context {
        const struct commit *commit;
+       enum date_mode dmode;
 
        /* These offsets are relative to the start of the commit message. */
        int commit_header_parsed;
@@ -584,10 +585,12 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
                return 1;
        case 'a':       /* author ... */
                return format_person_part(sb, placeholder[1],
-                                  msg + c->author.off, c->author.len);
+                                  msg + c->author.off, c->author.len,
+                                  c->dmode);
        case 'c':       /* committer ... */
                return format_person_part(sb, placeholder[1],
-                                  msg + c->committer.off, c->committer.len);
+                                  msg + c->committer.off, c->committer.len,
+                                  c->dmode);
        case 'e':       /* encoding */
                strbuf_add(sb, msg + c->encoding.off, c->encoding.len);
                return 1;
@@ -599,12 +602,14 @@ static size_t format_commit_item(struct strbuf *sb, const char *placeholder,
 }
 
 void format_commit_message(const struct commit *commit,
-                           const void *format, struct strbuf *sb)
+                          const void *format, struct strbuf *sb,
+                          enum date_mode dmode)
 {
        struct format_commit_context context;
 
        memset(&context, 0, sizeof(context));
        context.commit = commit;
+       context.dmode = dmode;
        strbuf_expand(sb, format, format_commit_item, &context);
 }
 
@@ -770,7 +775,7 @@ void pretty_print_commit(enum cmit_fmt fmt, const struct commit *commit,
        const char *encoding;
 
        if (fmt == CMIT_FMT_USERFORMAT) {
-               format_commit_message(commit, user_format, sb);
+               format_commit_message(commit, user_format, sb, dmode);
                return;
        }
 
index 2c03ec3069decb20f7557af4ac7dbe295f2dcf9c..35fec468b1951cc17606fca8edc47f809471f652 100644 (file)
@@ -1155,7 +1155,7 @@ int read_index_from(struct index_state *istate, const char *path)
        size_t mmap_size;
 
        errno = EBUSY;
-       if (istate->alloc)
+       if (istate->initialized)
                return istate->cache_nr;
 
        errno = ENOENT;
@@ -1195,6 +1195,7 @@ int read_index_from(struct index_state *istate, const char *path)
         * index size
         */
        istate->alloc = xmalloc(estimate_cache_size(mmap_size, istate->cache_nr));
+       istate->initialized = 1;
 
        src_offset = sizeof(*hdr);
        dst_offset = 0;
@@ -1247,6 +1248,7 @@ int discard_index(struct index_state *istate)
        cache_tree_free(&(istate->cache_tree));
        free(istate->alloc);
        istate->alloc = NULL;
+       istate->initialized = 0;
 
        /* no need to throw away allocated active_cache */
        return 0;
index e75079a6e1316c74b4dff702170134dc7559898f..36291b6b864a1213841aba91d58693324d1c88c7 100644 (file)
@@ -782,6 +782,10 @@ void init_revisions(struct rev_info *revs, const char *prefix)
 
        revs->commit_format = CMIT_FMT_DEFAULT;
 
+       revs->grep_filter.status_only = 1;
+       revs->grep_filter.pattern_tail = &(revs->grep_filter.pattern_list);
+       revs->grep_filter.regflags = REG_NEWLINE;
+
        diff_setup(&revs->diffopt);
        if (prefix && !revs->diffopt.prefix) {
                revs->diffopt.prefix = prefix;
@@ -946,15 +950,7 @@ void read_revisions_from_stdin(struct rev_info *revs)
 
 static void add_grep(struct rev_info *revs, const char *ptn, enum grep_pat_token what)
 {
-       if (!revs->grep_filter) {
-               struct grep_opt *opt = xcalloc(1, sizeof(*opt));
-               opt->status_only = 1;
-               opt->pattern_tail = &(opt->pattern_list);
-               opt->regflags = REG_NEWLINE;
-               revs->grep_filter = opt;
-       }
-       append_grep_pattern(revs->grep_filter, ptn,
-                           "command line", 0, what);
+       append_grep_pattern(&revs->grep_filter, ptn, "command line", 0, what);
 }
 
 static void add_header_grep(struct rev_info *revs, const char *field, const char *pattern)
@@ -1164,17 +1160,13 @@ static int handle_revision_opt(struct rev_info *revs, int argc, const char **arg
        } else if (!prefixcmp(arg, "--grep=")) {
                add_message_grep(revs, arg+7);
        } else if (!strcmp(arg, "--extended-regexp") || !strcmp(arg, "-E")) {
-               if (revs->grep_filter)
-                       revs->grep_filter->regflags |= REG_EXTENDED;
+               revs->grep_filter.regflags |= REG_EXTENDED;
        } else if (!strcmp(arg, "--regexp-ignore-case") || !strcmp(arg, "-i")) {
-               if (revs->grep_filter)
-                       revs->grep_filter->regflags |= REG_ICASE;
+               revs->grep_filter.regflags |= REG_ICASE;
        } else if (!strcmp(arg, "--fixed-strings") || !strcmp(arg, "-F")) {
-               if (revs->grep_filter)
-                       revs->grep_filter->fixed = 1;
+               revs->grep_filter.fixed = 1;
        } else if (!strcmp(arg, "--all-match")) {
-               if (revs->grep_filter)
-                       revs->grep_filter->all_match = 1;
+               revs->grep_filter.all_match = 1;
        } else if (!prefixcmp(arg, "--encoding=")) {
                arg += 11;
                if (strcmp(arg, "none"))
@@ -1349,9 +1341,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
        if (diff_setup_done(&revs->diffopt) < 0)
                die("diff_setup_done failed");
 
-       if (revs->grep_filter) {
-               compile_grep_patterns(revs->grep_filter);
-       }
+       compile_grep_patterns(&revs->grep_filter);
 
        if (revs->reverse && revs->reflog_info)
                die("cannot combine --reverse with --walk-reflogs");
@@ -1492,9 +1482,9 @@ static int rewrite_parents(struct rev_info *revs, struct commit *commit)
 
 static int commit_match(struct commit *commit, struct rev_info *opt)
 {
-       if (!opt->grep_filter)
+       if (!opt->grep_filter.pattern_list)
                return 1;
-       return grep_buffer(opt->grep_filter,
+       return grep_buffer(&opt->grep_filter,
                           NULL, /* we say nothing, not even filename */
                           commit->buffer, strlen(commit->buffer));
 }
index 1b045669ae05519a9f2023e5ccdfa4f75f2c7f29..91f194478bb91d381ab2b2440215144d8bb8d18d 100644 (file)
@@ -2,6 +2,7 @@
 #define REVISION_H
 
 #include "parse-options.h"
+#include "grep.h"
 
 #define SEEN           (1u<<0)
 #define UNINTERESTING   (1u<<1)
@@ -92,7 +93,7 @@ struct rev_info {
        int             show_log_size;
 
        /* Filter by commit log message */
-       struct grep_opt *grep_filter;
+       struct grep_opt grep_filter;
 
        /* Display history graph */
        struct git_graph *graph;
diff --git a/shell.c b/shell.c
index 6a48de05ff80f86050715ef3dab87a48b0a86ac9..ad60200d28e9957f54a34435f5dc59fce412666c 100644 (file)
--- a/shell.c
+++ b/shell.c
@@ -56,6 +56,19 @@ int main(int argc, char **argv)
 {
        char *prog;
        struct commands *cmd;
+       int devnull_fd;
+
+       /*
+        * Always open file descriptors 0/1/2 to avoid clobbering files
+        * in die().  It also avoids not messing up when the pipes are
+        * dup'ed onto stdin/stdout/stderr in the child processes we spawn.
+        */
+       devnull_fd = open("/dev/null", O_RDWR);
+       while (devnull_fd >= 0 && devnull_fd <= 2)
+               devnull_fd = dup(devnull_fd);
+       if (devnull_fd == -1)
+               die("opening /dev/null failed (%s)", strerror(errno));
+       close (devnull_fd);
 
        /*
         * Special hack to pretend to be a CVS server
index aff360303ae2a304bff4799def6906defdb85843..f2880152b019f4d77e3b743d7a7b02ba6d197d11 100755 (executable)
@@ -269,6 +269,17 @@ test_expect_success 'merge-recursive result' '
 
 '
 
+test_expect_success 'fail if the index has unresolved entries' '
+
+       rm -fr [abcd] &&
+       git checkout -f "$c1" &&
+
+       test_must_fail git merge "$c5" &&
+       test_must_fail git merge "$c5" 2> out &&
+       grep "You are in the middle of a conflicted merge" out
+
+'
+
 test_expect_success 'merge-recursive remove conflict' '
 
        rm -fr [abcd] &&
index 0574ef1f101df172a30755726b0ea1b6c2ef5f7d..db46d53e8271c0410a0dbf53a3560a8b635e2853 100755 (executable)
@@ -21,7 +21,7 @@ cat >"$p0" <<\EOF
 3. A quick brown fox jumps over the lazy cat, oops dog.
 EOF
 
-cat >"$p1" "$p0"
+cat 2>/dev/null >"$p1" "$p0"
 echo 'Foo Bar Baz' >"$p2"
 
 test -f "$p1" && cmp "$p0" "$p1" || {
index fe4fb5116ac4c482c357f0af3f0a34da27cee237..58680524258037eb0c17f7e2929d58ed1c16b574 100755 (executable)
@@ -7,12 +7,6 @@ test_description='quoted output'
 
 . ./test-lib.sh
 
-P1='pathname   with HT'
-: >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || {
-       echo >&2 'Filesystem does not support HT in names'
-       test_done
-}
-
 FN='濱野'
 GN='純'
 HT='   '
@@ -20,7 +14,7 @@ LF='
 '
 DQ='"'
 
-echo foo > "Name and an${HT}HT"
+echo foo 2>/dev/null > "Name and an${HT}HT"
 test -f "Name and an${HT}HT" || {
        # since FAT/NTFS does not allow tabs in filenames, skip this test
        say 'Your filesystem does not allow tabs in filenames, test skipped.'
index ec98509fd2144121e599edd6a85217840041f321..b1cbd36d1710a38b94838a2fdf08e0e5ded431f8 100755 (executable)
@@ -352,4 +352,20 @@ test_expect_success 'checkdiff allows new blank lines' '
        git diff --check
 '
 
+test_expect_success 'combined diff with autocrlf conversion' '
+
+       git reset --hard &&
+       echo >x hello &&
+       git commit -m "one side" x &&
+       git checkout HEAD^ &&
+       echo >x goodbye &&
+       git commit -m "the other side" x &&
+       git config core.autocrlf true &&
+       test_must_fail git merge master &&
+
+       git diff | sed -e "1,/^@@@/d" >actual &&
+       ! grep "^-" actual
+
+'
+
 test_done
index f07035ab7ec72557be7a0cba9ea286bcbaa79da9..55eb5f83f17c0ebfb537d390fd3913b7c89d65f4 100755 (executable)
@@ -13,8 +13,8 @@ P1='pathname  with HT'
 P2='pathname with SP'
 P3='pathname
 with LF'
-: >"$P1" 2>&1 && test -f "$P1" && rm -f "$P1" || {
-       echo >&2 'Filesystem does not support tabs in names'
+: 2>/dev/null >"$P1" && test -f "$P1" && rm -f "$P1" || {
+       say 'Your filesystem does not allow tabs in filenames, test skipped.'
        test_done
 }
 
index 4c8af45f834d034529c2a627768a0a3e6f1aac8d..0ab925c4e4710a560f0d35e47ccdda8ddb2b8212 100755 (executable)
@@ -69,7 +69,29 @@ test_expect_success 'diff-filter=D' '
 
 '
 
+test_expect_success 'setup case sensitivity tests' '
+       echo case >one &&
+       test_tick &&
+       git commit -a -m Second
+'
+
+test_expect_success 'log --grep' '
+       echo second >expect &&
+       git log -1 --pretty="tformat:%s" --grep=sec >actual &&
+       test_cmp expect actual
+'
 
+test_expect_success 'log -i --grep' '
+       echo Second >expect &&
+       git log -1 --pretty="tformat:%s" -i --grep=sec >actual &&
+       test_cmp expect actual
+'
+
+test_expect_success 'log --grep -i' '
+       echo Second >expect &&
+       git log -1 --pretty="tformat:%s" --grep=sec -i >actual &&
+       test_cmp expect actual
+'
 
 test_done
 
index 9176484db2f78122f71c0f11889e01382effcfb9..485ad4d44a6b9714c1986d6cff9c02263e1eb0f1 100755 (executable)
@@ -139,6 +139,12 @@ commit 131a310eb913d107dd3c09a65d1651175898735d
 commit 86c75cfd708a0e5868dc876ed5b8bb66c80b4873
 EOF
 
+test_expect_success '%ad respects --date=' '
+       echo 2005-04-07 >expect.ad-short &&
+       git log -1 --date=short --pretty=tformat:%ad >output.ad-short master &&
+       test_cmp expect.ad-short output.ad-short
+'
+
 test_expect_success 'empty email' '
        test_tick &&
        C=$(GIT_AUTHOR_EMAIL= git commit-tree HEAD^{tree} </dev/null) &&
index fee8fb77d48ef7d4fa08e77f879718d7ab5b1bc0..dbc90bc41625fccb4119cd6c2fc49668fe784122 100755 (executable)
@@ -498,4 +498,13 @@ test_expect_success 'merge fast-forward in a dirty tree' '
 
 test_debug 'gitk --all'
 
+test_expect_success 'in-index merge' '
+       git reset --hard c0 &&
+       git merge --no-ff -s resolve c1 > out &&
+       grep "Wonderful." out &&
+       verify_parents $c0 $c1
+'
+
+test_debug 'gitk --all'
+
 test_done
index ee21a107fd99e35b9d6325a040b7549b7a6c2502..f1f86ddb2381ce70e6845298e86ed96d6399fdf9 100755 (executable)
@@ -36,7 +36,9 @@ test_expect_success 'merge c1 to c2' '
        git diff --exit-code &&
        test -f c0.c &&
        test -f c1.c &&
-       test -f c2.c
+       test -f c2.c &&
+       test 3 = $(git ls-tree -r HEAD | wc -l) &&
+       test 3 = $(git ls-files | wc -l)
 '
 
 test_expect_success 'merge c2 to c3 (fails)' '
index cba0aca062f201c5cd5f8799f2190d4a6f06e7c7..ef21c62195d61980d4727e3f6d9c285422fcfe91 100644 (file)
@@ -376,6 +376,7 @@ int unpack_trees(unsigned len, struct tree_desc *t, struct unpack_trees_options
        state.refresh_cache = 1;
 
        memset(&o->result, 0, sizeof(o->result));
+       o->result.initialized = 1;
        if (o->src_index)
                o->result.timestamp = o->src_index->timestamp;
        o->merge_size = len;