From 668f3aa776bcd293de08413bf1b25b91c15f1b01 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:27 -0600 Subject: [PATCH 01/95] fast-export: Set revs.topo_order before calling setup_revisions setup_revisions sets a variety of flags based on the setting of other flags, such as setting the limited flag when topo_order is set. To avoid circumventing any invariants created by setup_revisions, we set revs.topo_order before calling it rather than after. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 6cef810312..e0cfa606dc 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -514,6 +514,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) git_config(git_default_config, NULL); init_revisions(&revs, prefix); + revs.topo_order = 1; argc = setup_revisions(argc, argv, &revs, NULL); argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0); if (argc > 1) @@ -524,7 +525,6 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) get_tags_and_duplicates(&revs.pending, &extra_refs); - revs.topo_order = 1; if (prepare_revision_walk(&revs)) die("revision walk setup failed"); revs.diffopt.format_callback = show_filemodify; From 02c48cd69b3ebfac3867f0f9ceb1503a5af118fc Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:28 -0600 Subject: [PATCH 02/95] fast-export: Omit tags that tag trees Commit c0582c53bcf4e83bba70e1ad23abbad31f96ebc8 introduced logic to just omit tags that point to tree objects. However, these objects were still being output and were pointing at "mark :0", which caused fast-import to crash. This patch makes sure such tags (including deeper nestings such as tags of tags of trees), are omitted. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 15 +++++++++++++++ t/t9301-fast-export.sh | 8 +++++++- 2 files changed, 22 insertions(+), 1 deletion(-) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index e0cfa606dc..8c90a2df67 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -289,6 +289,21 @@ static void handle_tag(const char *name, struct tag *tag) char *buf; const char *tagger, *tagger_end, *message; size_t message_size = 0; + struct object *tagged; + + /* Trees have no identifer in fast-export output, thus we have no way + * to output tags of trees, tags of tags of trees, etc. Simply omit + * such tags. + */ + tagged = tag->tagged; + while (tagged->type == OBJ_TAG) { + tagged = ((struct tag *)tagged)->tagged; + } + if (tagged->type == OBJ_TREE) { + warning("Omitting tag %s,\nsince tags of trees (or tags of tags of trees, etc.) are not supported.", + sha1_to_hex(tag->object.sha1)); + return; + } buf = read_sha1_file(tag->object.sha1, &type, &size); if (!buf) diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index 8c8a9e63c2..3f13e6b15c 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -271,8 +271,14 @@ test_expect_success 'set-up a few more tags for tag export tests' ' git tag -a tag-obj_tag-obj -m "tagging a tag" tree_tag-obj ' +test_expect_success 'tree_tag' ' + mkdir result && + (cd result && git init) && + git fast-export tree_tag > fe-stream && + (cd result && git fast-import < ../fe-stream) +' + # NEEDSWORK: not just check return status, but validate the output -test_expect_success 'tree_tag' 'git fast-export tree_tag' test_expect_success 'tree_tag-obj' 'git fast-export tree_tag-obj' test_expect_success 'tag-obj_tag' 'git fast-export tag-obj_tag' test_expect_success 'tag-obj_tag-obj' 'git fast-export tag-obj_tag-obj' From 2374502c6ca1c8007cb35682f13fb5db044df9ea Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:29 -0600 Subject: [PATCH 03/95] fast-export: Make sure we show actual ref names instead of "(null)" The code expects a ref name to be provided in commit->util. While there was some code to set commit->util, it only worked in cases where there was an unbroken chain of revisions from a ref to the relevant commit. In cases such as running git fast-export --parents master -- COPYING commit->util would fail to be set. The old method of setting commit->util has been removed in favor of requesting show_source from the revision traversal machinery (related to the "--source" option of "git log" family of commands.) However, this change does not fix cases like git fast export master~1 or git fast export :/arguments since in such cases commit->util will be "master~1" or ":/arguments" while we need the actual ref (e.g. "refs/heads/master") Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 8c90a2df67..43a7e17d3e 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -530,6 +530,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) init_revisions(&revs, prefix); revs.topo_order = 1; + revs.show_source = 1; argc = setup_revisions(argc, argv, &revs, NULL); argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0); if (argc > 1) @@ -546,11 +547,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) DIFF_OPT_SET(&revs.diffopt, RECURSIVE); while ((commit = get_revision(&revs))) { if (has_unshown_parent(commit)) { - struct commit_list *parent = commit->parents; add_object_array(&commit->object, NULL, &commits); - for (; parent; parent = parent->next) - if (!parent->item->util) - parent->item->util = commit->util; } else { handle_commit(commit, &revs); From 32164131db0984544b222ac515f95f917fa01441 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:30 -0600 Subject: [PATCH 04/95] fast-export: Do parent rewriting to avoid dropping relevant commits When specifying paths to export, parent rewriting must be turned on for fast-export to output anything at all. Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- builtin-fast-export.c | 1 + 1 file changed, 1 insertion(+) diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 43a7e17d3e..9b8bd37290 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -531,6 +531,7 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) init_revisions(&revs, prefix); revs.topo_order = 1; revs.show_source = 1; + revs.rewrite_parents = 1; argc = setup_revisions(argc, argv, &revs, NULL); argc = parse_options(argc, argv, prefix, options, fast_export_usage, 0); if (argc > 1) From 2d8ad46919213ebbd7bb72eb5b56cca8cc3ae07f Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:31 -0600 Subject: [PATCH 05/95] fast-export: Add a --tag-of-filtered-object option for newly dangling tags When providing a list of paths to limit what is exported, the object that a tag points to can be filtered out entirely. This new switch allows the user to specify what should happen to the tag in such a case. The default action, 'abort' will exit with an error message. With 'drop', the tag will simply be omitted from the output. With 'rewrite', if the object tagged was a commit, the tag will be modified to tag an alternate commit. The alternate commit is determined by treating the original commit as the "parent" of the tag and then using the parent rewriting algorithm of the revision traversal machinery (related to the "--parents" option of "git rev-list") Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- Documentation/git-fast-export.txt | 11 ++++++ builtin-fast-export.c | 59 +++++++++++++++++++++++++++++-- 2 files changed, 68 insertions(+), 2 deletions(-) diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt index 0c9eb567cb..194abdeeba 100644 --- a/Documentation/git-fast-export.txt +++ b/Documentation/git-fast-export.txt @@ -36,6 +36,17 @@ when encountering a signed tag. With 'strip', the tags will be made unsigned, with 'verbatim', they will be silently exported and with 'warn', they will be exported, but you will see a warning. +--tag-of-filtered-object=(abort|drop|rewrite):: + Specify how to handle tags whose tagged objectis filtered out. + Since revisions and files to export can be limited by path, + tagged objects may be filtered completely. ++ +When asking to 'abort' (which is the default), this program will die +when encountering such a tag. With 'drop' it will omit such tags from +the output. With 'rewrite', if the tagged object is a commit, it will +rewrite the tag to tag an ancestor commit (via parent rewriting; see +linkgit:git-rev-list[1]) + -M:: -C:: Perform move and/or copy detection, as described in the diff --git a/builtin-fast-export.c b/builtin-fast-export.c index 9b8bd37290..dc2c6ab173 100644 --- a/builtin-fast-export.c +++ b/builtin-fast-export.c @@ -23,7 +23,8 @@ static const char *fast_export_usage[] = { }; static int progress; -static enum { VERBATIM, WARN, STRIP, ABORT } signed_tag_mode = ABORT; +static enum { ABORT, VERBATIM, WARN, STRIP } signed_tag_mode = ABORT; +static enum { ERROR, DROP, REWRITE } tag_of_filtered_mode = ABORT; static int fake_missing_tagger; static int parse_opt_signed_tag_mode(const struct option *opt, @@ -42,6 +43,20 @@ static int parse_opt_signed_tag_mode(const struct option *opt, return 0; } +static int parse_opt_tag_of_filtered_mode(const struct option *opt, + const char *arg, int unset) +{ + if (unset || !strcmp(arg, "abort")) + tag_of_filtered_mode = ABORT; + else if (!strcmp(arg, "drop")) + tag_of_filtered_mode = DROP; + else if (!strcmp(arg, "rewrite")) + tag_of_filtered_mode = REWRITE; + else + return error("Unknown tag-of-filtered mode: %s", arg); + return 0; +} + static struct decoration idnums; static uint32_t last_idnum; @@ -290,6 +305,8 @@ static void handle_tag(const char *name, struct tag *tag) const char *tagger, *tagger_end, *message; size_t message_size = 0; struct object *tagged; + int tagged_mark; + struct commit *p; /* Trees have no identifer in fast-export output, thus we have no way * to output tags of trees, tags of tags of trees, etc. Simply omit @@ -348,10 +365,45 @@ static void handle_tag(const char *name, struct tag *tag) } } + /* handle tag->tagged having been filtered out due to paths specified */ + tagged = tag->tagged; + tagged_mark = get_object_mark(tagged); + if (!tagged_mark) { + switch(tag_of_filtered_mode) { + case ABORT: + die ("Tag %s tags unexported object; use " + "--tag-of-filtered-object= to handle it.", + sha1_to_hex(tag->object.sha1)); + case DROP: + /* Ignore this tag altogether */ + return; + case REWRITE: + if (tagged->type != OBJ_COMMIT) { + die ("Tag %s tags unexported %s!", + sha1_to_hex(tag->object.sha1), + typename(tagged->type)); + } + p = (struct commit *)tagged; + for (;;) { + if (p->parents && p->parents->next) + break; + if (p->object.flags & UNINTERESTING) + break; + if (!(p->object.flags & TREESAME)) + break; + if (!p->parents) + die ("Can't find replacement commit for tag %s\n", + sha1_to_hex(tag->object.sha1)); + p = p->parents->item; + } + tagged_mark = get_object_mark(&p->object); + } + } + if (!prefixcmp(name, "refs/tags/")) name += 10; printf("tag %s\nfrom :%d\n%.*s%sdata %d\n%.*s\n", - name, get_object_mark(tag->tagged), + name, tagged_mark, (int)(tagger_end - tagger), tagger, tagger == tagger_end ? "" : "\n", (int)message_size, (int)message_size, message ? message : ""); @@ -513,6 +565,9 @@ int cmd_fast_export(int argc, const char **argv, const char *prefix) OPT_CALLBACK(0, "signed-tags", &signed_tag_mode, "mode", "select handling of signed tags", parse_opt_signed_tag_mode), + OPT_CALLBACK(0, "tag-of-filtered-object", &tag_of_filtered_mode, "mode", + "select handling of tags that tag filtered objects", + parse_opt_tag_of_filtered_mode), OPT_STRING(0, "export-marks", &export_filename, "FILE", "Dump marks to this file"), OPT_STRING(0, "import-marks", &import_filename, "FILE", From 25e0ca5dd61f8a4625393fa1b71e1f88c9fab754 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:32 -0600 Subject: [PATCH 06/95] Add new fast-export testcases The testcases test the new --tag-of-filtered-object option, the output when limiting what to export by path, and test behavior when no exact-ref revision is included (e.g. master~8 present on command line but not master). Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- t/t9301-fast-export.sh | 88 ++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 88 insertions(+) diff --git a/t/t9301-fast-export.sh b/t/t9301-fast-export.sh index 3f13e6b15c..356964e53a 100755 --- a/t/t9301-fast-export.sh +++ b/t/t9301-fast-export.sh @@ -262,6 +262,94 @@ test_expect_success 'cope with tagger-less tags' ' ' +test_expect_success 'setup for limiting exports by PATH' ' + mkdir limit-by-paths && + cd limit-by-paths && + git init && + echo hi > there && + git add there && + git commit -m "First file" && + echo foo > bar && + git add bar && + git commit -m "Second file" && + git tag -a -m msg mytag && + echo morefoo >> bar && + git add bar && + git commit -m "Change to second file" && + cd .. +' + +cat > limit-by-paths/expected << EOF +blob +mark :1 +data 3 +hi + +reset refs/tags/mytag +commit refs/tags/mytag +mark :2 +author A U Thor 1112912713 -0700 +committer C O Mitter 1112912713 -0700 +data 11 +First file +M 100644 :1 there + +EOF + +test_expect_success 'dropping tag of filtered out object' ' + cd limit-by-paths && + git fast-export --tag-of-filtered-object=drop mytag -- there > output && + test_cmp output expected && + cd .. +' + +cat >> limit-by-paths/expected << EOF +tag mytag +from :2 +tagger C O Mitter 1112912713 -0700 +data 4 +msg + +EOF + +test_expect_success 'rewriting tag of filtered out object' ' + cd limit-by-paths && + git fast-export --tag-of-filtered-object=rewrite mytag -- there > output && + test_cmp output expected && + cd .. +' + +cat > limit-by-paths/expected << EOF +blob +mark :1 +data 4 +foo + +blob +mark :2 +data 3 +hi + +reset refs/heads/master +commit refs/heads/master +mark :3 +author A U Thor 1112912713 -0700 +committer C O Mitter 1112912713 -0700 +data 12 +Second file +M 100644 :1 bar +M 100644 :2 there + +EOF + +test_expect_failure 'no exact-ref revisions included' ' + cd limit-by-paths && + git fast-export master~2..master~1 > output && + test_cmp output expected && + cd .. +' + + test_expect_success 'set-up a few more tags for tag export tests' ' git checkout -f master && HEAD_TREE=`git show -s --pretty=raw HEAD | grep tree | sed "s/tree //"` && From 8af15d282e59a7f566b5e7eb71caebfc40ca5cd6 Mon Sep 17 00:00:00 2001 From: Elijah Newren Date: Thu, 25 Jun 2009 22:48:33 -0600 Subject: [PATCH 07/95] fast-export: Document the fact that git-rev-list arguments are accepted Signed-off-by: Elijah Newren Signed-off-by: Junio C Hamano --- Documentation/git-fast-export.txt | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/Documentation/git-fast-export.txt b/Documentation/git-fast-export.txt index 194abdeeba..af2328d401 100644 --- a/Documentation/git-fast-export.txt +++ b/Documentation/git-fast-export.txt @@ -82,6 +82,12 @@ marks the same across runs. allow that. So fake a tagger to be able to fast-import the output. +[git-rev-list-args...]:: + A list of arguments, acceptable to 'git-rev-parse' and + 'git-rev-list', that specifies the specific objects and references + to export. For example, `master\~10..master` causes the + current master reference to be exported along with all objects + added since its 10th ancestor commit. EXAMPLES -------- From 650d30d8a120c8982309ccb9ef40432b4ea2eb74 Mon Sep 17 00:00:00 2001 From: Andreas Ericsson Date: Mon, 29 Jun 2009 11:55:51 +0200 Subject: [PATCH 08/95] mailinfo: Remove only one set of square brackets git-format-patch prepends patches with a [PATCH x/n] prefix, but mailinfo used to remove any number of square-bracket pairs and the content between them. This prevents one from using a commit subject like this: [ and ] must be allowed as input Removing the square bracket pair from this rather clumsily constructed subject line loses important information, so we must take care not to. This patch causes the subject stripping to stop after it has encountered one pair of square brackets. One possible downside of this patch is that the patch-handling programs will now fail at removing author-added square-brackets to be removed, such as [RFC][PATCH x/n] However, since format-patch only adds one set of square brackets, this behaviour is quite easily undesrstood and defended while the previous behaviour is not. Signed-off-by: Andreas Ericsson Signed-off-by: Junio C Hamano --- builtin-mailinfo.c | 7 +++++++ t/t5100/info0012 | 2 +- t/t5100/sample.mbox | 2 +- 3 files changed, 9 insertions(+), 2 deletions(-) diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index 1eeeb4de6d..be42532d43 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -222,6 +222,8 @@ static void cleanup_subject(struct strbuf *subject) { char *pos; size_t remove; + int brackets_removed = 0; + while (subject->len) { switch (*subject->buf) { case 'r': case 'R': @@ -236,10 +238,15 @@ static void cleanup_subject(struct strbuf *subject) strbuf_remove(subject, 0, 1); continue; case '[': + /* remove only one set of square brackets */ + if (brackets_removed) + break; + if ((pos = strchr(subject->buf, ']'))) { remove = pos - subject->buf; if (remove <= (subject->len - remove) * 2) { strbuf_remove(subject, 0, remove + 1); + brackets_removed = 1; continue; } } else diff --git a/t/t5100/info0012 b/t/t5100/info0012 index ac1216ff75..9cd1415d25 100644 --- a/t/t5100/info0012 +++ b/t/t5100/info0012 @@ -1,5 +1,5 @@ Author: Dmitriy Blinov Email: bda@mnsspb.ru -Subject: Изменён список пакетов необходимых для сборки +Subject: [Navy-patches] Изменён список пакетов необходимых для сборки Date: Wed, 12 Nov 2008 17:54:41 +0300 diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index c5ad206b40..ba4d0c9baf 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -514,7 +514,7 @@ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit -Subject: [Navy-patches] [PATCH] +Subject: [PATCH] [Navy-patches] =?utf-8?b?0JjQt9C80LXQvdGR0L0g0YHQv9C40YHQvtC6INC/0LA=?= =?utf-8?b?0LrQtdGC0L7QsiDQvdC10L7QsdGF0L7QtNC40LzRi9GFINC00LvRjyA=?= =?utf-8?b?0YHQsdC+0YDQutC4?= From 1d8842d921cc2695f155f4a10904eeffad085c77 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 14 May 2009 13:22:36 -0700 Subject: [PATCH 09/95] Add 'fill_directory()' helper function for directory traversal Most of the users of "read_directory()" actually want a much simpler interface than the whole complex (but rather powerful) one. In fact 'git add' had already largely abstracted out the core interface issues into a private "fill_directory()" function that was largely applicable almost as-is to a number of callers. Yes, 'git add' wants to do some extra work of its own, specific to the add semantics, but we can easily split that out, and use the core as a generic function. This function does exactly that, and now that much simplified 'fill_directory()' function can be shared with a number of callers, while also ensuring that the rather more complex calling conventions of read_directory() are used by fewer call-sites. This also makes the 'common_prefix()' helper function private to dir.c, since all callers are now in that file. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- builtin-add.c | 45 ++++++++++++++------------------------------- builtin-clean.c | 12 +----------- builtin-ls-files.c | 7 +------ dir.c | 23 ++++++++++++++++++++++- dir.h | 3 +-- wt-status.c | 2 +- 6 files changed, 40 insertions(+), 52 deletions(-) diff --git a/builtin-add.c b/builtin-add.c index 78989dad8c..581a2a1748 100644 --- a/builtin-add.c +++ b/builtin-add.c @@ -97,35 +97,6 @@ static void treat_gitlinks(const char **pathspec) } } -static void fill_directory(struct dir_struct *dir, const char **pathspec, - int ignored_too) -{ - const char *path, *base; - int baselen; - - /* Set up the default git porcelain excludes */ - memset(dir, 0, sizeof(*dir)); - if (!ignored_too) { - dir->flags |= DIR_COLLECT_IGNORED; - setup_standard_excludes(dir); - } - - /* - * Calculate common prefix for the pathspec, and - * use that to optimize the directory walk - */ - baselen = common_prefix(pathspec); - path = "."; - base = ""; - if (baselen) - path = base = xmemdupz(*pathspec, baselen); - - /* Read the directory and prune it */ - read_directory(dir, path, base, baselen, pathspec); - if (pathspec) - prune_directory(dir, pathspec, baselen); -} - static void refresh(int verbose, const char **pathspec) { char *seen; @@ -343,9 +314,21 @@ int cmd_add(int argc, const char **argv, const char *prefix) die("index file corrupt"); treat_gitlinks(pathspec); - if (add_new_files) + if (add_new_files) { + int baselen; + + /* Set up the default git porcelain excludes */ + memset(&dir, 0, sizeof(dir)); + if (!ignored_too) { + dir.flags |= DIR_COLLECT_IGNORED; + setup_standard_excludes(&dir); + } + /* This picks up the paths that are not tracked */ - fill_directory(&dir, pathspec, ignored_too); + baselen = fill_directory(&dir, pathspec); + if (pathspec) + prune_directory(&dir, pathspec, baselen); + } if (refresh_only) { refresh(verbose, pathspec); diff --git a/builtin-clean.c b/builtin-clean.c index 1c1b6d26e9..2d8c735d48 100644 --- a/builtin-clean.c +++ b/builtin-clean.c @@ -33,7 +33,6 @@ int cmd_clean(int argc, const char **argv, const char *prefix) int ignored_only = 0, baselen = 0, config_set = 0, errors = 0; struct strbuf directory = STRBUF_INIT; struct dir_struct dir; - const char *path, *base; static const char **pathspec; struct strbuf buf = STRBUF_INIT; const char *qname; @@ -78,16 +77,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) pathspec = get_pathspec(prefix, argv); read_cache(); - /* - * Calculate common prefix for the pathspec, and - * use that to optimize the directory walk - */ - baselen = common_prefix(pathspec); - path = "."; - base = ""; - if (baselen) - path = base = xmemdupz(*pathspec, baselen); - read_directory(&dir, path, base, baselen, pathspec); + fill_directory(&dir, pathspec); if (pathspec) seen = xmalloc(argc > 0 ? argc : 1); diff --git a/builtin-ls-files.c b/builtin-ls-files.c index 2312866605..f473220502 100644 --- a/builtin-ls-files.c +++ b/builtin-ls-files.c @@ -161,12 +161,7 @@ static void show_files(struct dir_struct *dir, const char *prefix) /* For cached/deleted files we don't need to even do the readdir */ if (show_others || show_killed) { - const char *path = ".", *base = ""; - int baselen = prefix_len; - - if (baselen) - path = base = prefix; - read_directory(dir, path, base, baselen, pathspec); + fill_directory(dir, pathspec); if (show_others) show_other_files(dir); if (show_killed) diff --git a/dir.c b/dir.c index 74b3bbf6fd..0c8553b27c 100644 --- a/dir.c +++ b/dir.c @@ -19,7 +19,7 @@ static int read_directory_recursive(struct dir_struct *dir, int check_only, const struct path_simplify *simplify); static int get_dtype(struct dirent *de, const char *path); -int common_prefix(const char **pathspec) +static int common_prefix(const char **pathspec) { const char *path, *slash, *next; int prefix; @@ -52,6 +52,27 @@ int common_prefix(const char **pathspec) return prefix; } +int fill_directory(struct dir_struct *dir, const char **pathspec) +{ + const char *path, *base; + int baselen; + + /* + * Calculate common prefix for the pathspec, and + * use that to optimize the directory walk + */ + baselen = common_prefix(pathspec); + path = ""; + base = ""; + + if (baselen) + path = base = xmemdupz(*pathspec, baselen); + + /* Read the directory and prune it */ + read_directory(dir, path, base, baselen, pathspec); + return baselen; +} + /* * Does 'match' match the given name? * A match is found if diff --git a/dir.h b/dir.h index 541286ad1d..f9d69dd15f 100644 --- a/dir.h +++ b/dir.h @@ -61,13 +61,12 @@ struct dir_struct { char basebuf[PATH_MAX]; }; -extern int common_prefix(const char **pathspec); - #define MATCHED_RECURSIVELY 1 #define MATCHED_FNMATCH 2 #define MATCHED_EXACTLY 3 extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen); +extern int fill_directory(struct dir_struct *dir, const char **pathspec); extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen, const char **pathspec); extern int excluded(struct dir_struct *, const char *, int *); diff --git a/wt-status.c b/wt-status.c index 0ca4b13c29..47735d8129 100644 --- a/wt-status.c +++ b/wt-status.c @@ -255,7 +255,7 @@ static void wt_status_print_untracked(struct wt_status *s) DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; setup_standard_excludes(&dir); - read_directory(&dir, ".", "", 0, NULL); + fill_directory(&dir, NULL); for(i = 0; i < dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; if (!cache_name_is_other(ent->name, ent->len)) From dba2e2037f40685bffc87d3e7114a02c5bda1eff Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 8 Jul 2009 19:24:39 -0700 Subject: [PATCH 10/95] Simplify read_directory[_recursive]() arguments Stop the insanity with separate 'path' and 'base' arguments that must match. We don't need that crazy interface any more, since we cleaned up handling of 'path' in commit da4b3e8c28b1dc2b856d2555ac7bb47ab712598c. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- dir.c | 57 +++++++++++++++++++++++++------------------------- dir.h | 2 +- unpack-trees.c | 2 +- 3 files changed, 30 insertions(+), 31 deletions(-) diff --git a/dir.c b/dir.c index 0c8553b27c..b0671f59c8 100644 --- a/dir.c +++ b/dir.c @@ -14,8 +14,7 @@ struct path_simplify { const char *path; }; -static int read_directory_recursive(struct dir_struct *dir, - const char *path, const char *base, int baselen, +static int read_directory_recursive(struct dir_struct *dir, const char *path, int len, int check_only, const struct path_simplify *simplify); static int get_dtype(struct dirent *de, const char *path); @@ -54,23 +53,22 @@ static int common_prefix(const char **pathspec) int fill_directory(struct dir_struct *dir, const char **pathspec) { - const char *path, *base; - int baselen; + const char *path; + int len; /* * Calculate common prefix for the pathspec, and * use that to optimize the directory walk */ - baselen = common_prefix(pathspec); + len = common_prefix(pathspec); path = ""; - base = ""; - if (baselen) - path = base = xmemdupz(*pathspec, baselen); + if (len) + path = xmemdupz(*pathspec, len); /* Read the directory and prune it */ - read_directory(dir, path, base, baselen, pathspec); - return baselen; + read_directory(dir, path, len, pathspec); + return len; } /* @@ -526,7 +524,7 @@ static enum directory_treatment treat_directory(struct dir_struct *dir, /* This is the "show_other_directories" case */ if (!(dir->flags & DIR_HIDE_EMPTY_DIRECTORIES)) return show_directory; - if (!read_directory_recursive(dir, dirname, dirname, len, 1, simplify)) + if (!read_directory_recursive(dir, dirname, len, 1, simplify)) return ignore_directory; return show_directory; } @@ -595,15 +593,15 @@ static int get_dtype(struct dirent *de, const char *path) * Also, we ignore the name ".git" (even if it is not a directory). * That likely will not change. */ -static int read_directory_recursive(struct dir_struct *dir, const char *path, const char *base, int baselen, int check_only, const struct path_simplify *simplify) +static int read_directory_recursive(struct dir_struct *dir, const char *base, int baselen, int check_only, const struct path_simplify *simplify) { - DIR *fdir = opendir(*path ? path : "."); + DIR *fdir = opendir(*base ? base : "."); int contents = 0; if (fdir) { struct dirent *de; - char fullname[PATH_MAX + 1]; - memcpy(fullname, base, baselen); + char path[PATH_MAX + 1]; + memcpy(path, base, baselen); while ((de = readdir(fdir)) != NULL) { int len, dtype; @@ -614,17 +612,18 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co continue; len = strlen(de->d_name); /* Ignore overly long pathnames! */ - if (len + baselen + 8 > sizeof(fullname)) + if (len + baselen + 8 > sizeof(path)) continue; - memcpy(fullname + baselen, de->d_name, len+1); - if (simplify_away(fullname, baselen + len, simplify)) + memcpy(path + baselen, de->d_name, len+1); + len = baselen + len; + if (simplify_away(path, len, simplify)) continue; dtype = DTYPE(de); - exclude = excluded(dir, fullname, &dtype); + exclude = excluded(dir, path, &dtype); if (exclude && (dir->flags & DIR_COLLECT_IGNORED) - && in_pathspec(fullname, baselen + len, simplify)) - dir_add_ignored(dir, fullname, baselen + len); + && in_pathspec(path, len, simplify)) + dir_add_ignored(dir, path,len); /* * Excluded? If we don't explicitly want to show @@ -634,7 +633,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co continue; if (dtype == DT_UNKNOWN) - dtype = get_dtype(de, fullname); + dtype = get_dtype(de, path); /* * Do we want to see just the ignored files? @@ -651,9 +650,9 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co default: continue; case DT_DIR: - memcpy(fullname + baselen + len, "/", 2); + memcpy(path + len, "/", 2); len++; - switch (treat_directory(dir, fullname, baselen + len, simplify)) { + switch (treat_directory(dir, path, len, simplify)) { case show_directory: if (exclude != !!(dir->flags & DIR_SHOW_IGNORED)) @@ -661,7 +660,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co break; case recurse_into_directory: contents += read_directory_recursive(dir, - fullname, fullname, baselen + len, 0, simplify); + path, len, 0, simplify); continue; case ignore_directory: continue; @@ -675,7 +674,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *path, co if (check_only) goto exit_early; else - dir_add_name(dir, fullname, baselen + len); + dir_add_name(dir, path, len); } exit_early: closedir(fdir); @@ -738,15 +737,15 @@ static void free_simplify(struct path_simplify *simplify) free(simplify); } -int read_directory(struct dir_struct *dir, const char *path, const char *base, int baselen, const char **pathspec) +int read_directory(struct dir_struct *dir, const char *path, int len, const char **pathspec) { struct path_simplify *simplify; - if (has_symlink_leading_path(path, strlen(path))) + if (has_symlink_leading_path(path, len)) return dir->nr; simplify = create_simplify(pathspec); - read_directory_recursive(dir, path, base, baselen, 0, simplify); + read_directory_recursive(dir, path, len, 0, simplify); free_simplify(simplify); qsort(dir->entries, dir->nr, sizeof(struct dir_entry *), cmp_name); qsort(dir->ignored, dir->ignored_nr, sizeof(struct dir_entry *), cmp_name); diff --git a/dir.h b/dir.h index f9d69dd15f..a6314464f9 100644 --- a/dir.h +++ b/dir.h @@ -67,7 +67,7 @@ struct dir_struct { extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen); extern int fill_directory(struct dir_struct *dir, const char **pathspec); -extern int read_directory(struct dir_struct *, const char *path, const char *base, int baselen, const char **pathspec); +extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec); extern int excluded(struct dir_struct *, const char *, int *); extern void add_excludes_from_file(struct dir_struct *, const char *fname); diff --git a/unpack-trees.c b/unpack-trees.c index 05d0bb1f85..42c7d7d563 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -551,7 +551,7 @@ static int verify_clean_subdirectory(struct cache_entry *ce, const char *action, memset(&d, 0, sizeof(d)); if (o->dir) d.exclude_per_dir = o->dir->exclude_per_dir; - i = read_directory(&d, ce->name, pathbuf, namelen+1, NULL); + i = read_directory(&d, pathbuf, namelen+1, NULL); if (i) return o->gently ? -1 : error(ERRORMSG(o, not_uptodate_dir), ce->name); From caa6b7825aaddb8a97a5b793ca61df0c1ec9b76b Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Wed, 8 Jul 2009 19:31:49 -0700 Subject: [PATCH 11/95] Avoid doing extra 'lstat()'s for d_type if we have an up-to-date cache entry On filesystems without d_type, we can look at the cache entry first. Doing an lstat() can be expensive. Reported by Dmitry Potapov for Cygwin. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- dir.c | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/dir.c b/dir.c index b0671f59c8..8a9e7d8131 100644 --- a/dir.c +++ b/dir.c @@ -16,7 +16,7 @@ struct path_simplify { static int read_directory_recursive(struct dir_struct *dir, const char *path, int len, int check_only, const struct path_simplify *simplify); -static int get_dtype(struct dirent *de, const char *path); +static int get_dtype(struct dirent *de, const char *path, int len); static int common_prefix(const char **pathspec) { @@ -326,7 +326,7 @@ static int excluded_1(const char *pathname, if (x->flags & EXC_FLAG_MUSTBEDIR) { if (*dtype == DT_UNKNOWN) - *dtype = get_dtype(NULL, pathname); + *dtype = get_dtype(NULL, pathname, pathlen); if (*dtype != DT_DIR) continue; } @@ -566,14 +566,18 @@ static int in_pathspec(const char *path, int len, const struct path_simplify *si return 0; } -static int get_dtype(struct dirent *de, const char *path) +static int get_dtype(struct dirent *de, const char *path, int len) { int dtype = de ? DTYPE(de) : DT_UNKNOWN; + struct cache_entry *ce; struct stat st; if (dtype != DT_UNKNOWN) return dtype; - if (lstat(path, &st)) + ce = cache_name_exists(path, len, 0); + if (ce && ce_uptodate(ce)) + st.st_mode = ce->ce_mode; + else if (lstat(path, &st)) return dtype; if (S_ISREG(st.st_mode)) return DT_REG; @@ -633,7 +637,7 @@ static int read_directory_recursive(struct dir_struct *dir, const char *base, in continue; if (dtype == DT_UNKNOWN) - dtype = get_dtype(de, path); + dtype = get_dtype(de, path, len); /* * Do we want to see just the ignored files? From 443e061a41bee30de34793648793ed70477ac575 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 9 Jul 2009 13:14:28 -0700 Subject: [PATCH 12/95] Avoid using 'lstat()' to figure out directories If we have an up-to-date index entry for a file in that directory, we can know that the directories leading up to that file must be directories. No need to do an lstat() on the directory. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- dir.c | 47 ++++++++++++++++++++++++++++++++++++++++++----- 1 file changed, 42 insertions(+), 5 deletions(-) diff --git a/dir.c b/dir.c index 8a9e7d8131..e05b850acf 100644 --- a/dir.c +++ b/dir.c @@ -566,18 +566,55 @@ static int in_pathspec(const char *path, int len, const struct path_simplify *si return 0; } +static int get_index_dtype(const char *path, int len) +{ + int pos; + struct cache_entry *ce; + + ce = cache_name_exists(path, len, 0); + if (ce) { + if (!ce_uptodate(ce)) + return DT_UNKNOWN; + if (S_ISGITLINK(ce->ce_mode)) + return DT_DIR; + /* + * Nobody actually cares about the + * difference between DT_LNK and DT_REG + */ + return DT_REG; + } + + /* Try to look it up as a directory */ + pos = cache_name_pos(path, len); + if (pos >= 0) + return DT_UNKNOWN; + pos = -pos-1; + while (pos < active_nr) { + ce = active_cache[pos++]; + if (strncmp(ce->name, path, len)) + break; + if (ce->name[len] > '/') + break; + if (ce->name[len] < '/') + continue; + if (!ce_uptodate(ce)) + break; /* continue? */ + return DT_DIR; + } + return DT_UNKNOWN; +} + static int get_dtype(struct dirent *de, const char *path, int len) { int dtype = de ? DTYPE(de) : DT_UNKNOWN; - struct cache_entry *ce; struct stat st; if (dtype != DT_UNKNOWN) return dtype; - ce = cache_name_exists(path, len, 0); - if (ce && ce_uptodate(ce)) - st.st_mode = ce->ce_mode; - else if (lstat(path, &st)) + dtype = get_index_dtype(path, len); + if (dtype != DT_UNKNOWN) + return dtype; + if (lstat(path, &st)) return dtype; if (S_ISREG(st.st_mode)) return DT_REG; From 867f72bf434a05b9eadf851a81564be5173fbba5 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 9 Jul 2009 13:23:59 -0700 Subject: [PATCH 13/95] Prepare symlink caching for thread-safety This doesn't actually change the external interfaces, so they are still thread-unsafe, but it makes the code internally pass a pointer to a local 'struct cache_def' around, so that the core code can be made thread-safe. The threaded index preloading will want to verify that the paths leading up to a pathname are all real directories. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- symlinks.c | 75 +++++++++++++++++++++++++++++------------------------- 1 file changed, 40 insertions(+), 35 deletions(-) diff --git a/symlinks.c b/symlinks.c index 8dcd63261f..08ad35330f 100644 --- a/symlinks.c +++ b/symlinks.c @@ -38,13 +38,13 @@ static struct cache_def { int flags; int track_flags; int prefix_len_stat_func; -} cache; +} default_cache; -static inline void reset_lstat_cache(void) +static inline void reset_lstat_cache(struct cache_def *cache) { - cache.path[0] = '\0'; - cache.len = 0; - cache.flags = 0; + cache->path[0] = '\0'; + cache->len = 0; + cache->flags = 0; /* * The track_flags and prefix_len_stat_func members is only * set by the safeguard rule inside lstat_cache() @@ -70,23 +70,23 @@ static inline void reset_lstat_cache(void) * of the prefix, where the cache should use the stat() function * instead of the lstat() function to test each path component. */ -static int lstat_cache(const char *name, int len, +static int lstat_cache(struct cache_def *cache, const char *name, int len, int track_flags, int prefix_len_stat_func) { int match_len, last_slash, last_slash_dir, previous_slash; int match_flags, ret_flags, save_flags, max_len, ret; struct stat st; - if (cache.track_flags != track_flags || - cache.prefix_len_stat_func != prefix_len_stat_func) { + if (cache->track_flags != track_flags || + cache->prefix_len_stat_func != prefix_len_stat_func) { /* * As a safeguard rule we clear the cache if the * values of track_flags and/or prefix_len_stat_func * does not match with the last supplied values. */ - reset_lstat_cache(); - cache.track_flags = track_flags; - cache.prefix_len_stat_func = prefix_len_stat_func; + reset_lstat_cache(cache); + cache->track_flags = track_flags; + cache->prefix_len_stat_func = prefix_len_stat_func; match_len = last_slash = 0; } else { /* @@ -94,10 +94,10 @@ static int lstat_cache(const char *name, int len, * the 2 "excluding" path types. */ match_len = last_slash = - longest_path_match(name, len, cache.path, cache.len, + longest_path_match(name, len, cache->path, cache->len, &previous_slash); - match_flags = cache.flags & track_flags & (FL_NOENT|FL_SYMLINK); - if (match_flags && match_len == cache.len) + match_flags = cache->flags & track_flags & (FL_NOENT|FL_SYMLINK); + if (match_flags && match_len == cache->len) return match_flags; /* * If we now have match_len > 0, we would know that @@ -121,18 +121,18 @@ static int lstat_cache(const char *name, int len, max_len = len < PATH_MAX ? len : PATH_MAX; while (match_len < max_len) { do { - cache.path[match_len] = name[match_len]; + cache->path[match_len] = name[match_len]; match_len++; } while (match_len < max_len && name[match_len] != '/'); if (match_len >= max_len && !(track_flags & FL_FULLPATH)) break; last_slash = match_len; - cache.path[last_slash] = '\0'; + cache->path[last_slash] = '\0'; if (last_slash <= prefix_len_stat_func) - ret = stat(cache.path, &st); + ret = stat(cache->path, &st); else - ret = lstat(cache.path, &st); + ret = lstat(cache->path, &st); if (ret) { ret_flags = FL_LSTATERR; @@ -156,9 +156,9 @@ static int lstat_cache(const char *name, int len, */ save_flags = ret_flags & track_flags & (FL_NOENT|FL_SYMLINK); if (save_flags && last_slash > 0 && last_slash <= PATH_MAX) { - cache.path[last_slash] = '\0'; - cache.len = last_slash; - cache.flags = save_flags; + cache->path[last_slash] = '\0'; + cache->len = last_slash; + cache->flags = save_flags; } else if ((track_flags & FL_DIR) && last_slash_dir > 0 && last_slash_dir <= PATH_MAX) { /* @@ -172,11 +172,11 @@ static int lstat_cache(const char *name, int len, * can still cache the path components before the last * one (the found symlink or non-existing component). */ - cache.path[last_slash_dir] = '\0'; - cache.len = last_slash_dir; - cache.flags = FL_DIR; + cache->path[last_slash_dir] = '\0'; + cache->len = last_slash_dir; + cache->flags = FL_DIR; } else { - reset_lstat_cache(); + reset_lstat_cache(cache); } return ret_flags; } @@ -188,16 +188,17 @@ static int lstat_cache(const char *name, int len, void invalidate_lstat_cache(const char *name, int len) { int match_len, previous_slash; + struct cache_def *cache = &default_cache; /* FIXME */ - match_len = longest_path_match(name, len, cache.path, cache.len, + match_len = longest_path_match(name, len, cache->path, cache->len, &previous_slash); if (len == match_len) { - if ((cache.track_flags & FL_DIR) && previous_slash > 0) { - cache.path[previous_slash] = '\0'; - cache.len = previous_slash; - cache.flags = FL_DIR; + if ((cache->track_flags & FL_DIR) && previous_slash > 0) { + cache->path[previous_slash] = '\0'; + cache->len = previous_slash; + cache->flags = FL_DIR; } else { - reset_lstat_cache(); + reset_lstat_cache(cache); } } } @@ -207,7 +208,8 @@ void invalidate_lstat_cache(const char *name, int len) */ void clear_lstat_cache(void) { - reset_lstat_cache(); + struct cache_def *cache = &default_cache; /* FIXME */ + reset_lstat_cache(cache); } #define USE_ONLY_LSTAT 0 @@ -217,7 +219,8 @@ void clear_lstat_cache(void) */ int has_symlink_leading_path(const char *name, int len) { - return lstat_cache(name, len, + struct cache_def *cache = &default_cache; /* FIXME */ + return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK; } @@ -228,7 +231,8 @@ int has_symlink_leading_path(const char *name, int len) */ int has_symlink_or_noent_leading_path(const char *name, int len) { - return lstat_cache(name, len, + struct cache_def *cache = &default_cache; /* FIXME */ + return lstat_cache(cache, name, len, FL_SYMLINK|FL_NOENT|FL_DIR, USE_ONLY_LSTAT) & (FL_SYMLINK|FL_NOENT); } @@ -242,7 +246,8 @@ int has_symlink_or_noent_leading_path(const char *name, int len) */ int has_dirs_only_path(const char *name, int len, int prefix_len) { - return lstat_cache(name, len, + struct cache_def *cache = &default_cache; /* FIXME */ + return lstat_cache(cache, name, len, FL_DIR|FL_FULLPATH, prefix_len) & FL_DIR; } From b9fd284657de3ec30922fb17c0baf243ae947fdd Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 9 Jul 2009 13:35:31 -0700 Subject: [PATCH 14/95] Export thread-safe version of 'has_symlink_leading_path()' The threaded index preloading will want it, so that it can avoid locking by simply using a per-thread symlink/directory cache. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- cache.h | 10 ++++++++++ symlinks.c | 21 ++++++++++----------- 2 files changed, 20 insertions(+), 11 deletions(-) diff --git a/cache.h b/cache.h index 871c9844e8..f1e5ede021 100644 --- a/cache.h +++ b/cache.h @@ -744,7 +744,17 @@ struct checkout { }; extern int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *topath); + +struct cache_def { + char path[PATH_MAX + 1]; + int len; + int flags; + int track_flags; + int prefix_len_stat_func; +}; + extern int has_symlink_leading_path(const char *name, int len); +extern int threaded_has_symlink_leading_path(struct cache_def *, const char *, int); extern int has_symlink_or_noent_leading_path(const char *name, int len); extern int has_dirs_only_path(const char *name, int len, int prefix_len); extern void invalidate_lstat_cache(const char *name, int len); diff --git a/symlinks.c b/symlinks.c index 08ad35330f..4bdded39c5 100644 --- a/symlinks.c +++ b/symlinks.c @@ -32,13 +32,7 @@ static int longest_path_match(const char *name_a, int len_a, return match_len; } -static struct cache_def { - char path[PATH_MAX + 1]; - int len; - int flags; - int track_flags; - int prefix_len_stat_func; -} default_cache; +static struct cache_def default_cache; static inline void reset_lstat_cache(struct cache_def *cache) { @@ -214,15 +208,20 @@ void clear_lstat_cache(void) #define USE_ONLY_LSTAT 0 +/* + * Return non-zero if path 'name' has a leading symlink component + */ +int threaded_has_symlink_leading_path(struct cache_def *cache, const char *name, int len) +{ + return lstat_cache(cache, name, len, FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & FL_SYMLINK; +} + /* * Return non-zero if path 'name' has a leading symlink component */ int has_symlink_leading_path(const char *name, int len) { - struct cache_def *cache = &default_cache; /* FIXME */ - return lstat_cache(cache, name, len, - FL_SYMLINK|FL_DIR, USE_ONLY_LSTAT) & - FL_SYMLINK; + return threaded_has_symlink_leading_path(&default_cache, name, len); } /* From f62ce3de9dd4803f50f65e17f5fc03c7bdb49c40 Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Thu, 9 Jul 2009 13:37:02 -0700 Subject: [PATCH 15/95] Make index preloading check the whole path to the file This uses the new thread-safe 'threaded_has_symlink_leading_path()' function to efficiently verify that the whole path leading up to the filename is a proper path, and does not contain symlinks. This makes 'ce_uptodate()' a much stronger guarantee: it no longer just guarantees that the 'lstat()' of the path would match, it also means that we know that people haven't played games with moving directories around and covered it up with symlinks. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- preload-index.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/preload-index.c b/preload-index.c index 88edc5f8a9..14d5281183 100644 --- a/preload-index.c +++ b/preload-index.c @@ -34,7 +34,9 @@ static void *preload_thread(void *_data) struct thread_data *p = _data; struct index_state *index = p->index; struct cache_entry **cep = index->cache + p->offset; + struct cache_def cache; + memset(&cache, 0, sizeof(cache)); nr = p->nr; if (nr + p->offset > index->cache_nr) nr = index->cache_nr - p->offset; @@ -49,6 +51,8 @@ static void *preload_thread(void *_data) continue; if (!ce_path_match(ce, p->pathspec)) continue; + if (threaded_has_symlink_leading_path(&cache, ce->name, ce_namelen(ce))) + continue; if (lstat(ce->name, &st)) continue; if (ie_match_stat(index, ce, &st, CE_MATCH_RACY_IS_DIRTY)) From 6edd14968bf969a651d057ea7fb7757393d282bf Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Fri, 10 Jul 2009 20:17:33 -0700 Subject: [PATCH 16/95] Makefile: keep "git" when bindir is execdir For some reason there still are people who use the old style layout to put everything in $(bindir). The previous commit breaks the install for them, because it tries to unconditionally remove git from execdir and cp/ln from bindir --- oops. Signed-off-by: Junio C Hamano --- Makefile | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/Makefile b/Makefile index 311ce7d745..4be508e877 100644 --- a/Makefile +++ b/Makefile @@ -1641,10 +1641,11 @@ ifneq (,$X) endif bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \ execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \ - { $(RM) "$$execdir/git$X" && \ + { test "$$bindir/" = "$$execdir/" || \ + { $(RM) "$$execdir/git$X" && \ test -z "$(NO_CROSS_DIRECTORY_HARDLINKS)" && \ ln "$$bindir/git$X" "$$execdir/git$X" 2>/dev/null || \ - cp "$$bindir/git$X" "$$execdir/git$X"; } && \ + cp "$$bindir/git$X" "$$execdir/git$X"; } ; } && \ { for p in $(BUILT_INS); do \ $(RM) "$$execdir/$$p" && \ ln "$$execdir/git$X" "$$execdir/$$p" 2>/dev/null || \ From 0039ba7e5e630502be9ac601845b214abce93750 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 10 Jul 2009 12:10:43 -0500 Subject: [PATCH 17/95] unpack-trees.c: work around run-time array initialization flaw on IRIX 6.5 The c99 MIPSpro Compiler version 7.4.4m on IRIX 6.5 does not properly initialize run-time initialized arrays. An array which is initialized with fewer elements than the length of the array should have the unitialized elements initialized to zero. This compiler only initializes the remaining elements when the last element is a static parameter. So work around it by adding a "NULL" initialization parameter. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- unpack-trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpack-trees.c b/unpack-trees.c index 42c7d7d563..f9d12aafba 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -128,7 +128,7 @@ static inline int call_unpack_fn(struct cache_entry **src, struct unpack_trees_o static int unpack_index_entry(struct cache_entry *ce, struct unpack_trees_options *o) { - struct cache_entry *src[5] = { ce, }; + struct cache_entry *src[5] = { ce, NULL, }; o->pos++; if (ce_stage(ce)) { From 9398b85994ee7d602e29e0b82de01b9605ee535f Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 10 Jul 2009 12:10:44 -0500 Subject: [PATCH 18/95] git-compat-util.h: adjust for SGI IRIX 6.5 Don't define _XOPEN_SOURCE Do define _SGI_SOURCE Defining _XOPEN_SOURCE prevents many of the common functions and macros from being defined. _Not_ setting _XOPEN_SOURCE, and instead setting _SGI_SOURCE, provides all of the XPG4, XPG5, BSD, POSIX functions and declarations, _BUT_ provides a horribly broken snprintf(). SGI does have a working snprintf(), but it is only provided when _NO_XOPEN5 evaluates to zero, and this only happens if _XOPEN_SOURCE is defined which, as mentioned above, prevents many other common functions and defines. The broken snprintf will be worked around with SNPRINTF_RETURNS_BOGUS in the Makefile in a later patch. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- git-compat-util.h | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/git-compat-util.h b/git-compat-util.h index 9609eaa77f..913f41a42c 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -52,7 +52,7 @@ # else # define _XOPEN_SOURCE 500 # endif -#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) +#elif !defined(__APPLE__) && !defined(__FreeBSD__) && !defined(__USLC__) && !defined(_M_UNIX) && !defined(sgi) #define _XOPEN_SOURCE 600 /* glibc2 and AIX 5.3L need 500, OpenBSD needs 600 for S_ISLNK() */ #ifndef __sun__ #define _XOPEN_SOURCE_EXTENDED 1 /* AIX 5.3L needs this */ @@ -62,6 +62,7 @@ #define _GNU_SOURCE 1 #define _BSD_SOURCE 1 #define _NETBSD_SOURCE 1 +#define _SGI_SOURCE 1 #include #include From ecc395c112b45b00df6c8b1e8d665123c1a28bca Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 10 Jul 2009 12:10:45 -0500 Subject: [PATCH 19/95] Makefile: add NEEDS_LIBGEN to optionally add -lgen to compile arguments Commit 003b33a8 recently added a call to basename(). On IRIX 6.5, this function resides in libgen and -lgen is required for the linker. Update configure.ac too. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- Makefile | 5 +++++ configure.ac | 6 ++++++ 2 files changed, 11 insertions(+) diff --git a/Makefile b/Makefile index 4be508e877..6d1a38fde1 100644 --- a/Makefile +++ b/Makefile @@ -61,6 +61,8 @@ all:: # # Define NO_LIBGEN_H if you don't have libgen.h. # +# Define NEEDS_LIBGEN if your libgen needs -lgen when linking +# # Define NO_SYS_SELECT_H if you don't have sys/select.h. # # Define NO_SYMLINK_HEAD if you never want .git/HEAD to be a symbolic link. @@ -1019,6 +1021,9 @@ ifdef NEEDS_LIBICONV endif EXTLIBS += $(ICONV_LINK) -liconv endif +ifdef NEEDS_LIBGEN + EXTLIBS += -lgen +endif ifdef NEEDS_SOCKET EXTLIBS += -lsocket endif diff --git a/configure.ac b/configure.ac index 1885674e39..74d0af52a5 100644 --- a/configure.ac +++ b/configure.ac @@ -485,6 +485,12 @@ AC_CHECK_LIB([resolv], [hstrerror], AC_SUBST(NEEDS_RESOLV) test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv" +AC_CHECK_LIB([gen], [basename], +[NEEDS_LIBGEN=], +[NEEDS_LIBGEN=YesPlease]) +AC_SUBST(NEEDS_LIBGEN) +test -n "$NEEDS_LIBGEN" && LIBS="$LIBS -lgen" + ## Checks for header files. AC_MSG_NOTICE([CHECKS for header files]) # From 1fdffc1bd8865fc07107d021d2fce7cd707b9b84 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 10 Jul 2009 12:10:46 -0500 Subject: [PATCH 20/95] Makefile: add section for SGI IRIX 6.5 Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- Makefile | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/Makefile b/Makefile index 6d1a38fde1..ec24632259 100644 --- a/Makefile +++ b/Makefile @@ -830,6 +830,19 @@ ifeq ($(uname_S),GNU) NO_STRLCPY=YesPlease NO_MKSTEMPS = YesPlease endif +ifeq ($(uname_S),IRIX) + NO_SETENV = YesPlease + NO_UNSETENV = YesPlease + NO_STRCASESTR = YesPlease + NO_MEMMEM = YesPlease + NO_MKSTEMPS = YesPlease + NO_MKDTEMP = YesPlease + NO_MMAP = YesPlease + NO_EXTERNAL_GREP = UnfortunatelyYes + SNPRINTF_RETURNS_BOGUS = YesPlease + SHELL_PATH = /usr/gnu/bin/bash + NEEDS_LIBGEN = YesPlease +endif ifeq ($(uname_S),IRIX64) NO_IPV6=YesPlease NO_SETENV=YesPlease From 7c74ff50626faca2fd302d83610494dd9106896d Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Fri, 10 Jul 2009 13:31:19 -0500 Subject: [PATCH 21/95] Makefile: update IRIX64 section Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- Makefile | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/Makefile b/Makefile index ec24632259..bde27ed478 100644 --- a/Makefile +++ b/Makefile @@ -844,17 +844,17 @@ ifeq ($(uname_S),IRIX) NEEDS_LIBGEN = YesPlease endif ifeq ($(uname_S),IRIX64) - NO_IPV6=YesPlease NO_SETENV=YesPlease + NO_UNSETENV = YesPlease NO_STRCASESTR=YesPlease NO_MEMMEM = YesPlease NO_MKSTEMPS = YesPlease - NO_STRLCPY = YesPlease - NO_SOCKADDR_STORAGE=YesPlease + NO_MKDTEMP = YesPlease + NO_MMAP = YesPlease + NO_EXTERNAL_GREP = UnfortunatelyYes + SNPRINTF_RETURNS_BOGUS = YesPlease SHELL_PATH=/usr/gnu/bin/bash - BASIC_CFLAGS += -DPATH_MAX=1024 - # for now, build 32-bit version - BASIC_LDFLAGS += -L/usr/lib32 + NEEDS_LIBGEN = YesPlease endif ifeq ($(uname_S),HP-UX) NO_IPV6=YesPlease From d9eb0205a217984f3e70bf18ae66c02a22d3d475 Mon Sep 17 00:00:00 2001 From: Johan Herland Date: Fri, 10 Jul 2009 01:52:30 +0200 Subject: [PATCH 22/95] quickfetch(): Prevent overflow of the rev-list command line quickfetch() calls rev-list to check whether the objects we are about to fetch are already present in the repo (if so, we can skip the object fetch). However, when there are many (~1000) refs to be fetched, the rev-list command line grows larger than the maximum command line size on some systems (32K in Windows). This causes rev-list to fail, making quickfetch() return non-zero, which unnecessarily triggers the transport machinery. This somehow causes fetch to fail with an exit code. By using the --stdin option to rev-list (and feeding the object list to its standard input), we prevent the overflow of the rev-list command line, which causes quickfetch(), and subsequently the overall fetch, to succeed. However, using rev-list --stdin is not entirely straightforward: rev-list terminates immediately when encountering an unknown object, which can trigger SIGPIPE if we are still writing object's to its standard input. We therefore temporarily ignore SIGPIPE so that the fetch process is not terminated. The patch also contains a testcase to verify the fix (note that before the patch, the testcase would only fail on msysGit). Signed-off-by: Johan Herland Improved-by: Johannes Sixt Improved-by: Alex Riesen Tested-by: Peter Krefting Signed-off-by: Junio C Hamano --- builtin-fetch.c | 67 ++++++++++++++++++++++++++----------------- t/t5502-quickfetch.sh | 20 +++++++++++++ 2 files changed, 60 insertions(+), 27 deletions(-) diff --git a/builtin-fetch.c b/builtin-fetch.c index cd5eb9aff5..817dd6bff0 100644 --- a/builtin-fetch.c +++ b/builtin-fetch.c @@ -400,14 +400,14 @@ static int store_updated_refs(const char *raw_url, const char *remote_name, /* * We would want to bypass the object transfer altogether if - * everything we are going to fetch already exists and connected + * everything we are going to fetch already exists and is connected * locally. * - * The refs we are going to fetch are in to_fetch (nr_heads in - * total). If running + * The refs we are going to fetch are in ref_map. If running * - * $ git rev-list --objects to_fetch[0] to_fetch[1] ... --not --all + * $ git rev-list --objects --stdin --not --all * + * (feeding all the refs in ref_map on its standard input) * does not error out, that means everything reachable from the * refs we are going to fetch exists and is connected to some of * our existing refs. @@ -416,8 +416,9 @@ static int quickfetch(struct ref *ref_map) { struct child_process revlist; struct ref *ref; - char **argv; - int i, err; + int err; + const char *argv[] = {"rev-list", + "--quiet", "--objects", "--stdin", "--not", "--all", NULL}; /* * If we are deepening a shallow clone we already have these @@ -429,34 +430,46 @@ static int quickfetch(struct ref *ref_map) if (depth) return -1; - for (i = 0, ref = ref_map; ref; ref = ref->next) - i++; - if (!i) + if (!ref_map) return 0; - argv = xmalloc(sizeof(*argv) * (i + 6)); - i = 0; - argv[i++] = xstrdup("rev-list"); - argv[i++] = xstrdup("--quiet"); - argv[i++] = xstrdup("--objects"); - for (ref = ref_map; ref; ref = ref->next) - argv[i++] = xstrdup(sha1_to_hex(ref->old_sha1)); - argv[i++] = xstrdup("--not"); - argv[i++] = xstrdup("--all"); - argv[i++] = NULL; - memset(&revlist, 0, sizeof(revlist)); - revlist.argv = (const char**)argv; + revlist.argv = argv; revlist.git_cmd = 1; - revlist.no_stdin = 1; revlist.no_stdout = 1; revlist.no_stderr = 1; - err = run_command(&revlist); + revlist.in = -1; - for (i = 0; argv[i]; i++) - free(argv[i]); - free(argv); - return err; + err = start_command(&revlist); + if (err) { + error("could not run rev-list"); + return err; + } + + /* + * If rev-list --stdin encounters an unknown commit, it terminates, + * which will cause SIGPIPE in the write loop below. + */ + sigchain_push(SIGPIPE, SIG_IGN); + + for (ref = ref_map; ref; ref = ref->next) { + if (write_in_full(revlist.in, sha1_to_hex(ref->old_sha1), 40) < 0 || + write_in_full(revlist.in, "\n", 1) < 0) { + if (errno != EPIPE && errno != EINVAL) + error("failed write to rev-list: %s", strerror(errno)); + err = -1; + break; + } + } + + if (close(revlist.in)) { + error("failed to close rev-list's stdin: %s", strerror(errno)); + err = -1; + } + + sigchain_pop(SIGPIPE); + + return finish_command(&revlist) || err; } static int fetch_refs(struct transport *transport, struct ref *ref_map) diff --git a/t/t5502-quickfetch.sh b/t/t5502-quickfetch.sh index 16eadd6b68..1037a723fe 100755 --- a/t/t5502-quickfetch.sh +++ b/t/t5502-quickfetch.sh @@ -119,4 +119,24 @@ test_expect_success 'quickfetch should not copy from alternate' ' ' +test_expect_success 'quickfetch should handle ~1000 refs (on Windows)' ' + + git gc && + head=$(git rev-parse HEAD) && + branchprefix="$head refs/heads/branch" && + for i in 0 1 2 3 4 5 6 7 8 9; do + for j in 0 1 2 3 4 5 6 7 8 9; do + for k in 0 1 2 3 4 5 6 7 8 9; do + echo "$branchprefix$i$j$k" >> .git/packed-refs + done + done + done && + ( + cd cloned && + git fetch && + git fetch + ) + +' + test_done From 3c49a03524b686c7b575e0a667736217e5445447 Mon Sep 17 00:00:00 2001 From: Mattias Nissler Date: Tue, 7 Jul 2009 01:39:52 +0200 Subject: [PATCH 23/95] git-svn: Always duplicate paths returned from get_log This makes get_log more safe to use because callers cannot run into path clobbering any more. The additional overhead will not affect performance since the critical calls from the fetch loop need the path duplication anyway and the rest of the call sites is not performance critical. Signed-off-by: Mattias Nissler Acked-by: Eric Wong --- git-svn.perl | 45 +++++++++++++++++++++++---------------------- 1 file changed, 23 insertions(+), 22 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index d1af1a3d2f..b4e8d44351 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -2538,9 +2538,8 @@ sub find_parent_branch { unless (defined $paths) { my $err_handler = $SVN::Error::handler; $SVN::Error::handler = \&Git::SVN::Ra::skip_unknown_revs; - $self->ra->get_log([$self->{path}], $rev, $rev, 0, 1, 1, sub { - $paths = - Git::SVN::Ra::dup_changed_paths($_[0]) }); + $self->ra->get_log([$self->{path}], $rev, $rev, 0, 1, 1, + sub { $paths = $_[0] }); $SVN::Error::handler = $err_handler; } return undef unless defined $paths; @@ -4431,6 +4430,26 @@ sub get_log { my ($self, @args) = @_; my $pool = SVN::Pool->new; + # svn_log_changed_path_t objects passed to get_log are likely to be + # overwritten even if only the refs are copied to an external variable, + # so we should dup the structures in their entirety. Using an + # externally passed pool (instead of our temporary and quickly cleared + # pool in Git::SVN::Ra) does not help matters at all... + my $receiver = pop @args; + push(@args, sub { + my ($paths) = $_[0]; + return &$receiver(@_) unless $paths; + $_[0] = (); + foreach my $p (keys %$paths) { + my $i = $paths->{$p}; + my %s = map { $_ => $i->$_ } + qw/copyfrom_path copyfrom_rev action/; + $_[0]{$p} = \%s; + } + &$receiver(@_); + }); + + # the limit parameter was not supported in SVN 1.1.x, so we # drop it. Therefore, the receiver callback passed to it # is made aware of this limitation by being wrapped if @@ -4600,7 +4619,7 @@ sub gs_fetch_loop_common { }; sub _cb { my ($paths, $r, $author, $date, $log) = @_; - [ dup_changed_paths($paths), + [ $paths, { author => $author, date => $date, log => $log } ]; } $self->get_log([$longest_path], $min, $max, 0, 1, 1, @@ -4823,24 +4842,6 @@ sub skip_unknown_revs { die "Error from SVN, ($errno): ", $err->expanded_message,"\n"; } -# svn_log_changed_path_t objects passed to get_log are likely to be -# overwritten even if only the refs are copied to an external variable, -# so we should dup the structures in their entirety. Using an externally -# passed pool (instead of our temporary and quickly cleared pool in -# Git::SVN::Ra) does not help matters at all... -sub dup_changed_paths { - my ($paths) = @_; - return undef unless $paths; - my %ret; - foreach my $p (keys %$paths) { - my $i = $paths->{$p}; - my %s = map { $_ => $i->$_ } - qw/copyfrom_path copyfrom_rev action/; - $ret{$p} = \%s; - } - \%ret; -} - package Git::SVN::Log; use strict; use warnings; From 0b2af457a49e3b00d47d556d5301934d27909db8 Mon Sep 17 00:00:00 2001 From: Mattias Nissler Date: Tue, 7 Jul 2009 01:40:02 +0200 Subject: [PATCH 24/95] git-svn: Fix branch detection when repository root is inaccessible For the case of multiple projects sharing a single SVN repository, it is common practice to create the standard SVN directory layout within a subdirectory for each project. In such setups, access control is often used to limit what projects a given user may access. git-svn failed to detect branches (e.g. when passing --stdlayout to clone) because it relied on having access to the root directory in the repository. This patch solves this problem by making git-svn use paths relative to the given repository URL instead of the repository root. Signed-off-by: Mattias Nissler Acked-by: Eric Wong --- git-svn.perl | 43 +++++++++++----------------- t/t9138-git-svn-multiple-branches.sh | 8 +++--- 2 files changed, 21 insertions(+), 30 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index b4e8d44351..ec847580d6 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -876,10 +876,6 @@ sub cmd_multi_init { usage(1); } - # there are currently some bugs that prevent multi-init/multi-fetch - # setups from working well without this. - $Git::SVN::_minimize_url = 1; - $_prefix = '' unless defined $_prefix; if (defined $url) { $url = canonicalize_url($url); @@ -1180,7 +1176,7 @@ sub complete_url_ls_init { "wanted to set to: $gs->{url}\n"; } command_oneline('config', $k, $gs->{url}) unless $orig_url; - my $remote_path = "$ra->{svn_path}/$repo_path"; + my $remote_path = "$gs->{path}/$repo_path"; $remote_path =~ s#/+#/#g; $remote_path =~ s#^/##g; $remote_path .= "/*" if $remote_path !~ /\*/; @@ -2177,16 +2173,6 @@ sub ra { $ra; } -sub rel_path { - my ($self) = @_; - my $repos_root = $self->ra->{repos_root}; - return $self->{path} if ($self->{url} eq $repos_root); - my $url = $self->{url} . - (length $self->{path} ? "/$self->{path}" : $self->{path}); - $url =~ s!^\Q$repos_root\E(?:/+|$)!!g; - $url; -} - # prop_walk(PATH, REV, SUB) # ------------------------- # Recursively traverse PATH at revision REV and invoke SUB for each @@ -2512,10 +2498,7 @@ sub match_paths { if (my $path = $paths->{"/$self->{path}"}) { return ($path->{action} eq 'D') ? 0 : 1; } - my $repos_root = $self->ra->{repos_root}; - my $extended_path = $self->{url} . '/' . $self->{path}; - $extended_path =~ s#^\Q$repos_root\E(/|$)##; - $self->{path_regex} ||= qr/^\/\Q$extended_path\E\//; + $self->{path_regex} ||= qr/^\/\Q$self->{path}\E\//; if (grep /$self->{path_regex}/, keys %$paths) { return 1; } @@ -2545,7 +2528,7 @@ sub find_parent_branch { return undef unless defined $paths; # look for a parent from another branch: - my @b_path_components = split m#/#, $self->rel_path; + my @b_path_components = split m#/#, $self->{path}; my @a_path_components; my $i; while (@b_path_components) { @@ -2563,11 +2546,11 @@ sub find_parent_branch { my $r = $i->{copyfrom_rev}; my $repos_root = $self->ra->{repos_root}; my $url = $self->ra->{url}; - my $new_url = $repos_root . $branch_from; + my $new_url = $url . $branch_from; print STDERR "Found possible branch point: ", "$new_url => ", $self->full_url, ", $r\n"; $branch_from =~ s#^/##; - my $gs = $self->other_gs($new_url, $url, $repos_root, + my $gs = $self->other_gs($new_url, $url, $branch_from, $r, $self->{ref_id}); my ($r0, $parent) = $gs->find_rev_before($r, 1); { @@ -2752,9 +2735,9 @@ sub parse_svn_date { } sub other_gs { - my ($self, $new_url, $url, $repos_root, + my ($self, $new_url, $url, $branch_from, $r, $old_ref_id) = @_; - my $gs = Git::SVN->find_by_url($new_url, $repos_root, $branch_from); + my $gs = Git::SVN->find_by_url($new_url, $url, $branch_from); unless ($gs) { my $ref_id = $old_ref_id; $ref_id =~ s/\@\d+$//; @@ -4436,14 +4419,22 @@ sub get_log { # externally passed pool (instead of our temporary and quickly cleared # pool in Git::SVN::Ra) does not help matters at all... my $receiver = pop @args; + my $prefix = "/".$self->{svn_path}; + $prefix =~ s#/+($)##; + my $prefix_regex = qr#^\Q$prefix\E#; push(@args, sub { my ($paths) = $_[0]; return &$receiver(@_) unless $paths; $_[0] = (); foreach my $p (keys %$paths) { my $i = $paths->{$p}; - my %s = map { $_ => $i->$_ } - qw/copyfrom_path copyfrom_rev action/; + # Make path relative to our url, not repos_root + $p =~ s/$prefix_regex//; + my %s = map { $_ => $i->$_; } + qw/copyfrom_path copyfrom_rev action/; + if ($s{'copyfrom_path'}) { + $s{'copyfrom_path'} =~ s/$prefix_regex//; + } $_[0]{$p} = \%s; } &$receiver(@_); diff --git a/t/t9138-git-svn-multiple-branches.sh b/t/t9138-git-svn-multiple-branches.sh index cb9a6d229d..3cd06718eb 100755 --- a/t/t9138-git-svn-multiple-branches.sh +++ b/t/t9138-git-svn-multiple-branches.sh @@ -99,22 +99,22 @@ test_expect_success 'Multiple branch or tag paths require -d' ' test_expect_success 'create new branches and tags' ' ( cd git_project && - git svn branch -m "New branch 1" -d project/b_one New1 ) && + git svn branch -m "New branch 1" -d b_one New1 ) && ( cd svn_project && svn_cmd up && test -e b_one/New1/a.file ) && ( cd git_project && - git svn branch -m "New branch 2" -d project/b_two New2 ) && + git svn branch -m "New branch 2" -d b_two New2 ) && ( cd svn_project && svn_cmd up && test -e b_two/New2/a.file ) && ( cd git_project && - git svn branch -t -m "New tag 1" -d project/tags_A Tag1 ) && + git svn branch -t -m "New tag 1" -d tags_A Tag1 ) && ( cd svn_project && svn_cmd up && test -e tags_A/Tag1/a.file ) && ( cd git_project && - git svn tag -m "New tag 2" -d project/tags_B Tag2 ) && + git svn tag -m "New tag 2" -d tags_B Tag2 ) && ( cd svn_project && svn_cmd up && test -e tags_B/Tag2/a.file ) ' From b3e95936274a7f5d516e7c37b39e1a56b2d09709 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sat, 11 Jul 2009 14:13:12 -0700 Subject: [PATCH 25/95] git svn: allow uppercase UUIDs from SVN SVN allows uppercase A-F characters in repositories. Although `svnadmin' does not create UUIDs with uppercase by default, it is possible to change the UUID of a SVN repository and SVN itself will make no attempt to normalize them. Thanks to Esben Skovenborg for discovering this issue. Signed-off-by: Eric Wong --- git-svn.perl | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index ec847580d6..cfade63459 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -1359,11 +1359,11 @@ sub read_repo_config { sub extract_metadata { my $id = shift or return (undef, undef, undef); my ($url, $rev, $uuid) = ($id =~ /^\s*git-svn-id:\s+(.*)\@(\d+) - \s([a-f\d\-]+)$/x); + \s([a-f\d\-]+)$/ix); if (!defined $rev || !$uuid || !$url) { # some of the original repositories I made had # identifiers like this: - ($rev, $uuid) = ($id =~/^\s*git-svn-id:\s(\d+)\@([a-f\d\-]+)/); + ($rev, $uuid) = ($id =~/^\s*git-svn-id:\s(\d+)\@([a-f\d\-]+)/i); } return ($url, $rev, $uuid); } @@ -2010,7 +2010,7 @@ sub _set_svm_vars { chomp($src, $uuid); - $uuid =~ m{^[0-9a-f\-]{30,}$} + $uuid =~ m{^[0-9a-f\-]{30,}$}i or die "doesn't look right - svm:uuid is '$uuid'\n"; # the '!' is used to mark the repos_root!/relative/path @@ -2096,7 +2096,7 @@ sub svnsync { die "doesn't look right - svn:sync-from-url is '$url'\n"; my $uuid = tmp_config('--get', "$section.svnsync-uuid"); - ($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}) or + ($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}i) or die "doesn't look right - svn:sync-from-uuid is '$uuid'\n"; $svnsync = { url => $url, uuid => $uuid } @@ -2114,7 +2114,7 @@ sub svnsync { die "doesn't look right - svn:sync-from-url is '$url'\n"; my $uuid = $rp->{'svn:sync-from-uuid'} or die $err . "uuid\n"; - ($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}) or + ($uuid) = ($uuid =~ m{^([0-9a-f\-]{30,})$}i) or die "doesn't look right - svn:sync-from-uuid is '$uuid'\n"; my $section = "svn-remote.$self->{repo_id}"; @@ -2130,7 +2130,7 @@ sub ra_uuid { unless ($self->{ra_uuid}) { my $key = "svn-remote.$self->{repo_id}.uuid"; my $uuid = eval { tmp_config('--get', $key) }; - if (!$@ && $uuid && $uuid =~ /^([a-f\d\-]{30,})$/) { + if (!$@ && $uuid && $uuid =~ /^([a-f\d\-]{30,})$/i) { $self->{ra_uuid} = $uuid; } else { die "ra_uuid called without URL\n" unless $self->{url}; @@ -2848,7 +2848,7 @@ sub make_log_entry { die "Can't have both 'useSvmProps' and 'rewriteRoot' ", "options set!\n"; } - my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$}; + my ($uuid, $r) = $headrev =~ m{^([a-f\d\-]{30,}):(\d+)$}i; # we don't want "SVM: initializing mirror for junk" ... return undef if $r == 0; my $svm = $self->svm; From 69fb8283937a18a031aeef12ea2a530c8ccf3e83 Mon Sep 17 00:00:00 2001 From: Wincent Colaiuta Date: Sun, 12 Jul 2009 14:31:28 +0200 Subject: [PATCH 26/95] gitweb: update Git homepage URL git-scm.com is now the "official" Git project page, having taken over from git.or.cz, so update the default link accordingly. This saves a redirect when people hit git.or.cz. Signed-off-by: Wincent Colaiuta Signed-off-by: Junio C Hamano --- gitweb/gitweb.perl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/gitweb/gitweb.perl b/gitweb/gitweb.perl index 6a1b5b5b49..7fbd5ff89e 100755 --- a/gitweb/gitweb.perl +++ b/gitweb/gitweb.perl @@ -94,7 +94,7 @@ our $favicon = "++GITWEB_FAVICON++"; # URI and label (title) of GIT logo link #our $logo_url = "http://www.kernel.org/pub/software/scm/git/docs/"; #our $logo_label = "git documentation"; -our $logo_url = "http://git.or.cz/"; +our $logo_url = "http://git-scm.com/"; our $logo_label = "git homepage"; # source of projects list From 2657420d9ecee5c68f300cdabdf2bec7e76a2d05 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Mon, 13 Jul 2009 17:11:44 +0200 Subject: [PATCH 27/95] Document 'git (rev-list|log) --merges' MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- Documentation/git-rev-list.txt | 1 + Documentation/rev-list-options.txt | 4 ++++ 2 files changed, 5 insertions(+) diff --git a/Documentation/git-rev-list.txt b/Documentation/git-rev-list.txt index 1c9cc28895..a765cfa4d2 100644 --- a/Documentation/git-rev-list.txt +++ b/Documentation/git-rev-list.txt @@ -14,6 +14,7 @@ SYNOPSIS [ \--max-age=timestamp ] [ \--min-age=timestamp ] [ \--sparse ] + [ \--merges ] [ \--no-merges ] [ \--first-parent ] [ \--remove-empty ] diff --git a/Documentation/rev-list-options.txt b/Documentation/rev-list-options.txt index 11eec941df..bf66116d61 100644 --- a/Documentation/rev-list-options.txt +++ b/Documentation/rev-list-options.txt @@ -201,6 +201,10 @@ endif::git-rev-list[] Stop when a given path disappears from the tree. +--merges:: + + Print only merge commits. + --no-merges:: Do not print commits with more than one parent. From 4fe1a61973c82c459ac0a25cb5342d00d347dfd9 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Mon, 13 Jul 2009 17:11:45 +0200 Subject: [PATCH 28/95] bash: add '--merges' to common 'git log' options MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit ... so it's available for git log, shortlog and gitk. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- contrib/completion/git-completion.bash | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index 9c488646d0..887731e830 100755 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -1114,7 +1114,7 @@ _git_ls_tree () __git_log_common_options=" --not --all --branches --tags --remotes - --first-parent --no-merges + --first-parent --merges --no-merges --max-count= --max-age= --since= --after= --min-age= --until= --before= From f222abdeec7838891e79abd152c6cb67e532b68d Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Mon, 13 Jul 2009 14:41:12 -0700 Subject: [PATCH 29/95] Make 'git show' more useful For some reason, I ended up doing git show HEAD~5.. as an odd way of asking for a log. I realize I should just have used "git log", but at the same time it does make perfect conceptual sense. After all, you _could_ have done git show HEAD HEAD~1 HEAD~2 HEAD~3 HEAD~4 and saying "git show HEAD~5.." is pretty natural. It's not like "git show" only ever showed a single commit (or other object) before either! So conceptually, giving a commit range is a very sensible operation, even though you'd traditionally have used "git log" for that. However, doing that currently results in an error fatal: object ranges do not make sense when not walking revisions which admittedly _also_ makes perfect sense - from an internal git implementation standpoint in 'revision.c'. However, I think that asking to show a range makes sense to a user, while saying "object ranges no not make sense when not walking revisions" only makes sense to a git developer. So on the whole, of the two different "makes perfect sense" behaviors, I think I originally picked the wrong one. And quite frankly, I don't really see anybody actually _depending_ on that error case. So why not change it? So rather than error out, just turn that non-walking error case into a "silently turn on walking" instead. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- revision.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/revision.c b/revision.c index a31434bdc8..9f5dac5f1d 100644 --- a/revision.c +++ b/revision.c @@ -133,7 +133,7 @@ void mark_parents_uninteresting(struct commit *commit) static void add_pending_object_with_mode(struct rev_info *revs, struct object *obj, const char *name, unsigned mode) { if (revs->no_walk && (obj->flags & UNINTERESTING)) - die("object ranges do not make sense when not walking revisions"); + revs->no_walk = 0; if (revs->reflog_info && obj->type == OBJ_COMMIT && add_reflog_for_walk(revs->reflog_info, (struct commit *)obj, name)) From a38837341c995773f2adc29ff5971196187b07fb Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 14 Jul 2009 11:25:17 -0700 Subject: [PATCH 30/95] Improve on the 'invalid object' error message at commit time Not that anybody should ever get it, but somebody did (probably because of a flaky filesystem, but whatever). And each time I see an error message that I haven't seen before, I decide that next time it will look better. So this makes us write more relevant information about exactly which file ended up having issues with a missing object. Which will tell whether it was a tree object, for example, or just a regular file in the index (and which one). Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- cache-tree.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/cache-tree.c b/cache-tree.c index 16a65dfac1..d91743775d 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -329,7 +329,8 @@ static int update_one(struct cache_tree *it, entlen = pathlen - baselen; } if (mode != S_IFGITLINK && !missing_ok && !has_sha1_file(sha1)) - return error("invalid object %s", sha1_to_hex(sha1)); + return error("invalid object %06o %s for '%.*s'", + mode, sha1_to_hex(sha1), entlen+baselen, path); if (ce->ce_flags & CE_REMOVE) continue; /* entry being removed */ From 05c1da2f5e7a5c0d2bbd1154bbb6c5cc9cb2b17f Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Tue, 14 Jul 2009 14:19:10 -0700 Subject: [PATCH 31/95] Fix extraneous lstat's in 'git checkout -f' In our 'oneway_merge()' we always do an 'lstat()' to see if we might need to mark the entry for updating. But we really shouldn't need to do that when the cache entry is already marked as being ce_uptodate(), and this makes us do unnecessary lstat() calls if we have index preloading enabled. Signed-off-by: Linus Torvalds Signed-off-by: Junio C Hamano --- unpack-trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpack-trees.c b/unpack-trees.c index f9d12aafba..48d862d3b4 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -1004,7 +1004,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o) if (old && same(old, a)) { int update = 0; - if (o->reset) { + if (o->reset && !ce_uptodate(old)) { struct stat st; if (lstat(old->name, &st) || ie_match_stat(o->src_index, old, &st, CE_MATCH_IGNORE_VALID)) From 4525e8e41a8c0c4246a95097744604ea72198dad Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 15 Jul 2009 15:10:06 -0700 Subject: [PATCH 32/95] Revert "mailinfo: Remove only one set of square brackets" This reverts commit 650d30d8a120c8982309ccb9ef40432b4ea2eb74. Some mailing lists are configured add prefix "[listname] " to all their messages, and also people hand-edit subject lines, be it an output from format-patch or a patch generated by some other means. We cannot stop people from mucking with the subject line, and with the change, there always will be need for hand editing the subject when that happens. People have depended on the leading [bracketed string] removal. --- builtin-mailinfo.c | 7 ------- t/t5100/info0012 | 2 +- t/t5100/sample.mbox | 2 +- 3 files changed, 2 insertions(+), 9 deletions(-) diff --git a/builtin-mailinfo.c b/builtin-mailinfo.c index fb5ad70f3f..92637ac0ba 100644 --- a/builtin-mailinfo.c +++ b/builtin-mailinfo.c @@ -221,8 +221,6 @@ static void cleanup_subject(struct strbuf *subject) { char *pos; size_t remove; - int brackets_removed = 0; - while (subject->len) { switch (*subject->buf) { case 'r': case 'R': @@ -237,15 +235,10 @@ static void cleanup_subject(struct strbuf *subject) strbuf_remove(subject, 0, 1); continue; case '[': - /* remove only one set of square brackets */ - if (brackets_removed) - break; - if ((pos = strchr(subject->buf, ']'))) { remove = pos - subject->buf; if (remove <= (subject->len - remove) * 2) { strbuf_remove(subject, 0, remove + 1); - brackets_removed = 1; continue; } } else diff --git a/t/t5100/info0012 b/t/t5100/info0012 index 9cd1415d25..ac1216ff75 100644 --- a/t/t5100/info0012 +++ b/t/t5100/info0012 @@ -1,5 +1,5 @@ Author: Dmitriy Blinov Email: bda@mnsspb.ru -Subject: [Navy-patches] Изменён список пакетов необходимых для сборки +Subject: Изменён список пакетов необходимых для сборки Date: Wed, 12 Nov 2008 17:54:41 +0300 diff --git a/t/t5100/sample.mbox b/t/t5100/sample.mbox index 3a757d7d8f..c3074ac573 100644 --- a/t/t5100/sample.mbox +++ b/t/t5100/sample.mbox @@ -514,7 +514,7 @@ MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit -Subject: [PATCH] [Navy-patches] +Subject: [Navy-patches] [PATCH] =?utf-8?b?0JjQt9C80LXQvdGR0L0g0YHQv9C40YHQvtC6INC/0LA=?= =?utf-8?b?0LrQtdGC0L7QsiDQvdC10L7QsdGF0L7QtNC40LzRi9GFINC00LvRjyA=?= =?utf-8?b?0YHQsdC+0YDQutC4?= From 9d33f7c22fda81f7be8a7aa1576e6d399d3b45ec Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 16 Jul 2009 16:25:18 -0500 Subject: [PATCH 33/95] refs.c: release file descriptor on error return Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- refs.c | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/refs.c b/refs.c index 90163bdc56..bb0762ee2b 100644 --- a/refs.c +++ b/refs.c @@ -1525,8 +1525,10 @@ int for_each_recent_reflog_ent(const char *ref, each_reflog_ent_fn fn, long ofs, if (fstat(fileno(logfp), &statbuf) || statbuf.st_size < ofs || fseek(logfp, -ofs, SEEK_END) || - fgets(buf, sizeof(buf), logfp)) + fgets(buf, sizeof(buf), logfp)) { + fclose(logfp); return -1; + } } while (fgets(buf, sizeof(buf), logfp)) { From b45a09c4b4a80ccc6eeb0f390ab8f4eb6f31c922 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Thu, 16 Jul 2009 16:25:19 -0500 Subject: [PATCH 34/95] sha1_name.c: avoid unnecessary strbuf_release When we fall back to a standard for_each_reflog_ent() after failing to find the nth branch switch (or if we had a short reflog) with the call to for_each_recent_reflog_ent(), we do not need to free the memory allocated for our strbuf's since a strbuf_reset() will be performed in grab_nth_branch_switch() before assigning to the entry. Plus, the strbuf_release() negates the non-zero hint we initially gave to strbuf_init() just above these lines. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- sha1_name.c | 2 -- 1 file changed, 2 deletions(-) diff --git a/sha1_name.c b/sha1_name.c index 904bcd96a5..44bb62d270 100644 --- a/sha1_name.c +++ b/sha1_name.c @@ -777,8 +777,6 @@ int interpret_branch_name(const char *name, struct strbuf *buf) for_each_recent_reflog_ent("HEAD", grab_nth_branch_switch, 40960, &cb); if (cb.cnt < nth) { cb.cnt = 0; - for (i = 0; i < nth; i++) - strbuf_release(&cb.buf[i]); for_each_reflog_ent("HEAD", grab_nth_branch_switch, &cb); } if (cb.cnt < nth) From 78d3b06e0f5e6aaea001ee8e3e7c8e401dc4b244 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 18 Jul 2009 12:26:38 -0700 Subject: [PATCH 35/95] checkout -f: deal with a D/F conflict entry correctly When we switch branches with "checkout -f", unpack_trees() feeds two cache_entries to oneway_merge() function in its src[] array argument. The zeroth entry comes from the current index, and the first entry represents what the merge result should be, taken from the tree recorded in the commit we are switching to. When we have a blob (either regular file or a symlink) in the index and in the work tree at path "foo", and the switched-to tree has "foo/bar", i.e. "foo" becomes a directory, src[0] is obviously that blob currently registered at "foo". Even though we do not have anything at "foo" in the switched-to tree, src[1] is _not_ NULL in this case. The unpack_trees() machinery places a special marker df_conflict_entry to signal that no blob exists at "foo", but it will become a directory that may have somthing underneath it (namely "foo/bar"), so a usual 3-way merge can notice the situation. But oneway_merge() codepath failed to notice this and passed the special marker directly to merged_entry(). This happens to remove the "foo" in the end because the df_conflict_entry does not have any name (hence the "error" message) and its addition in add_index_entry() is rejected, but it is wrong. Signed-off-by: Junio C Hamano Acked-by: Linus Torvalds --- unpack-trees.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/unpack-trees.c b/unpack-trees.c index aaacaf1015..a0697d2412 100644 --- a/unpack-trees.c +++ b/unpack-trees.c @@ -982,7 +982,7 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o) return error("Cannot do a oneway merge of %d trees", o->merge_size); - if (!a) + if (!a || a == o->df_conflict_entry) return deleted_entry(old, old, o); if (old && same(old, a)) { From 3de4a44308d5c84c468f3fb69a3c3f3092eaf369 Mon Sep 17 00:00:00 2001 From: Mike Ralphson Date: Wed, 15 Jul 2009 15:34:24 +0100 Subject: [PATCH 36/95] cvsexportcommit: reorder tests to quiet intermittent failure Reorder tests introduced in fef3a7cc and 54d5cc0e so an intermittent but unimportant failure on the CVS side related to the former does not interfere with what is actually being tested. Signed-off-by: Mike Ralphson Tested-by: Tommy Nordgren Signed-off-by: Junio C Hamano --- t/t9200-git-cvsexportcommit.sh | 41 ++++++++++++++++++---------------- 1 file changed, 22 insertions(+), 19 deletions(-) diff --git a/t/t9200-git-cvsexportcommit.sh b/t/t9200-git-cvsexportcommit.sh index ef1f8d22f6..fc3795dc98 100755 --- a/t/t9200-git-cvsexportcommit.sh +++ b/t/t9200-git-cvsexportcommit.sh @@ -288,6 +288,27 @@ test_expect_success 'check files before directories' ' ' +test_expect_success 're-commit a removed filename which remains in CVS attic' ' + + (cd "$CVSWORK" && + echo >attic_gremlin && + cvs -Q add attic_gremlin && + cvs -Q ci -m "added attic_gremlin" && + rm attic_gremlin && + cvs -Q rm attic_gremlin && + cvs -Q ci -m "removed attic_gremlin") && + + echo > attic_gremlin && + git add attic_gremlin && + git commit -m "Added attic_gremlin" && + git cvsexportcommit -w "$CVSWORK" -c HEAD && + (cd "$CVSWORK"; cvs -Q update -d) && + test -f "$CVSWORK/attic_gremlin" +' + +# the state of the CVS sandbox may be indeterminate for ' space' +# after this test on some platforms / with some versions of CVS +# consider adding new tests above this point test_expect_success 'commit a file with leading spaces in the name' ' echo space > " space" && @@ -295,7 +316,7 @@ test_expect_success 'commit a file with leading spaces in the name' ' git commit -m "Add a file with a leading space" && id=$(git rev-parse HEAD) && git cvsexportcommit -w "$CVSWORK" -c $id && - check_entries "$CVSWORK" " space/1.1/|DS/1.1/|release-notes/1.2/" && + check_entries "$CVSWORK" " space/1.1/|DS/1.1/|attic_gremlin/1.3/|release-notes/1.2/" && test_cmp "$CVSWORK/ space" " space" ' @@ -317,22 +338,4 @@ test_expect_success 'use the same checkout for Git and CVS' ' ' -test_expect_success 're-commit a removed filename which remains in CVS attic' ' - - (cd "$CVSWORK" && - echo >attic_gremlin && - cvs -Q add attic_gremlin && - cvs -Q ci -m "added attic_gremlin" && - rm attic_gremlin && - cvs -Q rm attic_gremlin && - cvs -Q ci -m "removed attic_gremlin") && - - echo > attic_gremlin && - git add attic_gremlin && - git commit -m "Added attic_gremlin" && - git cvsexportcommit -w "$CVSWORK" -c HEAD && - (cd "$CVSWORK"; cvs -Q update -d) && - test -f "$CVSWORK/attic_gremlin" -' - test_done From d5cee0f78654357965cb88c4e6d3cfa272d9ae28 Mon Sep 17 00:00:00 2001 From: Michael J Gruber Date: Fri, 17 Jul 2009 16:28:06 +0200 Subject: [PATCH 37/95] t4202-log.sh: Test git log --no-walk sort order 'git log --no-walk' sorts commits by commit time whereas 'git show' does not (it leaves them as given on the command line). Document this by two tests so that we never forget why ba1d450 (Tentative built-in "git show", 2006-04-15) introduced it and 8e64006 (Teach revision machinery about --no-walk, 2007-07-24) exposed it as an option argument. Signed-off-by: Michael J Gruber Signed-off-by: Junio C Hamano --- t/t4202-log.sh | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/t/t4202-log.sh b/t/t4202-log.sh index aad3894ad4..48e0088b47 100755 --- a/t/t4202-log.sh +++ b/t/t4202-log.sh @@ -149,6 +149,26 @@ test_expect_success 'git log --follow' ' ' +cat > expect << EOF +804a787 sixth +394ef78 fifth +5d31159 fourth +EOF +test_expect_success 'git log --no-walk sorts by commit time' ' + git log --no-walk --oneline 5d31159 804a787 394ef78 > actual && + test_cmp expect actual +' + +cat > expect << EOF +5d31159 fourth +804a787 sixth +394ef78 fifth +EOF +test_expect_success 'git show leaves list of commits as given' ' + git show --oneline -s 5d31159 804a787 394ef78 > actual && + test_cmp expect actual +' + test_expect_success 'setup case sensitivity tests' ' echo case >one && test_tick && From bba0fd22ad654460a81c4b35462b600d9432a869 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 18 Jul 2009 17:19:47 -0700 Subject: [PATCH 38/95] push: do not give big warning when no preference is configured If the message said "we will be changing the default in the future, so this is to warn people who want to keep the current default what to do", it would have made some sense, but as it stands, the message is merely an unsolicited advertisement for a new feature, which it is not helpful at all. Squelch it. Signed-off-by: Junio C Hamano --- builtin-push.c | 27 +-------------------------- cache.h | 1 - environment.c | 2 +- 3 files changed, 2 insertions(+), 28 deletions(-) diff --git a/builtin-push.c b/builtin-push.c index 0a0297f981..1d92e22f0a 100644 --- a/builtin-push.c +++ b/builtin-push.c @@ -64,36 +64,11 @@ static void setup_push_tracking(void) add_refspec(refspec.buf); } -static const char *warn_unconfigured_push_msg[] = { - "You did not specify any refspecs to push, and the current remote", - "has not configured any push refspecs. The default action in this", - "case is to push all matching refspecs, that is, all branches", - "that exist both locally and remotely will be updated. This may", - "not necessarily be what you want to happen.", - "", - "You can specify what action you want to take in this case, and", - "avoid seeing this message again, by configuring 'push.default' to:", - " 'nothing' : Do not push anything", - " 'matching' : Push all matching branches (default)", - " 'tracking' : Push the current branch to whatever it is tracking", - " 'current' : Push the current branch" -}; - -static void warn_unconfigured_push(void) -{ - int i; - for (i = 0; i < ARRAY_SIZE(warn_unconfigured_push_msg); i++) - warning("%s", warn_unconfigured_push_msg[i]); -} - static void setup_default_push_refspecs(void) { git_config(git_default_config, NULL); switch (push_default) { - case PUSH_DEFAULT_UNSPECIFIED: - warn_unconfigured_push(); - /* fallthrough */ - + default: case PUSH_DEFAULT_MATCHING: add_refspec(":"); break; diff --git a/cache.h b/cache.h index f1e5ede021..c72f125bd4 100644 --- a/cache.h +++ b/cache.h @@ -543,7 +543,6 @@ enum rebase_setup_type { }; enum push_default_type { - PUSH_DEFAULT_UNSPECIFIED = -1, PUSH_DEFAULT_NOTHING = 0, PUSH_DEFAULT_MATCHING, PUSH_DEFAULT_TRACKING, diff --git a/environment.c b/environment.c index 801a005ef1..720f26b67d 100644 --- a/environment.c +++ b/environment.c @@ -42,7 +42,7 @@ enum safe_crlf safe_crlf = SAFE_CRLF_WARN; unsigned whitespace_rule_cfg = WS_DEFAULT_RULE; enum branch_track git_branch_track = BRANCH_TRACK_REMOTE; enum rebase_setup_type autorebase = AUTOREBASE_NEVER; -enum push_default_type push_default = PUSH_DEFAULT_UNSPECIFIED; +enum push_default_type push_default = PUSH_DEFAULT_MATCHING; #ifndef OBJECT_CREATION_MODE #define OBJECT_CREATION_MODE OBJECT_CREATION_USES_HARDLINKS #endif From 77acc32b29990a76ac6a63d3211b7c70adcef64d Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Sat, 18 Jul 2009 13:01:49 -0700 Subject: [PATCH 39/95] Updates to draft release notes to 1.6.4 Signed-off-by: Junio C Hamano --- Documentation/RelNotes-1.6.4.txt | 57 ++++++++++++++++++++++++++------ 1 file changed, 47 insertions(+), 10 deletions(-) diff --git a/Documentation/RelNotes-1.6.4.txt b/Documentation/RelNotes-1.6.4.txt index af68297af5..f578b8186f 100644 --- a/Documentation/RelNotes-1.6.4.txt +++ b/Documentation/RelNotes-1.6.4.txt @@ -22,13 +22,6 @@ branch pointed at by its HEAD, gets a large warning. You can choose what should happen upon such a push by setting the configuration variable receive.denyDeleteCurrent in the receiving repository. -When the user does not tell "git push" what to push, it has always -pushed matching refs. For some people it is unexpected, and a new -configuration variable push.default has been introduced to allow -changing a different default behaviour. To advertise the new feature, -a big warning is issued if this is not configured and a git push without -arguments is attempted. - Updates since v1.6.3 -------------------- @@ -38,26 +31,60 @@ Updates since v1.6.3 * gitweb Perl style clean-up. * git-svn updates, including a new --authors-prog option to map author - names by invoking an external program. + names by invoking an external program, 'git svn reset' to unwind + 'git svn fetch', support for more than one branches, etc. (portability) * We feed iconv with "UTF-8" instead of "utf8"; the former is - understood more widely. + understood more widely. Similarly updated test scripts to use + encoding names more widely understood (e.g. use "ISO8850-1" instead + of "ISO-8859-1"). + + * Various portability fixes/workarounds for different vintages of + SunOS, IRIX, and Windows. + + * Git-over-ssh transport on Windows supports PuTTY plink and TortoisePlink. (performance) + * Many repeated use of lstat() are optimized out in "checkout" codepath. + + * git-status (and underlying git-diff-index --cached) are optimized + to take advantage of cache-tree information in the index. + (usability, bells and whistles) * "git add --edit" lets users edit the whole patch text to fine-tune what is added to the index. + * "git am" accepts StGIT series file as its input. + + * "git bisect skip" skips to a more randomly chosen place in the hope + to avoid testing a commit that is too close to a commit that is + already known to be untestable. + + * "git cvsexportcommit" learned -k option to stop CVS keywords expansion + + * "git grep" learned -p option to show the location of the match using the + same context hunk marker "git diff" uses. + + * https transport can optionally be told that the used client + certificate is password protected, in which case it asks the + password only once. + + * "git imap-send" is IPv6 aware. + * "git log --graph" draws graphs more compactly by using horizonal lines when able. * "git log --decorate" shows shorter refnames by stripping well-known refs/* prefix. + * "git push $name" honors remote.$name.pushurl if present before + using remote.$name.url. In other words, the URL used for fetching + and pushing can be different. + * "git send-email" understands quoted aliases in .mailrc files (might have to be backported to 1.6.3.X). @@ -69,6 +96,11 @@ Updates since v1.6.3 * "add" and "update" subcommands to "git submodule" learned --reference option to use local clone with references. + * "git submodule update" learned --rebase option to update checked + out submodules by rebasing the local changes. + + * "gitweb" can optionally use gravatar to adorn author/committer names. + (developers) * A major part of the "git bisect" wrapper has moved to C. @@ -82,6 +114,11 @@ release, unless otherwise noted. Here are fixes that this release has, but have not been backported to v1.6.3.X series. + * "git diff-tree -r -t" used to omit new or removed directories from + the output. df533f3 (diff-tree -r -t: include added/removed + directories in the output, 2009-06-13) may need to be cherry-picked + to backport this fix. + * The way Git.pm sets up a Repository object was not friendly to callers that chdir around. It now internally records the repository location as an absolute path when autodetected. @@ -89,5 +126,5 @@ v1.6.3.X series. --- exec >/var/tmp/1 echo O=$(git describe master) -O=v1.6.3.1-168-g23807fa +O=v1.6.4-rc1-7-gbba0fd2 git shortlog --no-merges $O..master ^maint From f0e8b1a3ed48716fa48c93f64214da1ee20ed534 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 19 Jul 2009 03:08:27 -0700 Subject: [PATCH 40/95] git svn: rename tests that had conflicting numbers Some unrelated tests were developed simultaneously and resulted in test numbers conflicting. To avoid difficulty when referring to tests via the "tXXXX" convention, rename the newer tests. Suggested by Marc Branchaud. Signed-off-by: Eric Wong --- t/{t9139-git-svn-reset.sh => t9140-git-svn-reset.sh} | 0 ...vn-multiple-branches.sh => t9141-git-svn-multiple-branches.sh} | 0 2 files changed, 0 insertions(+), 0 deletions(-) rename t/{t9139-git-svn-reset.sh => t9140-git-svn-reset.sh} (100%) rename t/{t9138-git-svn-multiple-branches.sh => t9141-git-svn-multiple-branches.sh} (100%) diff --git a/t/t9139-git-svn-reset.sh b/t/t9140-git-svn-reset.sh similarity index 100% rename from t/t9139-git-svn-reset.sh rename to t/t9140-git-svn-reset.sh diff --git a/t/t9138-git-svn-multiple-branches.sh b/t/t9141-git-svn-multiple-branches.sh similarity index 100% rename from t/t9138-git-svn-multiple-branches.sh rename to t/t9141-git-svn-multiple-branches.sh From 2a679c7a3148978a3f58f1c12100383638e744c5 Mon Sep 17 00:00:00 2001 From: Eric Wong Date: Sun, 19 Jul 2009 22:08:45 -0700 Subject: [PATCH 41/95] git svn: fix reparenting when ugly http(s) URLs are used Mishandling of http(s) in need of escaping was causing t9118-git-svn-funky-branch-names to fail when SVN_HTTPD_PORT was defined. This bug was exposed in (but not caused by) commit 0b2af457a49e3b00d47d556d5301934d27909db8 (Fix branch detection when repository root is inaccessible) Signed-off-by: Eric Wong --- git-svn.perl | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/git-svn.perl b/git-svn.perl index cfade63459..43c86e85a1 100755 --- a/git-svn.perl +++ b/git-svn.perl @@ -4525,10 +4525,12 @@ sub gs_do_switch { my $full_url = $self->{url}; my $old_url = $full_url; - $full_url .= '/' . escape_uri_only($path) if length $path; + $full_url .= '/' . $path if length $path; my ($ra, $reparented); - if ($old_url =~ m#^svn(\+ssh)?://#) { + if ($old_url =~ m#^svn(\+ssh)?://# || + ($full_url =~ m#^https?://# && + escape_url($full_url) ne $full_url)) { $_[0] = undef; $self = undef; $RA = undef; From 1830d9cb62772c0626297e4bb6e537664283ebfa Mon Sep 17 00:00:00 2001 From: Greg Price Date: Wed, 22 Jul 2009 12:38:58 -0400 Subject: [PATCH 42/95] Fix rebase -p --onto In a rebase with --onto, the correct test for whether we can skip rewriting a commit is if it is already on top of $ONTO, not $UPSTREAM. Without --onto, this distinction does not exist and the behavior does not change. In a situation with two merged branches on a common base X: X---o---o---o---M \ / x---x---x---x Y if we try to move the branches from their base on X to be based on Y, so as to get X Y---o'--o'--o'--M' \ / x'--x'--x'--x' then we fail. The command `git rebase -p --onto Y X M` moves only the first-parent chain, like so: X \ x---x---x---x \ Y---o'--o'--o'--M' because it mistakenly drops the other branch(es) x---x---x---x from the TODO file. This tests and fixes this behavior. Signed-off-by: Greg Price Signed-off-by: Junio C Hamano --- git-rebase--interactive.sh | 2 +- t/t3414-rebase-preserve-onto.sh | 80 +++++++++++++++++++++++++++++++++ 2 files changed, 81 insertions(+), 1 deletion(-) create mode 100755 t/t3414-rebase-preserve-onto.sh diff --git a/git-rebase--interactive.sh b/git-rebase--interactive.sh index f96d887d23..23ded48322 100755 --- a/git-rebase--interactive.sh +++ b/git-rebase--interactive.sh @@ -703,7 +703,7 @@ first and then run 'git rebase --continue' again." preserve=t for p in $(git rev-list --parents -1 $sha1 | cut -d' ' -s -f2-) do - if test -f "$REWRITTEN"/$p -a \( $p != $UPSTREAM -o $sha1 = $first_after_upstream \) + if test -f "$REWRITTEN"/$p -a \( $p != $ONTO -o $sha1 = $first_after_upstream \) then preserve=f fi diff --git a/t/t3414-rebase-preserve-onto.sh b/t/t3414-rebase-preserve-onto.sh new file mode 100755 index 0000000000..80019ee072 --- /dev/null +++ b/t/t3414-rebase-preserve-onto.sh @@ -0,0 +1,80 @@ +#!/bin/sh +# +# Copyright (c) 2009 Greg Price +# + +test_description='git rebase -p should respect --onto + +In a rebase with --onto, we should rewrite all the commits that +aren'"'"'t on top of $ONTO, even if they are on top of $UPSTREAM. +' +. ./test-lib.sh + +. ../lib-rebase.sh + +# Set up branches like this: +# A1---B1---E1---F1---G1 +# \ \ / +# \ \--C1---D1--/ +# H1 + +test_expect_success 'setup' ' + test_commit A1 && + test_commit B1 && + test_commit C1 && + test_commit D1 && + git reset --hard B1 && + test_commit E1 && + test_commit F1 && + test_merge G1 D1 && + git reset --hard A1 && + test_commit H1 +' + +# Now rebase merge G1 from both branches' base B1, both should move: +# A1---B1---E1---F1---G1 +# \ \ / +# \ \--C1---D1--/ +# \ +# H1---E2---F2---G2 +# \ / +# \--C2---D2--/ + +test_expect_success 'rebase from B1 onto H1' ' + git checkout G1 && + git rebase -p --onto H1 B1 && + test "$(git rev-parse HEAD^1^1^1)" = "$(git rev-parse H1)" && + test "$(git rev-parse HEAD^2^1^1)" = "$(git rev-parse H1)" +' + +# On the other hand if rebase from E1 which is within one branch, +# then the other branch stays: +# A1---B1---E1---F1---G1 +# \ \ / +# \ \--C1---D1--/ +# \ \ +# H1-----F3-----G3 + +test_expect_success 'rebase from E1 onto H1' ' + git checkout G1 && + git rebase -p --onto H1 E1 && + test "$(git rev-parse HEAD^1^1)" = "$(git rev-parse H1)" && + test "$(git rev-parse HEAD^2)" = "$(git rev-parse D1)" +' + +# And the same if we rebase from a commit in the second-parent branch. +# A1---B1---E1---F1----G1 +# \ \ \ / +# \ \--C1---D1-\-/ +# \ \ +# H1------D3------G4 + +test_expect_success 'rebase from C1 onto H1' ' + git checkout G1 && + git rev-list --first-parent --pretty=oneline C1..G1 && + git rebase -p --onto H1 C1 && + test "$(git rev-parse HEAD^2^1)" = "$(git rev-parse H1)" && + test "$(git rev-parse HEAD^1)" = "$(git rev-parse F1)" +' + +test_done From 55d5d5bab7c3f9ab6310b9cf436a7935d7d32165 Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 22 Jul 2009 14:48:28 -0700 Subject: [PATCH 43/95] combine-diff.c: fix performance problem when folding common deleted lines MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit For a deleted line in a patch with the parent we are looking at, the append_lost() function finds the same line among a run of lines that were deleted from the same location by patches from parents we previously checked. This is so that patches with two parents @@ -1,4 +1,3 @@ @@ -1,4 +1,3 @@ one one -two -two three three -quatro -fyra +four +four can be coalesced into this sequence, reusing one line that describes the removal of "two" for both parents. @@@ -1,4 -1,4 +1,3 @@@ one --two three - quatro -frya ++four While reading the second patch (that removes "two" and then "fyra"), after finding where removal of the "two" matches, we need to find existing removal of "fyra" (if exists) in the removal list, but the match has to happen after all the existing matches (in this case "two"). The code used a naïve O(n^2) algorithm to compute this by scanning the whole removal list over and over again. This patch remembers where the next scan should be started in the existing removal list to avoid this. Noticed by Linus Torvalds. Signed-off-by: Junio C Hamano --- combine-diff.c | 13 +++++-------- 1 file changed, 5 insertions(+), 8 deletions(-) diff --git a/combine-diff.c b/combine-diff.c index 60d03676bb..b82f46cc60 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -80,6 +80,7 @@ struct lline { /* Lines surviving in the merge result */ struct sline { struct lline *lost_head, **lost_tail; + struct lline *next_lost; char *bol; int len; /* bit 0 up to (N-1) are on if the parent has this line (i.e. @@ -121,18 +122,12 @@ static void append_lost(struct sline *sline, int n, const char *line, int len) /* Check to see if we can squash things */ if (sline->lost_head) { - struct lline *last_one = NULL; - /* We cannot squash it with earlier one */ - for (lline = sline->lost_head; - lline; - lline = lline->next) - if (lline->parent_map & this_mask) - last_one = lline; - lline = last_one ? last_one->next : sline->lost_head; + lline = sline->next_lost; while (lline) { if (lline->len == len && !memcmp(lline->line, line, len)) { lline->parent_map |= this_mask; + sline->next_lost = lline->next; return; } lline = lline->next; @@ -147,6 +142,7 @@ static void append_lost(struct sline *sline, int n, const char *line, int len) lline->line[len] = 0; *sline->lost_tail = lline; sline->lost_tail = &lline->next; + sline->next_lost = NULL; } struct combine_diff_state { @@ -187,6 +183,7 @@ static void consume_line(void *state_, char *line, unsigned long len) xcalloc(state->num_parent, sizeof(unsigned long)); state->sline[state->nb-1].p_lno[state->n] = state->ob; + state->lost_bucket->next_lost = state->lost_bucket->lost_head; return; } if (!state->lost_bucket) From b810cbbde9232cbe9a3841edccc5b606bbd3a82e Mon Sep 17 00:00:00 2001 From: Junio C Hamano Date: Wed, 22 Jul 2009 14:48:29 -0700 Subject: [PATCH 44/95] diff --cc: a lost line at the beginning of the file is shown incorrectly When combine-diff inspected the diff from one parent to the merge result, it misinterpreted a header in the form @@ -l,k +0,0 @@. This hunk header means that K lines were removed from the beginning of the file, so the lost lines must be queued to the sline that represents the first line of the merge result, but we incremented our pointer incorrectly and ended up queuing it to the second line, which in turn made the lossage appear _after_ the first line. Signed-off-by: Junio C Hamano --- combine-diff.c | 16 ++++---- t/t4038-diff-combined.sh | 84 ++++++++++++++++++++++++++++++++++++++++ 2 files changed, 93 insertions(+), 7 deletions(-) create mode 100755 t/t4038-diff-combined.sh diff --git a/combine-diff.c b/combine-diff.c index b82f46cc60..1a6f9d1df5 100644 --- a/combine-diff.c +++ b/combine-diff.c @@ -164,20 +164,22 @@ static void consume_line(void *state_, char *line, unsigned long len) &state->nb, &state->nn)) return; state->lno = state->nb; - if (!state->nb) - /* @@ -1,2 +0,0 @@ to remove the - * first two lines... - */ - state->nb = 1; - if (state->nn == 0) + if (state->nn == 0) { /* @@ -X,Y +N,0 @@ removed Y lines * that would have come *after* line N * in the result. Our lost buckets hang * to the line after the removed lines, + * + * Note that this is correct even when N == 0, + * in which case the hunk removes the first + * line in the file. */ state->lost_bucket = &state->sline[state->nb]; - else + if (!state->nb) + state->nb = 1; + } else { state->lost_bucket = &state->sline[state->nb-1]; + } if (!state->sline[state->nb-1].p_lno) state->sline[state->nb-1].p_lno = xcalloc(state->num_parent, diff --git a/t/t4038-diff-combined.sh b/t/t4038-diff-combined.sh new file mode 100755 index 0000000000..2cf7e01ac2 --- /dev/null +++ b/t/t4038-diff-combined.sh @@ -0,0 +1,84 @@ +#!/bin/sh + +test_description='combined diff' + +. ./test-lib.sh + +setup_helper () { + one=$1 branch=$2 side=$3 && + + git branch $side $branch && + for l in $one two three fyra + do + echo $l + done >file && + git add file && + test_tick && + git commit -m $branch && + git checkout $side && + for l in $one two three quatro + do + echo $l + done >file && + git add file && + test_tick && + git commit -m $side && + test_must_fail git merge $branch && + for l in $one three four + do + echo $l + done >file && + git add file && + test_tick && + git commit -m "merge $branch into $side" +} + +verify_helper () { + it=$1 && + + # Ignore lines that were removed only from the other parent + sed -e ' + 1,/^@@@/d + /^ -/d + s/^\(.\)./\1/ + ' "$it" >"$it.actual.1" && + sed -e ' + 1,/^@@@/d + /^- /d + s/^.\(.\)/\1/ + ' "$it" >"$it.actual.2" && + + git diff "$it^" "$it" -- | sed -e '1,/^@@/d' >"$it.expect.1" && + test_cmp "$it.expect.1" "$it.actual.1" && + + git diff "$it^2" "$it" -- | sed -e '1,/^@@/d' >"$it.expect.2" && + test_cmp "$it.expect.2" "$it.actual.2" +} + +test_expect_success setup ' + >file && + git add file && + test_tick && + git commit -m initial && + + git branch withone && + git branch sansone && + + git checkout withone && + setup_helper one withone sidewithone && + + git checkout sansone && + setup_helper "" sansone sidesansone +' + +test_expect_success 'check combined output (1)' ' + git show sidewithone -- >sidewithone && + verify_helper sidewithone +' + +test_expect_failure 'check combined output (2)' ' + git show sidesansone -- >sidesansone && + verify_helper sidesansone +' + +test_done From 735c674416b87505400fcf738fd3a38b52f0eccb Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?SZEDER=20G=C3=A1bor?= Date: Wed, 22 Jul 2009 19:24:38 -0500 Subject: [PATCH 45/95] Trailing whitespace and no newline fix MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit If a patch adds a new line to the end of a file and this line ends with one trailing whitespace character and has no newline, then '--whitespace=fix' currently does not remove that trailing whitespace. This patch fixes this by removing the check for trailing whitespace at the end of the line at a hardcoded offset which does not take the eventual absence of newline into account. Signed-off-by: SZEDER Gábor Signed-off-by: Junio C Hamano --- t/t4124-apply-ws-rule.sh | 18 ++++++++++++++++++ ws.c | 5 ++--- 2 files changed, 20 insertions(+), 3 deletions(-) diff --git a/t/t4124-apply-ws-rule.sh b/t/t4124-apply-ws-rule.sh index f83322e513..5698a9a736 100755 --- a/t/t4124-apply-ws-rule.sh +++ b/t/t4124-apply-ws-rule.sh @@ -148,4 +148,22 @@ do done done +create_patch () { + sed -e "s/_/ /" <<-\EOF + diff --git a/target b/target + index e69de29..8bd6648 100644 + --- a/target + +++ b/target + @@ -0,0 +1 @@ + +A line with trailing whitespace and no newline_ + \ No newline at end of file + EOF +} + +test_expect_success 'trailing whitespace & no newline at the end of file' ' + >target && + create_patch | git apply --whitespace=fix - && + grep "newline$" target +' + test_done diff --git a/ws.c b/ws.c index 819c797cf6..8d855b7fd5 100644 --- a/ws.c +++ b/ws.c @@ -261,9 +261,8 @@ int ws_fix_copy(char *dst, const char *src, int len, unsigned ws_rule, int *erro /* * Strip trailing whitespace */ - if ((ws_rule & WS_TRAILING_SPACE) && - (2 <= len && isspace(src[len-2]))) { - if (src[len - 1] == '\n') { + if (ws_rule & WS_TRAILING_SPACE) { + if (1 < len && src[len - 1] == '\n') { add_nl_to_tail = 1; len--; if (1 < len && src[len - 1] == '\r') { From a1142892fd505c304e2e825902bf5d7a38044e87 Mon Sep 17 00:00:00 2001 From: Brandon Casey Date: Tue, 21 Jul 2009 15:23:06 -0500 Subject: [PATCH 46/95] configure.ac: rework/fix the NEEDS_RESOLV and NEEDS_LIBGEN tests The "action" parameters for these two tests were supplied incorrectly for the way the tests were implemented. The tests check whether a program which calls hstrerror() or basename() successfully links when -lresolv or -lgen are used, respectively. A successful linking would result in NEEDS_RESOLV or NEEDS_LIBGEN being unset, and failure would result in setting the respective variable. Aside from that issue, the tests did not handle the case where neither library was necessary for accessing the functions in question. So solve both of these issues by re-working the two tests so that their form is like the NEEDS_SOCKET test which attempts to link with just the c library, and if it fails then assumes that the additional library is necessary and sets the appropriate variable. Also an entry in the config.mak.in file is necessary for the NEEDS_LIBGEN variable to appear in the config.mak.autogen file with the value assigned by the configure script. Without it, the generated shell script would contain a snippet like this: for ac_lib in ; do ... which is incorrect. Signed-off-by: Brandon Casey Signed-off-by: Junio C Hamano --- config.mak.in | 1 + configure.ac | 4 ++-- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/config.mak.in b/config.mak.in index dd60451318..67b12f73a1 100644 --- a/config.mak.in +++ b/config.mak.in @@ -34,6 +34,7 @@ NO_LIBGEN_H=@NO_LIBGEN_H@ NEEDS_LIBICONV=@NEEDS_LIBICONV@ NEEDS_SOCKET=@NEEDS_SOCKET@ NEEDS_RESOLV=@NEEDS_RESOLV@ +NEEDS_LIBGEN=@NEEDS_LIBGEN@ NO_SYS_SELECT_H=@NO_SYS_SELECT_H@ NO_D_INO_IN_DIRENT=@NO_D_INO_IN_DIRENT@ NO_D_TYPE_IN_DIRENT=@NO_D_TYPE_IN_DIRENT@ diff --git a/configure.ac b/configure.ac index 74d0af52a5..ba44cf248f 100644 --- a/configure.ac +++ b/configure.ac @@ -479,13 +479,13 @@ test -n "$NEEDS_SOCKET" && LIBS="$LIBS -lsocket" # Define NEEDS_RESOLV if linking with -lnsl and/or -lsocket is not enough. # Notably on Solaris hstrerror resides in libresolv and on Solaris 7 # inet_ntop and inet_pton additionally reside there. -AC_CHECK_LIB([resolv], [hstrerror], +AC_CHECK_LIB([c], [hstrerror], [NEEDS_RESOLV=], [NEEDS_RESOLV=YesPlease]) AC_SUBST(NEEDS_RESOLV) test -n "$NEEDS_RESOLV" && LIBS="$LIBS -lresolv" -AC_CHECK_LIB([gen], [basename], +AC_CHECK_LIB([c], [basename], [NEEDS_LIBGEN=], [NEEDS_LIBGEN=YesPlease]) AC_SUBST(NEEDS_LIBGEN) From 65180c6618653acf7642fc2f2d4a93afacb489d8 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 22 Jul 2009 23:39:30 +0200 Subject: [PATCH 47/95] List send-email config options in config.txt. Also mention deprecated aliases that do not appear in the send-email manpage. Signed-off-by: Yann Dirson Signed-off-by: Junio C Hamano --- Documentation/config.txt | 44 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 44 insertions(+) diff --git a/Documentation/config.txt b/Documentation/config.txt index cb6832b4e8..6857d2f4a9 100644 --- a/Documentation/config.txt +++ b/Documentation/config.txt @@ -1387,6 +1387,50 @@ rerere.enabled:: default enabled if you create `rr-cache` directory under `$GIT_DIR`, but can be disabled by setting this option to false. +sendemail.identity:: + A configuration identity. When given, causes values in the + 'sendemail.' subsection to take precedence over + values in the 'sendemail' section. The default identity is + the value of 'sendemail.identity'. + +sendemail.smtpencryption:: + See linkgit:git-send-email[1] for description. Note that this + setting is not subject to the 'identity' mechanism. + +sendemail.smtpssl:: + Deprecated alias for 'sendemail.smtpencryption = ssl'. + +sendemail..*:: + Identity-specific versions of the 'sendemail.*' parameters + found below, taking precedence over those when the this + identity is selected, through command-line or + 'sendemail.identity'. + +sendemail.aliasesfile:: +sendemail.aliasfiletype:: +sendemail.bcc:: +sendemail.cc:: +sendemail.cccmd:: +sendemail.chainreplyto:: +sendemail.confirm:: +sendemail.envelopesender:: +sendemail.from:: +sendemail.multiedit:: +sendemail.signedoffbycc:: +sendemail.smtppass:: +sendemail.suppresscc:: +sendemail.suppressfrom:: +sendemail.to:: +sendemail.smtpserver:: +sendemail.smtpserverport:: +sendemail.smtpuser:: +sendemail.thread:: +sendemail.validate:: + See linkgit:git-send-email[1] for description. + +sendemail.signedoffcc:: + Deprecated alias for 'sendemail.signedoffbycc'. + showbranch.default:: The default set of branches for linkgit:git-show-branch[1]. See linkgit:git-show-branch[1]. From f693b7e9a5b7b009e71389310322fe864cd16046 Mon Sep 17 00:00:00 2001 From: Yann Dirson Date: Wed, 22 Jul 2009 23:39:31 +0200 Subject: [PATCH 48/95] Improve doc for format-patch threading options. This hopefully makes the relationship between threading options of format-patch and send-email easier to grasp. Signed-off-by: Yann Dirson Signed-off-by: Junio C Hamano --- Documentation/git-format-patch.txt | 22 +++++++++++++++------- Documentation/git-send-email.txt | 21 ++++++++++++++++----- 2 files changed, 31 insertions(+), 12 deletions(-) diff --git a/Documentation/git-format-patch.txt b/Documentation/git-format-patch.txt index 6f1fc80119..687e667598 100644 --- a/Documentation/git-format-patch.txt +++ b/Documentation/git-format-patch.txt @@ -10,7 +10,7 @@ SYNOPSIS -------- [verse] 'git format-patch' [-k] [(-o|--output-directory) | --stdout] - [--thread[=