{"thread":{"id":"27571","subject":"[PATCHv8 3/4] Support ref namespaces for remote repositories via upload-pack and receive-pack","startedAt":"2011-06-07T23:04:46Z","lastAt":"2011-06-15T14:00:00Z","messageCount":10,"participants":["Jamey Sharp","Junio C Hamano","Josh Triplett","Marc Branchaud","Jiang Xin","Shawn Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"169524","messageId":"1307487890-3915-1-git-send-email-jamey@minilop.net","threadId":"27571","inReplyTo":null,"subject":"[PATCHv8 0/4] Support ref namespaces","fromName":"Jamey Sharp","fromEmail":"jamey@minilop.net","sentAt":"2011-06-07T23:04:46Z","receivedAt":"2011-06-07T23:04:46Z","isPatch":false,"sender":{"key":"jamey@minilop.net","avatar":"https://gravatar.com/avatar/979ed4f9190c19c13a84945afe9a6cf141e8884ef6ddaae342db7a74ae28828e?d=mp&s=160"},"body":"This series adds support for dividing the refs of a single repository\ninto multiple namespaces, each of which can have its own branches, tags,\nand HEAD. Git can expose each namespace as an independent repository to\npull from and push to, while sharing the object store, and exposing all\nthe refs to operations such as git-gc.\n\nStoring multiple repositories as namespaces of a single repository\navoids storing duplicate copies of the same objects, such as when\nstoring multiple branches of the same source.  The alternates mechanism\nprovides similar support for avoiding duplicates, but alternates do not\nprevent duplication between new objects added to the repositories\nwithout ongoing maintenance, while namespaces do.\n\nThe first patch improves the prefix handling in the ref iteration\nfunctions, making it possible for us to implement\nfor_each_namespaced_ref later. The next two patches implement and then\nuse infrastructure for tracking the current namespace and iterating over\nthe refs in that namespace. The last patch adds general documentation\nfor namespaces, and specific references from the documentation on\nreceive-pack, upload-pack, http-backend, and git.\n\nv8: Fix error message in parsing of the --namespace option; noticed by\nBert Wesarg.\n\nv7 (unintentionally sent without a version number): Back out the change\nto actually use \"refs/\" as a filter, which caused t5501 to fail.  Patch\n1/4 now preserves the existing behavior, to avoid breaking assumptions\nlike this; that seems preferable to tracking down all the places that\nwould break due to this new ref filtering.  Adding that filtering and\nfixing all the resulting breakage seems like an entirely separate\nchange.\n\nJosh Triplett and Jamey Sharp (4):\n  Fix prefix handling in ref iteration functions\n  Add infrastructure for ref namespaces\n  Support ref namespaces for remote repositories via upload-pack and\n    receive-pack\n  Add documentation for ref namespaces\n\n Documentation/Makefile                 |    2 +-\n Documentation/git-http-backend.txt     |    8 +++\n Documentation/git-receive-pack.txt     |    2 +-\n Documentation/git-upload-pack.txt      |    4 ++\n Documentation/git.txt                  |   13 +++++-\n Documentation/gitnamespaces.txt        |   75 ++++++++++++++++++++++++++++++++\n builtin/receive-pack.c                 |   34 ++++++++++++---\n cache.h                                |    3 +\n contrib/completion/git-completion.bash |    3 +-\n environment.c                          |   41 +++++++++++++++++\n git.c                                  |   18 +++++++-\n refs.c                                 |   33 ++++++++++++--\n refs.h                                 |    3 +\n upload-pack.c                          |   15 +++---\n 14 files changed, 230 insertions(+), 24 deletions(-)\n create mode 100644 Documentation/gitnamespaces.txt\n\n-- \n1.7.5.3\n"},{"id":"169523","messageId":"1307487890-3915-2-git-send-email-jamey@minilop.net","threadId":"27571","inReplyTo":"1307487890-3915-1-git-send-email-jamey@minilop.net","subject":"[PATCHv8 1/4] Fix prefix handling in ref iteration functions","fromName":"Jamey Sharp","fromEmail":"jamey@minilop.net","sentAt":"2011-06-07T23:04:47Z","receivedAt":"2011-06-07T23:04:47Z","isPatch":false,"sender":{"key":"jamey@minilop.net","avatar":"https://gravatar.com/avatar/979ed4f9190c19c13a84945afe9a6cf141e8884ef6ddaae342db7a74ae28828e?d=mp&s=160"},"body":"From: Josh Triplett <josh@joshtriplett.org>\n\nThe do_for_each_ref iteration function accepts a prefix and a trim, and\nchecks for the prefix on each ref before passing in that ref; it also\nsupports trimming off part of the ref before passing it.  However,\ndo_for_each_ref used trim as the length of the prefix to check, ignoring\nthe actual length of the prefix.  Switch to using prefixcmp, checking\nthe entire length of the prefix string, to properly support a trim value\ndifferent than the length of the prefix.\n\nSeveral callers passed a prefix of \"refs/\" to filter out everything\noutside of refs/, but a trim of 0 to avoid trimming off the \"refs/\"; the\ntrim of 0 meant that the filter of \"refs/\" no longer applied.  Change\nthese callers to pass an empty prefix instead, to avoid changing the\nexisting behavior.  Various callers count on this lack of filtering,\nsuch as receive-pack which uses add_extra_ref to add alternates as refs\nnamed \".have\"; adding filtering would break that, causing\nt5501-fetch-push-alternates.sh to fail.  That lack of filtering doesn't\ncurrently have any other effect, since the loose ref functions can never\nsupply refs outside of \"refs/\", and packed-refs will not normally\ninclude such refs unless manually edited.\n\nCommit by Josh Triplett and Jamey Sharp.\n\nSigned-off-by: Josh Triplett <josh@joshtriplett.org>\nSigned-off-by: Jamey Sharp <jamey@minilop.net>\n---\n refs.c |    8 ++++----\n 1 files changed, 4 insertions(+), 4 deletions(-)\n\ndiff --git a/refs.c b/refs.c\nindex e3c0511..858cf92 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -584,7 +584,7 @@ int read_ref(const char *ref, unsigned char *sha1)\n static int do_one_ref(const char *base, each_ref_fn fn, int trim,\n \t\t      int flags, void *cb_data, struct ref_list *entry)\n {\n-\tif (strncmp(base, entry->name, trim))\n+\tif (prefixcmp(entry->name, base))\n \t\treturn 0;\n \n \tif (!(flags & DO_FOR_EACH_INCLUDE_BROKEN)) {\n@@ -728,12 +728,12 @@ int head_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)\n \n int for_each_ref(each_ref_fn fn, void *cb_data)\n {\n-\treturn do_for_each_ref(NULL, \"refs/\", fn, 0, 0, cb_data);\n+\treturn do_for_each_ref(NULL, \"\", fn, 0, 0, cb_data);\n }\n \n int for_each_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data)\n {\n-\treturn do_for_each_ref(submodule, \"refs/\", fn, 0, 0, cb_data);\n+\treturn do_for_each_ref(submodule, \"\", fn, 0, 0, cb_data);\n }\n \n int for_each_ref_in(const char *prefix, each_ref_fn fn, void *cb_data)\n@@ -819,7 +819,7 @@ int for_each_glob_ref(each_ref_fn fn, const char *pattern, void *cb_data)\n \n int for_each_rawref(each_ref_fn fn, void *cb_data)\n {\n-\treturn do_for_each_ref(NULL, \"refs/\", fn, 0,\n+\treturn do_for_each_ref(NULL, \"\", fn, 0,\n \t\t\t       DO_FOR_EACH_INCLUDE_BROKEN, cb_data);\n }\n \n-- \n1.7.5.3\n"},{"id":"169522","messageId":"1307487890-3915-3-git-send-email-jamey@minilop.net","threadId":"27571","inReplyTo":"1307487890-3915-1-git-send-email-jamey@minilop.net","subject":"[PATCHv8 2/4] Add infrastructure for ref namespaces","fromName":"Jamey Sharp","fromEmail":"jamey@minilop.net","sentAt":"2011-06-07T23:04:48Z","receivedAt":"2011-06-07T23:04:48Z","isPatch":false,"sender":{"key":"jamey@minilop.net","avatar":"https://gravatar.com/avatar/979ed4f9190c19c13a84945afe9a6cf141e8884ef6ddaae342db7a74ae28828e?d=mp&s=160"},"body":"From: Josh Triplett <josh@joshtriplett.org>\n\nAdd support for dividing the refs of a single repository into multiple\nnamespaces, each of which can have its own branches, tags, and HEAD.\nGit can expose each namespace as an independent repository to pull from\nand push to, while sharing the object store, and exposing all the refs\nto operations such as git-gc.\n\nStoring multiple repositories as namespaces of a single repository\navoids storing duplicate copies of the same objects, such as when\nstoring multiple branches of the same source.  The alternates mechanism\nprovides similar support for avoiding duplicates, but alternates do not\nprevent duplication between new objects added to the repositories\nwithout ongoing maintenance, while namespaces do.\n\nTo specify a namespace, set the GIT_NAMESPACE environment variable to\nthe namespace.  For each ref namespace, git stores the corresponding\nrefs in a directory under refs/namespaces/.  For example,\nGIT_NAMESPACE=foo will store refs under refs/namespaces/foo/.  You can\nalso specify namespaces via the --namespace option to git.\n\nNote that namespaces which include a / will expand to a hierarchy of\nnamespaces; for example, GIT_NAMESPACE=foo/bar will store refs under\nrefs/namespaces/foo/refs/namespaces/bar/.  This makes paths in\nGIT_NAMESPACE behave hierarchically, so that cloning with\nGIT_NAMESPACE=foo/bar produces the same result as cloning with\nGIT_NAMESPACE=foo and cloning from that repo with GIT_NAMESPACE=bar.  It\nalso avoids ambiguity with strange namespace paths such as\nfoo/refs/heads/, which could otherwise generate directory/file conflicts\nwithin the refs directory.\n\nThis adds the infrastructure for ref namespaces: handling the\nGIT_NAMESPACE environment variable and --namespace option, and iterating\nover refs in a namespace.  Subsequent commits use this infrastructure to\nimplement the user-visible support for ref namespaces.\n\nCommit by Josh Triplett and Jamey Sharp.\n\nSigned-off-by: Josh Triplett <josh@joshtriplett.org>\nSigned-off-by: Jamey Sharp <jamey@minilop.net>\n---\n cache.h                                |    3 ++\n contrib/completion/git-completion.bash |    1 +\n environment.c                          |   41 ++++++++++++++++++++++++++++++++\n git.c                                  |   18 ++++++++++++-\n refs.c                                 |   25 +++++++++++++++++++\n refs.h                                 |    3 ++\n 6 files changed, 89 insertions(+), 2 deletions(-)\n\ndiff --git a/cache.h b/cache.h\nindex e11cf6a..b256a94 100644\n--- a/cache.h\n+++ b/cache.h\n@@ -379,6 +379,7 @@ static inline enum object_type object_type(unsigned int mode)\n }\n \n #define GIT_DIR_ENVIRONMENT \"GIT_DIR\"\n+#define GIT_NAMESPACE_ENVIRONMENT \"GIT_NAMESPACE\"\n #define GIT_WORK_TREE_ENVIRONMENT \"GIT_WORK_TREE\"\n #define DEFAULT_GIT_DIR_ENVIRONMENT \".git\"\n #define DB_ENVIRONMENT \"GIT_OBJECT_DIRECTORY\"\n@@ -419,6 +420,8 @@ extern char *get_object_directory(void);\n extern char *get_index_file(void);\n extern char *get_graft_file(void);\n extern int set_git_dir(const char *path);\n+extern const char *get_git_namespace(void);\n+extern const char *strip_namespace(const char *namespaced_ref);\n extern const char *get_git_work_tree(void);\n extern const char *read_gitfile_gently(const char *path);\n extern void set_git_work_tree(const char *tree);\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b36290f..b10a1ec 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -2640,6 +2640,7 @@ _git ()\n \t\t\t--exec-path\n \t\t\t--html-path\n \t\t\t--work-tree=\n+\t\t\t--namespace=\n \t\t\t--help\n \t\t\t\"\n \t\t\t;;\ndiff --git a/environment.c b/environment.c\nindex 94d58fd..aad274b 100644\n--- a/environment.c\n+++ b/environment.c\n@@ -8,6 +8,7 @@\n  * are.\n  */\n #include \"cache.h\"\n+#include \"refs.h\"\n \n char git_default_email[MAX_GITNAME];\n char git_default_name[MAX_GITNAME];\n@@ -65,6 +66,9 @@ int core_preload_index = 0;\n char *git_work_tree_cfg;\n static char *work_tree;\n \n+static const char *namespace;\n+static size_t namespace_len;\n+\n static const char *git_dir;\n static char *git_object_dir, *git_index_file, *git_graft_file;\n \n@@ -86,6 +90,27 @@ const char * const local_repo_env[LOCAL_REPO_ENV_SIZE + 1] = {\n \tNULL\n };\n \n+static char *expand_namespace(const char *raw_namespace)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tstruct strbuf **components, **c;\n+\n+\tif (!raw_namespace || !*raw_namespace)\n+\t\treturn xstrdup(\"\");\n+\n+\tstrbuf_addstr(&buf, raw_namespace);\n+\tcomponents = strbuf_split(&buf, '/');\n+\tstrbuf_reset(&buf);\n+\tfor (c = components; *c; c++)\n+\t\tif (strcmp((*c)->buf, \"/\") != 0)\n+\t\t\tstrbuf_addf(&buf, \"refs/namespaces/%s\", (*c)->buf);\n+\tstrbuf_list_free(components);\n+\tif (check_ref_format(buf.buf) != CHECK_REF_FORMAT_OK)\n+\t\tdie(\"bad git namespace path \\\"%s\\\"\", raw_namespace);\n+\tstrbuf_addch(&buf, '/');\n+\treturn strbuf_detach(&buf, NULL);\n+}\n+\n static void setup_git_env(void)\n {\n \tgit_dir = getenv(GIT_DIR_ENVIRONMENT);\n@@ -111,6 +136,8 @@ static void setup_git_env(void)\n \t\tgit_graft_file = git_pathdup(\"info/grafts\");\n \tif (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))\n \t\tread_replace_refs = 0;\n+\tnamespace = expand_namespace(getenv(GIT_NAMESPACE_ENVIRONMENT));\n+\tnamespace_len = strlen(namespace);\n }\n \n int is_bare_repository(void)\n@@ -131,6 +158,20 @@ const char *get_git_dir(void)\n \treturn git_dir;\n }\n \n+const char *get_git_namespace(void)\n+{\n+\tif (!namespace)\n+\t\tsetup_git_env();\n+\treturn namespace;\n+}\n+\n+const char *strip_namespace(const char *namespaced_ref)\n+{\n+\tif (prefixcmp(namespaced_ref, get_git_namespace()) != 0)\n+\t\treturn NULL;\n+\treturn namespaced_ref + namespace_len;\n+}\n+\n static int git_work_tree_initialized;\n \n /*\ndiff --git a/git.c b/git.c\nindex 89721d4..47d2884 100644\n--- a/git.c\n+++ b/git.c\n@@ -7,8 +7,8 @@\n \n const char git_usage_string[] =\n \t\"git [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\\n\"\n-\t\"           [-p|--paginate|--no-pager] [--no-replace-objects]\\n\"\n-\t\"           [--bare] [--git-dir=<path>] [--work-tree=<path>]\\n\"\n+\t\"           [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\\n\"\n+\t\"           [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\\n\"\n \t\"           [-c name=value] [--help]\\n\"\n \t\"           <command> [<args>]\";\n \n@@ -126,6 +126,20 @@ static int handle_options(const char ***argv, int *argc, int *envchanged)\n \t\t\tsetenv(GIT_DIR_ENVIRONMENT, cmd + 10, 1);\n \t\t\tif (envchanged)\n \t\t\t\t*envchanged = 1;\n+\t\t} else if (!strcmp(cmd, \"--namespace\")) {\n+\t\t\tif (*argc < 2) {\n+\t\t\t\tfprintf(stderr, \"No namespace given for --namespace.\\n\" );\n+\t\t\t\tusage(git_usage_string);\n+\t\t\t}\n+\t\t\tsetenv(GIT_NAMESPACE_ENVIRONMENT, (*argv)[1], 1);\n+\t\t\tif (envchanged)\n+\t\t\t\t*envchanged = 1;\n+\t\t\t(*argv)++;\n+\t\t\t(*argc)--;\n+\t\t} else if (!prefixcmp(cmd, \"--namespace=\")) {\n+\t\t\tsetenv(GIT_NAMESPACE_ENVIRONMENT, cmd + 12, 1);\n+\t\t\tif (envchanged)\n+\t\t\t\t*envchanged = 1;\n \t\t} else if (!strcmp(cmd, \"--work-tree\")) {\n \t\t\tif (*argc < 2) {\n \t\t\t\tfprintf(stderr, \"No directory given for --work-tree.\\n\" );\ndiff --git a/refs.c b/refs.c\nindex 858cf92..e83bbf8 100644\n--- a/refs.c\n+++ b/refs.c\n@@ -782,6 +782,31 @@ int for_each_replace_ref(each_ref_fn fn, void *cb_data)\n \treturn do_for_each_ref(NULL, \"refs/replace/\", fn, 13, 0, cb_data);\n }\n \n+int head_ref_namespaced(each_ref_fn fn, void *cb_data)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tint ret = 0;\n+\tunsigned char sha1[20];\n+\tint flag;\n+\n+\tstrbuf_addf(&buf, \"%sHEAD\", get_git_namespace());\n+\tif (resolve_ref(buf.buf, sha1, 1, &flag))\n+\t\tret = fn(buf.buf, sha1, flag, cb_data);\n+\tstrbuf_release(&buf);\n+\n+\treturn ret;\n+}\n+\n+int for_each_namespaced_ref(each_ref_fn fn, void *cb_data)\n+{\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tint ret;\n+\tstrbuf_addf(&buf, \"%srefs/\", get_git_namespace());\n+\tret = do_for_each_ref(NULL, buf.buf, fn, 0, 0, cb_data);\n+\tstrbuf_release(&buf);\n+\treturn ret;\n+}\n+\n int for_each_glob_ref_in(each_ref_fn fn, const char *pattern,\n \tconst char *prefix, void *cb_data)\n {\ndiff --git a/refs.h b/refs.h\nindex 5e7a9a5..9a5c9e0 100644\n--- a/refs.h\n+++ b/refs.h\n@@ -36,6 +36,9 @@ extern int for_each_tag_ref_submodule(const char *submodule, each_ref_fn fn, voi\n extern int for_each_branch_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);\n extern int for_each_remote_ref_submodule(const char *submodule, each_ref_fn fn, void *cb_data);\n \n+extern int head_ref_namespaced(each_ref_fn fn, void *cb_data);\n+extern int for_each_namespaced_ref(each_ref_fn fn, void *cb_data);\n+\n static inline const char *has_glob_specials(const char *pattern)\n {\n \treturn strpbrk(pattern, \"?*[\");\n-- \n1.7.5.3\n"},{"id":"169520","messageId":"1307487890-3915-4-git-send-email-jamey@minilop.net","threadId":"27571","inReplyTo":"1307487890-3915-1-git-send-email-jamey@minilop.net","subject":"[PATCHv8 3/4] Support ref namespaces for remote repositories via upload-pack and receive-pack","fromName":"Jamey Sharp","fromEmail":"jamey@minilop.net","sentAt":"2011-06-07T23:04:49Z","receivedAt":"2011-06-07T23:04:49Z","isPatch":false,"sender":{"key":"jamey@minilop.net","avatar":"https://gravatar.com/avatar/979ed4f9190c19c13a84945afe9a6cf141e8884ef6ddaae342db7a74ae28828e?d=mp&s=160"},"body":"From: Josh Triplett <josh@joshtriplett.org>\n\nChange upload-pack and receive-pack to use the namespace-prefixed refs\nwhen working with the repository, and use the unprefixed refs when\ntalking to the client, maintaining the masquerade.  This allows\nclone, pull, fetch, and push to work with a suitably configured\nGIT_NAMESPACE.\n\nWith appropriate configuration, this also allows http-backend to expose\nnamespaces as multiple repositories with different paths.  This only\nrequires setting GIT_NAMESPACE, which http-backend passes through to\nupload-pack and receive-pack.\n\nCommit by Josh Triplett and Jamey Sharp.\n\nSigned-off-by: Josh Triplett <josh@joshtriplett.org>\nSigned-off-by: Jamey Sharp <jamey@minilop.net>\n---\n builtin/receive-pack.c |   34 ++++++++++++++++++++++++++++------\n upload-pack.c          |   15 ++++++++-------\n 2 files changed, 36 insertions(+), 13 deletions(-)\n\ndiff --git a/builtin/receive-pack.c b/builtin/receive-pack.c\nindex e1a687a..54dd5d4 100644\n--- a/builtin/receive-pack.c\n+++ b/builtin/receive-pack.c\n@@ -120,9 +120,14 @@ static int show_ref(const char *path, const unsigned char *sha1, int flag, void\n \treturn 0;\n }\n \n+static int show_ref_cb(const char *path, const unsigned char *sha1, int flag, void *cb_data)\n+{\n+\treturn show_ref(strip_namespace(path), sha1, flag, cb_data);\n+}\n+\n static void write_head_info(void)\n {\n-\tfor_each_ref(show_ref, NULL);\n+\tfor_each_namespaced_ref(show_ref_cb, NULL);\n \tif (!sent_capabilities)\n \t\tshow_ref(\"capabilities^{}\", null_sha1, 0, NULL);\n \n@@ -333,6 +338,8 @@ static void refuse_unconfigured_deny_delete_current(void)\n static const char *update(struct command *cmd)\n {\n \tconst char *name = cmd->ref_name;\n+\tstruct strbuf namespaced_name_buf = STRBUF_INIT;\n+\tconst char *namespaced_name;\n \tunsigned char *old_sha1 = cmd->old_sha1;\n \tunsigned char *new_sha1 = cmd->new_sha1;\n \tstruct ref_lock *lock;\n@@ -343,7 +350,10 @@ static const char *update(struct command *cmd)\n \t\treturn \"funny refname\";\n \t}\n \n-\tif (is_ref_checked_out(name)) {\n+\tstrbuf_addf(&namespaced_name_buf, \"%s%s\", get_git_namespace(), name);\n+\tnamespaced_name = strbuf_detach(&namespaced_name_buf, NULL);\n+\n+\tif (is_ref_checked_out(namespaced_name)) {\n \t\tswitch (deny_current_branch) {\n \t\tcase DENY_IGNORE:\n \t\t\tbreak;\n@@ -371,7 +381,7 @@ static const char *update(struct command *cmd)\n \t\t\treturn \"deletion prohibited\";\n \t\t}\n \n-\t\tif (!strcmp(name, head_name)) {\n+\t\tif (!strcmp(namespaced_name, head_name)) {\n \t\t\tswitch (deny_delete_current) {\n \t\t\tcase DENY_IGNORE:\n \t\t\t\tbreak;\n@@ -427,14 +437,14 @@ static const char *update(struct command *cmd)\n \t\t\trp_warning(\"Allowing deletion of corrupt ref.\");\n \t\t\told_sha1 = NULL;\n \t\t}\n-\t\tif (delete_ref(name, old_sha1, 0)) {\n+\t\tif (delete_ref(namespaced_name, old_sha1, 0)) {\n \t\t\trp_error(\"failed to delete %s\", name);\n \t\t\treturn \"failed to delete\";\n \t\t}\n \t\treturn NULL; /* good */\n \t}\n \telse {\n-\t\tlock = lock_any_ref_for_update(name, old_sha1, 0);\n+\t\tlock = lock_any_ref_for_update(namespaced_name, old_sha1, 0);\n \t\tif (!lock) {\n \t\t\trp_error(\"failed to lock %s\", name);\n \t\t\treturn \"failed to lock\";\n@@ -491,17 +501,29 @@ static void run_update_post_hook(struct command *commands)\n \n static void check_aliased_update(struct command *cmd, struct string_list *list)\n {\n+\tstruct strbuf buf = STRBUF_INIT;\n+\tconst char *dst_name;\n \tstruct string_list_item *item;\n \tstruct command *dst_cmd;\n \tunsigned char sha1[20];\n \tchar cmd_oldh[41], cmd_newh[41], dst_oldh[41], dst_newh[41];\n \tint flag;\n \n-\tconst char *dst_name = resolve_ref(cmd->ref_name, sha1, 0, &flag);\n+\tstrbuf_addf(&buf, \"%s%s\", get_git_namespace(), cmd->ref_name);\n+\tdst_name = resolve_ref(buf.buf, sha1, 0, &flag);\n+\tstrbuf_release(&buf);\n \n \tif (!(flag & REF_ISSYMREF))\n \t\treturn;\n \n+\tdst_name = strip_namespace(dst_name);\n+\tif (!dst_name) {\n+\t\trp_error(\"refusing update to broken symref '%s'\", cmd->ref_name);\n+\t\tcmd->skip_update = 1;\n+\t\tcmd->error_string = \"broken symref\";\n+\t\treturn;\n+\t}\n+\n \tif ((item = string_list_lookup(list, dst_name)) == NULL)\n \t\treturn;\n \ndiff --git a/upload-pack.c b/upload-pack.c\nindex ce5cbbe..267e5b1 100644\n--- a/upload-pack.c\n+++ b/upload-pack.c\n@@ -641,16 +641,17 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo\n \t\t\" side-band-64k ofs-delta shallow no-progress\"\n \t\t\" include-tag multi_ack_detailed\";\n \tstruct object *o = parse_object(sha1);\n+\tconst char *refname_nons = strip_namespace(refname);\n \n \tif (!o)\n \t\tdie(\"git upload-pack: cannot find object %s:\", sha1_to_hex(sha1));\n \n \tif (capabilities)\n-\t\tpacket_write(1, \"%s %s%c%s%s\\n\", sha1_to_hex(sha1), refname,\n+\t\tpacket_write(1, \"%s %s%c%s%s\\n\", sha1_to_hex(sha1), refname_nons,\n \t\t\t     0, capabilities,\n \t\t\t     stateless_rpc ? \" no-done\" : \"\");\n \telse\n-\t\tpacket_write(1, \"%s %s\\n\", sha1_to_hex(sha1), refname);\n+\t\tpacket_write(1, \"%s %s\\n\", sha1_to_hex(sha1), refname_nons);\n \tcapabilities = NULL;\n \tif (!(o->flags & OUR_REF)) {\n \t\to->flags |= OUR_REF;\n@@ -659,7 +660,7 @@ static int send_ref(const char *refname, const unsigned char *sha1, int flag, vo\n \tif (o->type == OBJ_TAG) {\n \t\to = deref_tag(o, refname, 0);\n \t\tif (o)\n-\t\t\tpacket_write(1, \"%s %s^{}\\n\", sha1_to_hex(o->sha1), refname);\n+\t\t\tpacket_write(1, \"%s %s^{}\\n\", sha1_to_hex(o->sha1), refname_nons);\n \t}\n \treturn 0;\n }\n@@ -680,12 +681,12 @@ static void upload_pack(void)\n {\n \tif (advertise_refs || !stateless_rpc) {\n \t\treset_timeout();\n-\t\thead_ref(send_ref, NULL);\n-\t\tfor_each_ref(send_ref, NULL);\n+\t\thead_ref_namespaced(send_ref, NULL);\n+\t\tfor_each_namespaced_ref(send_ref, NULL);\n \t\tpacket_flush(1);\n \t} else {\n-\t\thead_ref(mark_our_ref, NULL);\n-\t\tfor_each_ref(mark_our_ref, NULL);\n+\t\thead_ref_namespaced(mark_our_ref, NULL);\n+\t\tfor_each_namespaced_ref(mark_our_ref, NULL);\n \t}\n \tif (advertise_refs)\n \t\treturn;\n-- \n1.7.5.3\n"},{"id":"169521","messageId":"1307487890-3915-5-git-send-email-jamey@minilop.net","threadId":"27571","inReplyTo":"1307487890-3915-1-git-send-email-jamey@minilop.net","subject":"[PATCHv8 4/4] Add documentation for ref namespaces","fromName":"Jamey Sharp","fromEmail":"jamey@minilop.net","sentAt":"2011-06-07T23:04:50Z","receivedAt":"2011-06-07T23:04:50Z","isPatch":false,"sender":{"key":"jamey@minilop.net","avatar":"https://gravatar.com/avatar/979ed4f9190c19c13a84945afe9a6cf141e8884ef6ddaae342db7a74ae28828e?d=mp&s=160"},"body":"From: Josh Triplett <josh@joshtriplett.org>\n\nDocument the namespace mechanism in a new gitnamespaces(7) page.\nReference it from receive-pack and upload-pack.\n\nDocument the new --namespace option and GIT_NAMESPACE environment\nvariable in git(1), and reference gitnamespaces(7).\n\nAdd a sample Apache configuration to http-backend(1) to support\nnamespaced repositories, and reference gitnamespaces(7).\n\nCommit by Josh Triplett and Jamey Sharp.\n\nSigned-off-by: Josh Triplett <josh@joshtriplett.org>\nSigned-off-by: Jamey Sharp <jamey@minilop.net>\n---\n Documentation/Makefile                 |    2 +-\n Documentation/git-http-backend.txt     |    8 +++\n Documentation/git-receive-pack.txt     |    2 +-\n Documentation/git-upload-pack.txt      |    4 ++\n Documentation/git.txt                  |   13 +++++-\n Documentation/gitnamespaces.txt        |   75 ++++++++++++++++++++++++++++++++\n contrib/completion/git-completion.bash |    2 +-\n 7 files changed, 101 insertions(+), 5 deletions(-)\n create mode 100644 Documentation/gitnamespaces.txt\n\ndiff --git a/Documentation/Makefile b/Documentation/Makefile\nindex 36989b7..2004fbe 100644\n--- a/Documentation/Makefile\n+++ b/Documentation/Makefile\n@@ -6,7 +6,7 @@ MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \\\n \tgitrepository-layout.txt\n MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \\\n \tgitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \\\n-\tgitdiffcore.txt gitrevisions.txt gitworkflows.txt\n+\tgitdiffcore.txt gitnamespaces.txt gitrevisions.txt gitworkflows.txt\n \n MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)\n MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))\ndiff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt\nindex 277d9e1..f4e0741 100644\n--- a/Documentation/git-http-backend.txt\n+++ b/Documentation/git-http-backend.txt\n@@ -119,6 +119,14 @@ ScriptAliasMatch \\\n \n ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/\n ----------------------------------------------------------------\n++\n+To serve multiple repositories from different linkgit:gitnamespaces[7] in a\n+single repository:\n++\n+----------------------------------------------------------------\n+SetEnvIf Request_URI \"^/git/([^/]*)\" GIT_NAMESPACE=$1\n+ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1\n+----------------------------------------------------------------\n \n Accelerated static Apache 2.x::\n \tSimilar to the above, but Apache can be used to return static\ndiff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt\nindex f34e0ae..3534ba0 100644\n--- a/Documentation/git-receive-pack.txt\n+++ b/Documentation/git-receive-pack.txt\n@@ -149,7 +149,7 @@ if the repository is packed and is served via a dumb transport.\n \n SEE ALSO\n --------\n-linkgit:git-send-pack[1]\n+linkgit:git-send-pack[1], linkgit:gitnamespaces[7]\n \n GIT\n ---\ndiff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt\nindex 4c0ca9d..61a9a04 100644\n--- a/Documentation/git-upload-pack.txt\n+++ b/Documentation/git-upload-pack.txt\n@@ -33,6 +33,10 @@ OPTIONS\n <directory>::\n \tThe repository to sync from.\n \n+SEE ALSO\n+--------\n+linkgit:gitnamespaces[7]\n+\n GIT\n ---\n Part of the linkgit:git[1] suite\ndiff --git a/Documentation/git.txt b/Documentation/git.txt\nindex 5c45446..4cbf741 100644\n--- a/Documentation/git.txt\n+++ b/Documentation/git.txt\n@@ -10,8 +10,8 @@ SYNOPSIS\n --------\n [verse]\n 'git' [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n-    [-p|--paginate|--no-pager] [--no-replace-objects]\n-    [--bare] [--git-dir=<path>] [--work-tree=<path>]\n+    [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n+    [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n     [-c <name>=<value>]\n     [--help] <command> [<args>]\n \n@@ -325,6 +325,11 @@ help ...`.\n \tvariable (see core.worktree in linkgit:git-config[1] for a\n \tmore detailed discussion).\n \n+--namespace=<path>::\n+\tSet the git namespace.  See linkgit:gitnamespaces[7] for more\n+\tdetails.  Equivalent to setting the `GIT_NAMESPACE` environment\n+\tvariable.\n+\n --bare::\n \tTreat the repository as a bare repository.  If GIT_DIR\n \tenvironment is not set, it is set to the current working\n@@ -589,6 +594,10 @@ git so take care if using Cogito etc.\n \tThis can also be controlled by the '--work-tree' command line\n \toption and the core.worktree configuration variable.\n \n+'GIT_NAMESPACE'::\n+\tSet the git namespace; see linkgit:gitnamespaces[7] for details.\n+\tThe '--namespace' command-line option also sets this value.\n+\n 'GIT_CEILING_DIRECTORIES'::\n \tThis should be a colon-separated list of absolute paths.\n \tIf set, it is a list of directories that git should not chdir\ndiff --git a/Documentation/gitnamespaces.txt b/Documentation/gitnamespaces.txt\nnew file mode 100644\nindex 0000000..ed8924e\n--- /dev/null\n+++ b/Documentation/gitnamespaces.txt\n@@ -0,0 +1,75 @@\n+gitnamespaces(7)\n+================\n+\n+NAME\n+----\n+gitnamespaces - Git namespaces\n+\n+DESCRIPTION\n+-----------\n+\n+Git supports dividing the refs of a single repository into multiple\n+namespaces, each of which has its own branches, tags, and HEAD.  Git can\n+expose each namespace as an independent repository to pull from and push\n+to, while sharing the object store, and exposing all the refs to\n+operations such as linkgit:git-gc[1].\n+\n+Storing multiple repositories as namespaces of a single repository\n+avoids storing duplicate copies of the same objects, such as when\n+storing multiple branches of the same source.  The alternates mechanism\n+provides similar support for avoiding duplicates, but alternates do not\n+prevent duplication between new objects added to the repositories\n+without ongoing maintenance, while namespaces do.\n+\n+To specify a namespace, set the `GIT_NAMESPACE` environment variable to\n+the namespace.  For each ref namespace, git stores the corresponding\n+refs in a directory under `refs/namespaces/`.  For example,\n+`GIT_NAMESPACE=foo` will store refs under `refs/namespaces/foo/`.  You\n+can also specify namespaces via the `--namespace` option to\n+linkgit:git[1].\n+\n+Note that namespaces which include a `/` will expand to a hierarchy of\n+namespaces; for example, `GIT_NAMESPACE=foo/bar` will store refs under\n+`refs/namespaces/foo/refs/namespaces/bar/`.  This makes paths in\n+`GIT_NAMESPACE` behave hierarchically, so that cloning with\n+`GIT_NAMESPACE=foo/bar` produces the same result as cloning with\n+`GIT_NAMESPACE=foo` and cloning from that repo with `GIT_NAMESPACE=bar`.  It\n+also avoids ambiguity with strange namespace paths such as `foo/refs/heads/`,\n+which could otherwise generate directory/file conflicts within the `refs`\n+directory.\n+\n+linkgit:git-upload-pack[1] and linkgit:git-receive-pack[1] rewrite the\n+names of refs as specified by `GIT_NAMESPACE`.  git-upload-pack and\n+git-receive-pack will ignore all references outside the specified\n+namespace.\n+\n+The smart HTTP server, linkgit:git-http-backend[1], will pass\n+GIT_NAMESPACE through to the backend programs; see\n+linkgit:git-http-backend[1] for sample configuration to expose\n+repository namespaces as repositories.\n+\n+For a simple local test, you can use linkgit:git-remote-ext[1]:\n+\n+----------\n+git clone ext::'git --namespace=foo %s /tmp/prefixed.git'\n+----------\n+\n+SECURITY\n+--------\n+\n+Anyone with access to any namespace within a repository can potentially\n+access objects from any other namespace stored in the same repository.\n+You can't directly say \"give me object ABCD\" if you don't have a ref to\n+it, but you can do some other sneaky things like:\n+\n+. Claiming to push ABCD, at which point the server will optimize out the\n+  need for you to actually send it. Now you have a ref to ABCD and can\n+  fetch it (claiming not to have it, of course).\n+\n+. Requesting other refs, claiming that you have ABCD, at which point the\n+  server may generate deltas against ABCD.\n+\n+None of this causes a problem if you only host public repositories, or\n+if everyone who may read one namespace may also read everything in every\n+other namespace (for instance, if everyone in an organization has read\n+permission to every repository).\ndiff --git a/contrib/completion/git-completion.bash b/contrib/completion/git-completion.bash\nindex b10a1ec..ec1c986 100755\n--- a/contrib/completion/git-completion.bash\n+++ b/contrib/completion/git-completion.bash\n@@ -1469,7 +1469,7 @@ _git_help ()\n \t__gitcomp \"$__git_all_commands $(__git_aliases)\n \t\tattributes cli core-tutorial cvs-migration\n \t\tdiffcore gitk glossary hooks ignore modules\n-\t\trepository-layout tutorial tutorial-2\n+\t\tnamespaces repository-layout tutorial tutorial-2\n \t\tworkflows\n \t\t\"\n }\n-- \n1.7.5.3\n"},{"id":"169528","messageId":"7v4o4141mz.fsf@alter.siamese.dyndns.org","threadId":"27571","inReplyTo":"1307487890-3915-2-git-send-email-jamey@minilop.net","subject":"Re: [PATCHv8 1/4] Fix prefix handling in ref iteration functions","fromName":"Junio C Hamano","fromEmail":"gitster@pobox.com","sentAt":"2011-06-08T00:17:56Z","receivedAt":"2011-06-08T00:17:56Z","isPatch":false,"sender":{"key":"gitster@pobox.com","avatar":"https://avatars.githubusercontent.com/u/54884?v=4"},"body":"This round does fix the \".have\" issues, but with the --namespace patch\nlater in the series, it seems to break the same test, by filtering .have\nentries with \"refs/\" prefix.\n\n> Commit by Josh Triplett and Jamey Sharp.\n\nDidn't I ask you to remove this?\n\nPlease pick which one of you would be the primary contact for each patch.\nI know you said you two did these commits sitting side-by-side, but the\nthing is, we simply don't care, and \"git shortlog\" and the author list you\ncan see at http://www.git-scm.com/about don't, either.\n\nIt is somewhat irritating having to re-edit the log message (not just this\npart, but what have been queued were retitled, reflowed and reworded to\nmatch the style of other commits in the project better) over and over\nagain.\n"},{"id":"169530","messageId":"20110608014001.GA1800@leaf","threadId":"27571","inReplyTo":"7v4o4141mz.fsf@alter.siamese.dyndns.org","subject":"Re: [PATCHv8 1/4] Fix prefix handling in ref iteration functions","fromName":"Josh Triplett","fromEmail":"josh@joshtriplett.org","sentAt":"2011-06-08T01:40:01Z","receivedAt":"2011-06-08T01:40:01Z","isPatch":false,"sender":{"key":"josh@joshtriplett.org","avatar":"https://avatars.githubusercontent.com/u/162737?v=4"},"body":"On Tue, Jun 07, 2011 at 05:17:56PM -0700, Junio C Hamano wrote:\n> This round does fix the \".have\" issues, but with the --namespace patch\n> later in the series, it seems to break the same test, by filtering .have\n> entries with \"refs/\" prefix.\n\nOuch, missed that; good catch.  We'll fix that in the next round of the\npatch series.\n\n> > Commit by Josh Triplett and Jamey Sharp.\n> \n> Didn't I ask you to remove this?\n\nYou did ask, we responded (with a citation to a specific recommendation\nfrom the Git list saying to include such a note), and you hadn't said\nanything further about it until now.  If you insist that we remove it,\nfine, we'll remove it.\n\n> It is somewhat irritating having to re-edit the log message (not just this\n> part, but what have been queued were retitled, reflowed and reworded to\n> match the style of other commits in the project better) over and over\n> again.\n\nWe attempted to follow the usual commit message conventions, and none of\nthe feedback we received mentioned anything about any other desired\nchanges.  What changes would you like us to make?\n\n- Josh Triplett\n"},{"id":"169621","messageId":"4DEF931F.70907@xiplink.com","threadId":"27571","inReplyTo":"1307487890-3915-5-git-send-email-jamey@minilop.net","subject":"Re: [PATCHv8 4/4] Add documentation for ref namespaces","fromName":"Marc Branchaud","fromEmail":"marcnarc@xiplink.com","sentAt":"2011-06-08T15:19:59Z","receivedAt":"2011-06-08T15:19:59Z","isPatch":false,"sender":{"key":"marcnarc@xiplink.com","avatar":"https://avatars.githubusercontent.com/u/14980203?v=4"},"body":"On 11-06-07 07:04 PM, Jamey Sharp wrote:\n> From: Josh Triplett<josh@joshtriplett.org>\n>\n> Document the namespace mechanism in a new gitnamespaces(7) page.\n> Reference it from receive-pack and upload-pack.\n>\n> Document the new --namespace option and GIT_NAMESPACE environment\n> variable in git(1), and reference gitnamespaces(7).\n>\n> Add a sample Apache configuration to http-backend(1) to support\n> namespaced repositories, and reference gitnamespaces(7).\n>\n> Commit by Josh Triplett and Jamey Sharp.\n>\n> Signed-off-by: Josh Triplett<josh@joshtriplett.org>\n> Signed-off-by: Jamey Sharp<jamey@minilop.net>\n> ---\n>   Documentation/Makefile                 |    2 +-\n>   Documentation/git-http-backend.txt     |    8 +++\n>   Documentation/git-receive-pack.txt     |    2 +-\n>   Documentation/git-upload-pack.txt      |    4 ++\n>   Documentation/git.txt                  |   13 +++++-\n>   Documentation/gitnamespaces.txt        |   75 ++++++++++++++++++++++++++++++++\n>   contrib/completion/git-completion.bash |    2 +-\n>   7 files changed, 101 insertions(+), 5 deletions(-)\n>   create mode 100644 Documentation/gitnamespaces.txt\n>\n> diff --git a/Documentation/Makefile b/Documentation/Makefile\n> index 36989b7..2004fbe 100644\n> --- a/Documentation/Makefile\n> +++ b/Documentation/Makefile\n> @@ -6,7 +6,7 @@ MAN5_TXT=gitattributes.txt gitignore.txt gitmodules.txt githooks.txt \\\n>   \tgitrepository-layout.txt\n>   MAN7_TXT=gitcli.txt gittutorial.txt gittutorial-2.txt \\\n>   \tgitcvs-migration.txt gitcore-tutorial.txt gitglossary.txt \\\n> -\tgitdiffcore.txt gitrevisions.txt gitworkflows.txt\n> +\tgitdiffcore.txt gitnamespaces.txt gitrevisions.txt gitworkflows.txt\n>\n>   MAN_TXT = $(MAN1_TXT) $(MAN5_TXT) $(MAN7_TXT)\n>   MAN_XML=$(patsubst %.txt,%.xml,$(MAN_TXT))\n> diff --git a/Documentation/git-http-backend.txt b/Documentation/git-http-backend.txt\n> index 277d9e1..f4e0741 100644\n> --- a/Documentation/git-http-backend.txt\n> +++ b/Documentation/git-http-backend.txt\n> @@ -119,6 +119,14 @@ ScriptAliasMatch \\\n>\n>   ScriptAlias /git/ /var/www/cgi-bin/gitweb.cgi/\n>   ----------------------------------------------------------------\n> ++\n> +To serve multiple repositories from different linkgit:gitnamespaces[7] in a\n> +single repository:\n> ++\n> +----------------------------------------------------------------\n> +SetEnvIf Request_URI \"^/git/([^/]*)\" GIT_NAMESPACE=$1\n> +ScriptAliasMatch ^/git/[^/]*(.*) /usr/libexec/git-core/git-http-backend/storage.git$1\n> +----------------------------------------------------------------\n>\n>   Accelerated static Apache 2.x::\n>   \tSimilar to the above, but Apache can be used to return static\n> diff --git a/Documentation/git-receive-pack.txt b/Documentation/git-receive-pack.txt\n> index f34e0ae..3534ba0 100644\n> --- a/Documentation/git-receive-pack.txt\n> +++ b/Documentation/git-receive-pack.txt\n> @@ -149,7 +149,7 @@ if the repository is packed and is served via a dumb transport.\n>\n>   SEE ALSO\n>   --------\n> -linkgit:git-send-pack[1]\n> +linkgit:git-send-pack[1], linkgit:gitnamespaces[7]\n>\n>   GIT\n>   ---\n> diff --git a/Documentation/git-upload-pack.txt b/Documentation/git-upload-pack.txt\n> index 4c0ca9d..61a9a04 100644\n> --- a/Documentation/git-upload-pack.txt\n> +++ b/Documentation/git-upload-pack.txt\n> @@ -33,6 +33,10 @@ OPTIONS\n>   <directory>::\n>   \tThe repository to sync from.\n>\n> +SEE ALSO\n> +--------\n> +linkgit:gitnamespaces[7]\n> +\n>   GIT\n>   ---\n>   Part of the linkgit:git[1] suite\n> diff --git a/Documentation/git.txt b/Documentation/git.txt\n> index 5c45446..4cbf741 100644\n> --- a/Documentation/git.txt\n> +++ b/Documentation/git.txt\n> @@ -10,8 +10,8 @@ SYNOPSIS\n>   --------\n>   [verse]\n>   'git' [--version] [--exec-path[=<path>]] [--html-path] [--man-path] [--info-path]\n> -    [-p|--paginate|--no-pager] [--no-replace-objects]\n> -    [--bare] [--git-dir=<path>] [--work-tree=<path>]\n> +    [-p|--paginate|--no-pager] [--no-replace-objects] [--bare]\n> +    [--git-dir=<path>] [--work-tree=<path>] [--namespace=<name>]\n>       [-c<name>=<value>]\n>       [--help]<command>  [<args>]\n>\n> @@ -325,6 +325,11 @@ help ...`.\n>   \tvariable (see core.worktree in linkgit:git-config[1] for a\n>   \tmore detailed discussion).\n>\n> +--namespace=<path>::\n> +\tSet the git namespace.  See linkgit:gitnamespaces[7] for more\n> +\tdetails.  Equivalent to setting the `GIT_NAMESPACE` environment\n> +\tvariable.\n> +\n>   --bare::\n>   \tTreat the repository as a bare repository.  If GIT_DIR\n>   \tenvironment is not set, it is set to the current working\n> @@ -589,6 +594,10 @@ git so take care if using Cogito etc.\n>   \tThis can also be controlled by the '--work-tree' command line\n>   \toption and the core.worktree configuration variable.\n>\n> +'GIT_NAMESPACE'::\n> +\tSet the git namespace; see linkgit:gitnamespaces[7] for details.\n> +\tThe '--namespace' command-line option also sets this value.\n> +\n\nThanks for this work!\n\nDoes --namespace override GIT_NAMESPACE or extend it in some way?\n\nI also have a question about how to use this feature.  We currently have \na central \"Main.git\" repo where people put their finished work. \nDevelopers clone this repo with, say, \"git clone \nssh://host/git/Main.git\".  Each developer also has a \"personal\" repo \nwhere they can publish work-in-progress branches to share without \ncreating churn in Main.git.  Folks add personal repos as remotes in \ntheir Main.git clone, e.g. \"git remote add Marc \ngit://host/git/personal/marcnarc/Main.git\".\n\nThis is a fairly clean model:  The personal repos on the central host \nare just local clones of the Main.git repo, and fetching from a personal \nrepo only transmits unique refs.  But setting it up was a bit involved, \nand it looks like namespaces would make things even cleaner on the \ncentral host.\n\nBut I think our users will get tripped up by the remote-ext syntax.  The \nabove \"remote add\" command is reasonably straightforward, but with \nnamespaces it would be\n\n\tgit remote add Marc ext::\"git --namespace=personal/marcnarc %s \ngit://host/git/Main.git\"\n\nI can see a lot of opportunity for confusion as users try to type that in.\n\nSo my question is, is there any way we could adopt namespaces without \nteaching our users about remote-ext?  Ideally they would just use the \nsame URLs they already use, or maybe a slight variation thereof (e.g. \ngit://host/git/Main.git/personal/marcnarc).\n\n\t\tM.\n"},{"id":"170056","messageId":"4DF894FD.9040808@gmail.com","threadId":"27571","inReplyTo":"1307487890-3915-1-git-send-email-jamey@minilop.net","subject":"Painless namespaces design","fromName":"Jiang Xin","fromEmail":"worldhello.net@gmail.com","sentAt":"2011-06-15T11:18:21Z","receivedAt":"2011-06-15T11:18:21Z","isPatch":false,"sender":{"key":"worldhello.net@gmail.com","avatar":"https://avatars.githubusercontent.com/u/183860?v=4"},"body":"I like the idea of new namespaces feature from Josh Triplett, Jamey Sharp and others.\nI think it is better to pass namespace through remote.remote-name.namespace variables,\nnot through GIT_NAMESPACE environment.\n\nHost1 has a bare repository with multiple namespaces: foo, bar, and foo/baz.\n\n* master branch of default namespace : refs/heads/master\n* master branch of namespace foo is : refs/namespaces/foo/refs/heads/master\n* master branch of namesapce bar is : refs/namespaces/bar/refs/heads/master\n* master branch of namesapce foo/baz is : refs/namespaces/foo/refs/namespaces/baz/refs/heads/master\n\nUserA clone namespace foo from Host1:\n\n    $ git clone --namespace foo ssh://Host1/path/to/project.git\n\nthe default remote.origin section in  .git/config in userA's working directory:\n\n    [remote \"origin\"]\n        namespace = foo\n        fetch = +refs/heads/*:refs/remotes/origin/*\n        url = ssh://Host1/path/to/project.git\n\nWhen UserA runs `git fetch`, it's just like\n\n    git fetch origin refs/namespaces/foo/refs/heads/*:refs/remotes/origin/*\n\nWhen UserA runs `git push`, it's just like\n\n    git push origin refs/heads/master:refs/namespaces/foo/refs/heads/master\n\nThese can be done on the client side, so I think there is no necessary to hack\ngit-receive-pack and git-upload-pack.\n\nRefs of namespace foo/baz not cloned by UserA by default, so name space baz\ndoes not exists in UserA's new cloned repository.\n\nIf UserA wants to watch some commits on other namespace in project.git in Host1,\nUserA can do this:\n\n    $ git remote add --namespace bar  host1bar  ssh://Host1/path/to/project.git\n\nThen there is a new remote section in .git/config file in UserA's working directory.\n\n    [remote \"host1bar\"]\n        namespace = bar\n        fetch = +refs/heads/*:refs/remotes/host1bar/*\n        url = ssh://Host1/path/to/project.git\n\nWhen UserA runs git fetch host1bar, then:\n\n    refs/namespaces/bar/refs/heads/master [remote] => refs/remotes/host1bar/master [local]\n\nWhen UserA execute `git ls-remote host1bar`, only show references under  refs/namespaces/bar/refs/\nof remote Host1.\n\nTo mirror all namespaces of project.git in Host1, run this command:\n\n    git clone --mirror ssh://Host1/path/to/project.git\n\n\nI believe this design is painless for both git server and client side tools.\n\nTopgit is one of my daily use tools. Without namespaces feature, I have to create new repositories\nto track develop status. It is because the develop status of a topgit controlled repository\nis not through one certain branch, but through all the topic branches (refs/heads/t/*) and their\nbase branches (refs/top-bases/t/*).\n\nI'd like to see namespaces feature becomes one part of git.\n\n\n于 11-6-8 上午7:04, Jamey Sharp 写道:\n> This series adds support for dividing the refs of a single repository\n> into multiple namespaces, each of which can have its own branches, tags,\n> and HEAD. Git can expose each namespace as an independent repository to\n> pull from and push to, while sharing the object store, and exposing all\n> the refs to operations such as git-gc.\n> \n\n-- \nJiang Xin\n"},{"id":"170065","messageId":"BANLkTiktjki43wCX5d2SV+tKjp_fqmGznw@mail.gmail.com","threadId":"27571","inReplyTo":"4DF894FD.9040808@gmail.com","subject":"Re: Painless namespaces design","fromName":"Shawn Pearce","fromEmail":"spearce@spearce.org","sentAt":"2011-06-15T14:00:00Z","receivedAt":"2011-06-15T14:00:00Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"2011/6/15 Jiang Xin <worldhello.net@gmail.com>:\n> I like the idea of new namespaces feature from Josh Triplett, Jamey Sharp and others.\n> I think it is better to pass namespace through remote.remote-name.namespace variables,\n> not through GIT_NAMESPACE environment.\n...\n>    [remote \"origin\"]\n>        namespace = foo\n>        fetch = +refs/heads/*:refs/remotes/origin/*\n>        url = ssh://Host1/path/to/project.git\n>\n> When UserA runs `git fetch`, it's just like\n>\n>    git fetch origin refs/namespaces/foo/refs/heads/*:refs/remotes/origin/*\n\nThis is less than ideal. Part of the rationale for the GIT_NAMESPACE\nenvironment variable is to allow the server to restrict the namespace\nand only show that specific slice of the repository's refs to the\nclient. It allows a server administrator to put several logical\nrepositories into a single repository, and have clients be oblivious\nto this fact.\n\n-- \nShawn.\n"}]}