提交 202275b9 编写于 作者: S Stefan Beller 提交者: Junio C Hamano

submodule.c: get_super_prefix_or_empty

In a later patch we need to use the super_prefix, and
in case it is NULL we can just assume it is empty.
Create a helper function for this.

We already have some use cases for this helper function,
convert them, too.
Signed-off-by: NStefan Beller <sbeller@google.com>
Signed-off-by: NJunio C Hamano <gitster@pobox.com>
上级 6cd5757c
...@@ -1239,6 +1239,14 @@ int bad_to_remove_submodule(const char *path, unsigned flags) ...@@ -1239,6 +1239,14 @@ int bad_to_remove_submodule(const char *path, unsigned flags)
return ret; return ret;
} }
static const char *get_super_prefix_or_empty(void)
{
const char *s = get_super_prefix();
if (!s)
s = "";
return s;
}
static int find_first_merges(struct object_array *result, const char *path, static int find_first_merges(struct object_array *result, const char *path,
struct commit *a, struct commit *b) struct commit *a, struct commit *b)
{ {
...@@ -1438,11 +1446,8 @@ static void relocate_single_git_dir_into_superproject(const char *prefix, ...@@ -1438,11 +1446,8 @@ static void relocate_single_git_dir_into_superproject(const char *prefix,
die(_("could not create directory '%s'"), new_git_dir); die(_("could not create directory '%s'"), new_git_dir);
real_new_git_dir = real_pathdup(new_git_dir); real_new_git_dir = real_pathdup(new_git_dir);
if (!prefix)
prefix = get_super_prefix();
fprintf(stderr, _("Migrating git directory of '%s%s' from\n'%s' to\n'%s'\n"), fprintf(stderr, _("Migrating git directory of '%s%s' from\n'%s' to\n'%s'\n"),
prefix ? prefix : "", path, get_super_prefix_or_empty(), path,
real_old_git_dir, real_new_git_dir); real_old_git_dir, real_new_git_dir);
relocate_gitdir(path, real_old_git_dir, real_new_git_dir); relocate_gitdir(path, real_old_git_dir, real_new_git_dir);
...@@ -1513,8 +1518,7 @@ void absorb_git_dir_into_superproject(const char *prefix, ...@@ -1513,8 +1518,7 @@ void absorb_git_dir_into_superproject(const char *prefix,
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES) if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
die("BUG: we don't know how to pass the flags down?"); die("BUG: we don't know how to pass the flags down?");
if (get_super_prefix()) strbuf_addstr(&sb, get_super_prefix_or_empty());
strbuf_addstr(&sb, get_super_prefix());
strbuf_addstr(&sb, path); strbuf_addstr(&sb, path);
strbuf_addch(&sb, '/'); strbuf_addch(&sb, '/');
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册