* [PATCH v2 05/21] commit: convert to use parse_pathspec
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 11:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357903275-16804-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@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 (1<<0)
+/* Pathspec flags */
+#define PATHSPEC_EMPTY_MATCH_ALL (1<<0) /* 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
^ permalink raw reply related
* [PATCH v2 03/21] Export parse_pathspec() and convert some get_pathspec() calls
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 11:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357903275-16804-1-git-send-email-pclouds@gmail.com>
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 <pclouds@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 (1<<0)
+
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
^ permalink raw reply related
* [PATCH v2 04/21] clean: convert to use parse_pathspec
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 11:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357903275-16804-1-git-send-email-pclouds@gmail.com>
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@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
^ permalink raw reply related
* [PATCH v2 01/21] pathspec: save the non-wildcard length part
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 11:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357903275-16804-1-git-send-email-pclouds@gmail.com>
We mark pathspec with wildcards with the field use_wildcard. We
could do better by saving the length of the non-wildcard part, which
can be used for optimizations such as f9f6e2c (exclude: do strcmp as
much as possible before fnmatch - 2012-06-07).
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
---
builtin/ls-files.c | 2 +-
builtin/ls-tree.c | 2 +-
cache.h | 2 +-
dir.c | 6 +++---
tree-walk.c | 4 ++--
5 files changed, 8 insertions(+), 8 deletions(-)
diff --git a/builtin/ls-files.c b/builtin/ls-files.c
index b5434af..4a9ee69 100644
--- a/builtin/ls-files.c
+++ b/builtin/ls-files.c
@@ -337,7 +337,7 @@ void overlay_tree_on_cache(const char *tree_name, const char *prefix)
matchbuf[0] = prefix;
matchbuf[1] = NULL;
init_pathspec(&pathspec, matchbuf);
- pathspec.items[0].use_wildcard = 0;
+ pathspec.items[0].nowildcard_len = pathspec.items[0].len;
} else
init_pathspec(&pathspec, NULL);
if (read_tree(tree, 1, &pathspec))
diff --git a/builtin/ls-tree.c b/builtin/ls-tree.c
index 235c17c..fb76e38 100644
--- a/builtin/ls-tree.c
+++ b/builtin/ls-tree.c
@@ -168,7 +168,7 @@ int cmd_ls_tree(int argc, const char **argv, const char *prefix)
init_pathspec(&pathspec, get_pathspec(prefix, argv + 1));
for (i = 0; i < pathspec.nr; i++)
- pathspec.items[i].use_wildcard = 0;
+ pathspec.items[i].nowildcard_len = pathspec.items[i].len;
pathspec.has_wildcard = 0;
tree = parse_tree_indirect(sha1);
if (!tree)
diff --git a/cache.h b/cache.h
index 2b192d2..9304d91 100644
--- a/cache.h
+++ b/cache.h
@@ -482,7 +482,7 @@ struct pathspec {
struct pathspec_item {
const char *match;
int len;
- unsigned int use_wildcard:1;
+ int nowildcard_len;
} *items;
};
diff --git a/dir.c b/dir.c
index 5a83aa7..c391d46 100644
--- a/dir.c
+++ b/dir.c
@@ -230,7 +230,7 @@ static int match_pathspec_item(const struct pathspec_item *item, int prefix,
return MATCHED_RECURSIVELY;
}
- if (item->use_wildcard && !fnmatch(match, name, 0))
+ if (item->nowildcard_len < item->len && !fnmatch(match, name, 0))
return MATCHED_FNMATCH;
return 0;
@@ -1429,8 +1429,8 @@ int init_pathspec(struct pathspec *pathspec, const char **paths)
item->match = path;
item->len = strlen(path);
- item->use_wildcard = !no_wildcard(path);
- if (item->use_wildcard)
+ item->nowildcard_len = simple_length(path);
+ if (item->nowildcard_len < item->len)
pathspec->has_wildcard = 1;
}
diff --git a/tree-walk.c b/tree-walk.c
index 3f54c02..af871c5 100644
--- a/tree-walk.c
+++ b/tree-walk.c
@@ -626,7 +626,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
&never_interesting))
return entry_interesting;
- if (item->use_wildcard) {
+ if (item->nowildcard_len < item->len) {
if (!fnmatch(match + baselen, entry->path, 0))
return entry_interesting;
@@ -642,7 +642,7 @@ enum interesting tree_entry_interesting(const struct name_entry *entry,
}
match_wildcards:
- if (!item->use_wildcard)
+ if (item->nowildcard_len == item->len)
continue;
/*
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply related
* [PATCH v2 02/21] Add parse_pathspec() that converts cmdline args to struct pathspec
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 11:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357903275-16804-1-git-send-email-pclouds@gmail.com>
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 <pclouds@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;
- return spec;
+ static const char *raw[2];
+
+ pathspec->items = item = xmalloc(sizeof(*item));
+ item->match = prefix;
+ item->nowildcard_len = item->len = strlen(prefix);
+ raw[0] = prefix;
+ raw[1] = NULL;
+ pathspec->nr = 1;
+ pathspec->raw = raw;
+ return;
}
- /* Otherwise we have to re-write the entries.. */
- src = pathspec;
- dst = pathspec;
+ n = 0;
+ while (argv[n])
+ n++;
+
+ pathspec->nr = n;
+ pathspec->items = item = xmalloc(sizeof(*item) * n);
+ pathspec->raw = argv;
prefixlen = prefix ? strlen(prefix) : 0;
- while (*src) {
- *(dst++) = prefix_pathspec(prefix, prefixlen, *src);
- src++;
+
+ for (i = 0; i < n; i++) {
+ unsigned applied_magic;
+ const char *arg = argv[i];
+
+ applied_magic = prefix_pathspec(item + i, argv + i,
+ prefix, prefixlen, arg);
+ if (applied_magic & ~magic_mask)
+ die(_("pathspec magic in '%s' is not supported"
+ " by this command"), arg);
+ if (item[i].nowildcard_len < item[i].len)
+ pathspec->has_wildcard = 1;
}
- *dst = NULL;
- if (!*pathspec)
- return NULL;
- return pathspec;
+
+ qsort(pathspec->items, pathspec->nr,
+ sizeof(struct pathspec_item), pathspec_item_cmp);
+}
+
+const char **get_pathspec(const char *prefix, const char **pathspec)
+{
+ struct pathspec ps;
+ parse_pathspec(&ps, PATHSPEC_FROMTOP, 0, prefix, pathspec);
+ return ps.raw;
}
/*
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply related
* [PATCH v2 00/21] nd/parse-pathspec reroll
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 11:20 UTC (permalink / raw)
To: git; +Cc: Junio C Hamano, Nguyễn Thái Ngọc Duy
Changes:
- The incorrect patch 'pathspec: make sure the prefix part is
wildcard-clean' is removed. I want to keep this series simple.
Complex pathspec manipulation will have its own series later.
- Fix t7400.38 failure when core.ignorecase is on. We should exercise
core.ignorecase codepath more in the test suite, but that should be
in a separate series.
- parse_pathspec() learns PATHSPEC_EMPTY_MATCH_ALL flag to support
"no pathspec means match everything", which is used by some commands
like commit/status
- rename 'raw' to '_raw' to catch new access sites
I also checked if we still have similar faults to t7400.38 (modifying
pathspec directly leading to inconsistencies) and I think we're safe.
Nguyễn Thái Ngọc Duy (21):
pathspec: save the non-wildcard length part
Add parse_pathspec() that converts cmdline args to struct pathspec
Export parse_pathspec() and convert some get_pathspec() calls
clean: convert to use parse_pathspec
commit: convert to use parse_pathspec
status: convert to use parse_pathspec
rerere: convert to use parse_pathspec
checkout: convert to use parse_pathspec
rm: convert to use parse_pathspec
ls-files: convert to use parse_pathspec
archive: convert to use parse_pathspec
add: convert to use parse_pathspec
Convert read_cache_preload() to take struct pathspec
Convert unmerge_cache to take struct pathspec
checkout: convert read_tree_some to take struct pathspec
Convert report_path_error to take struct pathspec
Convert refresh_index to take struct pathspec
Convert {read,fill}_directory to take struct pathspec
Convert add_files_to_cache to take struct pathspec
Convert more init_pathspec() to parse_pathspec()
Rename field "raw" to "_raw" in struct pathspec
archive.c | 12 +++---
archive.h | 2 +-
builtin/add.c | 102 ++++++++++++++++++-------------------------------
builtin/checkout.c | 37 ++++++++----------
builtin/clean.c | 20 +++++-----
builtin/commit.c | 39 +++++++++----------
builtin/diff-files.c | 2 +-
builtin/diff-index.c | 2 +-
builtin/diff.c | 4 +-
builtin/grep.c | 6 +--
builtin/log.c | 2 +-
builtin/ls-files.c | 64 +++++++++++--------------------
builtin/ls-tree.c | 6 +--
builtin/rerere.c | 6 +--
builtin/rm.c | 16 ++++----
builtin/update-index.c | 3 +-
cache.h | 25 +++++++++---
diff-lib.c | 2 +-
dir.c | 72 +++++++++++++++++++++++++++++-----
dir.h | 5 ++-
merge-recursive.c | 2 +-
preload-index.c | 20 +++++-----
read-cache.c | 5 ++-
rerere.c | 6 +--
rerere.h | 4 +-
resolve-undo.c | 4 +-
resolve-undo.h | 2 +-
revision.c | 8 ++--
setup.c | 102 +++++++++++++++++++++++++++++++++++++------------
tree-diff.c | 8 ++--
tree-walk.c | 4 +-
tree.c | 4 +-
tree.h | 2 +-
wt-status.c | 17 ++++-----
wt-status.h | 2 +-
35 files changed, 339 insertions(+), 278 deletions(-)
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply
* missing objects -- prevention
From: Sitaram Chamarty @ 2013-01-11 11:10 UTC (permalink / raw)
To: Git Mailing List
Hi all,
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. 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?
Anything else I can watch out for or caution the team about?
The symptom is usually a disk space crunch caused by tmp_pack_* files
left around by auto-gc. Presumably the missing objects failed the gc
and so it left the files around, and they eventually accumulate enough
to cause disk full errors. (If a gc ever succeeded, I suspect these
files would go away, but that requires manual intervention).
I would appreciate any thoughts... Thanks!
--
Sitaram
^ permalink raw reply
* Re: [PATCH 03/19] reset.c: pass pathspec around instead of (prefix, argv) pair
From: Duy Nguyen @ 2013-01-11 11:10 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Martin von Zweigbergk, git
In-Reply-To: <7vfw28eiu3.fsf@alter.siamese.dyndns.org>
On Fri, Jan 11, 2013 at 6:09 AM, Junio C Hamano <gitster@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
^ permalink raw reply
* Re: t7400 broken on pu (Mac OS X)
From: Duy Nguyen @ 2013-01-11 11:03 UTC (permalink / raw)
To: Junio C Hamano; +Cc: Torsten Bögershausen, git
In-Reply-To: <7v38y83ooo.fsf@alter.siamese.dyndns.org>
On Fri, Jan 11, 2013 at 12:58 AM, Junio C Hamano <gitster@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
^ permalink raw reply
* Re: git checkout bug on Win7 x64
From: Konstantin Khomoutov @ 2013-01-11 9:54 UTC (permalink / raw)
To: Ishayahu Lastov
Cc: git-u79uwXL29TY76Z2rM5mHXA, git-users-/JYPxA39Uh5TLH3MbocFFw
In-Reply-To: <CAJ52sWnm23pLibG24PZm0UB=_tk7JahNx0c53E1udJG4D3yvvQ-JsoAwUIsXosN+BqQ9rBEUg@public.gmane.org>
On Fri, 11 Jan 2013 11:30:01 +0400
Ishayahu Lastov <meoc-it-JGs/UdohzUI@public.gmane.org> 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
--
^ permalink raw reply
* [PATCH v2 3/3] fetch: elaborate --depth action
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 9:05 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Stefan Beller, Jonathan Nieder, schlotter,
Ralf.Wildenhues, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357895148-30909-1-git-send-email-pclouds@gmail.com>
--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 <pclouds@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
^ permalink raw reply related
* [PATCH v2 2/3] upload-pack: fix off-by-one depth calculation in shallow clone
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 9:05 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Stefan Beller, Jonathan Nieder, schlotter,
Ralf.Wildenhues, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357895148-30909-1-git-send-email-pclouds@gmail.com>
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 <pclouds@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
^ permalink raw reply related
* [PATCH v2 1/3] fetch: add --unshallow for turning shallow repo into complete one
From: Nguyễn Thái Ngọc Duy @ 2013-01-11 9:05 UTC (permalink / raw)
To: git
Cc: Junio C Hamano, Stefan Beller, Jonathan Nieder, schlotter,
Ralf.Wildenhues, Nguyễn Thái Ngọc Duy
In-Reply-To: <1357875005-21956-1-git-send-email-pclouds@gmail.com>
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 <pclouds@gmail.com>
---
On Fri, Jan 11, 2013 at 10:55 AM, Junio C Hamano <gitster@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 0x7fffffff, 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, const char **argv, const char *prefix)
argc = parse_options(argc, argv, prefix,
builtin_fetch_options, builtin_fetch_usage, 0);
+ if (unshallow) {
+ if (depth)
+ die(_("--depth and --unshallow cannot be used together"));
+ else if (!is_repository_shallow())
+ die(_("--unshallow on a complete repository does not make sense"));
+ else {
+ static char inf_depth[12];
+ sprintf(inf_depth, "%d", INFINITE_DEPTH);
+ depth = inf_depth;
+ }
+ }
+
if (recurse_submodules != RECURSE_SUBMODULES_OFF) {
if (recurse_submodules_default) {
int arg = parse_fetch_recurse_submodules_arg("--recurse-submodules-default", recurse_submodules_default);
diff --git a/commit.h b/commit.h
index 0f469e5..fbde106 100644
--- a/commit.h
+++ b/commit.h
@@ -162,6 +162,9 @@ extern struct commit_list *get_merge_bases(struct commit *rev1, struct commit *r
extern struct commit_list *get_merge_bases_many(struct commit *one, int n, struct commit **twos, int cleanup);
extern struct commit_list *get_octopus_merge_bases(struct commit_list *in);
+/* largest postive number a signed 32-bit integer can contain */
+#define INFINITE_DEPTH 0x7fffffff
+
extern int register_shallow(const unsigned char *sha1);
extern int unregister_shallow(const unsigned char *sha1);
extern int for_each_commit_graft(each_commit_graft_fn, void *);
diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
index 6322e8a..426027e 100755
--- a/t/t5500-fetch-pack.sh
+++ b/t/t5500-fetch-pack.sh
@@ -264,6 +264,26 @@ test_expect_success 'clone shallow object count' '
grep "^count: 52" count.shallow
'
+test_expect_success 'fetch --no-shallow on full repo' '
+ test_must_fail git fetch --noshallow
+'
+
+test_expect_success 'fetch --depth --no-shallow' '
+ (
+ cd shallow &&
+ test_must_fail git fetch --depth=1 --noshallow
+ )
+'
+
+test_expect_success 'turn shallow to complete repository' '
+ (
+ cd shallow &&
+ git fetch --unshallow &&
+ ! test -f .git/shallow &&
+ git fsck --full
+ )
+'
+
test_expect_success 'clone shallow without --no-single-branch' '
git clone --depth 1 "file://$(pwd)/." shallow2
'
diff --git a/upload-pack.c b/upload-pack.c
index 6142421..88f0029 100644
--- a/upload-pack.c
+++ b/upload-pack.c
@@ -670,10 +670,17 @@ static void receive_needs(void)
if (depth == 0 && shallows.nr == 0)
return;
if (depth > 0) {
- struct commit_list *result, *backup;
+ struct commit_list *result = NULL, *backup = NULL;
int i;
- backup = result = get_shallow_commits(&want_obj, depth,
- SHALLOW, NOT_SHALLOW);
+ if (depth == INFINITE_DEPTH)
+ for (i = 0; i < shallows.nr; i++) {
+ struct object *object = shallows.objects[i].item;
+ object->flags |= NOT_SHALLOW;
+ }
+ else
+ backup = result =
+ get_shallow_commits(&want_obj, depth,
+ SHALLOW, NOT_SHALLOW);
while (result) {
struct object *object = &result->item->object;
if (!(object->flags & (CLIENT_SHALLOW|NOT_SHALLOW))) {
--
1.8.0.rc2.23.g1fb49df
^ permalink raw reply related
* [PATCH] git-completion.bash: Silence not a valid object errors
From: Dylan Smith @ 2013-01-11 8:06 UTC (permalink / raw)
To: git
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.smith@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
^ permalink raw reply related
* git checkout bug on Win7 x64
From: Ishayahu Lastov @ 2013-01-11 7:30 UTC (permalink / raw)
To: git
This is my session on Win7 x64:
Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.
C:\Dropbox\Dropbox\Wesnoth\Apocryphs>cd Apokryphs.Orks
C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks>git 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.Orks>cd scenarios
C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenarios>git 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>git checkout -- 01
_NothernVillage.cfg
C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenarios>git 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?
--
сохраняйте, пожалуйста, при ответе исходный текст письма
С уважением,
начальник отдела технической поддержки
Московского Еврейского Общинного Центра
Ишаяу Ластов
телефон: +7-495-645-05-16
моб : +7-901-569-81-86
с 12 до 18, с воскресенья по четверг
^ permalink raw reply
* Fwd: git checkout doesn't work?
From: Ishayahu Lastov @ 2013-01-11 6:46 UTC (permalink / raw)
To: git
In-Reply-To: <CAJ52sWkhQDhaZxjp4vxdwSX8HGYMqaXW=gZ-d6atUDKSjHg=yw@mail.gmail.com>
This is my session on Win7 x64:
Microsoft Windows [Version 6.1.7601]
(c) Корпорация Майкрософт (Microsoft Corp.), 2009. Все права защищены.
C:\Dropbox\Dropbox\Wesnoth\Apocryphs>cd Apokryphs.Orks
C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks>git 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.Orks>cd scenarios
C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenarios>git 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>git checkout -- 01
_NothernVillage.cfg
C:\Dropbox\Dropbox\Wesnoth\Apocryphs\Apokryphs.Orks\scenarios>git 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?
--
сохраняйте, пожалуйста, при ответе исходный текст письма
С уважением,
начальник отдела технической поддержки
Московского Еврейского Общинного Центра
Ишаяу Ластов
телефон: +7-495-645-05-16
моб : +7-901-569-81-86
с 12 до 18, с воскресенья по четверг
^ permalink raw reply
* Re: [PATCH 09/19] reset.c: replace switch by if-else
From: Martin von Zweigbergk @ 2013-01-11 6:35 UTC (permalink / raw)
To: Junio C Hamano; +Cc: git
In-Reply-To: <7vhamq5e1v.fsf@alter.siamese.dyndns.org>
On Wed, Jan 9, 2013 at 11:53 AM, Junio C Hamano <gitster@pobox.com> wrote:
> Martin von Zweigbergk <martinvonz@gmail.com> writes:
>
>> ---
>> builtin/reset.c | 13 +++----------
>> 1 file changed, 3 insertions(+), 10 deletions(-)
>>
>> diff --git a/builtin/reset.c b/builtin/reset.c
>> index 42d1563..05ccfd4 100644
>> --- a/builtin/reset.c
>> +++ b/builtin/reset.c
>> @@ -351,18 +351,11 @@ int cmd_reset(int argc, const char **argv, const char *prefix)
>> * saving the previous head in ORIG_HEAD before. */
>> update_ref_status = update_refs(rev, sha1);
>>
>> - switch (reset_type) {
>> - case HARD:
>> - if (!update_ref_status && !quiet)
>> - print_new_head_line(commit);
>> - break;
>> - case SOFT: /* Nothing else to do. */
>> - break;
>> - case MIXED: /* Report what has not been updated. */
>> + if (reset_type == HARD && !update_ref_status && !quiet)
>> + print_new_head_line(commit);
>> + else if (reset_type == MIXED) /* Report what has not been updated. */
>> update_index_refresh(0, NULL,
>> quiet ? REFRESH_QUIET : REFRESH_IN_PORCELAIN);
>> - break;
>> - }
>
> Justification?
Clairvoyance -- the HARD case will soon be the only non-empty case.
It's also missing KEEP and MERGE (but the empty SOFT block is there).
I'll update the message. I will also move the patch a little later in
the series, closer to where it will be useful.
^ permalink raw reply
* Re: Turning a complete repository to a shallow one
From: Junio C Hamano @ 2013-01-11 4:53 UTC (permalink / raw)
To: Duy Nguyen; +Cc: Git Mailing List
In-Reply-To: <CACsJy8Bv+AfDbttFdJ5a0PaoMrMtv1seda7VqLpfdevR4BMj4A@mail.gmail.com>
Duy Nguyen <pclouds@gmail.com> writes:
> Apparently we could do it:
>
> git clone --single-branch git.git
> cd git
> git tag -l|xargs git tag -d
> git fetch --depth=1 origin master
> git repack -ad
I may have been unclear in the earlier message, but this is one of
the reasons why I think "fetch --depth" is misadvertised (it says
"deepen the history", when the real thing it does is to truncate to
the new depth counting from the updated tip), and misdesigned (it
forces the user to guess what the new depth should be). It should
be advertised correctly, as a way to reset its depth starting from
the current history (and of course --depth=1 is truncates).
We should introduce a separate "fetch --deepen" that does what
normal people would want (see my earlier message with ASCII art).
^ permalink raw reply
* Turning a complete repository to a shallow one
From: Duy Nguyen @ 2013-01-11 4:40 UTC (permalink / raw)
To: Git Mailing List
Apparently we could do it:
git clone --single-branch git.git
cd git
git tag -l|xargs git tag -d
git fetch --depth=1 origin master
git repack -ad
Now the repository becomes shallow and all of history is _lost_. It is
a feature for those who wants to reduce disk usage, but it's also a
gun to shoot at your feet. I'm tempted to ban this case. If I want to
reduce disk usage, I should be forced to shallow clone it first, then
remove the original repository. I still have a complete repository if
I change my mind. And "rm -rf git" is alarming enough for me to think
it twice before executing.
Comments?
--
Duy
^ permalink raw reply
* [PATCH 3/3] t9604: fixup for new cvsimport
From: Chris Rorvick @ 2013-01-11 4:27 UTC (permalink / raw)
To: git; +Cc: Eric S. Raymond, Chris Rorvick
In-Reply-To: <1357878439-27500-1-git-send-email-chris@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 <user3@domain.org> EST5EDT
user4=User Four <user4@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.1.g220e17a
^ permalink raw reply related
* [PATCH 2/3] t9600: fixup for new cvsimport
From: Chris Rorvick @ 2013-01-11 4:27 UTC (permalink / raw)
To: git; +Cc: Eric S. Raymond, Chris Rorvick
In-Reply-To: <1357878439-27500-1-git-send-email-chris@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.1.g220e17a
^ permalink raw reply related
* [PATCH 1/3] t/lib-cvs.sh: allow cvsps version 3.x.
From: Chris Rorvick @ 2013-01-11 4:27 UTC (permalink / raw)
To: git; +Cc: Eric S. Raymond, Chris Rorvick
In-Reply-To: <1357878439-27500-1-git-send-email-chris@rorvick.com>
---
t/lib-cvs.sh | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/t/lib-cvs.sh b/t/lib-cvs.sh
index 44263ad..b55e861 100644
--- a/t/lib-cvs.sh
+++ b/t/lib-cvs.sh
@@ -15,7 +15,7 @@ export CVS
cvsps_version=`cvsps -h 2>&1 | sed -ne 's/cvsps version //p'`
case "$cvsps_version" in
-2.1 | 2.2*)
+2.1 | 2.2* | 3.*)
;;
'')
skip_all='skipping cvsimport tests, cvsps not found'
--
1.8.1.1.g220e17a
^ permalink raw reply related
* [PATCH 0/3] fixup remaining cvsimport tests
From: Chris Rorvick @ 2013-01-11 4:27 UTC (permalink / raw)
To: git; +Cc: Eric S. Raymond, Chris Rorvick
These patchs apply on top of of Eric Raymond's cvsimport patch. 7 of 15
tests in t9600 fail, one of which is fixed w/ a cvsps patch I've sent
to Eric (fixes revision map.) It no longer uses "origin" as the default
branch which I suspect is a problem for at least some of the remaining
tests. Both of the t9604 tests pass.
Chris
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.1.g220e17a
^ permalink raw reply
* Re: [PATCH 2/2] upload-pack: fix off-by-one depth calculation in shallow clone
From: Junio C Hamano @ 2013-01-11 4:26 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy
Cc: git, Stefan Beller, Jonathan Nieder, schlotter, Ralf.Wildenhues
In-Reply-To: <1357875005-21956-2-git-send-email-pclouds@gmail.com>
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> 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 <pclouds@gmail.com>
> ---
> 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));
Nice. No protocol extensions, you update the server side, and an
old client starts getting the right number of generations.
> diff --git a/t/t5500-fetch-pack.sh b/t/t5500-fetch-pack.sh
> index 6a6e672..58d3bdf 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
> +'
No &&-chaining?
Thanks.
^ permalink raw reply
* Re: [PATCH] minor diff between gitweb docs and actual template for $GIT/description
From: Tim Chase @ 2013-01-11 4:25 UTC (permalink / raw)
To: Jonathan Nieder; +Cc: git, Jakub Narebski
In-Reply-To: <20130111022200.GH30784@google.com>
On 01/10/13 20:22, Jonathan Nieder wrote:
> (+cc: Jakub, who maintains gitweb)
> Hi Tim,
>
> Tim Chase wrote:
>
>> The documentation for gitweb gives one description of the default
>> content for the $GIT/description, the description template has other
>> text. One of these two patches should be applied to bring them into
>> order (applying both would just reverse the problem). Or, both
>> could be changed to the same new text.
>
> May we have your sign-off? (See Documentation/SubmittingPatches for
> what this means.)
Hahahahah...a one liner doc-fix copy/pasting code from one place in
the codebase to another? If you need it, you've got it:
For my one line diff:
Signed-off-by: Tim Chase <git@tim.thechases.com>
Otherwise, consider my contribution CC0 or public domain or whatever
suits you best. Or take my patch as a bug report and "make" the fix
yourself. :-)
The patches should have been based off the master branch of
github.com/git/git, FWIW.
-tkc
@gumnos
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox