From 618faa1dc7cb5898473861c286391d0a4b043107 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 9 May 2006 19:23:23 -0700 Subject: checkout: use --aggressive when running a 3-way merge (-m). After doing an in-index 3-way merge, we always do the stock "merge-index merge-one-file" without doing anything fancy; use of --aggressive helps performance quite a bit. Signed-off-by: Junio C Hamano diff --git a/git-checkout.sh b/git-checkout.sh index 463ed2e..a11c939 100755 --- a/git-checkout.sh +++ b/git-checkout.sh @@ -144,7 +144,7 @@ else work=`git write-tree` && git read-tree --reset $new && git checkout-index -f -u -q -a && - git read-tree -m -u $old $new $work || exit + git read-tree -m -u --aggressive $old $new $work || exit if result=`git write-tree 2>/dev/null` then -- cgit v0.10.2-6-g49f6 From bdf0ef0824ecca427ec04ac047ffe4aaf73ace5a Mon Sep 17 00:00:00 2001 From: sean Date: Sat, 6 May 2006 14:14:02 -0400 Subject: Another config file parsing fix. If the variable we need to store should go into a section that currently only has a single variable (not matching the one we're trying to insert), we will already be into the next section before we notice we've bypassed the correct location to insert the variable. To handle this case we store the current location as soon as we find a variable matching the section of our new variable. This breakage was brought up by Linus. Signed-off-by: Sean Estabrooks Signed-off-by: Junio C Hamano diff --git a/config.c b/config.c index adb5ce4..0f518c9 100644 --- a/config.c +++ b/config.c @@ -336,8 +336,10 @@ static int store_aux(const char* key, const char* value) store.state = KEY_SEEN; store.seen++; } else if (strrchr(key, '.') - key == store.baselen && - !strncmp(key, store.key, store.baselen)) + !strncmp(key, store.key, store.baselen)) { store.state = SECTION_SEEN; + store.offset[store.seen] = ftell(config_file); + } } return 0; } -- cgit v0.10.2-6-g49f6 From d14f776402d9f7040cc71ff6e3b992b2e019526a Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 9 May 2006 12:24:02 -0700 Subject: git config syntax updates This updates the hierarchical section name syntax to [section+""] where the only rule for "randomstring" is that it can't contain a newline, and if you really want to insert a double-quote, you do it with \". It turns that into the section name "secion.randomstring". The "section" part is still case insensitive, but the "randomstring" part is case sensitive. So you could use this for things like [email "torvalds@osdl.org"] name = Linus Torvalds if you wanted to do the "email->name" conversion as part of the config file format (I'm not claiming that is sensible, I'm just giving it as an insane example). That would show up as the association email.torvalds@osdl.org.name -> Linus Torvalds which is easy to parse (the "." in the email _looks_ ambiguous, but it isn't: you know that there will always be a single key-name, so you find the key name with "strrchr(name, '.')" and things are entirely unambiguous). Repo-config is updated to be able to parse the new format, and also write things out in the new format. [jc: rolled two patches from Linus and one fix-up from Sean into one, with additional adjustments for t/t1300 test to check the case insensitiveness of section base and variable and case sensitiveness of the extended section part. Then stripped some part off to make the result applicable to the stale 1.3.X series that does not have recent enhancements. ] Signed-off-by: Linus Torvalds Signed-off-by: Sean Estabrooks Signed-off-by: Junio C Hamano diff --git a/config.c b/config.c index 0f518c9..0248c6d 100644 --- a/config.c +++ b/config.c @@ -134,6 +134,41 @@ static int get_value(config_fn_t fn, char *name, unsigned int len) return fn(name, value); } +static int get_extended_base_var(char *name, int baselen, int c) +{ + do { + if (c == '\n') + return -1; + c = get_next_char(); + } while (isspace(c)); + + /* We require the format to be '[base "extension"]' */ + if (c != '"') + return -1; + name[baselen++] = '.'; + + for (;;) { + int c = get_next_char(); + if (c == '\n') + return -1; + if (c == '"') + break; + if (c == '\\') { + c = get_next_char(); + if (c == '\n') + return -1; + } + name[baselen++] = c; + if (baselen > MAXNAME / 2) + return -1; + } + + /* Final ']' */ + if (get_next_char() != ']') + return -1; + return baselen; +} + static int get_base_var(char *name) { int baselen = 0; @@ -144,6 +179,8 @@ static int get_base_var(char *name) return -1; if (c == ']') return baselen; + if (isspace(c)) + return get_extended_base_var(name, baselen, c); if (!isalnum(c) && c != '.') return -1; if (baselen > MAXNAME / 2) @@ -335,10 +372,12 @@ static int store_aux(const char* key, const char* value) store.offset[store.seen] = ftell(config_file); store.state = KEY_SEEN; store.seen++; - } else if (strrchr(key, '.') - key == store.baselen && + } else { + if (strrchr(key, '.') - key == store.baselen && !strncmp(key, store.key, store.baselen)) { store.state = SECTION_SEEN; store.offset[store.seen] = ftell(config_file); + } } } return 0; @@ -346,8 +385,30 @@ static int store_aux(const char* key, const char* value) static void store_write_section(int fd, const char* key) { + const char *dot = strchr(key, '.'); + int len1 = store.baselen, len2 = -1; + + dot = strchr(key, '.'); + if (dot) { + int dotlen = dot - key; + if (dotlen < len1) { + len2 = len1 - dotlen - 1; + len1 = dotlen; + } + } + write(fd, "[", 1); - write(fd, key, store.baselen); + write(fd, key, len1); + if (len2 >= 0) { + write(fd, " \"", 2); + while (--len2 >= 0) { + unsigned char c = *++dot; + if (c == '"') + write(fd, "\\", 1); + write(fd, &c, 1); + } + write(fd, "\"", 1); + } write(fd, "]\n", 2); } @@ -421,7 +482,7 @@ int git_config_set(const char* key, const char* value) int git_config_set_multivar(const char* key, const char* value, const char* value_regex, int multi_replace) { - int i; + int i, dot; int fd = -1, in_fd; int ret; char* config_filename = strdup(git_path("config")); @@ -446,16 +507,23 @@ int git_config_set_multivar(const char* key, const char* value, * Validate the key and while at it, lower case it for matching. */ store.key = (char*)malloc(strlen(key)+1); - for (i = 0; key[i]; i++) - if (i != store.baselen && - ((!isalnum(key[i]) && key[i] != '.') || - (i == store.baselen+1 && !isalpha(key[i])))) { - fprintf(stderr, "invalid key: %s\n", key); - free(store.key); - ret = 1; - goto out_free; - } else - store.key[i] = tolower(key[i]); + dot = 0; + for (i = 0; key[i]; i++) { + unsigned char c = key[i]; + if (c == '.') + dot = 1; + /* Leave the extended basename untouched.. */ + if (!dot || i > store.baselen) { + if (!isalnum(c) || (i == store.baselen+1 && !isalpha(c))) { + fprintf(stderr, "invalid key: %s\n", key); + free(store.key); + ret = 1; + goto out_free; + } + c = tolower(c); + } + store.key[i] = c; + } store.key[i] = 0; /* diff --git a/repo-config.c b/repo-config.c index c5ebb76..58b6c52 100644 --- a/repo-config.c +++ b/repo-config.c @@ -48,11 +48,13 @@ static int show_config(const char* key_, const char* value_) static int get_value(const char* key_, const char* regex_) { int i; + char *tl; - key = malloc(strlen(key_)+1); - for (i = 0; key_[i]; i++) - key[i] = tolower(key_[i]); - key[i] = 0; + key = strdup(key_); + for (tl=key+strlen(key)-1; tl >= key && *tl != '.'; --tl) + *tl = tolower(*tl); + for (tl=key; *tl && *tl != '.'; ++tl) + *tl = tolower(*tl); if (regex_) { if (regex_[0] == '!') { diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh index ab4dd5c..028d159 100755 --- a/t/t1300-repo-config.sh +++ b/t/t1300-repo-config.sh @@ -229,7 +229,7 @@ test_expect_failure 'invalid key' 'git-repo-config inval.2key blabla' test_expect_success 'correct key' 'git-repo-config 123456.a123 987' test_expect_success 'hierarchical section' \ - 'git-repo-config 1.2.3.alpha beta' + 'git-repo-config Version.1.2.3eX.Alpha beta' cat > expect << EOF [beta] ; silly comment # another comment @@ -241,8 +241,8 @@ noIndent= sillyValue ; 'nother silly comment NoNewLine = wow2 for me [123456] a123 = 987 -[1.2.3] - alpha = beta +[Version "1.2.3eX"] + Alpha = beta EOF test_expect_success 'hierarchical section value' 'cmp .git/config expect' -- cgit v0.10.2-6-g49f6 From e88856b485cd73dfc1f3ef8d4c5b52a2f557e8c8 Mon Sep 17 00:00:00 2001 From: Dennis Stosberg Date: Thu, 11 May 2006 19:35:31 +0200 Subject: Fix compilation on newer NetBSD systems NetBSD >=2.0 has iconv() in libc. A libiconv is not required and does not exist. See: http://netbsd.gw.com/cgi-bin/man-cgi?iconv+3+NetBSD-2.0 [jc: with a bit of simplification later discussed on the list.] Signed-off-by: Dennis Stosberg Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 3972d10..9f6425d 100644 --- a/Makefile +++ b/Makefile @@ -281,7 +281,9 @@ ifeq ($(uname_S),OpenBSD) ALL_LDFLAGS += -L/usr/local/lib endif ifeq ($(uname_S),NetBSD) - NEEDS_LIBICONV = YesPlease + ifeq ($(shell expr "$(uname_R)" : '[01]\.'),2) + NEEDS_LIBICONV = YesPlease + endif ALL_CFLAGS += -I/usr/pkg/include ALL_LDFLAGS += -L/usr/pkg/lib -Wl,-rpath,/usr/pkg/lib endif -- cgit v0.10.2-6-g49f6 From f3dd5eae58cf3d0d944604af4c71a7043d5368fd Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 14 May 2006 19:26:56 -0700 Subject: Install git-send-email by default After 567ffeb7722eefab3991cb894c96548b92b57cc2 and 4bc87a28be020a6bf7387161c65ea3d8e4a0228b, git-send-email no longer requires any non-standard Perl modules, so there's no reason to special-case it. Signed-off-by: Eric Wong Signed-off-by: Junio C Hamano diff --git a/Makefile b/Makefile index 9f6425d..b808eca 100644 --- a/Makefile +++ b/Makefile @@ -131,7 +131,8 @@ SCRIPT_PERL = \ git-archimport.perl git-cvsimport.perl git-relink.perl \ git-shortlog.perl git-fmt-merge-msg.perl git-rerere.perl \ git-annotate.perl git-cvsserver.perl \ - git-svnimport.perl git-mv.perl git-cvsexportcommit.perl + git-svnimport.perl git-mv.perl git-cvsexportcommit.perl \ + git-send-email.perl SCRIPT_PYTHON = \ git-merge-recursive.py @@ -317,10 +318,6 @@ else endif endif -ifdef WITH_SEND_EMAIL - SCRIPT_PERL += git-send-email.perl -endif - ifndef NO_CURL ifdef CURLDIR # This is still problematic -- gcc does not always want -R. diff --git a/git.spec.in b/git.spec.in index 96dfc1d..8ccd256 100644 --- a/git.spec.in +++ b/git.spec.in @@ -74,12 +74,12 @@ Git revision tree visualiser ('gitk') %setup -q %build -make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_OWN_SUBPROCESS_PY=YesPlease WITH_SEND_EMAIL=1 \ +make %{_smp_mflags} CFLAGS="$RPM_OPT_FLAGS" WITH_OWN_SUBPROCESS_PY=YesPlease \ prefix=%{_prefix} all %{!?_without_docs: doc} %install rm -rf $RPM_BUILD_ROOT -make %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT WITH_OWN_SUBPROCESS_PY=YesPlease WITH_SEND_EMAIL=1 \ +make %{_smp_mflags} DESTDIR=$RPM_BUILD_ROOT WITH_OWN_SUBPROCESS_PY=YesPlease \ prefix=%{_prefix} mandir=%{_mandir} \ install %{!?_without_docs: install-doc} -- cgit v0.10.2-6-g49f6 From 1b9bc5a7b7434d771726011613a00cb202bd9f44 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Mon, 15 May 2006 12:52:00 -0700 Subject: Fix pack-index issue on 64-bit platforms a bit more portably. Apparently is not enough for uint32_t on OpenBSD; use "unsigned int" -- hopefully that would stay 32-bit on every platform we care about, at least until we update the pack-index file format. Our sha1 routines optimized for architectures use uint32_t and expects '#include ' to be enough, so OpenBSD on arm or ppc might have similar issues down the road, I dunno. Signed-off-by: Junio C Hamano diff --git a/pack-objects.c b/pack-objects.c index aa2c098..614e87b 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -10,7 +10,6 @@ #include "tree-walk.h" #include #include -#include static const char pack_usage[] = "git-pack-objects [-q] [--no-reuse-delta] [--non-empty] [--local] [--incremental] [--window=N] [--depth=N] {--stdout | base-name} < object-list"; @@ -157,7 +156,7 @@ static void prepare_pack_revindex(struct pack_revindex *rix) rix->revindex = xmalloc(sizeof(unsigned long) * (num_ent + 1)); for (i = 0; i < num_ent; i++) { - uint32_t hl = *((uint32_t *)(index + 24 * i)); + unsigned int hl = *((unsigned int *)(index + 24 * i)); rix->revindex[i] = ntohl(hl); } /* This knows the pack format -- the 20-byte trailer diff --git a/sha1_file.c b/sha1_file.c index 673c58d..66db206 100644 --- a/sha1_file.c +++ b/sha1_file.c @@ -13,7 +13,6 @@ #include "commit.h" #include "tag.h" #include "tree.h" -#include #ifndef O_NOATIME #if defined(__linux__) && (defined(__i386__) || defined(__PPC__)) @@ -1127,7 +1126,7 @@ int find_pack_entry_one(const unsigned char *sha1, int mi = (lo + hi) / 2; int cmp = memcmp(index + 24 * mi + 4, sha1, 20); if (!cmp) { - e->offset = ntohl(*((uint32_t *)(index + 24 * mi))); + e->offset = ntohl(*((unsigned int *)(index + 24 * mi))); memcpy(e->sha1, sha1, 20); e->p = p; return 1; -- cgit v0.10.2-6-g49f6