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>
Stefan Beller committed
Mar 14, 2017 at 14:46 UTC
202275b96b6c3ffc2c380cfb017e4f6a0dd6bddb
1 file changed
+10
-6
submodule.c
+10
-6
@@ -1239,6 +1239,14 @@ out:
1239
return ret;
1240
}
1241
1242
+static const char *get_super_prefix_or_empty(void)
1243
+{
1244
+ const char *s = get_super_prefix();
1245
+ if (!s)
1246
+ s = "";
1247
+ return s;
1248
+}
1249
+
1250
static int find_first_merges(struct object_array *result, const char *path,
1251
struct commit *a, struct commit *b)
1252
{
@@ -1438,11 +1446,8 @@ static void relocate_single_git_dir_into_superproject(const char *prefix,
1446
die(_("could not create directory '%s'"), new_git_dir);
1447
real_new_git_dir = real_pathdup(new_git_dir);
1448
1441
- if (!prefix)
1442
- prefix = get_super_prefix();
1443
-
1449
fprintf(stderr, _("Migrating git directory of '%s%s' from\n'%s' to\n'%s'\n"),
1445
- prefix ? prefix : "", path,
1450
+ get_super_prefix_or_empty(), path,
1451
real_old_git_dir, real_new_git_dir);
1452
1453
relocate_gitdir(path, real_old_git_dir, real_new_git_dir);
@@ -1513,8 +1518,7 @@ void absorb_git_dir_into_superproject(const char *prefix,
1518
if (flags & ~ABSORB_GITDIR_RECURSE_SUBMODULES)
1519
die("BUG: we don't know how to pass the flags down?");
1520
1516
- if (get_super_prefix())
1517
- strbuf_addstr(&sb, get_super_prefix());
1521
+ strbuf_addstr(&sb, get_super_prefix_or_empty());
1522
strbuf_addstr(&sb, path);
1523
strbuf_addch(&sb, '/');
1524