[PATCHv4 {6,7}/7] submodule update: allow '.' for branch value

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



This replaces the last two commits of  sb/submodule-update-dot-branch.

Thanks Jeff for pointing out the possible segfault.
In the last commit I removed commented code in the test.

Thanks,
Stefan

diff to sb/submodule-update-dot-branch:
diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index ae88eff..f1acc4d 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -906,6 +906,9 @@ static const char *remote_submodule_branch(const char *path)
        git_config(submodule_config, NULL);
 
        sub = submodule_from_path(null_sha1, path);
+       if (!sub)
+               return NULL;
+
        if (!sub->branch)
                return "master";
 
@@ -933,11 +936,16 @@ static const char *remote_submodule_branch(const char *path)
 static int resolve_remote_submodule_branch(int argc, const char **argv,
                const char *prefix)
 {
+       const char *ret;
        struct strbuf sb = STRBUF_INIT;
        if (argc != 2)
                die("submodule--helper remote-branch takes exactly one arguments, got %d", argc);
 
-       printf("%s", remote_submodule_branch(argv[1]));
+       ret = remote_submodule_branch(argv[1]);
+       if (!ret)
+               die("submodule %s doesn't exist", argv[1]);
+
+       printf("%s", ret);
        strbuf_release(&sb);
        return 0;
 }
diff --git a/t/t7406-submodule-update.sh b/t/t7406-submodule-update.sh
index 1c4c1f2..d7983cf 100755
--- a/t/t7406-submodule-update.sh
+++ b/t/t7406-submodule-update.sh
@@ -238,7 +238,6 @@ test_expect_success 'submodule update --remote should fetch upstream changes wit
                test_cmp expect actual &&
                git checkout master &&
                git branch -d test-branch &&
-               #~ git -C ../submodule branch -d test-branch &&
                git reset --hard HEAD^
        )
 '

Stefan Beller (2):
  submodule--helper: add remote-branch helper
  submodule update: allow '.' for branch value

 builtin/submodule--helper.c | 54 ++++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            |  2 +-
 t/t7406-submodule-update.sh | 35 ++++++++++++++++++++++++++++-
 3 files changed, 88 insertions(+), 3 deletions(-)

-- 
2.9.2.524.gdbd1860

--
To unsubscribe from this list: send the line "unsubscribe git" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html



[Index of Archives]     [Linux Kernel Development]     [Gcc Help]     [IETF Annouce]     [DCCP]     [Netdev]     [Networking]     [Security]     [V4L]     [Bugtraq]     [Yosemite]     [MIPS Linux]     [ARM Linux]     [Linux Security]     [Linux RAID]     [Linux SCSI]     [Fedora Users]