Code

Merge branch 'maint' to sync with 1.6.5.7
authorJunio C Hamano <gitster@pobox.com>
Wed, 16 Dec 2009 19:09:31 +0000 (11:09 -0800)
committerJunio C Hamano <gitster@pobox.com>
Wed, 16 Dec 2009 20:47:15 +0000 (12:47 -0800)
* maint:
  Git 1.6.5.7
  worktree: don't segfault with an absolute pathspec without a work tree
  ignore unknown color configuration
  help.autocorrect: do not run a command if the command given is junk
  Illustrate "filter" attribute with an example

Documentation/RelNotes-1.6.5.7.txt [new file with mode: 0644]
Documentation/git.txt
Documentation/gitattributes.txt
builtin-branch.c
builtin-commit.c
diff.c
help.c
setup.c
t/t1501-worktree.sh
t/t4026-color.sh

diff --git a/Documentation/RelNotes-1.6.5.7.txt b/Documentation/RelNotes-1.6.5.7.txt
new file mode 100644 (file)
index 0000000..5b49ea5
--- /dev/null
@@ -0,0 +1,19 @@
+Git v1.6.5.7 Release Notes
+==========================
+
+Fixes since v1.6.5.6
+--------------------
+
+* If a user specifies a color for a <slot> (i.e. a class of things to show
+  in a particular color) that is known only by newer versions of git
+  (e.g. "color.diff.func" was recently added for upcoming 1.6.6 release),
+  an older version of git should just ignore them.  Instead we diagnosed
+  it as an error.
+
+* With help.autocorrect set to non-zero value, the logic to guess typoes
+  in the subcommand name misfired and ran a random nonsense command.
+
+* If a command is run with an absolute path as a pathspec inside a bare
+  repository, e.g. "rev-list HEAD -- /home", the code tried to run
+  strlen() on NULL, which is the result of get_git_work_tree(), and
+  segfaulted.
index 3d0cbf63ed29b6549f5deacf52af07d74bc25105..51ca39291f281ddc4c971d1aa824e800a02857fd 100644 (file)
@@ -43,9 +43,10 @@ unreleased) version of git, that is available from 'master'
 branch of the `git.git` repository.
 Documentation for older releases are available here:
 
-* link:v1.6.5.6/git.html[documentation for release 1.6.5.6]
+* link:v1.6.5.7/git.html[documentation for release 1.6.5.7]
 
 * release notes for
+  link:RelNotes-1.6.5.7.txt[1.6.5.7],
   link:RelNotes-1.6.5.6.txt[1.6.5.6],
   link:RelNotes-1.6.5.5.txt[1.6.5.5],
   link:RelNotes-1.6.5.4.txt[1.6.5.4],
index 1f472cea59a64023d91d25b09cc4d6f0aa39bc28..5a45e51890b1f4b13db3d8082da83731dc76ceac 100644 (file)
@@ -197,6 +197,25 @@ intent is that if someone unsets the filter driver definition,
 or does not have the appropriate filter program, the project
 should still be usable.
 
+For example, in .gitattributes, you would assign the `filter`
+attribute for paths.
+
+------------------------
+*.c    filter=indent
+------------------------
+
+Then you would define a "filter.indent.clean" and "filter.indent.smudge"
+configuration in your .git/config to specify a pair of commands to
+modify the contents of C programs when the source files are checked
+in ("clean" is run) and checked out (no change is made because the
+command is "cat").
+
+------------------------
+[filter "indent"]
+       clean = indent
+       smudge = cat
+------------------------
+
 
 Interaction between checkin/checkout attributes
 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
index 05e876e28554fec546ee4256bf3576dcb8017047..c87e63b02dd3bb0e12e5bf14aec22a0f219867b0 100644 (file)
@@ -65,7 +65,7 @@ static int parse_branch_color_slot(const char *var, int ofs)
                return BRANCH_COLOR_LOCAL;
        if (!strcasecmp(var+ofs, "current"))
                return BRANCH_COLOR_CURRENT;
-       die("bad config variable '%s'", var);
+       return -1;
 }
 
 static int git_branch_config(const char *var, const char *value, void *cb)
@@ -76,6 +76,8 @@ static int git_branch_config(const char *var, const char *value, void *cb)
        }
        if (!prefixcmp(var, "color.branch.")) {
                int slot = parse_branch_color_slot(var, 13);
+               if (slot < 0)
+                       return 0;
                if (!value)
                        return config_error_nonbool(var);
                color_parse(value, var, branch_colors[slot]);
index e93a647c59f1f52a4b0eb92b6c84fd9cec0aad6a..f54772f74a14e480ae978b38ce3bcd49ee994411 100644 (file)
@@ -890,7 +890,7 @@ static int parse_status_slot(const char *var, int offset)
                return WT_STATUS_NOBRANCH;
        if (!strcasecmp(var+offset, "unmerged"))
                return WT_STATUS_UNMERGED;
-       die("bad config variable '%s'", var);
+       return -1;
 }
 
 static int git_status_config(const char *k, const char *v, void *cb)
@@ -910,6 +910,8 @@ static int git_status_config(const char *k, const char *v, void *cb)
        }
        if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
                int slot = parse_status_slot(k, 13);
