summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Documentation/git-repo-config.txt12
-rw-r--r--Documentation/git-send-email.txt9
-rw-r--r--Makefile5
-rw-r--r--blame.c4
-rw-r--r--builtin-apply.c6
-rw-r--r--builtin-diff-files.c2
-rw-r--r--builtin-diff-index.c2
-rw-r--r--builtin-diff-tree.c42
-rw-r--r--builtin-diff.c26
-rw-r--r--builtin-grep.c16
-rw-r--r--builtin-log.c4
-rw-r--r--builtin-read-tree.c3
-rw-r--r--builtin-rev-list.c64
-rw-r--r--config.c43
-rw-r--r--connect.c5
-rwxr-xr-xcontrib/git-svn/git-svn.perl14
-rw-r--r--convert-objects.c22
-rw-r--r--csum-file.c4
-rw-r--r--daemon.c5
-rw-r--r--diff-delta.c5
-rw-r--r--diff-lib.c45
-rw-r--r--diff.c2
-rw-r--r--diffcore-order.c2
-rwxr-xr-xgit-send-email.perl14
-rw-r--r--http-fetch.c15
-rw-r--r--http-push.c43
-rw-r--r--http.c4
-rw-r--r--imap-send.c2
-rw-r--r--merge-index.c5
-rw-r--r--name-rev.c19
-rw-r--r--object-refs.c33
-rw-r--r--object.c17
-rw-r--r--object.h13
-rw-r--r--pack-check.c6
-rw-r--r--pack-objects.c4
-rw-r--r--pack-redundant.c18
-rw-r--r--patch-delta.c4
-rw-r--r--pkt-line.c4
-rw-r--r--quote.c9
-rw-r--r--read-cache.c13
-rw-r--r--repo-config.c37
-rw-r--r--revision.c33
-rw-r--r--revision.h12
-rw-r--r--sha1_file.c29
-rw-r--r--ssh-fetch.c2
-rw-r--r--t/Makefile2
-rwxr-xr-xt/t1300-repo-config.sh24
-rw-r--r--tag.c4
-rw-r--r--tree-walk.c11
49 files changed, 446 insertions, 273 deletions
diff --git a/Documentation/git-repo-config.txt b/Documentation/git-repo-config.txt
index d5142e0dcd..803c0d5cae 100644
--- a/Documentation/git-repo-config.txt
+++ b/Documentation/git-repo-config.txt
@@ -73,6 +73,18 @@ OPTIONS
List all variables set in .git/config.
+ENVIRONMENT
+-----------
+
+GIT_CONFIG::
+ Take the configuration from the given file instead of .git/config.
+
+GIT_CONFIG_LOCAL::
+ Currently the same as $GIT_CONFIG; when Git will support global
+ configuration files, this will cause it to take the configuration
+ from the global configuration file in addition to the given file.
+
+
EXAMPLE
-------
diff --git a/Documentation/git-send-email.txt b/Documentation/git-send-email.txt
index ad1b9cf2e9..481b3f50e3 100644
--- a/Documentation/git-send-email.txt
+++ b/Documentation/git-send-email.txt
@@ -24,9 +24,16 @@ OPTIONS
-------
The options available are:
+--bcc::
+ Specify a "Bcc:" value for each email.
+
+ The --bcc option must be repeated for each user you want on the bcc list.
+
--cc::
Specify a starting "Cc:" value for each email.
+ The --cc option must be repeated for each user you want on the cc list.
+
--chain-reply-to, --no-chain-reply-to::
If this is set, each email will be sent as a reply to the previous
email sent. If disabled with "--no-chain-reply-to", all emails after
@@ -76,6 +83,8 @@ The options available are:
Generally, this will be the upstream maintainer of the
project involved.
+ The --to option must be repeated for each user you want on the to list.
+
Author
------
diff --git a/Makefile b/Makefile
index ae5e8d790a..69b5500f3f 100644
--- a/Makefile
+++ b/Makefile
@@ -472,7 +472,6 @@ PYTHON_PATH_SQ = $(subst ','\'',$(PYTHON_PATH))
GIT_PYTHON_DIR_SQ = $(subst ','\'',$(GIT_PYTHON_DIR))
ALL_CFLAGS += -DSHA1_HEADER='$(SHA1_HEADER_SQ)' $(COMPAT_CFLAGS)
-ALL_CFLAGS += -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"'
LIB_OBJS += $(COMPAT_OBJS)
export prefix TAR INSTALL DESTDIR SHELL_PATH template_dir
### Build rules
@@ -548,6 +547,8 @@ git$X git.spec \
exec_cmd.o: exec_cmd.c GIT-CFLAGS
$(CC) -o $*.o -c $(ALL_CFLAGS) '-DGIT_EXEC_PATH="$(gitexecdir_SQ)"' $<
+builtin-init-db.o: builtin-init-db.c GIT-CFLAGS
+ $(CC) -o $*.o -c $(ALL_CFLAGS) -DDEFAULT_GIT_TEMPLATE_DIR='"$(template_dir_SQ)"' $<
http.o: http.c GIT-CFLAGS
$(CC) -o $*.o -c $(ALL_CFLAGS) -DGIT_USER_AGENT='"git/$(GIT_VERSION)"' $<
@@ -611,7 +612,7 @@ tags:
find . -name '*.[hcS]' -print | xargs ctags -a
### Detect prefix changes
-TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_VERSION):\
+TRACK_CFLAGS = $(subst ','\'',$(ALL_CFLAGS)):$(GIT_PYTHON_DIR_SQ):\
$(bindir_SQ):$(gitexecdir_SQ):$(template_dir_SQ):$(prefix_SQ)
GIT-CFLAGS: .FORCE-GIT-CFLAGS
diff --git a/blame.c b/blame.c
index 7c0b62cf3f..c86e2fd4b3 100644
--- a/blame.c
+++ b/blame.c
@@ -301,9 +301,9 @@ static void fill_line_map(struct commit *commit, struct commit *other,
if (DEBUG)
printf("map: i1: %d %d %p i2: %d %d %p\n",
i1, map[i1],
- i1 != -1 ? blame_lines[map[i1]] : NULL,
+ (void *) (i1 != -1 ? blame_lines[map[i1]] : NULL),
i2, map2[i2],
- i2 != -1 ? blame_lines[map2[i2]] : NULL);
+ (void *) (i2 != -1 ? blame_lines[map2[i2]] : NULL));
if (map2[i2] != -1 &&
blame_lines[map[i1]] &&
!blame_lines[map2[i2]])
diff --git a/builtin-apply.c b/builtin-apply.c
index e113c74dd8..6dd0472ae0 100644
--- a/builtin-apply.c
+++ b/builtin-apply.c
@@ -148,7 +148,7 @@ static void *read_patch_file(int fd, unsigned long *sizep)
buffer = xrealloc(buffer, alloc);
nr = alloc - size;
}
- nr = xread(fd, buffer + size, nr);
+ nr = xread(fd, (char *) buffer + size, nr);
if (!nr)
break;
if (nr < 0)
@@ -164,7 +164,7 @@ static void *read_patch_file(int fd, unsigned long *sizep)
*/
if (alloc < size + SLOP)
buffer = xrealloc(buffer, size + SLOP);
- memset(buffer + size, 0, SLOP);
+ memset((char *) buffer + size, 0, SLOP);
return buffer;
}
@@ -1194,7 +1194,7 @@ static int read_old_data(struct stat *st, const char *path, void *buf, unsigned
return error("unable to open %s", path);
got = 0;
for (;;) {
- int ret = xread(fd, buf + got, size - got);
+ int ret = xread(fd, (char *) buf + got, size - got);
if (ret <= 0)
break;
got += ret;
diff --git a/builtin-diff-files.c b/builtin-diff-files.c
index cebda828ee..5afc1d7208 100644
--- a/builtin-diff-files.c
+++ b/builtin-diff-files.c
@@ -41,7 +41,7 @@ int cmd_diff_files(int argc, const char **argv, char **envp)
* rev.max_count is reasonable (0 <= n <= 3),
* there is no other revision filtering parameters.
*/
- if (rev.pending_objects ||
+ if (rev.pending.nr ||
rev.min_age != -1 || rev.max_age != -1)
usage(diff_files_usage);
/*
diff --git a/builtin-diff-index.c b/builtin-diff-index.c
index 1958580d82..c42ef9a7a7 100644
--- a/builtin-diff-index.c
+++ b/builtin-diff-index.c
@@ -32,7 +32,7 @@ int cmd_diff_index(int argc, const char **argv, char **envp)
* Make sure there is one revision (i.e. pending object),
* and there is no revision filtering parameters.
*/
- if (!rev.pending_objects || rev.pending_objects->next ||
+ if (rev.pending.nr != 1 ||
rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
usage(diff_cache_usage);
return run_diff_index(&rev, cached);
diff --git a/builtin-diff-tree.c b/builtin-diff-tree.c
index 58cf65856d..3409a39a9f 100644
--- a/builtin-diff-tree.c
+++ b/builtin-diff-tree.c
@@ -65,7 +65,6 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
char line[1000];
struct object *tree1, *tree2;
static struct rev_info *opt = &log_tree_opt;
- struct object_list *list;
int read_stdin = 0;
git_config(git_diff_config);
@@ -86,45 +85,28 @@ int cmd_diff_tree(int argc, const char **argv, char **envp)
}
/*
- * NOTE! "setup_revisions()" will have inserted the revisions
- * it parsed in reverse order. So if you do
- *
- * git-diff-tree a b
- *
- * the commit list will be "b" -> "a" -> NULL, so we reverse
- * the order of the objects if the first one is not marked
- * UNINTERESTING.
+ * NOTE! We expect "a ^b" to be equal to "a..b", so we
+ * reverse the order of the objects if the second one
+ * is marked UNINTERESTING.
*/
- nr_sha1 = 0;
- list = opt->pending_objects;
- if (list) {
- nr_sha1++;
- tree1 = list->item;
- list = list->next;
- if (list) {
- nr_sha1++;
- tree2 = tree1;
- tree1 = list->item;
- if (list->next)
- usage(diff_tree_usage);
- /* Switch them around if the second one was uninteresting.. */
- if (tree2->flags & UNINTERESTING) {
- struct object *tmp = tree2;
- tree2 = tree1;
- tree1 = tmp;
- }
- }
- }
-
+ nr_sha1 = opt->pending.nr;
switch (nr_sha1) {
case 0:
if (!read_stdin)
usage(diff_tree_usage);
break;
case 1:
+ tree1 = opt->pending.objects[0].item;
diff_tree_commit_sha1(tree1->sha1);
break;
case 2:
+ tree1 = opt->pending.objects[0].item;
+ tree2 = opt->pending.objects[1].item;
+ if (tree2->flags & UNINTERESTING) {
+ struct object *tmp = tree2;
+ tree2 = tree1;
+ tree1 = tmp;
+ }
diff_tree_sha1(tree1->sha1,
tree2->sha1,
"", &opt->diffopt);
diff --git a/builtin-diff.c b/builtin-diff.c
index 6ac3d4b8ca..99a2f76605 100644
--- a/builtin-diff.c
+++ b/builtin-diff.c
@@ -50,7 +50,7 @@ static int builtin_diff_files(struct rev_info *revs,
* specified rev.max_count is reasonable (0 <= n <= 3), and
* there is no other revision filtering parameter.
*/
- if (revs->pending_objects ||
+ if (revs->pending.nr ||
revs->min_age != -1 ||
revs->max_age != -1 ||
3 < revs->max_count)
@@ -172,7 +172,7 @@ static int builtin_diff_index(struct rev_info *revs,
* Make sure there is one revision (i.e. pending object),
* and there is no revision filtering parameters.
*/
- if (!revs->pending_objects || revs->pending_objects->next ||
+ if (revs->pending.nr != 1 ||
revs->max_count != -1 || revs->min_age != -1 ||
revs->max_age != -1)
usage(builtin_diff_usage);
@@ -181,10 +181,10 @@ static int builtin_diff_index(struct rev_info *revs,
static int builtin_diff_tree(struct rev_info *revs,
int argc, const char **argv,
- struct object_list *ent)
+ struct object_array_entry *ent)
{
const unsigned char *(sha1[2]);
- int swap = 1;
+ int swap = 0;
while (1 < argc) {
const char *arg = argv[1];
if (!strcmp(arg, "--raw"))
@@ -195,10 +195,10 @@ static int builtin_diff_tree(struct rev_info *revs,
}
/* We saw two trees, ent[0] and ent[1].
- * unless ent[0] is unintesting, they are swapped
+ * if ent[1] is unintesting, they are swapped
*/
- if (ent[0].item->flags & UNINTERESTING)
- swap = 0;
+ if (ent[1].item->flags & UNINTERESTING)
+ swap = 1;
sha1[swap] = ent[0].item->sha1;
sha1[1-swap] = ent[1].item->sha1;
diff_tree_sha1(sha1[0], sha1[1], "", &revs->diffopt);
@@ -208,7 +208,7 @@ static int builtin_diff_tree(struct rev_info *revs,
static int builtin_diff_combined(struct rev_info *revs,
int argc, const char **argv,
- struct object_list *ent,
+ struct object_array_entry *ent,
int ents)
{
const unsigned char (*parent)[20];
@@ -242,13 +242,14 @@ void add_head(struct rev_info *revs)
obj = parse_object(sha1);
if (!obj)
return;
- add_object(obj, &revs->pending_objects, NULL, "HEAD");
+ add_pending_object(revs, obj, "HEAD");
}
int cmd_diff(int argc, const char **argv, char **envp)
{
+ int i;
struct rev_info rev;
- struct object_list *list, ent[100];
+ struct object_array_entry ent[100];
int ents = 0, blobs = 0, paths = 0;
const char *path = NULL;
struct blobinfo blob[2];
@@ -281,7 +282,7 @@ int cmd_diff(int argc, const char **argv, char **envp)
/* Do we have --cached and not have a pending object, then
* default to HEAD by hand. Eek.
*/
- if (!rev.pending_objects) {
+ if (!rev.pending.nr) {
int i;
for (i = 1; i < argc; i++) {
const char *arg = argv[i];
@@ -294,7 +295,8 @@ int cmd_diff(int argc, const char **argv, char **envp)
}
}
- for (list = rev.pending_objects; list; list = list->next) {
+ for (i = 0; i < rev.pending.nr; i++) {
+ struct object_array_entry *list = rev.pending.objects+i;
struct object *obj = list->item;
const char *name = list->name;
int flags = (obj->flags & UNINTERESTING);
diff --git a/builtin-grep.c b/builtin-grep.c
index f7767bb4ee..2e7986cece 100644
--- a/builtin-grep.c
+++ b/builtin-grep.c
@@ -658,7 +658,7 @@ int cmd_grep(int argc, const char **argv, char **envp)
int cached = 0;
int seen_dashdash = 0;
struct grep_opt opt;
- struct object_list *list, **tail, *object_list = NULL;
+ struct object_array list = { 0, 0, NULL };
const char *prefix = setup_git_directory();
const char **paths = NULL;
int i;
@@ -678,7 +678,6 @@ int cmd_grep(int argc, const char **argv, char **envp)
* that continues up to the -- (if exists), and then paths.
*/
- tail = &object_list;
while (1 < argc) {
const char *arg = argv[1];
argc--; argv++;
@@ -852,12 +851,9 @@ int cmd_grep(int argc, const char **argv, char **envp)
/* Is it a rev? */
if (!get_sha1(arg, sha1)) {
struct object *object = parse_object(sha1);
- struct object_list *elem;
if (!object)
die("bad object %s", arg);
- elem = object_list_insert(object, tail);
- elem->name = arg;
- tail = &elem->next;
+ add_object_array(object, arg, &list);
continue;
}
if (!strcmp(arg, "--")) {
@@ -882,16 +878,16 @@ int cmd_grep(int argc, const char **argv, char **envp)
paths[1] = NULL;
}
- if (!object_list)
+ if (!list.nr)
return !grep_cache(&opt, paths, cached);
if (cached)
die("both --cached and trees are given.");
- for (list = object_list; list; list = list->next) {
+ for (i = 0; i < list.nr; i++) {
struct object *real_obj;
- real_obj = deref_tag(list->item, NULL, 0);
- if (grep_object(&opt, paths, real_obj, list->name))
+ real_obj = deref_tag(list.objects[i].item, NULL, 0);
+ if (grep_object(&opt, paths, real_obj, list.objects[i].name))
hit = 1;
}
return !hit;
diff --git a/builtin-log.c b/builtin-log.c
index 9187fd337b..5a8a50b81d 100644
--- a/builtin-log.c
+++ b/builtin-log.c
@@ -257,8 +257,8 @@ int cmd_format_patch(int argc, const char **argv, char **envp)
output_directory);
}
- if (rev.pending_objects && rev.pending_objects->next == NULL) {
- rev.pending_objects->item->flags |= UNINTERESTING;
+ if (rev.pending.nr == 1) {
+ rev.pending.objects[0].item->flags |= UNINTERESTING;
add_head(&rev);
}
diff --git a/builtin-read-tree.c b/builtin-read-tree.c
index 04506da892..9a2099d730 100644
--- a/builtin-read-tree.c
+++ b/builtin-read-tree.c
@@ -31,8 +31,7 @@ static int merge_size = 0;
static struct object_list *trees = NULL;
-static struct cache_entry df_conflict_entry = {
-};
+static struct cache_entry df_conflict_entry;
struct tree_entry_list {
struct tree_entry_list *next;
diff --git a/builtin-rev-list.c b/builtin-rev-list.c
index 71353eb19d..63bad0e96a 100644
--- a/builtin-rev-list.c
+++ b/builtin-rev-list.c
@@ -99,26 +99,26 @@ static void show_commit(struct commit *commit)
}
}
-static struct object_list **process_blob(struct blob *blob,
- struct object_list **p,
- struct name_path *path,
- const char *name)
+static void process_blob(struct blob *blob,
+ struct object_array *p,
+ struct name_path *path,
+ const char *name)
{
struct object *obj = &blob->object;
if (!revs.blob_objects)
- return p;
+ return;
if (obj->flags & (UNINTERESTING | SEEN))
- return p;
+ return;
obj->flags |= SEEN;
name = strdup(name);
- return add_object(obj, p, path, name);
+ add_object(obj, p, path, name);
}
-static struct object_list **process_tree(struct tree *tree,
- struct object_list **p,
- struct name_path *path,
- const char *name)
+static void process_tree(struct tree *tree,
+ struct object_array *p,
+ struct name_path *path,
+ const char *name)
{
struct object *obj = &tree->object;
struct tree_desc desc;
@@ -126,14 +126,14 @@ static struct object_list **process_tree(struct tree *tree,
struct name_path me;
if (!revs.tree_objects)
- return p;
+ return;
if (obj->flags & (UNINTERESTING | SEEN))
- return p;
+ return;
if (parse_tree(tree) < 0)
die("bad tree object %s", sha1_to_hex(obj->sha1));
obj->flags |= SEEN;
name = strdup(name);
- p = add_object(obj, p, path, name);
+ add_object(obj, p, path, name);
me.up = path;
me.elem = name;
me.elem_len = strlen(name);
@@ -143,57 +143,59 @@ static struct object_list **process_tree(struct tree *tree,
while (tree_entry(&desc, &entry)) {
if (S_ISDIR(entry.mode))
- p = process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
+ process_tree(lookup_tree(entry.sha1), p, &me, entry.path);
else
- p = process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
+ process_blob(lookup_blob(entry.sha1), p, &me, entry.path);
}
free(tree->buffer);
tree->buffer = NULL;
- return p;
}
static void show_commit_list(struct rev_info *revs)
{
+ int i;
struct commit *commit;
- struct object_list *objects = NULL, **p = &objects, *pending;
+ struct object_array objects = { 0, 0, NULL };
while ((commit = get_revision(revs)) != NULL) {
- p = process_tree(commit->tree, p, NULL, "");
+ process_tree(commit->tree, &objects, NULL, "");
show_commit(commit);
}
- for (pending = revs->pending_objects; pending; pending = pending->next) {
+ for (i = 0; i < revs->pending.nr; i++) {
+ struct object_array_entry *pending = revs->pending.objects + i;
struct object *obj = pending->item;
const char *name = pending->name;
if (obj->flags & (UNINTERESTING | SEEN))
continue;
if (obj->type == TYPE_TAG) {
obj->flags |= SEEN;
- p = add_object(obj, p, NULL, name);
+ add_object_array(obj, name, &objects);
continue;
}
if (obj->type == TYPE_TREE) {
- p = process_tree((struct tree *)obj, p, NULL, name);
+ process_tree((struct tree *)obj, &objects, NULL, name);
continue;
}
if (obj->type == TYPE_BLOB) {
- p = process_blob((struct blob *)obj, p, NULL, name);
+ process_blob((struct blob *)obj, &objects, NULL, name);
continue;
}
die("unknown pending object %s (%s)", sha1_to_hex(obj->sha1), name);
}
- while (objects) {
+ for (i = 0; i < objects.nr; i++) {
+ struct object_array_entry *p = objects.objects + i;
+
/* An object with name "foo\n0000000..." can be used to
* confuse downstream git-pack-objects very badly.
*/
- const char *ep = strchr(objects->name, '\n');
+ const char *ep = strchr(p->name, '\n');
if (ep) {
- printf("%s %.*s\n", sha1_to_hex(objects->item->sha1),
- (int) (ep - objects->name),
- objects->name);
+ printf("%s %.*s\n", sha1_to_hex(p->item->sha1),
+ (int) (ep - p->name),
+ p->name);
}
else
- printf("%s %s\n", sha1_to_hex(objects->item->sha1), objects->name);
- objects = objects->next;
+ printf("%s %s\n", sha1_to_hex(p->item->sha1), p->name);
}
}
@@ -348,7 +350,7 @@ int cmd_rev_list(int argc, const char **argv, char **envp)
if ((!list &&
(!(revs.tag_objects||revs.tree_objects||revs.blob_objects) &&
- !revs.pending_objects)) ||
+ !revs.pending.nr)) ||
revs.diff)
usage(rev_list_usage);
diff --git a/config.c b/config.c
index 984c75f5dd..3e077d4c6c 100644
--- a/config.c
+++ b/config.c
@@ -317,7 +317,33 @@ int git_config_from_file(config_fn_t fn, const char *filename)
int git_config(config_fn_t fn)
{
- return git_config_from_file(fn, git_path("config"));
+ int ret = 0;
+ char *repo_config = NULL;
+ const char *home = NULL, *filename;
+
+ /* $GIT_CONFIG makes git read _only_ the given config file,
+ * $GIT_CONFIG_LOCAL will make it process it in addition to the
+ * global config file, the same way it would the per-repository
+ * config file otherwise. */
+ filename = getenv("GIT_CONFIG");
+ if (!filename) {
+ home = getenv("HOME");
+ filename = getenv("GIT_CONFIG_LOCAL");
+ if (!filename)
+ filename = repo_config = strdup(git_path("config"));
+ }
+
+ if (home) {
+ char *user_config = strdup(mkpath("%s/.gitconfig", home));
+ if (!access(user_config, R_OK))
+ ret = git_config_from_file(fn, user_config);
+ free(user_config);
+ }
+
+ ret += git_config_from_file(fn, filename);
+ if (repo_config)
+ free(repo_config);
+ return ret;
}
/*
@@ -490,10 +516,19 @@ int git_config_set_multivar(const char* key, const char* value,
int i, dot;
int fd = -1, in_fd;
int ret;
- char* config_filename = strdup(git_path("config"));
- char* lock_file = strdup(git_path("config.lock"));
+ char* config_filename;
+ char* lock_file;
const char* last_dot = strrchr(key, '.');
+ config_filename = getenv("GIT_CONFIG");
+ if (!config_filename) {
+ config_filename = getenv("GIT_CONFIG_LOCAL");
+ if (!config_filename)
+ config_filename = git_path("config");
+ }
+ config_filename = strdup(config_filename);
+ lock_file = strdup(mkpath("%s.lock", config_filename));
+
/*
* Since "key" actually contains the section name and the real
* key name separated by a dot, we have to know where the dot is.
@@ -600,7 +635,7 @@ int git_config_set_multivar(const char* key, const char* value,
* As a side effect, we make sure to transform only a valid
* existing config file.
*/
- if (git_config(store_aux)) {
+ if (git_config_from_file(store_aux, config_filename)) {
fprintf(stderr, "invalid config file\n");
free(store.key);
if (store.value_regex != NULL) {
diff --git a/connect.c b/connect.c
index 52d709e58d..db7342e4d2 100644
--- a/connect.c
+++ b/connect.c
@@ -581,6 +581,11 @@ int git_connect(int fd[2], char *url, const char *prog)
enum protocol protocol = PROTO_LOCAL;
int free_path = 0;
+ /* Without this we cannot rely on waitpid() to tell
+ * what happened to our children.
+ */
+ signal(SIGCHLD, SIG_DFL);
+
host = strstr(url, "://");
if(host) {
*host = '\0';
diff --git a/contrib/git-svn/git-svn.perl b/contrib/git-svn/git-svn.perl
index 7e7f2f0cd9..08c30103f5 100755
--- a/contrib/git-svn/git-svn.perl
+++ b/contrib/git-svn/git-svn.perl
@@ -479,17 +479,18 @@ sub commit_lib {
my @lock = $SVN::Core::VERSION ge '1.2.0' ? (undef, 0) : ();
my $commit_msg = "$GIT_SVN_DIR/.svn-commit.tmp.$$";
+ if (defined $LC_ALL) {
+ $ENV{LC_ALL} = $LC_ALL;
+ } else {
+ delete $ENV{LC_ALL};
+ }
foreach my $c (@revs) {
+ my $log_msg = get_commit_message($c, $commit_msg);
+
# fork for each commit because there's a memory leak I
# can't track down... (it's probably in the SVN code)
defined(my $pid = open my $fh, '-|') or croak $!;
if (!$pid) {
- if (defined $LC_ALL) {
- $ENV{LC_ALL} = $LC_ALL;
- } else {
- delete $ENV{LC_ALL};
- }
- my $log_msg = get_commit_message($c, $commit_msg);
my $ed = SVN::Git::Editor->new(
{ r => $r_last,
ra => $SVN,
@@ -535,6 +536,7 @@ sub commit_lib {
($r_last, $cmt_last) = ($r_new, $cmt_new);
}
}
+ $ENV{LC_ALL} = 'C';
unlink $commit_msg;
}
diff --git a/convert-objects.c b/convert-objects.c
index a67d6b479e..0fabd8981c 100644
--- a/convert-objects.c
+++ b/convert-objects.c
@@ -103,12 +103,12 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base
if (!slash) {
newlen += sprintf(new + newlen, "%o %s", mode, path);
new[newlen++] = '\0';
- memcpy(new + newlen, buffer + len - 20, 20);
+ memcpy(new + newlen, (char *) buffer + len - 20, 20);
newlen += 20;
used += len;
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
continue;
}
@@ -121,7 +121,7 @@ static int write_subdirectory(void *buffer, unsigned long size, const char *base
used += len;
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
}
write_sha1_file(new, newlen, tree_type, result_sha1);
@@ -137,13 +137,13 @@ static void convert_tree(void *buffer, unsigned long size, unsigned char *result
while (size) {
int len = 1+strlen(buffer);
- convert_binary_sha1(buffer + len);
+ convert_binary_sha1((char *) buffer + len);
len += 20;
if (len > size)
die("corrupt tree object");
size -= len;
- buffer += len;
+ buffer = (char *) buffer + len;
}
write_subdirectory(orig_buffer, orig_size, "", 0, result_sha1);
@@ -244,14 +244,14 @@ static void convert_date(void *buffer, unsigned long size, unsigned char *result
// "tree <sha1>\n"
memcpy(new + newlen, buffer, 46);
newlen += 46;
- buffer += 46;
+ buffer = (char *) buffer + 46;
size -= 46;
// "parent <sha1>\n"
while (!memcmp(buffer, "parent ", 7)) {
memcpy(new + newlen, buffer, 48);
newlen += 48;
- buffer += 48;
+ buffer = (char *) buffer + 48;
size -= 48;
}
@@ -275,11 +275,11 @@ static void convert_commit(void *buffer, unsigned long size, unsigned char *resu
if (memcmp(buffer, "tree ", 5))
die("Bad commit '%s'", (char*) buffer);
- convert_ascii_sha1(buffer+5);
- buffer += 46; /* "tree " + "hex sha1" + "\n" */
+ convert_ascii_sha1((char *) buffer + 5);
+ buffer = (char *) buffer + 46; /* "tree " + "hex sha1" + "\n" */
while (!memcmp(buffer, "parent ", 7)) {
- convert_ascii_sha1(buffer+7);
- buffer += 48;
+ convert_ascii_sha1((char *) buffer + 7);
+ buffer = (char *) buffer + 48;
}
convert_date(orig_buffer, orig_size, result_sha1);
}
diff --git a/csum-file.c b/csum-file.c
index 5f9249aeed..ebaad0397f 100644
--- a/csum-file.c
+++ b/csum-file.c
@@ -17,7 +17,7 @@ static int sha1flush(struct sha1file *f, unsigned int count)
for (;;) {
int ret = xwrite(f->fd, buf, count);
if (ret > 0) {
- buf += ret;
+ buf = (char *) buf + ret;
count -= ret;
if (count)
continue;
@@ -57,7 +57,7 @@ int sha1write(struct sha1file *f, void *buf, unsigned int count)
memcpy(f->buffer + offset, buf, nr);
count -= nr;
offset += nr;
- buf += nr;
+ buf = (char *) buf + nr;
left -= nr;
if (!left) {
SHA1_Update(&f->ctx, f->buffer, offset);
diff --git a/daemon.c b/daemon.c
index 0747ce2a37..1ba4d669da 100644
--- a/daemon.c
+++ b/daemon.c
@@ -673,6 +673,11 @@ int main(int argc, char **argv)
int inetd_mode = 0;
int i;
+ /* Without this we cannot rely on waitpid() to tell
+ * what happened to our children.
+ */
+ signal(SIGCHLD, SIG_DFL);
+
for (i = 1; i < argc; i++) {
char *arg = argv[i];
diff --git a/diff-delta.c b/diff-delta.c
index 25a798d050..8b9172aa2e 100644
--- a/diff-delta.c
+++ b/diff-delta.c
@@ -22,6 +22,7 @@
#include <string.h>
#include "delta.h"
+#include "git-compat-util.h"
/* maximum hash entry list for the same hash bucket */
#define HASH_LIMIT 64
@@ -131,7 +132,7 @@ struct delta_index {
const void *src_buf;
unsigned long src_size;
unsigned int hash_mask;
- struct index_entry *hash[0];
+ struct index_entry *hash[FLEX_ARRAY];
};
struct delta_index * create_delta_index(const void *buf, unsigned long bufsize)
@@ -283,7 +284,7 @@ create_delta(const struct delta_index *index,
ref_data = index->src_buf;
ref_top = ref_data + index->src_size;
data = trg_buf;
- top = trg_buf + trg_size;
+ top = (const unsigned char *) trg_buf + trg_size;
outpos++;
val = 0;
diff --git a/diff-lib.c b/diff-lib.c
index 2183b41b03..116b5a9d68 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -34,21 +34,23 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
continue;
if (ce_stage(ce)) {
- struct {
- struct combine_diff_path p;
- struct combine_diff_parent filler[5];
- } combine;
+ struct combine_diff_path *dpath;
int num_compare_stages = 0;
+ size_t path_len;
- combine.p.next = NULL;
- combine.p.len = ce_namelen(ce);
- combine.p.path = xmalloc(combine.p.len + 1);
- memcpy(combine.p.path, ce->name, combine.p.len);
- combine.p.path[combine.p.len] = 0;
- combine.p.mode = 0;
- memset(combine.p.sha1, 0, 20);
- memset(&combine.p.parent[0], 0,
- sizeof(combine.filler));
+ path_len = ce_namelen(ce);
+
+ dpath = xmalloc (combine_diff_path_size (5, path_len));
+ dpath->path = (char *) &(dpath->parent[5]);
+
+ dpath->next = NULL;
+ dpath->len = path_len;
+ memcpy(dpath->path, ce->name, path_len);
+ dpath->path[path_len] = '\0';
+ dpath->mode = 0;
+ memset(dpath->sha1, 0, 20);
+ memset(&(dpath->parent[0]), 0,
+ sizeof(struct combine_diff_parent)*5);
while (i < entries) {
struct cache_entry *nce = active_cache[i];
@@ -64,11 +66,11 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
if (2 <= stage) {
int mode = ntohl(nce->ce_mode);
num_compare_stages++;
- memcpy(combine.p.parent[stage-2].sha1,
+ memcpy(dpath->parent[stage-2].sha1,
nce->sha1, 20);
- combine.p.parent[stage-2].mode =
+ dpath->parent[stage-2].mode =
canon_mode(mode);
- combine.p.parent[stage-2].status =
+ dpath->parent[stage-2].status =
DIFF_STATUS_MODIFIED;
}
@@ -83,13 +85,14 @@ int run_diff_files(struct rev_info *revs, int silent_on_removed)
i--;
if (revs->combine_merges && num_compare_stages == 2) {
- show_combined_diff(&combine.p, 2,
+ show_combined_diff(dpath, 2,
revs->dense_combined_merges,
revs);
- free(combine.p.path);
+ free(dpath);
continue;
}
- free(combine.p.path);
+ free(dpath);
+ dpath = NULL;
/*
* Show the diff for the 'ce' if we found the one
@@ -329,8 +332,8 @@ int run_diff_index(struct rev_info *revs, int cached)
}
mark_merge_entries();
- ent = revs->pending_objects->item;
- tree_name = revs->pending_objects->name;
+ ent = revs->pending.objects[0].item;
+ tree_name = revs->pending.objects[0].name;
tree = parse_tree_indirect(ent->sha1);
if (!tree)
return error("bad tree object %s", tree_name);
diff --git a/diff.c b/diff.c
index 9e9cfc8b75..fb1411c52d 100644
--- a/diff.c
+++ b/diff.c
@@ -515,7 +515,7 @@ static void emit_binary_diff(mmfile_t *one, mmfile_t *two)
else
line[0] = bytes - 26 + 'a' - 1;
encode_85(line + 1, cp, bytes);
- cp += bytes;
+ cp = (char *) cp + bytes;
puts(line);
}
printf("\n");
diff --git a/diffcore-order.c b/diffcore-order.c
index 0bc2b22f84..aef6da6044 100644
--- a/diffcore-order.c
+++ b/diffcore-order.c
@@ -30,7 +30,7 @@ static void prepare_order(const char *orderfile)
close(fd);
if (map == MAP_FAILED)
return;
- endp = map + st.st_size;
+ endp = (char *) map + st.st_size;
for (pass = 0; pass < 2; pass++) {
cnt = 0;
cp = map;
diff --git a/git-send-email.perl b/git-send-email.perl
index 7b1cca70ab..c5d9e73351 100755
--- a/git-send-email.perl
+++ b/git-send-email.perl
@@ -65,6 +65,20 @@ my $rc = GetOptions("from=s" => \$from,
"no-signed-off-cc|no-signed-off-by-cc" => \$no_signed_off_cc,
);
+# Verify the user input
+
+foreach my $entry (@to) {
+ die "Comma in --to entry: $entry'\n" unless $entry !~ m/,/;
+}
+
+foreach my $entry (@initial_cc) {
+ die "Comma in --cc entry: $entry'\n" unless $entry !~ m/,/;
+}
+
+foreach my $entry (@bcclist) {
+ die "Comma in --bcclist entry: $entry'\n" unless $entry !~ m/,/;
+}
+
# Now, let's fill any that aren't set in with defaults:
sub gitvar {
diff --git a/http-fetch.c b/http-fetch.c
index da1a7f5416..2b63d89501 100644
--- a/http-fetch.c
+++ b/http-fetch.c
@@ -123,7 +123,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
struct object_request *obj_req = (struct object_request *)data;
do {
ssize_t retval = write(obj_req->local,
- ptr + posn, size - posn);
+ (char *) ptr + posn, size - posn);
if (retval < 0)
return posn;
posn += retval;
@@ -1136,13 +1136,14 @@ int fetch(unsigned char *sha1)
static inline int needs_quote(int ch)
{
- switch (ch) {
- case '/': case '-': case '.':
- case 'A'...'Z': case 'a'...'z': case '0'...'9':
+ if (((ch >= 'A') && (ch <= 'Z'))
+ || ((ch >= 'a') && (ch <= 'z'))
+ || ((ch >= '0') && (ch <= '9'))
+ || (ch == '/')
+ || (ch == '-')
+ || (ch == '.'))
return 0;
- default:
- return 1;
- }
+ return 1;
}
static inline int hex(int v)
diff --git a/http-push.c b/http-push.c
index ba64f8fff5..8d472f0202 100644
--- a/http-push.c
+++ b/http-push.c
@@ -196,7 +196,7 @@ static size_t fwrite_sha1_file(void *ptr, size_t eltsize, size_t nmemb,
struct transfer_request *request = (struct transfer_request *)data;
do {
ssize_t retval = write(request->local_fileno,
- ptr + posn, size - posn);
+ (char *) ptr + posn, size - posn);
if (retval < 0)
return posn;
posn += retval;
@@ -1077,13 +1077,14 @@ static int fetch_indices(void)
static inline int needs_quote(int ch)
{
- switch (ch) {
- case '/': case '-': case '.':
- case 'A'...'Z': case 'a'...'z': case '0'...'9':
+ if (((ch >= 'A') && (ch <= 'Z'))
+ || ((ch >= 'a') && (ch <= 'z'))
+ || ((ch >= '0') && (ch <= '9'))
+ || (ch == '/')
+ || (ch == '-')
+ || (ch == '.'))
return 0;
- default:
- return 1;
- }
+ return 1;
}
static inline int hex(int v)
@@ -1171,7 +1172,7 @@ static void one_remote_object(const char *hex)
obj->flags |= REMOTE;
if (!object_list_contains(objects, obj))
- add_object(obj, &objects, NULL, "");
+ object_list_insert(obj, &objects);
}
static void handle_lockprop_ctx(struct xml_ctx *ctx, int tag_closed)
@@ -1699,6 +1700,15 @@ static int locking_available(void)
return lock_flags;
}
+struct object_list **add_one_object(struct object *obj, struct object_list **p)
+{
+ struct object_list *entry = xmalloc(sizeof(struct object_list));
+ entry->item = obj;
+ entry->next = *p;
+ *p = entry;
+ return &entry->next;
+}
+
static struct object_list **process_blob(struct blob *blob,
struct object_list **p,
struct name_path *path,
@@ -1712,8 +1722,7 @@ static struct object_list **process_blob(struct blob *blob,
return p;
obj->flags |= SEEN;
- name = strdup(name);
- return add_object(obj, p, path, name);
+ return add_one_object(obj, p);
}
static struct object_list **process_tree(struct tree *tree,
@@ -1735,7 +1744,7 @@ static struct object_list **process_tree(struct tree *tree,
obj->flags |= SEEN;
name = strdup(name);
- p = add_object(obj, p, NULL, name);
+ p = add_one_object(obj, p);
me.up = path;
me.elem = name;
me.elem_len = strlen(name);
@@ -1756,8 +1765,9 @@ static struct object_list **process_tree(struct tree *tree,
static int get_delta(struct rev_info *revs, struct remote_lock *lock)
{
+ int i;
struct commit *commit;
- struct object_list **p = &objects, *pending;
+ struct object_list **p = &objects;
int count = 0;
while ((commit = get_revision(revs)) != NULL) {
@@ -1767,15 +1777,16 @@ static int get_delta(struct rev_info *revs, struct remote_lock *lock)
count += add_send_request(&commit->object, lock);
}
- for (pending = revs->pending_objects; pending; pending = pending->next) {
- struct object *obj = pending->item;
- const char *name = pending->name;
+ for (i = 0; i < revs->pending.nr; i++) {
+ struct object_array_entry *entry = revs->pending.objects + i;
+ struct object *obj = entry->item;
+ const char *name = entry->name;
if (obj->flags & (UNINTERESTING | SEEN))
continue;
if (obj->type == TYPE_TAG) {
obj->flags |= SEEN;
- p = add_object(obj, p, NULL, name);
+ p = add_one_object(obj, p);
continue;
}
if (obj->type == TYPE_TREE) {
diff --git a/http.c b/http.c
index 08769cc7cd..6c1937b676 100644
--- a/http.c
+++ b/http.c
@@ -34,7 +34,7 @@ size_t fread_buffer(void *ptr, size_t eltsize, size_t nmemb,
size_t size = eltsize * nmemb;
if (size > buffer->size - buffer->posn)
size = buffer->size - buffer->posn;
- memcpy(ptr, buffer->buffer + buffer->posn, size);
+ memcpy(ptr, (char *) buffer->buffer + buffer->posn, size);
buffer->posn += size;
return size;
}
@@ -49,7 +49,7 @@ size_t fwrite_buffer(const void *ptr, size_t eltsize,
buffer->size = buffer->posn + size;
buffer->buffer = xrealloc(buffer->buffer, buffer->size);
}
- memcpy(buffer->buffer + buffer->posn, ptr, size);
+ memcpy((char *) buffer->buffer + buffer->posn, ptr, size);
buffer->posn += size;
data_received++;
return size;
diff --git a/imap-send.c b/imap-send.c
index 285ad29afb..94e39cd94c 100644
--- a/imap-send.c
+++ b/imap-send.c
@@ -93,7 +93,7 @@ typedef struct {
char *data;
int len;
unsigned char flags;
- unsigned char crlf:1;
+ unsigned int crlf:1;
} msg_data_t;
#define DRV_OK 0
diff --git a/merge-index.c b/merge-index.c
index 024196e7ac..190e12fb7c 100644
--- a/merge-index.c
+++ b/merge-index.c
@@ -99,6 +99,11 @@ int main(int argc, char **argv)
{
int i, force_file = 0;
+ /* Without this we cannot rely on waitpid() to tell
+ * what happened to our children.
+ */
+ signal(SIGCHLD, SIG_DFL);
+
if (argc < 3)
usage("git-merge-index [-o] [-q] <merge-program> (-a | <filename>*)");
diff --git a/name-rev.c b/name-rev.c
index c29b93ea71..3a5ac35d16 100644
--- a/name-rev.c
+++ b/name-rev.c
@@ -125,11 +125,10 @@ static const char* get_rev_name(struct object *o)
return buffer;
}
-
+
int main(int argc, char **argv)
{
- struct object_list *revs = NULL;
- struct object_list **walker = &revs;
+ struct object_array revs = { 0, 0, NULL };
int as_is = 0, all = 0, transform_stdin = 0;
setup_git_directory();
@@ -184,9 +183,7 @@ int main(int argc, char **argv)
if (cutoff > commit->date)
cutoff = commit->date;
- object_list_append((struct object *)commit, walker);
- (*walker)->name = *argv;
- walker = &((*walker)->next);
+ add_object_array((struct object *)commit, *argv, &revs);
}
for_each_ref(name_ref);
@@ -243,9 +240,13 @@ int main(int argc, char **argv)
if (objs[i])
printf("%s %s\n", sha1_to_hex(objs[i]->sha1),
get_rev_name(objs[i]));
- } else
- for ( ; revs; revs = revs->next)
- printf("%s %s\n", revs->name, get_rev_name(revs->item));
+ } else {
+ int i;
+ for (i = 0; i < revs.nr; i++)
+ printf("%s %s\n",
+ revs.objects[i].name,
+ get_rev_name(revs.objects[i].item));
+ }
return 0;
}
diff --git a/object-refs.c b/object-refs.c
index 8afa2276fb..b1b8065851 100644
--- a/object-refs.c
+++ b/object-refs.c
@@ -12,6 +12,18 @@ static unsigned int hash_obj(struct object *obj, unsigned int n)
return hash % n;
}
+static void insert_ref_hash(struct object_refs *ref, struct object_refs **hash, unsigned int size)
+{
+ int j = hash_obj(ref->base, size);
+
+ while (hash[j]) {
+ j++;
+ if (j >= size)
+ j = 0;
+ }
+ hash[j] = ref;
+}
+
static void grow_refs_hash(void)
{
int i;
@@ -20,30 +32,16 @@ static void grow_refs_hash(void)
new_hash = calloc(new_hash_size, sizeof(struct object_refs *));
for (i = 0; i < refs_hash_size; i++) {
- int j;
struct object_refs *ref = refs_hash[i];
if (!ref)
continue;
- j = hash_obj(ref->base, new_hash_size);
- new_hash[j] = ref;
+ insert_ref_hash(ref, new_hash, new_hash_size);
}
free(refs_hash);
refs_hash = new_hash;
refs_hash_size = new_hash_size;
}
-static void insert_ref_hash(struct object_refs *ref)
-{
- int j = hash_obj(ref->base, refs_hash_size);
-
- while (refs_hash[j]) {
- j++;
- if (j >= refs_hash_size)
- j = 0;
- }
- refs_hash[j] = ref;
-}
-
static void add_object_refs(struct object *obj, struct object_refs *ref)
{
int nr = nr_object_refs + 1;
@@ -51,7 +49,7 @@ static void add_object_refs(struct object *obj, struct object_refs *ref)
if (nr > refs_hash_size * 2 / 3)
grow_refs_hash();
ref->base = obj;
- insert_ref_hash(ref);
+ insert_ref_hash(ref, refs_hash, refs_hash_size);
nr_object_refs = nr;
}
@@ -127,6 +125,9 @@ void mark_reachable(struct object *obj, unsigned int mask)
if (!track_object_refs)
die("cannot do reachability with object refs turned off");
+ /* nothing to lookup */
+ if (!refs_hash_size)
+ return;
/* If we've been here already, don't bother */
if (obj->flags & mask)
return;
diff --git a/object.c b/object.c
index e26e319ccd..37784cee9a 100644
--- a/object.c
+++ b/object.c
@@ -200,3 +200,20 @@ int object_list_contains(struct object_list *list, struct object *obj)
}
return 0;
}
+
+void add_object_array(struct object *obj, const char *name, struct object_array *array)
+{
+ unsigned nr = array->nr;
+ unsigned alloc = array->alloc;
+ struct object_array_entry *objects = array->objects;
+
+ if (nr >= alloc) {
+ alloc = (alloc + 32) * 2;
+ objects = xrealloc(objects, alloc * sizeof(*objects));
+ array->alloc = alloc;
+ array->objects = objects;
+ }
+ objects[nr].item = obj;
+ objects[nr].name = name;
+ array->nr = ++nr;
+}
diff --git a/object.h b/object.h
index c537b4b72a..6f23a9a180 100644
--- a/object.h
+++ b/object.h
@@ -4,7 +4,6 @@
struct object_list {
struct object *item;
struct object_list *next;
- const char *name;
};
struct object_refs {
@@ -13,6 +12,15 @@ struct object_refs {
struct object *ref[FLEX_ARRAY]; /* more */
};
+struct object_array {
+ unsigned int nr;
+ unsigned int alloc;
+ struct object_array_entry {
+ struct object *item;
+ const char *name;
+ } *objects;
+};
+
#define TYPE_BITS 3
#define FLAG_BITS 27
@@ -72,4 +80,7 @@ unsigned object_list_length(struct object_list *list);
int object_list_contains(struct object_list *list, struct object *obj);
+/* Object array handling .. */
+void add_object_array(struct object *obj, const char *name, struct object_array *array);
+
#endif /* OBJECT_H */
diff --git a/pack-check.c b/pack-check.c
index e57587909e..3a62e1b7e4 100644
--- a/pack-check.c
+++ b/pack-check.c
@@ -29,10 +29,10 @@ static int verify_packfile(struct packed_git *p)
pack_base = p->pack_base;
SHA1_Update(&ctx, pack_base, pack_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, pack_base + pack_size - 20, 20))
+ if (memcmp(sha1, (char *) pack_base + pack_size - 20, 20))
return error("Packfile %s SHA1 mismatch with itself",
p->pack_name);
- if (memcmp(sha1, index_base + index_size - 40, 20))
+ if (memcmp(sha1, (char *) index_base + index_size - 40, 20))
return error("Packfile %s SHA1 mismatch with idx",
p->pack_name);
@@ -135,7 +135,7 @@ int verify_pack(struct packed_git *p, int verbose)
SHA1_Init(&ctx);
SHA1_Update(&ctx, index_base, index_size - 20);
SHA1_Final(sha1, &ctx);
- if (memcmp(sha1, index_base + index_size - 20, 20))
+ if (memcmp(sha1, (char *) index_base + index_size - 20, 20))
ret = error("Packfile index for %s SHA1 mismatch",
p->pack_name);
diff --git a/pack-objects.c b/pack-objects.c
index 7a8c16c317..bed2497b79 100644
--- a/pack-objects.c
+++ b/pack-objects.c
@@ -156,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++) {
- unsigned int hl = *((unsigned int *)(index + 24 * i));
+ unsigned int hl = *((unsigned int *)((char *) index + 24*i));
rix->revindex[i] = ntohl(hl);
}
/* This knows the pack format -- the 20-byte trailer
@@ -300,7 +300,7 @@ static unsigned long write_object(struct sha1file *f,
use_packed_git(p);
datalen = find_packed_object_size(p, entry->in_pack_offset);
- buf = p->pack_base + entry->in_pack_offset;
+ buf = (char *) p->pack_base + entry->in_pack_offset;
sha1write(f, buf, datalen);
unuse_packed_git(p);
hdrlen = 0; /* not really */
diff --git a/pack-redundant.c b/pack-redundant.c
index cd81f5a66e..41fb960569 100644
--- a/pack-redundant.c
+++ b/pack-redundant.c
@@ -246,12 +246,12 @@ static struct pack_list * pack_list_difference(const struct pack_list *A,
static void cmp_two_packs(struct pack_list *p1, struct pack_list *p2)
{
int p1_off, p2_off;
- void *p1_base, *p2_base;
+ unsigned char *p1_base, *p2_base;
struct llist_item *p1_hint = NULL, *p2_hint = NULL;
-
+
p1_off = p2_off = 256 * 4 + 4;
- p1_base = (void *)p1->pack->index_base;
- p2_base = (void *)p2->pack->index_base;
+ p1_base = (unsigned char *) p1->pack->index_base;
+ p2_base = (unsigned char *) p2->pack->index_base;
while (p1_off <= p1->pack->index_size - 3 * 20 &&
p2_off <= p2->pack->index_size - 3 * 20)
@@ -351,11 +351,11 @@ static size_t sizeof_union(struct packed_git *p1, struct packed_git *p2)
{
size_t ret = 0;
int p1_off, p2_off;
- void *p1_base, *p2_base;
+ char *p1_base, *p2_base;
p1_off = p2_off = 256 * 4 + 4;
- p1_base = (void *)p1->index_base;
- p2_base = (void *)p2->index_base;
+ p1_base = (char *)p1->index_base;
+ p2_base = (char *)p2->index_base;
while (p1_off <= p1->index_size - 3 * 20 &&
p2_off <= p2->index_size - 3 * 20)
@@ -534,7 +534,7 @@ static struct pack_list * add_pack(struct packed_git *p)
{
struct pack_list l;
size_t off;
- void *base;
+ unsigned char *base;
if (!p->pack_local && !(alt_odb || verbose))
return NULL;
@@ -543,7 +543,7 @@ static struct pack_list * add_pack(struct packed_git *p)
llist_init(&l.all_objects);
off = 256 * 4 + 4;
- base = (void *)p->index_base;
+ base = (unsigned char *)p->index_base;
while (off <= p->index_size - 3 * 20) {
llist_insert_back(l.all_objects, base + off);
off += 24;
diff --git a/patch-delta.c b/patch-delta.c
index 8f318ed8aa..e3a1d425ee 100644
--- a/patch-delta.c
+++ b/patch-delta.c
@@ -25,7 +25,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
return NULL;
data = delta_buf;
- top = delta_buf + delta_size;
+ top = (const unsigned char *) delta_buf + delta_size;
/* make sure the orig file size matches what we expect */
size = get_delta_hdr_size(&data, top);
@@ -56,7 +56,7 @@ void *patch_delta(const void *src_buf, unsigned long src_size,
cp_off + cp_size > src_size ||
cp_size > size)
goto bad;
- memcpy(out, src_buf + cp_off, cp_size);
+ memcpy(out, (char *) src_buf + cp_off, cp_size);
out += cp_size;
size -= cp_size;
} else if (cmd) {
diff --git a/pkt-line.c b/pkt-line.c
index 3d724acf23..c1e81f976f 100644
--- a/pkt-line.c
+++ b/pkt-line.c
@@ -22,7 +22,7 @@ ssize_t safe_write(int fd, const void *buf, ssize_t n)
while (n) {
int ret = xwrite(fd, buf, n);
if (ret > 0) {
- buf += ret;
+ buf = (char *) buf + ret;
n -= ret;
continue;
}
@@ -68,7 +68,7 @@ static void safe_read(int fd, void *buffer, unsigned size)
int n = 0;
while (n < size) {
- int ret = xread(fd, buffer + n, size - n);
+ int ret = xread(fd, (char *) buffer + n, size - n);
if (ret < 0)
die("read error (%s)", strerror(errno));
if (!ret)
diff --git a/quote.c b/quote.c
index 06792d47c3..dcc2326610 100644
--- a/quote.c
+++ b/quote.c
@@ -206,7 +206,14 @@ char *unquote_c_style(const char *quoted, const char **endp)
case '\\': case '"':
break; /* verbatim */
- case '0'...'7':
+ case '0':
+ case '1':
+ case '2':
+ case '3':
+ case '4':
+ case '5':
+ case '6':
+ case '7':
/* octal */
ac = ((ch - '0') << 6);
if ((ch = *sp++) < '0' || '7' < ch)
diff --git a/read-cache.c b/read-cache.c
index c499c51856..3c32aae7e8 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -706,7 +706,7 @@ static int verify_hdr(struct cache_header *hdr, unsigned long size)
SHA1_Init(&c);
SHA1_Update(&c, hdr, size - 20);
SHA1_Final(sha1, &c);
- if (memcmp(sha1, (void *)hdr + size - 20, 20))
+ if (memcmp(sha1, (char *) hdr + size - 20, 20))
return error("bad index file sha1 signature");
return 0;
}
@@ -770,7 +770,7 @@ int read_cache(void)
offset = sizeof(*hdr);
for (i = 0; i < active_nr; i++) {
- struct cache_entry *ce = map + offset;
+ struct cache_entry *ce = (struct cache_entry *) ((char *) map + offset);
offset = offset + ce_size(ce);
active_cache[i] = ce;
}
@@ -783,10 +783,11 @@ int read_cache(void)
* in 4-byte network byte order.
*/
unsigned long extsize;
- memcpy(&extsize, map + offset + 4, 4);
+ memcpy(&extsize, (char *) map + offset + 4, 4);
extsize = ntohl(extsize);
- if (read_index_extension(map + offset,
- map + offset + 8, extsize) < 0)
+ if (read_index_extension(((const char *) map) + offset,
+ (char *) map + offset + 8,
+ extsize) < 0)
goto unmap;
offset += 8;
offset += extsize;
@@ -820,7 +821,7 @@ static int ce_write(SHA_CTX *context, int fd, void *data, unsigned int len)
}
write_buffer_len = buffered;
len -= partial;
- data += partial;
+ data = (char *) data + partial;
}
return 0;
}
diff --git a/repo-config.c b/repo-config.c
index 08fc4cc57d..ab8f1afeea 100644
--- a/repo-config.c
+++ b/repo-config.c
@@ -64,7 +64,20 @@ static int show_config(const char* key_, const char* value_)
static int get_value(const char* key_, const char* regex_)
{
+ int ret = -1;
char *tl;
+ char *global = NULL, *repo_config = NULL;
+ const char *local;
+
+ local = getenv("GIT_CONFIG");
+ if (!local) {
+ const char *home = getenv("HOME");
+ local = getenv("GIT_CONFIG_LOCAL");
+ if (!local)
+ local = repo_config = strdup(git_path("config"));
+ if (home)
+ global = strdup(mkpath("%s/.gitconfig", home));
+ }
key = strdup(key_);
for (tl=key+strlen(key)-1; tl >= key && *tl != '.'; --tl)
@@ -76,7 +89,7 @@ static int get_value(const char* key_, const char* regex_)
key_regexp = (regex_t*)malloc(sizeof(regex_t));
if (regcomp(key_regexp, key, REG_EXTENDED)) {
fprintf(stderr, "Invalid key pattern: %s\n", key_);
- return -1;
+ goto free_strings;
}
}
@@ -89,11 +102,16 @@ static int get_value(const char* key_, const char* regex_)
regexp = (regex_t*)malloc(sizeof(regex_t));
if (regcomp(regexp, regex_, REG_EXTENDED)) {
fprintf(stderr, "Invalid pattern: %s\n", regex_);
- return -1;
+ goto free_strings;
}
}
- git_config(show_config);
+ if (do_all && global)
+ git_config_from_file(show_config, global);
+ git_config_from_file(show_config, local);
+ if (!do_all && !seen && global)
+ git_config_from_file(show_config, global);
+
free(key);
if (regexp) {
regfree(regexp);
@@ -101,9 +119,16 @@ static int get_value(const char* key_, const char* regex_)
}
if (do_all)
- return !seen;
-
- return (seen == 1) ? 0 : 1;
+ ret = !seen;
+ else
+ ret = (seen == 1) ? 0 : 1;
+
+free_strings:
+ if (repo_config)
+ free(repo_config);
+ if (global)
+ free(global);
+ return ret;
}
int main(int argc, const char **argv)
diff --git a/revision.c b/revision.c
index 7bff2a10b1..b963f2adfd 100644
--- a/revision.c
+++ b/revision.c
@@ -31,17 +31,12 @@ static char *path_name(struct name_path *path, const char *name)
return n;
}
-struct object_list **add_object(struct object *obj,
- struct object_list **p,
- struct name_path *path,
- const char *name)
+void add_object(struct object *obj,
+ struct object_array *p,
+ struct name_path *path,
+ const char *name)
{
- struct object_list *entry = xmalloc(sizeof(*entry));
- entry->item = obj;
- entry->next = *p;
- entry->name = path_name(path, name);
- *p = entry;
- return &entry->next;
+ add_object_array(obj, path_name(path, name), p);
}
static void mark_blob_uninteresting(struct blob *blob)
@@ -117,9 +112,9 @@ void mark_parents_uninteresting(struct commit *commit)
}
}
-static void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
+void add_pending_object(struct rev_info *revs, struct object *obj, const char *name)
{
- add_object(obj, &revs->pending_objects, NULL, name);
+ add_object_array(obj, name, &revs->pending);
}
static struct object *get_reference(struct rev_info *revs, const char *name, const unsigned char *sha1, unsigned int flags)
@@ -836,7 +831,7 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
object = get_reference(revs, arg, sha1, flags ^ local_flags);
add_pending_object(revs, object, arg);
}
- if (def && !revs->pending_objects) {
+ if (def && !revs->pending.nr) {
unsigned char sha1[20];
struct object *object;
if (get_sha1(def, sha1))
@@ -868,11 +863,13 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, const ch
void prepare_revision_walk(struct rev_info *revs)
{
- struct object_list *list;
+ int nr = revs->pending.nr;
+ struct object_array_entry *list = revs->pending.objects;
- list = revs->pending_objects;
- revs->pending_objects = NULL;
- while (list) {
+ revs->pending.nr = 0;
+ revs->pending.alloc = 0;
+ revs->pending.objects = NULL;
+ while (--nr >= 0) {
struct commit *commit = handle_commit(revs, list->item, list->name);
if (commit) {
if (!(commit->object.flags & SEEN)) {
@@ -880,7 +877,7 @@ void prepare_revision_walk(struct rev_info *revs)
insert_by_date(commit, &revs->commits);
}
}
- list = list->next;
+ list++;
}
if (revs->no_walk)
diff --git a/revision.h b/revision.h
index 4020e25c33..c010a08116 100644
--- a/revision.h
+++ b/revision.h
@@ -18,7 +18,7 @@ typedef void (prune_fn_t)(struct rev_info *revs, struct commit *commit);
struct rev_info {
/* Starting list */
struct commit_list *commits;
- struct object_list *pending_objects;
+ struct object_array pending;
/* Basic information */
const char *prefix;
@@ -99,9 +99,11 @@ struct name_path {
const char *elem;
};
-extern struct object_list **add_object(struct object *obj,
- struct object_list **p,
- struct name_path *path,
- const char *name);
+extern void add_object(struct object *obj,
+ struct object_array *p,
+ struct name_path *path,
+ const char *name);
+
+extern void add_pending_object(struct rev_info *revs, struct object *obj, const char *name);
#endif
diff --git a/sha1_file.c b/sha1_file.c
index b4ff233bad..c80528b506 100644
--- a/sha1_file.c
+++ b/sha1_file.c
@@ -486,8 +486,9 @@ int use_packed_git(struct packed_git *p)
* this is cheap.
*/
if (memcmp((char*)(p->index_base) + p->index_size - 40,
- p->pack_base + p->pack_size - 20, 20)) {
-
+ (char *) p->pack_base + p->pack_size - 20,
+ 20)) {
+
die("packfile %s does not match index.", p->pack_name);
}
}
@@ -701,7 +702,7 @@ static void *unpack_sha1_rest(z_stream *stream, void *buffer, unsigned long size
int bytes = strlen(buffer) + 1;
unsigned char *buf = xmalloc(1+size);
- memcpy(buf, buffer + bytes, stream->total_out - bytes);
+ memcpy(buf, (char *) buffer + bytes, stream->total_out - bytes);
bytes = stream->total_out - bytes;
if (bytes < size) {
stream->next_out = buf + bytes;
@@ -853,7 +854,7 @@ static unsigned long unpack_object_header(struct packed_git *p, unsigned long of
if (offset >= p->pack_size)
die("object offset outside of pack file");
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
c = *pack++;
offset++;
*type = (c >> 4) & 7;
@@ -883,7 +884,7 @@ int check_reuse_pack_delta(struct packed_git *p, unsigned long offset,
ptr = unpack_object_header(p, ptr, kindp, sizep);
if (*kindp != OBJ_DELTA)
goto done;
- memcpy(base, p->pack_base + ptr, 20);
+ memcpy(base, (char *) p->pack_base + ptr, 20);
status = 0;
done:
unuse_packed_git(p);
@@ -903,7 +904,7 @@ void packed_object_info_detail(struct pack_entry *e,
enum object_type kind;
offset = unpack_object_header(p, e->offset, &kind, size);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
if (kind != OBJ_DELTA)
*delta_chain_length = 0;
else {
@@ -919,7 +920,7 @@ void packed_object_info_detail(struct pack_entry *e,
find_pack_entry_one(pack, &base_ent, p);
offset = unpack_object_header(p, base_ent.offset,
&kind, &junk);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
chain_length++;
} while (kind == OBJ_DELTA);
*delta_chain_length = chain_length;
@@ -957,7 +958,7 @@ static int packed_object_info(struct pack_entry *entry,
die("cannot map packed file");
offset = unpack_object_header(p, entry->offset, &kind, &size);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
left = p->pack_size - offset;
switch (kind) {
@@ -1096,7 +1097,7 @@ void *unpack_entry_gently(struct pack_entry *entry,
void *retval;
offset = unpack_object_header(p, entry->offset, &kind, &size);
- pack = p->pack_base + offset;
+ pack = (unsigned char *) p->pack_base + offset;
left = p->pack_size - offset;
switch (kind) {
case OBJ_DELTA:
@@ -1134,7 +1135,7 @@ int nth_packed_object_sha1(const struct packed_git *p, int n,
void *index = p->index_base + 256;
if (n < 0 || num_packed_objects(p) <= n)
return -1;
- memcpy(sha1, (index + 24 * n + 4), 20);
+ memcpy(sha1, (char *) index + (24 * n) + 4, 20);
return 0;
}
@@ -1148,9 +1149,9 @@ int find_pack_entry_one(const unsigned char *sha1,
do {
int mi = (lo + hi) / 2;
- int cmp = memcmp(index + 24 * mi + 4, sha1, 20);
+ int cmp = memcmp((char *) index + (24 * mi) + 4, sha1, 20);
if (!cmp) {
- e->offset = ntohl(*((unsigned int *)(index + 24 * mi)));
+ e->offset = ntohl(*((unsigned int *) ((char *) index + (24 * mi))));
memcpy(e->sha1, sha1, 20);
e->p = p;
return 1;
@@ -1290,7 +1291,7 @@ void *read_object_with_reference(const unsigned char *sha1,
ref_length = strlen(ref_type);
if (memcmp(buffer, ref_type, ref_length) ||
- get_sha1_hex(buffer + ref_length, actual_sha1)) {
+ get_sha1_hex((char *) buffer + ref_length, actual_sha1)) {
free(buffer);
return NULL;
}
@@ -1408,7 +1409,7 @@ static int write_buffer(int fd, const void *buf, size_t len)
return error("file write error (%s)", strerror(errno));
}
len -= size;
- buf += size;
+ buf = (char *) buf + size;
}
return 0;
}
diff --git a/ssh-fetch.c b/ssh-fetch.c
index e3067b878e..1e59cd2008 100644
--- a/ssh-fetch.c
+++ b/ssh-fetch.c
@@ -24,7 +24,7 @@ static ssize_t force_write(int fd, void *buffer, size_t length)
{
ssize_t ret = 0;
while (ret < length) {
- ssize_t size = write(fd, buffer + ret, length - ret);
+ ssize_t size = write(fd, (char *) buffer + ret, length - ret);
if (size < 0) {
return size;
}
diff --git a/t/Makefile b/t/Makefile
index 549598575b..632c55f6d5 100644
--- a/t/Makefile
+++ b/t/Makefile
@@ -19,7 +19,7 @@ endif
all: $(T) clean
$(T):
- @echo "*** $@ ***"; '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
+ @echo "*** $@ ***"; GIT_CONFIG=.git/config '$(SHELL_PATH_SQ)' $@ $(GIT_TEST_OPTS)
clean:
rm -fr trash
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 8260d57b63..0de2497746 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -309,5 +309,29 @@ EOF
test_expect_success 'new variable inserts into proper section' 'cmp .git/config expect'
+cat > other-config << EOF
+[ein]
+ bahn = strasse
+EOF
+
+cat > expect << EOF
+ein.bahn=strasse
+EOF
+
+GIT_CONFIG=other-config git-repo-config -l > output
+
+test_expect_success 'alternative GIT_CONFIG' 'cmp output expect'
+
+GIT_CONFIG=other-config git-repo-config anwohner.park ausweis
+
+cat > expect << EOF
+[ein]
+ bahn = strasse
+[anwohner]
+ park = ausweis
+EOF
+
+test_expect_success '--set in alternative GIT_CONFIG' 'cmp other-config expect'
+
test_done
diff --git a/tag.c b/tag.c
index 5f70a5b810..74d0dabe5d 100644
--- a/tag.c
+++ b/tag.c
@@ -47,10 +47,10 @@ int parse_tag_buffer(struct tag *item, void *data, unsigned long size)
if (size < 64)
return -1;
- if (memcmp("object ", data, 7) || get_sha1_hex(data + 7, object))
+ if (memcmp("object ", data, 7) || get_sha1_hex((char *) data + 7, object))
return -1;
- type_line = data + 48;
+ type_line = (char *) data + 48;
if (memcmp("\ntype ", type_line-1, 6))
return -1;
diff --git a/tree-walk.c b/tree-walk.c
index 297c6972b9..3f83e98f3a 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -43,7 +43,7 @@ void update_tree_entry(struct tree_desc *desc)
if (size < len)
die("corrupt tree file");
- desc->buf = buf + len;
+ desc->buf = (char *) buf + len;
desc->size = size - len;
}
@@ -66,7 +66,7 @@ const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pat
const void *tree = desc->buf;
unsigned long size = desc->size;
int len = strlen(tree)+1;
- const unsigned char *sha1 = tree + len;
+ const unsigned char *sha1 = (unsigned char *) tree + len;
const char *path;
unsigned int mode;
@@ -80,7 +80,8 @@ const unsigned char *tree_entry_extract(struct tree_desc *desc, const char **pat
int tree_entry(struct tree_desc *desc, struct name_entry *entry)
{
- const void *tree = desc->buf, *path;
+ const void *tree = desc->buf;
+ const char *path;
unsigned long len, size = desc->size;
if (!size)
@@ -95,10 +96,10 @@ int tree_entry(struct tree_desc *desc, struct name_entry *entry)
entry->pathlen = len;
path += len + 1;
- entry->sha1 = path;
+ entry->sha1 = (const unsigned char *) path;
path += 20;
- len = path - tree;
+ len = path - (char *) tree;
if (len > size)
die("corrupt tree file");