[PATCH] git-completion.bash: Silence not a valid object errors
Trying to complete the command git show master:./file would cause a Not a valid object name error to be output on standard error. Silence the error so it won't appear on the command line. Signed-off-by: Dylan Smith dylan.ah.sm...@gmail.com --- 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 0b77eb1..d4c7bfe 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -397,7 +397,7 @@ __git_complete_revlist_file () *) pfx=$ref:$pfx ;; esac - __gitcomp_nl $(git --git-dir=$(__gitdir) ls-tree $ls \ + __gitcomp_nl $(git --git-dir=$(__gitdir) ls-tree $ls 2/dev/null \ | sed '/^100... blob /{ s,^.*,, s,$, , -- 1.7.9.5 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 1/3] fetch: add --unshallow for turning shallow repo into complete one
The user can do --depth=2147483647 (*) for restoring complete repo now. But it's hard to remember. Any other numbers larger than the longest commit chain in the repository would also do, but some guessing may be involved. Make easy-to-remember --unshallow an alias for --depth=2147483647. Make upload-pack recognize this special number as infinite depth. The effect is essentially the same as before, except that upload-pack is more efficient because it does not have to traverse to the bottom anymore. The chance of a user actually wanting exactly 2147483647 commits depth, not infinite, on a repository with a history that long, is probably too small to consider. The client can learn to add or subtract one commit to avoid the special treatment when that actually happens. (*) This is the largest positive number a 32-bit signed integer can contain. JGit and older C Git store depth as int so both are OK with this number. Dulwich does not support shallow clone. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- On Fri, Jan 11, 2013 at 10:55 AM, Junio C Hamano gits...@pobox.com wrote: I think no shallow makes sense in a much more important way than infinite depth, and this patch is a good idea for a reason entirely different from the justification your log message makes ;-) [snip] Calling the option --no-shallow (or even better, --unshallow, meaning make it a repository that is no longer shallow) makes it crystal clear that the option is about wiping away the shallowness. Of course, the result has to contain an untruncted history, but that is a mere side effect and an implementation detail from the end user's point of view. Very well said. --unshallow it is. Documentation/fetch-options.txt | 4 Documentation/git-fetch-pack.txt| 2 ++ Documentation/technical/shallow.txt | 3 +++ builtin/fetch.c | 17 - commit.h| 3 +++ t/t5500-fetch-pack.sh | 20 upload-pack.c | 13 ++--- 7 files changed, 58 insertions(+), 4 deletions(-) diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 6e98bdf..8a0449c 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -13,6 +13,10 @@ to the specified number of commits from the tip of each remote branch history. Tags for the deepened commits are not fetched. +--unshallow:: + Convert a shallow repository to a complete one, removing all + the limitations imposed by shallow repositories. + ifndef::git-pull[] --dry-run:: Show what would be done, without making any changes. diff --git a/Documentation/git-fetch-pack.txt b/Documentation/git-fetch-pack.txt index 8c75120..b81e90d 100644 --- a/Documentation/git-fetch-pack.txt +++ b/Documentation/git-fetch-pack.txt @@ -84,6 +84,8 @@ be in a separate packet, and the list must end with a flush packet. --depth=n:: Limit fetching to ancestor-chains not longer than n. + 'git-upload-pack' treats the special depth 2147483647 as + infinite even if there is an ancestor-chain that long. --no-progress:: Do not show the progress. diff --git a/Documentation/technical/shallow.txt b/Documentation/technical/shallow.txt index 0502a54..ea2f69f 100644 --- a/Documentation/technical/shallow.txt +++ b/Documentation/technical/shallow.txt @@ -53,3 +53,6 @@ It also writes an appropriate $GIT_DIR/shallow. You can deepen a shallow repository with git-fetch --depth 20 repo branch, which will fetch branch from repo, but stop at depth 20, updating $GIT_DIR/shallow. + +The special depth 2147483647 (or 0x7fff, the largest positive +number a signed 32-bit integer can contain) means infinite depth. diff --git a/builtin/fetch.c b/builtin/fetch.c index 4b5a898..2b15ced 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -32,7 +32,7 @@ enum { static int all, append, dry_run, force, keep, multiple, prune, update_head_ok, verbosity; static int progress = -1, recurse_submodules = RECURSE_SUBMODULES_DEFAULT; -static int tags = TAGS_DEFAULT; +static int tags = TAGS_DEFAULT, unshallow; static const char *depth; static const char *upload_pack; static struct strbuf default_rla = STRBUF_INIT; @@ -82,6 +82,9 @@ static struct option builtin_fetch_options[] = { OPT_BOOL(0, progress, progress, N_(force progress reporting)), OPT_STRING(0, depth, depth, N_(depth), N_(deepen history of shallow clone)), + { OPTION_SET_INT, 0, unshallow, unshallow, NULL, + N_(convert to a complete repository), + PARSE_OPT_NONEG | PARSE_OPT_NOARG, NULL, 1 }, { OPTION_STRING, 0, submodule-prefix, submodule_prefix, N_(dir), N_(prepend this to submodule path output), PARSE_OPT_HIDDEN }, { OPTION_STRING, 0, recurse-submodules-default, @@ -970,6 +973,18 @@ int cmd_fetch(int argc,
[PATCH v2 2/3] upload-pack: fix off-by-one depth calculation in shallow clone
get_shallow_commits() is used to determine the cut points at a given depth (i.e. the number of commits in a chain that the user likes to get). However we count current depth up to the commit commit but we do the cutting at its parents (i.e. current depth + 1). This makes upload-pack always return one commit more than requested. This patch fixes it. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- Fixed the command chain in t5500. shallow.c | 8 +++- t/t5500-fetch-pack.sh | 25 +++-- 2 files changed, 26 insertions(+), 7 deletions(-) diff --git a/shallow.c b/shallow.c index a0363de..6be915f 100644 --- a/shallow.c +++ b/shallow.c @@ -72,8 +72,14 @@ struct commit_list *get_shallow_commits(struct object_array *heads, int depth, } if (parse_commit(commit)) die(invalid commit); - commit-object.flags |= not_shallow_flag; cur_depth++; + if (cur_depth = depth) { + commit_list_insert(commit, result); + commit-object.flags |= shallow_flag; + commit = NULL; + continue; + } + commit-object.flags |= not_shallow_flag; for (p = commit-parents, commit = NULL; p; p = p-next) { if (!p-item-util) { int *pointer = xmalloc(sizeof(int)); diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh index 426027e..354d32c 100755 --- a/t/t5500-fetch-pack.sh +++ b/t/t5500-fetch-pack.sh @@ -130,16 +130,25 @@ test_expect_success 'single given branch clone' ' test_must_fail git --git-dir=branch-a/.git rev-parse origin/B ' +test_expect_success 'clone shallow depth 1' ' + git clone --no-single-branch --depth 1 file://$(pwd)/. shallow0 + test `git --git-dir=shallow0/.git rev-list --count HEAD` = 1 +' + test_expect_success 'clone shallow' ' git clone --no-single-branch --depth 2 file://$(pwd)/. shallow ' +test_expect_success 'clone shallow depth count' ' + test `git --git-dir=shallow/.git rev-list --count HEAD` = 2 +' + test_expect_success 'clone shallow object count' ' ( cd shallow git count-objects -v ) count.shallow - grep ^in-pack: 18 count.shallow + grep ^in-pack: 12 count.shallow ' test_expect_success 'clone shallow object count (part 2)' ' @@ -256,12 +265,16 @@ test_expect_success 'additional simple shallow deepenings' ' ) ' +test_expect_success 'clone shallow depth count' ' + test `git --git-dir=shallow/.git rev-list --count HEAD` = 11 +' + test_expect_success 'clone shallow object count' ' ( cd shallow git count-objects -v ) count.shallow - grep ^count: 52 count.shallow + grep ^count: 55 count.shallow ' test_expect_success 'fetch --no-shallow on full repo' ' @@ -293,7 +306,7 @@ test_expect_success 'clone shallow object count' ' cd shallow2 git count-objects -v ) count.shallow2 - grep ^in-pack: 6 count.shallow2 + grep ^in-pack: 3 count.shallow2 ' test_expect_success 'clone shallow with --branch' ' @@ -301,7 +314,7 @@ test_expect_success 'clone shallow with --branch' ' ' test_expect_success 'clone shallow object count' ' - echo in-pack: 6 count3.expected + echo in-pack: 3 count3.expected GIT_DIR=shallow3/.git git count-objects -v | grep ^in-pack count3.actual test_cmp count3.expected count3.actual @@ -330,7 +343,7 @@ EOF GIT_DIR=shallow6/.git git tag -l taglist.actual test_cmp taglist.expected taglist.actual - echo in-pack: 7 count6.expected + echo in-pack: 4 count6.expected GIT_DIR=shallow6/.git git count-objects -v | grep ^in-pack count6.actual test_cmp count6.expected count6.actual @@ -345,7 +358,7 @@ EOF GIT_DIR=shallow7/.git git tag -l taglist.actual test_cmp taglist.expected taglist.actual - echo in-pack: 7 count7.expected + echo in-pack: 4 count7.expected GIT_DIR=shallow7/.git git count-objects -v | grep ^in-pack count7.actual test_cmp count7.expected count7.actual -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] fetch: elaborate --depth action
--depth is explained as deepen, but the way it's applied, it can shorten the history as well. Keen users may have noticed the implication by the phrase the specified number of commits from the tip of each remote branch. Put shorten in the description to make it clearer. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- Documentation/fetch-options.txt | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Documentation/fetch-options.txt b/Documentation/fetch-options.txt index 8a0449c..fb92b02 100644 --- a/Documentation/fetch-options.txt +++ b/Documentation/fetch-options.txt @@ -8,7 +8,7 @@ option old data in `.git/FETCH_HEAD` will be overwritten. --depth=depth:: - Deepen the history of a 'shallow' repository created by + Deepen or shorten the history of a 'shallow' repository created by `git clone` with `--depth=depth` option (see linkgit:git-clone[1]) to the specified number of commits from the tip of each remote branch history. Tags for the deepened commits are not fetched. -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git checkout bug on Win7 x64
On Fri, 11 Jan 2013 11:30:01 +0400 Ishayahu Lastov meoc...@mail.ru wrote: [...] As I understand after last git checkout in git status I should see that I gave no changes. It looks like an bug, isn't it? Looks like an EOL-conversion problem rather typical to Windows, see http://stackoverflow.com/a/2016426/720999 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: t7400 broken on pu (Mac OS X)
On Fri, Jan 11, 2013 at 12:58 AM, Junio C Hamano gits...@pobox.com wrote: I can see why it is wrong to let pathspec.raw be rewritten without making matching change to the containing pathspec, but I find it strange why it matters only on case-insensitive codepath. Yeah, I don't get it either. I can see that core.ignorecase exercises some more code, but still fail to see the link. I should get to the bottom of this and write some tests to for core.ignorecase-only code. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 03/19] reset.c: pass pathspec around instead of (prefix, argv) pair
On Fri, Jan 11, 2013 at 6:09 AM, Junio C Hamano gits...@pobox.com wrote: Or I could hold off nd/parse-pathspec if this series has a better chance of graduation first. Decision? I am greedy and want to have both ;-) Apparently I have no problems with your being greedy. There is no textual conflict between the two topics at the moment, but because the ultimate goal of your series is to remove all uses of the pathspec.raw[] field outside the implementation of pathspec matching, it might help to rename the field to _private_raw (or remove it), and either make get_pathspec() private or disappear, to ensure that the compiler will help us catching semantic conflicts with new users of it at a late stage of your series. There are still some uses for get_pathspec() and new call sites won't cause big problems because they would need init_pathspec() to convert get_pathspec() results to struct pathspec. I will rename raw[] though. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 02/21] Add parse_pathspec() that converts cmdline args to struct pathspec
Currently to fill a struct pathspec, we do: const char **paths; paths = get_pathspec(prefix, argv); ... init_pathspec(pathspec, paths); paths can only carry bare strings, which loses information from command line arguments such as pathspec magic or the prefix part's length for each argument. parse_pathspec() is introduced to combine the two calls into one. The plan is gradually replace all get_pathspec() and init_pathspec() with parse_pathspec(). get_pathspec() now becomes a thin wrapper of parse_pathspec(). parse_pathspec() allows the caller to reject the pathspec magics that it does not support. When a new pathspec magic is introduced, we can enable it per command after making sure that all underlying code has no problem with the new magic. flags parameter is currently unused. But it would allow callers to pass certain instructions to parse_pathspec, for example forcing literal pathspec when no magic is used. With the introduction of parse_pathspec, there are now two functions that can initialize struct pathspec: init_pathspec and parse_pathspec. Any semantic changes in struct pathspec must be reflected in both functions. init_pathspec() will be phased out in favor of parse_pathspec(). Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- dir.c | 2 +- dir.h | 1 + setup.c | 99 + 3 files changed, 77 insertions(+), 25 deletions(-) diff --git a/dir.c b/dir.c index c391d46..31f0995 100644 --- a/dir.c +++ b/dir.c @@ -291,7 +291,7 @@ int match_pathspec_depth(const struct pathspec *ps, /* * Return the length of the simple part of a path match limiter. */ -static int simple_length(const char *match) +int simple_length(const char *match) { int len = -1; diff --git a/dir.h b/dir.h index f5c89e3..1d4888b 100644 --- a/dir.h +++ b/dir.h @@ -66,6 +66,7 @@ struct dir_struct { #define MATCHED_RECURSIVELY 1 #define MATCHED_FNMATCH 2 #define MATCHED_EXACTLY 3 +extern int simple_length(const char *match); extern char *common_prefix(const char **pathspec); extern int match_pathspec(const char **pathspec, const char *name, int namelen, int prefix, char *seen); extern int match_pathspec_depth(const struct pathspec *pathspec, diff --git a/setup.c b/setup.c index f108c4b..4fcdae6 100644 --- a/setup.c +++ b/setup.c @@ -174,7 +174,7 @@ static struct pathspec_magic { /* * Take an element of a pathspec and check for magic signatures. - * Append the result to the prefix. + * Append the result to the prefix. Return the magic bitmap. * * For now, we only parse the syntax and throw out anything other than * top magic. @@ -185,7 +185,10 @@ static struct pathspec_magic { * the prefix part must always match literally, and a single stupid * string cannot express such a case. */ -static const char *prefix_pathspec(const char *prefix, int prefixlen, const char *elt) +static unsigned prefix_pathspec(struct pathspec_item *item, + const char **raw, + const char *prefix, int prefixlen, + const char *elt) { unsigned magic = 0; const char *copyfrom = elt; @@ -241,39 +244,87 @@ static const char *prefix_pathspec(const char *prefix, int prefixlen, const char } if (magic PATHSPEC_FROMTOP) - return xstrdup(copyfrom); + item-match = xstrdup(copyfrom); else - return prefix_path(prefix, prefixlen, copyfrom); + item-match = prefix_path(prefix, prefixlen, copyfrom); + *raw = item-match; + item-len = strlen(item-match); + item-nowildcard_len = simple_length(item-match); + return magic; } -const char **get_pathspec(const char *prefix, const char **pathspec) +static int pathspec_item_cmp(const void *a_, const void *b_) { - const char *entry = *pathspec; - const char **src, **dst; - int prefixlen; + struct pathspec_item *a, *b; - if (!prefix !entry) - return NULL; + a = (struct pathspec_item *)a_; + b = (struct pathspec_item *)b_; + return strcmp(a-match, b-match); +} + +/* + * Given command line arguments and a prefix, convert the input to + * pathspec. die() if any magic other than ones in magic_mask. + */ +static void parse_pathspec(struct pathspec *pathspec, + unsigned magic_mask, unsigned flags, + const char *prefix, const char **argv) +{ + struct pathspec_item *item; + const char *entry = *argv; + int i, n, prefixlen; + + memset(pathspec, 0, sizeof(*pathspec)); + + /* No arguments, no prefix - no pathspec */ + if (!entry !prefix) + return; + /* No arguments with prefix - prefix pathspec */ if (!entry) { - static const char *spec[2]; - spec[0] = prefix; - spec[1] = NULL; -
[PATCH v2 03/21] Export parse_pathspec() and convert some get_pathspec() calls
These call sites follow the pattern: paths = get_pathspec(prefix, argv); init_pathspec(pathspec, paths); which can be converted into a single parse_pathspec() call. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/grep.c | 4 +--- builtin/ls-tree.c | 2 +- builtin/update-index.c | 3 +-- cache.h| 6 ++ revision.c | 4 ++-- setup.c| 6 +++--- 6 files changed, 14 insertions(+), 11 deletions(-) diff --git a/builtin/grep.c b/builtin/grep.c index 0e1b6c8..705f9ff 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -630,7 +630,6 @@ int cmd_grep(int argc, const char **argv, const char *prefix) const char *show_in_pager = NULL, *default_pager = dummy; struct grep_opt opt; struct object_array list = OBJECT_ARRAY_INIT; - const char **paths = NULL; struct pathspec pathspec; struct string_list path_list = STRING_LIST_INIT_NODUP; int i; @@ -857,8 +856,7 @@ int cmd_grep(int argc, const char **argv, const char *prefix) verify_filename(prefix, argv[j], j == i); } - paths = get_pathspec(prefix, argv + i); - init_pathspec(pathspec, paths); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv + i); pathspec.max_depth = opt.max_depth; pathspec.recursive = 1; diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c index fb76e38..a78ba53 100644 --- a/builtin/ls-tree.c +++ b/builtin/ls-tree.c @@ -166,7 +166,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix) if (get_sha1(argv[0], sha1)) die(Not a valid object name %s, argv[0]); - init_pathspec(pathspec, get_pathspec(prefix, argv + 1)); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv + 1); for (i = 0; i pathspec.nr; i++) pathspec.items[i].nowildcard_len = pathspec.items[i].len; pathspec.has_wildcard = 0; diff --git a/builtin/update-index.c b/builtin/update-index.c index ada1dff..6728e59 100644 --- a/builtin/update-index.c +++ b/builtin/update-index.c @@ -546,10 +546,9 @@ static int do_reupdate(int ac, const char **av, */ int pos; int has_head = 1; - const char **paths = get_pathspec(prefix, av + 1); struct pathspec pathspec; - init_pathspec(pathspec, paths); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, av + 1); if (read_ref(HEAD, head_sha1)) /* If there is no HEAD, that means it is an initial diff --git a/cache.h b/cache.h index 9304d91..e52365d 100644 --- a/cache.h +++ b/cache.h @@ -473,6 +473,9 @@ extern int index_name_is_other(const struct index_state *, const char *, int); extern int ie_match_stat(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); extern int ie_modified(const struct index_state *, struct cache_entry *, struct stat *, unsigned int); +/* Pathspec magic */ +#define PATHSPEC_FROMTOP(10) + struct pathspec { const char **raw; /* get_pathspec() result, not freed by free_pathspec() */ int nr; @@ -487,6 +490,9 @@ struct pathspec { }; extern int init_pathspec(struct pathspec *, const char **); +extern void parse_pathspec(struct pathspec *pathspec, unsigned magic, + unsigned flags, const char *prefix, + const char **args); extern void free_pathspec(struct pathspec *); extern int ce_path_match(const struct cache_entry *ce, const struct pathspec *pathspec); diff --git a/revision.c b/revision.c index 95d21e6..a044242 100644 --- a/revision.c +++ b/revision.c @@ -1851,8 +1851,8 @@ int setup_revisions(int argc, const char **argv, struct rev_info *revs, struct s */ ALLOC_GROW(prune_data.path, prune_data.nr+1, prune_data.alloc); prune_data.path[prune_data.nr++] = NULL; - init_pathspec(revs-prune_data, - get_pathspec(revs-prefix, prune_data.path)); + parse_pathspec(revs-prune_data, PATHSPEC_FROMTOP, 0, + revs-prefix, prune_data.path); } if (revs-def == NULL) diff --git a/setup.c b/setup.c index 4fcdae6..6e960b9 100644 --- a/setup.c +++ b/setup.c @@ -266,9 +266,9 @@ static int pathspec_item_cmp(const void *a_, const void *b_) * Given command line arguments and a prefix, convert the input to * pathspec. die() if any magic other than ones in magic_mask. */ -static void parse_pathspec(struct pathspec *pathspec, - unsigned magic_mask, unsigned flags, - const char *prefix, const char **argv) +void parse_pathspec(struct pathspec *pathspec, + unsigned magic_mask, unsigned flags, + const char *prefix, const char **argv) { struct pathspec_item *item; const char *entry = *argv; -- 1.8.0.rc2.23.g1fb49df -- To
[PATCH v2 04/21] clean: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/clean.c | 20 ++-- 1 file changed, 10 insertions(+), 10 deletions(-) diff --git a/builtin/clean.c b/builtin/clean.c index 69c1cda..788ad8c 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -42,7 +42,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) int rm_flags = REMOVE_DIR_KEEP_NESTED_GIT; struct strbuf directory = STRBUF_INIT; struct dir_struct dir; - static const char **pathspec; + struct pathspec pathspec; struct strbuf buf = STRBUF_INIT; struct string_list exclude_list = STRING_LIST_INIT_NODUP; const char *qname; @@ -101,12 +101,12 @@ int cmd_clean(int argc, const char **argv, const char *prefix) add_exclude(exclude_list.items[i].string, , 0, dir.exclude_list[EXC_CMDL]); - pathspec = get_pathspec(prefix, argv); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); - fill_directory(dir, pathspec); + fill_directory(dir, pathspec.raw); - if (pathspec) - seen = xmalloc(argc 0 ? argc : 1); + if (pathspec.nr) + seen = xmalloc(pathspec.nr); for (i = 0; i dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; @@ -141,10 +141,10 @@ int cmd_clean(int argc, const char **argv, const char *prefix) if (lstat(ent-name, st)) continue; - if (pathspec) { - memset(seen, 0, argc 0 ? argc : 1); - matches = match_pathspec(pathspec, ent-name, len, -0, seen); + if (pathspec.nr) { + memset(seen, 0, pathspec.nr); + matches = match_pathspec_depth(pathspec, ent-name, len, + 0, seen); } if (S_ISDIR(st.st_mode)) { @@ -169,7 +169,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) } strbuf_reset(directory); } else { - if (pathspec !matches) + if (pathspec.nr !matches) continue; qname = quote_path_relative(ent-name, -1, buf, prefix); if (show_only) { -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 05/21] commit: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/commit.c | 18 +- cache.h | 3 +++ setup.c | 3 +++ 3 files changed, 15 insertions(+), 9 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index d6dd3df..444ae1d 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -277,17 +277,17 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, { int fd; struct string_list partial; - const char **pathspec = NULL; + struct pathspec pathspec; char *old_index_env = NULL; int refresh_flags = REFRESH_QUIET; if (is_status) refresh_flags |= REFRESH_UNMERGED; + parse_pathspec(pathspec, PATHSPEC_FROMTOP, + PATHSPEC_EMPTY_MATCH_ALL, + prefix, argv); - if (*argv) - pathspec = get_pathspec(prefix, argv); - - if (read_cache_preload(pathspec) 0) + if (read_cache_preload(pathspec.raw) 0) die(_(index file corrupt)); if (interactive) { @@ -329,9 +329,9 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, * (A) if all goes well, commit the real index; * (B) on failure, rollback the real index. */ - if (all || (also pathspec *pathspec)) { + if (all || (also pathspec.nr)) { fd = hold_locked_index(index_lock, 1); - add_files_to_cache(also ? prefix : NULL, pathspec, 0); + add_files_to_cache(also ? prefix : NULL, pathspec.raw, 0); refresh_cache_or_die(refresh_flags); update_main_cache_tree(WRITE_TREE_SILENT); if (write_cache(fd, active_cache, active_nr) || @@ -350,7 +350,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, * and create commit from the_index. * We still need to refresh the index here. */ - if (!only (!pathspec || !*pathspec)) { + if (!only !pathspec.nr) { fd = hold_locked_index(index_lock, 1); refresh_cache_or_die(refresh_flags); if (active_cache_changed) { @@ -395,7 +395,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, memset(partial, 0, sizeof(partial)); partial.strdup_strings = 1; - if (list_paths(partial, !current_head ? NULL : HEAD, prefix, pathspec)) + if (list_paths(partial, !current_head ? NULL : HEAD, prefix, pathspec.raw)) exit(1); discard_cache(); diff --git a/cache.h b/cache.h index e52365d..a3c316f 100644 --- a/cache.h +++ b/cache.h @@ -476,6 +476,9 @@ extern int ie_modified(const struct index_state *, struct cache_entry *, struct /* Pathspec magic */ #define PATHSPEC_FROMTOP(10) +/* Pathspec flags */ +#define PATHSPEC_EMPTY_MATCH_ALL (10) /* No args means match everything */ + struct pathspec { const char **raw; /* get_pathspec() result, not freed by free_pathspec() */ int nr; diff --git a/setup.c b/setup.c index 6e960b9..a26b6c0 100644 --- a/setup.c +++ b/setup.c @@ -280,6 +280,9 @@ void parse_pathspec(struct pathspec *pathspec, if (!entry !prefix) return; + if (!*argv (flags PATHSPEC_EMPTY_MATCH_ALL)) + return; + /* No arguments with prefix - prefix pathspec */ if (!entry) { static const char *raw[2]; -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 06/21] status: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/commit.c | 9 + wt-status.c | 17 +++-- wt-status.h | 2 +- 3 files changed, 13 insertions(+), 15 deletions(-) diff --git a/builtin/commit.c b/builtin/commit.c index 444ae1d..196dfab 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1205,11 +1205,12 @@ int cmd_status(int argc, const char **argv, const char *prefix) handle_untracked_files_arg(s); if (show_ignored_in_status) s.show_ignored_files = 1; - if (*argv) - s.pathspec = get_pathspec(prefix, argv); + parse_pathspec(s.pathspec, PATHSPEC_FROMTOP, + PATHSPEC_EMPTY_MATCH_ALL, + prefix, argv); - read_cache_preload(s.pathspec); - refresh_index(the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL); + read_cache_preload(s.pathspec.raw); + refresh_index(the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec.raw, NULL, NULL); fd = hold_locked_index(index_lock, 0); if (0 = fd) diff --git a/wt-status.c b/wt-status.c index 2a9658b..13e6aba 100644 --- a/wt-status.c +++ b/wt-status.c @@ -434,7 +434,7 @@ static void wt_status_collect_changes_worktree(struct wt_status *s) } rev.diffopt.format_callback = wt_status_collect_changed_cb; rev.diffopt.format_callback_data = s; - init_pathspec(rev.prune_data, s-pathspec); + rev.prune_data = s-pathspec; run_diff_files(rev, 0); } @@ -459,22 +459,20 @@ static void wt_status_collect_changes_index(struct wt_status *s) rev.diffopt.detect_rename = 1; rev.diffopt.rename_limit = 200; rev.diffopt.break_opt = 0; - init_pathspec(rev.prune_data, s-pathspec); + rev.prune_data = s-pathspec; run_diff_index(rev, 1); } static void wt_status_collect_changes_initial(struct wt_status *s) { - struct pathspec pathspec; int i; - init_pathspec(pathspec, s-pathspec); for (i = 0; i active_nr; i++) { struct string_list_item *it; struct wt_status_change_data *d; struct cache_entry *ce = active_cache[i]; - if (!ce_path_match(ce, pathspec)) + if (!ce_path_match(ce, s-pathspec)) continue; it = string_list_insert(s-change, ce-name); d = it-util; @@ -489,7 +487,6 @@ static void wt_status_collect_changes_initial(struct wt_status *s) else d-index_status = DIFF_STATUS_ADDED; } - free_pathspec(pathspec); } static void wt_status_collect_untracked(struct wt_status *s) @@ -505,11 +502,11 @@ static void wt_status_collect_untracked(struct wt_status *s) DIR_SHOW_OTHER_DIRECTORIES | DIR_HIDE_EMPTY_DIRECTORIES; setup_standard_excludes(dir); - fill_directory(dir, s-pathspec); + fill_directory(dir, s-pathspec.raw); for (i = 0; i dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; if (cache_name_is_other(ent-name, ent-len) - match_pathspec(s-pathspec, ent-name, ent-len, 0, NULL)) + match_pathspec_depth(s-pathspec, ent-name, ent-len, 0, NULL)) string_list_insert(s-untracked, ent-name); free(ent); } @@ -517,11 +514,11 @@ static void wt_status_collect_untracked(struct wt_status *s) if (s-show_ignored_files) { dir.nr = 0; dir.flags = DIR_SHOW_IGNORED | DIR_SHOW_OTHER_DIRECTORIES; - fill_directory(dir, s-pathspec); + fill_directory(dir, s-pathspec.raw); for (i = 0; i dir.nr; i++) { struct dir_entry *ent = dir.entries[i]; if (cache_name_is_other(ent-name, ent-len) - match_pathspec(s-pathspec, ent-name, ent-len, 0, NULL)) + match_pathspec_depth(s-pathspec, ent-name, ent-len, 0, NULL)) string_list_insert(s-ignored, ent-name); free(ent); } diff --git a/wt-status.h b/wt-status.h index 236b41f..dd8df41 100644 --- a/wt-status.h +++ b/wt-status.h @@ -44,7 +44,7 @@ struct wt_status { int is_initial; char *branch; const char *reference; - const char **pathspec; + struct pathspec pathspec; int verbose; int amend; enum commit_whence whence; -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 07/21] rerere: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/rerere.c | 6 +++--- rerere.c | 8 rerere.h | 4 +++- 3 files changed, 10 insertions(+), 8 deletions(-) diff --git a/builtin/rerere.c b/builtin/rerere.c index dc1708e..a573c4a 100644 --- a/builtin/rerere.c +++ b/builtin/rerere.c @@ -68,11 +68,11 @@ int cmd_rerere(int argc, const char **argv, const char *prefix) return rerere(flags); if (!strcmp(argv[0], forget)) { - const char **pathspec; + struct pathspec pathspec; if (argc 2) warning('git rerere forget' without paths is deprecated); - pathspec = get_pathspec(prefix, argv + 1); - return rerere_forget(pathspec); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv + 1); + return rerere_forget(pathspec); } fd = setup_rerere(merge_rr, flags); diff --git a/rerere.c b/rerere.c index a6a5cd5..f8ddf85 100644 --- a/rerere.c +++ b/rerere.c @@ -655,7 +655,7 @@ static int rerere_forget_one_path(const char *path, struct string_list *rr) return 0; } -int rerere_forget(const char **pathspec) +int rerere_forget(struct pathspec *pathspec) { int i, fd; struct string_list conflict = STRING_LIST_INIT_DUP; @@ -666,12 +666,12 @@ int rerere_forget(const char **pathspec) fd = setup_rerere(merge_rr, RERERE_NOAUTOUPDATE); - unmerge_cache(pathspec); + unmerge_cache(pathspec-raw); find_conflict(conflict); for (i = 0; i conflict.nr; i++) { struct string_list_item *it = conflict.items[i]; - if (!match_pathspec(pathspec, it-string, strlen(it-string), - 0, NULL)) + if (!match_pathspec_depth(pathspec, it-string, strlen(it-string), + 0, NULL)) continue; rerere_forget_one_path(it-string, merge_rr); } diff --git a/rerere.h b/rerere.h index 156d2aa..4aa06c9 100644 --- a/rerere.h +++ b/rerere.h @@ -3,6 +3,8 @@ #include string-list.h +struct pathspec; + #define RERERE_AUTOUPDATE 01 #define RERERE_NOAUTOUPDATE 02 @@ -16,7 +18,7 @@ extern void *RERERE_RESOLVED; extern int setup_rerere(struct string_list *, int); extern int rerere(int); extern const char *rerere_path(const char *hex, const char *file); -extern int rerere_forget(const char **); +extern int rerere_forget(struct pathspec *); extern int rerere_remaining(struct string_list *); extern void rerere_clear(struct string_list *); extern void rerere_gc(struct string_list *); -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 08/21] checkout: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/checkout.c | 30 ++ 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index a9c1b5a..da25298 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -45,7 +45,7 @@ struct checkout_opts { int branch_exists; const char *prefix; - const char **pathspec; + struct pathspec pathspec; struct tree *source_tree; }; @@ -256,39 +256,37 @@ static int checkout_paths(const struct checkout_opts *opts, if (opts-patch_mode) return run_add_interactive(revision, --patch=checkout, - opts-pathspec); + opts-pathspec.raw); lock_file = xcalloc(1, sizeof(struct lock_file)); newfd = hold_locked_index(lock_file, 1); - if (read_cache_preload(opts-pathspec) 0) + if (read_cache_preload(opts-pathspec.raw) 0) return error(_(corrupt index file)); if (opts-source_tree) - read_tree_some(opts-source_tree, opts-pathspec); + read_tree_some(opts-source_tree, opts-pathspec.raw); - for (pos = 0; opts-pathspec[pos]; pos++) - ; - ps_matched = xcalloc(1, pos); + ps_matched = xcalloc(1, opts-pathspec.nr); for (pos = 0; pos active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; if (opts-source_tree !(ce-ce_flags CE_UPDATE)) continue; - match_pathspec(opts-pathspec, ce-name, ce_namelen(ce), 0, ps_matched); + match_pathspec_depth(opts-pathspec, ce-name, ce_namelen(ce), 0, ps_matched); } - if (report_path_error(ps_matched, opts-pathspec, opts-prefix)) + if (report_path_error(ps_matched, opts-pathspec.raw, opts-prefix)) return 1; /* checkout -m path to recreate conflicted state */ if (opts-merge) - unmerge_cache(opts-pathspec); + unmerge_cache(opts-pathspec.raw); /* Any unmerged paths? */ for (pos = 0; pos active_nr; pos++) { struct cache_entry *ce = active_cache[pos]; - if (match_pathspec(opts-pathspec, ce-name, ce_namelen(ce), 0, NULL)) { + if (match_pathspec_depth(opts-pathspec, ce-name, ce_namelen(ce), 0, NULL)) { if (!ce_stage(ce)) continue; if (opts-force) { @@ -315,7 +313,7 @@ static int checkout_paths(const struct checkout_opts *opts, struct cache_entry *ce = active_cache[pos]; if (opts-source_tree !(ce-ce_flags CE_UPDATE)) continue; - if (match_pathspec(opts-pathspec, ce-name, ce_namelen(ce), 0, NULL)) { + if (match_pathspec_depth(opts-pathspec, ce-name, ce_namelen(ce), 0, NULL)) { if (!ce_stage(ce)) { errs |= checkout_entry(ce, state, NULL); continue; @@ -960,7 +958,7 @@ static int switch_unborn_to_new_branch(const struct checkout_opts *opts) static int checkout_branch(struct checkout_opts *opts, struct branch_info *new) { - if (opts-pathspec) + if (opts-pathspec.nr) die(_(paths cannot be used with switching branches)); if (opts-patch_mode) @@ -1110,9 +1108,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) } if (argc) { - opts.pathspec = get_pathspec(prefix, argv); + parse_pathspec(opts.pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); - if (!opts.pathspec) + if (!opts.pathspec.nr) die(_(invalid path specification)); /* @@ -1144,7 +1142,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix) strbuf_release(buf); } - if (opts.patch_mode || opts.pathspec) + if (opts.patch_mode || opts.pathspec.nr) return checkout_paths(opts, new.name); else return checkout_branch(opts, new); -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 09/21] rm: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/rm.c | 16 +++- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/builtin/rm.c b/builtin/rm.c index dabfcf6..d719d95 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -216,7 +216,7 @@ static struct option builtin_rm_options[] = { int cmd_rm(int argc, const char **argv, const char *prefix) { int i, newfd; - const char **pathspec; + struct pathspec pathspec; char *seen; git_config(git_default_config, NULL); @@ -249,27 +249,25 @@ int cmd_rm(int argc, const char **argv, const char *prefix) } } - pathspec = get_pathspec(prefix, argv); - refresh_index(the_index, REFRESH_QUIET, pathspec, NULL, NULL); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); + refresh_index(the_index, REFRESH_QUIET, pathspec.raw, NULL, NULL); seen = NULL; - for (i = 0; pathspec[i] ; i++) - /* nothing */; - seen = xcalloc(i, 1); + seen = xcalloc(pathspec.nr, 1); for (i = 0; i active_nr; i++) { struct cache_entry *ce = active_cache[i]; - if (!match_pathspec(pathspec, ce-name, ce_namelen(ce), 0, seen)) + if (!match_pathspec_depth(pathspec, ce-name, ce_namelen(ce), 0, seen)) continue; ALLOC_GROW(list.entry, list.nr + 1, list.alloc); list.entry[list.nr].name = ce-name; list.entry[list.nr++].is_submodule = S_ISGITLINK(ce-ce_mode); } - if (pathspec) { + if (pathspec.nr) { const char *match; int seen_any = 0; - for (i = 0; (match = pathspec[i]) != NULL ; i++) { + for (i = 0; (match = pathspec.raw[i]) != NULL ; i++) { if (!seen[i]) { if (!ignore_unmatch) { die(_(pathspec '%s' did not match any files), -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 10/21] ls-files: convert to use parse_pathspec
strip_trailing_slash_from_submodules() modifies pathspec and is moved to dir.c, close to other pathspec code. It'll be removed later when parse_pathspec() learns to take over its job. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/ls-files.c | 42 +++--- cache.h| 1 + dir.c | 20 3 files changed, 32 insertions(+), 31 deletions(-) diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 4a9ee69..9336abd 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -30,7 +30,7 @@ static int debug_mode; static const char *prefix; static int max_prefix_len; static int prefix_len; -static const char **pathspec; +static struct pathspec pathspec; static int error_unmatch; static char *ps_matched; static const char *with_tree; @@ -58,7 +58,7 @@ static void show_dir_entry(const char *tag, struct dir_entry *ent) if (len = ent-len) die(git ls-files: internal error - directory entry not superset of prefix); - if (!match_pathspec(pathspec, ent-name, ent-len, len, ps_matched)) + if (!match_pathspec_depth(pathspec, ent-name, ent-len, len, ps_matched)) return; fputs(tag, stdout); @@ -133,7 +133,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce) if (len = ce_namelen(ce)) die(git ls-files: internal error - cache entry not superset of prefix); - if (!match_pathspec(pathspec, ce-name, ce_namelen(ce), len, ps_matched)) + if (!match_pathspec_depth(pathspec, ce-name, ce_namelen(ce), len, ps_matched)) return; if (tag *tag show_valid_bit @@ -187,7 +187,7 @@ static void show_ru_info(void) len = strlen(path); if (len max_prefix_len) continue; /* outside of the prefix */ - if (!match_pathspec(pathspec, path, len, max_prefix_len, ps_matched)) + if (!match_pathspec_depth(pathspec, path, len, max_prefix_len, ps_matched)) continue; /* uninterested */ for (i = 0; i 3; i++) { if (!ui-mode[i]) @@ -216,7 +216,7 @@ static void show_files(struct dir_struct *dir) /* For cached/deleted files we don't need to even do the readdir */ if (show_others || show_killed) { - fill_directory(dir, pathspec); + fill_directory(dir, pathspec.raw); if (show_others) show_other_files(dir); if (show_killed) @@ -287,21 +287,6 @@ static void prune_cache(const char *prefix) active_nr = last; } -static void strip_trailing_slash_from_submodules(void) -{ - const char **p; - - for (p = pathspec; *p != NULL; p++) { - int len = strlen(*p), pos; - - if (len 1 || (*p)[len - 1] != '/') - continue; - pos = cache_name_pos(*p, len - 1); - if (pos = 0 S_ISGITLINK(active_cache[pos]-ce_mode)) - *p = xstrndup(*p, len - 1); - } -} - /* * Read the tree specified with --with-tree option * (typically, HEAD) into stage #1 and then @@ -549,23 +534,18 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (require_work_tree !is_inside_work_tree()) setup_work_tree(); - pathspec = get_pathspec(prefix, argv); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); /* be nice with submodule paths ending in a slash */ - if (pathspec) - strip_trailing_slash_from_submodules(); + strip_trailing_slash_from_submodules(pathspec); /* Find common prefix for all pathspec's */ - max_prefix = common_prefix(pathspec); + max_prefix = common_prefix(pathspec.raw); max_prefix_len = max_prefix ? strlen(max_prefix) : 0; /* Treat unmatching pathspec elements as errors */ - if (pathspec error_unmatch) { - int num; - for (num = 0; pathspec[num]; num++) - ; - ps_matched = xcalloc(1, num); - } + if (pathspec.nr error_unmatch) + ps_matched = xcalloc(1, pathspec.nr); if ((dir.flags DIR_SHOW_IGNORED) !exc_given) die(ls-files --ignored needs some exclude pattern); @@ -592,7 +572,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (ps_matched) { int bad; - bad = report_path_error(ps_matched, pathspec, prefix); + bad = report_path_error(ps_matched, pathspec.raw, prefix); if (bad) fprintf(stderr, Did you forget to 'git add'?\n); diff --git a/cache.h b/cache.h index a3c316f..62eefb1 100644 --- a/cache.h +++ b/cache.h @@ -496,6 +496,7 @@ extern int init_pathspec(struct pathspec *, const char
[PATCH v2 11/21] archive: convert to use parse_pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- archive.c | 10 -- archive.h | 2 +- 2 files changed, 5 insertions(+), 7 deletions(-) diff --git a/archive.c b/archive.c index 4666404..530badb 100644 --- a/archive.c +++ b/archive.c @@ -150,7 +150,6 @@ int write_archive_entries(struct archiver_args *args, struct archiver_context context; struct unpack_trees_options opts; struct tree_desc t; - struct pathspec pathspec; int err; if (args-baselen 0 args-base[args-baselen - 1] == '/') { @@ -185,10 +184,8 @@ int write_archive_entries(struct archiver_args *args, git_attr_set_direction(GIT_ATTR_INDEX, the_index); } - init_pathspec(pathspec, args-pathspec); - err = read_tree_recursive(args-tree, , 0, 0, pathspec, + err = read_tree_recursive(args-tree, , 0, 0, args-pathspec, write_archive_entry, context); - free_pathspec(pathspec); if (err == READ_TREE_RECURSIVE) err = 0; return err; @@ -230,8 +227,9 @@ static int path_exists(struct tree *tree, const char *path) static void parse_pathspec_arg(const char **pathspec, struct archiver_args *ar_args) { - ar_args-pathspec = pathspec = get_pathspec(, pathspec); - if (pathspec) { + parse_pathspec(ar_args-pathspec, PATHSPEC_FROMTOP, 0, , pathspec); + if (ar_args-pathspec.nr) { + pathspec = ar_args-pathspec.raw; while (*pathspec) { if (!path_exists(ar_args-tree, *pathspec)) die(path not found: %s, *pathspec); diff --git a/archive.h b/archive.h index 895afcd..a98c49e 100644 --- a/archive.h +++ b/archive.h @@ -8,7 +8,7 @@ struct archiver_args { const unsigned char *commit_sha1; const struct commit *commit; time_t time; - const char **pathspec; + struct pathspec pathspec; unsigned int verbose : 1; unsigned int worktree_attributes : 1; unsigned int convert : 1; -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 12/21] add: convert to use parse_pathspec
treat_gitlinks() modifies pathspec and is moved to dir.c, close to other pathspec code. It'll be removed later when parse_pathspec() learns to take over its job. Note that treat_gitlinks() and strip_trailing_slash_from_submodules() do not perform exactly the same thing. But that does not matter for now. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/add.c | 84 --- cache.h | 1 + dir.c | 32 +++ 3 files changed, 61 insertions(+), 56 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index e664100..c8592fe 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -153,33 +153,6 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec, int return seen; } -static void treat_gitlinks(const char **pathspec) -{ - int i; - - if (!pathspec || !*pathspec) - return; - - for (i = 0; i active_nr; i++) { - struct cache_entry *ce = active_cache[i]; - if (S_ISGITLINK(ce-ce_mode)) { - int len = ce_namelen(ce), j; - for (j = 0; pathspec[j]; j++) { - int len2 = strlen(pathspec[j]); - if (len2 = len || pathspec[j][len] != '/' || - memcmp(ce-name, pathspec[j], len)) - continue; - if (len2 == len + 1) - /* strip trailing slash */ - pathspec[j] = xstrndup(ce-name, len); - else - die (_(Path '%s' is in submodule '%.*s'), - pathspec[j], len, ce-name); - } - } - } -} - static void refresh(int verbose, const char **pathspec) { char *seen; @@ -197,21 +170,18 @@ static void refresh(int verbose, const char **pathspec) free(seen); } -static const char **validate_pathspec(int argc, const char **argv, const char *prefix) +static void validate_pathspec(const char **pathspec, const char *prefix) { - const char **pathspec = get_pathspec(prefix, argv); - - if (pathspec) { - const char **p; - for (p = pathspec; *p; p++) { - if (has_symlink_leading_path(*p, strlen(*p))) { - int len = prefix ? strlen(prefix) : 0; - die(_('%s' is beyond a symbolic link), *p + len); - } + const char **p; + if (!pathspec) + return; + + for (p = pathspec; *p; p++) { + if (has_symlink_leading_path(*p, strlen(*p))) { + int len = prefix ? strlen(prefix) : 0; + die(_('%s' is beyond a symbolic link), *p + len); } } - - return pathspec; } int run_add_interactive(const char *revision, const char *patch_mode, @@ -248,7 +218,8 @@ int interactive_add(int argc, const char **argv, const char *prefix, int patch) const char **pathspec = NULL; if (argc) { - pathspec = validate_pathspec(argc, argv, prefix); + pathspec = get_pathspec(prefix, argv); + validate_pathspec(pathspec, prefix); if (!pathspec) return -1; } @@ -367,7 +338,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) { int exit_status = 0; int newfd; - const char **pathspec; + struct pathspec pathspec; struct dir_struct dir; int flags; int add_new_files; @@ -415,11 +386,12 @@ int cmd_add(int argc, const char **argv, const char *prefix) fprintf(stderr, _(Maybe you wanted to say 'git add .'?\n)); return 0; } - pathspec = validate_pathspec(argc, argv, prefix); + parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); + validate_pathspec(pathspec.raw, prefix); if (read_cache() 0) die(_(index file corrupt)); - treat_gitlinks(pathspec); + treat_gitlinks(pathspec); if (add_new_files) { int baselen; @@ -432,33 +404,33 @@ int cmd_add(int argc, const char **argv, const char *prefix) } /* This picks up the paths that are not tracked */ - baselen = fill_directory(dir, pathspec); - if (pathspec) - seen = prune_directory(dir, pathspec, baselen); + baselen = fill_directory(dir, pathspec.raw); + if (pathspec.nr) + seen = prune_directory(dir, pathspec.raw, baselen); } if (refresh_only) { - refresh(verbose, pathspec); + refresh(verbose,
[PATCH v2 13/21] Convert read_cache_preload() to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/checkout.c | 2 +- builtin/commit.c | 4 ++-- builtin/diff-files.c | 2 +- builtin/diff-index.c | 2 +- builtin/diff.c | 4 ++-- cache.h | 4 +++- preload-index.c | 20 +++- 7 files changed, 21 insertions(+), 17 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index da25298..00910dc 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -261,7 +261,7 @@ static int checkout_paths(const struct checkout_opts *opts, lock_file = xcalloc(1, sizeof(struct lock_file)); newfd = hold_locked_index(lock_file, 1); - if (read_cache_preload(opts-pathspec.raw) 0) + if (read_cache_preload(opts-pathspec) 0) return error(_(corrupt index file)); if (opts-source_tree) diff --git a/builtin/commit.c b/builtin/commit.c index 196dfab..069d853 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -287,7 +287,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, PATHSPEC_EMPTY_MATCH_ALL, prefix, argv); - if (read_cache_preload(pathspec.raw) 0) + if (read_cache_preload(pathspec) 0) die(_(index file corrupt)); if (interactive) { @@ -1209,7 +1209,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) PATHSPEC_EMPTY_MATCH_ALL, prefix, argv); - read_cache_preload(s.pathspec.raw); + read_cache_preload(s.pathspec); refresh_index(the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec.raw, NULL, NULL); fd = hold_locked_index(index_lock, 0); diff --git a/builtin/diff-files.c b/builtin/diff-files.c index 46085f8..9200069 100644 --- a/builtin/diff-files.c +++ b/builtin/diff-files.c @@ -61,7 +61,7 @@ int cmd_diff_files(int argc, const char **argv, const char *prefix) (rev.diffopt.output_format DIFF_FORMAT_PATCH)) rev.combine_merges = rev.dense_combined_merges = 1; - if (read_cache_preload(rev.diffopt.pathspec.raw) 0) { + if (read_cache_preload(rev.diffopt.pathspec) 0) { perror(read_cache_preload); return -1; } diff --git a/builtin/diff-index.c b/builtin/diff-index.c index 1c737f7..ce15b23 100644 --- a/builtin/diff-index.c +++ b/builtin/diff-index.c @@ -43,7 +43,7 @@ int cmd_diff_index(int argc, const char **argv, const char *prefix) usage(diff_cache_usage); if (!cached) { setup_work_tree(); - if (read_cache_preload(rev.diffopt.pathspec.raw) 0) { + if (read_cache_preload(rev.diffopt.pathspec) 0) { perror(read_cache_preload); return -1; } diff --git a/builtin/diff.c b/builtin/diff.c index 8c2af6c..62bdc4d 100644 --- a/builtin/diff.c +++ b/builtin/diff.c @@ -140,7 +140,7 @@ static int builtin_diff_index(struct rev_info *revs, usage(builtin_diff_usage); if (!cached) { setup_work_tree(); - if (read_cache_preload(revs-diffopt.pathspec.raw) 0) { + if (read_cache_preload(revs-diffopt.pathspec) 0) { perror(read_cache_preload); return -1; } @@ -240,7 +240,7 @@ static int builtin_diff_files(struct rev_info *revs, int argc, const char **argv revs-combine_merges = revs-dense_combined_merges = 1; setup_work_tree(); - if (read_cache_preload(revs-diffopt.pathspec.raw) 0) { + if (read_cache_preload(revs-diffopt.pathspec) 0) { perror(read_cache_preload); return -1; } diff --git a/cache.h b/cache.h index af96376..c594ded 100644 --- a/cache.h +++ b/cache.h @@ -182,6 +182,8 @@ struct cache_entry { #error CE_EXTENDED_FLAGS out of range #endif +struct pathspec; + /* * Copy the sha1 and stat state of a cache entry from one to * another. But we never change the name, or the hash state! @@ -433,7 +435,7 @@ extern int init_db(const char *template_dir, unsigned int flags); /* Initialize and use the cache information */ extern int read_index(struct index_state *); -extern int read_index_preload(struct index_state *, const char **pathspec); +extern int read_index_preload(struct index_state *, const struct pathspec *pathspec); extern int read_index_from(struct index_state *, const char *path); extern int is_index_unborn(struct index_state *); extern int read_index_unmerged(struct index_state *); diff --git a/preload-index.c b/preload-index.c index 49cb08d..91f27f7 100644 --- a/preload-index.c +++ b/preload-index.c @@ -4,7 +4,8 @@ #include cache.h #ifdef NO_PTHREADS -static void preload_index(struct index_state *index, const char **pathspec) +static void preload_index(struct index_state *index, +
[PATCH v2 14/21] Convert unmerge_cache to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/checkout.c | 2 +- rerere.c | 2 +- resolve-undo.c | 4 ++-- resolve-undo.h | 2 +- 4 files changed, 5 insertions(+), 5 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index 00910dc..aa399d6 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -281,7 +281,7 @@ static int checkout_paths(const struct checkout_opts *opts, /* checkout -m path to recreate conflicted state */ if (opts-merge) - unmerge_cache(opts-pathspec.raw); + unmerge_cache(opts-pathspec); /* Any unmerged paths? */ for (pos = 0; pos active_nr; pos++) { diff --git a/rerere.c b/rerere.c index f8ddf85..9d149fa 100644 --- a/rerere.c +++ b/rerere.c @@ -666,7 +666,7 @@ int rerere_forget(struct pathspec *pathspec) fd = setup_rerere(merge_rr, RERERE_NOAUTOUPDATE); - unmerge_cache(pathspec-raw); + unmerge_cache(pathspec); find_conflict(conflict); for (i = 0; i conflict.nr; i++) { struct string_list_item *it = conflict.items[i]; diff --git a/resolve-undo.c b/resolve-undo.c index 72b4612..1bfece2 100644 --- a/resolve-undo.c +++ b/resolve-undo.c @@ -156,7 +156,7 @@ int unmerge_index_entry_at(struct index_state *istate, int pos) return unmerge_index_entry_at(istate, pos); } -void unmerge_index(struct index_state *istate, const char **pathspec) +void unmerge_index(struct index_state *istate, const struct pathspec *pathspec) { int i; @@ -165,7 +165,7 @@ void unmerge_index(struct index_state *istate, const char **pathspec) for (i = 0; i istate-cache_nr; i++) { struct cache_entry *ce = istate-cache[i]; - if (!match_pathspec(pathspec, ce-name, ce_namelen(ce), 0, NULL)) + if (!match_pathspec_depth(pathspec, ce-name, ce_namelen(ce), 0, NULL)) continue; i = unmerge_index_entry_at(istate, i); } diff --git a/resolve-undo.h b/resolve-undo.h index 8458769..81e8803 100644 --- a/resolve-undo.h +++ b/resolve-undo.h @@ -11,6 +11,6 @@ extern void resolve_undo_write(struct strbuf *, struct string_list *); extern struct string_list *resolve_undo_read(const char *, unsigned long); extern void resolve_undo_clear_index(struct index_state *); extern int unmerge_index_entry_at(struct index_state *, int); -extern void unmerge_index(struct index_state *, const char **); +extern void unmerge_index(struct index_state *, const struct pathspec *); #endif -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 15/21] checkout: convert read_tree_some to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/checkout.c | 9 +++-- tree.c | 4 ++-- tree.h | 2 +- 3 files changed, 6 insertions(+), 9 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index aa399d6..a7ddb35 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -82,12 +82,9 @@ static int update_some(const unsigned char *sha1, const char *base, int baselen, return 0; } -static int read_tree_some(struct tree *tree, const char **pathspec) +static int read_tree_some(struct tree *tree, const struct pathspec *pathspec) { - struct pathspec ps; - init_pathspec(ps, pathspec); - read_tree_recursive(tree, , 0, 0, ps, update_some, NULL); - free_pathspec(ps); + read_tree_recursive(tree, , 0, 0, pathspec, update_some, NULL); /* update the index with the given tree's info * for all args, expanding wildcards, and exit @@ -265,7 +262,7 @@ static int checkout_paths(const struct checkout_opts *opts, return error(_(corrupt index file)); if (opts-source_tree) - read_tree_some(opts-source_tree, opts-pathspec.raw); + read_tree_some(opts-source_tree, opts-pathspec); ps_matched = xcalloc(1, opts-pathspec.nr); diff --git a/tree.c b/tree.c index 62fed63..ff72f67 100644 --- a/tree.c +++ b/tree.c @@ -47,7 +47,7 @@ static int read_one_entry_quick(const unsigned char *sha1, const char *base, int } static int read_tree_1(struct tree *tree, struct strbuf *base, - int stage, struct pathspec *pathspec, + int stage, const struct pathspec *pathspec, read_tree_fn_t fn, void *context) { struct tree_desc desc; @@ -116,7 +116,7 @@ static int read_tree_1(struct tree *tree, struct strbuf *base, int read_tree_recursive(struct tree *tree, const char *base, int baselen, - int stage, struct pathspec *pathspec, + int stage, const struct pathspec *pathspec, read_tree_fn_t fn, void *context) { struct strbuf sb = STRBUF_INIT; diff --git a/tree.h b/tree.h index 69bcb5e..9dc90ba 100644 --- a/tree.h +++ b/tree.h @@ -25,7 +25,7 @@ typedef int (*read_tree_fn_t)(const unsigned char *, const char *, int, const ch extern int read_tree_recursive(struct tree *tree, const char *base, int baselen, - int stage, struct pathspec *pathspec, + int stage, const struct pathspec *pathspec, read_tree_fn_t fn, void *context); extern int read_tree(struct tree *tree, int stage, struct pathspec *pathspec); -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 16/21] Convert report_path_error to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/checkout.c | 2 +- builtin/commit.c | 14 ++ builtin/ls-files.c | 14 -- cache.h| 2 +- 4 files changed, 16 insertions(+), 16 deletions(-) diff --git a/builtin/checkout.c b/builtin/checkout.c index a7ddb35..648768e 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -273,7 +273,7 @@ static int checkout_paths(const struct checkout_opts *opts, match_pathspec_depth(opts-pathspec, ce-name, ce_namelen(ce), 0, ps_matched); } - if (report_path_error(ps_matched, opts-pathspec.raw, opts-prefix)) + if (report_path_error(ps_matched, opts-pathspec, opts-prefix)) return 1; /* checkout -m path to recreate conflicted state */ diff --git a/builtin/commit.c b/builtin/commit.c index 069d853..8777c19 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -181,20 +181,18 @@ static int commit_index_files(void) * and return the paths that match the given pattern in list. */ static int list_paths(struct string_list *list, const char *with_tree, - const char *prefix, const char **pattern) + const char *prefix, const struct pathspec *pattern) { int i; char *m; - if (!pattern) + if (!pattern-nr) return 0; - for (i = 0; pattern[i]; i++) - ; - m = xcalloc(1, i); + m = xcalloc(1, pattern-nr); if (with_tree) { - char *max_prefix = common_prefix(pattern); + char *max_prefix = common_prefix(pattern-raw); overlay_tree_on_cache(with_tree, max_prefix ? max_prefix : prefix); free(max_prefix); } @@ -205,7 +203,7 @@ static int list_paths(struct string_list *list, const char *with_tree, if (ce-ce_flags CE_UPDATE) continue; - if (!match_pathspec(pattern, ce-name, ce_namelen(ce), 0, m)) + if (!match_pathspec_depth(pattern, ce-name, ce_namelen(ce), 0, m)) continue; item = string_list_insert(list, ce-name); if (ce_skip_worktree(ce)) @@ -395,7 +393,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, memset(partial, 0, sizeof(partial)); partial.strdup_strings = 1; - if (list_paths(partial, !current_head ? NULL : HEAD, prefix, pathspec.raw)) + if (list_paths(partial, !current_head ? NULL : HEAD, prefix, pathspec)) exit(1); discard_cache(); diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 9336abd..be6e05d 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -349,7 +349,9 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix) } } -int report_path_error(const char *ps_matched, const char **pathspec, const char *prefix) +int report_path_error(const char *ps_matched, + const struct pathspec *pathspec, + const char *prefix) { /* * Make sure all pathspec matched; otherwise it is an error. @@ -357,7 +359,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, const char struct strbuf sb = STRBUF_INIT; const char *name; int num, errors = 0; - for (num = 0; pathspec[num]; num++) { + for (num = 0; num pathspec-nr; num++) { int other, found_dup; if (ps_matched[num]) @@ -367,11 +369,11 @@ int report_path_error(const char *ps_matched, const char **pathspec, const char * twice. Do not barf on such a mistake. */ for (found_dup = other = 0; -!found_dup pathspec[other]; +!found_dup pathspec-raw[other]; other++) { if (other == num || !ps_matched[other]) continue; - if (!strcmp(pathspec[other], pathspec[num])) + if (!strcmp(pathspec-raw[other], pathspec-raw[num])) /* * Ok, we have a match already. */ @@ -380,7 +382,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, const char if (found_dup) continue; - name = quote_path_relative(pathspec[num], -1, sb, prefix); + name = quote_path_relative(pathspec-raw[num], -1, sb, prefix); error(pathspec '%s' did not match any file(s) known to git., name); errors++; @@ -572,7 +574,7 @@ int cmd_ls_files(int argc, const char **argv, const char *cmd_prefix) if (ps_matched) { int bad; - bad = report_path_error(ps_matched, pathspec.raw, prefix); +
[PATCH v2 17/21] Convert refresh_index to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/add.c| 14 ++ builtin/commit.c | 2 +- builtin/rm.c | 2 +- cache.h | 2 +- read-cache.c | 5 +++-- 5 files changed, 12 insertions(+), 13 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index c8592fe..4e2b603 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -153,19 +153,17 @@ static char *prune_directory(struct dir_struct *dir, const char **pathspec, int return seen; } -static void refresh(int verbose, const char **pathspec) +static void refresh(int verbose, const struct pathspec *pathspec) { char *seen; - int i, specs; + int i; - for (specs = 0; pathspec[specs]; specs++) - /* nothing */; - seen = xcalloc(specs, 1); + seen = xcalloc(pathspec-nr, 1); refresh_index(the_index, verbose ? REFRESH_IN_PORCELAIN : REFRESH_QUIET, pathspec, seen, _(Unstaged changes after refreshing the index:)); - for (i = 0; i specs; i++) { + for (i = 0; i pathspec-nr; i++) { if (!seen[i]) - die(_(pathspec '%s' did not match any files), pathspec[i]); + die(_(pathspec '%s' did not match any files), pathspec-raw[i]); } free(seen); } @@ -410,7 +408,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) } if (refresh_only) { - refresh(verbose, pathspec.raw); + refresh(verbose, pathspec); goto finish; } diff --git a/builtin/commit.c b/builtin/commit.c index 8777c19..2fe6054 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -1208,7 +1208,7 @@ int cmd_status(int argc, const char **argv, const char *prefix) prefix, argv); read_cache_preload(s.pathspec); - refresh_index(the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec.raw, NULL, NULL); + refresh_index(the_index, REFRESH_QUIET|REFRESH_UNMERGED, s.pathspec, NULL, NULL); fd = hold_locked_index(index_lock, 0); if (0 = fd) diff --git a/builtin/rm.c b/builtin/rm.c index d719d95..b5edde8 100644 --- a/builtin/rm.c +++ b/builtin/rm.c @@ -250,7 +250,7 @@ int cmd_rm(int argc, const char **argv, const char *prefix) } parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); - refresh_index(the_index, REFRESH_QUIET, pathspec.raw, NULL, NULL); + refresh_index(the_index, REFRESH_QUIET, pathspec, NULL, NULL); seen = NULL; seen = xcalloc(pathspec.nr, 1); diff --git a/cache.h b/cache.h index 40eaa04..32298ba 100644 --- a/cache.h +++ b/cache.h @@ -515,7 +515,7 @@ extern void fill_stat_cache_info(struct cache_entry *ce, struct stat *st); #define REFRESH_IGNORE_MISSING 0x0008 /* ignore non-existent */ #define REFRESH_IGNORE_SUBMODULES 0x0010 /* ignore submodules */ #define REFRESH_IN_PORCELAIN 0x0020 /* user friendly output, not needs update */ -extern int refresh_index(struct index_state *, unsigned int flags, const char **pathspec, char *seen, const char *header_msg); +extern int refresh_index(struct index_state *, unsigned int flags, const struct pathspec *pathspec, char *seen, const char *header_msg); struct lock_file { struct lock_file *next; diff --git a/read-cache.c b/read-cache.c index fda78bc..dec2ba6 100644 --- a/read-cache.c +++ b/read-cache.c @@ -1093,7 +1093,8 @@ static void show_file(const char * fmt, const char * name, int in_porcelain, printf(fmt, name); } -int refresh_index(struct index_state *istate, unsigned int flags, const char **pathspec, +int refresh_index(struct index_state *istate, unsigned int flags, + const struct pathspec *pathspec, char *seen, const char *header_msg) { int i; @@ -1128,7 +1129,7 @@ int refresh_index(struct index_state *istate, unsigned int flags, const char **p continue; if (pathspec - !match_pathspec(pathspec, ce-name, ce_namelen(ce), 0, seen)) + !match_pathspec_depth(pathspec, ce-name, ce_namelen(ce), 0, seen)) filtered = 1; if (ce_stage(ce)) { -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 18/21] Convert {read,fill}_directory to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/add.c | 2 +- builtin/clean.c| 2 +- builtin/grep.c | 2 +- builtin/ls-files.c | 2 +- dir.c | 10 +- dir.h | 4 ++-- wt-status.c| 4 ++-- 7 files changed, 13 insertions(+), 13 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 4e2b603..0295cef 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -402,7 +402,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) } /* This picks up the paths that are not tracked */ - baselen = fill_directory(dir, pathspec.raw); + baselen = fill_directory(dir, pathspec); if (pathspec.nr) seen = prune_directory(dir, pathspec.raw, baselen); } diff --git a/builtin/clean.c b/builtin/clean.c index 788ad8c..41c8cad 100644 --- a/builtin/clean.c +++ b/builtin/clean.c @@ -103,7 +103,7 @@ int cmd_clean(int argc, const char **argv, const char *prefix) parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); - fill_directory(dir, pathspec.raw); + fill_directory(dir, pathspec); if (pathspec.nr) seen = xmalloc(pathspec.nr); diff --git a/builtin/grep.c b/builtin/grep.c index 705f9ff..f370bad 100644 --- a/builtin/grep.c +++ b/builtin/grep.c @@ -522,7 +522,7 @@ static int grep_directory(struct grep_opt *opt, const struct pathspec *pathspec, if (exc_std) setup_standard_excludes(dir); - fill_directory(dir, pathspec-raw); + fill_directory(dir, pathspec); for (i = 0; i dir.nr; i++) { const char *name = dir.entries[i]-name; int namelen = strlen(name); diff --git a/builtin/ls-files.c b/builtin/ls-files.c index be6e05d..7bb637b 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -216,7 +216,7 @@ static void show_files(struct dir_struct *dir) /* For cached/deleted files we don't need to even do the readdir */ if (show_others || show_killed) { - fill_directory(dir, pathspec.raw); + fill_directory(dir, pathspec); if (show_others) show_other_files(dir); if (show_killed) diff --git a/dir.c b/dir.c index 4d1f71c..eb52913 100644 --- a/dir.c +++ b/dir.c @@ -72,7 +72,7 @@ char *common_prefix(const char **pathspec) return len ? xmemdupz(*pathspec, len) : NULL; } -int fill_directory(struct dir_struct *dir, const char **pathspec) +int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec) { size_t len; @@ -80,10 +80,10 @@ int fill_directory(struct dir_struct *dir, const char **pathspec) * Calculate common prefix for the pathspec, and * use that to optimize the directory walk */ - len = common_prefix_len(pathspec); + len = common_prefix_len(pathspec-raw); /* Read the directory and prune it */ - read_directory(dir, pathspec ? *pathspec : , len, pathspec); + read_directory(dir, pathspec-nr ? pathspec-raw[0] : , len, pathspec); return len; } @@ -1211,14 +1211,14 @@ static int treat_leading_path(struct dir_struct *dir, return rc; } -int read_directory(struct dir_struct *dir, const char *path, int len, const char **pathspec) +int read_directory(struct dir_struct *dir, const char *path, int len, const struct pathspec *pathspec) { struct path_simplify *simplify; if (has_symlink_leading_path(path, len)) return dir-nr; - simplify = create_simplify(pathspec); + simplify = create_simplify(pathspec ? pathspec-raw : NULL); if (!len || treat_leading_path(dir, path, len, simplify)) read_directory_recursive(dir, path, len, 0, simplify); free_simplify(simplify); diff --git a/dir.h b/dir.h index 1d4888b..b51d2e9 100644 --- a/dir.h +++ b/dir.h @@ -74,8 +74,8 @@ extern int match_pathspec_depth(const struct pathspec *pathspec, int prefix, char *seen); extern int within_depth(const char *name, int namelen, int depth, int max_depth); -extern int fill_directory(struct dir_struct *dir, const char **pathspec); -extern int read_directory(struct dir_struct *, const char *path, int len, const char **pathspec); +extern int fill_directory(struct dir_struct *dir, const struct pathspec *pathspec); +extern int read_directory(struct dir_struct *, const char *path, int len, const struct pathspec *pathspec); extern int excluded_from_list(const char *pathname, int pathlen, const char *basename, int *dtype, struct exclude_list *el); diff --git a/wt-status.c b/wt-status.c index 13e6aba..2e1a62b 100644 --- a/wt-status.c +++ b/wt-status.c @@ -502,7 +502,7 @@ static void wt_status_collect_untracked(struct wt_status *s) DIR_SHOW_OTHER_DIRECTORIES |
[PATCH v2 19/21] Convert add_files_to_cache to take struct pathspec
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- builtin/add.c| 8 +--- builtin/commit.c | 2 +- cache.h | 2 +- 3 files changed, 7 insertions(+), 5 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 0295cef..5d262eb 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -80,13 +80,15 @@ static void update_callback(struct diff_queue_struct *q, } } -int add_files_to_cache(const char *prefix, const char **pathspec, int flags) +int add_files_to_cache(const char *prefix, + const struct pathspec *pathspec, int flags) { struct update_callback_data data; struct rev_info rev; init_revisions(rev, prefix); setup_revisions(0, NULL, rev, NULL); - init_pathspec(rev.prune_data, pathspec); + if (pathspec) + rev.prune_data = *pathspec; rev.diffopt.output_format = DIFF_FORMAT_CALLBACK; rev.diffopt.format_callback = update_callback; data.flags = flags; @@ -437,7 +439,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) plug_bulk_checkin(); - exit_status |= add_files_to_cache(prefix, pathspec.raw, flags); + exit_status |= add_files_to_cache(prefix, pathspec, flags); if (add_new_files) exit_status |= add_files(dir, flags); diff --git a/builtin/commit.c b/builtin/commit.c index 2fe6054..d79613d 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -329,7 +329,7 @@ static char *prepare_index(int argc, const char **argv, const char *prefix, */ if (all || (also pathspec.nr)) { fd = hold_locked_index(index_lock, 1); - add_files_to_cache(also ? prefix : NULL, pathspec.raw, 0); + add_files_to_cache(also ? prefix : NULL, pathspec, 0); refresh_cache_or_die(refresh_flags); update_main_cache_tree(WRITE_TREE_SILENT); if (write_cache(fd, active_cache, active_nr) || diff --git a/cache.h b/cache.h index 32298ba..3e09a61 100644 --- a/cache.h +++ b/cache.h @@ -1228,7 +1228,7 @@ void packet_trace_identity(const char *prog); * return 0 if success, 1 - if addition of a file failed and * ADD_FILES_IGNORE_ERRORS was specified in flags */ -int add_files_to_cache(const char *prefix, const char **pathspec, int flags); +int add_files_to_cache(const char *prefix, const struct pathspec *pathspec, int flags); /* diff.c */ extern int diff_auto_refresh_index; -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 20/21] Convert more init_pathspec() to parse_pathspec()
init_pathspec() was introduced to work with the result from get_pathspec(). init_pathspec() will be removed eventually after parse_pathspec() takes over, so that there is only place that initializes struct pathspec. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- archive.c | 2 +- builtin/log.c | 2 +- builtin/ls-files.c | 10 -- diff-lib.c | 2 +- merge-recursive.c | 2 +- 5 files changed, 8 insertions(+), 10 deletions(-) diff --git a/archive.c b/archive.c index 530badb..3caa31f 100644 --- a/archive.c +++ b/archive.c @@ -218,7 +218,7 @@ static int path_exists(struct tree *tree, const char *path) struct pathspec pathspec; int ret; - init_pathspec(pathspec, paths); + parse_pathspec(pathspec, 0, 0, , paths); ret = read_tree_recursive(tree, , 0, 0, pathspec, reject_entry, NULL); free_pathspec(pathspec); return ret != 0; diff --git a/builtin/log.c b/builtin/log.c index e7b7db1..495ae77 100644 --- a/builtin/log.c +++ b/builtin/log.c @@ -455,7 +455,7 @@ int cmd_show(int argc, const char **argv, const char *prefix) init_grep_defaults(); git_config(git_log_config, NULL); - init_pathspec(match_all, NULL); + memset(match_all, 0, sizeof(match_all)); init_revisions(rev, prefix); rev.diff = 1; rev.always_show_header = 1; diff --git a/builtin/ls-files.c b/builtin/ls-files.c index 7bb637b..79949de 100644 --- a/builtin/ls-files.c +++ b/builtin/ls-files.c @@ -318,13 +318,11 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix) } if (prefix) { - static const char *(matchbuf[2]); - matchbuf[0] = prefix; - matchbuf[1] = NULL; - init_pathspec(pathspec, matchbuf); - pathspec.items[0].nowildcard_len = pathspec.items[0].len; + static const char *(matchbuf[1]); + matchbuf[0] = NULL; + parse_pathspec(pathspec, 0, 0, prefix, matchbuf); } else - init_pathspec(pathspec, NULL); + memset(pathspec, 0, sizeof(pathspec)); if (read_tree(tree, 1, pathspec)) die(unable to read tree entries %s, tree_name); diff --git a/diff-lib.c b/diff-lib.c index f35de0f..9c07f6a 100644 --- a/diff-lib.c +++ b/diff-lib.c @@ -500,7 +500,7 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt) struct rev_info revs; init_revisions(revs, NULL); - init_pathspec(revs.prune_data, opt-pathspec.raw); + revs.prune_data = opt-pathspec; revs.diffopt = *opt; if (diff_cache(revs, tree_sha1, NULL, 1)) diff --git a/merge-recursive.c b/merge-recursive.c index d882060..cd95bdb 100644 --- a/merge-recursive.c +++ b/merge-recursive.c @@ -297,7 +297,7 @@ static int get_files_dirs(struct merge_options *o, struct tree *tree) { int n; struct pathspec match_all; - init_pathspec(match_all, NULL); + memset(match_all, 0, sizeof(match_all)); if (read_tree_recursive(tree, , 0, 0, match_all, save_files_dirs, o)) return 0; n = o-current_file_set.nr + o-current_directory_set.nr; -- 1.8.0.rc2.23.g1fb49df -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 21/21] Rename field raw to _raw in struct pathspec
This patch is essentially no-op. It helps catching new use of this field though. This field is introduced as an intermediate step for the pathspec conversion and will be removed eventually. At this stage no more access sites should be introduced. Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- archive.c | 2 +- builtin/add.c | 20 ++-- builtin/checkout.c | 2 +- builtin/commit.c | 2 +- builtin/ls-files.c | 8 builtin/ls-tree.c | 2 +- builtin/rm.c | 2 +- cache.h| 2 +- dir.c | 22 +++--- revision.c | 4 ++-- setup.c| 6 +++--- tree-diff.c| 8 12 files changed, 40 insertions(+), 40 deletions(-) diff --git a/archive.c b/archive.c index 3caa31f..c52e525 100644 --- a/archive.c +++ b/archive.c @@ -229,7 +229,7 @@ static void parse_pathspec_arg(const char **pathspec, { parse_pathspec(ar_args-pathspec, PATHSPEC_FROMTOP, 0, , pathspec); if (ar_args-pathspec.nr) { - pathspec = ar_args-pathspec.raw; + pathspec = ar_args-pathspec._raw; while (*pathspec) { if (!path_exists(ar_args-tree, *pathspec)) die(path not found: %s, *pathspec); diff --git a/builtin/add.c b/builtin/add.c index 5d262eb..6b6a72e 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -165,7 +165,7 @@ static void refresh(int verbose, const struct pathspec *pathspec) pathspec, seen, _(Unstaged changes after refreshing the index:)); for (i = 0; i pathspec-nr; i++) { if (!seen[i]) - die(_(pathspec '%s' did not match any files), pathspec-raw[i]); + die(_(pathspec '%s' did not match any files), pathspec-_raw[i]); } free(seen); } @@ -387,7 +387,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) return 0; } parse_pathspec(pathspec, PATHSPEC_FROMTOP, 0, prefix, argv); - validate_pathspec(pathspec.raw, prefix); + validate_pathspec(pathspec._raw, prefix); if (read_cache() 0) die(_(index file corrupt)); @@ -406,7 +406,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) /* This picks up the paths that are not tracked */ baselen = fill_directory(dir, pathspec); if (pathspec.nr) - seen = prune_directory(dir, pathspec.raw, baselen); + seen = prune_directory(dir, pathspec._raw, baselen); } if (refresh_only) { @@ -420,17 +420,17 @@ int cmd_add(int argc, const char **argv, const char *prefix) path_exclude_check_init(check, dir); if (!seen) - seen = find_used_pathspec(pathspec.raw); - for (i = 0; pathspec.raw[i]; i++) { - if (!seen[i] pathspec.raw[i][0] -!file_exists(pathspec.raw[i])) { + seen = find_used_pathspec(pathspec._raw); + for (i = 0; pathspec._raw[i]; i++) { + if (!seen[i] pathspec._raw[i][0] +!file_exists(pathspec._raw[i])) { if (ignore_missing) { int dtype = DT_UNKNOWN; - if (path_excluded(check, pathspec.raw[i], -1, dtype)) - dir_add_ignored(dir, pathspec.raw[i], strlen(pathspec.raw[i])); + if (path_excluded(check, pathspec._raw[i], -1, dtype)) + dir_add_ignored(dir, pathspec._raw[i], strlen(pathspec._raw[i])); } else die(_(pathspec '%s' did not match any files), - pathspec.raw[i]); + pathspec._raw[i]); } } free(seen); diff --git a/builtin/checkout.c b/builtin/checkout.c index 648768e..716a949 100644 --- a/builtin/checkout.c +++ b/builtin/checkout.c @@ -253,7 +253,7 @@ static int checkout_paths(const struct checkout_opts *opts, if (opts-patch_mode) return run_add_interactive(revision, --patch=checkout, - opts-pathspec.raw); + opts-pathspec._raw); lock_file = xcalloc(1, sizeof(struct lock_file)); diff --git a/builtin/commit.c b/builtin/commit.c index d79613d..876916c 100644 --- a/builtin/commit.c +++ b/builtin/commit.c @@ -192,7 +192,7 @@ static int list_paths(struct string_list *list, const char *with_tree, m = xcalloc(1, pattern-nr); if (with_tree) { - char *max_prefix =
Re: git checkout doesn't work?
On Fri, Jan 11, 2013 at 1:46 PM, Ishayahu Lastov meoc...@mail.ru wrote: This is my session on Win7 x64: Microsoft Windows [Version 6.1.7601] (c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены. C:\Dropbox\Dropbox\Wesnoth\Apocryphscd Apokryphs.Orks C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orksgit status # On branch master # Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded. # # Changes not staged for commit: # (use git add file... to update what will be committed) # (use git checkout -- file... to discard changes in working directory) # # modified: scenarios/01_NothernVillage.cfg # no changes added to commit (use git add and/or git commit -a) C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orkscd scenarios C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenariosgit status # On branch master # Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded. # # Changes not staged for commit: # (use git add file... to update what will be committed) # (use git checkout -- file... to discard changes in working directory) # # modified: 01_NothernVillage.cfg # no changes added to commit (use git add and/or git commit -a) C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenariosgit checkout -- 01 _NothernVillage.cfg C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenariosgit status # On branch master # Your branch is behind 'origin/master' by 3 commits, and can be fast-forwarded. # # Changes not staged for commit: # (use git add file... to update what will be committed) # (use git checkout -- file... to discard changes in working directory) # # modified: 01_NothernVillage.cfg # no changes added to commit (use git add and/or git commit -a) C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenarios As I understand after last git checkout in git status I should see that I gave no changes. It looks like an bug, isn't it? Yeah, perhaps it's file attributes. What does this say? git diff --summary --stat -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: What's cooking in git.git (Jan 2013, #04; Wed, 9)
On Thu, Jan 10, 2013 at 4:04 AM, Junio C Hamano gits...@pobox.com wrote: Here are the topics that have been cooking. Commits prefixed with '-' are only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'. I see you start to use no-change commits as a way to keep notes in 'pu'. Isn't git notes designed for that? Just wanted to understand why you chose that way and maybe we could improve git-notes a bit to fit this purpose. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 17/21] Convert refresh_index to take struct pathspec
On Fri, Jan 11, 2013 at 06:21:11PM +0700, Nguyễn Thái Ngọc Duy wrote: - for (i = 0; i specs; i++) { + for (i = 0; i pathspec-nr; i++) { if (!seen[i]) - die(_(pathspec '%s' did not match any files), pathspec[i]); + die(_(pathspec '%s' did not match any files), pathspec-raw[i]); } This needs the following fixup on top. I don't want to send another reroll just a couple hours after I flooded git@vger. I did not plan to work on the series this soon but somehow another problem got me back here. -- 8 -- diff --git a/builtin/add.c b/builtin/add.c index 1235eb9..e1bcdb9 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -159,7 +159,8 @@ static void refresh(int verbose, const struct pathspec *pathspec) pathspec, seen, _(Unstaged changes after refreshing the index:)); for (i = 0; i pathspec-nr; i++) { if (!seen[i]) - die(_(pathspec '%s' did not match any files), pathspec-raw[i]); + die(_(pathspec '%s' did not match any files), + pathspec-items[i].match); } free(seen); } -- 8 -- and the baaad reason: pathspec-items[] are sorted because of 86e4ca6 (tree_entry_interesting(): fix depth limit with overlapping pathspecs - 2010-12-15). But raw[] are _not_. So raw[i] does not correspond to item[i]. Now seen[] array returned from match_pathspec() has the order corresponding to raw[]. On the other hand match_pathspec_depth() returns seen[] corresponds to items[]. This patch converts match_pathspec() to match_pathspec_depth() so we need to use the correct pathspec array. I'll put these explanation in the next reroll. And don't worry about this subtle difference. My next email kills match_pathspec() for good. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 22/21] Convert the last use of match_pathspec() and remove it
Signed-off-by: Nguyễn Thái Ngọc Duy pclo...@gmail.com --- I was digging the t7400.38 failure and found that add.c is the last place that uses match_pathspec(). This is the first yay moment for me since 'struct pathspec' was introduced. I wanted to remove this function for so long! Good luck resolving conflicts by the way ;-) builtin/add.c | 47 - dir.c | 97 --- dir.h | 1 - 3 files changed, 20 insertions(+), 125 deletions(-) diff --git a/builtin/add.c b/builtin/add.c index 6b6a72e..1235eb9 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -99,7 +99,7 @@ int add_files_to_cache(const char *prefix, return !!data.add_errors; } -static void fill_pathspec_matches(const char **pathspec, char *seen, int specs) +static void fill_pathspec_matches(struct pathspec *pathspec, char *seen) { int num_unmatched = 0, i; @@ -109,49 +109,43 @@ static void fill_pathspec_matches(const char **pathspec, char *seen, int specs) * mistakenly think that the user gave a pathspec that did not match * anything. */ - for (i = 0; i specs; i++) + for (i = 0; i pathspec-nr; i++) if (!seen[i]) num_unmatched++; if (!num_unmatched) return; for (i = 0; i active_nr; i++) { struct cache_entry *ce = active_cache[i]; - match_pathspec(pathspec, ce-name, ce_namelen(ce), 0, seen); + match_pathspec_depth(pathspec, ce-name, ce_namelen(ce), 0, seen); } } -static char *find_used_pathspec(const char **pathspec) +static char *find_used_pathspec(struct pathspec *pathspec) { char *seen; - int i; - - for (i = 0; pathspec[i]; i++) - ; /* just counting */ - seen = xcalloc(i, 1); - fill_pathspec_matches(pathspec, seen, i); + seen = xcalloc(pathspec-nr, 1); + fill_pathspec_matches(pathspec, seen); return seen; } -static char *prune_directory(struct dir_struct *dir, const char **pathspec, int prefix) +static char *prune_directory(struct dir_struct *dir, struct pathspec *pathspec, int prefix) { char *seen; - int i, specs; + int i; struct dir_entry **src, **dst; - for (specs = 0; pathspec[specs]; specs++) - /* nothing */; - seen = xcalloc(specs, 1); + seen = xcalloc(pathspec-nr, 1); src = dst = dir-entries; i = dir-nr; while (--i = 0) { struct dir_entry *entry = *src++; - if (match_pathspec(pathspec, entry-name, entry-len, - prefix, seen)) + if (match_pathspec_depth(pathspec, entry-name, entry-len, +prefix, seen)) *dst++ = entry; } dir-nr = dst - dir-entries; - fill_pathspec_matches(pathspec, seen, specs); + fill_pathspec_matches(pathspec, seen); return seen; } @@ -406,7 +400,7 @@ int cmd_add(int argc, const char **argv, const char *prefix) /* This picks up the paths that are not tracked */ baselen = fill_directory(dir, pathspec); if (pathspec.nr) - seen = prune_directory(dir, pathspec._raw, baselen); + seen = prune_directory(dir, pathspec, baselen); } if (refresh_only) { @@ -420,17 +414,16 @@ int cmd_add(int argc, const char **argv, const char *prefix) path_exclude_check_init(check, dir); if (!seen) - seen = find_used_pathspec(pathspec._raw); - for (i = 0; pathspec._raw[i]; i++) { - if (!seen[i] pathspec._raw[i][0] -!file_exists(pathspec._raw[i])) { + seen = find_used_pathspec(pathspec); + for (i = 0; i pathspec.nr; i++) { + const char *path = pathspec.items[i].match; + if (!seen[i] !file_exists(path)) { if (ignore_missing) { int dtype = DT_UNKNOWN; - if (path_excluded(check, pathspec._raw[i], -1, dtype)) - dir_add_ignored(dir, pathspec._raw[i], strlen(pathspec._raw[i])); + if (path_excluded(check, path, -1, dtype)) + dir_add_ignored(dir, path, pathspec.items[i].len); } else - die(_(pathspec '%s' did not match any files), - pathspec._raw[i]); + die(_(pathspec '%s' did not match any files), path); }
Re: [PATCH] git-completion.bash: Silence not a valid object errors
On Fri, Jan 11, 2013 at 03:06:22AM -0500, Dylan Smith wrote: Trying to complete the command git show master:./file would cause a Not a valid object name error to be output on standard error. Silence the error so it won't appear on the command line. Signed-off-by: Dylan Smith dylan.ah.sm...@gmail.com --- Thanks, I've been annoyed by this, too. The fix looks obviously correct. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: What's cooking in git.git (Jan 2013, #04; Wed, 9)
Duy Nguyen pclo...@gmail.com writes: On Thu, Jan 10, 2013 at 4:04 AM, Junio C Hamano gits...@pobox.com wrote: Here are the topics that have been cooking. Commits prefixed with '-' are only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'. I see you start to use no-change commits as a way to keep notes in 'pu'. Isn't git notes designed for that? It is not designed for this. You could (ab)use notes for that purpose, but at the semantic level, I do not think notes is a good match. The branches 'pu' and its subset 'jch' (designed to be slightly ahead of 'next', and this is what I regularly do my Git work with) are rebuilt on top of 'master' in every integration cycle (like 2 to 3 times a day). The insn to rebuild the latter currently looks like this (familiarity with the Documentation/howto/maintain-git.txt document in 'pu' would help understanding this section): $ cat Meta/redo-jch.sh Meta/Reintegrate \EOF jc/format-patch-reroll nd/retire-fnmatch ... jk/maint-fast-import-doc-reorder nd/upload-pack-shallow-must-be-commit ap/log-mailmap ### match next jc/doc-maintainer mk/complete-tcsh pe/doc-email-env-is-trumped-by-config as/check-ignore EOF The Reintegrate machinery merges the topic listed on each line, and the ### match next marks the point _between_ the two merges to remind me that merging everything before this line to 'master' must match what the 'next' branch has. The markers on 'pu' are similar. You can emulate that semantics by attaching a note to the merge commit that merges ap/log-mailmap topic, but that is unwieldy, and more importantly, it does not correctly express the meaning of the marker. I often reorder lines before that ### match next marker between integration rounds, to float topics that are more ready than others near the top, to make sure that they do not depend on other topics and cause mismerges when merged to 'master' without others. The next integration cycle may have ap/log-mailmap earlier, e.g. $ cat Meta/redo-jch.sh Meta/Reintegrate \EOF nd/upload-pack-shallow-must-be-commit ap/log-mailmap jc/format-patch-reroll ... jk/maint-fast-import-doc-reorder nd/retire-fnmatch ### match next jc/doc-maintainer mk/complete-tcsh ... and having a note on the previous merge of ap/log-mailmap does not help expressing the semantics correctly. It is not like I cease to declare the merge of ap/log-mailmap ought to match 'next' and now declare the merge of nk/retire-fnmatch ought to match 'next'. It's much clearer to have the marker as a separate entity, as opposed to emulating it with an attribute of a merge commit that happens to be adjacent to what I really want to mark (i.e. a place *between* two merge commits). Another way you could use notes to emulate this is to give each merge that comes before the marker line a note that says this merge is before the marker line. But it still is more work to present the result as here is a sequence, then a marker, and then another sequence, then another marker In short, notes may be able to emulate it but it is not the best tool for the job. It is not like I'll be running format-patch and rebasing these throw-away integration branches, so no-change commits are the best way to express what I want to in the history. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/2] improve-wincred-compatibility
On Thu, Jan 10, 2013 at 1:10 PM, Karsten Blees karsten.bl...@gmail.com wrote: Changes since initial version (see attached diff for details): - split in two patches - removed unused variables - improved the dll error message - changed ?: to if else - added comments Also available here: https://github.com/kblees/git/tree/kb/improve-wincred-compatibility-v2 git pull git://github.com/kblees/git.git kb/improve-wincred-compatibility-v2 Karsten Blees (2): wincred: accept CRLF on stdin to simplify console usage wincred: improve compatibility with windows versions .../credential/wincred/git-credential-wincred.c| 206 - 1 file changed, 75 insertions(+), 131 deletions(-) Wonderful! Acked-by: Erik Faye-Lund kusmab...@gmail.com -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] cvsimport: rewrite to use cvsps 3.x to fix major bugs
From: Eric S. Raymond e...@thyrsus.com ... diff --git a/git-cvsimport.perl b/git-cvsimport-fallback.perl similarity index 98% rename from git-cvsimport.perl rename to git-cvsimport-fallback.perl index 0a31ebd..4bc0717 100755 --- a/git-cvsimport.perl +++ b/git-cvsimport-fallback.perl @@ -1,4 +1,8 @@ #!/usr/bin/perl +# This code became obsolete in January 2013, and is retained only as a +# fallback from git-cvsimport.py for users who have only cvsps-2.x. +# It (and the code in cvsimport.py that calls it) should be removed +# once the 3.x version has had a reasonable time to propagate. # This tool is copyright (c) 2005, Matthias Urlichs. # It is released under the Gnu Public License, version 2. @@ -27,6 +31,10 @@ use POSIX qw(strftime tzset dup2 ENOENT); use IPC::Open2; +print(STDERR You do not appear to have cvsps 3.x.\n); +print(STDERR Falling back to unmaintained Perl cvsimport for cvsps 2.x.\n); +print(STDERR Upgrade your cvsps for best results.\n); I think the prevalent style in this script is to write print without parentheses: print STDERR msg\n; diff --git a/git-cvsimport.py b/git-cvsimport.py new file mode 100755 index 000..129471e --- /dev/null +++ b/git-cvsimport.py @@ -0,0 +1,354 @@ +#!/usr/bin/env python +# +# Import CVS history into git +# +# Intended to be a near-workalike of Matthias Urlichs's Perl implementation. ... +class cvsps: +Method class for cvsps back end. +def __init__(self): +self.opts = +self.revmap = None +def set_repo(self, val): +Set the repository root option. +if not val.startswith(:): +if not val.startswith(os.sep): +val = os.path.abspath(val) +val = :local: + val +self.opts += --root '%s' % val This looks lazy and unsafe quoting. Is there anything that makes sure repository path does not contain a single quote? +def set_authormap(self, val): +Set the author-map file. +self.opts += -A '%s' % val +def set_fuzz(self, val): +Set the commit-similarity window. +self.opts += -z %s % val +def set_nokeywords(self): +Suppress CVS keyword expansion. +self.opts += -k +def add_opts(self, val): +Add options to the engine command line. +self.opts += + val ... especially for callers of this method. The same comment applies to many uses of val in the method implementations of this class and the cvs2git class. +def command(self): +Emit the command implied by all previous options. +return (cvs2git --username=git-cvsimport --quiet --quiet --blobfile={0} --dumpfile={1} {2} {3} cat {0} {1} rm {0} {1}).format(tempfile.mkstemp()[1], tempfile.mkstemp()[1], self.opts, self.modulepath) Could we do something better with this overlong source line? +if __name__ == '__main__': ... +for (opt, val) in options: +if opt == '-v': +verbose += 1 +elif opt == '-b': +bare = True +elif opt == '-e': +for cls in (cvsps, cvs2git): +if cls.__name__ == val: +backend = cls() +break +else: +sys.stderr.write(git cvsimport: unknown engine %s.\n % val) +sys.exit(1) +elif opt == '-d': +backend.set_repo(val) +elif opt == '-C': +outdir = val +elif opt == '-r': +remotize = True +elif opt == '-o': +sys.stderr.write(git cvsimport: -o is no longer supported.\n) +sys.exit(1) Isn't this a regression? +elif opt == '-i': +import_only = True +elif opt == '-k': +backend.set_nokeywords() +elif opt == '-u': +underscore_to_dot = True +elif opt == '-s': +slashsubst = val +elif opt == '-p': +backend.add_opts(val.replace(,, )) +elif opt == '-z': ... +elif opt == '-P': +backend = filesource(val) +sys.exit(1) ??? +elif opt in ('-m', '-M'): +sys.stderr.write(git cvsimport: -m and -M are no longer supported: use reposurgeon instead.\n) +sys.exit(1) I wonder if it is better to ignore these options with a warning but still let the command continue; cvsps-3.x was supposed to get merges right without the help of these ad-hoc options, no? Otherwise it looks like a regression to me. +elif opt == '-S': +backend.set_exclusion(val) +elif opt == '-a': +sys.stderr.write(git cvsimport: -a is no longer supported.\n) +sys.exit(1) +elif opt == '-L': +sys.stderr.write(git cvsimport: -L is no longer supported.\n) +sys.exit(1) +elif opt == '-A': +authormap = os.path.abspath(val) +
git send-email should not allow 'y' for in-reply-to
[raising this UI wart to the git list] On 01/11/2013 01:42 AM, Peter Krempa wrote: On 01/11/13 07:31, Chunyan Liu wrote: This patch series is to... [snip] Please don't answer y when git send email shows the following prompt: Message-ID to be used as In-Reply-To for the first email? you should respond with a message ID there. Unfortunately we have a growing thread that contains submissions with this mistake. Anyone willing to patch upstream 'git send-email' to reject a simple 'y' rather than blindly sending a bad messageID for the in-reply-to field, to help future users avoid this mistake? Obviously, it won't help until the patch eventually percolates into distros, so it would be a few more months before we see the benefits, but down the road it will prevent confusing threads. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: missing objects -- prevention
On Fri, Jan 11, 2013 at 04:40:38PM +0530, Sitaram Chamarty wrote: I find a lot of info on how to recover from and/or repair a repo that has missing (or corrupted) objects. What I need is info on common reasons (other than disk errors -- we've checked for those) for such errors to occur, any preventive measures we can take, and so on. I don't think any race can cause corruption of the object or packfiles because of the way they are written. At GitHub, every case of file-level corruption we've seen has been a filesystem issue. So I think the main thing systemic/race issue to worry about is missing objects. And since git only deletes objects during a prune (assuming you are using git-gc or repack -A so that repack cannot drop objects), I think prune is the only thing to watch out for. The --expire time saves us from the obvious races where you write object X but have not yet referenced it, and a simultaneous prune wants to delete it. However, it's possible that you have an old object that is unreferenced, but would become referenced as a result of an in-progress operation. For example, commit X is unreferenced and ready to be pruned, you build commit Y on top of it, but before you write the ref, git-prune removes X. The server-side version of that would happen via receive-pack, and is even more unlikely, because X would have to be referenced initially for us to advertise it. So it's something like: 1. The repo has a ref R pointing at commit X. 2. A user starts a push to another ref, Q, of commit Y that builds on X. Git advertises ref R, so the sender knows they do not need to send X, but only Y. The user then proceeds to send the packfile (which might take a very long time). 3. Meanwhile, another user deletes ref R. X becomes unreferenced. 4. After step 3 but before step 2 has finished, somebody runs prune (this might sound unlikely, but if you kick off a gc job after each push, or after N pushes, it's not so unlikely). It sees that X is unreferenced, and it may very well be older than the --expire setting. Prune deletes X. 5. The packfile in (2) arrives, and receive-pack attempts to update the refs. So it's even a bit more unlikely than the local case, because receive-pack would not otherwise build on dangling objects. You have to race steps (2) and (3) just to create the situation. Then we have an extra protection in the form of check_everything_connected, which receive-pack runs before writing the refs into place. So if step 4 happens while the packfile is being sent (which is the most likely case, since it is the longest stretch of receive-pack's time), we would still catch it there and reject the push (annoying to the user, but the repo remains consistent). However, that's not foolproof. We might hit step 4 after we've checked that everything is connected but right before we write the ref. In which case we drop X, which has just become referenced, and we have a missing object. So I think it's possible. But I have never actually seen it in practice, and come up with this scenario only by brainstorming what could go wrong scenarios. This could be mitigated if there was a proposed refs storage. Receive-pack would write a note saying consider Y for pruning purposes, but it's not really referenced yet, check connectivity for Y against the current refs, and then eventually write Y to its real ref (or reject it if there are problems). Prune would either run before the proposed note is written, which would mean it deletes X, but the connectivity check fails. Or it would run after, in which case it would leave X alone. For example, can *any* type of network error or race condition cause this? (Say, can one push writes an object, then fails an update check, and a later push succeeds and races against a gc that removes the unreachable object?) Or... the repo is pretty large -- about 6-7 GB, so could size cause a race that would not show up on a smaller repo? The above is the only open issue I know about. I don't think it is dependent on repo size, but the window is widened for a really large push, because rev-list takes longer to run. It does not widen if you have receive.fsckobjects set, because that happens before we do the connectivity check (and the connectivity check is run in a sub-process, so the race timer starts when we exec rev-list, which may open and mmap packfiles or otherwise cache the presence of X in memory). Anything else I can watch out for or caution the team about? That's the only open issue I know about for missing objects. There is a race with simultaneously deleting and packing refs. It doesn't cause object db corruption, but it will cause refs to rewind back to their packed versions. I have seen that one in practice (though relatively rare). I fixed it in b3f1280, which is not yet in any released version. The symptom is usually a disk space crunch caused by tmp_pack_* files left around by auto-gc.
Re: [PATCH] git-completion.bash: Silence not a valid object errors
Dylan Smith dylan.ah.sm...@gmail.com writes: Trying to complete the command git show master:./file would cause a Not a valid object name error to be output on standard error. Silence the error so it won't appear on the command line. Signed-off-by: Dylan Smith dylan.ah.sm...@gmail.com --- Looks obviously correct. Thanks. 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 0b77eb1..d4c7bfe 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -397,7 +397,7 @@ __git_complete_revlist_file () *) pfx=$ref:$pfx ;; esac - __gitcomp_nl $(git --git-dir=$(__gitdir) ls-tree $ls \ + __gitcomp_nl $(git --git-dir=$(__gitdir) ls-tree $ls 2/dev/null \ | sed '/^100... blob /{ s,^.*,, s,$, , -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
On Fri, Jan 11, 2013 at 09:39:06AM -0700, Eric Blake wrote: Please don't answer y when git send email shows the following prompt: Message-ID to be used as In-Reply-To for the first email? you should respond with a message ID there. Unfortunately we have a growing thread that contains submissions with this mistake. Anyone willing to patch upstream 'git send-email' to reject a simple 'y' rather than blindly sending a bad messageID for the in-reply-to field, to help future users avoid this mistake? Obviously, it won't help until the patch eventually percolates into distros, so it would be a few more months before we see the benefits, but down the road it will prevent confusing threads. What version of git? Commit 51bbccf is in v1.7.12.1 and higher, and says: $ git show 51bbccf commit 51bbccfd1b4a9e2807413022c56ab05c835164fb Author: Junio C Hamano gits...@pobox.com Date: Tue Aug 14 15:15:53 2012 -0700 send-email: validate reconfirm interactive responses People answer 'y' to Who should the emails appear to be from? and 'n' to Message-ID to be used as In-Reply-To for the first email? for some unknown reason. While it is possible that your local username really is y and you are sending the mail to your local colleagues, it is possible, and some might even say it is likely, that it is a user error. Fortunately, our interactive prompter already has input validation mechanism built-in. Enhance it so that we can optionally reconfirm and allow the user to pass an input that does not validate, and softly require input to the sender, in-reply-to, and recipient to contain @ and . in this order, which would catch most cases of mistakes. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH 09/19] reset.c: replace switch by if-else
Martin von Zweigbergk martinv...@gmail.com writes: Justification? Clairvoyance ... ;-) -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
On 01/11/2013 09:47 AM, Jeff King wrote: On Fri, Jan 11, 2013 at 09:39:06AM -0700, Eric Blake wrote: Please don't answer y when git send email shows the following prompt: Anyone willing to patch upstream 'git send-email' to reject a simple 'y' What version of git? Commit 51bbccf is in v1.7.12.1 and higher, and says: $ git show 51bbccf commit 51bbccfd1b4a9e2807413022c56ab05c835164fb Author: Junio C Hamano gits...@pobox.com Date: Tue Aug 14 15:15:53 2012 -0700 send-email: validate reconfirm interactive responses People answer 'y' to Who should the emails appear to be from? and 'n' to Message-ID to be used as In-Reply-To for the first email? for some unknown reason. While it is possible that your local username really is y and you are sending the mail to your local colleagues, it is possible, and some might even say it is likely, that it is a user error. Awesome! Already implemented! In the case that sparked this particular email, the culprit was using 1.7.3.4; earlier this month, a separate culprit to the same libvirt mailing list was using 1.7.11.7. I was right about it needing to take a few months to percolate to the actual users. -- Eric Blake eblake redhat com+1-919-301-3266 Libvirt virtualization library http://libvirt.org signature.asc Description: OpenPGP digital signature
Re: [PATCH v2 03/21] Export parse_pathspec() and convert some get_pathspec() calls
On Fri, Jan 11, 2013 at 06:20:57PM +0700, Nguyễn Thái Ngọc Duy wrote: +#define PATHSPEC_FROMTOP(10) The previous commit introduces a use of this macro in get_pathspec. Should this be defined by that commit instead? @@ -266,9 +266,9 @@ static int pathspec_item_cmp(const void *a_, const void *b_) * Given command line arguments and a prefix, convert the input to * pathspec. die() if any magic other than ones in magic_mask. */ -static void parse_pathspec(struct pathspec *pathspec, -unsigned magic_mask, unsigned flags, -const char *prefix, const char **argv) +void parse_pathspec(struct pathspec *pathspec, + unsigned magic_mask, unsigned flags, The prototype for this function uses just magic instead of magic_mask. Should they be consistent? -- Matt -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: parsecvs has been salvaged
Very cool! I'm glad you got it doing what you wanted; I'll be interested to see how parsecvs compares in quality and performance to cvs2git and cvsps. --Bart On Fri, Jan 11, 2013 at 3:21 AM, Eric S. Raymond e...@thyrsus.com wrote: Since Heiko Voigt and others were concerned about this, I report that I have successfully salvaged the parsecvs code. I now have it emitting a correct-looking fast-import stream for my main test repository. I'm not ready to ship it yet because there are several features I think it ought to have before I do. An -R option like cvsps's; correct interpretation of a third timezone field as in cvsps; and, most significantly, I want to make sure it emits warnings for important error and problem conditions like unresolvable tags and absence of commitids. But these are all relatively minor issues. It is likely I will be able to ship early next week, at which point I will add support for parsecvs as a third engine in new cvsimport. This next step in the larger program will be factoring out the cvsps test suite and applying it to all three of cvsps, cvs2git, and parsecvs so I can compare results. -- a href=http://www.catb.org/~esr/;Eric S. Raymond/a Americans have the right and advantage of being armed - unlike the citizens of other countries whose governments are afraid to trust the people with arms. -- James Madison, The Federalist Papers -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
On 11 January 2013 08:47, Jeff King p...@peff.net wrote: On Fri, Jan 11, 2013 at 09:39:06AM -0700, Eric Blake wrote: Please don't answer y when git send email shows the following prompt: Message-ID to be used as In-Reply-To for the first email? you should respond with a message ID there. Unfortunately we have a growing thread that contains submissions with this mistake. snip/ People answer 'y' to Who should the emails appear to be from? and 'n' to Message-ID to be used as In-Reply-To for the first email? for some unknown reason. While it is possible that your local username really is y and you are sending the mail to your local colleagues, it is possible, and some might even say it is likely, that it is a user error. I have never used Git's email support so this doesn't affect me one way or another but it seems that checking the results is fixing the symptoms, not the problem? I apologize if this was already discussed but I couldn't find such a discussion. I was wondering if it might be a better idea to change the wording of the questions if they have proven so confusing? The first time (just now) that I read Message-ID to be used as In-Reply-To for the first email?, it clearly seemed like a yes/no question to me. :-) How about What Message-ID to use as In-Reply-To for the first email? or Provide the Message-ID to use as In-Reply-To for the first email:. I'm a little surprised that Who should the emails appear to be from? would be interpreted as a yes/no question but we could rephrase that similarly as Provide the name of the email sender: (I don't really like this particular version but you get the idea). -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v5] git-completion.bash: add support for path completion
The git-completion.bash script did not implemented full, git aware, support to complete paths, for git commands that operate on files within the current working directory or the index. As an example: git add TAB will suggest all files in the current working directory, including ignored files and files that have not been modified. Support path completion, for git commands where the non-option arguments always refer to paths within the current working directory or the index, as follows: * the path completion for the git rm and git ls-files commands will suggest all cached files. * the path completion for the git add command will suggest all untracked and modified files. Ignored files are excluded. * the path completion for the git clean command will suggest all untracked files. Ignored files are excluded. * the path completion for the git mv command will suggest all cached files when expanding the first argument, and all untracked and cached files for subsequent arguments. In the latter case, empty directories are included and ignored files are excluded. * the path completion for the git commit command will suggest all files that have been modified from the HEAD, if HEAD exists, otherwise it will suggest all cached files. For all affected commands, completion will always stop at directory boundary. Only standard ignored files are excluded, using the --exclude-standard option of the ls-files command. When using a recent Bash version, Git path completion will be the same as builtin file completion, e.g. git add contrib/ will suggest relative file names. Signed-off-by: Manlio Perillo manlio.peri...@gmail.com --- Changes: * Applied Junio patch to fix completion inside a subdirectory. * Quoted the hopefully last incorrectly unquoted variable. * Fixed coding style (removed stdout file descriptor in shell redirection, since it is redundant). * Fixed regression in path completion, when using non canonicalized or absolute path names. The problem has been solved making sure to chdir to the specified directory before executing ls-files and diff-index commands. The only issue is that there is no tilde expansion, but this is harmless, since default bash completion will be used (the old behaviour). * Improved path completion when the new compopt builtin is available (Bash = 4.x). Now git paths completion is done in exactly the same way as Bash builtin filenames completion. * Updated the zsh compatibility code to use the improved path completion support * Fixed incorrect git mv arguments count used to check the first path to be renamed. When options are used (unless they are git main options), -- is required to separate options from non options arguments. It is harmless to not use --; in this case bash will suggest untracked files and directories for the first argument. XXX: should I add this implementation note in the commit message? * Make sure to sort ls-files and diff-index filtered output before removing duplicate directories. * Merged master. Please note that before merging this patch in next, we need to update the zsh and tcsh completion scripts. I have the changes ready, but I will post them later since both scripts needs more patches (I have posted an informal patch for zsh, and changes to tcsh should be in pu, but I need to test them). contrib/completion/git-completion.bash | 250 ++--- 1 file changed, 234 insertions(+), 16 deletions(-) diff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash index a4c48e1..51b8b3b 100644 --- a/contrib/completion/git-completion.bash +++ b/contrib/completion/git-completion.bash @@ -13,6 +13,7 @@ #*) .git/remotes file names #*) git 'subcommands' #*) tree paths within 'ref:path/to/file' expressions +#*) file paths within current working directory and index #*) common --long-options # # To use these routines: @@ -233,6 +234,118 @@ __gitcomp_nl () COMPREPLY=($(compgen -P ${2-} -S ${4- } -W $1 -- ${3-$cur})) } +# Generates completion reply with compgen from newline-separated possible +# completion filenames. +# It accepts 1 to 3 arguments: +# 1: List of possible completion filenames, separated by a single newline. +# 2: A directory prefix to be added to each possible completion filename +#(optional). +# 3: Generate possible completion matches for this word (optional). +__gitcomp_file () +{ + local IFS=$'\n' + + # XXX does not work when the directory prefix contains a tilde, + # since tilde expansion is not applied. + # This means that COMPREPLY will be empty and Bash default + # completion will be used. + COMPREPLY=($(compgen -P ${2-} -W $1
Re: git send-email should not allow 'y' for in-reply-to
On Fri, Jan 11, 2013 at 10:43:39AM -0800, Hilco Wijbenga wrote: People answer 'y' to Who should the emails appear to be from? and 'n' to Message-ID to be used as In-Reply-To for the first email? for some unknown reason. While it is possible that your local username really is y and you are sending the mail to your local colleagues, it is possible, and some might even say it is likely, that it is a user error. I have never used Git's email support so this doesn't affect me one way or another but it seems that checking the results is fixing the symptoms, not the problem? I apologize if this was already discussed but I couldn't find such a discussion. It depends on who you are. If you are the person running send-email, then the symptom is your confusion. If you are somebody else, the symptom is somebody else sending out a bogus email. That patch fixes only the latter. :) More seriously, I agree that re-wording the question is a reasonable thing to do. I do not use send-email, either, so I don't have a strong opinion on it. The suggestions you made: How about What Message-ID to use as In-Reply-To for the first email? or Provide the Message-ID to use as In-Reply-To for the first email:. seem fine to me. Maybe somebody who has been confused by it can offer more. At any rate, patches welcome. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] cvsimport: rewrite to use cvsps 3.x to fix major bugs
Eric S. Raymond e...@thyrsus.com writes: Junio C Hamano gits...@pobox.com: I think the prevalent style in this script is to write print without parentheses: print STDERR msg\n; That can be easily fixed. This looks lazy and unsafe quoting. Is there anything that makes sure repository path does not contain a single quote? No. But...wait, checking...the Perl code didn't have the analogous check, so there's no increased vulnerability here. I'll put it on the to-do list for after I ship parsecvs. I checked before I sent that review, and as far as I could tell, it was fairly consistently avoiding the lazy and insecure forms, e.g. system(com mand . $param); open($fh, com mand . $param . |); while ($fh) { ... } but used the more sequre list form, e.g. system(qw(com mand), $param); open($fh, -|, qw(com mand), $param); while ($fh){ ... } But of course there may be some places that were careless that I didn't spot (and previous reviewers of the current cvsimport didn't). -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] cvsimport: rewrite to use cvsps 3.x to fix major bugs
Eric S. Raymond e...@thyrsus.com writes: Junio C Hamano gits...@pobox.com: ... The other is a design-level problem - these options were a bad idea to begin with. In earlier list mail I said An example of the batchiness mistake close to home is the -m and -M options in the old version of cvsimport. It takes human judgment looking at the whole commit DAG in gitspace to decide what merge points would best express the (as you say, sometimes ambiguous) CVS history - what's needed is a scalpel and sutures in a surgeon's hand, not a regexp hammer. One specific problem with the regexp hammer is false-positive matches leading to unintended merges. Yeah, it is OK to _discourage_ its use, but to me it looks like that the above is a fairly subjective policy decision, not something I should let you impose on the users of the old cvsimport, which you do not seem to even treat as your users. Having the code to die when it sees options the rewritten version does not yet support before it calls the fallback makes the fallback much less effective, no? Only to the extent that -o/-m/-M are really important, which I doubt. But that might be fixable, and I'll put it on the to-do list. Not very impressed (yet). The advertised fix major bugs sounds more like trade major bugs with different ones with a couple of feature removals at this point. If you think that, you have failed to understand just how broken and dangerous the old combination is. None of the details you've called out are major by any stretch of the imagination compared to it silently botching the translation of repositories. The major in my sentence was from your description (the bugs you fixed), and not about the new ones you still have in this draft. I did not mean to say that you are trading fixes to major bugs with different major bugs. Insecure quoting of parameters is much easier to fix; it does need to be addressed, though. It is just that looking at the state of the patch as submitted left me with a feeling that this topic needs a lot more time to mature than I previously was led to believe by your earlier messages, which made me someaht sad. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Version 1.8.1 does not compile on Cygwin 1.7.14
This short discussion on GitHub (file git-compat-util.h) might be relevant: https://github.com/msysgit/git/commit/435bdf8c7ffa493f8f6f2e8f329f8cc22db16ce6#commitcomment-2407194 The change suggested there (to remove an inclusion of windows.h in git-compat-util.h) might simplify the solution a little. Might even remove the need for auto-configuration in Makefile (worked for me). -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: Version 1.8.1 does not compile on Cygwin 1.7.14
On Fri, Jan 11, 2013 at 9:08 PM, Alex Riesen raa.l...@gmail.com wrote: This short discussion on GitHub (file git-compat-util.h) might be relevant: https://github.com/msysgit/git/commit/435bdf8c7ffa493f8f6f2e8f329f8cc22db16ce6#commitcomment-2407194 The change suggested there (to remove an inclusion of windows.h in git-compat-util.h) might simplify the solution a little. Might even remove the need for auto-configuration in Makefile (worked for me). Just to be clear, the change is this: diff --git a/git-compat-util.h b/git-compat-util.h index 4a1979f..780a919 100644 --- a/git-compat-util.h +++ b/git-compat-util.h @@ -85,12 +85,6 @@ #define _NETBSD_SOURCE 1 #define _SGI_SOURCE 1 -#ifdef WIN32 /* Both MinGW and MSVC */ -#define WIN32_LEAN_AND_MEAN /* stops windows.h including winsock.h */ -#include winsock2.h -#include windows.h -#endif - #include unistd.h #include stdio.h #include sys/stat.h -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[BUG]:Git doesn't work with Sock5 proxy on MAC
On Thu, Jan 10, 2013 at 9:51 PM, Herry Wang tech.he...@gmail.com wrote: OS: Darwin ... 11.4.2 Darwin Kernel Version 11.4.2: Thu Aug 23 16:25:48 PDT 2012; root:xnu-1699.32.7~1/RELEASE_X86_64 x86_64 Git: version: (via homebrew) git --version git version 1.8.0 curl version: curl --version curl 7.28.1 (x86_64-apple-darwin11.4.2) git clone http://herry@stash.somesite/a.git Cloning into 'a'... error: Empty reply from server while accessing git/info/refs?service=git-upload-pack fatal: HTTP request failed i tried export http_proxy=socks5://ip:port, all_proxy=socks5://, neither of them works. I also configure socks proxy in ~/.curlrc, git is not working well. However, curl is doing well with curlrc config. From the trace, looks like git is just put the http request via proxy host. But according with socks protocol, it should have some headers. Interesting thing is, http_proxy way is working perfectly on my Ubuntu enviroment. Thanks Herry -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
Jeff King p...@peff.net wrote in message news:2013085417.ga12...@sigill.intra.peff.net... On Fri, Jan 11, 2013 at 10:43:39AM -0800, Hilco Wijbenga wrote: How about What Message-ID to use as In-Reply-To for the first email? or Provide the Message-ID to use as In-Reply-To for the first email:. seem fine to me. Maybe somebody who has been confused by it can offer more. At any rate, patches welcome. Suggestion: Message-ID to use as In-Reply-To for the first email:. Simple and unlikely to generate a y or n response. Putting Message-ID first makes it more obvious what data is being asked for by this prompt. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git-archive fails against smart-http repos
On Wed, Jan 09, 2013 at 10:52:48AM -0800, Bruce Lysik wrote: Trying to run git-archive fails against smart-http based repos. Example: $ git archive --verbose --format=zip --remote=http://code.toofishes.net/git/dan/initscripts.git fatal: Operation not supported by protocol. Unexpected end of command stream This problem was brought up against my internal repos as well. Right. Neither the client nor server for the http transport knows how to handle the git-upload-archive service (as opposed to the regular git-upload-pack or git-receive-pack services). I don't think there's anything technical standing in the way; it is has simply never been implemented. Currently, you can do remote git-archive only locally, via ssh, or over git:// (but then only if the server side has explicitly enabled it). Patches welcome. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] git-completion.bash: Silence not a valid object errors
-BEGIN PGP SIGNED MESSAGE- Hash: SHA1 Il 11/01/2013 09:06, Dylan Smith ha scritto: Trying to complete the command git show master:./file would cause a Not a valid object name error to be output on standard error. Silence the error so it won't appear on the command line. I reported the problem a few weeks ago; thanks. [...] Regards Manlio -BEGIN PGP SIGNATURE- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAlDwgCAACgkQscQJ24LbaUTAxgCfZbB8X8IaTZAcT8iTs1XIILBJ 72MAn2zlh3xbRa/wjq1WyA2yOiAlaCr7 =dMN7 -END PGP SIGNATURE- -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
On Fri, Jan 11, 2013 at 08:13:57PM +, Matt Seitz (matseitz) wrote: How about What Message-ID to use as In-Reply-To for the first email? or Provide the Message-ID to use as In-Reply-To for the first email:. seem fine to me. Maybe somebody who has been confused by it can offer more. At any rate, patches welcome. Suggestion: Message-ID to use as In-Reply-To for the first email:. Simple and unlikely to generate a y or n response. Putting Message-ID first makes it more obvious what data is being asked for by this prompt. You'd think. But the existing message that has been causing problems is: Message-ID to be used as In-Reply-To for the first email? which is more or less what you are proposing. I do think a colon rather than a question mark helps indicate that the response is not yes/no. -Peff -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
On Fri, Jan 11, 2013 at 10:23 PM, Jeff King p...@peff.net wrote: On Fri, Jan 11, 2013 at 08:13:57PM +, Matt Seitz (matseitz) wrote: How about What Message-ID to use as In-Reply-To for the first email? or Provide the Message-ID to use as In-Reply-To for the first email:. seem fine to me. Maybe somebody who has been confused by it can offer more. At any rate, patches welcome. Suggestion: Message-ID to use as In-Reply-To for the first email:. Simple and unlikely to generate a y or n response. Putting Message-ID first makes it more obvious what data is being asked for by this prompt. You'd think. But the existing message that has been causing problems is: Message-ID to be used as In-Reply-To for the first email? which is more or less what you are proposing. I do think a colon rather than a question mark helps indicate that the response is not yes/no. That is true. I'm definitely not a wording person, but assuming people who make the mistake probably don't read the whole sentence out of laziness (that might be somehow extreme though ;), starting it with what makes it obvious at first sight that you can't answer yes/no. That is not true if the message starts with Message-ID .. which doesn't look like a question. Now it feels like you have agree or not. Antoine, -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v5] git-completion.bash: add support for path completion
Manlio Perillo manlio.peri...@gmail.com writes: +# Process path list returned by ls-files and diff-index --name-only +# commands, in order to list only file names relative to a specified +# directory, and append a slash to directory names. +__git_index_file_list_filter () +{ + # Default to Bash = 4.x + __git_index_file_list_filter_bash +} + +# Execute git ls-files, returning paths relative to the directory +# specified in the first argument, and using the options specified in +# the second argument. +__git_ls_files_helper () +{ + # NOTE: $2 is not quoted in order to support multiple options + cd $1 git ls-files --exclude-standard $2 +} 2/dev/null I think this redirection is correct but a bit tricky; it is in effect during the execution of the { block } (in other words, it is not about squelching errors during the function definition). -- 8 -- #!/bin/sh cat t.sh \EOF echo I am $1 t () { echo Goes to stdout; echo 2 Goes to stderr; } 2/dev/null t for sh in bash dash ksh zsh do $sh t.sh $sh done -- 8 -- Bash does (so do dash and real ATT ksh) grok this correctly, but zsh does not seem to (I tried zsh 4.3.10 and 4.3.17; also zsh pretending to be ksh gets this wrong as well). Not that what ksh does matters, as it won't be dot-sourcing bash completion script. It however may affect zsh, which does seem to dot-source this file. Perhaps zsh completion may have to be rewritten in a similar way as tcsh completion is done (i.e. does not dot-source this file but ask bash to do the heavy-lifting). This function seems to be always called in an subshell (e.g. as an upstream of a pipeline), so the cd may be harmless, but don't you need to disable CDPATH while doing this? +# Execute git diff-index, returning paths relative to the directory +# specified in the first argument, and using the tree object id +# specified in the second argument. +__git_diff_index_helper () +{ + cd $1 git diff-index --name-only --relative $2 +} 2/dev/null Ditto. @@ -722,6 +875,43 @@ __git_has_doubledash () return 1 } +# Try to count non option arguments passed on the command line for the +# specified git command. +# When options are used, it is necessary to use the special -- option to +# tell the implementation were non option arguments begin. +# XXX this can not be improved, since options can appear everywhere, as +# an example: +#git mv x -n y If that is the case, it is a bug in the command line parser, I think. We should reject it, and the command line completer certainly should not encourage it. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] format_commit_message(): simplify calls to logmsg_reencode()
All the other callers of logmsg_reencode() pass return value of get_commit_output_encoding() or get_log_output_encoding(). Teach the function to optionally take NULL as a synonym to aka no conversion requested so that we can simplify the only remaining calling site. Signed-off-by: Junio C Hamano gits...@pobox.com --- pretty.c | 16 1 file changed, 4 insertions(+), 12 deletions(-) diff --git a/pretty.c b/pretty.c index e87fe9f..732e2a2 100644 --- a/pretty.c +++ b/pretty.c @@ -500,7 +500,7 @@ char *logmsg_reencode(const struct commit *commit, char *encoding; char *out; - if (!*output_encoding) + if (!output_encoding || !*output_encoding) return NULL; encoding = get_header(commit, encoding); use_encoding = encoding ? encoding : utf8; @@ -1184,23 +1184,15 @@ void format_commit_message(const struct commit *commit, const struct pretty_print_context *pretty_ctx) { struct format_commit_context context; - static const char utf8[] = UTF-8; const char *output_enc = pretty_ctx-output_encoding; memset(context, 0, sizeof(context)); context.commit = commit; context.pretty_ctx = pretty_ctx; context.wrap_start = sb-len; - context.message = commit-buffer; - if (output_enc) { - char *enc = get_header(commit, encoding); - if (strcmp(enc ? enc : utf8, output_enc)) { - context.message = logmsg_reencode(commit, output_enc); - if (!context.message) - context.message = commit-buffer; - } - free(enc); - } + context.message = logmsg_reencode(commit, output_enc); + if (!context.message) + context.message = commit-buffer; strbuf_expand(sb, format, format_commit_item, context); rewrap_message_tail(sb, context, 0, 0, 0); -- 1.8.1.407.g91cb4ac -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] format_commit_message(): simplify calls to logmsg_reencode()
Please disregard this... -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
Antoine Pelisse apeli...@gmail.com writes: On Fri, Jan 11, 2013 at 10:23 PM, Jeff King p...@peff.net wrote: On Fri, Jan 11, 2013 at 08:13:57PM +, Matt Seitz (matseitz) wrote: How about What Message-ID to use as In-Reply-To for the first email? or Provide the Message-ID to use as In-Reply-To for the first email:. seem fine to me. Maybe somebody who has been confused by it can offer more. At any rate, patches welcome. Suggestion: Message-ID to use as In-Reply-To for the first email:. Simple and unlikely to generate a y or n response. Putting Message-ID first makes it more obvious what data is being asked for by this prompt. You'd think. But the existing message that has been causing problems is: Message-ID to be used as In-Reply-To for the first email? which is more or less what you are proposing. I do think a colon rather than a question mark helps indicate that the response is not yes/no. That is true. I'm definitely not a wording person, but assuming people who make the mistake probably don't read the whole sentence out of laziness (that might be somehow extreme though ;), starting it with what makes it obvious at first sight that you can't answer yes/no. That is not true if the message starts with Message-ID .. which doesn't look like a question. Now it feels like you have agree or not. The exchange, when you do not have a configuration, goes like this: $ git send-email 0001-filename-of-the-patch.patch 0001-filename-of-the-patch.patch Who should the emails be sent to (if any)? junio Are you sure you want to use junio [y/N]? y Message-ID to be used as In-Reply-To for the first email (if any)? Why not do this instead? $ git send-email 0001-filename-of-the-patch.patch 0001-filename-of-the-patch.patch Who should the emails be sent to (if any)? junio Are you sure you want to use junio [y/N]? y Is this a response to an existing message [y/N]? y What is the Message-ID of the message you are replying to? -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
On Fri, Jan 11, 2013 at 11:18 PM, Junio C Hamano gits...@pobox.com wrote: The exchange, when you do not have a configuration, goes like this: $ git send-email 0001-filename-of-the-patch.patch 0001-filename-of-the-patch.patch Who should the emails be sent to (if any)? junio Are you sure you want to use junio [y/N]? y Message-ID to be used as In-Reply-To for the first email (if any)? Why not do this instead? $ git send-email 0001-filename-of-the-patch.patch 0001-filename-of-the-patch.patch Who should the emails be sent to (if any)? junio Are you sure you want to use junio [y/N]? y Is this a response to an existing message [y/N]? y I'm not sure about the extra question. If the user doesn't care, he will probably use the empty default, which will result in the same number of steps. If the user cares, he probably knows what he's doing and will give a sensible value. What is the Message-ID of the message you are replying to? I would simply go for: What Message-ID are you replying to (if any)? If I don't know what to answer, I would definitely not say y/yes/n/no, but press enter directly. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
Antoine Pelisse apeli...@gmail.com writes: I would simply go for: What Message-ID are you replying to (if any)? If I don't know what to answer, I would definitely not say y/yes/n/no, but press enter directly. Sounds sensible (even though technically you reply to a message that has that message ID, and not to a message ID ;-)). Any better phrasing from others? If not, I'd say we adopt this text. Thanks. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
What's cooking in git.git (Jan 2013, #05; Fri, 11)
Here are the topics that have been cooking. Commits prefixed with '-' are only in 'pu' (proposed updates) while commits prefixed with '+' are in 'next'. As usual, this cycle is expected to last for 8 to 10 weeks, with a preview -rc0 sometime in the middle of next month. You can find the changes described here in the integration branches of the repositories listed at http://git-blame.blogspot.com/p/git-public-repositories.html -- [Graduated to master] * as/api-allocation-doc (2013-01-06) 1 commit (merged to 'next' on 2013-01-08 at c80b544) + api-allocation-growing.txt: encourage better variable naming * as/dir-c-cleanup (2012-12-28) 10 commits (merged to 'next' on 2013-01-08 at 5aee090) + dir.c: rename free_excludes() to clear_exclude_list() + dir.c: refactor is_path_excluded() + dir.c: refactor is_excluded() + dir.c: refactor is_excluded_from_list() + dir.c: rename excluded() to is_excluded() + dir.c: rename excluded_from_list() to is_excluded_from_list() + dir.c: rename path_excluded() to is_path_excluded() + dir.c: rename cryptic 'which' variable to more consistent name + Improve documentation and comments regarding directory traversal API + api-directory-listing.txt: update to match code (this branch is used by as/check-ignore.) Refactor and generally clean up the directory traversal API implementation. * aw/rebase-am-failure-detection (2012-10-11) 1 commit (merged to 'next' on 2013-01-07 at 9e2ee43) + rebase: Handle cases where format-patch fails Originally merged to 'next' on 2013-01-02 Save output from format-patch command in a temporary file, just in case it aborts, to give a better failure-case behaviour. * jc/comment-cygwin-win32api-in-makefile (2013-01-06) 1 commit (merged to 'next' on 2013-01-08 at dea04e8) + Makefile: add comment on CYGWIN_V15_WIN32API * jc/maint-fmt-merge-msg-no-edit-lose-credit (2012-12-28) 1 commit (merged to 'next' on 2013-01-07 at 497bf10) + merge --no-edit: do not credit people involved in the side branch Originally merged to 'next' on 2013-01-02 Stop spending cycles to compute information to be placed on commented lines in merge --no-edit. * jk/config-uname (2013-01-03) 1 commit (merged to 'next' on 2013-01-08 at f986500) + Makefile: hoist uname autodetection to config.mak.uname Move the bits to set fallback default based on the platform from the main Makefile to a separate file, so that it can be included in Makefiles in subdirectories. * jl/interrupt-clone-remove-separate-git-dir (2013-01-05) 1 commit (merged to 'next' on 2013-01-08 at 568f874) + clone: support atomic operation with --separate-git-dir When git clone --separate-git-dir is interrupted, we failed to remove the real location we created the repository. * mz/pick-unborn (2012-12-23) 2 commits (merged to 'next' on 2013-01-07 at c6c062b) + learn to pick/revert into unborn branch + tests: move test_cmp_rev to test-lib-functions Originally merged to 'next' on 2013-01-02 Allows git cherry-pick $commit when you do not have any history behind HEAD yet. * nd/wildmatch (2013-01-01) 18 commits (merged to 'next' on 2013-01-07 at 2a39f7d) + wildmatch: replace variable 'special' with better named ones + compat/fnmatch: respect NO_FNMATCH* even on glibc + wildmatch: fix ** special case + t3070: Disable some failing fnmatch tests + test-wildmatch: avoid Windows path mangling + Support ** wildcard in .gitignore and .gitattributes + wildmatch: make /**/ match zero or more directories + wildmatch: adjust ** behavior + wildmatch: fix case-insensitive matching + wildmatch: remove static variable force_lower_case + wildmatch: make wildmatch's return value compatible with fnmatch + t3070: disable unreliable fnmatch tests + Integrate wildmatch to git + wildmatch: follow Git's coding convention + wildmatch: remove unnecessary functions + Import wildmatch from rsync + ctype: support iscntrl, ispunct, isxdigit and isprint + ctype: make sane_ctype[] const array (this branch is used by nd/retire-fnmatch.) Originally merged to 'next' on 2013-01-01 Allows pathname patterns in .gitignore and .gitattributes files with double-asterisks foo/**/bar to match any number of directory hierarchies. * rs/leave-base-name-in-name-field-of-tar (2013-01-05) 1 commit (merged to 'next' on 2013-01-08 at 98f325e) + archive-tar: split long paths more carefully Improve compatibility with implementations of tar that do not like empty name field in header (with the additional prefix field holding everything). * tb/test-shell-lint (2013-01-02) 1 commit (merged to 'next' on 2013-01-07 at 0bca54a) + test: Add check-non-portable-shell.pl Originally merged to 'next' on 2013-01-04 Check for common mistakes in the test scripts, based on simple pattern-matching. -- [New Topics] * jk/maint-fast-import-doc-reorder (2013-01-09) 2 commits
Re: missing objects -- prevention
Thanks for the very detailed answer. On Fri, Jan 11, 2013 at 10:12 PM, Jeff King p...@peff.net wrote: On Fri, Jan 11, 2013 at 04:40:38PM +0530, Sitaram Chamarty wrote: I find a lot of info on how to recover from and/or repair a repo that has missing (or corrupted) objects. What I need is info on common reasons (other than disk errors -- we've checked for those) for such errors to occur, any preventive measures we can take, and so on. I don't think any race can cause corruption of the object or packfiles because of the way they are written. At GitHub, every case of file-level corruption we've seen has been a filesystem issue. So I think the main thing systemic/race issue to worry about is missing objects. And since git only deletes objects during a prune (assuming you are using git-gc or repack -A so that repack cannot drop objects), I think prune is the only thing to watch out for. No one runs anything manually under normal conditions. If there's any gc happening, it's gc --auto. The --expire time saves us from the obvious races where you write object X but have not yet referenced it, and a simultaneous prune wants to delete it. However, it's possible that you have an old object that is unreferenced, but would become referenced as a result of an in-progress operation. For example, commit X is unreferenced and ready to be pruned, you build commit Y on top of it, but before you write the ref, git-prune removes X. The server-side version of that would happen via receive-pack, and is even more unlikely, because X would have to be referenced initially for us to advertise it. So it's something like: 1. The repo has a ref R pointing at commit X. 2. A user starts a push to another ref, Q, of commit Y that builds on X. Git advertises ref R, so the sender knows they do not need to send X, but only Y. The user then proceeds to send the packfile (which might take a very long time). 3. Meanwhile, another user deletes ref R. X becomes unreferenced. The gitolite logs show that no deletion of refs has happened. 4. After step 3 but before step 2 has finished, somebody runs prune (this might sound unlikely, but if you kick off a gc job after each push, or after N pushes, it's not so unlikely). It sees that X is unreferenced, and it may very well be older than the --expire setting. Prune deletes X. 5. The packfile in (2) arrives, and receive-pack attempts to update the refs. So it's even a bit more unlikely than the local case, because receive-pack would not otherwise build on dangling objects. You have to race steps (2) and (3) just to create the situation. Then we have an extra protection in the form of check_everything_connected, which receive-pack runs before writing the refs into place. So if step 4 happens while the packfile is being sent (which is the most likely case, since it is the longest stretch of receive-pack's time), we would still catch it there and reject the push (annoying to the user, but the repo remains consistent). However, that's not foolproof. We might hit step 4 after we've checked that everything is connected but right before we write the ref. In which case we drop X, which has just become referenced, and we have a missing object. So I think it's possible. But I have never actually seen it in practice, and come up with this scenario only by brainstorming what could go wrong scenarios. This could be mitigated if there was a proposed refs storage. Receive-pack would write a note saying consider Y for pruning purposes, but it's not really referenced yet, check connectivity for Y against the current refs, and then eventually write Y to its real ref (or reject it if there are problems). Prune would either run before the proposed note is written, which would mean it deletes X, but the connectivity check fails. Or it would run after, in which case it would leave X alone. For example, can *any* type of network error or race condition cause this? (Say, can one push writes an object, then fails an update check, and a later push succeeds and races against a gc that removes the unreachable object?) Or... the repo is pretty large -- about 6-7 GB, so could size cause a race that would not show up on a smaller repo? The above is the only open issue I know about. I don't think it is dependent on repo size, but the window is widened for a really large push, because rev-list takes longer to run. It does not widen if you have receive.fsckobjects set, because that happens before we do the connectivity check (and the connectivity check is run in a sub-process, so the race timer starts when we exec rev-list, which may open and mmap packfiles or otherwise cache the presence of X in memory). Anything else I can watch out for or caution the team about? That's the only open issue I know about for missing objects. There is a race with simultaneously deleting and packing
Re: git send-email should not allow 'y' for in-reply-to
On 12/01/2013 10:54 AM, Junio C Hamano wrote: Antoine Pelisse apeli...@gmail.com writes: I would simply go for: What Message-ID are you replying to (if any)? If I don't know what to answer, I would definitely not say y/yes/n/no, but press enter directly. Sounds sensible (even though technically you reply to a message that has that message ID, and not to a message ID ;-)). Any better phrasing from others? If not, I'd say we adopt this text. I guess it depends on how much we mind if people accidentally miss the message ID. If we don't mind much, we could say something like: What Message-ID are you replying to [Default=None]? If we are concerned that when a Message-ID exists, it should be provided, we could split to 2 questions: Are you replying to an existing Message [Y/n]? And then, if the answer is Y, What Message-ID are you replying to? Regards, Ben -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: git send-email should not allow 'y' for in-reply-to
Ben Aveling bena@optusnet.com.au writes: On 12/01/2013 10:54 AM, Junio C Hamano wrote: Antoine Pelisse apeli...@gmail.com writes: I would simply go for: What Message-ID are you replying to (if any)? If I don't know what to answer, I would definitely not say y/yes/n/no, but press enter directly. Sounds sensible (even though technically you reply to a message that has that message ID, and not to a message ID ;-)). Any better phrasing from others? If not, I'd say we adopt this text. I guess it depends on how much we mind if people accidentally miss the message ID. If we don't mind much, we could say something like: What Message-ID are you replying to [Default=None]? If we are concerned that when a Message-ID exists, it should be provided, we could split to 2 questions: Are you replying to an existing Message [Y/n]? And then, if the answer is Y, What Message-ID are you replying to? Eewww. Now we come back to full circles. It sometimes helps to follow the in-reply-to chain to see what has already been said in the thread, I guess ;-) -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] t9605: test for cvsps commit ordering bug
Import of a trivial CVS repository fails due to a cvsps bug. Given the following series of commits: timestamp abc message --- --- --- --- --- 2012/12/12 21:09:39 1.1changes are done 2012/12/12 21:09:441.1 changes 2012/12/12 21:09:461.2 changes 2012/12/12 21:09:50 1.1 1.3 changes are done cvsps mangles the commit ordering (edited for brevity): - PatchSet 1 Date: 2012/12/12 15:09:39 Log: changes are done Members: a:INITIAL-1.1 b:INITIAL-1.1 c:1.2-1.3 - PatchSet 2 Date: 2012/12/12 15:09:44 Log: changes Members: c:INITIAL-1.1 - PatchSet 3 Date: 2012/12/12 15:09:46 Log: changes Members: c:1.1-1.2 This is seen in cvsps versions 2.x and up through at least 3.7. Signed-off-by: Chris Rorvick ch...@rorvick.com --- Ran into this recently. No branching and no criss cross timestamps, just lazy commit messages. And it magically backed out a bug fix. This applies on top of master. With minor modifications I've tested it with Eric's latest code and confirmed the bug still exists. Chris t/t9605-cvsimport-commit-order.sh | 25 +++ t/t9605/cvsroot/.gitattributes | 1 + t/t9605/cvsroot/CVSROOT/.gitignore | 2 ++ t/t9605/cvsroot/module/a,v | 24 +++ t/t9605/cvsroot/module/b,v | 24 +++ t/t9605/cvsroot/module/c,v | 62 ++ 6 files changed, 138 insertions(+) create mode 100755 t/t9605-cvsimport-commit-order.sh create mode 100644 t/t9605/cvsroot/.gitattributes create mode 100644 t/t9605/cvsroot/CVSROOT/.gitignore create mode 100644 t/t9605/cvsroot/module/a,v create mode 100644 t/t9605/cvsroot/module/b,v create mode 100644 t/t9605/cvsroot/module/c,v diff --git a/t/t9605-cvsimport-commit-order.sh b/t/t9605-cvsimport-commit-order.sh new file mode 100755 index 000..ab4042e --- /dev/null +++ b/t/t9605-cvsimport-commit-order.sh @@ -0,0 +1,25 @@ +#!/bin/sh + +test_description='git cvsimport commit order' +. ./lib-cvs.sh + +setup_cvs_test_repository t9605 + +test_expect_success 'checkout with CVS' ' + + echo CVSROOT=$CVSROOT + cvs checkout -d module-cvs module +' + +test_expect_failure 'import into git (commit order mangled)' ' + + git cvsimport -R -a -p-x -C module-git module + ( + cd module-git + git merge origin + ) + test_cmp module-cvs/c module-git/c +false +' + +test_done diff --git a/t/t9605/cvsroot/.gitattributes b/t/t9605/cvsroot/.gitattributes new file mode 100644 index 000..562b12e --- /dev/null +++ b/t/t9605/cvsroot/.gitattributes @@ -0,0 +1 @@ +* -whitespace diff --git a/t/t9605/cvsroot/CVSROOT/.gitignore b/t/t9605/cvsroot/CVSROOT/.gitignore new file mode 100644 index 000..3bb9b34 --- /dev/null +++ b/t/t9605/cvsroot/CVSROOT/.gitignore @@ -0,0 +1,2 @@ +history +val-tags diff --git a/t/t9605/cvsroot/module/a,v b/t/t9605/cvsroot/module/a,v new file mode 100644 index 000..6455911 --- /dev/null +++ b/t/t9605/cvsroot/module/a,v @@ -0,0 +1,24 @@ +head 1.1; +access; +symbols; +locks; strict; +comment@# @; + + +1.1 +date 2012.12.12.21.09.39;author tester; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@changes are done +@ +text +@file a +@ diff --git a/t/t9605/cvsroot/module/b,v b/t/t9605/cvsroot/module/b,v new file mode 100644 index 000..55545c8 --- /dev/null +++ b/t/t9605/cvsroot/module/b,v @@ -0,0 +1,24 @@ +head 1.1; +access; +symbols; +locks; strict; +comment@# @; + + +1.1 +date 2012.12.12.21.09.50;author tester; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@changes are done +@ +text +@file b +@ diff --git a/t/t9605/cvsroot/module/c,v b/t/t9605/cvsroot/module/c,v new file mode 100644 index 000..d3eac77 --- /dev/null +++ b/t/t9605/cvsroot/module/c,v @@ -0,0 +1,62 @@ +head 1.3; +access; +symbols; +locks; strict; +comment@# @; + + +1.3 +date 2012.12.12.21.09.50;author tester; state Exp; +branches; +next 1.2; + +1.2 +date 2012.12.12.21.09.46;author tester; state Exp; +branches; +next 1.1; + +1.1 +date 2012.12.12.21.09.44;author tester; state Exp; +branches; +next ; + + +desc +@@ + + +1.3 +log +@changes are done +@ +text +@file c +line two +line three +line four +line five +@ + + +1.2 +log +@changes +@ +text +@d2 4 +a5 4 +line 2 +line 3 +line 4 +line 5 +@ + + +1.1 +log +@changes +@ +text +@d2 4 +@ + -- 1.8.1.rc3.335.g88a67d6 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2] t9605: test for cvsps commit ordering bug
Import of a trivial CVS repository fails due to a cvsps bug. Given the following series of commits: timestamp abc message --- --- --- --- --- 2012/12/12 21:09:39 1.1changes are done 2012/12/12 21:09:441.1 changes 2012/12/12 21:09:461.2 changes 2012/12/12 21:09:50 1.1 1.3 changes are done cvsps mangles the commit ordering (edited for brevity): - PatchSet 1 Date: 2012/12/12 15:09:39 Log: changes are done Members: a:INITIAL-1.1 b:INITIAL-1.1 c:1.2-1.3 - PatchSet 2 Date: 2012/12/12 15:09:44 Log: changes Members: c:INITIAL-1.1 - PatchSet 3 Date: 2012/12/12 15:09:46 Log: changes Members: c:1.1-1.2 This is seen in cvsps versions 2.x and up through at least 3.7. Signed-off-by: Chris Rorvick ch...@rorvick.com --- It actually does fail without the false at the end. :-P Sorry for the noise. t/t9605-cvsimport-commit-order.sh | 24 +++ t/t9605/cvsroot/.gitattributes | 1 + t/t9605/cvsroot/CVSROOT/.gitignore | 2 ++ t/t9605/cvsroot/module/a,v | 24 +++ t/t9605/cvsroot/module/b,v | 24 +++ t/t9605/cvsroot/module/c,v | 62 ++ 6 files changed, 137 insertions(+) create mode 100755 t/t9605-cvsimport-commit-order.sh create mode 100644 t/t9605/cvsroot/.gitattributes create mode 100644 t/t9605/cvsroot/CVSROOT/.gitignore create mode 100644 t/t9605/cvsroot/module/a,v create mode 100644 t/t9605/cvsroot/module/b,v create mode 100644 t/t9605/cvsroot/module/c,v diff --git a/t/t9605-cvsimport-commit-order.sh b/t/t9605-cvsimport-commit-order.sh new file mode 100755 index 000..86aafd1 --- /dev/null +++ b/t/t9605-cvsimport-commit-order.sh @@ -0,0 +1,24 @@ +#!/bin/sh + +test_description='git cvsimport commit order' +. ./lib-cvs.sh + +setup_cvs_test_repository t9605 + +test_expect_success 'checkout with CVS' ' + + echo CVSROOT=$CVSROOT + cvs checkout -d module-cvs module +' + +test_expect_failure 'import into git (commit order mangled)' ' + + git cvsimport -R -a -p-x -C module-git module + ( + cd module-git + git merge origin + ) + test_cmp module-cvs/c module-git/c +' + +test_done diff --git a/t/t9605/cvsroot/.gitattributes b/t/t9605/cvsroot/.gitattributes new file mode 100644 index 000..562b12e --- /dev/null +++ b/t/t9605/cvsroot/.gitattributes @@ -0,0 +1 @@ +* -whitespace diff --git a/t/t9605/cvsroot/CVSROOT/.gitignore b/t/t9605/cvsroot/CVSROOT/.gitignore new file mode 100644 index 000..3bb9b34 --- /dev/null +++ b/t/t9605/cvsroot/CVSROOT/.gitignore @@ -0,0 +1,2 @@ +history +val-tags diff --git a/t/t9605/cvsroot/module/a,v b/t/t9605/cvsroot/module/a,v new file mode 100644 index 000..6455911 --- /dev/null +++ b/t/t9605/cvsroot/module/a,v @@ -0,0 +1,24 @@ +head 1.1; +access; +symbols; +locks; strict; +comment@# @; + + +1.1 +date 2012.12.12.21.09.39;author tester; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@changes are done +@ +text +@file a +@ diff --git a/t/t9605/cvsroot/module/b,v b/t/t9605/cvsroot/module/b,v new file mode 100644 index 000..55545c8 --- /dev/null +++ b/t/t9605/cvsroot/module/b,v @@ -0,0 +1,24 @@ +head 1.1; +access; +symbols; +locks; strict; +comment@# @; + + +1.1 +date 2012.12.12.21.09.50;author tester; state Exp; +branches; +next ; + + +desc +@@ + + +1.1 +log +@changes are done +@ +text +@file b +@ diff --git a/t/t9605/cvsroot/module/c,v b/t/t9605/cvsroot/module/c,v new file mode 100644 index 000..d3eac77 --- /dev/null +++ b/t/t9605/cvsroot/module/c,v @@ -0,0 +1,62 @@ +head 1.3; +access; +symbols; +locks; strict; +comment@# @; + + +1.3 +date 2012.12.12.21.09.50;author tester; state Exp; +branches; +next 1.2; + +1.2 +date 2012.12.12.21.09.46;author tester; state Exp; +branches; +next 1.1; + +1.1 +date 2012.12.12.21.09.44;author tester; state Exp; +branches; +next ; + + +desc +@@ + + +1.3 +log +@changes are done +@ +text +@file c +line two +line three +line four +line five +@ + + +1.2 +log +@changes +@ +text +@d2 4 +a5 4 +line 2 +line 3 +line 4 +line 5 +@ + + +1.1 +log +@changes +@ +text +@d2 4 +@ + -- 1.8.1.rc3.335.g88a67d6 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] cvsimport: rewrite to use cvsps 3.x to fix major bugs
I cloned git://gitorious.org/cvsps/cvsps.git and installed cvsps-3.7 at c2ce6cc (More fun with test loads, sigh. Timezones suck., 2013-01-09) earlier on my $PATH, and tried to run t96xx series with this patch applied on top of Git 1.8.1. The first thing I noticed was that all the tests were skipped. A patch to t/lib-cvs.sh might be sufficient, - 8 - diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh index 44263ad..423953f 100644 --- a/t/lib-cvs.sh +++ b/t/lib-cvs.sh @@ -17,6 +17,8 @@ cvsps_version=`cvsps -h 21 | sed -ne 's/cvsps version //p'` case $cvsps_version in 2.1 | 2.2*) ;; +3.*) + ;; '') skip_all='skipping cvsimport tests, cvsps not found' test_done - 8 - but I didn't check more than now it seems not to skip them. And here is what I got: - 8 - Test Summary Report --- t9600-cvsimport.sh (Wstat: 256 Tests: 15 Failed: 9) Failed tests: 4-6, 8-9, 11-13, 15 Non-zero exit status: 1 t9601-cvsimport-vendor-branch.sh (Wstat: 256 Tests: 9 Failed: 8) Failed tests: 1-4, 6-9 Non-zero exit status: 1 t9602-cvsimport-branches-tags.sh (Wstat: 256 Tests: 11 Failed: 5) Failed tests: 1-3, 7, 9 Non-zero exit status: 1 t9604-cvsimport-timestamps.sh (Wstat: 256 Tests: 2 Failed: 2) Failed tests: 1-2 Non-zero exit status: 1 Files=5, Tests=38, 5 wallclock secs ( 0.05 usr 0.01 sys + 0.49 cusr 0.16 csys = 0.71 CPU) Result: FAIL - 8 - A funny thing was that without cvsps-3.7 on $PATH (which means I am getting distro packaged cvsps 2.1), I got identical errors. Looking at the log message, it seems that you meant to remove t960[123], so perhaps the patch simply forgot to remove 9601 and 9602? As neither test runs git cvsimport with -o/-m/-M options, ideally we should be able to pass them with and without having cvsps-3.x. Not passing them without cvsps-3.x would mean that the fallback mode of rewritten cvsimport is not working as expected. Not passing them with cvsps-3.x may mean the tests were expecting a wrong conversion result, or they uncover bugs in the replacement cvsimport. t9600 fails with -a is no longer supported, even without having cvsps-3.x on the $PATH (i.e. attempting to use the fallback). I wonder if this is an option the updated cvsimport would want to simply ignore? It is a way to tell the old cvsps/cvsimport to disable its heuristics to ignore commits made within the last 10 minutes (this is done in the hope of waiting for the per-file nature of CVS commits to stabilize, IIUC); the user tells the command that he knows that the CVS repository is now quiescent and it is safe to import the whole thing. If the updated cvsps can identify the changeset more reliably and it no longer needs -a option, it may be more helpful to the users to migrate their script if it allowed, warned and then ignored the option. It certainly would help sharing of this test script between runs that use the old and new cvsps as backends. t9601 (after resurrecting the t/t9601/cvsroot directory) fails in an interesting way. - 8 - $ sh t9601-cvsimport-vendor-branch.sh -i -v Initialized empty Git repository in /git/git.build/t/trash directory.t9601-cvsimport-vendor-branch/.git/ expecting success: git cvsimport -C module-git module Traceback (most recent call last): File /git/git.build/git-cvsimport, line 262, in module subprocess.check_output(cvsps -V 2/dev/null, shell=True) AttributeError: 'module' object has no attribute 'check_output' not ok - 1 import a module with a vendor branch - 8 - Apparently, the copy of subprocess.py I have does not give us the check_output thing: - 8 - $ python Python 2.6.6 (r266:84292, Dec 26 2010, 22:31:48) [GCC 4.4.5] on linux2 Type help, copyright, credits or license for more information. import subprocess dir(subprocess) ['CalledProcessError', 'MAXFD', 'PIPE', 'Popen', 'STDOUT', '__all__', '__builtins__', '__doc__', '__file__', '__name__', '__package__', '_active', '_cleanup', '_demo_posix', '_demo_windows', '_eintr_retry_call', 'call', 'check_call', 'errno', 'fcntl', 'gc', 'list2cmdline', 'mswindows', 'os', 'pickle', 'select', 'signal', 'sys', 'traceback', 'types'] - 8 - The story is the same for t9602 and t9603 (again after resurrecting the necessary files). http://docs.python.org/2/library/subprocess.html tells me that check_output has first become available in 2.7. So... does this mean that we now set the minimum required version of Python to 2.7? I dunno. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] t/t960[123]: remove leftover scripts
The rewrite patch was supposed to remove these scripts, but somehow we ended up removing only the supporting files for them but not the test script themselves. Remove them for real. Signed-off-by: Junio C Hamano gits...@pobox.com --- * I'll queue this on top of your patch together with a few fix-up patches from Chris Rorvick. This may have been caused by your private patch e-mail mangled somewhere between us before I resent your patch, or perhaps you simply may have forgot to remove them, but at this point I do not really care where these deletions were lost---the only thing I care about is to make sure that you _meant_ to remove them in your patch (i.e. if you didn't mean to, then I am further breaking the tests in a way you did not intend to), so I'd appreciate either Yup, these three files should be removed, or No, they should stay; removal of their supporting data is no longer needed from you (I and this patch expect the former, of course). By the way, Chris, we'll need your Sign-off on the three paches (t/lib-cvs.sh fix to allow cvsps v3, t9600 fix and t9604 fix). t/t9601-cvsimport-vendor-branch.sh | 85 -- t/t9602-cvsimport-branches-tags.sh | 78 -- t/t9603-cvsimport-patchsets.sh | 39 - 3 files changed, 202 deletions(-) delete mode 100755 t/t9601-cvsimport-vendor-branch.sh delete mode 100755 t/t9602-cvsimport-branches-tags.sh delete mode 100755 t/t9603-cvsimport-patchsets.sh diff --git a/t/t9601-cvsimport-vendor-branch.sh b/t/t9601-cvsimport-vendor-branch.sh deleted file mode 100755 index 827d39f..000 --- a/t/t9601-cvsimport-vendor-branch.sh +++ /dev/null @@ -1,85 +0,0 @@ -#!/bin/sh - -# Description of the files in the repository: -# -#imported-once.txt: -# -# Imported once. 1.1 and 1.1.1.1 should be identical. -# -#imported-twice.txt: -# -# Imported twice. HEAD should reflect the contents of the -# second import (i.e., have the same contents as 1.1.1.2). -# -#imported-modified.txt: -# -# Imported, then modified on HEAD. HEAD should reflect the -# modification. -# -#imported-modified-imported.txt: -# -# Imported, then modified on HEAD, then imported again. -# -#added-imported.txt,v: -# -# Added with 'cvs add' to create 1.1, then imported with -# completely different contents to create 1.1.1.1, therefore the -# vendor branch was never the default branch. -# -#imported-anonymously.txt: -# -# Like imported-twice.txt, but with a vendor branch whose branch -# tag has been removed. - -test_description='git cvsimport handling of vendor branches' -. ./lib-cvs.sh - -setup_cvs_test_repository t9601 - -test_expect_success PERL 'import a module with a vendor branch' ' - - git cvsimport -C module-git module - -' - -test_expect_success PERL 'check HEAD out of cvs repository' 'test_cvs_co master' - -test_expect_success PERL 'check master out of git repository' 'test_git_co master' - -test_expect_success PERL 'check a file that was imported once' ' - - test_cmp_branch_file master imported-once.txt - -' - -test_expect_failure PERL 'check a file that was imported twice' ' - - test_cmp_branch_file master imported-twice.txt - -' - -test_expect_success PERL 'check a file that was imported then modified on HEAD' ' - - test_cmp_branch_file master imported-modified.txt - -' - -test_expect_success PERL 'check a file that was imported, modified, then imported again' ' - - test_cmp_branch_file master imported-modified-imported.txt - -' - -test_expect_success PERL 'check a file that was added to HEAD then imported' ' - - test_cmp_branch_file master added-imported.txt - -' - -test_expect_success PERL 'a vendor branch whose tag has been removed' ' - - test_cmp_branch_file master imported-anonymously.txt - -' - -test_done diff --git a/t/t9602-cvsimport-branches-tags.sh b/t/t9602-cvsimport-branches-tags.sh deleted file mode 100755 index e1db323..000 --- a/t/t9602-cvsimport-branches-tags.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/sh - -# A description of the repository used for this test can be found in -# t9602/README. - -test_description='git cvsimport handling of branches and tags' -. ./lib-cvs.sh - -setup_cvs_test_repository t9602 - -test_expect_success PERL 'import module' ' - - git cvsimport -C module-git module - -' - -test_expect_success PERL 'test branch master' ' - - test_cmp_branch_tree master - -' - -test_expect_success PERL 'test branch vendorbranch' ' - - test_cmp_branch_tree vendorbranch - -' - -test_expect_failure PERL 'test branch B_FROM_INITIALS' ' - - test_cmp_branch_tree B_FROM_INITIALS - -' - -test_expect_failure PERL 'test branch B_FROM_INITIALS_BUT_ONE' ' - - test_cmp_branch_tree B_FROM_INITIALS_BUT_ONE - -' - -test_expect_failure PERL 'test branch B_MIXED' ' - - test_cmp_branch_tree B_MIXED
[BUG] Possible bug in `remote set-url --add --push`
Hi, I believe `remote set-url --add --push` has a bug. Performed tests with v1.8.0.1 and v1.8.1 (Mac OS X). Quoting the relevant part of the documentation: set-url Changes URL remote points to. Sets first URL remote points to matching regex oldurl (first URL if no oldurl is given) to newurl. If oldurl doesn’t match any URL, error occurs and nothing is changed. With --push, push URLs are manipulated instead of fetch URLs. With --add, instead of changing some URL, new URL is added. With --delete, instead of changing some URL, all URLs matching regex url are deleted. Trying to delete all non-push URLs is an error. Here are some steps to reproduce: 1. Show the remote URLs jweyrich@pharao:test_clone1 [* master]$ git remote -v origin /Volumes/sandbox/test (fetch) origin /Volumes/sandbox/test (push) 2. Add a new push URL for origin jweyrich@pharao:test_clone1 [* master]$ git remote set-url --add --push origin \ /Volumes/sandbox/test_clone2 3. Check what happened jweyrich@pharao:test_clone1 [* master]$ git remote -v origin /Volumes/sandbox/test (fetch) origin /Volumes/sandbox/test_clone2 (push) 4. Missing an URL? Re-add the original one jweyrich@pharao:test_clone1 [* master]$ git remote set-url --add --push origin \ /Volumes/sandbox/test 5. Check what happened, again jweyrich@pharao:test_clone1 [* master]$ git remote -v origin /Volumes/sandbox/test (fetch) origin /Volumes/sandbox/test_clone2 (push) origin /Volumes/sandbox/test (push) In step 2, Git replaced the original push URL instead of adding a new one. But it seems to happen only the first time I use `remote set-url --add --push`. Re-adding the original URL using the same command seems to work properly. And FWIW, if I delete (with set-url --delete) both URLs push, Git restores the original URL. Please, could someone try to reproduce? - jw -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH] tests: turn on test-lint-shell-syntax by default
The test Makefile has a default set of lint tests which are run as part of make test. The macro TEST_LINT defaults to test-lint-duplicates test-lint-executable. Add test-lint-shell-syntax here, to detect non-portable shell syntax early. Signed-off-by: Torsten Bögershausen tbo...@web.de --- t/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/Makefile b/t/Makefile index 1923cc1..6fa2b80 100644 --- a/t/Makefile +++ b/t/Makefile @@ -13,7 +13,7 @@ TAR ?= $(TAR) RM ?= rm -f PROVE ?= prove DEFAULT_TEST_TARGET ?= test -TEST_LINT ?= test-lint-duplicates test-lint-executable +TEST_LINT ?= test-lint-duplicates test-lint-executable test-lint-shell-syntax # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) -- 1.8.0.197.g5a90748 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] tests: turn on test-lint-shell-syntax by default
Torsten Bögershausen tbo...@web.de writes: The test Makefile has a default set of lint tests which are run as part of make test. The macro TEST_LINT defaults to test-lint-duplicates test-lint-executable. Add test-lint-shell-syntax here, to detect non-portable shell syntax early. Signed-off-by: Torsten Bögershausen tbo...@web.de --- As I said already, I do not want to do this yet without further reduction of false positives. Addition of the shell script test was a good starting point, but as it stands, it still is too brittle and will trigger on something even trivially innouous, like this: test_expect_success 'no issues' ' cat test.file -\EOF which is the right way? EOF ' t/Makefile | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/t/Makefile b/t/Makefile index 1923cc1..6fa2b80 100644 --- a/t/Makefile +++ b/t/Makefile @@ -13,7 +13,7 @@ TAR ?= $(TAR) RM ?= rm -f PROVE ?= prove DEFAULT_TEST_TARGET ?= test -TEST_LINT ?= test-lint-duplicates test-lint-executable +TEST_LINT ?= test-lint-duplicates test-lint-executable test-lint-shell-syntax # Shell quote; SHELL_PATH_SQ = $(subst ','\'',$(SHELL_PATH)) -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 03/21] Export parse_pathspec() and convert some get_pathspec() calls
On Sat, Jan 12, 2013 at 12:56 AM, Matt Kraai kr...@ftbfs.org wrote: On Fri, Jan 11, 2013 at 06:20:57PM +0700, Nguyễn Thái Ngọc Duy wrote: +#define PATHSPEC_FROMTOP(10) The previous commit introduces a use of this macro in get_pathspec. Should this be defined by that commit instead? This macro is already defined in setup.c when parse_pathspec is introduced. I wanted to move it from setup.c to cache.h but forgot to remove the original definition. Will fix. @@ -266,9 +266,9 @@ static int pathspec_item_cmp(const void *a_, const void *b_) * Given command line arguments and a prefix, convert the input to * pathspec. die() if any magic other than ones in magic_mask. */ -static void parse_pathspec(struct pathspec *pathspec, -unsigned magic_mask, unsigned flags, -const char *prefix, const char **argv) +void parse_pathspec(struct pathspec *pathspec, + unsigned magic_mask, unsigned flags, The prototype for this function uses just magic instead of magic_mask. Should they be consistent? Definitely. Will fix. -- Duy -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH] t/t960[123]: remove leftover scripts
On Fri, Jan 11, 2013 at 11:38 PM, Junio C Hamano gits...@pobox.com wrote: By the way, Chris, we'll need your Sign-off on the three paches (t/lib-cvs.sh fix to allow cvsps v3, t9600 fix and t9604 fix). Sure. I was just maintaining them for myself but thought I'd share when I saw the follow-up patch. Didn't think to amend them. Chris -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 0/3] fixup remaining cvsimport tests
Reroll w/ sign-off. Chris Rorvick (3): t/lib-cvs.sh: allow cvsps version 3.x. t9600: fixup for new cvsimport t9604: fixup for new cvsimport t/lib-cvs.sh| 2 +- t/t9600-cvsimport.sh| 10 -- t/t9604-cvsimport-timestamps.sh | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) -- 1.8.1.rc3.335.g88a67d6 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 2/3] t9600: fixup for new cvsimport
cvsimport no longer supports -a (import all commits including recent ones) and no longer uses the 'origin' branch by default for imports. Signed-off-by: Chris Rorvick ch...@rorvick.com --- t/t9600-cvsimport.sh | 10 -- 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/t/t9600-cvsimport.sh b/t/t9600-cvsimport.sh index 4c384ff..14f54d5 100755 --- a/t/t9600-cvsimport.sh +++ b/t/t9600-cvsimport.sh @@ -44,7 +44,7 @@ EOF test_expect_success PERL 'import a trivial module' ' - git cvsimport -a -R -z 0 -C module-git module + git cvsimport -R -z 0 -C module-git module test_cmp module-cvs/o_fortuna module-git/o_fortuna ' @@ -90,8 +90,7 @@ test_expect_success PERL 'update git module' ' (cd module-git git config cvsimport.trackRevisions true - git cvsimport -a -z 0 module - git merge origin + git cvsimport -z 0 module ) test_cmp module-cvs/o_fortuna module-git/o_fortuna @@ -119,8 +118,7 @@ test_expect_success PERL 'cvsimport.module config works' ' (cd module-git git config cvsimport.module module git config cvsimport.trackRevisions true - git cvsimport -a -z0 - git merge origin + git cvsimport -z0 ) test_cmp module-cvs/tick module-git/tick @@ -140,7 +138,7 @@ test_expect_success PERL 'import from a CVS working tree' ' $CVS co -d import-from-wt module (cd import-from-wt git config cvsimport.trackRevisions false - git cvsimport -a -z0 + git cvsimport -z0 echo 1 expect git log -1 --pretty=format:%s%n actual test_cmp actual expect -- 1.8.1.rc3.335.g88a67d6 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
[PATCH v2 3/3] t9604: fixup for new cvsimport
cvsps no longer writes a cache file and therefore no longer can be told to ignore it with -x. Signed-off-by: Chris Rorvick ch...@rorvick.com --- t/t9604-cvsimport-timestamps.sh | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) diff --git a/t/t9604-cvsimport-timestamps.sh b/t/t9604-cvsimport-timestamps.sh index 1fd5142..b1629b6 100755 --- a/t/t9604-cvsimport-timestamps.sh +++ b/t/t9604-cvsimport-timestamps.sh @@ -7,8 +7,7 @@ setup_cvs_test_repository t9604 test_expect_success 'check timestamps are UTC (TZ=CST6CDT)' ' - TZ=CST6CDT git cvsimport -p-x -C module-1 module - git cvsimport -p-x -C module-1 module + TZ=CST6CDT git cvsimport -C module-1 module ( cd module-1 git log --format=%s %ai @@ -42,7 +41,7 @@ test_expect_success 'check timestamps with author-specific timezones' ' user3=User Three us...@domain.org EST5EDT user4=User Four us...@domain.org MST7MDT EOF - git cvsimport -p-x -A cvs-authors -C module-2 module + git cvsimport -A cvs-authors -C module-2 module ( cd module-2 git log --format=%s %ai %an -- 1.8.1.rc3.335.g88a67d6 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/3] fixup remaining cvsimport tests
Chris Rorvick ch...@rorvick.com writes: Reroll w/ sign-off. Chris Rorvick (3): t/lib-cvs.sh: allow cvsps version 3.x. t9600: fixup for new cvsimport t9604: fixup for new cvsimport t/lib-cvs.sh| 2 +- t/t9600-cvsimport.sh| 10 -- t/t9604-cvsimport-timestamps.sh | 5 ++--- 3 files changed, 7 insertions(+), 10 deletions(-) Thanks. I too noticed the droppage of -a support, which may not be a big deal (people can drop it from their script, run cvsimport and they can drop newer commits from the resulting Git history to emulate the old behaviour without -a that attempted to find a quiescent point if they really want to and suspect that the upstream CVS repository was not quiescent during the import). Likewise for -x. You said no longer can be told and that is technically true, but it is more like no longer need to be told, as stale cache cannot get in the way, so it is probably not a big deal, either, for people to drop it from their script. About the changed behaviour regarding origin, I suspect that it is a change for the better, but we would probably need documentation updates to cover it (and deleted options and (mis)features) before this topic graduates. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [PATCH v2 0/3] fixup remaining cvsimport tests
On Sat, Jan 12, 2013 at 12:36 AM, Junio C Hamano gits...@pobox.com wrote: I too noticed the droppage of -a support, which may not be a big deal (people can drop it from their script, run cvsimport and they can drop newer commits from the resulting Git history to emulate the old behaviour without -a that attempted to find a quiescent point if they really want to and suspect that the upstream CVS repository was not quiescent during the import). Is there any value to -a when fuzz is exposed (-z)? I mean this is a functional sense. I think there is a lot of value to maintaining the interfaces of both cvsimport and cvsps where possible. Likewise for -x. You said no longer can be told and that is technically true, but it is more like no longer need to be told, as stale cache cannot get in the way, so it is probably not a big deal, either, for people to drop it from their script. :-) I originally wrote need and then changed it to be clearer on why it was being removed. -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html
Re: [BUG] Possible bug in `remote set-url --add --push`
Jardel Weyrich jweyr...@gmail.com writes: I believe `remote set-url --add --push` has a bug. Performed tests with v1.8.0.1 and v1.8.1 (Mac OS X). Quoting the relevant part of the documentation: set-url Changes URL remote points to. Sets first URL remote points to matching regex oldurl (first URL if no oldurl is given) to newurl. If oldurl doesn’t match any URL, error occurs and nothing is changed. With --push, push URLs are manipulated instead of fetch URLs. With --add, instead of changing some URL, new URL is added. With --delete, instead of changing some URL, all URLs matching regex url are deleted. Trying to delete all non-push URLs is an error. Here are some steps to reproduce: 1. Show the remote URLs jweyrich@pharao:test_clone1 [* master]$ git remote -v origin /Volumes/sandbox/test (fetch) origin /Volumes/sandbox/test (push) 2. Add a new push URL for origin jweyrich@pharao:test_clone1 [* master]$ git remote set-url --add --push origin \ /Volumes/sandbox/test_clone2 3. Check what happened jweyrich@pharao:test_clone1 [* master]$ git remote -v origin /Volumes/sandbox/test (fetch) origin /Volumes/sandbox/test_clone2 (push) The original pushurl was replaced with the additional one, instead of being left and the new one getting added. That looks certainly wrong. However, the result of applying the attached patch (either to v1.7.12 or v1.8.1) still passes the test and I do not think it is doing anything differently from what you described above. What do you get from git config -l | grep '^remote\.origin' in steps 1. and 3. in your procedure? This question is trying to tell if your bug is in git remote -v or in git remote set-url. -- 8 -- From 0f6cbc67db926e97707ae732b02e790b4604508e Mon Sep 17 00:00:00 2001 From: Junio C Hamano gits...@pobox.com Date: Fri, 11 Jan 2013 23:04:16 -0800 Subject: [PATCH] t5505: adding one pushurl from jweyrich Signed-off-by: Junio C Hamano gits...@pobox.com --- t/t5505-remote.sh | 19 +++ 1 file changed, 19 insertions(+) diff --git a/t/t5505-remote.sh b/t/t5505-remote.sh index c03ffdd..b31c5bb 100755 --- a/t/t5505-remote.sh +++ b/t/t5505-remote.sh @@ -901,6 +901,25 @@ test_expect_success 'remote set-url --push --add aaa' ' cmp expect actual ' +test_expect_success 'remote set-url --push --add' ' + git config remote.jweyrich.url /Volumes/sandbox/test + git config remote.jweyrich.pushurl /Volumes/sandbox/test + git config remote.jweyrich.fetch refs/heads/*:refs/remotes/jweyrich/* + + added=/Volumes/sandbox/test_clone2 + { + git config -l | grep ^remote\.jweyrich\. + echo remote.jweyrich.pushurl=$added + } | sort expect + + git remote set-url --add --push jweyrich $added + git config -l | grep ^remote\.jweyrich\. | sort actual + + test_cmp expect actual + + git remote -v | grep ^jweyrich # this is just for debugging +' + test_expect_success 'remote set-url --push bar aaa' ' git remote set-url --push someremote bar aaa echo foo expect -- 1.8.1.421.g6236851 -- To unsubscribe from this list: send the line unsubscribe git in the body of a message to majord...@vger.kernel.org More majordomo info at http://vger.kernel.org/majordomo-info.html