diff options
-rw-r--r-- | Documentation/RelNotes-1.6.5.7.txt | 19 | ||||
-rw-r--r-- | Documentation/git.txt | 3 | ||||
-rw-r--r-- | Documentation/gitattributes.txt | 19 | ||||
-rw-r--r-- | builtin-branch.c | 4 | ||||
-rw-r--r-- | builtin-commit.c | 4 | ||||
-rw-r--r-- | diff.c | 4 | ||||
-rw-r--r-- | help.c | 7 | ||||
-rw-r--r-- | setup.c | 7 | ||||
-rwxr-xr-x | t/t1501-worktree.sh | 15 | ||||
-rwxr-xr-x | t/t4026-color.sh | 17 |
10 files changed, 91 insertions, 8 deletions
diff --git a/Documentation/RelNotes-1.6.5.7.txt b/Documentation/RelNotes-1.6.5.7.txt new file mode 100644 index 0000000000..5b49ea53be --- /dev/null +++ b/Documentation/RelNotes-1.6.5.7.txt @@ -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. diff --git a/Documentation/git.txt b/Documentation/git.txt index 3d0cbf63ed..51ca39291f 100644 --- a/Documentation/git.txt +++ b/Documentation/git.txt @@ -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], diff --git a/Documentation/gitattributes.txt b/Documentation/gitattributes.txt index 1f472cea59..5a45e51890 100644 --- a/Documentation/gitattributes.txt +++ b/Documentation/gitattributes.txt @@ -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 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/builtin-branch.c b/builtin-branch.c index 05e876e285..c87e63b02d 100644 --- a/builtin-branch.c +++ b/builtin-branch.c @@ -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]); diff --git a/builtin-commit.c b/builtin-commit.c index e93a647c59..f54772f74a 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -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]); @@ -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]); @@ -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"); @@ -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: diff --git a/t/t1501-worktree.sh b/t/t1501-worktree.sh index f6a6f839a1..74e6443664 100755 --- a/t/t1501-worktree.sh +++ b/t/t1501-worktree.sh @@ -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 diff --git a/t/t4026-color.sh b/t/t4026-color.sh index b61e5169f4..5ade44c043 100755 --- a/t/t4026-color.sh +++ b/t/t4026-color.sh @@ -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 |