From e1b10391eabdaaa4c89c53099dd96d5f9d978719 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 11 Oct 2005 18:47:34 -0700 Subject: Use git config file for committer name and email info This starts using the "user.name" and "user.email" config variables if they exist as the default name and email when committing. This means that you don't have to use the GIT_COMMITTER_EMAIL environment variable to override your email - you can just edit the config file instead. The patch looks bigger than it is because it makes the default name and email information non-static and renames it appropriately. And it moves the common git environment variables into a new library file, so that you can link against libgit.a and get the git environment without having to link in zlib and libcrypt. In short, most of it is renaming and moving, the real change core is just a few new lines in "git_default_config()" that copies the user config values to the new base. It also changes "git-var -l" to list the config variables. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- commit-tree.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'commit-tree.c') diff --git a/commit-tree.c b/commit-tree.c index b1ef0b590a..030fb704e5 100644 --- a/commit-tree.c +++ b/commit-tree.c @@ -89,6 +89,9 @@ int main(int argc, char **argv) char *buffer; unsigned int size; + setup_ident(); + git_config(git_default_config); + if (argc < 2 || get_sha1_hex(argv[1], tree_sha1) < 0) usage(commit_tree_usage); @@ -104,7 +107,6 @@ int main(int argc, char **argv) } if (!parents) fprintf(stderr, "Committing initial tree %s\n", argv[1]); - setup_ident(); init_buffer(&buffer, &size); add_buffer(&buffer, &size, "tree %s\n", sha1_to_hex(tree_sha1)); -- cgit v1.2.3 From 4546738b58a0134eef154231b07d60fc174d56e3 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 13 Oct 2005 11:03:18 -0700 Subject: Unlocalized isspace and friends Do our own ctype.h, just to get the sane semantics: we want locale-independence, _and_ we want the right signed behaviour. Plus we only use a very small subset of ctype.h anyway (isspace, isalpha, isdigit and isalnum). Signed-off-by: Junio C Hamano --- Makefile | 3 ++- apply.c | 1 - cache.h | 26 ++++++++++++++++++++++++++ commit-tree.c | 1 - commit.c | 1 - config.c | 1 - convert-objects.c | 1 - ctype.c | 23 +++++++++++++++++++++++ date.c | 1 - diff-tree.c | 1 - ident.c | 1 - mailsplit.c | 1 - pack-objects.c | 1 - patch-id.c | 1 - refs.c | 1 - update-ref.c | 1 - 16 files changed, 51 insertions(+), 14 deletions(-) create mode 100644 ctype.c (limited to 'commit-tree.c') diff --git a/Makefile b/Makefile index e2e87f6beb..9fe65ba2be 100644 --- a/Makefile +++ b/Makefile @@ -159,7 +159,8 @@ LIB_OBJS = \ object.o pack-check.o patch-delta.o path.o pkt-line.o \ quote.o read-cache.o refs.o run-command.o \ server-info.o setup.o sha1_file.o sha1_name.o strbuf.o \ - tag.o tree.o usage.o config.o environment.o $(DIFF_OBJS) + tag.o tree.o usage.o config.o environment.o ctype.o \ + $(DIFF_OBJS) LIBS = $(LIB_FILE) LIBS += -lz diff --git a/apply.c b/apply.c index 155fbe84da..f4d00f2835 100644 --- a/apply.c +++ b/apply.c @@ -6,7 +6,6 @@ * This applies patches on top of some (arbitrary) version of the SCM. * */ -#include #include #include "cache.h" diff --git a/cache.h b/cache.h index 328658235b..f1d15ab3c9 100644 --- a/cache.h +++ b/cache.h @@ -387,4 +387,30 @@ extern int git_config_bool(const char *, const char *); extern char git_default_email[MAX_GITNAME]; extern char git_default_name[MAX_GITNAME]; +/* Sane ctype - no locale, and works with signed chars */ +#undef isspace +#undef isdigit +#undef isalpha +#undef isalnum +#undef tolower +#undef toupper +extern unsigned char sane_ctype[256]; +#define GIT_SPACE 0x01 +#define GIT_DIGIT 0x02 +#define GIT_ALPHA 0x04 +#define sane_istest(x,mask) ((sane_ctype[(unsigned char)(x)] & (mask)) != 0) +#define isspace(x) sane_istest(x,GIT_SPACE) +#define isdigit(x) sane_istest(x,GIT_DIGIT) +#define isalpha(x) sane_istest(x,GIT_ALPHA) +#define isalnum(x) sane_istest(x,GIT_ALPHA | GIT_DIGIT) +#define tolower(x) sane_case((unsigned char)(x), 0x20) +#define toupper(x) sane_case((unsigned char)(x), 0) + +static inline int sane_case(int x, int high) +{ + if (sane_istest(x, GIT_ALPHA)) + x = (x & ~0x20) | high; + return x; +} + #endif /* CACHE_H */ diff --git a/commit-tree.c b/commit-tree.c index 030fb704e5..ea0fdd44e2 100644 --- a/commit-tree.c +++ b/commit-tree.c @@ -7,7 +7,6 @@ #include #include -#include #define BLOCKING (1ul << 14) diff --git a/commit.c b/commit.c index f735f981bb..8f403180e5 100644 --- a/commit.c +++ b/commit.c @@ -1,4 +1,3 @@ -#include #include "tag.h" #include "commit.h" #include "cache.h" diff --git a/config.c b/config.c index 9b7c6f2942..519fecfee4 100644 --- a/config.c +++ b/config.c @@ -1,4 +1,3 @@ -#include #include "cache.h" diff --git a/convert-objects.c b/convert-objects.c index 9ad0c77678..a892013f0f 100644 --- a/convert-objects.c +++ b/convert-objects.c @@ -1,6 +1,5 @@ #define _XOPEN_SOURCE /* glibc2 needs this */ #include -#include #include "cache.h" struct entry { diff --git a/ctype.c b/ctype.c new file mode 100644 index 0000000000..56bdffa636 --- /dev/null +++ b/ctype.c @@ -0,0 +1,23 @@ +/* + * Sane locale-independent, ASCII ctype. + * + * No surprises, and works with signed and unsigned chars. + */ +#include "cache.h" + +#define SS GIT_SPACE +#define AA GIT_ALPHA +#define DD GIT_DIGIT + +unsigned char sane_ctype[256] = { + 0, 0, 0, 0, 0, 0, 0, 0, 0, SS, SS, 0, 0, SS, 0, 0, /* 0-15 */ + 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 16-15 */ + SS, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, /* 32-15 */ + DD, DD, DD, DD, DD, DD, DD, DD, DD, DD, 0, 0, 0, 0, 0, 0, /* 48-15 */ + 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, /* 64-15 */ + AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 80-15 */ + 0, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, /* 96-15 */ + AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, AA, 0, 0, 0, 0, 0, /* 112-15 */ + /* Nothing in the 128.. range */ +}; + diff --git a/date.c b/date.c index b21cadc4d6..63f5a09197 100644 --- a/date.c +++ b/date.c @@ -4,7 +4,6 @@ * Copyright (C) Linus Torvalds, 2005 */ -#include #include #include "cache.h" diff --git a/diff-tree.c b/diff-tree.c index 2203fa56d0..851722037d 100644 --- a/diff-tree.c +++ b/diff-tree.c @@ -1,4 +1,3 @@ -#include #include "cache.h" #include "diff.h" #include "commit.h" diff --git a/ident.c b/ident.c index 7a9f5672eb..1bfbc6ff35 100644 --- a/ident.c +++ b/ident.c @@ -9,7 +9,6 @@ #include #include -#include static char git_default_date[50]; diff --git a/mailsplit.c b/mailsplit.c index 0f8100dcca..189f4ed724 100644 --- a/mailsplit.c +++ b/mailsplit.c @@ -11,7 +11,6 @@ #include #include #include -#include #include #include "cache.h" diff --git a/pack-objects.c b/pack-objects.c index 8a1ee746e0..b3e6152033 100644 --- a/pack-objects.c +++ b/pack-objects.c @@ -1,4 +1,3 @@ -#include #include "cache.h" #include "object.h" #include "delta.h" diff --git a/patch-id.c b/patch-id.c index 960e7cedf9..edbc4aa3e8 100644 --- a/patch-id.c +++ b/patch-id.c @@ -1,4 +1,3 @@ -#include #include "cache.h" static void flush_current_id(int patchlen, unsigned char *id, SHA_CTX *c) diff --git a/refs.c b/refs.c index 5a8cbd4ef3..42240d2769 100644 --- a/refs.c +++ b/refs.c @@ -2,7 +2,6 @@ #include "cache.h" #include -#include /* We allow "recursive" symbolic refs. Only within reason, though */ #define MAXDEPTH 5 diff --git a/update-ref.c b/update-ref.c index 4a1704c1a5..65dc3d6385 100644 --- a/update-ref.c +++ b/update-ref.c @@ -1,6 +1,5 @@ #include "cache.h" #include "refs.h" -#include static const char git_update_ref_usage[] = "git-update-ref []"; -- cgit v1.2.3 From 5e5f8091e5c9b4f09ad4019c8fddbf25fd2ccbe9 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Tue, 18 Oct 2005 15:41:43 -0700 Subject: Remove unused include. Signed-off-by: Junio C Hamano --- commit-tree.c | 3 --- ident.c | 1 - 2 files changed, 4 deletions(-) (limited to 'commit-tree.c') diff --git a/commit-tree.c b/commit-tree.c index ea0fdd44e2..b60299fed0 100644 --- a/commit-tree.c +++ b/commit-tree.c @@ -5,9 +5,6 @@ */ #include "cache.h" -#include -#include - #define BLOCKING (1ul << 14) /* diff --git a/ident.c b/ident.c index 1bfbc6ff35..06d0e6cbd3 100644 --- a/ident.c +++ b/ident.c @@ -8,7 +8,6 @@ #include "cache.h" #include -#include static char git_default_date[50]; -- cgit v1.2.3