* [PATCH 3/6] Test "git remote show" and "git remote prune"
From: Johannes Schindelin @ 2007-12-05 19:02 UTC (permalink / raw)
To: git, gitster
In-Reply-To: <Pine.LNX.4.64.0712051858270.27959@racer.site>
While at it, also fix a few instances where a cd was done outside of a
subshell.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
t/t5505-remote.sh | 34 ++++++++++++++++++++++++++++++++++
1 files changed, 34 insertions(+), 0 deletions(-)
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 636aec2..c7d7242 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -97,4 +97,38 @@ test_expect_success 'remove remote' '
)
'
+cat > test/expect << EOF
+* remote origin
+ URL: $(pwd)/one/.git
+ Remote branch(es) merged with 'git pull' while on branch master
+ master
+ New remote branches (next fetch will store in remotes/origin)
+ master
+ Tracked remote branches
+ side master
+EOF
+
+test_expect_success 'show' '
+ (cd test &&
+ git config --add remote.origin.fetch \
+ refs/heads/master:refs/heads/upstream &&
+ git fetch &&
+ git branch -d -r origin/master &&
+ (cd ../one &&
+ echo 1 > file &&
+ git commit -m update file) &&
+ git remote show origin > output &&
+ git diff expect output)
+'
+
+test_expect_success 'prune' '
+ (cd one &&
+ git branch -m side side2) &&
+ (cd test &&
+ git fetch origin &&
+ git remote prune origin &&
+ git rev-parse refs/remotes/origin/side2 &&
+ ! git rev-parse refs/remotes/origin/side)
+'
+
test_done
--
1.5.3.7.2157.g9598e
^ permalink raw reply related
* [PATCH 4/6] Make git-remote a builtin
From: Johannes Schindelin @ 2007-12-05 19:02 UTC (permalink / raw)
To: git, gitster
In-Reply-To: <Pine.LNX.4.64.0712051858270.27959@racer.site>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
Makefile | 3 +-
builtin-remote.c | 517 ++++++++++++++++++++
builtin.h | 1 +
.../examples/git-remote.perl | 0
git.c | 1 +
remote.c | 3 +-
remote.h | 1 +
t/t5505-remote.sh | 4 +-
8 files changed, 526 insertions(+), 4 deletions(-)
create mode 100644 builtin-remote.c
rename git-remote.perl => contrib/examples/git-remote.perl (100%)
diff --git a/Makefile b/Makefile
index 233bb5f..e840ca3 100644
--- a/Makefile
+++ b/Makefile
@@ -228,7 +228,7 @@ SCRIPT_SH = \
SCRIPT_PERL = \
git-add--interactive.perl \
git-archimport.perl git-cvsimport.perl git-relink.perl \
- git-cvsserver.perl git-remote.perl git-cvsexportcommit.perl \
+ git-cvsserver.perl git-cvsexportcommit.perl \
git-send-email.perl git-svn.perl
SCRIPTS = $(patsubst %.sh,%,$(SCRIPT_SH)) \
@@ -362,6 +362,7 @@ BUILTIN_OBJS = \
builtin-push.o \
builtin-read-tree.o \
builtin-reflog.o \
+ builtin-remote.o \
builtin-send-pack.o \
builtin-config.o \
builtin-rerere.o \
diff --git a/builtin-remote.c b/builtin-remote.c
new file mode 100644
index 0000000..41ac4a1
--- /dev/null
+++ b/builtin-remote.c
@@ -0,0 +1,517 @@
+#include "cache.h"
+#include "parse-options.h"
+#include "transport.h"
+#include "remote.h"
+#include "path-list.h"
+#include "strbuf.h"
+#include "run-command.h"
+#include "refs.h"
+
+static const char * const builtin_remote_usage[] = {
+ "git remote",
+ "git remote add <name> <url>",
+ "git remote rm <name>",
+ "git remote show <name>",
+ "git remote prune <name>",
+ "git remote update [group]",
+ NULL
+};
+
+static int verbose;
+
+static inline int postfixcmp(const char *string, const char *postfix)
+{
+ int len1 = strlen(string), len2 = strlen(postfix);
+ if (len1 < len2)
+ return 1;
+ return strcmp(string + len1 - len2, postfix);
+}
+
+static inline const char *skip_prefix(const char *name, const char *prefix)
+{
+ return !name ? "" :
+ prefixcmp(name, prefix) ? name : name + strlen(prefix);
+}
+
+static int opt_parse_track(const struct option *opt, const char *arg, int not)
+{
+ struct path_list *list = opt->value;
+ if (not)
+ path_list_clear(list, 0);
+ else
+ path_list_append(arg, list);
+ return 0;
+}
+
+static int fetch_remote(const char *name)
+{
+ const char *argv[] = { "fetch", name, NULL };
+ if (run_command_v_opt(argv, RUN_GIT_CMD))
+ return error ("Could not fetch %s", name);
+ return 0;
+}
+
+static int add(int argc, const char **argv)
+{
+ int fetch = 0, mirror = 0;
+ struct path_list track = { NULL, 0, 0 };
+ const char *master = NULL;
+ struct remote *remote;
+ struct strbuf buf, buf2;
+ const char *name, *url;
+ int i;
+
+ struct option options[] = {
+ OPT_GROUP("add specific options"),
+ OPT_BOOLEAN('f', "fetch", &fetch, "fetch the remote branches"),
+ OPT_CALLBACK('t', "track", &track, "branch",
+ "branch(es) to track", opt_parse_track),
+ OPT_STRING('m', "master", &master, "branch", "master branch"),
+ OPT_BOOLEAN(0, "mirror", &mirror, "no separate remotes"),
+ OPT_END()
+ };
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
+
+ if (argc < 2)
+ usage_with_options(builtin_remote_usage, options);
+
+ name = argv[0];
+ url = argv[1];
+
+ remote = remote_get(name);
+ if (remote && (remote->url_nr > 1 || strcmp(name, remote->url[0]) ||
+ remote->fetch_refspec_nr))
+ die ("remote %s already exists.", name);
+
+ strbuf_init(&buf, 0);
+ strbuf_init(&buf2, 0);
+
+ strbuf_addf(&buf, "remote.%s.url", name);
+ if (git_config_set(buf.buf, url))
+ return 1;
+
+ if (track.nr == 0)
+ path_list_append("*", &track);
+ for (i = 0; i < track.nr; i++) {
+ struct path_list_item *item = track.items + i;
+
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "remote.%s.fetch", name);
+
+ strbuf_reset(&buf2);
+ if (mirror)
+ strbuf_addf(&buf2, "refs/%s:refs/%s",
+ item->path, item->path);
+ else
+ strbuf_addf(&buf2, "refs/heads/%s:refs/remotes/%s/%s",
+ item->path, name, item->path);
+ if (git_config_set_multivar(buf.buf, buf2.buf, "^$", 0))
+ return 1;
+ }
+
+ if (fetch && fetch_remote(name))
+ return 1;
+
+ if (master) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "refs/remotes/%s/HEAD", name);
+
+ strbuf_reset(&buf2);
+ strbuf_addf(&buf2, "refs/remotes/%s/%s", name, master);
+
+ if (create_symref(buf.buf, buf2.buf, "remote add"))
+ return error ("Could not setup master '%s'", master);
+ }
+
+ strbuf_release(&buf);
+ strbuf_release(&buf2);
+ path_list_clear(&track, 0);
+
+ return 0;
+}
+
+struct branch_info {
+ char *remote;
+ struct path_list merge;
+};
+
+static struct path_list branch_list;
+
+static int config_read_branches(const char *key, const char *value)
+{
+ if (!prefixcmp(key, "branch.")) {
+ char *name;
+ struct path_list_item *item;
+ struct branch_info *info;
+ enum { REMOTE, MERGE } type;
+
+ key += 7;
+ if (!postfixcmp(key, ".remote")) {
+ name = xstrndup(key, strlen(key) - 7);
+ type = REMOTE;
+ } else if (!postfixcmp(key, ".merge")) {
+ name = xstrndup(key, strlen(key) - 6);
+ type = MERGE;
+ } else
+ return 0;
+
+ item = path_list_insert(name, &branch_list);
+
+ if (!item->util)
+ item->util = xcalloc(sizeof(struct branch_info), 1);
+ info = item->util;
+ if (type == REMOTE) {
+ if (info->remote)
+ warning ("more than one branch.%s", key);
+ info->remote = xstrdup(value);
+ } else {
+ char *space = strchr(value, ' ');
+ value = skip_prefix(value, "refs/heads/");
+ while (space) {
+ char *merge;
+ merge = xstrndup(value, space - value);
+ path_list_append(merge, &info->merge);
+ value = skip_prefix(space + 1, "refs/heads/");
+ space = strchr(value, ' ');
+ }
+ path_list_append(xstrdup(value), &info->merge);
+ }
+ }
+ return 0;
+}
+
+static void read_branches()
+{
+ if (branch_list.nr)
+ return;
+ git_config(config_read_branches);
+ sort_path_list(&branch_list);
+}
+
+struct ref_states {
+ struct remote *remote;
+ struct strbuf remote_prefix;
+ struct path_list new, stale, tracked;
+};
+
+static int handle_one_branch(const char *refname,
+ const unsigned char *sha1, int flags, void *cb_data)
+{
+ struct ref_states *states = cb_data;
+ struct refspec refspec;
+
+ memset(&refspec, 0, sizeof(refspec));
+ refspec.dst = (char *)refname;
+ if (!remote_find_tracking(states->remote, &refspec)) {
+ struct path_list_item *item;
+ const char *name = skip_prefix(refspec.src, "refs/heads/");
+ if (unsorted_path_list_has_path(&states->tracked, name) ||
+ unsorted_path_list_has_path(&states->new,
+ name))
+ return 0;
+ item = path_list_append(name, &states->stale);
+ item->util = xstrdup(refname);
+ }
+ return 0;
+}
+
+static int get_ref_states(const struct ref *ref, struct ref_states *states)
+{
+ struct ref *fetch_map = NULL, **tail = &fetch_map;
+ int i;
+
+ for (i = 0; i < states->remote->fetch_refspec_nr; i++)
+ if (get_fetch_map(ref, states->remote->fetch +i, &tail, 1))
+ die ("Could not get fetch map for refspec %s",
+ states->remote->fetch_refspec[i]);
+
+ states->new.strdup_paths = states->tracked.strdup_paths = 1;
+ for (ref = fetch_map; ref; ref = ref->next) {
+ struct path_list *target = &states->tracked;
+ unsigned char sha1[20];
+ void *util = NULL;
+
+ if (!ref->peer_ref || read_ref(ref->peer_ref->name, sha1))
+ target = &states->new;
+ else {
+ target = &states->tracked;
+ if (hashcmp(sha1, ref->new_sha1))
+ util = &states;
+ }
+ path_list_append(skip_prefix(ref->name, "refs/heads/"),
+ target)->util = util;
+ }
+ free_refs(fetch_map);
+
+ strbuf_addf(&states->remote_prefix,
+ "refs/remotes/%s/", states->remote->name);
+ for_each_ref(handle_one_branch, states);
+ sort_path_list(&states->stale);
+
+ return 0;
+}
+
+static int remove_tracking_branch(const char *refname,
+ const unsigned char *sha1, int flags, void *cb_data)
+{
+ const char *remote_prefix = cb_data;
+
+ if (!prefixcmp(refname, remote_prefix) &&
+ delete_ref(refname, sha1))
+ return error("Could not remove branch %s", refname);
+ return 0;
+}
+
+static int rm(int argc, const char **argv)
+{
+ struct option options[] = {
+ OPT_END()
+ };
+ struct remote *remote;
+ struct strbuf buf;
+ int i;
+
+ if (argc != 2)
+ usage_with_options(builtin_remote_usage, options);
+
+ remote = remote_get(argv[1]);
+ if (!remote)
+ die ("No such remote: %s", argv[1]);
+
+ strbuf_init(&buf, 0);
+ strbuf_addf(&buf, "remote.%s", remote->name);
+ if (git_config_rename_section(buf.buf, NULL) < 1)
+ return error("Could not remove config section '%s'", buf.buf);
+
+ read_branches();
+ for (i = 0; i < branch_list.nr; i++) {
+ struct path_list_item *item = branch_list.items +i;
+ struct branch_info *info = item->util;
+ if (info->remote && !strcmp(info->remote, remote->name)) {
+ const char *keys[] = { "remote", "merge", NULL }, **k;
+ for (k = keys; *k; k++) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "branch.%s.%s",
+ item->path, *k);
+ if (git_config_set(buf.buf, NULL)) {
+ strbuf_release(&buf);
+ return -1;
+ }
+ }
+ }
+ }
+
+ /*
+ * NEEDSTHOUGHT: this could check something like
+ * !remote_find_tracking(remote, &refspec) to know if the
+ * branch was really tracked. But then we'll have to make
+ * sure that no other remote writes into that branch.
+ * Probably not worth it.
+ */
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "refs/remotes/%s/", remote->name);
+ i = for_each_ref(remove_tracking_branch, buf.buf);
+ strbuf_release(&buf);
+
+ return i;
+}
+
+static void show_list(const char *title, struct path_list *list)
+{
+ int i;
+
+ if (!list->nr)
+ return;
+
+ printf(title, list->nr > 1 ? "es" : "");
+ printf("\n ");
+ for (i = 0; i < list->nr; i++)
+ printf("%s%s", i ? " " : "", list->items[i].path);
+ printf("\n");
+}
+
+static int show_or_prune(int argc, const char **argv, int prune)
+{
+ int dry_run = 0, result = 0;
+ struct option options[] = {
+ OPT_GROUP("show specific options"),
+ OPT__DRY_RUN(&dry_run),
+ OPT_END()
+ };
+ struct ref_states states;
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage, 0);
+
+ if (argc < 1)
+ usage_with_options(builtin_remote_usage, options);
+
+ memset(&states, 0, sizeof(states));
+ for (; argc; argc--, argv++) {
+ struct transport *transport;
+ const struct ref *ref;
+ struct strbuf buf;
+ int i, got_states;
+
+ states.remote = remote_get(*argv);
+ if (!states.remote)
+ return error("No such remote: %s", *argv);
+ transport = transport_get(NULL, states.remote->url[0]);
+ ref = transport_get_remote_refs(transport);
+
+ read_branches();
+ got_states = get_ref_states(ref, &states);
+ if (got_states)
+ result = error("Error getting local info for '%s'",
+ states.remote->name);
+
+ if (prune) {
+ struct strbuf buf;
+
+ strbuf_init(&buf, 0);
+ for (i = 0; i < states.stale.nr; i++) {
+ strbuf_reset(&buf);
+ strbuf_addf(&buf, "refs/remotes/%s/%s", *argv,
+ states.stale.items[i].path);
+ result |= delete_ref(buf.buf, NULL);
+ }
+
+ strbuf_release(&buf);
+ goto cleanup_states;
+ }
+
+ printf("* remote %s\n URL: %s\n", *argv,
+ states.remote->url[0] ?
+ states.remote->url[0] : "(no URL)");
+
+ for (i = 0; i < branch_list.nr; i++) {
+ struct path_list_item *branch = branch_list.items + i;
+ struct branch_info *info = branch->util;
+ int j;
+
+ if (!info->merge.nr || strcmp(*argv, info->remote))
+ continue;
+ printf(" Remote branch%s merged with 'git pull' "
+ "while on branch %s\n ",
+ info->merge.nr > 1 ? "es" : "",
+ branch->path);
+ for (j = 0; j < info->merge.nr; j++)
+ printf(" %s", info->merge.items[j].path);
+ printf("\n");
+ }
+
+ if (got_states)
+ continue;
+ strbuf_init(&buf, 0);
+ strbuf_addf(&buf, " New remote branch%%s (next fetch will "
+ "store in remotes/%s)", states.remote->name);
+ show_list(buf.buf, &states.new);
+ strbuf_release(&buf);
+ show_list(" Stale tracking branch%s (use 'git remote prune')",
+ &states.stale);
+ show_list(" Tracked remote branch%s",
+ &states.tracked);
+
+ if (states.remote->push_refspec_nr) {
+ printf(" Local branch%s pushed with 'git push'\n ",
+ states.remote->push_refspec_nr > 1 ?
+ "es" : "");
+ for (i = 0; i < states.remote->push_refspec_nr; i++) {
+ struct refspec *spec = states.remote->push + i;
+ printf(" %s%s%s%s", spec->force ? "+" : "",
+ skip_prefix(spec->src, "refs/heads/"),
+ spec->dst ? ":" : "",
+ skip_prefix(spec->dst, "refs/heads/"));
+ }
+ }
+cleanup_states:
+ /* NEEDSWORK: free remote */
+ path_list_clear(&states.new, 0);
+ path_list_clear(&states.stale, 0);
+ path_list_clear(&states.tracked, 0);
+ }
+
+ return result;
+}
+
+static int update_one(struct remote *remote, void *priv)
+{
+ if (!remote->skip_default_update)
+ return fetch_remote(remote->name);
+ return 0;
+}
+
+static int update(int argc, const char **argv)
+{
+ int i;
+
+ if (argc < 2)
+ return for_each_remote(update_one, NULL);
+
+ for (i = 1; i < argc; i++)
+ if (fetch_remote(argv[i]))
+ return 1;
+ return 0;
+}
+
+static int get_one_entry(struct remote *remote, void *priv)
+{
+ struct path_list *list = priv;
+
+ path_list_append(remote->name, list)->util = (void *)remote->url[0];
+ if (remote->url[0] && remote->url[1])
+ warning ("Remote %s has more than one URL", remote->name);
+
+ return 0;
+}
+
+static int show_all()
+{
+ struct path_list list = { NULL, 0, 0 };
+ int result = for_each_remote(get_one_entry, &list);
+
+ if (!result) {
+ int i;
+
+ sort_path_list(&list);
+ for (i = 0; i < list.nr; i++) {
+ struct path_list_item *item = list.items + i;
+ printf("%s%s%s\n", item->path,
+ verbose ? "\t" : "",
+ verbose && item->util ?
+ (const char *)item->util : "");
+ }
+ }
+ return result;
+}
+
+int cmd_remote(int argc, const char **argv, const char *prefix)
+{
+ struct option options[] = {
+ OPT__VERBOSE(&verbose),
+ OPT_END()
+ };
+ int result;
+
+ argc = parse_options(argc, argv, options, builtin_remote_usage,
+ PARSE_OPT_STOP_AT_NON_OPTION);
+
+ if (argc < 1)
+ result = show_all();
+ else if (!strcmp(argv[0], "add"))
+ result = add(argc, argv);
+ else if (!strcmp(argv[0], "rm"))
+ result = rm(argc, argv);
+ else if (!strcmp(argv[0], "show"))
+ result = show_or_prune(argc, argv, 0);
+ else if (!strcmp(argv[0], "prune"))
+ result = show_or_prune(argc, argv, 1);
+ else if (!strcmp(argv[0], "update"))
+ result = update(argc, argv);
+ else {
+ error ("Unknown subcommand: %s", argv[0]);
+ usage_with_options(builtin_remote_usage, options);
+ }
+
+ return result ? 1 : 0;
+}
diff --git a/builtin.h b/builtin.h
index cb675c4..20b6e75 100644
--- a/builtin.h
+++ b/builtin.h
@@ -66,6 +66,7 @@ extern int cmd_prune_packed(int argc, const char **argv, const char *prefix);
extern int cmd_push(int argc, const char **argv, const char *prefix);
extern int cmd_read_tree(int argc, const char **argv, const char *prefix);
extern int cmd_reflog(int argc, const char **argv, const char *prefix);
+extern int cmd_remote(int argc, const char **argv, const char *prefix);
extern int cmd_config(int argc, const char **argv, const char *prefix);
extern int cmd_rerere(int argc, const char **argv, const char *prefix);
extern int cmd_reset(int argc, const char **argv, const char *prefix);
diff --git a/git-remote.perl b/contrib/examples/git-remote.perl
similarity index 100%
rename from git-remote.perl
rename to contrib/examples/git-remote.perl
diff --git a/git.c b/git.c
index c8b7e74..80e9082 100644
--- a/git.c
+++ b/git.c
@@ -349,6 +349,7 @@ static void handle_internal_command(int argc, const char **argv)
{ "push", cmd_push, RUN_SETUP },
{ "read-tree", cmd_read_tree, RUN_SETUP },
{ "reflog", cmd_reflog, RUN_SETUP },
+ { "remote", cmd_remote, RUN_SETUP },
{ "repo-config", cmd_config },
{ "rerere", cmd_rerere, RUN_SETUP },
{ "reset", cmd_reset, RUN_SETUP },
diff --git a/remote.c b/remote.c
index 3fb0f99..ae7abe4 100644
--- a/remote.c
+++ b/remote.c
@@ -280,7 +280,8 @@ static int handle_config(const char *key, const char *value)
remote->fetch_tags = -1;
} else if (!strcmp(subkey, ".proxy")) {
remote->http_proxy = xstrdup(value);
- }
+ } else if (!strcmp(subkey, ".skipdefaultupdate"))
+ remote->skip_default_update = 1;
return 0;
}
diff --git a/remote.h b/remote.h
index 86e036d..bb26d3c 100644
--- a/remote.h
+++ b/remote.h
@@ -22,6 +22,7 @@ struct remote {
* 2 to always fetch tags
*/
int fetch_tags;
+ int skip_default_update;
const char *receivepack;
const char *uploadpack;
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index c7d7242..d343a96 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -100,9 +100,9 @@ test_expect_success 'remove remote' '
cat > test/expect << EOF
* remote origin
URL: $(pwd)/one/.git
- Remote branch(es) merged with 'git pull' while on branch master
+ Remote branch merged with 'git pull' while on branch master
master
- New remote branches (next fetch will store in remotes/origin)
+ New remote branch (next fetch will store in remotes/origin)
master
Tracked remote branches
side master
--
1.5.3.7.2157.g9598e
^ permalink raw reply related
* [PATCH 5/6] builtin-remote: prune remotes correctly that were added with --mirror
From: Johannes Schindelin @ 2007-12-05 19:02 UTC (permalink / raw)
To: git, gitster
In-Reply-To: <Pine.LNX.4.64.0712051858270.27959@racer.site>
This adds special handling for mirror remotes.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
This fixes a real bug in git-remote, which I tried to fix in the
perl script, failing.
builtin-remote.c | 16 +++++++++++++---
t/t5505-remote.sh | 16 ++++++++++++++++
2 files changed, 29 insertions(+), 3 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index 41ac4a1..142eb97 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -367,12 +367,22 @@ static int show_or_prune(int argc, const char **argv, int prune)
if (prune) {
struct strbuf buf;
+ int prefix_len;
strbuf_init(&buf, 0);
+ if (states.remote->fetch_refspec_nr == 1 &&
+ states.remote->fetch->pattern &&
+ !strcmp(states.remote->fetch->src,
+ states.remote->fetch->dst))
+ /* handle --mirror remote */
+ strbuf_addstr(&buf, "refs/heads/");
+ else
+ strbuf_addf(&buf, "refs/remotes/%s/", *argv);
+ prefix_len = buf.len;
+
for (i = 0; i < states.stale.nr; i++) {
- strbuf_reset(&buf);
- strbuf_addf(&buf, "refs/remotes/%s/%s", *argv,
- states.stale.items[i].path);
+ strbuf_setlen(&buf, prefix_len);
+ strbuf_addstr(&buf, states.stale.items[i].path);
result |= delete_ref(buf.buf, NULL);
}
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index d343a96..2376e0a 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -131,4 +131,20 @@ test_expect_success 'prune' '
! git rev-parse refs/remotes/origin/side)
'
+test_expect_success 'add --mirror && prune' '
+ (mkdir mirror &&
+ cd mirror &&
+ git init &&
+ git remote add --mirror -f origin ../one) &&
+ (cd one &&
+ git branch -m side2 side) &&
+ (cd mirror &&
+ git rev-parse --verify refs/heads/side2 &&
+ ! git rev-parse --verify refs/heads/side &&
+ git fetch origin &&
+ git remote prune origin &&
+ ! git rev-parse --verify refs/heads/side2 &&
+ git rev-parse --verify refs/heads/side)
+'
+
test_done
--
1.5.3.7.2157.g9598e
^ permalink raw reply related
* [PATCH 6/6] DWIM "git add remote ..."
From: Johannes Schindelin @ 2007-12-05 19:03 UTC (permalink / raw)
To: git, gitster
In-Reply-To: <Pine.LNX.4.64.0712051858270.27959@racer.site>
It is wrong to divert to "git remote add" when you typed the
(more English) "git add remote". But is it also pretty convenient.
So implement it, but do not document it ;-)
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
builtin-add.c | 7 +++++++
t/t5505-remote.sh | 6 ++++++
2 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/builtin-add.c b/builtin-add.c
index 5c29cc2..b5b4c2f 100644
--- a/builtin-add.c
+++ b/builtin-add.c
@@ -196,6 +196,13 @@ int cmd_add(int argc, const char **argv, const char *prefix)
const char **pathspec;
struct dir_struct dir;
+ if (argc > 1 && !strcmp(argv[1], "remote") &&
+ access("remote", F_OK)) {
+ argv[1] = argv[0];
+ argv[0] = "remote";
+ return cmd_remote(argc, argv, prefix);
+ }
+
argc = parse_options(argc, argv, builtin_add_options,
builtin_add_usage, 0);
if (patch_interactive)
diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh
index 2376e0a..83ed70c 100755
--- a/t/t5505-remote.sh
+++ b/t/t5505-remote.sh
@@ -147,4 +147,10 @@ test_expect_success 'add --mirror && prune' '
git rev-parse --verify refs/heads/side)
'
+test_expect_success 'add remote' '
+ (cd test &&
+ git add remote -f another-one ../one &&
+ git diff master remotes/another-one/master)
+'
+
test_done
--
1.5.3.7.2157.g9598e
^ permalink raw reply related
* [PATCH 1/6] path-list: add functions to work with unsorted lists
From: Johannes Schindelin @ 2007-12-05 19:05 UTC (permalink / raw)
To: git, gitster
In-Reply-To: <Pine.LNX.4.64.0712051900370.27959@racer.site>
Up to now, path-lists were sorted at all times. But sometimes it
is much more convenient to build the list and sort it at the end,
or sort it not at all.
Add path_list_append() and sort_path_list() to allow that.
Also, add the unsorted_path_list_has_path() function, to do a linear
search.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
I should have done that long ago.
path-list.c | 30 ++++++++++++++++++++++++++++++
path-list.h | 8 +++++++-
2 files changed, 37 insertions(+), 1 deletions(-)
diff --git a/path-list.c b/path-list.c
index 3d83b7b..92e5cf2 100644
--- a/path-list.c
+++ b/path-list.c
@@ -102,3 +102,33 @@ void print_path_list(const char *text, const struct path_list *p)
for (i = 0; i < p->nr; i++)
printf("%s:%p\n", p->items[i].path, p->items[i].util);
}
+
+struct path_list_item *path_list_append(const char *path, struct path_list *list)
+{
+ ALLOC_GROW(list->items, list->nr + 1, list->alloc);
+ list->items[list->nr].path =
+ list->strdup_paths ? xstrdup(path) : (char *)path;
+ return list->items + list->nr++;
+}
+
+static int cmp_items(const void *a, const void *b)
+{
+ const struct path_list_item *one = a;
+ const struct path_list_item *two = b;
+ return strcmp(one->path, two->path);
+}
+
+void sort_path_list(struct path_list *list)
+{
+ qsort(list->items, list->nr, sizeof(*list->items), cmp_items);
+}
+
+int unsorted_path_list_has_path(struct path_list *list, const char *path)
+{
+ int i;
+ for (i = 0; i < list->nr; i++)
+ if (!strcmp(path, list->items[i].path))
+ return 1;
+ return 0;
+}
+
diff --git a/path-list.h b/path-list.h
index 5931e2c..ca2cbba 100644
--- a/path-list.h
+++ b/path-list.h
@@ -13,10 +13,16 @@ struct path_list
};
void print_path_list(const char *text, const struct path_list *p);
+void path_list_clear(struct path_list *list, int free_util);
+/* Use these functions only on sorted lists: */
int path_list_has_path(const struct path_list *list, const char *path);
-void path_list_clear(struct path_list *list, int free_util);
struct path_list_item *path_list_insert(const char *path, struct path_list *list);
struct path_list_item *path_list_lookup(const char *path, struct path_list *list);
+/* Use these functions only on unsorted lists: */
+struct path_list_item *path_list_append(const char *path, struct path_list *list);
+void sort_path_list(struct path_list *list);
+int unsorted_path_list_has_path(struct path_list *list, const char *path);
+
#endif /* PATH_LIST_H */
--
1.5.3.7.2157.g9598e
^ permalink raw reply related
* Re: [PATCH] git-checkout --push/--pop
From: David Kågedal @ 2007-12-05 17:44 UTC (permalink / raw)
To: git
In-Reply-To: <vpqir3de8t6.fsf@bauges.imag.fr>
Matthieu Moy <Matthieu.Moy@imag.fr> writes:
> Junio C Hamano <gitster@pobox.com> writes:
>
>> Matthieu, is this something that forgetful people would find useful?
>
> Not sure. That's obviously an interesting feature, but adding two more
> options to checkout (which is already a huge swiss-army knife) might
> not be worth the trouble.
>
> And the issue with push/pop approaches is that I usually notice I have
> to use pop after not having used push (i.e. I use "cd -" all the time,
> but rarely "pushd"/"popd").
It is probably more common that you want to be able to switch back to
the previous branch, than that you actually need a full stack.
So a "git checkout --previous" could be enough. Or a set of aliases
[alias]
co = !"git symbolic-ref HEAD | sed -ne 's!refs/heads/!!p' > .git/LAST ; git checkout"
pop = !"git co $(cat .git/LAST)"
--
David Kågedal
^ permalink raw reply
* Re: fetch_refs_via_pack() discards status?
From: Daniel Barkalow @ 2007-12-05 19:16 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Shawn O. Pearce, Git Mailing List
In-Reply-To: <7vk5nt1v7k.fsf@gitster.siamese.dyndns.org>
On Tue, 4 Dec 2007, Junio C Hamano wrote:
> The code calls fetch_pack() to get the list of refs it fetched, and
> discards refs and always returns 0 to signal success.
>
> But builtin-fetch-pack.c::fetch_pack() has error cases. The function
> returns NULL if error is detected (shallow-support side seems to choose
> to die but I suspect that is easily fixable to error out as well).
>
> Shouldn't fetch_refs_via_pack() propagate that error to the caller?
I think that's right. I think I got as far as having the error status from
fetch_pack() actually returned correctly, and then failed to look at it.
I'd personally avoid testing a pointer to freed memory, but that's
obviously not actually wrong.
-Daniel
*This .sig left intentionally blank*
^ permalink raw reply
* Re: [PATCH] Add option --path to allow to run tests with real systems
From: Junio C Hamano @ 2007-12-05 19:32 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
In-Reply-To: <20071205134522.GA24617@laptop>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> diff --git a/t/test-lib.sh b/t/test-lib.sh
> index 90b6844..50a3551 100644
> --- a/t/test-lib.sh
> +++ b/t/test-lib.sh
> @@ -84,6 +84,8 @@ do
> --no-python)
> # noop now...
> shift ;;
> + --path=*)
> + path="${1#*=}"; shift ;;
> *)
> break ;;
> esac
> @@ -296,11 +298,19 @@ test_done () {
>
> # Test the binaries we have just built. The tests are kept in
> # t/ subdirectory and are run in trash subdirectory.
> -PATH=$(pwd)/..:$PATH
> -GIT_EXEC_PATH=$(pwd)/..
> +if [ -n "$path" ]; then
> + [ -x "$path/git" ] || error "git not found in $path"
> + PATH="$path":$PATH
> + export PATH
> + GIT_EXEC_PATH="$(git --exec-path)"
This is wrong, isn't it? $path may point at the freshly built but not
installed git executable, but it reports --exec-path the location that
git-foo and friends are to be _eventually_ installed, not the location
they are sitting after built, being tested, waiting to be installed.
^ permalink raw reply
* Re: [PATCH] git config: Don't rely on regexec() returning 1 on non-match
From: Junio C Hamano @ 2007-12-05 19:34 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: Björn Steinbrink, gitster, git
In-Reply-To: <Pine.LNX.4.64.0712051513570.27959@racer.site>
Thanks. I'll apply but http://git.pastebin.com/m24a4e277 feels somewhat
safer and less intrusive.
^ permalink raw reply
* Re: [PATCH 6/6] DWIM "git add remote ..."
From: Linus Torvalds @ 2007-12-05 19:34 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git, gitster
In-Reply-To: <Pine.LNX.4.64.0712051902510.27959@racer.site>
On Wed, 5 Dec 2007, Johannes Schindelin wrote:
>
> It is wrong to divert to "git remote add" when you typed the
> (more English) "git add remote". But is it also pretty convenient.
Please don't do cute things like this. Suddenly "git add remote" has two
different meanings depending on whether you have a file called "remote" or
not. That is *not* ok.
Not to mention the fact that your patch is also a horrible piece of
bug-infested shit, to put it less-than-politely. Namely, you now broke
"git add remote" when "remote" is a symbolic link pointing to hyperspace.
But even if you fix that bug, it only goes to show just how misguided
things like these are. It's a *lot* more important to make sense and not
have surprising special cases, than to try to make git command lines act
as if they were free-form English.
Linus
^ permalink raw reply
* Re: [PATCH/RFC] autoconf: Add test for OLD_ICONV
From: Junio C Hamano @ 2007-12-05 19:38 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, Ramsay Jones, Arjen Laarhoven, Brian Gernhardt
In-Reply-To: <1196869526-2197-1-git-send-email-jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> diff --git a/configure.ac b/configure.ac
> index 5f8a15b..5d2936e 100644
> --- a/configure.ac
> +++ b/configure.ac
> @@ -212,6 +212,27 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket"
>
>
> ## Checks for header files.
> +AC_MSG_NOTICE([CHECKS for header files])
> +#
> +# Define OLD_ICONV if your library has an old iconv(), where the second
> +# (input buffer pointer) parameter is declared with type (const char **).
> +AC_DEFUN([OLDICONVTEST_SRC], [[
> +#include <iconv.h>
> +
> +int main(void)
> +{
> + iconv_t cd;
> + char *ibp, *obp;
> + size_t insz, outsz;
> + iconv(cd, &ibp, &insz, &obp, &outsz);
> +}
> +]])
> +AC_MSG_CHECKING([for old iconv()])
> +AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
> + [AC_MSG_RESULT([no])],
> + [AC_MSG_RESULT([yes])
> + OLD_ICONV=YesPlease])
> +AC_SUBST(OLD_ICONV)
>
Which result does COMPILE_IFELSE give for non error warnings? Ok, or
Bad?
^ permalink raw reply
* Re: [PATCH] Soft aliases: add "less" and minimal documentation
From: Junio C Hamano @ 2007-12-05 19:45 UTC (permalink / raw)
To: Johannes Schindelin; +Cc: git
In-Reply-To: <Pine.LNX.4.64.0712051131120.27959@racer.site>
Johannes Schindelin <Johannes.Schindelin@gmx.de> writes:
> Now you can use "git less HEAD" to view the raw HEAD commit object. It
> is really a soft alias (i.e. it can be overridden by any user-specified
> alias) to "-p cat-file -p".
I actually regret to have suggested "git less". Not only because you
can always say "git show" instead, but because the error message you
would get with usage string will _not_ say "git-less", but some other
command's name if you say "git less nonsense".
I on the other hand find the "view" alias moderately less problematic.
As long as the future direction for the "view" alias is to allow it to
notice user preference and launch something other than the default
"gitk", iow, it is crystal clear that "git view" is just a short-hand
for launching a history browser and the users are free to choose
whichever viewer available, it won't feel inconsistent if underlying
"gitk" barfed on malformed input using its own name.
But then the users can do all that themselves. People who like qgit do
not have to configure "git view" to launch qgit but instead run their
favorite program directly. One thing the built-in alias is possibly
bringing to the table is to give smaller number of commands people need
to learn, without having to know "gitk", "qgit", "tig", "gitview",
"instaweb", and possibly others, while at the same time enforcing a
policy that the history viewer of choice is aliased to "git view" (not
"git viewer" or "git visualize") to maintain a bit of consistency across
users.
By extension to this reasoning, I am not too keen on adding "update",
"up", "checkin", "ci", nor "co". I do not think of any alternative
backend implementations to these aliases, which means that there isn't
even the advantage of giving a single front-end that lets the user do
the same thing using a choice from multiple backends and keeps the
interface simple for these names.
^ permalink raw reply
* Re: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
From: Junio C Hamano @ 2007-12-05 19:46 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, Guillaume Seguin
In-Reply-To: <200712051113.40654.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> First patch, which is modified version of Guillaume Seguin patch solves
> problem that links in gitweb does lead to correct 'tag' view, while the
> second one solves the problem from the other side: instead of ensuring
> that links in gitweb are unambiguous it tries to resolve ambiguity.
Ok, I'll queue the first one (disambiguate) for 1.5.4 while letting the
people decide the latter for now.
> The problem is caused by the fact that git _always_ prefer heads (head
> refs) to tags (tag refs), even when it is clear
> $ git cat-file tags ambiguous-ref
> that we want a tag. So alternate solution would be to correct
> git-cat-file.
You are getting the layering all wrong.
* git-cat-file takes "object name" on its command line (so do many
other commands).
* One of the way to spell an "object name" is to refer to it with a ref
that can reach it (e.g. to name 12th generation parent of the tip of
the master branch, you spell "master~12" and you are using the ref
refs/heads/master).
* You do not have to always write out the ref in full. There is a
defined order to disambiguate refs (see git-rev-parse(1)), that
allows you to say 'master' and it expands to either refs/tags/master,
refs/heads/master or whatever.
Now git-cat-file does not care how you spelled your object name, and has
no business influencing the ref disambiguation order. You _could_ argue
"git cat-file tag <foo>" _expects_ <foo> to name a tag, but that logic
is very flawed (and that is why I said your understanding of layering is
screwed) for two reasons:
(1) <foo> may be user input to the script that uses cat-file and the
script may be expecting a tag there. Perhaps the script is about
creating a new branch from a tag (expecting a tag) and adds some
administrative info in the configuration file for the branch. It
does first:
t=$(git cat-file tag "$1") || die not a tag
and later the script may want to do:
git branch $newone "$1"
git config branch.$newone.description "created from tag $1 ($t)"
If you make "cat-file tag" to favor tag, and in a similar fashion
if you make "branch" favor branch, the above will not do what you
expect.
Consistently resolving the refname without (or minimum number of)
exceptions would give less surprising result.
(2) "git cat-file -t <foo>" is to find out what type the object is and
is meant to be used by callers who do not know the type. There is
no "favoring this class of ref over other classses" possible there.
> It would be quite easy I think to add checking if gitweb returns
> expected HTTP return code (HTTP status). So what is the portable way
> to check if first line of some output matches given regexp (given fixed
> string)?
Huh? Wouldn't something like this be enough?
>expect.empty &&
cmd >actual.out 2>actual.err &&
diff -u expect.empty actual.err &&
first=$(sed -e '1q' <actual.out) &&
test "z$first" = "I like it"
^ permalink raw reply
* Re: [PATCH] Color support for "git-add -i"
From: Junio C Hamano @ 2007-12-05 19:46 UTC (permalink / raw)
To: Johannes Sixt; +Cc: Dan Zwell, Jeff King, Wincent Colaiuta, git
In-Reply-To: <475697BC.2090701@viscovery.net>
Johannes Sixt <j.sixt@viscovery.net> writes:
> Junio C Hamano schrieb:
>> +color.interactive::
>> + When true (or `always`), always use colors in `git add
>> + --interactive`. When false (or `never`), never. When set to
>> + `auto`, use colors only when the output is to the
>> + terminal. Defaults to false.
>
> Any particular reason why color.interactive = true should be different from
> color.diff = true? See 57f2b842 ("color.diff = true" is not "always" anymore)
Leftover from the original series. Thanks for noticing.
We will probably want that "git config --colorbool" thing we discussed
earlier.
^ permalink raw reply
* Re: [PATCH 6/6] DWIM "git add remote ..."
From: Johannes Schindelin @ 2007-12-05 19:47 UTC (permalink / raw)
To: Linus Torvalds; +Cc: git, gitster
In-Reply-To: <alpine.LFD.0.9999.0712051129280.13796@woody.linux-foundation.org>
Hi,
On Wed, 5 Dec 2007, Linus Torvalds wrote:
> On Wed, 5 Dec 2007, Johannes Schindelin wrote:
> >
> > It is wrong to divert to "git remote add" when you typed the (more
> > English) "git add remote". But is it also pretty convenient.
>
> Please don't do cute things like this. Suddenly "git add remote" has two
> different meanings depending on whether you have a file called "remote"
> or not. That is *not* ok.
>
> Not to mention the fact that your patch is also a horrible piece of
> bug-infested shit, to put it less-than-politely. Namely, you now broke
> "git add remote" when "remote" is a symbolic link pointing to
> hyperspace.
>
> But even if you fix that bug, it only goes to show just how misguided
> things like these are. It's a *lot* more important to make sense and not
> have surprising special cases, than to try to make git command lines act
> as if they were free-form English.
Hehe. You're right, of course. But I could not resist showing off that
patch which I wrote after I mixed up the command line of "remote add" for
the 926th time.
Ciao,
Dscho
^ permalink raw reply
* Re: [PATCH/RFC] autoconf: Add test for OLD_ICONV
From: Wincent Colaiuta @ 2007-12-05 20:49 UTC (permalink / raw)
To: Jakub Narebski
Cc: git, Junio C Hamano, Ramsay Jones, Arjen Laarhoven,
Brian Gernhardt
In-Reply-To: <200712051752.28667.jnareb@gmail.com>
El 5/12/2007, a las 17:52, Jakub Narebski escribió:
> On Wed, 5 December 2007, Wincent Colaiuta wrote:
>>
>> Before applying your patch:
>>
>> CC utf8.o
>> utf8.c: In function ‘reencode_string’:
>> utf8.c:328: warning: passing argument 2 of ‘iconv’ from incompatible
>> pointer type
>> CC convert.o
>>
>> After applying your patch:
>>
>> CC utf8.o
>> CC convert.o
>
> Do I understand correctly that above is excerpt from the output of the
> following sequence of commands before and after this patch applied?
>
> $ make configure
> $ ./configure [options]
> $ make
Yes, that's right, but with a "make clean" before anything else.
> Do you have something like below in ./configure output?
>
> configure: CHECKS for header files
> checking for old iconv()... yes
This:
configure: CHECKS for header files
checking for old iconv()... no
>> This on Darwin Kernel Version 9.1.0 (Mac OS X 10.5.1).
>
> Strange... in Makefile there is
>
> ifeq ($(uname_S),Darwin)
> NEEDS_SSL_WITH_CRYPTO = YesPlease
> NEEDS_LIBICONV = YesPlease
> OLD_ICONV = UnfortunatelyYes
> NO_STRLCPY = YesPlease
> NO_MEMMEM = YesPlease
> endif
>
> so the uname based guessing should set OLD_ICONV on Darwin...
That happens *before* config.mak.autogen is included in the Makefile,
so it gets overridden.
Cheers,
Wincent
^ permalink raw reply
* Re: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
From: Jakub Narebski @ 2007-12-05 21:02 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Guillaume Seguin
In-Reply-To: <7v7ijsq5zm.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
> > It would be quite easy I think to add checking if gitweb returns
> > expected HTTP return code (HTTP status). So what is the portable way
> > to check if first line of some output matches given regexp (given fixed
> > string)?
>
> Huh? Wouldn't something like this be enough?
>
> >expect.empty &&
> cmd >actual.out 2>actual.err &&
> diff -u expect.empty actual.err &&
> first=$(sed -e '1q' <actual.out) &&
> test "z$first" = "I like it"
Well, actually that is even better idea. We can go for one of the three
levels of HTTP status checking:
1. Check if we got "Status: 200 OK" when we expect it, and not have it
when we expect other HTTP status, e.g. when requesting nonexistent
file. The above code is enough for that.
2. We can check if we got expected status number, for example 200 for
when we expect no error, or 404 when object is not found, or 403
if there is no such object etc. I was thinking about using this version
the need to check not full first line, but fragment of it.
3. We can check full first line, for example
Status: 200 OK
Status: 403 Forbidden
Status: 404 Not Found
Status: 400 Bad Request
but this might tie gitweb test too tightly with minute details of
gitweb output. The above code is good for that too.
What do you think, which route we should go in test?
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: fetch_refs_via_pack() discards status?
From: Junio C Hamano @ 2007-12-05 21:06 UTC (permalink / raw)
To: Daniel Barkalow; +Cc: Shawn O. Pearce, Git Mailing List
In-Reply-To: <Pine.LNX.4.64.0712051356040.5349@iabervon.org>
Daniel Barkalow <barkalow@iabervon.org> writes:
> On Tue, 4 Dec 2007, Junio C Hamano wrote:
>
>> The code calls fetch_pack() to get the list of refs it fetched, and
>> discards refs and always returns 0 to signal success.
>>
>> But builtin-fetch-pack.c::fetch_pack() has error cases. The function
>> returns NULL if error is detected (shallow-support side seems to choose
>> to die but I suspect that is easily fixable to error out as well).
>>
>> Shouldn't fetch_refs_via_pack() propagate that error to the caller?
>
> I think that's right. I think I got as far as having the error status from
> fetch_pack() actually returned correctly, and then failed to look at it.
> I'd personally avoid testing a pointer to freed memory, but that's
> obviously not actually wrong.
>
> -Daniel
Hmph, is that an Ack that the patchlet is actually a bugfix?
^ permalink raw reply
* Re: [PATCH] gitweb: Try harder in parse_tag; perhaps it was given ambiguous name
From: Junio C Hamano @ 2007-12-05 21:14 UTC (permalink / raw)
To: Jakub Narebski; +Cc: git, Guillaume Seguin
In-Reply-To: <200712052202.27111.jnareb@gmail.com>
Jakub Narebski <jnareb@gmail.com> writes:
> Well, actually that is even better idea. We can go for one of the three
> levels of HTTP status checking:
>
> 1. Check if we got "Status: 200 OK" when we expect it, and not have it
> when we expect other HTTP status, e.g. when requesting nonexistent
> file. The above code is enough for that.
>
> 2. We can check if we got expected status number, for example 200 for
> when we expect no error, or 404 when object is not found, or 403
> if there is no such object etc. I was thinking about using this version
> the need to check not full first line, but fragment of it.
>
> 3. We can check full first line, for example
> Status: 200 OK
> Status: 403 Forbidden
> Status: 404 Not Found
> Status: 400 Bad Request
> but this might tie gitweb test too tightly with minute details of
> gitweb output. The above code is good for that too.
>
> What do you think, which route we should go in test?
4. We should check for what we expect in the parts of gitweb output we
care about. E.g.
* If we are making sure it refuses to serve incorrect request
(e.g. no such repository), we should check for the status, which is
what we care about (we may not care about how the actual error
message is stated).
* Otherwise (and I suspect this is "most of the tests"), we obviously
expect to have "200 OK", and check for that;
BUT IN ADDITION
* If we want to make sure that a specific aspect of the output was
buggy and a patch fixed it (e.g. an href used a short refname
without having refs/heads or refs/tags prefixed, causing
ambiguity), we also should check that part of output in generated
HTML, not just the HTTP status header.
^ permalink raw reply
* Re: [PATCH/RFC] autoconf: Add test for OLD_ICONV
From: Jakub Narebski @ 2007-12-05 21:19 UTC (permalink / raw)
To: Wincent Colaiuta
Cc: git, Junio C Hamano, Ramsay Jones, Arjen Laarhoven,
Brian Gernhardt
In-Reply-To: <52A4CC8B-EB11-4E3F-A3B6-06826F860E5D@wincent.com>
Wincent Colaiuta wrote:
> El 5/12/2007, a las 17:52, Jakub Narebski escribió:
>> On Wed, 5 December 2007, Wincent Colaiuta wrote:
>>>
>>> Before applying your patch:
>>>
>>> CC utf8.o
>>> utf8.c: In function ‘reencode_string’:
>>> utf8.c:328: warning: passing argument 2 of ‘iconv’ from incompatible
>>> pointer type
>>> CC convert.o
>>>
>>> After applying your patch:
>>>
>>> CC utf8.o
>>> CC convert.o
>>
>> Do I understand correctly that above is excerpt from the output of the
>> following sequence of commands before and after this patch applied?
>>
>> $ make configure
>> $ ./configure [options]
>> $ make
>
> Yes, that's right, but with a "make clean" before anything else.
>
>> Do you have something like below in ./configure output?
>>
>> configure: CHECKS for header files
>> checking for old iconv()... yes
>
> This:
>
> configure: CHECKS for header files
> checking for old iconv()... no
>
>>> This on Darwin Kernel Version 9.1.0 (Mac OS X 10.5.1).
>>
>> Strange... in Makefile there is
>>
>> ifeq ($(uname_S),Darwin)
>> NEEDS_SSL_WITH_CRYPTO = YesPlease
>> NEEDS_LIBICONV = YesPlease
>> OLD_ICONV = UnfortunatelyYes
>> NO_STRLCPY = YesPlease
>> NO_MEMMEM = YesPlease
>> endif
>>
>> so the uname based guessing should set OLD_ICONV on Darwin...
>
> That happens *before* config.mak.autogen is included in the Makefile,
> so it gets overridden.
Ahhh... now I understand. You have installed new iconv() on your
computer, and generic 'uname -s' (OS name) based guessing in Makefile
guesses wrongly that you need OLD_ICONV, while ./configure script
actually tests it and correctly decides to unset OLD_ICONV !
BTW. Perhaps it whould be written more explicitely:
+AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
+ [AC_MSG_RESULT([no])
+ OLD_ICONV=],
+ [AC_MSG_RESULT([yes])
+ OLD_ICONV=YesPlease])
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: [PATCH/RFC] autoconf: Add test for OLD_ICONV
From: Jakub Narebski @ 2007-12-05 21:26 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git, Ramsay Jones, Arjen Laarhoven, Brian Gernhardt
In-Reply-To: <7vtzmxortn.fsf@gitster.siamese.dyndns.org>
Junio C Hamano wrote:
> Jakub Narebski <jnareb@gmail.com> writes:
>
>> +AC_MSG_CHECKING([for old iconv()])
>> +AC_COMPILE_IFELSE(OLDICONVTEST_SRC,
>> + [AC_MSG_RESULT([no])],
>> + [AC_MSG_RESULT([yes])
>> + OLD_ICONV=YesPlease])
>> +AC_SUBST(OLD_ICONV)
>>
>
> Which result does COMPILE_IFELSE give for non error warnings? Ok, or
> Bad?
- Macro: AC_COMPILE_IFELSE (INPUT, [ACTION-IF-FOUND],
[ACTION-IF-NOT-FOUND])
Run the compiler and compilation flags of the current language
(*note Language Choice::) on the INPUT, run the shell commands
ACTION-IF-TRUE on success, ACTION-IF-FALSE otherwise. The INPUT
can be made by `AC_LANG_PROGRAM' and friends.
And if I have checked correctly code which causes only warnings
returns Ok (in this case print 'no' after 'checking for old iconv()... '
and do not set OLD_ICONV, which means it will be unset).
--
Jakub Narebski
Poland
^ permalink raw reply
* Re: git-svn: .git/svn disk usage
From: Steven Grimm @ 2007-12-05 21:30 UTC (permalink / raw)
To: Eric Wong; +Cc: David Voit, git
In-Reply-To: <20071205085451.GA347@soma>
How about using git itself to keep some of this information? I'll just
throw this idea out there; might or might not make any actual sense.
Create a new "git-svn metadata" branch. This branch contains a fake
directory (never intended for checkout, though you could do it) that
has a "file" for each svn revision. The filename is just the svn
revision number, maybe divided into subdirectories in case you want to
check the branch out for debugging purposes or whatever. The contents
are the git commit SHA1 and whatever other metadata you want to keep
in the future.
The advantage of doing it this way? You can pass around svn metadata
using the normal git fetch/push tools, query the metadata using "git
show", etc. In terms of data integrity, it's as secure as anything
else in a git repository, much more so than a separately maintained db
file under .git.
Along similar lines, a separate branch where the filenames are commit
SHA1s and the file contents are the stuff that currently gets written
into the git-svn-id: lines would mean no more need to rewrite history
when doing dcommit, and thus easier mixing of native git workflows and
interactions with an svn repository.
It would be great if you could clone a git-svn repository and then do
"git svn dcommit" from the clone, secure in the knowledge that things
will stay consistent even if the origin gets your changes via "git svn
fetch" rather than from you.
-Steve
^ permalink raw reply
* Re: [PATCH/RFC] autoconf: Add test for OLD_ICONV
From: Brian Gernhardt @ 2007-12-05 21:38 UTC (permalink / raw)
To: Jakub Narebski
Cc: Wincent Colaiuta, git, Junio C Hamano, Ramsay Jones,
Arjen Laarhoven
In-Reply-To: <200712052219.00930.jnareb@gmail.com>
On Dec 5, 2007, at 4:19 PM, Jakub Narebski wrote:
> Ahhh... now I understand. You have installed new iconv() on your
> computer, and generic 'uname -s' (OS name) based guessing in Makefile
> guesses wrongly that you need OLD_ICONV, while ./configure script
> actually tests it and correctly decides to unset OLD_ICONV !
As far as the "installed new iconv()" goes, you may be wrong there.
The latest major release of OS X includes a version of iconv that does
not need OLD_ICONV as part of the base system. I've had to unset it
in my config.mak in order to avoid the warning.
~~ Brian Gernhardt
^ permalink raw reply
* [PATCH 7/6] builtin-remote: guard remote->url accesses by remote->url_nr check
From: Johannes Schindelin @ 2007-12-05 21:40 UTC (permalink / raw)
To: git, gitster; +Cc: Johannes Sixt
In-Reply-To: <Pine.LNX.4.64.0712051902080.27959@racer.site>
struct remote's url member is not a NULL terminated list. Instead, we
have to check url_nr before accessing it.
Noticed by Johannes Sixt.
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
---
For your viewing pleasure, this is not a resend, but an amend.
Feel free to squash with 4/6, or to bug me to do it.
builtin-remote.c | 10 ++++++----
1 files changed, 6 insertions(+), 4 deletions(-)
diff --git a/builtin-remote.c b/builtin-remote.c
index 142eb97..ea323e2 100644
--- a/builtin-remote.c
+++ b/builtin-remote.c
@@ -356,7 +356,8 @@ static int show_or_prune(int argc, const char **argv, int prune)
states.remote = remote_get(*argv);
if (!states.remote)
return error("No such remote: %s", *argv);
- transport = transport_get(NULL, states.remote->url[0]);
+ transport = transport_get(NULL, states.remote->url_nr > 0 ?
+ states.remote->url[0] : NULL);
ref = transport_get_remote_refs(transport);
read_branches();
@@ -391,7 +392,7 @@ static int show_or_prune(int argc, const char **argv, int prune)
}
printf("* remote %s\n URL: %s\n", *argv,
- states.remote->url[0] ?
+ states.remote->url_nr > 0 ?
states.remote->url[0] : "(no URL)");
for (i = 0; i < branch_list.nr; i++) {
@@ -468,8 +469,9 @@ static int get_one_entry(struct remote *remote, void *priv)
{
struct path_list *list = priv;
- path_list_append(remote->name, list)->util = (void *)remote->url[0];
- if (remote->url[0] && remote->url[1])
+ path_list_append(remote->name, list)->util = remote->url_nr ?
+ (void *)remote->url[0] : NULL;
+ if (remote->url_nr > 1)
warning ("Remote %s has more than one URL", remote->name);
return 0;
--
1.5.3.7.2157.g9598e
^ permalink raw reply related
* Re: [PATCH/RFC] autoconf: Add test for OLD_ICONV
From: Pascal Obry @ 2007-12-05 21:46 UTC (permalink / raw)
To: Jakub Narebski
Cc: git, Junio C Hamano, Ramsay Jones, Arjen Laarhoven,
Brian Gernhardt
In-Reply-To: <1196869526-2197-1-git-send-email-jnareb@gmail.com>
Jakub Narebski a écrit :
> Signed-off-by: Jakub Narebski <jnareb@gmail.com>
> ---
> This patch needs checking if it correctly sets OLD_ICONV
> when needed. I have checked only that it is not set when
> with new iconv() declaration. Could people using Cygwin
> (and other with OLD_ICONV: Darwin) test it?
Not working on Cygwin:
$ autoconf
$ ./configure --prefix=/usr/local --build=i686-pc-cygwin
...
configure: CHECKS for header files
checking for old iconv()... no
It should be yes above. And in config.mak.autogen we have:
OLD_ICONV=
Note also that you should remove all the hard-coded settings in Makefile
anyway.
Pascal.
--
--|------------------------------------------------------
--| Pascal Obry Team-Ada Member
--| 45, rue Gabriel Peri - 78114 Magny Les Hameaux FRANCE
--|------------------------------------------------------
--| http://www.obry.net
--| "The best way to travel is by means of imagination"
--|
--| gpg --keyserver wwwkeys.pgp.net --recv-key C1082595
^ 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