]> rtime.felk.cvut.cz Git - git.git/commitdiff
Merge branch 'ks/maint-1.6.0-mailinfo-folded' into maint-1.6.0
authorJunio C Hamano <gitster@pobox.com>
Fri, 13 Mar 2009 04:48:43 +0000 (21:48 -0700)
committerJunio C Hamano <gitster@pobox.com>
Fri, 13 Mar 2009 04:48:43 +0000 (21:48 -0700)
* ks/maint-1.6.0-mailinfo-folded:
  mailinfo: tests for RFC2047 examples
  mailinfo: add explicit test for mails like '<a.u.thor@example.com> (A U Thor)'
  mailinfo: 'From:' header should be unfold as well
  mailinfo: correctly handle multiline 'Subject:' header

34 files changed:
Documentation/git-apply.txt
Documentation/git-describe.txt
Documentation/git-diff-files.txt
Documentation/githooks.txt
Documentation/technical/api-strbuf.txt
Documentation/user-manual.txt
Makefile
builtin-apply.c
builtin-commit.c
builtin-fast-export.c
builtin-fsck.c
builtin-grep.c
builtin-mv.c
cache.h
contrib/examples/README [new file with mode: 0644]
diff.c
dir.c
fast-import.c
git-bisect.sh
git-rebase--interactive.sh
git-repack.sh
git.spec.in
perl/Git.pm
sha1_file.c
sha1_name.c
t/t3001-ls-files-others-exclude.sh
t/t3404-rebase-interactive.sh
t/t3501-revert-cherry-pick.sh
t/t4114-apply-typechange.sh
t/t6030-bisect-porcelain.sh
t/t7001-mv.sh
test-dump-cache-tree.c [moved from dump-cache-tree.c with 100% similarity]
test-path-utils.c
unpack-trees.c

index feb51f124ac8a806e65d41f6274c58de64d2991f..44e1968a1cd87ba6003e650846a45c62f07a9f5f 100644 (file)
@@ -147,7 +147,7 @@ discouraged.
        considered whitespace errors.
 +
 By default, the command outputs warning messages but applies the patch.
-When `git-apply is used for statistics and not applying a
+When `git-apply` is used for statistics and not applying a
 patch, it defaults to `nowarn`.
 +
 You can use different `<action>` to control this
index c4dbc2ae342833561080f7a18a93bcf5ac5a0dd3..59a6fd17ab3566986aa2f4b12b2ce034aa2c5a97 100644 (file)
@@ -38,7 +38,7 @@ OPTIONS
        Automatically implies --tags.
 
 --abbrev=<n>::
-       Instead of using the default 8 hexadecimal digits as the
+       Instead of using the default 7 hexadecimal digits as the
        abbreviated object name, use <n> digits.
 
 --candidates=<n>::
index 5c8c1d95a89b15e936816f486a8114cbc6788fb9..c5261415643d359648900e17f522ba7b96fed44a 100644 (file)
@@ -21,7 +21,10 @@ OPTIONS
 -------
 include::diff-options.txt[]
 
--1 -2 -3 or --base --ours --theirs, and -0::
+-1 --base::
+-2 --ours::
+-3 --theirs::
+-0::
        Diff against the "base" version, "our branch" or "their
        branch" respectively.  With these options, diffs for
        merged entries are not shown.
index 5faaaa5fedcd0d61234d3927a89d77144f2a15ad..024abb2ff10077f86a073e83f17a4902d340097c 100644 (file)
@@ -86,7 +86,7 @@ This hook is invoked by 'git-commit' right after preparing the
 default log message, and before the editor is started.
 
 It takes one to three parameters.  The first is the name of the file
-that the commit log message.  The second is the source of the commit
+that contains the commit log message.  The second is the source of the commit
 message, and can be: `message` (if a `-m` or `-F` option was
 given); `template` (if a `-t` option was given or the
 configuration option `commit.template` is set); `merge` (if the
index a9668e5f2d2b1a7ffac45e4111ca6d8a4818af2b..4242dc01426b46d62bfb7da9f51100c23df2a972 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 99cb80878b3b710babd00b401dc41d73c34c695b..2ae88c575d0828809aafa242881d0377f7b54726 100644 (file)
@@ -1497,7 +1497,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 186a8efd1b74a0510e67e75a6191206a1a6818c2..5de4247fbd88c0ae45bf4d825b901ea92fb12483 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -1301,7 +1301,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 50b623e54c003fb5bbe183568d13f496c3c41c25..7a1ff041f15cd4e6ce2a5b1d1e3cb668f2f54f5e 100644 (file)
@@ -2445,7 +2445,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 1e08399919fb40f710236d223c12528648e6f40a..6cbdd55f168507259a17b64a19ad29310c6d3397 100644 (file)
@@ -625,7 +625,6 @@ static int prepare_to_commit(const char *index_file, const char *prefix)
        if (!commitable && !in_merge && !allow_empty &&
            !(amend && is_a_merge(head_sha1))) {
                run_status(stdout, index_file, prefix, 0);
-               unlink(commit_editmsg);
                return 0;
        }
 
index 838633808c3eb4891919aa397716f04fcd4cfe24..cdb7df5efeec9bbe6ec4ef4ab380403ea662bb12 100644 (file)
@@ -511,6 +511,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix)
 
        get_tags_and_duplicates(&revs.pending, &extra_refs);
 
+       revs.topo_order = 1;
        if (prepare_revision_walk(&revs))
                die("revision walk setup failed");
        revs.diffopt.format_callback = show_filemodify;
index 30971ce0ad170350cc6aaa2d213d348c267263db..aa4b239e42e8ade25cb481c4cdb55866eb37d948 100644 (file)
@@ -624,7 +624,7 @@ int cmd_fsck(int argc, const char **argv, const char *prefix)
        }
 
        heads = 0;
-       for (i = 1; i < argc; i++) {
+       for (i = 0; i < argc; i++) {
                const char *arg = argv[i];
                if (!get_sha1(arg, head_sha1)) {
                        struct object *obj = lookup_object(head_sha1);
index 3a51662a35878ae6b5965c90abb747b5b27c5493..d3cc75e3a47bed0d44d1981a6f609f24558a9e1b 100644 (file)
@@ -289,6 +289,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)
index 4f65b5ae9baf66953e79886fd93fe31786b24d36..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);
@@ -192,6 +192,7 @@ int cmd_mv(int argc, const char **argv, const char *prefix)
                                        memmove(destination + i,
                                                destination + i + 1,
                                                (argc - i) * sizeof(char *));
+                                       i--;
                                }
                        } else
                                die ("%s, source=%s, destination=%s",
diff --git a/cache.h b/cache.h
index 42f2f2754b93ff9d93883529778190d35a8ea43a..099a32e5fc536830fadc31cc68663ac3495a2a61 100644 (file)
--- a/cache.h
+++ b/cache.h
@@ -739,6 +739,7 @@ extern unsigned char* use_pack(struct packed_git *, struct pack_window **, off_t
 extern void close_pack_windows(struct packed_git *);
 extern void unuse_pack(struct pack_window **);
 extern void free_pack_by_name(const char *);
+extern void clear_delta_base_cache(void);
 extern struct packed_git *add_packed_git(const char *, int, int);
 extern const unsigned char *nth_packed_object_sha1(struct packed_git *, uint32_t);
 extern off_t nth_packed_object_offset(const struct packed_git *, uint32_t);
diff --git a/contrib/examples/README b/contrib/examples/README
new file mode 100644 (file)
index 0000000..6946f3d
--- /dev/null
@@ -0,0 +1,3 @@
+These are original scripted implementations, kept primarily for their
+reference value to any aspiring plumbing users who want to learn how
+pieces can be fit together.
diff --git a/diff.c b/diff.c
index f91f256c56e5e4be0b3f162695e1d35e63124569..6fea3c03476ac1817453a61fad0cda93a954df9a 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -2096,16 +2096,86 @@ static const char *external_diff_attr(const char *name)
        return NULL;
 }
 
+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 {
@@ -2145,11 +2215,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 */
@@ -2163,13 +2228,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);
@@ -2179,83 +2242,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);
 }
diff --git a/dir.c b/dir.c
index cfaa28ff23acb462aa0cfd54a405316320ec3bc8..04a4b9861e03739df5c048448cd5c0be28b400db 100644 (file)
--- a/dir.c
+++ b/dir.c
@@ -139,7 +139,7 @@ int match_pathspec(const char **pathspec, const char *name, int namelen, int pre
 
 static int no_wildcard(const char *string)
 {
-       return string[strcspn(string, "*?[{")] == '\0';
+       return string[strcspn(string, "*?[{\\")] == '\0';
 }
 
 void add_exclude(const char *string, const char *base,
index d58cca58e5fdbe0838e3622148d7b502affeaebf..5bc9ce2cc944d12914df0802fb4e010b056ed634 100644 (file)
@@ -943,6 +943,7 @@ static void end_packfile(void)
 {
        struct packed_git *old_p = pack_data, *new_p;
 
+       clear_delta_base_cache();
        if (object_count) {
                char *idx_name;
                int i;
@@ -1868,12 +1869,13 @@ static void file_change_m(struct branch *b)
        if (!p)
                die("Corrupt mode: %s", command_buf.buf);
        switch (mode) {
+       case 0644:
+       case 0755:
+               mode |= S_IFREG;
        case S_IFREG | 0644:
        case S_IFREG | 0755:
        case S_IFLNK:
        case S_IFGITLINK:
-       case 0644:
-       case 0755:
                /* ok */
                break;
        default:
@@ -1940,7 +1942,7 @@ static void file_change_m(struct branch *b)
                            typename(type), command_buf.buf);
        }
 
-       tree_content_set(&b->branch_tree, p, sha1, S_IFREG | mode, NULL);
+       tree_content_set(&b->branch_tree, p, sha1, mode, NULL);
 }
 
 static void file_change_d(struct branch *b)
index 97ac600873ebd0dff6310071343403a41a867b8a..b95dbbbbb243069f5e673869b3867cfa4151aff7 100755 (executable)
@@ -263,62 +263,74 @@ filter_skipped() {
        _skip="$2"
 
        if [ -z "$_skip" ]; then
-               eval_rev_list "$_eval"
+               eval_rev_list "$_eval" | {
+                       while read line
+                       do
+                               echo "$line &&"
+                       done
+                       echo ':'
+               }
                return
        fi
 
        # Let's parse the output of:
        # "git rev-list --bisect-vars --bisect-all ..."
-       eval_rev_list "$_eval" | while read hash line
-       do
-               case "$VARS,$FOUND,$TRIED,$hash" in
-                       # We display some vars.
-                       1,*,*,*) echo "$hash $line" ;;
-
-                       # Split line.
-                       ,*,*,---*) ;;
-
-                       # We had nothing to search.
+       eval_rev_list "$_eval" | {
+               VARS= FOUND= TRIED=
+               while read hash line
+               do
+                       case "$VARS,$FOUND,$TRIED,$hash" in
+                       1,*,*,*)
+                               # "bisect_foo=bar" read from rev-list output.
+                               echo "$hash &&"
+                               ;;
+                       ,*,*,---*)
+                               # Separator
+                               ;;
                        ,,,bisect_rev*)
-                               echo "bisect_rev="
+                               # We had nothing to search.
+                               echo "bisect_rev= &&"
                                VARS=1
                                ;;
-
-                       # We did not find a good bisect rev.
-                       # This should happen only if the "bad"
-                       # commit is also a "skip" commit.
                        ,,*,bisect_rev*)
-                               echo "bisect_rev=$TRIED"
+                               # We did not find a good bisect rev.
+                               # This should happen only if the "bad"
+                               # commit is also a "skip" commit.
+                               echo "bisect_rev='$TRIED' &&"
                                VARS=1
                                ;;
-
-                       # We are searching.
                        ,,*,*)
+                               # We are searching.
                                TRIED="${TRIED:+$TRIED|}$hash"
                                case "$_skip" in
                                *$hash*) ;;
                                *)
-                                       echo "bisect_rev=$hash"
-                                       echo "bisect_tried=\"$TRIED\""
+                                       echo "bisect_rev=$hash &&"
+                                       echo "bisect_tried='$TRIED' &&"
                                        FOUND=1
                                        ;;
                                esac
                                ;;
-
-                       # We have already found a rev to be tested.
-                       ,1,*,bisect_rev*) VARS=1 ;;
-                       ,1,*,*) ;;
-
-                       # ???
-                       *) die "filter_skipped error " \
-                           "VARS: '$VARS' " \
-                           "FOUND: '$FOUND' " \
-                           "TRIED: '$TRIED' " \
-                           "hash: '$hash' " \
-                           "line: '$line'"
-                       ;;
-               esac
-       done
+                       ,1,*,bisect_rev*)
+                               # We have already found a rev to be tested.
+                               VARS=1
+                               ;;
+                       ,1,*,*)
+                               ;;
+                       *)
+                               # Unexpected input
+                               echo "die 'filter_skipped error'"
+                               die "filter_skipped error " \
+                                   "VARS: '$VARS' " \
+                                   "FOUND: '$FOUND' " \
+                                   "TRIED: '$TRIED' " \
+                                   "hash: '$hash' " \
+                                   "line: '$line'"
+                               ;;
+                       esac
+               done
+               echo ':'
+       }
 }
 
 exit_if_skipped_commits () {
index 124cb5846b07ee9aa72fac4cbb88098c94f5741a..59c148ff6d477c5c40258d3adc5c95f5c775ccc6 100755 (executable)
@@ -309,7 +309,7 @@ do_next () {
        squash|s)
                comment_for_reflog squash
 
-               has_action "$DONE" ||
+               test -f "$DONE" && has_action "$DONE" ||
                        die "Cannot 'squash' without a previous commit"
 
                mark_action_done
index 458a497af810c7bb188a5aafb80c32aa0bc05264..be6db5e805d62e0440f7de3c1f6ee3fcd16a2ed3 100755 (executable)
@@ -88,32 +88,79 @@ if [ -z "$names" ]; then
                echo Nothing new to pack.
        fi
 fi
-for name in $names ; do
-       fullbases="$fullbases pack-$name"
-       chmod a-w "$PACKTMP-$name.pack"
-       chmod a-w "$PACKTMP-$name.idx"
-       mkdir -p "$PACKDIR" || exit
 
+# Ok we have prepared all new packfiles.
+mkdir -p "$PACKDIR" || exit
+
+# First see if there are packs of the same name and if so
+# if we can move them out of the way (this can happen if we
+# repacked immediately after packing fully.
+rollback=
+failed=
+for name in $names
+do
        for sfx in pack idx
        do
-               if test -f "$PACKDIR/pack-$name.$sfx"
-               then
-                       mv -f "$PACKDIR/pack-$name.$sfx" \
-                               "$PACKDIR/old-pack-$name.$sfx"
-               fi
-       done &&
+               file=pack-$name.$sfx
+               test -f "$PACKDIR/$file" || continue
+               rm -f "$PACKDIR/old-$file" &&
+               mv "$PACKDIR/$file" "$PACKDIR/old-$file" || {
+                       failed=t
+                       break
+               }
+               rollback="$rollback $file"
+       done
+       test -z "$failed" || break
+done
+
+# If renaming failed for any of them, roll the ones we have
+# already renamed back to their original names.
+if test -n "$failed"
+then
+       rollback_failure=
+       for file in $rollback
+       do
+               mv "$PACKDIR/old-$file" "$PACKDIR/$file" ||
+               rollback_failure="$rollback_failure $file"
+       done
+       if test -n "$rollback_failure"
+       then
+               echo >&2 "WARNING: Some packs in use have been renamed by"
+               echo >&2 "WARNING: prefixing old- to their name, in order to"
+               echo >&2 "WARNING: replace them with the new version of the"
+               echo >&2 "WARNING: file.  But the operation failed, and"
+               echo >&2 "WARNING: attempt to rename them back to their"
+               echo >&2 "WARNING: original names also failed."
+               echo >&2 "WARNING: Please rename them in $PACKDIR manually:"
+               for file in $rollback_failure
+               do
+                       echo >&2 "WARNING:   old-$file -> $file"
+               done
+       fi
+       exit 1
+fi
+
+# Now the ones with the same name are out of the way...
+fullbases=
+for name in $names
+do
+       fullbases="$fullbases pack-$name"
+       chmod a-w "$PACKTMP-$name.pack"
+       chmod a-w "$PACKTMP-$name.idx"
        mv -f "$PACKTMP-$name.pack" "$PACKDIR/pack-$name.pack" &&
-       mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" &&
-       test -f "$PACKDIR/pack-$name.pack" &&
-       test -f "$PACKDIR/pack-$name.idx" || {
-               echo >&2 "Couldn't replace the existing pack with updated one."
-               echo >&2 "The original set of packs have been saved as"
-               echo >&2 "old-pack-$name.{pack,idx} in $PACKDIR."
-               exit 1
-       }
-       rm -f "$PACKDIR/old-pack-$name.pack" "$PACKDIR/old-pack-$name.idx"
+       mv -f "$PACKTMP-$name.idx"  "$PACKDIR/pack-$name.idx" ||
+       exit
+done
+
+# Remove the "old-" files
+for name in $names
+do
+       rm -f "$PACKDIR/old-pack-$name.idx"
+       rm -f "$PACKDIR/old-pack-$name.pack"
 done
 
+# End of pack replacement.
+
 if test "$remove_redundant" = t
 then
        # We know $existing are all redundant.
index 6733b6f5551e43835fcf46793142d9d7ffbe27f9..0319c82a7ca03396285a6111e0cda1725f3f29c7 100644 (file)
@@ -97,7 +97,7 @@ BuildRequires:  perl(Error)
 %description -n perl-Git
 Perl interface to Git
 
-%define path_settings ETC_GITCONFIG=/etc/gitconfig prefix=%{_prefix} mandir=%{_mandir} htmldir=%{_docdir}/%{name}-core-%{version}
+%define path_settings ETC_GITCONFIG=/etc/gitconfig prefix=%{_prefix} mandir=%{_mandir} htmldir=%{_docdir}/%{name}-%{version}
 
 %prep
 %setup -q
@@ -189,6 +189,9 @@ rm -rf $RPM_BUILD_ROOT
 # No files for you!
 
 %changelog
+* Mon Feb 04 2009 David J. Mellor <dmellor@whistlingcat.com>
+- fixed broken git help -w after renaming the git-core package to git.
+
 * Fri Sep 12 2008 Quy Tonthat <qtonthat@gmail.com>
 - move git-cvsserver to bindir.
 
index ba94453781c98a97a95c65999873fc28b013340d..29a17839f3564bb5518304569e592a738e78d8af 100644 (file)
@@ -1012,8 +1012,8 @@ sub _temp_cache {
        my $temp_fd = \$TEMP_FILEMAP{$name};
        if (defined $$temp_fd and $$temp_fd->opened) {
                if ($TEMP_FILES{$$temp_fd}{locked}) {
-                       throw Error::Simple("Temp file with moniker '",
-                               $name, "' already in use");
+                       throw Error::Simple("Temp file with moniker '" .
+                               $name . "' already in use");
                }
        } else {
                if (defined $$temp_fd) {
index 88035a0cd19d040c8b626684c3ff1f7fdb35e837..bea958ec81ce1e1904b1b574348faae4eea4c3d0 100644 (file)
@@ -676,6 +676,7 @@ void free_pack_by_name(const char *pack_name)
        while (*pp) {
                p = *pp;
                if (strcmp(pack_name, p->pack_name) == 0) {
+                       clear_delta_base_cache();
                        close_pack_windows(p);
                        if (p->pack_fd != -1)
                                close(p->pack_fd);
@@ -1630,6 +1631,13 @@ static inline void release_delta_base_cache(struct delta_base_cache_entry *ent)
        }
 }
 
+void clear_delta_base_cache(void)
+{
+       unsigned long p;
+       for (p = 0; p < MAX_DELTA_CACHE; p++)
+               release_delta_base_cache(&delta_base_cache[p]);
+}
+
 static void add_delta_base_cache(struct packed_git *p, off_t base_offset,
        void *base, unsigned long base_size, enum object_type type)
 {
@@ -2280,7 +2288,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 75a5a7e96f292bed344a7609fca2f3a45ba4314e..c4fdaded01192f4ddb3c8956dd5d1f7b83606817 100644 (file)
@@ -309,7 +309,7 @@ static int get_sha1_basic(const char *str, int len, unsigned char *sha1)
 
        /* basic@{time or number} format to query ref-log */
        reflog_len = at = 0;
-       if (str[len-1] == '}') {
+       if (len && str[len-1] == '}') {
                for (at = 0; at < len - 1; at++) {
                        if (str[at] == '@' && str[at+1] == '{') {
                                reflog_len = (len-1) - (at+2);
index 8666946b025097d3e93c7853d39265429da81578..6a1711374579082000e95e39e4f6c0d572d11cd4 100755 (executable)
@@ -19,6 +19,9 @@ do
     >$dir/a.$i
   done
 done
+>"#ignore1"
+>"#ignore2"
+>"#hidden"
 
 cat >expect <<EOF
 a.2
@@ -42,6 +45,9 @@ three/a.8
 EOF
 
 echo '.gitignore
+\#ignore1
+\#ignore2*
+\#hid*n
 output
 expect
 .gitignore
@@ -79,9 +85,10 @@ test_expect_success \
        >output &&
      test_cmp expect output'
 
-cat > excludes-file << EOF
+cat > excludes-file <<\EOF
 *.[1-8]
 e*
+\#*
 EOF
 
 git config core.excludesFile excludes-file
index 7d10a27f1dcb8058f0e3c6180c3d45705fe3b21d..2cc8e7abe1b9244b2d6520cdbb0e0769e2a6d986 100755 (executable)
@@ -373,6 +373,38 @@ test_expect_success '--continue tries to commit, even for "edit"' '
        test $parent = $(git rev-parse HEAD^)
 '
 
+test_expect_success 'aborted --continue does not squash commits after "edit"' '
+       old=$(git rev-parse HEAD) &&
+       test_tick &&
+       FAKE_LINES="edit 1" git rebase -i HEAD^ &&
+       echo "edited again" > file7 &&
+       git add file7 &&
+       (
+               FAKE_COMMIT_MESSAGE=" " &&
+               export FAKE_COMMIT_MESSAGE &&
+               test_must_fail git rebase --continue
+       ) &&
+       test $old = $(git rev-parse HEAD) &&
+       git rebase --abort
+'
+
+test_expect_success 'auto-amend only edited commits after "edit"' '
+       test_tick &&
+       FAKE_LINES="edit 1" git rebase -i HEAD^ &&
+       echo "edited again" > file7 &&
+       git add file7 &&
+       FAKE_COMMIT_MESSAGE="edited file7 again" git commit &&
+       echo "and again" > file7 &&
+       git add file7 &&
+       test_tick &&
+       (
+               FAKE_COMMIT_MESSAGE="and again" &&
+               export FAKE_COMMIT_MESSAGE &&
+               test_must_fail git rebase --continue
+       ) &&
+       git rebase --abort
+'
+
 test_expect_success 'rebase a detached HEAD' '
        grandparent=$(git rev-parse HEAD~2) &&
        git checkout $(git rev-parse HEAD) &&
index 6da212825a447866364979c2fb10778b6bbc02d5..bb4cf00d78637b3bdf0c4e3da99291e0ab3c718f 100755 (executable)
@@ -45,6 +45,7 @@ test_expect_success 'cherry-pick after renaming branch' '
 
        git checkout rename2 &&
        git cherry-pick added &&
+       test $(git rev-parse HEAD^) = $(git rev-parse rename2) &&
        test -f opos &&
        grep "Add extra line at the end" opos
 
@@ -54,6 +55,7 @@ test_expect_success 'revert after renaming branch' '
 
        git checkout rename1 &&
        git revert added &&
+       test $(git rev-parse HEAD^) = $(git rev-parse rename1) &&
        test -f spoo &&
        ! grep "Add extra line at the end" spoo
 
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 36c9a6965f2b200f712ae5a6ae008ca1ef5007a0..0b81e65aa3897f40f4ef420bae7ed4f7bf4c5675 100755 (executable)
@@ -224,6 +224,31 @@ test_expect_success 'bisect skip: cannot tell between 2 commits' '
        fi
 '
 
+# $HASH1 is good, $HASH4 is both skipped and bad, we skip $HASH3
+# and $HASH2 is good,
+# so we should not be able to tell the first bad commit
+# among $HASH3 and $HASH4
+test_expect_success 'bisect skip: with commit both bad and skipped' '
+       git bisect start &&
+       git bisect skip &&
+       git bisect bad &&
+       git bisect good $HASH1 &&
+       git bisect skip &&
+       if git bisect good > my_bisect_log.txt
+       then
+               echo Oops, should have failed.
+               false
+       else
+               test $? -eq 2 &&
+               grep "first bad commit could be any of" my_bisect_log.txt &&
+               ! grep $HASH1 my_bisect_log.txt &&
+               ! grep $HASH2 my_bisect_log.txt &&
+               grep $HASH3 my_bisect_log.txt &&
+               grep $HASH4 my_bisect_log.txt &&
+               git bisect reset
+       fi
+'
+
 # We want to automatically find the commit that
 # introduced "Another" into hello.
 test_expect_success \
index 66bb1264ff7f8528168ca82ba908cff29658fa9d..d2ec550af6c749ed6f41c89ca9f4c238e227034d 100755 (executable)
@@ -38,6 +38,39 @@ test_expect_success \
     'git diff-tree -r -M --name-status  HEAD^ HEAD | \
     grep "^R100..*path1/COPYING..*path0/COPYING"'
 
+test_expect_success \
+    'checking -k on non-existing file' \
+    'git mv -k idontexist path0'
+
+test_expect_success \
+    'checking -k on untracked file' \
+    'touch untracked1 &&
+     git mv -k untracked1 path0 &&
+     test -f untracked1 &&
+     test ! -f path0/untracked1'
+
+test_expect_success \
+    'checking -k on multiple untracked files' \
+    'touch untracked2 &&
+     git mv -k untracked1 untracked2 path0 &&
+     test -f untracked1 &&
+     test -f untracked2 &&
+     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 \
+     .git/index.lock
+
 test_expect_success \
     'adding another file' \
     'cp ../../README path0/README &&
similarity index 100%
rename from dump-cache-tree.c
rename to test-dump-cache-tree.c
index a0bcb0e210523124fa977c8bf46667cf25d0335f..2c0f5a37e8b9051b1db80aa04e9ea763fb8d772b 100644 (file)
@@ -3,7 +3,7 @@
 int main(int argc, char **argv)
 {
        if (argc == 3 && !strcmp(argv[1], "normalize_absolute_path")) {
-               char *buf = xmalloc(strlen(argv[2])+1);
+               char *buf = xmalloc(PATH_MAX + 1);
                int rv = normalize_absolute_path(buf, argv[2]);
                assert(strlen(buf) == rv);
                puts(buf);
index 54f301da67be879c80426bc21776427fdd38c02e..4229eec1235842cf3432e4d5707b0e75845708b1 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;