+               if (slot < 0)
+                       return 0;
                if (!v)
                        return config_error_nonbool(k);
                color_parse(v, k, s->color_palette[slot]);
diff --git a/diff.c b/diff.c
index d952686926e2e97aab3e369ad192027b4d7e676b..08bbd3e9070996b38f4d34cedf7640d93aa5808d 100644 (file)
--- a/diff.c
+++ b/diff.c
@@ -63,7 +63,7 @@ static int parse_diff_color_slot(const char *var, int ofs)
                return DIFF_WHITESPACE;
        if (!strcasecmp(var+ofs, "func"))
                return DIFF_FUNCINFO;
-       die("bad config variable '%s'", var);
+       return -1;
 }
 
 static int git_config_rename(const char *var, const char *value)
@@ -122,6 +122,8 @@ int git_diff_basic_config(const char *var, const char *value, void *cb)
 
        if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
                int slot = parse_diff_color_slot(var, 11);
+               if (slot < 0)
+                       return 0;
                if (!value)
                        return config_error_nonbool(var);
                color_parse(value, var, diff_colors[slot]);
diff --git a/help.c b/help.c
index e8db31f60f010887ccb3a943344da566e0937403..9da97d7462040d3935e7eaa95b1167357b38a943 100644 (file)
--- a/help.c
+++ b/help.c
@@ -297,6 +297,9 @@ static void add_cmd_list(struct cmdnames *cmds, struct cmdnames *old)
        old->names = NULL;
 }
 
+/* An empirically derived magic number */
+#define SIMILAR_ENOUGH(x) ((x) < 6)
+
 const char *help_unknown_cmd(const char *cmd)
 {
        int i, n, best_similarity = 0;
@@ -331,7 +334,7 @@ const char *help_unknown_cmd(const char *cmd)
        n = 1;
        while (n < main_cmds.cnt && best_similarity == main_cmds.names[n]->len)
                ++n;
-       if (autocorrect && n == 1) {
+       if (autocorrect && n == 1 && SIMILAR_ENOUGH(best_similarity)) {
                const char *assumed = main_cmds.names[0]->name;
                main_cmds.names[0] = NULL;
                clean_cmdnames(&main_cmds);
@@ -349,7 +352,7 @@ const char *help_unknown_cmd(const char *cmd)
 
        fprintf(stderr, "git: '%s' is not a git-command. See 'git --help'.\n", cmd);
 
-       if (best_similarity < 6) {
+       if (SIMILAR_ENOUGH(best_similarity)) {
                fprintf(stderr, "\nDid you mean %s?\n",
                        n < 2 ? "this": "one of these");
 
diff --git a/setup.c b/setup.c
index f67250b7c1f7b5a62c30de0122c404554357f61b..2cf0f1993718fd737cd87e79d2f4950832c59c9f 100644 (file)
--- a/setup.c
+++ b/setup.c
@@ -18,9 +18,12 @@ const char *prefix_path(const char *prefix, int len, const char *path)
        if (normalize_path_copy(sanitized, sanitized))
                goto error_out;
        if (is_absolute_path(orig)) {
+               size_t len, total;
                const char *work_tree = get_git_work_tree();
-               size_t len = strlen(work_tree);
-               size_t total = strlen(sanitized) + 1;
+               if (!work_tree)
+                       goto error_out;
+               len = strlen(work_tree);
+               total = strlen(sanitized) + 1;
                if (strncmp(sanitized, work_tree, len) ||
                    (sanitized[len] != '\0' && sanitized[len] != '/')) {
                error_out:
index f6a6f839a18de4c3775ea965f164d0d20f2bbe9b..74e6443664010196f2694304179917fdadc53c01 100755 (executable)
@@ -174,4 +174,19 @@ test_expect_success 'git grep' '
        GIT_DIR=../.. GIT_WORK_TREE=.. git grep -l changed | grep dir/tracked)
 '
 
+test_expect_success 'git commit' '
+       (
+               cd repo.git &&
+               GIT_DIR=. GIT_WORK_TREE=work git commit -a -m done
+       )
+'
+
+test_expect_success 'absolute pathspec should fail gracefully' '
+       (
+               cd repo.git || exit 1
+               git config --unset core.worktree
+               test_must_fail git log HEAD -- /home
+       )
+'
+
 test_done
index b61e5169f4e9e8d9f87b9ea16e71dfcf1fb9f340..5ade44c043ca6577b2e331b152515359128dbd32 100755 (executable)
@@ -66,4 +66,21 @@ test_expect_success 'extra character after attribute' '
        invalid_color "dimX"
 '
 
+test_expect_success 'unknown color slots are ignored (diff)' '
+       git config --unset diff.color.new
+       git config color.diff.nosuchslotwilleverbedefined white &&
+       git diff --color
+'
+
+test_expect_success 'unknown color slots are ignored (branch)' '
+       git config color.branch.nosuchslotwilleverbedefined white &&
+       git branch -a
+'
+
+test_expect_success 'unknown color slots are ignored (status)' '
+       git config color.status.nosuchslotwilleverbedefined white || exit
+       git status
+       case $? in 0|1) : ok ;; *) false ;; esac
+'
+
 test_done