aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJunio C Hamano <gitster@pobox.com>2008-02-11 13:23:06 -0800
committerJunio C Hamano <gitster@pobox.com>2008-02-11 13:23:06 -0800
commit04f32cf1b31717bf0b7cbbc00783a4107cc19cfd (patch)
treefaa82765b851e6f0cabfe37e4936d5ca1bf623ec
parent94bf9f7c37cca0241785a5f4e54e5cc98e175244 (diff)
parent6c47d0e8f3983cff5bf633cb8e6f7ecfecf48db7 (diff)
downloadgit-04f32cf1b31717bf0b7cbbc00783a4107cc19cfd.tar.gz
git-04f32cf1b31717bf0b7cbbc00783a4107cc19cfd.tar.xz
Merge branch 'maint'
* maint: (35 commits) config.c: guard config parser from value=NULL builtin-log.c: guard config parser from value=NULL imap-send.c: guard config parser from value=NULL wt-status.c: guard config parser from value=NULL setup.c: guard config parser from value=NULL remote.c: guard config parser from value=NULL merge-recursive.c: guard config parser from value=NULL http.c: guard config parser from value=NULL help.c: guard config parser from value=NULL git.c: guard config parser from value=NULL diff.c: guard config parser from value=NULL convert.c: guard config parser from value=NULL connect.c: guard config parser from value=NULL builtin-tag.c: guard config parser from value=NULL builtin-show-branch.c: guard config parser from value=NULL builtin-reflog.c: guard config parser from value=NULL builtin-log.c: guard config parser from value=NULL builtin-config.c: guard config parser from value=NULL builtin-commit.c: guard config parser from value=NULL builtin-branch.c: guard config parser from value=NULL ...
-rw-r--r--Documentation/config.txt2
-rw-r--r--Documentation/git-branch.txt15
-rw-r--r--Documentation/git-checkout.txt7
-rw-r--r--Documentation/git-pull.txt10
-rw-r--r--archive-tar.c2
-rw-r--r--builtin-apply.c2
-rw-r--r--builtin-branch.c9
-rw-r--r--builtin-commit.c3
-rw-r--r--builtin-config.c2
-rw-r--r--builtin-gc.c2
-rw-r--r--builtin-log.c7
-rw-r--r--builtin-pack-objects.c13
-rw-r--r--builtin-prune.c39
-rw-r--r--builtin-reflog.c16
-rw-r--r--builtin-show-branch.c2
-rw-r--r--builtin-tag.c2
-rw-r--r--cache.h1
-rw-r--r--config.c30
-rw-r--r--connect.c2
-rw-r--r--convert.c4
-rw-r--r--diff.c14
-rwxr-xr-xgit-bisect.sh8
-rwxr-xr-xgit-rebase--interactive.sh2
-rw-r--r--git.c2
-rw-r--r--help.c2
-rw-r--r--http.c25
-rw-r--r--imap-send.c4
-rw-r--r--merge-recursive.c11
-rw-r--r--remote.c9
-rw-r--r--setup.c2
-rwxr-xr-xt/t1300-repo-config.sh19
-rw-r--r--t/t5304-prune.sh32
-rwxr-xr-xt/t6030-bisect-porcelain.sh12
-rw-r--r--wt-status.c2
34 files changed, 255 insertions, 59 deletions
diff --git a/Documentation/config.txt b/Documentation/config.txt
index 3e10feb9f..f9bdb164e 100644
--- a/Documentation/config.txt
+++ b/Documentation/config.txt
@@ -333,7 +333,7 @@ branch.autosetupmerge::
so that linkgit:git-pull[1] will appropriately merge from that
remote branch. Note that even if this option is not set,
this behavior can be chosen per-branch using the `--track`
- and `--no-track` options. This option defaults to false.
+ and `--no-track` options. This option defaults to true.
branch.<name>.remote::
When in branch <name>, it tells `git fetch` which remote to fetch.
diff --git a/Documentation/git-branch.txt b/Documentation/git-branch.txt
index f920c04cc..7e8874aca 100644
--- a/Documentation/git-branch.txt
+++ b/Documentation/git-branch.txt
@@ -34,11 +34,11 @@ Note that this will create the new branch, but it will not switch the
working tree to it; use "git checkout <newbranch>" to switch to the
new branch.
-When a local branch is started off a remote branch, git can setup the
+When a local branch is started off a remote branch, git sets up the
branch so that linkgit:git-pull[1] will appropriately merge from that
-remote branch. If this behavior is desired, it is possible to make it
-the default using the global `branch.autosetupmerge` configuration
-flag. Otherwise, it can be chosen per-branch using the `--track`
+remote branch. If this behavior is not desired, it is possible to
+disable it using the global `branch.autosetupmerge` configuration
+flag. That setting can be overridden by using the `--track`
and `--no-track` options.
With a '-m' or '-M' option, <oldbranch> will be renamed to <newbranch>.
@@ -108,10 +108,11 @@ OPTIONS
Set up configuration so that git-pull will automatically
retrieve data from the remote branch. Use this if you always
pull from the same remote branch into the new branch, or if you
- don't want to use "git pull <repository> <refspec>" explicitly. Set the
- branch.autosetupmerge configuration variable to true if you
+ don't want to use "git pull <repository> <refspec>" explicitly.
+ This behavior is the default. Set the
+ branch.autosetupmerge configuration variable to false if you
want git-checkout and git-branch to always behave as if
- '--track' were given.
+ '--no-track' were given.
--no-track::
When a branch is created off a remote branch,
diff --git a/Documentation/git-checkout.txt b/Documentation/git-checkout.txt
index 584359ff3..b4cfa044b 100644
--- a/Documentation/git-checkout.txt
+++ b/Documentation/git-checkout.txt
@@ -52,10 +52,11 @@ OPTIONS
set up configuration so that git-pull will automatically
retrieve data from the remote branch. Use this if you always
pull from the same remote branch into the new branch, or if you
- don't want to use "git pull <repository> <refspec>" explicitly. Set the
- branch.autosetupmerge configuration variable to true if you
+ don't want to use "git pull <repository> <refspec>" explicitly.
+ This behavior is the default. Set the
+ branch.autosetupmerge configuration variable to false if you
want git-checkout and git-branch to always behave as if
- '--track' were given.
+ '--no-track' were given.
--no-track::
When -b is given and a branch is created off a remote branch,
diff --git a/Documentation/git-pull.txt b/Documentation/git-pull.txt
index 4cc633a5e..179bdfc69 100644
--- a/Documentation/git-pull.txt
+++ b/Documentation/git-pull.txt
@@ -39,11 +39,11 @@ include::merge-strategies.txt[]
there is a remote ref for the upstream branch, and this branch
was rebased since last fetched, the rebase uses that information
to avoid rebasing non-local changes.
-
- *NOTE:* This is a potentially _dangerous_ mode of operation.
- It rewrites history, which does not bode well when you
- published that history already. Do *not* use this option
- unless you have read linkgit:git-rebase[1] carefully.
++
+*NOTE:* This is a potentially _dangerous_ mode of operation.
+It rewrites history, which does not bode well when you
+published that history already. Do *not* use this option
+unless you have read linkgit:git-rebase[1] carefully.
\--no-rebase::
Override earlier \--rebase.
diff --git a/archive-tar.c b/archive-tar.c
index e1bced560..30aa2e23f 100644
--- a/archive-tar.c
+++ b/archive-tar.c
@@ -222,7 +222,7 @@ static void write_global_extended_header(const unsigned char *sha1)
static int git_tar_config(const char *var, const char *value)
{
if (!strcmp(var, "tar.umask")) {
- if (!strcmp(value, "user")) {
+ if (value && !strcmp(value, "user")) {
tar_umask = umask(0);
umask(tar_umask);
} else {
diff --git a/builtin-apply.c b/builtin-apply.c
index 15432b678..a11b1bbee 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -2746,6 +2746,8 @@ static int apply_patch(int fd, const char *filename, int inaccurate_eof)
static int git_apply_config(const char *var, const char *value)
{
if (!strcmp(var, "apply.whitespace")) {
+ if (!value)
+ return config_error_nonbool(var);
apply_default_whitespace = xstrdup(value);
return 0;
}
diff --git a/builtin-branch.c b/builtin-branch.c
index 089cae592..e414c8898 100644
--- a/builtin-branch.c
+++ b/builtin-branch.c
@@ -70,12 +70,15 @@ static int git_branch_config(const char *var, const char *value)
}
if (!prefixcmp(var, "color.branch.")) {
int slot = parse_branch_color_slot(var, 13);
+ if (!value)
+ return config_error_nonbool(var);
color_parse(value, var, branch_colors[slot]);
return 0;
}
- if (!strcmp(var, "branch.autosetupmerge"))
- branch_track = git_config_bool(var, value);
-
+ if (!strcmp(var, "branch.autosetupmerge")) {
+ branch_track = git_config_bool(var, value);
+ return 0;
+ }
return git_default_config(var, value);
}
diff --git a/builtin-commit.c b/builtin-commit.c
index c787bed69..a43f20199 100644
--- a/builtin-commit.c
+++ b/builtin-commit.c
@@ -743,6 +743,8 @@ static void print_summary(const char *prefix, const unsigned char *sha1)
int git_commit_config(const char *k, const char *v)
{
if (!strcmp(k, "commit.template")) {
+ if (!v)
+ return config_error_nonbool(v);
template_file = xstrdup(v);
return 0;
}
@@ -929,6 +931,7 @@ int cmd_commit(int argc, const char **argv, const char *prefix)
unlink(git_path("MERGE_HEAD"));
unlink(git_path("MERGE_MSG"));
+ unlink(git_path("SQUASH_MSG"));
if (commit_index_files())
die ("Repository has been updated, but unable to write\n"
diff --git a/builtin-config.c b/builtin-config.c
index e4a12e316..077d8ef2d 100644
--- a/builtin-config.c
+++ b/builtin-config.c
@@ -168,6 +168,8 @@ static char parsed_color[COLOR_MAXLEN];
static int git_get_color_config(const char *var, const char *value)
{
if (!strcmp(var, get_color_slot)) {
+ if (!value)
+ config_error_nonbool(var);
color_parse(value, var, parsed_color);
get_color_found = 1;
}
diff --git a/builtin-gc.c b/builtin-gc.c
index ac34788c8..ad4a75eed 100644
--- a/builtin-gc.c
+++ b/builtin-gc.c
@@ -37,7 +37,7 @@ static const char *argv_rerere[] = {"rerere", "gc", NULL};
static int gc_config(const char *var, const char *value)
{
if (!strcmp(var, "gc.packrefs")) {
- if (!strcmp(value, "notbare"))
+ if (value && !strcmp(value, "notbare"))
pack_refs = -1;
else
pack_refs = git_config_bool(var, value);
diff --git a/builtin-log.c b/builtin-log.c
index dcc9f8179..99d69f079 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -219,7 +219,7 @@ static int git_log_config(const char *var, const char *value)
{
if (!strcmp(var, "format.subjectprefix")) {
if (!value)
- die("format.subjectprefix without value");
+ config_error_nonbool(var);
fmt_patch_subject_prefix = xstrdup(value);
return 0;
}
@@ -432,7 +432,7 @@ static int git_format_config(const char *var, const char *value)
}
if (!strcmp(var, "format.suffix")) {
if (!value)
- die("format.suffix without value");
+ return config_error_nonbool(var);
fmt_patch_suffix = xstrdup(value);
return 0;
}
@@ -440,11 +440,10 @@ static int git_format_config(const char *var, const char *value)
return 0;
}
if (!strcmp(var, "format.numbered")) {
- if (!strcasecmp(value, "auto")) {
+ if (value && !strcasecmp(value, "auto")) {
auto_number = 1;
return 0;
}
-
numbered = git_config_bool(var, value);
return 0;
}
diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c
index 692a76126..acb05554d 100644
--- a/builtin-pack-objects.c
+++ b/builtin-pack-objects.c
@@ -1464,7 +1464,7 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
return m;
}
-static unsigned long free_unpacked(struct unpacked *n)
+static unsigned long free_unpacked_data(struct unpacked *n)
{
unsigned long freed_mem = sizeof_delta_index(n->index);
free_delta_index(n->index);
@@ -1474,6 +1474,12 @@ static unsigned long free_unpacked(struct unpacked *n)
free(n->data);
n->data = NULL;
}
+ return freed_mem;
+}
+
+static unsigned long free_unpacked(struct unpacked *n)
+{
+ unsigned long freed_mem = free_unpacked_data(n);
n->entry = NULL;
n->depth = 0;
return freed_mem;
@@ -1514,7 +1520,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
mem_usage > window_memory_limit &&
count > 1) {
uint32_t tail = (idx + window - count) % window;
- mem_usage -= free_unpacked(array + tail);
+ mem_usage -= free_unpacked_data(array + tail);
count--;
}
@@ -1547,6 +1553,9 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
if (!m->entry)
break;
ret = try_delta(n, m, max_depth, &mem_usage);
+ if (window_memory_limit &&
+ mem_usage > window_memory_limit)
+ mem_usage -= free_unpacked_data(m);
if (ret < 0)
break;
else if (ret > 0)
diff --git a/builtin-prune.c b/builtin-prune.c
index b5e768421..bb8ead92c 100644
--- a/builtin-prune.c
+++ b/builtin-prune.c
@@ -83,6 +83,44 @@ static void prune_object_dir(const char *path)
}
}
+/*
+ * Write errors (particularly out of space) can result in
+ * failed temporary packs (and more rarely indexes and other
+ * files begining with "tmp_") accumulating in the
+ * object directory.
+ */
+static void remove_temporary_files(void)
+{
+ DIR *dir;
+ struct dirent *de;
+ char* dirname=get_object_directory();
+
+ dir = opendir(dirname);
+ if (!dir) {
+ fprintf(stderr, "Unable to open object directory %s\n",
+ dirname);
+ return;
+ }
+ while ((de = readdir(dir)) != NULL) {
+ if (!prefixcmp(de->d_name, "tmp_")) {
+ char name[PATH_MAX];
+ int c = snprintf(name, PATH_MAX, "%s/%s",
+ dirname, de->d_name);
+ if (c < 0 || c >= PATH_MAX)
+ continue;
+ if (expire) {
+ struct stat st;
+ if (stat(name, &st) != 0 || st.st_mtime >= expire)
+ continue;
+ }
+ printf("Removing stale temporary file %s\n", name);
+ if (!show_only)
+ unlink(name);
+ }
+ }
+ closedir(dir);
+}
+
int cmd_prune(int argc, const char **argv, const char *prefix)
{
int i;
@@ -115,5 +153,6 @@ int cmd_prune(int argc, const char **argv, const char *prefix)
sync();
prune_packed_objects(show_only);
+ remove_temporary_files();
return 0;
}
diff --git a/builtin-reflog.c b/builtin-reflog.c
index e6834dd83..4836ec951 100644
--- a/builtin-reflog.c
+++ b/builtin-reflog.c
@@ -307,13 +307,19 @@ static int collect_reflog(const char *ref, const unsigned char *sha1, int unused
static int reflog_expire_config(const char *var, const char *value)
{
- if (!strcmp(var, "gc.reflogexpire"))
+ if (!strcmp(var, "gc.reflogexpire")) {
+ if (!value)
+ config_error_nonbool(var);
default_reflog_expire = approxidate(value);
- else if (!strcmp(var, "gc.reflogexpireunreachable"))
+ return 0;
+ }
+ if (!strcmp(var, "gc.reflogexpireunreachable")) {
+ if (!value)
+ config_error_nonbool(var);
default_reflog_expire_unreachable = approxidate(value);
- else
- return git_default_config(var, value);
- return 0;
+ return 0;
+ }
+ return git_default_config(var, value);
}
static int cmd_reflog_expire(int argc, const char **argv, const char *prefix)
diff --git a/builtin-show-branch.c b/builtin-show-branch.c
index 6dc835d30..019abd352 100644
--- a/builtin-show-branch.c
+++ b/builtin-show-branch.c
@@ -536,6 +536,8 @@ static void append_one_rev(const char *av)
static int git_show_branch_config(const char *var, const char *value)
{
if (!strcmp(var, "showbranch.default")) {
+ if (!value)
+ return config_error_nonbool(var);
if (default_alloc <= default_num + 1) {
default_alloc = default_alloc * 3 / 2 + 20;
default_arg = xrealloc(default_arg, sizeof *default_arg * default_alloc);
diff --git a/builtin-tag.c b/builtin-tag.c
index 03e70155f..4a4a88c10 100644
--- a/builtin-tag.c
+++ b/builtin-tag.c
@@ -258,7 +258,7 @@ static int git_tag_config(const char *var, const char *value)
{
if (!strcmp(var, "user.signingkey")) {
if (!value)
- die("user.signingkey without value");
+ return config_error_nonbool(value);
set_signingkey(value);
return 0;
}
diff --git a/cache.h b/cache.h
index 549f4bbac..6abcee437 100644
--- a/cache.h
+++ b/cache.h
@@ -589,6 +589,7 @@ extern int git_config_set_multivar(const char *, const char *, const char *, int
extern int git_config_rename_section(const char *, const char *);
extern const char *git_etc_gitconfig(void);
extern int check_repository_format_version(const char *var, const char *value);
+extern int config_error_nonbool(const char *);
#define MAX_GITNAME (1000)
extern char git_default_email[MAX_GITNAME];
diff --git a/config.c b/config.c
index 498259ebe..3e72778e9 100644
--- a/config.c
+++ b/config.c
@@ -408,21 +408,29 @@ int git_default_config(const char *var, const char *value)
}
if (!strcmp(var, "user.name")) {
+ if (!value)
+ return config_error_nonbool(var);
strlcpy(git_default_name, value, sizeof(git_default_name));
return 0;
}
if (!strcmp(var, "user.email")) {
+ if (!value)
+ return config_error_nonbool(var);
strlcpy(git_default_email, value, sizeof(git_default_email));
return 0;
}
if (!strcmp(var, "i18n.commitencoding")) {
+ if (!value)
+ return config_error_nonbool(var);
git_commit_encoding = xstrdup(value);
return 0;
}
if (!strcmp(var, "i18n.logoutputencoding")) {
+ if (!value)
+ return config_error_nonbool(var);
git_log_output_encoding = xstrdup(value);
return 0;
}
@@ -434,23 +442,29 @@ int git_default_config(const char *var, const char *value)
}
if (!strcmp(var, "core.pager")) {
+ if (!value)
+ return config_error_nonbool(var);
pager_program = xstrdup(value);
return 0;
}
if (!strcmp(var, "core.editor")) {
+ if (!value)
+ return config_error_nonbool(var);
editor_program = xstrdup(value);
return 0;
}
if (!strcmp(var, "core.excludesfile")) {
if (!value)
- die("core.excludesfile without value");
+ return config_error_nonbool(var);
excludes_file = xstrdup(value);
return 0;
}
if (!strcmp(var, "core.whitespace")) {
+ if (!value)
+ return config_error_nonbool(var);
whitespace_rule_cfg = parse_whitespace_rule(value);
return 0;
}
@@ -701,12 +715,17 @@ static ssize_t find_beginning_of_line(const char* contents, size_t size,
size_t equal_offset = size, bracket_offset = size;
ssize_t offset;
+contline:
for (offset = offset_-2; offset > 0
&& contents[offset] != '\n'; offset--)
switch (contents[offset]) {
case '=': equal_offset = offset; break;
case ']': bracket_offset = offset; break;
}
+ if (offset > 0 && contents[offset-1] == '\\') {
+ offset_ = offset;
+ goto contline;
+ }
if (bracket_offset < equal_offset) {
*found_bracket = 1;
offset = bracket_offset+1;
@@ -1074,3 +1093,12 @@ int git_config_rename_section(const char *old_name, const char *new_name)
free(config_filename);
return ret;
}
+
+/*
+ * Call this to report error for your variable that should not
+ * get a boolean value (i.e. "[my] var" means "true").
+ */
+int config_error_nonbool(const char *var)
+{
+ return error("Missing value for '%s'", var);
+}
diff --git a/connect.c b/connect.c
index 3aefd4ace..71597d492 100644
--- a/connect.c
+++ b/connect.c
@@ -370,6 +370,8 @@ static int git_proxy_command_options(const char *var, const char *value)
if (git_proxy_command)
return 0;
+ if (!value)
+ return config_error_nonbool(var);
/* [core]
* ;# matches www.kernel.org as well
* gitproxy = netcatter-1 for kernel.org
diff --git a/convert.c b/convert.c
index 80f114b2e..552707e8e 100644
--- a/convert.c
+++ b/convert.c
@@ -326,14 +326,14 @@ static int read_convert_config(const char *var, const char *value)
if (!strcmp("smudge", ep)) {
if (!value)
- return error("%s: lacks value", var);
+ return config_error_nonbool(var);
drv->smudge = strdup(value);
return 0;
}
if (!strcmp("clean", ep)) {
if (!value)
- return error("%s: lacks value", var);
+ return config_error_nonbool(var);
drv->clean = strdup(value);
return 0;
}
diff --git a/diff.c b/diff.c
index 5b8afdcb0..4d2e23ae1 100644
--- a/diff.c
+++ b/diff.c
@@ -158,6 +158,8 @@ int git_diff_ui_config(const char *var, const char *value)
return 0;
}
if (!strcmp(var, "diff.external")) {
+ if (!value)
+ return config_error_nonbool(var);
external_diff_cmd_cfg = xstrdup(value);
return 0;
}
@@ -165,8 +167,11 @@ int git_diff_ui_config(const char *var, const char *value)
const char *ep = strrchr(var, '.');
if (ep != var + 4) {
- if (!strcmp(ep, ".command"))
+ if (!strcmp(ep, ".command")) {
+ if (!value)
+ return config_error_nonbool(var);
return parse_lldiff_command(var, ep, value);
+ }
}
}
@@ -177,6 +182,8 @@ int git_diff_basic_config(const char *var, const char *value)
{
if (!prefixcmp(var, "diff.color.") || !prefixcmp(var, "color.diff.")) {
int slot = parse_diff_color_slot(var, 11);
+ if (!value)
+ return config_error_nonbool(var);
color_parse(value, var, diff_colors[slot]);
return 0;
}
@@ -184,8 +191,11 @@ int git_diff_basic_config(const char *var, const char *value)
if (!prefixcmp(var, "diff.")) {
const char *ep = strrchr(var, '.');
if (ep != var + 4) {
- if (!strcmp(ep, ".funcname"))
+ if (!strcmp(ep, ".funcname")) {
+ if (!value)
+ return config_error_nonbool(var);
return parse_funcname_pattern(var, ep, value);
+ }
}
}
diff --git a/git-bisect.sh b/git-bisect.sh
index 538524989..393fa3558 100755
--- a/git-bisect.sh
+++ b/git-bisect.sh
@@ -26,6 +26,9 @@ OPTIONS_SPEC=
. git-sh-setup
require_work_tree
+_x40='[0-9a-f][0-9a-f][0-9a-f][0-9a-f][0-9a-f]'
+_x40="$_x40$_x40$_x40$_x40$_x40$_x40$_x40$_x40"
+
sq() {
@@PERL@@ -e '
for (@ARGV) {
@@ -60,7 +63,8 @@ bisect_start() {
# top-of-line master first!
#
head=$(GIT_DIR="$GIT_DIR" git symbolic-ref HEAD) ||
- die "Bad HEAD - I need a symbolic ref"
+ head=$(GIT_DIR="$GIT_DIR" git rev-parse --verify HEAD) ||
+ die "Bad HEAD - I need a HEAD"
case "$head" in
refs/heads/bisect)
if [ -s "$GIT_DIR/head-name" ]; then
@@ -70,7 +74,7 @@ bisect_start() {
fi
git checkout $branch || exit
;;
- refs/heads/*)
+ refs/heads/*|$_x40)
[ -s "$GIT_DIR/head-name" ] && die "won't bisect on seeked tree"
echo "${head#refs/heads/}" >"$GIT_DIR/head-name"
;;
diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh
index 402ff3782..fb12b03b2 100755
--- a/git-rebase--interactive.sh
+++ b/git-rebase--interactive.sh
@@ -432,7 +432,7 @@ do
shift ;;
esac
;;
- --merge)
+ -m|--merge)
# we use merge anyway
;;
-C*)
diff --git a/git.c b/git.c
index 15fec8974..0cb86884d 100644
--- a/git.c
+++ b/git.c
@@ -93,6 +93,8 @@ static char *alias_string;
static int git_alias_config(const char *var, const char *value)
{
if (!prefixcmp(var, "alias.") && !strcmp(var + 6, alias_command)) {
+ if (!value)
+ return config_error_nonbool(var);
alias_string = xstrdup(value);
}
return 0;
diff --git a/help.c b/help.c
index 1302a61c8..95e7640fe 100644
--- a/help.c
+++ b/help.c
@@ -40,6 +40,8 @@ static void parse_help_format(const char *format)
static int git_help_config(const char *var, const char *value)
{
if (!strcmp(var, "help.format")) {
+ if (!value)
+ return config_error_nonbool(var);
help_default_format = xstrdup(value);
return 0;
}
diff --git a/http.c b/http.c
index d2c11aee9..5925d0747 100644
--- a/http.c
+++ b/http.c
@@ -101,16 +101,18 @@ static int http_options(const char *var, const char *value)
if (!strcmp("http.sslcert", var)) {
if (ssl_cert == NULL) {
- ssl_cert = xmalloc(strlen(value)+1);
- strcpy(ssl_cert, value);
+ if (!value)
+ return config_error_nonbool(var);
+ ssl_cert = xstrdup(value);
}
return 0;
}
#if LIBCURL_VERSION_NUM >= 0x070902
if (!strcmp("http.sslkey", var)) {
if (ssl_key == NULL) {
- ssl_key = xmalloc(strlen(value)+1);
- strcpy(ssl_key, value);
+ if (!value)
+ return config_error_nonbool(var);
+ ssl_key = xstrdup(value);
}
return 0;
}
@@ -118,16 +120,18 @@ static int http_options(const char *var, const char *value)
#if LIBCURL_VERSION_NUM >= 0x070908
if (!strcmp("http.sslcapath", var)) {
if (ssl_capath == NULL) {
- ssl_capath = xmalloc(strlen(value)+1);
- strcpy(ssl_capath, value);
+ if (!value)
+ return config_error_nonbool(var);
+ ssl_capath = xstrdup(value);
}
return 0;
}
#endif
if (!strcmp("http.sslcainfo", var)) {
if (ssl_cainfo == NULL) {
- ssl_cainfo = xmalloc(strlen(value)+1);
- strcpy(ssl_cainfo, value);
+ if (!value)
+ return config_error_nonbool(var);
+ ssl_cainfo = xstrdup(value);
}
return 0;
}
@@ -157,8 +161,9 @@ static int http_options(const char *var, const char *value)
}
if (!strcmp("http.proxy", var)) {
if (curl_http_proxy == NULL) {
- curl_http_proxy = xmalloc(strlen(value)+1);
- strcpy(curl_http_proxy, value);
+ if (!value)
+ return config_error_nonbool(var);
+ curl_http_proxy = xstrdup(value);
}
return 0;
}
diff --git a/imap-send.c b/imap-send.c
index a429a76a6..9025d9aa3 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -1254,6 +1254,10 @@ git_imap_config(const char *key, const char *val)
if (strncmp( key, imap_key, sizeof imap_key - 1 ))
return 0;
+
+ if (!val)
+ return config_error_nonbool(key);
+
key += sizeof imap_key - 1;
if (!strcmp( "folder", key )) {
diff --git a/merge-recursive.c b/merge-recursive.c
index c292a77a8..34e3167ca 100644
--- a/merge-recursive.c
+++ b/merge-recursive.c
@@ -844,8 +844,9 @@ static int read_merge_config(const char *var, const char *value)
int namelen;
if (!strcmp(var, "merge.default")) {
- if (value)
- default_ll_merge = strdup(value);
+ if (!value)
+ return config_error_nonbool(var);
+ default_ll_merge = strdup(value);
return 0;
}
@@ -878,14 +879,14 @@ static int read_merge_config(const char *var, const char *value)
if (!strcmp("name", ep)) {
if (!value)
- return error("%s: lacks value", var);
+ return config_error_nonbool(var);
fn->description = strdup(value);
return 0;
}
if (!strcmp("driver", ep)) {
if (!value)
- return error("%s: lacks value", var);
+ return config_error_nonbool(var);
/*
* merge.<name>.driver specifies the command line:
*
@@ -908,7 +909,7 @@ static int read_merge_config(const char *var, const char *value)
if (!strcmp("recursive", ep)) {
if (!value)
- return error("%s: lacks value", var);
+ return config_error_nonbool(var);
fn->recursive = strdup(value);
return 0;
}
diff --git a/remote.c b/remote.c
index 0e006804e..20abbc07a 100644
--- a/remote.c
+++ b/remote.c
@@ -222,15 +222,18 @@ static int handle_config(const char *key, const char *value)
subkey = strrchr(name, '.');
if (!subkey)
return 0;
- if (!value)
- return 0;
branch = make_branch(name, subkey - name);
if (!strcmp(subkey, ".remote")) {
+ if (!value)
+ return config_error_nonbool(key);
branch->remote_name = xstrdup(value);
if (branch == current_branch)
default_remote_name = branch->remote_name;
- } else if (!strcmp(subkey, ".merge"))
+ } else if (!strcmp(subkey, ".merge")) {
+ if (!value)
+ return config_error_nonbool(key);
add_merge(branch, xstrdup(value));
+ }
return 0;
}
if (prefixcmp(key, "remote."))
diff --git a/setup.c b/setup.c
index adede16a4..4509598d5 100644
--- a/setup.c
+++ b/setup.c
@@ -372,6 +372,8 @@ int check_repository_format_version(const char *var, const char *value)
if (is_bare_repository_cfg == 1)
inside_work_tree = -1;
} else if (strcmp(var, "core.worktree") == 0) {
+ if (!value)
+ return config_error_nonbool(var);
if (git_work_tree_cfg)
free(git_work_tree_cfg);
git_work_tree_cfg = xstrdup(value);
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 66aeb88db..4928a5711 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -71,6 +71,25 @@ EOF
test_expect_success 'non-match result' 'cmp .git/config expect'
+cat > .git/config <<\EOF
+[alpha]
+bar = foo
+[beta]
+baz = multiple \
+lines
+EOF
+
+test_expect_success 'unset with cont. lines' \
+ 'git config --unset beta.baz'
+
+cat > expect <<\EOF
+[alpha]
+bar = foo
+[beta]
+EOF
+
+test_expect_success 'unset with cont. lines is correct' 'cmp .git/config expect'
+
cat > .git/config << EOF
[beta] ; silly comment # another comment
noIndent= sillyValue ; 'nother silly comment
diff --git a/t/t5304-prune.sh b/t/t5304-prune.sh
new file mode 100644
index 000000000..6560af756
--- /dev/null
+++ b/t/t5304-prune.sh
@@ -0,0 +1,32 @@
+#!/bin/sh
+#
+# Copyright (c) 2008 Johannes E. Schindelin
+#
+
+test_description='prune'
+. ./test-lib.sh
+
+test_expect_success setup '
+
+ : > file &&
+ git add file &&
+ test_tick &&
+ git commit -m initial &&
+ git gc
+
+'
+
+test_expect_success 'prune stale packs' '
+
+ orig_pack=$(echo .git/objects/pack/*.pack) &&
+ : > .git/objects/tmp_1.pack &&
+ : > .git/objects/tmp_2.pack &&
+ test-chmtime -86501 .git/objects/tmp_1.pack &&
+ git prune --expire 1.day &&
+ test -f $orig_pack &&
+ test -f .git/objects/tmp_2.pack &&
+ ! test -f .git/objects/tmp_1.pack
+
+'
+
+test_done
diff --git a/t/t6030-bisect-porcelain.sh b/t/t6030-bisect-porcelain.sh
index 2ba4b00e5..ec71123f4 100755
--- a/t/t6030-bisect-porcelain.sh
+++ b/t/t6030-bisect-porcelain.sh
@@ -254,6 +254,18 @@ test_expect_success 'bisect run & skip: find first bad' '
grep "$HASH6 is first bad commit" my_bisect_log.txt
'
+test_expect_success 'bisect starting with a detached HEAD' '
+
+ git bisect reset &&
+ git checkout master^ &&
+ HEAD=$(git rev-parse --verify HEAD) &&
+ git bisect start &&
+ test $HEAD = $(cat .git/head-name) &&
+ git bisect reset &&
+ test $HEAD = $(git rev-parse --verify HEAD)
+
+'
+
#
#
test_done
diff --git a/wt-status.c b/wt-status.c
index c0c247243..bfd1b0fcc 100644
--- a/wt-status.c
+++ b/wt-status.c
@@ -402,6 +402,8 @@ int git_status_config(const char *k, const char *v)
}
if (!prefixcmp(k, "status.color.") || !prefixcmp(k, "color.status.")) {
int slot = parse_status_slot(k, 13);
+ if (!v)
+ return config_error_nonbool(k);
color_parse(v, k, wt_status_colors[slot]);
return 0;
}