* [PATCH 14/16] clone: support narrow checkout with --path option
2008-09-14 13:08 ` [PATCH 13/16] ls-files: add --narrow-match=spec option for testing narrow matching Nguyễn Thái Ngọc Duy
@ 2008-09-14 13:08 ` Nguyễn Thái Ngọc Duy
2008-09-14 19:01 ` Jakub Narebski
0 siblings, 1 reply; 4+ messages in thread
From: Nguyễn Thái Ngọc Duy @ 2008-09-14 13:08 UTC (permalink / raw)
To: git; +Cc: Nguyễn Thái Ngọc Duy
Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
Documentation/git-clone.txt | 8 +++++++-
builtin-clone.c | 13 +++++++++++++
t/t5703-clone-narrow.sh | 39 +++++++++++++++++++++++++++++++++++++++
3 files changed, 59 insertions(+), 1 deletions(-)
create mode 100755 t/t5703-clone-narrow.sh
diff --git a/Documentation/git-clone.txt b/Documentation/git-clone.txt
index 0e14e73..0a7d11d 100644
--- a/Documentation/git-clone.txt
+++ b/Documentation/git-clone.txt
@@ -12,7 +12,8 @@ SYNOPSIS
'git clone' [--template=<template_directory>]
[-l] [-s] [--no-hardlinks] [-q] [-n] [--bare] [--mirror]
[-o <name>] [-u <upload-pack>] [--reference <repository>]
- [--depth <depth>] [--] <repository> [<directory>]
+ [--depth <depth>] [--path=<narrow_spec>] [--]
+ <repository> [<directory>]
DESCRIPTION
-----------
@@ -94,6 +95,11 @@ then the cloned repository will become corrupt.
-n::
No checkout of HEAD is performed after the clone is complete.
+--path=<narrow_spec>::
+ A narrow checkout of HEAD is performed after clone is complete
+ with given narrow spec. Please refer to linkgit:git-checkout[1]
+ for more detail on narrow checkout and narrow spec.
+
--bare::
Make a 'bare' GIT repository. That is, instead of
creating `<directory>` and placing the administrative
diff --git a/builtin-clone.c b/builtin-clone.c
index c843529..37d44ca 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,
@@ -385,10 +388,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";
@@ -597,6 +605,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);
diff --git a/t/t5703-clone-narrow.sh b/t/t5703-clone-narrow.sh
new file mode 100755
index 0000000..3ab9eaf
--- /dev/null
+++ b/t/t5703-clone-narrow.sh
@@ -0,0 +1,39 @@
+#!/bin/sh
+
+test_description='narrow clone'
+
+. ./test-lib.sh
+
+test_expect_success setup '
+ rm -fr .git &&
+ test_create_repo src &&
+ (
+ cd src
+ mkdir -p work/sub/dir
+ touch untracked tracked modified added
+ touch work/untracked work/tracked work/modified work/added
+ git add tracked work/tracked
+ git add modified work/modified
+ git commit -m initial
+ )
+
+'
+
+test_expect_success 'narrow clone incompatible with --bare' '
+ rm -fr dst &&
+ test_must_fail git clone --path=work --bare src dst
+'
+
+test_expect_success 'narrow clone incompatible with --no-checkout' '
+ rm -fr dst &&
+ test_must_fail git clone --path=work -n src dst
+'
+
+test_expect_success 'clone with --path' '
+ rm -fr dst &&
+ git clone --path=work src dst &&
+ cd dst &&
+ test -z "$(git ls-files --checkout | grep -v ^work/)"
+'
+
+test_done
--
1.6.0.96.g2fad1.dirty
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH 14/16] clone: support narrow checkout with --path option
2008-09-14 13:08 ` [PATCH 14/16] clone: support narrow checkout with --path option Nguyễn Thái Ngọc Duy
@ 2008-09-14 19:01 ` Jakub Narebski
2008-09-15 20:27 ` Junio C Hamano
0 siblings, 1 reply; 4+ messages in thread
From: Jakub Narebski @ 2008-09-14 19:01 UTC (permalink / raw)
To: Nguyễn Thái Ngọc Duy; +Cc: git
I will comment only on the documentation...
Nguyễn Thái Ngọc Duy <pclouds@gmail.com> writes:
> +--path=<narrow_spec>::
> + A narrow checkout of HEAD is performed after clone is complete
> + with given narrow spec. Please refer to linkgit:git-checkout[1]
> + for more detail on narrow checkout and narrow spec.
Two questions. First, can you repeat those specifiers, i.e. use
"git clone --path=Documentation/ --path=.gitignore"?
Second, how `--path=<narrow_spec>` interacts with `-n' (no checkout).
Does it even have any sense? Perhaps those options should be mutually
incompatibile (and --bare and this option too)?
--
Jakub Narebski
Poland
ShadeHawk on #git
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 14/16] clone: support narrow checkout with --path option
[not found] <48cdd598c6cd9_12e03ff42d900428232ec@app02.zenbe.com.tmail>
@ 2008-09-15 7:40 ` Jakub Narebski
0 siblings, 0 replies; 4+ messages in thread
From: Jakub Narebski @ 2008-09-15 7:40 UTC (permalink / raw)
To: Duy Nguyen; +Cc: git
Duy Nguyen wrote:
> On 09/15/2008 "Jakub Narebski" <jnareb@gmail.com> wrote:
> >
> > Second, how `--path=<narrow_spec>` interacts with `-n' (no checkout).
> > Does it even have any sense? Perhaps those options should be mutually
> > incompatibile (and --bare and this option too)?
>
> Yes they are incompatible and won't work if either -n or --bare is provided with --path.
Perhaps that should be stated explicitly? It is quite obvious, but...
--
Jakub Narebski
Poland
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH 14/16] clone: support narrow checkout with --path option
2008-09-14 19:01 ` Jakub Narebski
@ 2008-09-15 20:27 ` Junio C Hamano
0 siblings, 0 replies; 4+ messages in thread
From: Junio C Hamano @ 2008-09-15 20:27 UTC (permalink / raw)
To: Jakub Narebski; +Cc: Nguyễn Thái Ngọc Duy, git
Jakub Narebski <jnareb@gmail.com> writes:
> Second, how `--path=<narrow_spec>` interacts with `-n' (no checkout).
> Does it even have any sense? Perhaps those options should be mutually
> incompatibile (and --bare and this option too)?
Technically you could mark the index entries with no-checkout bits even
with -n, so that later checkout or branch switching would honor that, but
the branch switching would make paths that do not exist in the remote HEAD
branch but do exist in the switched-to branch appear, which would be
confusing. So instead of supporting:
$ git clone -n --path=Documentation/ $there work
$ cd work
$ git checkout next
we can support:
$ git clone -n $there work
$ cd work
$ git checkout --path=Documentation/ next
which is much easier to explain and understand.
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2008-09-15 20:28 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <48cdd598c6cd9_12e03ff42d900428232ec@app02.zenbe.com.tmail>
2008-09-15 7:40 ` [PATCH 14/16] clone: support narrow checkout with --path option Jakub Narebski
2008-09-14 13:07 [PATCH 00/16] Narrow/Partial/Sparse checkout Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 01/16] Extend index to save more flags Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 02/16] Introduce CE_NO_CHECKOUT bit Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 03/16] update-index: refactor mark_valid() in preparation for new options Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 04/16] update-index: add --checkout/--no-checkout to update CE_NO_CHECKOUT bit Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 05/16] ls-files: add --narrow-checkout option to "will checkout" entries Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 06/16] Add tests for updating no-checkout entries in index Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 07/16] Prevent diff machinery from examining worktree outside narrow checkout Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 08/16] checkout_entry(): CE_NO_CHECKOUT on checked out entries Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 09/16] ls-files: apply --deleted on narrow area only Nguyễn Thái Ngọc Duy
2008-09-14 13:07 ` [PATCH 10/16] grep: skip files that have not been checked out Nguyễn Thái Ngọc Duy
2008-09-14 13:08 ` [PATCH 11/16] unpack_trees(): add support for narrow checkout Nguyễn Thái Ngọc Duy
2008-09-14 13:08 ` [PATCH 12/16] narrow spec: put '+' before a spec will change semantic of '*' Nguyễn Thái Ngọc Duy
2008-09-14 13:08 ` [PATCH 13/16] ls-files: add --narrow-match=spec option for testing narrow matching Nguyễn Thái Ngọc Duy
2008-09-14 13:08 ` [PATCH 14/16] clone: support narrow checkout with --path option Nguyễn Thái Ngọc Duy
2008-09-14 19:01 ` Jakub Narebski
2008-09-15 20:27 ` Junio C Hamano
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).