git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCHv4 {6,7}/7] submodule update: allow '.' for branch value
@ 2016-08-03 20:44 Stefan Beller
  2016-08-03 20:44 ` [PATCHv4 6/7] submodule--helper: add remote-branch helper Stefan Beller
  2016-08-03 20:44 ` [PATCHv4 6/7] submodule update: allow '.' for branch value Stefan Beller
  0 siblings, 2 replies; 6+ messages in thread
From: Stefan Beller @ 2016-08-03 20:44 UTC (permalink / raw)
  To: gitster; +Cc: git, Jens.Lehmann, apenwarr, jrnieder, Stefan Beller

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


^ permalink raw reply related	[flat|nested] 6+ messages in thread

end of thread, other threads:[~2016-08-03 23:22 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-08-03 20:44 [PATCHv4 {6,7}/7] submodule update: allow '.' for branch value Stefan Beller
2016-08-03 20:44 ` [PATCHv4 6/7] submodule--helper: add remote-branch helper Stefan Beller
2016-08-03 23:13   ` Junio C Hamano
2016-08-03 23:22     ` Stefan Beller
2016-08-03 20:44 ` [PATCHv4 6/7] submodule update: allow '.' for branch value Stefan Beller
2016-08-03 23:14   ` Junio C Hamano

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).