summaryrefslogtreecommitdiff
path: root/submodule.c
diff options
context:
space:
mode:
authorStefan Beller <sbeller@google.com>2017-03-14 21:46:36 (GMT)
committerJunio C Hamano <gitster@pobox.com>2017-03-16 21:07:16 (GMT)
commit202275b96b6c3ffc2c380cfb017e4f6a0dd6bddb (patch)
tree4d4a30838f8bdbe245d50e1bf1cbb3ce916c1a8a /submodule.c
parent6cd5757c898d845747d9886c71cb5884b56e9702 (diff)
downloadgit-202275b96b6c3ffc2c380cfb017e4f6a0dd6bddb.zip
git-202275b96b6c3ffc2c380cfb017e4f6a0dd6bddb.tar.gz
git-202275b96b6c3ffc2c380cfb017e4f6a0dd6bddb.tar.bz2
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: Stefan Beller <sbeller@google.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'submodule.c')
-rw-r--r--submodule.c16
1 files changed, 10 insertions, 6 deletions
diff --git a/submodule.c b/submodule.c
index 0b2596e..d8efbdb 100644
--- a/submodule.c
+++ b/submodule.c
@@ -1239,6 +1239,14 @@ out:
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,
struct commit *a, struct commit *b)
{
@@ -1438,11 +1446,8 @@ static void relocate_single_git_dir_into_superproject(const char *prefix,
die(_("could not create directory '%s'"), 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"),
- prefix ? prefix : "", path,
+ get_super_prefix_or_empty(), 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,
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
die("BUG: we don't know how to pass the flags down?");
- if (get_super_prefix())
- strbuf_addstr(&sb, get_super_prefix());
+ strbuf_addstr(&sb, get_super_prefix_or_empty());
strbuf_addstr(&sb, path);
strbuf_addch(&sb, '/');