* [PATCH 1/9] Introduce CE_NO_CHECKOUT bit
[not found] <cover.1218807249.git.pclouds@gmail.com>
@ 2008-08-15 14:24 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:25 ` [PATCH 2/9] update-index: add --checkout/--no-checkout options to update " Nguyễn Thái Ngọc Duy
` (7 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:24 UTC (permalink / raw)
To: git
This bit is the basis of narrow checkout. If this bit is on, the entry
is outside narrow checkout and therefore should be ignored (similar
to CE_VALID)
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
cache.h | 8 ++++++++
read-cache.c | 6 +++---
2 files changed, 11 insertions(+), 3 deletions(-)
diff --git a/cache.h b/cache.h
index 30f1d62..86288b6 100644
--- a/cache.h
+++ b/cache.h
@@ -126,6 +126,7 @@ struct cache_entry {
#define CE_NAMEMASK (0x0fff)
#define CE_STAGEMASK (0x3000)
+#define CE_NO_CHECKOUT (0x4000)
#define CE_VALID (0x8000)
#define CE_STAGESHIFT 12
@@ -138,6 +139,9 @@ struct cache_entry {
#define CE_HASHED (0x100000)
#define CE_UNHASHED (0x200000)
+/* "Assume unchanged" mask */
+#define CE_VALID_MASK (CE_VALID | CE_NO_CHECKOUT)
+
/*
* Copy the sha1 and stat state of a cache entry from one to
* another. But we never change the name, or the hash state!
@@ -173,6 +177,10 @@ static inline size_t ce_namelen(const struct cache_entry *ce)
#define ondisk_ce_size(ce) ondisk_cache_entry_size(ce_namelen(ce))
#define ce_stage(ce) ((CE_STAGEMASK & (ce)->ce_flags) >> CE_STAGESHIFT)
#define ce_uptodate(ce) ((ce)->ce_flags & CE_UPTODATE)
+#define ce_no_checkout(ce) ((ce)->ce_flags & CE_NO_CHECKOUT)
+#define ce_checkout(ce) (!ce_no_checkout(ce))
+#define ce_mark_no_checkout(ce) ((ce)->ce_flags |= CE_NO_CHECKOUT)
+#define ce_mark_checkout(ce) ((ce)->ce_flags &= ~CE_NO_CHECKOUT)
#define ce_mark_uptodate(ce) ((ce)->ce_flags |= CE_UPTODATE)
#define ce_permissions(mode) (((mode) & 0100) ? 0755 : 0644)
diff --git a/read-cache.c b/read-cache.c
index a940f8d..d7f6b97 100644
--- a/read-cache.c
+++ b/read-cache.c
@@ -253,7 +253,7 @@ int ie_match_stat(const struct index_state *istate,
* If it's marked as always valid in the index, it's
* valid whatever the checked-out copy says.
*/
- if (!ignore_valid && (ce->ce_flags & CE_VALID))
+ if (!ignore_valid && (ce->ce_flags & CE_VALID_MASK))
return 0;
changed = ce_match_stat_basic(ce, st);
@@ -943,10 +943,10 @@ static struct cache_entry *refresh_cache_ent(struct index_state *istate,
return ce;
/*
- * CE_VALID means the user promised us that the change to
+ * CE_VALID_MASK means the user promised us that the change to
* the work tree does not matter and told us not to worry.
*/
- if (!ignore_valid && (ce->ce_flags & CE_VALID)) {
+ if (!ignore_valid && (ce->ce_flags & CE_VALID_MASK)) {
ce_mark_uptodate(ce);
return ce;
}
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 2/9] update-index: add --checkout/--no-checkout options to update CE_NO_CHECKOUT bit
[not found] <cover.1218807249.git.pclouds@gmail.com>
2008-08-15 14:24 ` [PATCH 1/9] Introduce CE_NO_CHECKOUT bit Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:25 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:25 ` [PATCH 3/9] ls-files: add --checkout option to show checked out files Nguyễn Thái Ngọc Duy
` (6 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:25 UTC (permalink / raw)
To: git
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-update-index.c | 40 +++++++++++++++++++++++++---------------
1 files changed, 25 insertions(+), 15 deletions(-)
diff --git a/builtin-update-index.c b/builtin-update-index.c
index 434cb8e..1d6bb65 100644
--- a/builtin-update-index.c
+++ b/builtin-update-index.c
@@ -24,8 +24,9 @@ static int info_only;
static int force_remove;
static int verbose;
static int mark_valid_only;
-#define MARK_VALID 1
-#define UNMARK_VALID 2
+static int mark_no_checkout_only;
+#define MARK_FLAG 1
+#define UNMARK_FLAG 2
static void report(const char *fmt, ...)
{
@@ -40,19 +41,15 @@ static void report(const char *fmt, ...)
va_end(vp);
}
-static int mark_valid(const char *path)
+static int mark_ce_flags(const char *path, int flag, int mark)
{
int namelen = strlen(path);
int pos = cache_name_pos(path, namelen);
if (0 <= pos) {
- switch (mark_valid_only) {
- case MARK_VALID:
- active_cache[pos]->ce_flags |= CE_VALID;
- break;
- case UNMARK_VALID:
- active_cache[pos]->ce_flags &= ~CE_VALID;
- break;
- }
+ if (mark)
+ active_cache[pos]->ce_flags |= flag;
+ else
+ active_cache[pos]->ce_flags &= ~flag;
cache_tree_invalidate_path(active_cache_tree, path);
active_cache_changed = 1;
return 0;
@@ -276,7 +273,12 @@ static void update_one(const char *path, const char *prefix, int prefix_length)
goto free_return;
}
if (mark_valid_only) {
- if (mark_valid(p))
+ if (mark_ce_flags(p, CE_VALID, mark_valid_only == MARK_FLAG))
+ die("Unable to mark file %s", path);
+ goto free_return;
+ }
+ if (mark_no_checkout_only) {
+ if (mark_ce_flags(p, CE_NO_CHECKOUT, mark_no_checkout_only == MARK_FLAG))
die("Unable to mark file %s", path);
goto free_return;
}
@@ -390,7 +392,7 @@ static void read_index_info(int line_termination)
}
static const char update_index_usage[] =
-"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
+"git update-index [-q] [--add] [--replace] [--remove] [--unmerged] [--refresh] [--really-refresh] [--cacheinfo] [--chmod=(+|-)x] [--assume-unchanged] [--checkout|--no-checkout] [--info-only] [--force-remove] [--stdin] [--index-info] [--unresolve] [--again | -g] [--ignore-missing] [-z] [--verbose] [--] <file>...";
static unsigned char head_sha1[20];
static unsigned char merge_head_sha1[20];
@@ -647,11 +649,19 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
continue;
}
if (!strcmp(path, "--assume-unchanged")) {
- mark_valid_only = MARK_VALID;
+ mark_valid_only = MARK_FLAG;
continue;
}
if (!strcmp(path, "--no-assume-unchanged")) {
- mark_valid_only = UNMARK_VALID;
+ mark_valid_only = UNMARK_FLAG;
+ continue;
+ }
+ if (!strcmp(path, "--checkout")) {
+ mark_no_checkout_only = UNMARK_FLAG;
+ continue;
+ }
+ if (!strcmp(path, "--no-checkout")) {
+ mark_no_checkout_only = MARK_FLAG;
continue;
}
if (!strcmp(path, "--info-only")) {
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 3/9] ls-files: add --checkout option to show checked out files
[not found] <cover.1218807249.git.pclouds@gmail.com>
2008-08-15 14:24 ` [PATCH 1/9] Introduce CE_NO_CHECKOUT bit Nguyễn Thái Ngọc Duy
2008-08-15 14:25 ` [PATCH 2/9] update-index: add --checkout/--no-checkout options to update " Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:25 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 4/9] Prevent diff machinery from examining worktree outside narrow checkout Nguyễn Thái Ngọc Duy
` (5 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:25 UTC (permalink / raw)
To: git
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-ls-files.c | 13 ++++++++++---
1 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index e8d568e..bcb1536 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -14,6 +14,7 @@
static int abbrev;
static int show_deleted;
static int show_cached;
+static int show_checkout;
static int show_others;
static int show_stage;
static int show_unmerged;
@@ -235,7 +236,7 @@ static void show_files(struct dir_struct *dir, const char *prefix)
if (show_killed)
show_killed_files(dir);
}
- if (show_cached | show_stage) {
+ if (show_cached | show_stage | show_checkout) {
for (i = 0; i < active_nr; i++) {
struct cache_entry *ce = active_cache[i];
int dtype = ce_to_dtype(ce);
@@ -245,6 +246,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
continue;
if (ce->ce_flags & CE_UPDATE)
continue;
+ if (show_checkout && ce_no_checkout(ce))
+ continue;
show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
}
}
@@ -423,7 +426,7 @@ int report_path_error(const char *ps_matched, const char **pathspec, int prefix_
}
static const char ls_files_usage[] =
- "git ls-files [-z] [-t] [-v] (--[cached|deleted|others|stage|unmerged|killed|modified])* "
+ "git ls-files [-z] [-t] [-v] (--[cached|checkout|deleted|others|stage|unmerged|killed|modified])* "
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
"[ --exclude-per-directory=<filename> ] [--exclude-standard] "
"[--full-name] [--abbrev] [--] [<file>]*";
@@ -465,6 +468,10 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
show_cached = 1;
continue;
}
+ if (!strcmp(arg, "--checkout")) {
+ show_checkout = 1;
+ continue;
+ }
if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) {
show_deleted = 1;
continue;
@@ -593,7 +600,7 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
/* With no flags, we default to showing the cached files */
if (!(show_stage | show_deleted | show_others | show_unmerged |
- show_killed | show_modified))
+ show_killed | show_modified | show_checkout))
show_cached = 1;
read_cache();
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 4/9] Prevent diff machinery from examining worktree outside narrow checkout
[not found] <cover.1218807249.git.pclouds@gmail.com>
` (2 preceding siblings ...)
2008-08-15 14:25 ` [PATCH 3/9] ls-files: add --checkout option to show checked out files Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:26 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 5/9] Clear CE_NO_CHECKOUT on checked out entries Nguyễn Thái Ngọc Duy
` (4 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:26 UTC (permalink / raw)
To: git
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
diff-lib.c | 5 +++--
diff.c | 4 +++-
2 files changed, 6 insertions(+), 3 deletions(-)
diff --git a/diff-lib.c b/diff-lib.c
index e7eaff9..4fffd31 100644
--- a/diff-lib.c
+++ b/diff-lib.c
@@ -159,7 +159,7 @@ int run_diff_files(struct rev_info *revs, unsigned int option)
continue;
}
- if (ce_uptodate(ce))
+ if (ce_uptodate(ce) || ce_no_checkout(ce))
continue;
changed = check_removed(ce, &st);
@@ -346,6 +346,8 @@ static void do_oneway_diff(struct unpack_trees_options *o,
struct rev_info *revs = cbdata->revs;
int match_missing, cached;
+ /* if the entry is not checked out, don't examine work tree */
+ cached = o->index_only || ce_no_checkout(idx);
/*
* Backward compatibility wart - "diff-index -m" does
* not mean "do not ignore merges", but "match_missing".
@@ -353,7 +355,6 @@ static void do_oneway_diff(struct unpack_trees_options *o,
* But with the revision flag parsing, that's found in
* "!revs->ignore_merges".
*/
- cached = o->index_only;
match_missing = !revs->ignore_merges;
if (cached && idx && ce_stage(idx)) {
diff --git a/diff.c b/diff.c
index a6c1432..ad164a5 100644
--- a/diff.c
+++ b/diff.c
@@ -1716,8 +1716,10 @@ static int reuse_worktree_file(const char *name, const unsigned char *sha1, int
/*
* If ce matches the file in the work tree, we can reuse it.
+ * For narrow checkout case, ce_uptodate() may be true although
+ * the file may or may not exist in the work tree.
*/
- if (ce_uptodate(ce) ||
+ if ((ce_uptodate(ce) && ce_checkout(ce)) ||
(!lstat(name, &st) && !ce_match_stat(ce, &st, 0)))
return 1;
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 5/9] Clear CE_NO_CHECKOUT on checked out entries.
[not found] <cover.1218807249.git.pclouds@gmail.com>
` (3 preceding siblings ...)
2008-08-15 14:26 ` [PATCH 4/9] Prevent diff machinery from examining worktree outside narrow checkout Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:26 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 6/9] Add support for narrow checkout in unpack_trees() Nguyễn Thái Ngọc Duy
` (3 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:26 UTC (permalink / raw)
To: git
With this you can just do "git checkout some-files" to
widen your checkout. On caveat though: caller must save
the index.
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
entry.c | 1 +
1 files changed, 1 insertions(+), 0 deletions(-)
diff --git a/entry.c b/entry.c
index 222aaa3..c1c01f4 100644
--- a/entry.c
+++ b/entry.c
@@ -230,5 +230,6 @@ int checkout_entry(struct cache_entry *ce, const struct checkout *state, char *t
} else if (state->not_new)
return 0;
create_directories(path, state);
+ ce_mark_checkout(ce);
return write_entry(ce, path, state, 0);
}
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 6/9] Add support for narrow checkout in unpack_trees()
[not found] <cover.1218807249.git.pclouds@gmail.com>
` (4 preceding siblings ...)
2008-08-15 14:26 ` [PATCH 5/9] Clear CE_NO_CHECKOUT on checked out entries Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:26 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 7/9] ls-files: add --narrow-match=spec option to test narrow matching Nguyễn Thái Ngọc Duy
` (2 subsequent siblings)
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:26 UTC (permalink / raw)
To: git
This patch teaches unpack_trees() to checkout/remove entries
on working directories appropriately when narrow area is
changed. There are three kind of changes:
- new_narrow_path: reset workdir to a new narrow checkout
- add_narrow_path: keep current narrow areas and add more entries
- remove_narrow_path: remove some entries from current narrow areas
CE_WD_REMOVE is introduced to remove entries from working directories,
but still keep them in index
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
cache.h | 3 ++
unpack-trees.c | 106 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++
unpack-trees.h | 4 ++
3 files changed, 113 insertions(+), 0 deletions(-)
diff --git a/cache.h b/cache.h
index 86288b6..f502b28 100644
--- a/cache.h
+++ b/cache.h
@@ -139,6 +139,9 @@ struct cache_entry {
#define CE_HASHED (0x100000)
#define CE_UNHASHED (0x200000)
+/* Only remove in work directory, not index */
+#define CE_WD_REMOVE (0x400000)
+
/* "Assume unchanged" mask */
#define CE_VALID_MASK (CE_VALID | CE_NO_CHECKOUT)
diff --git a/unpack-trees.c b/unpack-trees.c
index cba0aca..022c643 100644
--- a/unpack-trees.c
+++ b/unpack-trees.c
@@ -96,6 +96,21 @@ static int check_updates(struct unpack_trees_options *o)
if (o->update && o->verbose_update) {
for (total = cnt = 0; cnt < index->cache_nr; cnt++) {
struct cache_entry *ce = index->cache[cnt];
+
+ /*
+ * Special case: CE_WD_REMOVE may be set along with CE_NO_CHECKOUT
+ * when some files are going to leave narrow checkout, so it must
+ * go before ce_no_checkout() check
+ */
+ if (ce->ce_flags & CE_WD_REMOVE) {
+ total++;
+ continue;
+ }
+
+ /* Now if there is any update outside narrow, ignore it */
+ if (ce_no_checkout(ce))
+ continue;
+
if (ce->ce_flags & (CE_UPDATE | CE_REMOVE))
total++;
}
@@ -108,6 +123,18 @@ static int check_updates(struct unpack_trees_options *o)
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
+ /* As stated earlier, CE_WD_REMOVE must bypass ce_no_checkout() check */
+ if (ce->ce_flags & CE_WD_REMOVE) {
+ display_progress(progress, ++cnt);
+ if (o->update)
+ unlink_entry(ce);
+ continue;
+ }
+
+ /* Now if there is any update outside narrow, ignore it */
+ if (ce_no_checkout(ce))
+ continue;
+
if (ce->ce_flags & CE_REMOVE) {
display_progress(progress, ++cnt);
if (o->update)
@@ -121,6 +148,9 @@ static int check_updates(struct unpack_trees_options *o)
for (i = 0; i < index->cache_nr; i++) {
struct cache_entry *ce = index->cache[i];
+ if (ce_no_checkout(ce))
+ continue;
+
if (ce->ce_flags & CE_UPDATE) {
display_progress(progress, ++cnt);
ce->ce_flags &= ~CE_UPDATE;
@@ -725,6 +755,58 @@ static void show_stage_entry(FILE *o,
}
#endif
+int match_narrow_spec(const char *spec_, const char *path)
+{
+ int match = 0;
+ char *spec, *cur_spec;
+
+ if (!spec_)
+ return 1; /* always match if spec_ is NULL */
+ spec = cur_spec = xstrdup(spec_);
+
+ while (!match) {
+ char *next_spec = strchr(cur_spec, ':');
+ if (!next_spec) {
+ if (!fnmatch(cur_spec, path, 0))
+ match = 1;
+ break;
+ }
+ *next_spec = '\0';
+ if (!fnmatch(cur_spec, path, 0))
+ match = 1;
+ cur_spec = next_spec+1;
+ }
+ free(spec);
+ return match;
+}
+
+static int apply_narrow_checkout(struct cache_entry *ce, struct cache_entry *old_ce, struct unpack_trees_options *o)
+{
+ int checkout;
+ int was_no_checkout = old_ce && ce_no_checkout(old_ce);
+
+ if (!(o->new_narrow_path | o->add_narrow_path | o->remove_narrow_path))
+ return 0;
+
+ checkout = match_narrow_spec(o->narrow_spec, ce->name);
+
+ /*
+ * The logic is a bit twisted here, when we expand checkout (add_narrow_path)
+ * we narrow no_checkout area. Similarly when we narrow checkout
+ * (remove_narrow_path), we expand no_checkout area. So there are three cases:
+ *
+ * [1] New narrow spec: do not care about old_ce
+ * [2] Expand spec: mark no_checkout if no_checkout previously _and_ now too
+ * [3] Narrow spec: mark no_checkout if previously no_checkout _or_ now checkout
+ */
+ if ((o->new_narrow_path && !checkout) /* [1] */
+ || (o->add_narrow_path && !checkout && was_no_checkout) /* [2] */
+ || (o->remove_narrow_path && (checkout || was_no_checkout))) /* [3] */
+ ce_mark_no_checkout(ce);
+
+ return 1;
+}
+
int threeway_merge(struct cache_entry **stages, struct unpack_trees_options *o)
{
struct cache_entry *index;
@@ -899,6 +981,7 @@ int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o)
struct cache_entry *current = src[0];
struct cache_entry *oldtree = src[1];
struct cache_entry *newtree = src[2];
+ int has_narrow_checkout = 0;
if (o->merge_size != 2)
return error("Cannot do a twoway merge of %d trees",
@@ -909,6 +992,9 @@ int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o)
if (newtree == o->df_conflict_entry)
newtree = NULL;
+ if (newtree)
+ has_narrow_checkout = apply_narrow_checkout(newtree, current, o);
+
if (current) {
if ((!oldtree && !newtree) || /* 4 and 5 */
(!oldtree && newtree &&
@@ -918,6 +1004,21 @@ int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o)
(oldtree && newtree &&
!same(oldtree, newtree) && /* 18 and 19 */
same(current, newtree))) {
+ if (has_narrow_checkout) {
+ /* enter narrow checkout, keep entry and add to workdir */
+ if (ce_no_checkout(current) && ce_checkout(newtree)) {
+ add_entry(o, current, CE_UPDATE, CE_NO_CHECKOUT);
+ return 1;
+ }
+
+ /* leave narrow checkout, keep entry and remove from workdir */
+ if (ce_checkout(current) && ce_no_checkout(newtree)) {
+ if (verify_uptodate(current, o))
+ return -1;
+ add_entry(o, current, CE_WD_REMOVE | CE_NO_CHECKOUT, 0);
+ return 1;
+ }
+ }
return keep_entry(current, o);
}
else if (oldtree && !newtree && same(current, oldtree)) {
@@ -927,6 +1028,9 @@ int twoway_merge(struct cache_entry **src, struct unpack_trees_options *o)
else if (oldtree && newtree &&
same(current, oldtree) && !same(current, newtree)) {
/* 20 or 21 */
+ /* enter narrow checkout, make sure always add */
+ if (has_narrow_checkout && ce_no_checkout(current) && ce_checkout(newtree))
+ newtree->ce_flags |= CE_UPDATE;
return merged_entry(newtree, current, o);
}
else {
@@ -987,6 +1091,8 @@ int oneway_merge(struct cache_entry **src, struct unpack_trees_options *o)
if (!a)
return deleted_entry(old, old, o);
+ apply_narrow_checkout(a, NULL, o);
+
if (old && same(old, a)) {
int update = 0;
if (o->reset) {
diff --git a/unpack-trees.h b/unpack-trees.h
index 94e5672..880cef8 100644
--- a/unpack-trees.h
+++ b/unpack-trees.h
@@ -26,6 +26,9 @@ struct unpack_trees_options {
verbose_update:1,
aggressive:1,
skip_unmerged:1,
+ new_narrow_path:1,
+ add_narrow_path:2,
+ remove_narrow_path:2,
gently:1;
const char *prefix;
int pos;
@@ -37,6 +40,7 @@ struct unpack_trees_options {
int merge_size;
struct cache_entry *df_conflict_entry;
+ const char *narrow_spec;
void *unpack_data;
struct index_state *dst_index;
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 7/9] ls-files: add --narrow-match=spec option to test narrow matching
[not found] <cover.1218807249.git.pclouds@gmail.com>
` (5 preceding siblings ...)
2008-08-15 14:26 ` [PATCH 6/9] Add support for narrow checkout in unpack_trees() Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:26 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:27 ` [PATCH 8/9] clone: support narrow checkout with --path option Nguyễn Thái Ngọc Duy
2008-08-15 14:27 ` [PATCH 9/9] checkout: add new options to support narrow checkout Nguyễn Thái Ngọc Duy
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:26 UTC (permalink / raw)
To: git
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-ls-files.c | 10 +++++++++-
1 files changed, 9 insertions(+), 1 deletions(-)
diff --git a/builtin-ls-files.c b/builtin-ls-files.c
index bcb1536..0064f73 100644
--- a/builtin-ls-files.c
+++ b/builtin-ls-files.c
@@ -29,6 +29,7 @@ static const char **pathspec;
static int error_unmatch;
static char *ps_matched;
static const char *with_tree;
+static const char *narrow_spec;
static const char *tag_cached = "";
static const char *tag_unmerged = "";
@@ -219,6 +220,7 @@ static void show_ce_entry(const char *tag, struct cache_entry *ce)
write_name_quoted(ce->name + offset, stdout, line_terminator);
}
+int match_narrow_spec(const char *spec_, const char *path); /* unpack-trees.c */
static void show_files(struct dir_struct *dir, const char *prefix)
{
int i;
@@ -248,6 +250,8 @@ static void show_files(struct dir_struct *dir, const char *prefix)
continue;
if (show_checkout && ce_no_checkout(ce))
continue;
+ if (narrow_spec && !match_narrow_spec(narrow_spec, ce->name))
+ continue;
show_ce_entry(ce_stage(ce) ? tag_unmerged : tag_cached, ce);
}
}
@@ -429,7 +433,7 @@ static const char ls_files_usage[] =
"git ls-files [-z] [-t] [-v] (--[cached|checkout|deleted|others|stage|unmerged|killed|modified])* "
"[ --ignored ] [--exclude=<pattern>] [--exclude-from=<file>] "
"[ --exclude-per-directory=<filename> ] [--exclude-standard] "
- "[--full-name] [--abbrev] [--] [<file>]*";
+ "[--narrow-match=narrowspec] [--full-name] [--abbrev] [--] [<file>]*";
int cmd_ls_files(int argc, const char **argv, const char *prefix)
{
@@ -472,6 +476,10 @@ int cmd_ls_files(int argc, const char **argv, const char *prefix)
show_checkout = 1;
continue;
}
+ if (!prefixcmp(arg, "--narrow-match=")) {
+ narrow_spec = arg+15;
+ continue;
+ }
if (!strcmp(arg, "-d") || !strcmp(arg, "--deleted")) {
show_deleted = 1;
continue;
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 8/9] clone: support narrow checkout with --path option
[not found] <cover.1218807249.git.pclouds@gmail.com>
` (6 preceding siblings ...)
2008-08-15 14:26 ` [PATCH 7/9] ls-files: add --narrow-match=spec option to test narrow matching Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:27 ` Nguyễn Thái Ngọc Duy
2008-08-15 14:27 ` [PATCH 9/9] checkout: add new options to support narrow checkout Nguyễn Thái Ngọc Duy
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:27 UTC (permalink / raw)
To: git
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-clone.c | 13 +++++++++++++
1 files changed, 13 insertions(+), 0 deletions(-)
diff --git a/builtin-clone.c b/builtin-clone.c
index c0e3086..0fcf53d 100644
--- a/builtin-clone.c
+++ b/builtin-clone.c
@@ -36,6 +36,7 @@ static const char * const builtin_clone_usage[] = {
static int option_quiet, option_no_checkout, option_bare, option_mirror;
static int option_local, option_no_hardlinks, option_shared;
static char *option_template, *option_reference, *option_depth;
+static char *option_narrow_path;
static char *option_origin = NULL;
static char *option_upload_pack = "git-upload-pack";
@@ -43,6 +44,8 @@ static struct option builtin_clone_options[] = {
OPT__QUIET(&option_quiet),
OPT_BOOLEAN('n', "no-checkout", &option_no_checkout,
"don't create a checkout"),
+ OPT_STRING(0, "path", &option_narrow_path, "prefixes",
+ "limit checkout to specified paths (narrow checkout)"),
OPT_BOOLEAN(0, "bare", &option_bare, "create a bare repository"),
OPT_BOOLEAN(0, "naked", &option_bare, "create a bare repository"),
OPT_BOOLEAN(0, "mirror", &option_mirror,
@@ -376,10 +379,15 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
if (option_origin)
die("--bare and --origin %s options are incompatible.",
option_origin);
+ if (option_narrow_path)
+ die("--bare and --path options are incompatible.");
option_no_checkout = 1;
use_separate_remote = 0;
}
+ if (option_no_checkout && option_narrow_path)
+ die("--no-checkout and --path options are incompatible.");
+
if (!option_origin)
option_origin = "origin";
@@ -586,6 +594,11 @@ int cmd_clone(int argc, const char **argv, const char *prefix)
opts.src_index = &the_index;
opts.dst_index = &the_index;
+ if (option_narrow_path) {
+ opts.new_narrow_path = 1;
+ opts.narrow_spec = option_narrow_path;
+ }
+
tree = parse_tree_indirect(remote_head->old_sha1);
parse_tree(tree);
init_tree_desc(&t, tree->buffer, tree->size);
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
* [PATCH 9/9] checkout: add new options to support narrow checkout
[not found] <cover.1218807249.git.pclouds@gmail.com>
` (7 preceding siblings ...)
2008-08-15 14:27 ` [PATCH 8/9] clone: support narrow checkout with --path option Nguyễn Thái Ngọc Duy
@ 2008-08-15 14:27 ` Nguyễn Thái Ngọc Duy
8 siblings, 0 replies; 9+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-08-15 14:27 UTC (permalink / raw)
To: git
These options include:
--full: return to full checkout (default)
--path: narrow checkout to some areas according to given spec
--add-path/--remove-path: adjust current narrow checkout
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
builtin-checkout.c | 41 +++++++++++++++++++++++++++++++++++++++++
1 files changed, 41 insertions(+), 0 deletions(-)
diff --git a/builtin-checkout.c b/builtin-checkout.c
index e95eab9..f2254c6 100644
--- a/builtin-checkout.c
+++ b/builtin-checkout.c
@@ -160,6 +160,11 @@ struct checkout_opts {
char *new_branch;
int new_branch_log;
enum branch_track track;
+
+ char *new_path;
+ char *add_path;
+ char *remove_path;
+ int no_narrow_checkout;
};
static int reset_tree(struct tree *tree, struct checkout_opts *o, int worktree)
@@ -255,6 +260,23 @@ static int merge_working_tree(struct checkout_opts *opts,
tree = parse_tree_indirect(new->commit->object.sha1);
init_tree_desc(&trees[1], tree->buffer, tree->size);
+ if (opts->no_narrow_checkout) {
+ /* leave narrow_spec NULL */
+ topts.new_narrow_path = 1;
+ }
+ else if (opts->new_path) {
+ topts.narrow_spec = opts->new_path;
+ topts.new_narrow_path = 1;
+ }
+ else if (opts->add_path) {
+ topts.narrow_spec = opts->add_path;
+ topts.add_narrow_path = 1;
+ }
+ else if (opts->remove_path) {
+ topts.narrow_spec = opts->remove_path;
+ topts.remove_narrow_path = 1;
+ }
+
ret = unpack_trees(2, trees, &topts);
if (ret == -1) {
/*
@@ -428,6 +450,10 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
BRANCH_TRACK_EXPLICIT),
OPT_BOOLEAN('f', NULL, &opts.force, "force"),
OPT_BOOLEAN('m', NULL, &opts.merge, "merge"),
+ OPT_BOOLEAN(0, "full", &opts.no_narrow_checkout, "quit sparse checkout"),
+ OPT_STRING(0, "path", &opts.new_path, "prefixes", "apply new narrow checkout path"),
+ OPT_STRING(0, "add-path", &opts.add_path, "prefixes", "add more checkout area"),
+ OPT_STRING(0, "remove-path", &opts.remove_path, "prefixes", "narrow checkout area"),
OPT_END(),
};
int has_dash_dash;
@@ -460,6 +486,18 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
if (opts.track == -1)
opts.track = git_branch_track;
+ if (((opts.no_narrow_checkout ? 1 : 0) +
+ (opts.new_path ? 1 : 0) +
+ (opts.add_path ? 1 : 0) +
+ (opts.remove_path ? 1 : 0)) > 1)
+ die("git checkout: --path, --full, --add-path and --remove-path are incompatible");
+
+ if (opts.new_branch && (opts.add_path || opts.remove_path))
+ die("git checkout: --add-path and --remove-path should only be used on current branch");
+
+ if (opts.new_branch && opts.no_narrow_checkout)
+ die("git checkout: switching branch with --full does not make sense");
+
if (opts.force && opts.merge)
die("git checkout: -f and -m are incompatible");
@@ -550,6 +588,9 @@ no_reference:
}
}
+ if (opts.no_narrow_checkout || opts.new_path || opts.add_path || opts.remove_path)
+ die("git checkout: updating paths is incompatible with setting sparse checkout");
+
return checkout_paths(source_tree, pathspec);
}
--
1.6.0.rc3.250.g8dd0
^ permalink raw reply related [flat|nested] 9+ messages in thread
end of thread, other threads:[~2008-08-15 14:29 UTC | newest]
Thread overview: 9+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1218807249.git.pclouds@gmail.com>
2008-08-15 14:24 ` [PATCH 1/9] Introduce CE_NO_CHECKOUT bit Nguyễn Thái Ngọc Duy
2008-08-15 14:25 ` [PATCH 2/9] update-index: add --checkout/--no-checkout options to update " Nguyễn Thái Ngọc Duy
2008-08-15 14:25 ` [PATCH 3/9] ls-files: add --checkout option to show checked out files Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 4/9] Prevent diff machinery from examining worktree outside narrow checkout Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 5/9] Clear CE_NO_CHECKOUT on checked out entries Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 6/9] Add support for narrow checkout in unpack_trees() Nguyễn Thái Ngọc Duy
2008-08-15 14:26 ` [PATCH 7/9] ls-files: add --narrow-match=spec option to test narrow matching Nguyễn Thái Ngọc Duy
2008-08-15 14:27 ` [PATCH 8/9] clone: support narrow checkout with --path option Nguyễn Thái Ngọc Duy
2008-08-15 14:27 ` [PATCH 9/9] checkout: add new options to support narrow checkout Nguyễn Thái Ngọc Duy
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).