* [RFC/WIP PATCH 3/3] submodule: simplify decision tree whether to or not to fetch
From: Heiko Voigt @ 2013-02-25 1:06 UTC (permalink / raw)
To: git; +Cc: Jens Lehmann
In-Reply-To: <cover.1361751905.git.hvoigt@hvoigt.net>
To make extending this logic later easier.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
submodule.c | 50 +++++++++++++++++++++++++++-----------------------
1 file changed, 27 insertions(+), 23 deletions(-)
diff --git a/submodule.c b/submodule.c
index b603000..a6fe16e 100644
--- a/submodule.c
+++ b/submodule.c
@@ -737,6 +737,23 @@ static void calculate_changed_submodule_paths(void)
submodule_config_cache_free(&submodule_config_cache);
}
+static int get_fetch_recurse_config(const char *name, int command_line_option)
+{
+ if (command_line_option != RECURSE_SUBMODULES_DEFAULT)
+ return command_line_option;
+
+ struct string_list_item *fetch_recurse_submodules_option;
+ fetch_recurse_submodules_option = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name);
+ if (fetch_recurse_submodules_option)
+ /* local config overrules everything except commandline */
+ return (intptr_t)fetch_recurse_submodules_option->util;
+
+ if (gitmodules_is_unmerged)
+ return RECURSE_SUBMODULES_OFF;
+
+ return config_fetch_recurse_submodules;
+}
+
int fetch_populated_submodules(const struct argv_array *options,
const char *prefix, int command_line_option,
int quiet)
@@ -781,32 +798,19 @@ int fetch_populated_submodules(const struct argv_array *options,
if (name_for_path)
name = name_for_path->util;
- default_argv = "yes";
- if (command_line_option == RECURSE_SUBMODULES_DEFAULT) {
- struct string_list_item *fetch_recurse_submodules_option;
- fetch_recurse_submodules_option = unsorted_string_list_lookup(&config_fetch_recurse_submodules_for_name, name);
- if (fetch_recurse_submodules_option) {
- if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_OFF)
- continue;
- if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_ON_DEMAND) {
- if (!unsorted_string_list_lookup(&changed_submodule_names, name))
- continue;
- default_argv = "on-demand";
- }
- } else {
- if ((config_fetch_recurse_submodules == RECURSE_SUBMODULES_OFF) ||
- gitmodules_is_unmerged)
- continue;
- if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) {
- if (!unsorted_string_list_lookup(&changed_submodule_names, name))
- continue;
- default_argv = "on-demand";
- }
- }
- } else if (command_line_option == RECURSE_SUBMODULES_ON_DEMAND) {
+ switch (get_fetch_recurse_config(name, command_line_option)) {
+ default:
+ case RECURSE_SUBMODULES_DEFAULT:
+ case RECURSE_SUBMODULES_ON_DEMAND:
if (!unsorted_string_list_lookup(&changed_submodule_names, name))
continue;
default_argv = "on-demand";
+ break;
+ case RECURSE_SUBMODULES_ON:
+ default_argv = "yes";
+ break;
+ case RECURSE_SUBMODULES_OFF:
+ continue;
}
strbuf_addf(&submodule_path, "%s/%s", work_tree, ce->name);
--
1.8.2.rc0.25.g5062c01
^ permalink raw reply related
* [RFC/WIP PATCH 2/3] implement fetching of moved submodules
From: Heiko Voigt @ 2013-02-25 1:05 UTC (permalink / raw)
To: git; +Cc: Jens Lehmann
In-Reply-To: <cover.1361751905.git.hvoigt@hvoigt.net>
Change calculation of changed submodule paths to read revisions config.
We now read the submodule name for every changed submodule path in a
commit. We then use the submodules names for fetching instead of the
submodule paths.
We lazily read all configurations of changed submodule path into a cache
which can then be used to lookup the configuration for a certain revision
and path or name.
It is expected that .gitmodules files do not change often between
commits. Thats why we lookup the .gitmodules sha1 and use a submodule
configuration cache to lazily lookup the parsed result for a submodule
stored by its name.
This cache could be reused for other purposes which need knowledge about
submodule configurations. For example automatic clone on fetch of a new
submodule if it is configured to be automatically initialized.
The submodule configuration in the current worktree can be stored using
the null sha1.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
Makefile | 1 +
submodule-config-cache.c | 96 ++++++++++++++++++++++
submodule-config-cache.h | 34 ++++++++
submodule.c | 196 ++++++++++++++++++++++++++++++++++++++------
t/t5526-fetch-submodules.sh | 31 +++++++
5 files changed, 335 insertions(+), 23 deletions(-)
create mode 100644 submodule-config-cache.c
create mode 100644 submodule-config-cache.h
diff --git a/Makefile b/Makefile
index 98da708..2e1d83b 100644
--- a/Makefile
+++ b/Makefile
@@ -858,6 +858,7 @@ LIB_OBJS += strbuf.o
LIB_OBJS += streaming.o
LIB_OBJS += string-list.o
LIB_OBJS += submodule.o
+LIB_OBJS += submodule-config-cache.o
LIB_OBJS += symlinks.o
LIB_OBJS += tag.o
LIB_OBJS += trace.o
diff --git a/submodule-config-cache.c b/submodule-config-cache.c
new file mode 100644
index 0000000..8ea5ac4
--- /dev/null
+++ b/submodule-config-cache.c
@@ -0,0 +1,96 @@
+#include "cache.h"
+#include "submodule-config-cache.h"
+#include "strbuf.h"
+#include "hash.h"
+
+void submodule_config_cache_init(struct submodule_config_cache *cache)
+{
+ init_hash(&cache->for_name);
+ init_hash(&cache->for_path);
+}
+
+static int free_one_submodule_config(void *ptr, void *data)
+{
+ struct submodule_config *entry = ptr;
+
+ strbuf_release(&entry->path);
+ strbuf_release(&entry->name);
+ free(entry);
+
+ return 0;
+}
+
+void submodule_config_cache_free(struct submodule_config_cache *cache)
+{
+ /* NOTE: its important to iterate over the name hash here
+ * since paths might have multiple entries */
+ for_each_hash(&cache->for_name, free_one_submodule_config, NULL);
+ free_hash(&cache->for_path);
+ free_hash(&cache->for_name);
+}
+
+static unsigned int hash_sha1_string(const unsigned char *sha1, const char *string)
+{
+ int c;
+ unsigned int hash, string_hash = 5381;
+ memcpy(&hash, sha1, sizeof(hash));
+
+ /* djb2 hash */
+ while ((c = *string++))
+ string_hash = ((string_hash << 5) + hash) + c; /* hash * 33 + c */
+
+ return hash + string_hash;
+}
+
+void submodule_config_cache_update_path(struct submodule_config_cache *cache,
+ struct submodule_config *config)
+{
+ void **pos;
+ int hash = hash_sha1_string(config->gitmodule_sha1, config->path.buf);
+ pos = insert_hash(hash, config, &cache->for_path);
+ if (pos) {
+ config->next = *pos;
+ *pos = config;
+ }
+}
+
+void submodule_config_cache_insert(struct submodule_config_cache *cache, struct submodule_config *config)
+{
+ unsigned int hash;
+ void **pos;
+
+ hash = hash_sha1_string(config->gitmodule_sha1, config->name.buf);
+ pos = insert_hash(hash, config, &cache->for_name);
+ if (pos) {
+ config->next = *pos;
+ *pos = config;
+ }
+}
+
+struct submodule_config *submodule_config_cache_lookup_path(struct submodule_config_cache *cache,
+ const unsigned char *gitmodule_sha1, const char *path)
+{
+ unsigned int hash = hash_sha1_string(gitmodule_sha1, path);
+ struct submodule_config *config = lookup_hash(hash, &cache->for_path);
+
+ while (config &&
+ hashcmp(config->gitmodule_sha1, gitmodule_sha1) &&
+ strcmp(path, config->path.buf))
+ config = config->next;
+
+ return config;
+}
+
+struct submodule_config *submodule_config_cache_lookup_name(struct submodule_config_cache *cache,
+ const unsigned char *gitmodule_sha1, const char *name)
+{
+ unsigned int hash = hash_sha1_string(gitmodule_sha1, name);
+ struct submodule_config *config = lookup_hash(hash, &cache->for_name);
+
+ while (config &&
+ hashcmp(config->gitmodule_sha1, gitmodule_sha1) &&
+ strcmp(name, config->name.buf))
+ config = config->next;
+
+ return config;
+}
diff --git a/submodule-config-cache.h b/submodule-config-cache.h
new file mode 100644
index 0000000..2b48c27
--- /dev/null
+++ b/submodule-config-cache.h
@@ -0,0 +1,34 @@
+#ifndef SUBMODULE_CONFIG_CACHE_H
+#define SUBMODULE_CONFIG_CACHE_H
+
+#include "hash.h"
+#include "strbuf.h"
+
+struct submodule_config_cache {
+ struct hash_table for_path;
+ struct hash_table for_name;
+};
+
+/* one submodule_config_cache entry */
+struct submodule_config {
+ struct strbuf path;
+ struct strbuf name;
+ unsigned char gitmodule_sha1[20];
+ int fetch_recurse_submodules;
+ struct submodule_config *next;
+};
+
+void submodule_config_cache_init(struct submodule_config_cache *cache);
+void submodule_config_cache_free(struct submodule_config_cache *cache);
+
+void submodule_config_cache_update_path(struct submodule_config_cache *cache,
+ struct submodule_config *config);
+void submodule_config_cache_insert(struct submodule_config_cache *cache,
+ struct submodule_config *config);
+
+struct submodule_config *submodule_config_cache_lookup_path(struct submodule_config_cache *cache,
+ const unsigned char *gitmodule_sha1, const char *path);
+struct submodule_config *submodule_config_cache_lookup_name(struct submodule_config_cache *cache,
+ const unsigned char *gitmodule_sha1, const char *name);
+
+#endif /* SUBMODULE_CONFIG_CACHE_H */
diff --git a/submodule.c b/submodule.c
index 9ba1496..b603000 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1,5 +1,6 @@
#include "cache.h"
#include "submodule.h"
+#include "submodule-config-cache.h"
#include "dir.h"
#include "diff.h"
#include "commit.h"
@@ -11,11 +12,12 @@
#include "sha1-array.h"
#include "argv-array.h"
+struct submodule_config_cache submodule_config_cache;
static struct string_list config_name_for_path;
static struct string_list config_fetch_recurse_submodules_for_name;
static struct string_list config_ignore_for_name;
static int config_fetch_recurse_submodules = RECURSE_SUBMODULES_ON_DEMAND;
-static struct string_list changed_submodule_paths;
+static struct string_list changed_submodule_names;
static int initialized_fetch_ref_tips;
static struct sha1_array ref_tips_before_fetch;
static struct sha1_array ref_tips_after_fetch;
@@ -487,34 +489,177 @@ static int is_submodule_commit_present(const char *path, unsigned char sha1[20])
return is_present;
}
+static int read_sha1_strbuf(struct strbuf *s, const unsigned char *sha1,
+ enum object_type *type)
+{
+ unsigned long size;
+ void *sha1_data;
+
+ sha1_data = read_sha1_file(sha1, type, &size);
+ if (!sha1_data)
+ return 0;
+
+ strbuf_attach(s, sha1_data, size, size);
+
+ return size;
+}
+
+struct parse_submodule_config_parameter {
+ unsigned char *gitmodule_sha1;
+ struct submodule_config_cache *cache;
+};
+
+static int name_and_item_from_var(const char *var, struct strbuf *name, struct strbuf *item)
+{
+ /* find the name and add it */
+ strbuf_addstr(name, var + strlen("submodule."));
+ char *end = strrchr(name->buf, '.');
+ if (!end) {
+ strbuf_release(name);
+ return 0;
+ }
+ *end = '\0';
+ if (((end + 1) - name->buf) < name->len)
+ strbuf_addstr(item, end + 1);
+
+ return 1;
+}
+
+static struct submodule_config *lookup_or_create_by_name(struct submodule_config_cache *cache,
+ unsigned char *gitmodule_sha1, const char *name)
+{
+ struct submodule_config *config;
+ config = submodule_config_cache_lookup_name(cache, gitmodule_sha1, name);
+ if (config)
+ return config;
+
+ config = xmalloc(sizeof(*config));
+
+ strbuf_init(&config->name, 1024);
+ strbuf_addstr(&config->name, name);
+
+ strbuf_init(&config->path, 1024);
+
+ hashcpy(config->gitmodule_sha1, gitmodule_sha1);
+ config->fetch_recurse_submodules = RECURSE_SUBMODULES_DEFAULT;
+ config->next = NULL;
+
+ submodule_config_cache_insert(cache, config);
+
+ return config;
+}
+
+static void warn_multiple_config(struct submodule_config *config, const char *option)
+{
+ warning("%s:.gitmodules, multiple configurations found for submodule.%s.%s. "
+ "Skipping second one!", sha1_to_hex(config->gitmodule_sha1),
+ option, config->name.buf);
+}
+
+static int parse_submodule_config_into_cache(const char *var, const char *value, void *data)
+{
+ struct parse_submodule_config_parameter *me = data;
+ struct submodule_config *submodule_config;
+
+ /* We only read submodule.<name> entries */
+ if (prefixcmp(var, "submodule."))
+ return 0;
+
+ struct strbuf name = STRBUF_INIT, item = STRBUF_INIT;
+ if (!name_and_item_from_var(var, &name, &item))
+ return 0;
+
+ submodule_config = lookup_or_create_by_name(me->cache, me->gitmodule_sha1, name.buf);
+
+ if (!suffixcmp(var, ".path")) {
+ if (*submodule_config->path.buf != '\0') {
+ warn_multiple_config(submodule_config, "path");
+ return 0;
+ }
+ strbuf_addstr(&submodule_config->path, value);
+ submodule_config_cache_update_path(me->cache, submodule_config);
+ }
+
+ if (!suffixcmp(var, ".fetchrecursesubmodules")) {
+ if (submodule_config->fetch_recurse_submodules != RECURSE_SUBMODULES_DEFAULT) {
+ warn_multiple_config(submodule_config, "fetchrecursesubmodules");
+ return 0;
+ }
+ submodule_config->fetch_recurse_submodules =
+ parse_fetch_recurse_submodules_arg(var, value);
+ }
+
+ strbuf_release(&name);
+ strbuf_release(&item);
+
+ return 0;
+}
+
+static struct submodule_config *get_submodule_config_for_commit_path(struct submodule_config_cache *cache,
+ const unsigned char *commit_sha1, const char *path)
+{
+ struct strbuf rev = STRBUF_INIT;
+ struct strbuf config = STRBUF_INIT;
+ unsigned char sha1[20];
+ enum object_type type;
+ struct submodule_config *submodule_config;
+ struct parse_submodule_config_parameter parameter;
+
+ strbuf_addf(&rev, "%s:.gitmodules", sha1_to_hex(commit_sha1));
+ if (get_sha1(rev.buf, sha1) < 0) {
+ strbuf_release(&rev);
+ return NULL;
+ }
+ strbuf_release(&rev);
+
+ submodule_config = submodule_config_cache_lookup_path(cache, sha1, path);
+ if (submodule_config)
+ return submodule_config;
+
+ if (!read_sha1_strbuf(&config, sha1, &type))
+ return NULL;
+
+ if (type != OBJ_BLOB) {
+ strbuf_release(&config);
+ return NULL;
+ }
+
+ /* fill the submodule config into the cache */
+ parameter.cache = cache;
+ parameter.gitmodule_sha1 = sha1;
+ git_config_from_strbuf(parse_submodule_config_into_cache, &config, ¶meter);
+ strbuf_release(&config);
+
+ return submodule_config_cache_lookup_path(cache, sha1, path);
+}
+
static void submodule_collect_changed_cb(struct diff_queue_struct *q,
struct diff_options *options,
void *data)
{
+ const unsigned char *commit_sha1 = data;
int i;
for (i = 0; i < q->nr; i++) {
struct diff_filepair *p = q->queue[i];
+ struct string_list_item *name_item;
+ struct submodule_config *submodule_config;
+
if (!S_ISGITLINK(p->two->mode))
continue;
- if (S_ISGITLINK(p->one->mode)) {
- /* NEEDSWORK: We should honor the name configured in
- * the .gitmodules file of the commit we are examining
- * here to be able to correctly follow submodules
- * being moved around. */
- struct string_list_item *path;
- path = unsorted_string_list_lookup(&changed_submodule_paths, p->two->path);
- if (!path && !is_submodule_commit_present(p->two->path, p->two->sha1))
- string_list_append(&changed_submodule_paths, xstrdup(p->two->path));
- } else {
- /* Submodule is new or was moved here */
- /* NEEDSWORK: When the .git directories of submodules
- * live inside the superprojects .git directory some
- * day we should fetch new submodules directly into
- * that location too when config or options request
- * that so they can be checked out from there. */
+ submodule_config = get_submodule_config_for_commit_path(&submodule_config_cache,
+ commit_sha1, p->two->path);
+ if (!submodule_config)
continue;
- }
+
+ name_item = unsorted_string_list_lookup(&changed_submodule_names, submodule_config->name.buf);
+ if (name_item)
+ continue;
+
+ if (is_submodule_commit_present(p->two->path, p->two->sha1))
+ continue;
+
+ string_list_append(&changed_submodule_names, xstrdup(submodule_config->name.buf));
}
}
@@ -550,6 +695,8 @@ static void calculate_changed_submodule_paths(void)
if (!config_name_for_path.nr)
return;
+ submodule_config_cache_init(&submodule_config_cache);
+
init_revisions(&rev, NULL);
argv_array_push(&argv, "--"); /* argv[0] program name */
sha1_array_for_each_unique(&ref_tips_after_fetch,
@@ -563,7 +710,7 @@ static void calculate_changed_submodule_paths(void)
/*
* Collect all submodules (whether checked out or not) for which new
- * commits have been recorded upstream in "changed_submodule_paths".
+ * commits have been recorded upstream in "changed_submodule_names".
*/
while ((commit = get_revision(&rev))) {
struct commit_list *parent = commit->parents;
@@ -573,6 +720,7 @@ static void calculate_changed_submodule_paths(void)
DIFF_OPT_SET(&diff_opts, RECURSIVE);
diff_opts.output_format |= DIFF_FORMAT_CALLBACK;
diff_opts.format_callback = submodule_collect_changed_cb;
+ diff_opts.format_callback_data = commit->object.sha1;
diff_setup_done(&diff_opts);
diff_tree_sha1(parent->item->object.sha1, commit->object.sha1, "", &diff_opts);
diffcore_std(&diff_opts);
@@ -585,6 +733,8 @@ static void calculate_changed_submodule_paths(void)
sha1_array_clear(&ref_tips_before_fetch);
sha1_array_clear(&ref_tips_after_fetch);
initialized_fetch_ref_tips = 0;
+
+ submodule_config_cache_free(&submodule_config_cache);
}
int fetch_populated_submodules(const struct argv_array *options,
@@ -639,7 +789,7 @@ int fetch_populated_submodules(const struct argv_array *options,
if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_OFF)
continue;
if ((intptr_t)fetch_recurse_submodules_option->util == RECURSE_SUBMODULES_ON_DEMAND) {
- if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
+ if (!unsorted_string_list_lookup(&changed_submodule_names, name))
continue;
default_argv = "on-demand";
}
@@ -648,13 +798,13 @@ int fetch_populated_submodules(const struct argv_array *options,
gitmodules_is_unmerged)
continue;
if (config_fetch_recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND) {
- if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
+ if (!unsorted_string_list_lookup(&changed_submodule_names, name))
continue;
default_argv = "on-demand";
}
}
} else if (command_line_option == RECURSE_SUBMODULES_ON_DEMAND) {
- if (!unsorted_string_list_lookup(&changed_submodule_paths, ce->name))
+ if (!unsorted_string_list_lookup(&changed_submodule_names, name))
continue;
default_argv = "on-demand";
}
@@ -685,7 +835,7 @@ int fetch_populated_submodules(const struct argv_array *options,
}
argv_array_clear(&argv);
out:
- string_list_clear(&changed_submodule_paths, 1);
+ string_list_clear(&changed_submodule_names, 1);
return result;
}
diff --git a/t/t5526-fetch-submodules.sh b/t/t5526-fetch-submodules.sh
index ca5b027..7ee4c2b 100755
--- a/t/t5526-fetch-submodules.sh
+++ b/t/t5526-fetch-submodules.sh
@@ -450,4 +450,35 @@ test_expect_success "don't fetch submodule when newly recorded commits are alrea
test_i18ncmp expect.err actual.err
'
+test_expect_success "fetch new commits when submodule got renamed" '
+ (
+ cd submodule &&
+ git checkout -b rename_sub &&
+ echo a >a &&
+ git add a &&
+ git commit -ma &&
+ git rev-parse HEAD >../expect
+ ) &&
+ git clone . downstream2 &&
+ (
+ cd downstream2 &&
+ git submodule update --init --recursive &&
+ git checkout -b rename &&
+ mv submodule submodule_renamed &&
+ git config -f .gitmodules submodule.submodule.path submodule_renamed &&
+ git add submodule_renamed .gitmodules &&
+ git commit -m "rename submodule -> submodule-renamed" &&
+ git push origin rename
+ ) &&
+ (
+ cd downstream &&
+ git fetch --recurse-submodules=on-demand &&
+ (
+ cd submodule &&
+ git rev-parse origin/rename_sub >../../actual
+ )
+ ) &&
+ test_cmp expect actual
+'
+
test_done
--
1.8.2.rc0.25.g5062c01
^ permalink raw reply related
* [RFC/WIP PATCH 1/3] teach config parsing to read from strbuf
From: Heiko Voigt @ 2013-02-25 1:04 UTC (permalink / raw)
To: git; +Cc: Jens Lehmann
In-Reply-To: <cover.1361751905.git.hvoigt@hvoigt.net>
This can be used to read configuration values directly from gits
database.
Signed-off-by: Heiko Voigt <hvoigt@hvoigt.net>
---
.gitignore | 1 +
Makefile | 1 +
cache.h | 1 +
config.c | 119 ++++++++++++++++++++++++++++++++++++++-----------
t/t1300-repo-config.sh | 4 ++
test-config.c | 41 +++++++++++++++++
6 files changed, 142 insertions(+), 25 deletions(-)
create mode 100644 test-config.c
diff --git a/.gitignore b/.gitignore
index 6669bf0..386b7f2 100644
--- a/.gitignore
+++ b/.gitignore
@@ -178,6 +178,7 @@
/gitweb/static/gitweb.min.*
/test-chmtime
/test-ctype
+/test-config
/test-date
/test-delta
/test-dump-cache-tree
diff --git a/Makefile b/Makefile
index ba8e243..98da708 100644
--- a/Makefile
+++ b/Makefile
@@ -543,6 +543,7 @@ PROGRAMS += $(patsubst %.o,git-%$X,$(PROGRAM_OBJS))
TEST_PROGRAMS_NEED_X += test-chmtime
TEST_PROGRAMS_NEED_X += test-ctype
+TEST_PROGRAMS_NEED_X += test-config
TEST_PROGRAMS_NEED_X += test-date
TEST_PROGRAMS_NEED_X += test-delta
TEST_PROGRAMS_NEED_X += test-dump-cache-tree
diff --git a/cache.h b/cache.h
index e493563..ada2362 100644
--- a/cache.h
+++ b/cache.h
@@ -1128,6 +1128,7 @@ extern int update_server_info(int);
typedef int (*config_fn_t)(const char *, const char *, void *);
extern int git_default_config(const char *, const char *, void *);
extern int git_config_from_file(config_fn_t fn, const char *, void *);
+extern int git_config_from_strbuf(config_fn_t fn, struct strbuf *strbuf, void *data);
extern void git_config_push_parameter(const char *text);
extern int git_config_from_parameters(config_fn_t fn, void *data);
extern int git_config(config_fn_t fn, void *);
diff --git a/config.c b/config.c
index aefd80b..f995e98 100644
--- a/config.c
+++ b/config.c
@@ -13,6 +13,9 @@
typedef struct config_file {
struct config_file *prev;
FILE *f;
+ int is_strbuf;
+ struct strbuf *strbuf_contents;
+ int strbuf_pos;
const char *name;
int linenr;
int eof;
@@ -24,6 +27,46 @@ static config_file *cf;
static int zlib_compression_seen;
+static int config_file_valid(struct config_file *file)
+{
+ if (file->f)
+ return 1;
+ if (file->is_strbuf)
+ return 1;
+
+ return 0;
+}
+
+static int config_fgetc(struct config_file *file)
+{
+ if (!file->is_strbuf)
+ return fgetc(file->f);
+
+ if (file->strbuf_pos < file->strbuf_contents->len)
+ return file->strbuf_contents->buf[file->strbuf_pos++];
+
+ return EOF;
+}
+
+static int config_ungetc(int c, struct config_file *file)
+{
+ if (!file->is_strbuf)
+ return ungetc(c, file->f);
+
+ if (file->strbuf_pos > 0)
+ return file->strbuf_contents->buf[--file->strbuf_pos];
+
+ return EOF;
+}
+
+static long config_ftell(struct config_file *file)
+{
+ if (!file->is_strbuf)
+ return ftell(file->f);
+
+ return file->strbuf_pos;
+}
+
#define MAX_INCLUDE_DEPTH 10
static const char include_depth_advice[] =
"exceeded maximum include depth (%d) while including\n"
@@ -169,16 +212,15 @@ int git_config_from_parameters(config_fn_t fn, void *data)
static int get_next_char(void)
{
int c;
- FILE *f;
c = '\n';
- if (cf && ((f = cf->f) != NULL)) {
- c = fgetc(f);
+ if (cf && config_file_valid(cf)) {
+ c = config_fgetc(cf);
if (c == '\r') {
/* DOS like systems */
- c = fgetc(f);
+ c = config_fgetc(cf);
if (c != '\n') {
- ungetc(c, f);
+ config_ungetc(c, cf);
c = '\r';
}
}
@@ -896,6 +938,38 @@ int git_default_config(const char *var, const char *value, void *dummy)
return 0;
}
+static int do_config_from(struct config_file *top, config_fn_t fn, void *data)
+{
+ int ret;
+
+ /* push config-file parsing state stack */
+ top->prev = cf;
+ top->linenr = 1;
+ top->eof = 0;
+ strbuf_init(&top->value, 1024);
+ strbuf_init(&top->var, 1024);
+ cf = top;
+
+ ret = git_parse_file(fn, data);
+
+ /* pop config-file parsing state stack */
+ strbuf_release(&top->value);
+ strbuf_release(&top->var);
+ cf = top->prev;
+
+ return ret;
+}
+
+static void config_file_init(struct config_file *top, const char *filename,
+ FILE *f, struct strbuf *string)
+{
+ top->f = f;
+ top->name = filename;
+ top->is_strbuf = f ? 0 : 1;
+ top->strbuf_contents = string;
+ top->strbuf_pos = 0;
+}
+
int git_config_from_file(config_fn_t fn, const char *filename, void *data)
{
int ret;
@@ -905,28 +979,24 @@ int git_config_from_file(config_fn_t fn, const char *filename, void *data)
if (f) {
config_file top;
- /* push config-file parsing state stack */
- top.prev = cf;
- top.f = f;
- top.name = filename;
- top.linenr = 1;
- top.eof = 0;
- strbuf_init(&top.value, 1024);
- strbuf_init(&top.var, 1024);
- cf = ⊤
-
- ret = git_parse_file(fn, data);
+ config_file_init(&top, filename, f, NULL);
- /* pop config-file parsing state stack */
- strbuf_release(&top.value);
- strbuf_release(&top.var);
- cf = top.prev;
+ ret = do_config_from(&top, fn, data);
fclose(f);
}
return ret;
}
+int git_config_from_strbuf(config_fn_t fn, struct strbuf *strbuf, void *data)
+{
+ config_file top;
+
+ config_file_init(&top, NULL, NULL, strbuf);
+
+ return do_config_from(&top, fn, data);
+}
+
const char *git_etc_gitconfig(void)
{
static const char *system_wide;
@@ -1053,7 +1123,6 @@ static int store_aux(const char *key, const char *value, void *cb)
{
const char *ep;
size_t section_len;
- FILE *f = cf->f;
switch (store.state) {
case KEY_SEEN:
@@ -1065,7 +1134,7 @@ static int store_aux(const char *key, const char *value, void *cb)
return 1;
}
- store.offset[store.seen] = ftell(f);
+ store.offset[store.seen] = config_ftell(cf);
store.seen++;
}
break;
@@ -1092,19 +1161,19 @@ static int store_aux(const char *key, const char *value, void *cb)
* Do not increment matches: this is no match, but we
* just made sure we are in the desired section.
*/
- store.offset[store.seen] = ftell(f);
+ store.offset[store.seen] = config_ftell(cf);
/* fallthru */
case SECTION_END_SEEN:
case START:
if (matches(key, value)) {
- store.offset[store.seen] = ftell(f);
+ store.offset[store.seen] = config_ftell(cf);
store.state = KEY_SEEN;
store.seen++;
} else {
if (strrchr(key, '.') - key == store.baselen &&
!strncmp(key, store.key, store.baselen)) {
store.state = SECTION_SEEN;
- store.offset[store.seen] = ftell(f);
+ store.offset[store.seen] = config_ftell(cf);
}
}
}
diff --git a/t/t1300-repo-config.sh b/t/t1300-repo-config.sh
index 3c96fda..3304bcd 100755
--- a/t/t1300-repo-config.sh
+++ b/t/t1300-repo-config.sh
@@ -1087,4 +1087,8 @@ test_expect_success 'barf on incomplete string' '
grep " line 3 " error
'
+test_expect_success 'reading config from strbuf' '
+ test-config strbuf
+'
+
test_done
diff --git a/test-config.c b/test-config.c
new file mode 100644
index 0000000..7a4103c
--- /dev/null
+++ b/test-config.c
@@ -0,0 +1,41 @@
+#include "cache.h"
+
+static const char *config_string = "[some]\n"
+ " value = content\n";
+
+static int config_strbuf(const char *var, const char *value, void *data)
+{
+ int *success = data;
+ if (!strcmp(var, "some.value") && !strcmp(value, "content"))
+ *success = 0;
+
+ printf("var: %s, value: %s\n", var, value);
+
+ return 1;
+}
+
+static void die_usage(int argc, char **argv)
+{
+ fprintf(stderr, "Usage: %s strbuf\n", argv[0]);
+ exit(1);
+}
+
+int main(int argc, char **argv)
+{
+ if (argc < 2)
+ die_usage(argc, argv);
+
+ if (!strcmp(argv[1], "strbuf")) {
+ int success = 1;
+ struct strbuf buf = STRBUF_INIT;
+
+ strbuf_addstr(&buf, config_string);
+ git_config_from_strbuf(config_strbuf, &buf, &success);
+
+ return success;
+ }
+
+ die_usage(argc, argv);
+
+ return 1;
+}
--
1.8.2.rc0.25.g5062c01
^ permalink raw reply related
* [RFC/WIP PATCH 0/3] fetch moved submodules on-demand
From: Heiko Voigt @ 2013-02-25 1:02 UTC (permalink / raw)
To: git; +Cc: Jens Lehmann
Hi,
this is a series I have been working on and off. My plan is that it
might be part of a slightly bigger series also implementing on-demand
clone of submodules into the .git/modules folder if a submodule is
configured like that.
This is needed as preparation for the final goal of automatic
checkout/deletion of submodules when they appear/disappear. My plan
is to introduce a new .gitmodules variable
submodule.<name>.init
to specify whether a submodule should be initialized (and thus cloned)
by default or not. If not configured it will default to off to stay
closed to the current behavior. If it proves useful we can maybe change
that default later to on.
That way we would get much closer to "clone/fetch and get everything you
need to work on a project".
I send this series mainly to inform people what I have been working and
to maybe get some early feedback about the approach. Let me know what
you think.
Cheers Heiko
Heiko Voigt (3):
teach config parsing to read from strbuf
implement fetching of moved submodules
submodule: simplify decision tree whether to or not to fetch
.gitignore | 1 +
Makefile | 2 +
cache.h | 1 +
config.c | 119 +++++++++++++++++-----
submodule-config-cache.c | 96 ++++++++++++++++++
submodule-config-cache.h | 34 +++++++
submodule.c | 242 ++++++++++++++++++++++++++++++++++++--------
t/t1300-repo-config.sh | 4 +
t/t5526-fetch-submodules.sh | 31 ++++++
test-config.c | 41 ++++++++
10 files changed, 502 insertions(+), 69 deletions(-)
create mode 100644 submodule-config-cache.c
create mode 100644 submodule-config-cache.h
create mode 100644 test-config.c
--
1.8.2.rc0.25.g5062c01
^ permalink raw reply
* [PATCH 4/4] contrib/mw-to-git/t/install-wiki.sh: use a lowercase "usage:" string
From: David Aguilar @ 2013-02-24 22:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <1361746121-56921-3-git-send-email-davvid@gmail.com>
Make the usage string consistent with Git.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
contrib/mw-to-git/t/install-wiki.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/contrib/mw-to-git/t/install-wiki.sh b/contrib/mw-to-git/t/install-wiki.sh
index c6d6fa3..70a53f6 100755
--- a/contrib/mw-to-git/t/install-wiki.sh
+++ b/contrib/mw-to-git/t/install-wiki.sh
@@ -15,7 +15,7 @@ fi
. "$WIKI_TEST_DIR"/test-gitmw-lib.sh
usage () {
- echo "Usage: "
+ echo "usage: "
echo " ./install-wiki.sh <install | delete | --help>"
echo " install | -i : Install a wiki on your computer."
echo " delete | -d : Delete the wiki and all its pages and "
--
1.7.12.4 (Apple Git-37)
^ permalink raw reply related
* [PATCH 3/4] contrib/examples/git-remote.perl: use a lowercase "usage:" string
From: David Aguilar @ 2013-02-24 22:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <1361746121-56921-2-git-send-email-davvid@gmail.com>
Make the usage string consistent with Git.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
contrib/examples/git-remote.perl | 8 ++++----
1 file changed, 4 insertions(+), 4 deletions(-)
diff --git a/contrib/examples/git-remote.perl b/contrib/examples/git-remote.perl
index b549a3c..d42df7b 100755
--- a/contrib/examples/git-remote.perl
+++ b/contrib/examples/git-remote.perl
@@ -380,7 +380,7 @@ elsif ($ARGV[0] eq 'show') {
}
}
if ($i >= @ARGV) {
- print STDERR "Usage: git remote show <remote>\n";
+ print STDERR "usage: git remote show <remote>\n";
exit(1);
}
my $status = 0;
@@ -410,7 +410,7 @@ elsif ($ARGV[0] eq 'prune') {
}
}
if ($i >= @ARGV) {
- print STDERR "Usage: git remote prune <remote>\n";
+ print STDERR "usage: git remote prune <remote>\n";
exit(1);
}
my $status = 0;
@@ -458,13 +458,13 @@ elsif ($ARGV[0] eq 'add') {
}
elsif ($ARGV[0] eq 'rm') {
if (@ARGV <= 1) {
- print STDERR "Usage: git remote rm <remote>\n";
+ print STDERR "usage: git remote rm <remote>\n";
exit(1);
}
exit(rm_remote($ARGV[1]));
}
else {
- print STDERR "Usage: git remote\n";
+ print STDERR "usage: git remote\n";
print STDERR " git remote add <name> <url>\n";
print STDERR " git remote rm <name>\n";
print STDERR " git remote show <name>\n";
--
1.7.12.4 (Apple Git-37)
^ permalink raw reply related
* [PATCH 2/4] tests: use a lowercase "usage:" string
From: David Aguilar @ 2013-02-24 22:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <1361746121-56921-1-git-send-email-davvid@gmail.com>
Adjust test commands and test suites so that their
usage strings are consistent with Git.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
t/lib-git-svn.sh | 2 +-
t/t1509/prepare-chroot.sh | 2 +-
test-chmtime.c | 2 +-
test-delta.c | 2 +-
test-genrandom.c | 2 +-
5 files changed, 5 insertions(+), 5 deletions(-)
diff --git a/t/lib-git-svn.sh b/t/lib-git-svn.sh
index 199f22c..c5e55b1 100644
--- a/t/lib-git-svn.sh
+++ b/t/lib-git-svn.sh
@@ -148,7 +148,7 @@ stop_httpd () {
convert_to_rev_db () {
"$PERL_PATH" -w -- - "$@" <<\EOF
use strict;
-@ARGV == 2 or die "Usage: convert_to_rev_db <input> <output>";
+@ARGV == 2 or die "usage: convert_to_rev_db <input> <output>";
open my $wr, '+>', $ARGV[1] or die "$!: couldn't open: $ARGV[1]";
open my $rd, '<', $ARGV[0] or die "$!: couldn't open: $ARGV[0]";
my $size = (stat($rd))[7];
diff --git a/t/t1509/prepare-chroot.sh b/t/t1509/prepare-chroot.sh
index c5334a8..6269117 100755
--- a/t/t1509/prepare-chroot.sh
+++ b/t/t1509/prepare-chroot.sh
@@ -14,7 +14,7 @@ xmkdir() {
R="$1"
-[ -n "$R" ] || die "Usage: prepare-chroot.sh <root>"
+[ -n "$R" ] || die "usage: prepare-chroot.sh <root>"
[ -x git ] || die "This script needs to be executed at git source code's top directory"
[ -x /bin/busybox ] || die "You need busybox"
diff --git a/test-chmtime.c b/test-chmtime.c
index 92713d1..02b42ba 100644
--- a/test-chmtime.c
+++ b/test-chmtime.c
@@ -114,6 +114,6 @@ int main(int argc, const char *argv[])
return 0;
usage:
- fprintf(stderr, "Usage: %s %s\n", argv[0], usage_str);
+ fprintf(stderr, "usage: %s %s\n", argv[0], usage_str);
return -1;
}
diff --git a/test-delta.c b/test-delta.c
index af40a3c..4595cd6 100644
--- a/test-delta.c
+++ b/test-delta.c
@@ -23,7 +23,7 @@ int main(int argc, char *argv[])
unsigned long from_size, data_size, out_size;
if (argc != 5 || (strcmp(argv[1], "-d") && strcmp(argv[1], "-p"))) {
- fprintf(stderr, "Usage: %s\n", usage_str);
+ fprintf(stderr, "usage: %s\n", usage_str);
return 1;
}
diff --git a/test-genrandom.c b/test-genrandom.c
index b3c28d9..54824d0 100644
--- a/test-genrandom.c
+++ b/test-genrandom.c
@@ -12,7 +12,7 @@ int main(int argc, char *argv[])
unsigned char *c;
if (argc < 2 || argc > 3) {
- fprintf(stderr, "Usage: %s <seed_string> [<size>]\n", argv[0]);
+ fprintf(stderr, "usage: %s <seed_string> [<size>]\n", argv[0]);
return 1;
}
--
1.7.12.4 (Apple Git-37)
^ permalink raw reply related
* [PATCH 1/4] git-svn: use a lowercase "usage:" string
From: David Aguilar @ 2013-02-24 22:48 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
Make the usage string consistent with Git.
Signed-off-by: David Aguilar <davvid@gmail.com>
---
I'm not sure why this wasn't caught in my first round.
It should probably be squashed into the 02/16 from v2.
git-svn.perl | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/git-svn.perl b/git-svn.perl
index a93166f..6c7bd95 100755
--- a/git-svn.perl
+++ b/git-svn.perl
@@ -534,7 +534,7 @@ sub cmd_fetch {
}
my ($remote) = @_;
if (@_ > 1) {
- die "Usage: $0 fetch [--all] [--parent] [svn-remote]\n";
+ die "usage: $0 fetch [--all] [--parent] [svn-remote]\n";
}
$Git::SVN::no_reuse_existing = undef;
if ($_fetch_parent) {
@@ -1404,7 +1404,7 @@ sub cmd_multi_fetch {
# this command is special because it requires no metadata
sub cmd_commit_diff {
my ($ta, $tb, $url) = @_;
- my $usage = "Usage: $0 commit-diff -r<revision> ".
+ my $usage = "usage: $0 commit-diff -r<revision> ".
"<tree-ish> <tree-ish> [<URL>]";
fatal($usage) if (!defined $ta || !defined $tb);
my $svn_path = '';
--
1.7.12.4 (Apple Git-37)
^ permalink raw reply related
* Re: [PATCH v2 00/16] use a lowercase "usage:" string
From: David Aguilar @ 2013-02-24 22:32 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Jonathan Nieder
In-Reply-To: <7vobf94c95.fsf@alter.siamese.dyndns.org>
On Sun, Feb 24, 2013 at 1:45 PM, Junio C Hamano <gitster@pobox.com> wrote:
> Thanks.
>
> After applying these patches, "git grep '^[^#]*Usage:'" still shows
> a handful more hits, such as contrib/examples/git-remote.perl that
> are touched by this series.
Thanks, I'll take a look at these.
I stayed away from tests and comments in the first round so that
we could catch the user-facing strings. That seems to have settled
in well so I can make another pass and catch these last remaining
stragglers.
--
David
^ permalink raw reply
* Re: [PATCH 13/13] Fixup! doc: giteveryday and user-manual man format
From: Philip Oakley @ 2013-02-24 22:32 UTC (permalink / raw)
To: W. Trevor King; +Cc: GitList
In-Reply-To: <20130224150140.GM1361@odin.tremily.us>
On 24/02/13 15:01, W. Trevor King wrote:
> On Sat, Feb 23, 2013 at 11:06:01PM +0000, Philip Oakley wrote:
>> diff --git a/Documentation/gituser-manual.txt b/Documentation/gituser-manual.txt
>> index a4778d7..e991b11 100644
>> --- a/Documentation/gituser-manual.txt
>> +++ b/Documentation/gituser-manual.txt
>> @@ -1,7 +1,12 @@
>> Git User's Manual (for version 1.5.3 or newer)
>> -______________________________________________
>> +==============================================
>
> I'd be happy dropping the parenthetical bit here. It's hard to
> imagine someone still running something earlier than 1.5.3. It's even
> harder to imagine them installing a modern user manual man page for
> their old Git version ;).
>
Sensible. Will do.
Philip
^ permalink raw reply
* Re: [PATCH 12/13] Documentation/Makefile: update git guide links
From: Philip Oakley @ 2013-02-24 22:31 UTC (permalink / raw)
To: W. Trevor King; +Cc: GitList
In-Reply-To: <20130224145831.GL1361@odin.tremily.us>
On 24/02/13 14:58, W. Trevor King wrote:
> On Sat, Feb 23, 2013 at 11:06:00PM +0000, Philip Oakley wrote:
>> OBSOLETE_HTML = git-remote-helpers.html
>> +OBSOLETE_HTML = everyday.html
>> +OBSOLETE_HTML = user-manual.html
>> DOC_HTML=$(MAN_HTML) $(OBSOLETE_HTML)
>
> Should be '+=' instead of '='.
>
Well spotted. That maybe part of why my make of the documentation failed.
Though the 'new' giteveryday gituser-manual don't build as man pages, so
I may simply leave them with their old make process - If I understand
correctly they are in the right place and just need the 'git' prefix.
However I'm biased by my Msysgit/G4W experience which always assumes
--web and fires up the HTML version so there may be issues with the
plain .txt version attempting to be displayed as a man page if it
doesn't follow the format. (my linux laptop was a repair of a 'scrapper')
Philip
^ permalink raw reply
* Re: [PATCH 09/13] Rename everyday to giteveryday
From: Philip Oakley @ 2013-02-24 22:16 UTC (permalink / raw)
To: W. Trevor King; +Cc: GitList
In-Reply-To: <20130224145526.GK1361@odin.tremily.us>
On 24/02/13 14:55, W. Trevor King wrote:
> On Sat, Feb 23, 2013 at 11:05:57PM +0000, Philip Oakley wrote:
>> diff --git a/Documentation/everyday.txt b/Documentation/everyday.txt
>> index e1fba85..3fc69f6 100644
>> --- a/Documentation/everyday.txt
>> +++ b/Documentation/everyday.txt
>> @@ -1,413 +1,25 @@
>> -Everyday Git With 20 Commands Or So
>> +Everyday GIT With 20 Commands Or So
>> ===================================
>
> This looks like it's opposing 48a8c26 (Documentation: avoid poor-man's
> small caps GIT, 2013-01-21). Another reason to use 'Git' over 'GIT'
> is to match the page we're redirecting to:
My mistake. When I was separating out the changes into separate patches
I incorrectly restored/copied an old version of the title.
Will correct.
>
>> new file mode 100644
>> index 0000000..e1fba85
>> --- /dev/null
>> +++ b/Documentation/giteveryday.txt
>> @@ -0,0 +1,413 @@
>> +Everyday Git With 20 Commands Or So
>> +===================================
>
> Trevor
>
Philip
^ permalink raw reply
* Re: [PATCH 06/13] Add guide-list.txt and extraction shell
From: Philip Oakley @ 2013-02-24 22:12 UTC (permalink / raw)
To: W. Trevor King; +Cc: GitList
In-Reply-To: <20130224145113.GJ1361@odin.tremily.us>
On 24/02/13 14:51, W. Trevor King wrote:
> On Sat, Feb 23, 2013 at 11:05:54PM +0000, Philip Oakley wrote:
>> +# Usage: ./generate-guidelist.sh >>common-guides.h
>
> Following David's recent series, it's probably better to use a
> lowercase 'usage' [1].
I prefer the Initial capital version to suggest the start of a sentence,
but I can go with either way.
> Also, I'd expect '>common-guides.h' would make
> more sense than appending with '>>'.
My mistake. Will correct.
>
>> +/* re-use struct cmdname_help in common-commands.h */
>> +
>> +static struct cmdname_help common_guides[] = {"
>
> This is probably just copied from generate-cmdlist.sh, but maybe it
> would be a good idea to #include "common-commands.h" here?
I was trying to avoid nested includes. Eventually, if the series is
accepted, I'd want to refactor the guide generation into the existing
command generation so that .h file would then disappear.
>
> Trevor
>
> [1]: http://article.gmane.org/gmane.comp.version-control.git/216961
>
Philip
^ permalink raw reply
* Building git with NO_PERL=1 will install git-submodule, which depends on perl
From: Tomas Carnecky @ 2013-02-24 22:12 UTC (permalink / raw)
To: git
Compare with git-instaweb which is replaced by as a small shell script which
informs the user that the functionality is not implemented.
I've only checked git-submodule, other commands may also have an undocumented
dependency on perl.
^ permalink raw reply
* Re: [PATCH 01/13] Use 'Git' in help messages
From: David Aguilar @ 2013-02-24 22:11 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Philip Oakley, GitList
In-Reply-To: <7vr4k65box.fsf@alter.siamese.dyndns.org>
On Sun, Feb 24, 2013 at 12:59 AM, Junio C Hamano <gitster@pobox.com> wrote:
> David Aguilar <davvid@gmail.com> writes:
>
>> This is referring to "git the command", not "git the system",
>> so it should not be changed according to the rule that was
>> applied when many "git" strings were changed to "Git".
>
> That sounds like a sensible objection.
>
>> There are scripts, etc. in the wild that parse this output.
>> which is another reason we would not want to change this.
>
> Are there? For what purpose?
>
> Especially when these are all _("l10n ready"), I find that somewhat
> unlikely.
A script might conditionally use new git behavior and parse the
output of "git version" to determine whether or not it can use it.
oh-my-zsh does this, for example [*].
Changing the git to Git is probably fine for some scripts that
do something interesting based on the git version since they
might be doing something simple like splitting the string on
whitespace and taking the last element as the version number.
These won't be broken by this change, but this approach is
already broken for a different reason. Apple's build of git
prints "git version 1.7.12.4 (Apple Git-37)" so they would
need to account for the last parens section optionally
being there. Changing "git" to "Git" only breaks anyone that
has assumed that they could get the version by doing
s/git version// on the string.
I think being able to find the version at runtime is something
that is typically used by packagers and folks that want to be
portable across git versions. For these, it would be helpful
to have a consistent and stable output that can be easily parsed.
By deciding to not mark these l10n ready and keeping the output
consistent we could help that use case.
[*] I'm not saying this is a good idea or something that scripts
should do, I'm just pointing out that it is done in practice,
so it is worth considering their use cases.
--
David
^ permalink raw reply
* Re: [PATCH 02/13] Show 'git help <guide>' usage, with examples
From: Philip Oakley @ 2013-02-24 22:05 UTC (permalink / raw)
To: W. Trevor King; +Cc: GitList
In-Reply-To: <20130224143902.GI1361@odin.tremily.us>
On 24/02/13 14:39, W. Trevor King wrote:
> On Sat, Feb 23, 2013 at 11:05:50PM +0000, Philip Oakley wrote:
>> + "Examples: 'git help git', 'git help branch', 'git help tutorial'..");
>
> This sentence should end in '.', not '..'.
>
> Cheers,
> Trevor
>
I should have used three as ellipsis ... to suggest 'more', which was my
intent, but ended up neither here, nor there.
Philip
^ permalink raw reply
* Re: [PATCH 05/13] Help.c: add list_common_guides_help() function
From: Philip Oakley @ 2013-02-24 21:51 UTC (permalink / raw)
To: Junio C Hamano; +Cc: GitList
In-Reply-To: <7vmwuu5bm1.fsf@alter.siamese.dyndns.org>
From: "Junio C Hamano" <gitster@pobox.com>
Sent: Sunday, February 24, 2013 9:01 AM
> Philip Oakley <philipoakley@iee.org> writes:
>
>> diff --git a/common-guides.h b/common-guides.h
>> new file mode 100644
>> index 0000000..a8ad8d1
>> --- /dev/null
>> +++ b/common-guides.h
>> @@ -0,0 +1,12 @@
>> +/* Automatically generated by ./generate-guidelist.sh */
>> +/* re-use struct cmdname_help in common-commands.h */
>
> Huh?
The first comment line fortells of patch 6 which can generate this .h
file.
The second comment line notes that I re-use cmdname_help, rather than
creating another struct with a similar name.
I should probably have noted these points in the commit message. (or
waited until patch 6 to add the comment).
Philip
^ permalink raw reply
* Re: [PATCH 01/13] Use 'Git' in help messages
From: Philip Oakley @ 2013-02-24 21:50 UTC (permalink / raw)
To: Junio C Hamano, David Aguilar; +Cc: GitList
In-Reply-To: <7vr4k65box.fsf@alter.siamese.dyndns.org>
From: "Junio C Hamano" <gitster@pobox.com>
Sent: Sunday, February 24, 2013 8:59 AM
> David Aguilar <davvid@gmail.com> writes:
>
>> This is referring to "git the command", not "git the system",
>> so it should not be changed according to the rule that was
>> applied when many "git" strings were changed to "Git".
>
> That sounds like a sensible objection.
>
I'd read the messages in the tone 'commands of the Git system', but I
can see that both views are equally plausible. Though the final _("git:
'%s' is not a Git command. See 'git --help'.") can't be referring to a
'git-<cmd>', obviously ;-)
>> There are scripts, etc. in the wild that parse this output.
>> which is another reason we would not want to change this.
>
> Are there? For what purpose?
>
> Especially when these are all _("l10n ready"), I find that somewhat
> unlikely.
>
> The bash completion (in contrib/) does read from the command list
> IIRC. I do not think it relies on the messages, though.
I was aware of that bash completion used 'git help -a' so I avoided
changing the response to that option. Initially I'd thought of making
'-a' provide both commands and guides but knew I'd need to ensure the
completion would still be sensible. I'd taken Juio's earlier advice to
keep '-a' unchanged and simply add the -g|--guides option as a
supplemental 'git help' response..
Philip
^ permalink raw reply
* Re: [PATCH v2 00/16] use a lowercase "usage:" string
From: Junio C Hamano @ 2013-02-24 21:45 UTC (permalink / raw)
To: David Aguilar; +Cc: git, Jonathan Nieder
In-Reply-To: <1361667024-49776-1-git-send-email-davvid@gmail.com>
Thanks.
After applying these patches, "git grep '^[^#]*Usage:'" still shows
a handful more hits, such as contrib/examples/git-remote.perl that
are touched by this series.
^ permalink raw reply
* Re: [PATCH] Improve QNX support in GIT
From: Junio C Hamano @ 2013-02-24 21:24 UTC (permalink / raw)
To: Mike Gorchak; +Cc: git
In-Reply-To: <CAHXAxrO_AeLoHw6TaVkDZsS=J6Ro+qEuMs4rbyCoFuHAGT+6vg@mail.gmail.com>
Mike Gorchak <mike.gorchak.qnx@gmail.com> writes:
> CFLAGS="-I/usr/qnxVVV/include" LDFLAGS="-I/usr/qnxVVV/lib" ./configure
> --prefix=/usr
Oh, I didn't notice that, but the definition of ALL_CFLAGS may be
what is wrong. It allows CFLAGS to come before BASIC_CFLAGS that
adds -Icompat/, which goes against the whole point of having
replacement headers in compat/ directory.
^ permalink raw reply
* Re: Load testing of git
From: Shawn Pearce @ 2013-02-24 20:31 UTC (permalink / raw)
To: thomas; +Cc: Yuri Mikhailov, git
In-Reply-To: <201302241758.18316.thomas@koch.ro>
On Sun, Feb 24, 2013 at 8:58 AM, Thomas Koch <thomas@koch.ro> wrote:
> Yuri Mikhailov:
>> Dear Git community,
>>
>> I am a Software Developer and I have been using git for a while.
>> Currently my company is looking for a version control system to use
>> and we find Git a good candidate for us. But what is important for us
>> to know is scalability of this VCS. Does anyone performed load testing
>> of Git? What is the practical maximum number of files and revisions
>> this system can handle?
>>
>> Best regards,
>> Iurii Mykhailov
>
> Have a look at the projects using Git[1]. There are for sure projects that
> exceeds the scalability you're thinking about. The linux Kernel might be the
> biggest project.
I highly doubt the Linux kernel is the biggest project.
IIRC WebKit has more objects, more files, etc. Its repository's
compressed form is >4G.
I know of at least some proprietary repositories with 96G in them. Not
much history, but a lot of binary blobs around 128M each doesn't
compress well. And bup wasn't used so we didn't get very good
compression over the files.
^ permalink raw reply
* [PATCH] Makefile: make mandir, htmldir and infodir absolute
From: John Keeping @ 2013-02-24 19:55 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Jonathan Nieder, git, Steffen Prohaska, Jakub Narebski
In-Reply-To: <7vehgldt8e.fsf_-_@alter.siamese.dyndns.org>
This matches the use of the variables with the same names in autotools,
reducing the potential for user surprise.
Using relative paths in these variables also causes issues if they are
exported from the Makefile, as discussed in commit c09d62f (Makefile: do
not export mandir/htmldir/infodir, 2013-02-12).
Suggested-by: Junio C Hamano <gitster@pobox.com>
Signed-off-by: John Keeping <john@keeping.me.uk>
---
On Tue, Feb 12, 2013 at 03:09:53PM -0800, Junio C Hamano wrote:
> A longer term fix is to introduce runtime_{man,html,info}dir variables
> to hold these funny values, and make {man,html,info}dir variables
> to have real paths whose default values begin with $(prefix), but
> as a first step, stop exporting them from the top-level Makefile.
Here's an attempt at doing that.
If this is sensible, should bindir_relative be calculated in the same
way?
Makefile | 36 +++++++++++++++++++++---------------
1 file changed, 21 insertions(+), 15 deletions(-)
diff --git a/Makefile b/Makefile
index 7c75e3b..087eec4 100644
--- a/Makefile
+++ b/Makefile
@@ -360,33 +360,39 @@ STRIP ?= strip
# Among the variables below, these:
# gitexecdir
# template_dir
-# mandir
-# infodir
-# htmldir
# sysconfdir
# can be specified as a relative path some/where/else;
# this is interpreted as relative to $(prefix) and "git" at
# runtime figures out where they are based on the path to the executable.
+# Additionally, the following will be treated as relative by "git" if they
+# begin with "$(prefix)/":
+# mandir
+# infodir
+# htmldir
# This can help installing the suite in a relocatable way.
prefix = $(HOME)
bindir_relative = bin
bindir = $(prefix)/$(bindir_relative)
-mandir = share/man
-infodir = share/info
+mandir = $(prefix)/share/man
+infodir = $(prefix)/share/info
gitexecdir = libexec/git-core
mergetoolsdir = $(gitexecdir)/mergetools
sharedir = $(prefix)/share
gitwebdir = $(sharedir)/gitweb
localedir = $(sharedir)/locale
template_dir = share/git-core/templates
-htmldir = share/doc/git-doc
+htmldir = $(prefix)/share/doc/git-doc
ETC_GITCONFIG = $(sysconfdir)/gitconfig
ETC_GITATTRIBUTES = $(sysconfdir)/gitattributes
lib = lib
# DESTDIR =
pathsep = :
+mandir_relative = $(patsubst $(prefix)/%,%,$(mandir))
+infodir_relative = $(patsubst $(prefix)/%,%,$(infodir))
+htmldir_relative = $(patsubst $(prefix)/%,%,$(htmldir))
+
export prefix bindir sharedir sysconfdir gitwebdir localedir
CC = cc
@@ -1548,12 +1554,12 @@ ETC_GITATTRIBUTES_SQ = $(subst ','\'',$(ETC_GITATTRIBUTES))
DESTDIR_SQ = $(subst ','\'',$(DESTDIR))
bindir_SQ = $(subst ','\'',$(bindir))
bindir_relative_SQ = $(subst ','\'',$(bindir_relative))
-mandir_SQ = $(subst ','\'',$(mandir))
-infodir_SQ = $(subst ','\'',$(infodir))
+mandir_relative_SQ = $(subst ','\'',$(mandir_relative))
+infodir_relative_SQ = $(subst ','\'',$(infodir_relative))
localedir_SQ = $(subst ','\'',$(localedir))
gitexecdir_SQ = $(subst ','\'',$(gitexecdir))
template_dir_SQ = $(subst ','\'',$(template_dir))
-htmldir_SQ = $(subst ','\'',$(htmldir))
+htmldir_relative_SQ = $(subst ','\'',$(htmldir_relative))
prefix_SQ = $(subst ','\'',$(prefix))
gitwebdir_SQ = $(subst ','\'',$(gitwebdir))
@@ -1685,9 +1691,9 @@ strip: $(PROGRAMS) git$X
git.sp git.s git.o: GIT-PREFIX
git.sp git.s git.o: EXTRA_CPPFLAGS = \
- '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
- '-DGIT_MAN_PATH="$(mandir_SQ)"' \
- '-DGIT_INFO_PATH="$(infodir_SQ)"'
+ '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
+ '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
+ '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ git.o \
@@ -1697,9 +1703,9 @@ help.sp help.s help.o: common-cmds.h
builtin/help.sp builtin/help.s builtin/help.o: common-cmds.h GIT-PREFIX
builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
- '-DGIT_HTML_PATH="$(htmldir_SQ)"' \
- '-DGIT_MAN_PATH="$(mandir_SQ)"' \
- '-DGIT_INFO_PATH="$(infodir_SQ)"'
+ '-DGIT_HTML_PATH="$(htmldir_relative_SQ)"' \
+ '-DGIT_MAN_PATH="$(mandir_relative_SQ)"' \
+ '-DGIT_INFO_PATH="$(infodir_relative_SQ)"'
version.sp version.s version.o: GIT-VERSION-FILE GIT-USER-AGENT
version.sp version.s version.o: EXTRA_CPPFLAGS = \
--
1.8.2.rc0.248.g2dab8ff
^ permalink raw reply related
* Re: Certificate validation vulnerability in Git
From: Andreas Ericsson @ 2013-02-24 18:46 UTC (permalink / raw)
To: Zubin Mithra; +Cc: git, Dhanesh K.
In-Reply-To: <CAA5xPpmmZuMK7q3-pTOx4L6DxFtyw5HWYdH7kHEsK=96KM5kAQ@mail.gmail.com>
On 02/24/2013 06:31 PM, Zubin Mithra wrote:
> Hello,
>
> There seems to be a security issue in the way git uses openssl for
> certificate validation. Similar occurrences have been found and
> documented in other open source projects, the research can be found at
> [1].
>
> -=========]
> - imap-send.c
>
> Line 307
>
> 307 ret = SSL_connect(sock->ssl);
> 308 if (ret <= 0) {
> 309 socket_perror("SSL_connect", sock, ret);
> 310 return -1;
> 311 }
> 312
>
> Certificate validation errors are signaled either through return
> values of SSL_connect or by setting internal flags. The internal flags
> need to be checked using the SSL_get_verify_result function. This is
> not performed.
>
> Kindly fix these issues, file a CVE and credit it to Dhanesh K. and
> Zubin Mithra. Thanks.
>
The lack of certificate authority verification presents no attack vector
for git imap-send. As such, it doesn't warrant a CVE. I'm sure you'll
be credited with a "reported-by" line in the commit message if someone
decides to fix it though. Personally, I'm not fussed.
> We are not subscribed to this list, so we'd appreciate it if you could
> CC us in the replies.
>
That's standard on this list. Please follow the same convention if/when
you reply. Thanks.
--
Andreas Ericsson andreas.ericsson@op5.se
OP5 AB www.op5.se
Tel: +46 8-230225 Fax: +46 8-230231
Considering the successes of the wars on alcohol, poverty, drugs and
terror, I think we should give some serious thought to declaring war
on peace.
^ permalink raw reply
* [PATCH 1/1] Fix git compilation without libiconv
From: Mike Gorchak @ 2013-02-24 18:04 UTC (permalink / raw)
To: git
Fix git compilation without available libiconv library.
From: Mike Gorchak <mike.gorchak.qnx@gmail.com>
Signed-off-by: Mike Gorchak <mike.gorchak.qnx@gmail.com>
---
configure.ac | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/configure.ac b/configure.ac
index 1991258..d0e82c1 100644
--- a/configure.ac
+++ b/configure.ac
@@ -566,7 +566,9 @@ for l in $lib_order; do
[AC_MSG_RESULT([yes])
NO_ICONV=
break],
- [AC_MSG_RESULT([no])])
+ [AC_MSG_RESULT([no])
+ NEEDS_LIBICONV=
+ ])
LIBS="$old_LIBS"
done
--
1.8.2-rc0
^ permalink raw reply related
* Re: Load testing of git
From: Jeff Epler @ 2013-02-24 17:54 UTC (permalink / raw)
To: Yuri Mikhailov; +Cc: git
In-Reply-To: <CAGjB8pR+uByiJJikBXbaxUZO4rDgyfvJ31agxaQuWrMwSS1N7Q@mail.gmail.com>
In 2012 there was a thread about git's performance on large
repositories. One archive of the discussion begins here:
http://mid.gmane.org/CB5074CF.3AD7A%25joshua.redstone%40fb.com
> The test repo has 4 million commits, linear history and about 1.3
> million files.
I'm not sure to what extent git performance may have changed since then,
e.g., by improving the index format.
Jeff
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox