From 7a31cc0f96681d6cba54b38bb87daa2440bef448 Mon Sep 17 00:00:00 2001 From: Frank Lichtenheld Date: Mon, 11 Feb 2008 01:23:03 +0100 Subject: [PATCH 01/35] config: Fix --unset for continuation lines find_beginning_of_line didn't take into account that the previous line might have ended with \ in which case it shouldn't stop but continue its search. Signed-off-by: Frank Lichtenheld Acked-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- config.c | 5 +++++ t/t1300-repo-config.sh | 19 +++++++++++++++++++ 2 files changed, 24 insertions(+) diff --git a/config.c b/config.c index 526a3f429..e799f40db 100644 --- a/config.c +++ b/config.c @@ -701,12 +701,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; diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index 42eac2a7c..44dcc1f94 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 From 473d33168be9b0984f6281d5613f3b7b84817e99 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 11:22:01 -0800 Subject: [PATCH 02/35] git-pull documentation: fix markup A note paragraph was mistakenly made into an indented monospace display. Noticed by Miklos Vajna. Signed-off-by: Junio C Hamano --- Documentation/git-pull.txt | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) 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. From ce32660edc2b83c6fdf550f6869e0b01e255dadb Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Sun, 10 Feb 2008 13:59:50 +0000 Subject: [PATCH 03/35] bisect: allow starting with a detached HEAD Instead of insisting on a symbolic ref, bisect now accepts detached HEADs, too. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- git-bisect.sh | 8 ++++++-- t/t6030-bisect-porcelain.sh | 12 ++++++++++++ 2 files changed, 18 insertions(+), 2 deletions(-) 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/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 From 0ed50ceb48662e1d2b4e131f1ed79252062547dd Mon Sep 17 00:00:00 2001 From: Johannes Schindelin Date: Mon, 11 Feb 2008 11:27:20 +0000 Subject: [PATCH 04/35] Document that the default of branch.autosetupmerge is true In 34a3e69 (git-branch: default to --track) the default was changed to true, to help new git users. But yours truly forgot to update the documentation. This fixes it. Noticed by Kalle Olavi Niemitalo. Signed-off-by: Johannes Schindelin Signed-off-by: Junio C Hamano --- Documentation/config.txt | 2 +- Documentation/git-branch.txt | 15 ++++++++------- Documentation/git-checkout.txt | 7 ++++--- 3 files changed, 13 insertions(+), 11 deletions(-) diff --git a/Documentation/config.txt b/Documentation/config.txt index 4e222f15a..6d8cca46a 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..remote:: When in branch , 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 " 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, will be renamed to . @@ -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 " explicitly. Set the - branch.autosetupmerge configuration variable to true if you + don't want to use "git pull " 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 " explicitly. Set the - branch.autosetupmerge configuration variable to true if you + don't want to use "git pull " 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, From 65ae89bc315753e7bb31e941e77e002003665bc0 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Uwe=20Kleine-K=1B=2CAv=1B=28Bnig?= Date: Mon, 11 Feb 2008 14:45:26 +0100 Subject: [PATCH 05/35] rebase -i: accept -m as advertised in the man page MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Uwe Kleine-K,Av(Bnig Signed-off-by: Junio C Hamano --- git-rebase--interactive.sh | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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*) From 8464010f974245b1e392d34ddbfb914fcf3d8c23 Mon Sep 17 00:00:00 2001 From: David Steven Tweed Date: Thu, 7 Feb 2008 02:55:14 +0000 Subject: [PATCH 06/35] Make git prune remove temporary packs that look like write failures Write errors when repacking (eg, due to out-of-space conditions) can leave temporary packs (and possibly other files beginning with "tmp_") lying around which no existing codepath removes and which aren't obvious to the casual user. These can also be multi-megabyte files wasting noticeable space. Unfortunately there's no way to definitely tell in builtin-prune that a tmp_ file is not being used by a concurrent process, such as a fetch. However, it is documented that pruning should only be done on a quiet repository and --expire is honoured (using code from Johannes Schindelin, along with a test case he wrote) so that its safety is the same as that of loose object pruning. Since they might be signs of a problem (unlike orphaned loose objects) the names of any removed files are printed. Signed-off-by: David Tweed (david.tweed@gmail.com) Acked-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- builtin-prune.c | 39 +++++++++++++++++++++++++++++++++++++++ t/t5304-prune.sh | 32 ++++++++++++++++++++++++++++++++ 2 files changed, 71 insertions(+) create mode 100644 t/t5304-prune.sh 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/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 From 5a95b85566b1700e042fdce6ec2de9ce7b5a8787 Mon Sep 17 00:00:00 2001 From: Gerrit Pape Date: Fri, 8 Feb 2008 09:53:58 +0000 Subject: [PATCH 07/35] builtin-commit: remove .git/SQUASH_MSG upon successful commit MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit After doing a merge --squash, and commit afterwards, the commit message template SQUASH_MSG in the git directory is not removed, which means that the content of SQUASH_MSG is used as default commit message for all subsequent commits. So have git commit remove the file SQUASH_MSG from the git directory upon a successful commit. The problem was discovered by Frédéric Brière, reported through http://bugs.debian.org/464656 Signed-off-by: Gerrit Pape Signed-off-by: Junio C Hamano --- builtin-commit.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin-commit.c b/builtin-commit.c index c787bed69..3a47275b8 100644 --- a/builtin-commit.c +++ b/builtin-commit.c @@ -929,6 +929,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" From 9c2174350cc0ae0f6bad126e15fe1f9f044117ab Mon Sep 17 00:00:00 2001 From: Martin Koegler Date: Mon, 11 Feb 2008 08:26:25 +0100 Subject: [PATCH 08/35] pack-objects: only throw away data during memory pressure If pack-objects hit the memory limit, it deletes objects from the delta window. This patch make it only delete the data, which is recomputed, if needed again. Signed-off-by: Martin Koegler Acked-by: Nicolas Pitre Signed-off-by: Junio C Hamano --- builtin-pack-objects.c | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/builtin-pack-objects.c b/builtin-pack-objects.c index d3efeff03..4113f013c 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) From e94a45de42cea90f6fbd313cfabb5dd10d49e03c Mon Sep 17 00:00:00 2001 From: James Bowes Date: Mon, 4 Feb 2008 08:13:07 -0500 Subject: [PATCH 09/35] Add a BuildRequires for gettext in the spec file. Signed-off-by: James Bowes Signed-off-by: Junio C Hamano --- git.spec.in | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/git.spec.in b/git.spec.in index 659f05881..3f9f88815 100644 --- a/git.spec.in +++ b/git.spec.in @@ -8,7 +8,7 @@ License: GPL Group: Development/Tools URL: http://kernel.org/pub/software/scm/git/ Source: http://kernel.org/pub/software/scm/git/%{name}-%{version}.tar.gz -BuildRequires: zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel %{!?_without_docs:, xmlto, asciidoc > 6.0.3} +BuildRequires: zlib-devel >= 1.2, openssl-devel, curl-devel, expat-devel, gettext %{!?_without_docs:, xmlto, asciidoc > 6.0.3} BuildRoot: %{_tmppath}/%{name}-%{version}-%{release}-root-%(%{__id_u} -n) Requires: git-core = %{version}-%{release} @@ -181,6 +181,9 @@ rm -rf $RPM_BUILD_ROOT %{!?_without_docs: %doc Documentation/technical} %changelog +* Sun Feb 03 2008 James Bowes +- Add a BuildRequires for gettext + * Fri Jan 11 2008 Junio C Hamano - Include gitk message files From ac3593da8f224d32cd4ffbd43ee7a04c732686dc Mon Sep 17 00:00:00 2001 From: Jonas Fonseca Date: Mon, 4 Feb 2008 23:01:20 +0100 Subject: [PATCH 10/35] man pages are littered with .ft C and others Jakub Narebski wrote Sun, Feb 03, 2008: > Junio C Hamano wrote: > > Jakub Narebski writes: > > > > [From] http://thread.gmane.org/gmane.comp.version-control.git/53457/focus=53458 > Julian Phillips: > > Are you using docbook xsl 1.72? There are known problems building the > > manpages with that version. 1.71 works, and 1.73 should work when it get > > released. I was able to solve this problem with this patch, which adds a XSL file used specifically for DOCBOOK_XSL_172=YesPlease and where dots and backslashes are escaped properly so they won't be substituted to the wrong thing further down the "DocBook XSL pipeline". Doing the escaping in the existing callout.xsl breaks v1.70.1. Hopefully v1.73 will end this part of the manpage nightmare. Signed-off-by: Junio C Hamano --- Documentation/Makefile | 4 +++- Documentation/manpage-1.72.xsl | 17 +++++++++++++++++ 2 files changed, 20 insertions(+), 1 deletion(-) create mode 100644 Documentation/manpage-1.72.xsl diff --git a/Documentation/Makefile b/Documentation/Makefile index 7a325462e..43781fb24 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -45,6 +45,7 @@ man7dir=$(mandir)/man7 ASCIIDOC=asciidoc ASCIIDOC_EXTRA = +MANPAGE_XSL = callouts.xsl INSTALL?=install RM ?= rm -f DOC_REF = origin/man @@ -65,6 +66,7 @@ ASCIIDOC_EXTRA += -a asciidoc7compatible endif ifdef DOCBOOK_XSL_172 ASCIIDOC_EXTRA += -a docbook-xsl-172 +MANPAGE_XSL = manpage-1.72.xsl endif # @@ -159,7 +161,7 @@ $(MAN_HTML): %.html : %.txt %.1 %.5 %.7 : %.xml $(RM) $@ - xmlto -m callouts.xsl man $< + xmlto -m $(MANPAGE_XSL) man $< %.xml : %.txt $(RM) $@+ $@ diff --git a/Documentation/manpage-1.72.xsl b/Documentation/manpage-1.72.xsl new file mode 100644 index 000000000..fe3cd72d6 --- /dev/null +++ b/Documentation/manpage-1.72.xsl @@ -0,0 +1,17 @@ + + + + + + + ⌂sp + + + + + + + ⌂br + + + From b26768e25685b4f575ae07a38e5180b9879bd01e Mon Sep 17 00:00:00 2001 From: Mike Hommey Date: Sat, 9 Feb 2008 10:41:36 +0100 Subject: [PATCH 11/35] Work around curl-gnutls not liking to be reinitialized curl versions 7.16.3 to 7.18.0 included had a regression in which https requests following curl_global_cleanup/init sequence would fail with ASN1 parser errors with curl-gnutls. Such sequences happen in some cases such as git fetch. We work around this by removing the http_init and http_cleanup calls from get_refs_via_curl, replacing them with a transport->data initialization with the http_walker (which does http_init). While the http_walker is not currently used in get_refs_via_curl, http and walker code refactor will make it use it. Signed-off-by: Mike Hommey Signed-off-by: Junio C Hamano --- transport.c | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/transport.c b/transport.c index babaa2139..497f85372 100644 --- a/transport.c +++ b/transport.c @@ -441,11 +441,12 @@ static struct ref *get_refs_via_curl(struct transport *transport) struct ref *ref = NULL; struct ref *last_ref = NULL; + if (!transport->data) + transport->data = get_http_walker(transport->url); + refs_url = xmalloc(strlen(transport->url) + 11); sprintf(refs_url, "%s/info/refs", transport->url); - http_init(); - slot = get_active_slot(); slot->results = &results; curl_easy_setopt(slot->curl, CURLOPT_FILE, &buffer); @@ -473,8 +474,6 @@ static struct ref *get_refs_via_curl(struct transport *transport) return NULL; } - http_cleanup(); - data = buffer.buf; start = NULL; mid = data; From cc1816b0d64a2aa3d6c32d642c3b403f8625c484 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 8 Feb 2008 20:38:22 -0800 Subject: [PATCH 12/35] archive-tar.c: guard config parser from value=NULL Signed-off-by: Junio C Hamano --- archive-tar.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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 { From c5e5a2c097240e7d51374eef398d388c5ee5cc9b Mon Sep 17 00:00:00 2001 From: Miklos Vajna Date: Fri, 8 Feb 2008 15:26:18 +0100 Subject: [PATCH 13/35] builtin-gc.c: guard config parser from value=NULL Signed-off-by: Miklos Vajna Signed-off-by: Junio C Hamano --- builtin-gc.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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); From 40ea4ed9032a80c9dba706d6030bd11b08c35f4d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:41:18 -0800 Subject: [PATCH 14/35] Add config_error_nonbool() helper function This is used to report misconfigured configuration file that does not give any value to a non-boolean variable, e.g. [section] var It is perfectly fine to say it if the section.var is a boolean (it means true), but if a variable expects a string value it should be flagged as a configuration error. Signed-off-by: Junio C Hamano --- cache.h | 1 + config.c | 9 +++++++++ 2 files changed, 10 insertions(+) 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 e799f40db..03c94a270 100644 --- a/config.c +++ b/config.c @@ -1079,3 +1079,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); +} From a0ed3e6adea2ca69b7f4a76ac771e39cc9fa272e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:44:49 -0800 Subject: [PATCH 15/35] builtin-apply.c: guard config parser from value=NULL apply.whitespace configuration expects a string value. Signed-off-by: Junio C Hamano --- builtin-apply.c | 2 ++ 1 file changed, 2 insertions(+) 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; } From 5768c98ab8892ee0ca46e23ed46c4d94e0503e72 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:45:50 -0800 Subject: [PATCH 16/35] builtin-branch.c: guard config parser from value=NULL color.branch.* configuration variables expect a string value. Signed-off-by: Junio C Hamano --- builtin-branch.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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); } From d865eb2a0d5f121a46dfcc18c78e7f27e0af0fbc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:46:39 -0800 Subject: [PATCH 17/35] builtin-commit.c: guard config parser from value=NULL commit.template configuration expects a string value. Signed-off-by: Junio C Hamano --- builtin-commit.c | 2 ++ 1 file changed, 2 insertions(+) diff --git a/builtin-commit.c b/builtin-commit.c index 3a47275b8..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; } From f769982d02f70534789593e2bab889c9aa3a641c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:48:12 -0800 Subject: [PATCH 18/35] builtin-config.c: guard config parser from value=NULL color configuration variables expect a string value. Signed-off-by: Junio C Hamano --- builtin-config.c | 2 ++ 1 file changed, 2 insertions(+) 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; } From 995c45279e270811f53b7ff8bf44a07ed3457ddc Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:48:55 -0800 Subject: [PATCH 19/35] builtin-log.c: guard config parser from value=NULL format.subjectprefix configuration expects a string value. Signed-off-by: Junio C Hamano --- builtin-log.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-log.c b/builtin-log.c index dcc9f8179..9458428a8 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; } From 4f342b96d15205ec052e400f10121dd7cee39963 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:50:06 -0800 Subject: [PATCH 20/35] builtin-reflog.c: guard config parser from value=NULL gc.reflogexpire and gc.reflogexpireunreachable configuration expect a string value suitable for calling approxidate() with. Signed-off-by: Junio C Hamano --- builtin-reflog.c | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) 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) From 4f9c412bf778e091d06cd01376b64cef15e3954c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:51:03 -0800 Subject: [PATCH 21/35] builtin-show-branch.c: guard config parser from value=NULL showbranch.default configuration expects a string value. Signed-off-by: Junio C Hamano --- builtin-show-branch.c | 2 ++ 1 file changed, 2 insertions(+) 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); From 406d95f2d013bd17d79bbcf9438a2f03bd70a78a Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:51:31 -0800 Subject: [PATCH 22/35] builtin-tag.c: guard config parser from value=NULL user.signingkey configuration expects a string value. Signed-off-by: Junio C Hamano --- builtin-tag.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) 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; } From c64b9ad0fc02134d7271eb841fbdef9bc16660ea Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:52:15 -0800 Subject: [PATCH 23/35] connect.c: guard config parser from value=NULL core.gitproxy configuration expects a string value. Signed-off-by: Junio C Hamano --- connect.c | 2 ++ 1 file changed, 2 insertions(+) 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 From a7269e5cb703083efb084ba19bc703ebc915aa5c Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:53:36 -0800 Subject: [PATCH 24/35] convert.c: guard config parser from value=NULL filter.*.smudge and filter.*.clean configuration variables expect a string value. Signed-off-by: Junio C Hamano --- convert.c | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) 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; } From 64f30e948be5fb2cd2f65e91c0eab5ab4719c636 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:53:56 -0800 Subject: [PATCH 25/35] diff.c: guard config parser from value=NULL diff.external, diff.*.command, diff.color.*, color.diff.* and diff.*.funcname configuration variables expect a string value. Signed-off-by: Junio C Hamano --- diff.c | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) 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); + } } } From e08404a82d19a60fd60822e8c0d95dd5629e0809 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:56:06 -0800 Subject: [PATCH 26/35] git.c: guard config parser from value=NULL alias.* configuration expects a string value Signed-off-by: Junio C Hamano --- git.c | 2 ++ 1 file changed, 2 insertions(+) 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; From b51b2bb4c3da805727fd43219e3f817475ae52d3 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:56:26 -0800 Subject: [PATCH 27/35] help.c: guard config parser from value=NULL help.format configuration expects a string value Signed-off-by: Junio C Hamano --- help.c | 2 ++ 1 file changed, 2 insertions(+) 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; } From 111dd25f3c34ccad101047c32e89d1bb87136f60 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:57:22 -0800 Subject: [PATCH 28/35] http.c: guard config parser from value=NULL http.sslcert and friends expect a string value Signed-off-by: Junio C Hamano --- http.c | 25 +++++++++++++++---------- 1 file changed, 15 insertions(+), 10 deletions(-) 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; } From e098368b5b990eb05cbc60a271ab6d731820e0c2 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 10:59:17 -0800 Subject: [PATCH 29/35] merge-recursive.c: guard config parser from value=NULL merge.default, merge.*.{name,driver} expect a string value Signed-off-by: Junio C Hamano --- merge-recursive.c | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) 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..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; } From d2370cc2960d3b0a090c57dfea99209c59b515f7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 11:00:10 -0800 Subject: [PATCH 30/35] remote.c: guard config parser from value=NULL branch.*.{remote,merge} expect a string value Signed-off-by: Junio C Hamano --- remote.c | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) 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.")) From 180483c5c94a37c9fe304dded99d3db56d2d2b38 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 11:00:32 -0800 Subject: [PATCH 31/35] setup.c: guard config parser from value=NULL core.worktree expects a string value Signed-off-by: Junio C Hamano --- setup.c | 2 ++ 1 file changed, 2 insertions(+) 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); From 451d36bb25e1832dbe66b799f6526daa0b637d26 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 11:00:57 -0800 Subject: [PATCH 32/35] wt-status.c: guard config parser from value=NULL status.color.* and color.status.* expect a string value Signed-off-by: Junio C Hamano --- wt-status.c | 2 ++ 1 file changed, 2 insertions(+) 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; } From 3c17c34ac79f58665db73deeb995bc070b7f1a2f Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 12:04:00 -0800 Subject: [PATCH 33/35] imap-send.c: guard config parser from value=NULL None of the configuration variables this expects is boolean. Signed-off-by: Junio C Hamano --- imap-send.c | 4 ++++ 1 file changed, 4 insertions(+) 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 )) { From 90f5c1864caf40ac2a0fef6bc771eab3ecc561b6 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 13:09:16 -0800 Subject: [PATCH 34/35] builtin-log.c: guard config parser from value=NULL format.suffix expects a string value. format.numbered is bool plus "auto" Signed-off-by: Junio C Hamano --- builtin-log.c | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/builtin-log.c b/builtin-log.c index 9458428a8..99d69f079 100644 --- a/builtin-log.c +++ b/builtin-log.c @@ -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; } From 6c47d0e8f3983cff5bf633cb8e6f7ecfecf48db7 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 11 Feb 2008 13:10:27 -0800 Subject: [PATCH 35/35] config.c: guard config parser from value=NULL user.{name,email}, core.{pager,editor,excludesfile,whitespace} and i18n.{commit,logoutput}encoding all expect string values. Signed-off-by: Junio C Hamano --- config.c | 16 +++++++++++++++- 1 file changed, 15 insertions(+), 1 deletion(-) diff --git a/config.c b/config.c index 03c94a270..3f4d3b160 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; }