diff options
author | Junio C Hamano <gitster@pobox.com> | 2013-04-22 11:12:40 -0700 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2013-04-22 11:12:40 -0700 |
commit | fd6d822e847f88d016cb608d6b76a3914f372c66 (patch) | |
tree | 36d276214d5506687eaed0198c8367b9a0fd271d /builtin | |
parent | 561954bfa1c1a1c5a76ca59001da331c73c5c141 (diff) | |
parent | b552b56df2c13885a67ca9ec9f76c21d3b7e2cde (diff) | |
download | git-fd6d822e847f88d016cb608d6b76a3914f372c66.tar.gz |
Merge branch 'as/clone-reference-with-gitfile'
"git clone" did not work if a repository pointed at by the
"--reference" option is a gitfile that points at another place.
* as/clone-reference-with-gitfile:
clone: Allow repo using gitfile as a reference
clone: Fix error message for reference repository
Diffstat (limited to 'builtin')
-rw-r--r-- | builtin/clone.c | 16 |
1 files changed, 13 insertions, 3 deletions
diff --git a/builtin/clone.c b/builtin/clone.c index f9c380eb6c..58fee9874f 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -232,16 +232,26 @@ static void strip_trailing_slashes(char *dir) static int add_one_reference(struct string_list_item *item, void *cb_data) { char *ref_git; + const char *repo; struct strbuf alternate = STRBUF_INIT; - /* Beware: real_path() and mkpath() return static buffer */ + /* Beware: read_gitfile(), real_path() and mkpath() return static buffer */ ref_git = xstrdup(real_path(item->string)); - if (is_directory(mkpath("%s/.git/objects", ref_git))) { + + repo = read_gitfile(ref_git); + if (!repo) + repo = read_gitfile(mkpath("%s/.git", ref_git)); + if (repo) { + free(ref_git); + ref_git = xstrdup(repo); + } + + if (!repo && is_directory(mkpath("%s/.git/objects", ref_git))) { char *ref_git_git = mkpathdup("%s/.git", ref_git); free(ref_git); ref_git = ref_git_git; } else if (!is_directory(mkpath("%s/objects", ref_git))) - die(_("reference repository '%s' is not a local directory."), + die(_("reference repository '%s' is not a local repository."), item->string); strbuf_addf(&alternate, "%s/objects", ref_git); |