git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 0/2] Port `git submodule init` from shell to C
@ 2016-01-15 23:37 Stefan Beller
  2016-01-15 23:37 ` [PATCH 1/2] submodule: Port resolve_relative_url " Stefan Beller
                   ` (2 more replies)
  0 siblings, 3 replies; 31+ messages in thread
From: Stefan Beller @ 2016-01-15 23:37 UTC (permalink / raw)
  To: git; +Cc: gitster, j6t, sunshine, Jens.Lehmann, Stefan Beller

The first patch is a reroll of "[PATCH] submodule: Port resolve_relative_url
from shell to C" and the second patch is new.

This applies on top of origin/sb/submodule-parallel-update, as it makes use
of the recorded update strategy in the submodule configuration.

Thanks,
Stefan

Stefan Beller (2):
  submodule: Port resolve_relative_url from shell to C
  submodule: Port init from shell to C

 builtin/submodule--helper.c | 330 +++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            | 118 +---------------
 t/t0060-path-utils.sh       |  42 ++++++
 3 files changed, 370 insertions(+), 120 deletions(-)

-- 
2.7.0.rc0.37.gb4a0220.dirty

^ permalink raw reply	[flat|nested] 31+ messages in thread
* [PATCH 0/2] Port `git submodule init` from shell to C
@ 2016-02-12 23:39 Stefan Beller
  0 siblings, 0 replies; 31+ messages in thread
From: Stefan Beller @ 2016-02-12 23:39 UTC (permalink / raw)
  To: git, gitster, jrnieder, Jens.Lehmann; +Cc: Stefan Beller

This applies on top of the just sent series which is going to replace
sb/submodule-parallel-update, replacing sb/submodule-init.

* Using enums for the submodule update strategy now.

Thanks,
Stefan

Stefan Beller (2):
  submodule: port resolve_relative_url from shell to C
  submodule: port init from shell to C

 builtin/submodule--helper.c | 315 +++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            | 118 +----------------
 submodule.c                 |  21 +++
 submodule.h                 |   1 +
 t/t0060-path-utils.sh       |  42 ++++++
 5 files changed, 382 insertions(+), 115 deletions(-)

-- 
2.7.1.292.g18a4ced.dirty

^ permalink raw reply	[flat|nested] 31+ messages in thread
* [PATCH 0/2] Port `git submodule init` from shell to C
@ 2016-03-15  0:15 Stefan Beller
  0 siblings, 0 replies; 31+ messages in thread
From: Stefan Beller @ 2016-03-15  0:15 UTC (permalink / raw)
  To: git; +Cc: gitster, jrnieder, j6t, pclouds, Stefan Beller

This applies on top of origin/sb/submodule-parallel-update.
By having the `init` functionality in C, we can reference it easier
from other parts in the code.

Thanks for the reviews a long time ago!

Junio,
  I fixed the NEEDSWORK comment for relative_url
  and thought about the memory allocation
Duy,
  I fixed the i18n issues introduced.
Johannes,
  I took $PWD instead of absolute paths. According to your last message, this
  may still break on Windows for 
test_submodule_relative_url "(null)" "$PWD/home2/../remote" "../bundle1" "$PWD/home2/../bundle1"

There are however no further tests starting with /.

Thanks,
Stefan

Stefan Beller (2):
  submodule: port resolve_relative_url from shell to C
  submodule: port init from shell to C

 builtin/submodule--helper.c | 317 +++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            | 118 +----------------
 submodule.c                 |  21 +++
 submodule.h                 |   1 +
 t/t0060-path-utils.sh       |  43 ++++++
 5 files changed, 385 insertions(+), 115 deletions(-)

Diff to origin/sb/submodule-init:

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index 213af2e..d942463 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -22,7 +22,7 @@ static char *get_default_remote(void)
 	const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, &flag);
 
 	if (!refname)
-		die("No such ref: HEAD");
+		die(_("No such ref: %s"), "HEAD");
 
 	/* detached HEAD */
 	if (!strcmp(refname, "HEAD"))
@@ -94,12 +94,14 @@ static int chop_last_dir(char **remoteurl, int is_relative)
  * the superproject working tree otherwise.
  *
  * NEEDSWORK: This works incorrectly on the domain and protocol part.
- * remote_url      url              outcome          correct
- * http://a.com/b  ../c             http://a.com/c   yes
- * http://a.com/b  ../../c          http://c         no (domain should be kept)
- * http://a.com/b  ../../../c       http:/c          no
- * http://a.com/b  ../../../../c    http:c           no
- * http://a.com/b  ../../../../../c    .:c           no
+ * remote_url      url              outcome          expectation
+ * http://a.com/b  ../c             http://a.com/c   as is
+ * http://a.com/b  ../../c          http://c         error out
+ * http://a.com/b  ../../../c       http:/c          error out
+ * http://a.com/b  ../../../../c    http:c           error out
+ * http://a.com/b  ../../../../../c    .:c           error out
+ * NEEDSWORK: Given how chop_last_dir() works, this function is broken
+ * when a local part has a colon in its path component, too.
  */
 static char *relative_url(const char *remote_url,
 				const char *url,
@@ -146,6 +148,7 @@ static char *relative_url(const char *remote_url,
 	}
 	strbuf_reset(&sb);
 	strbuf_addf(&sb, "%s%s%s", remoteurl, colonsep ? ":" : "/", url);
+	free(remoteurl);
 
 	if (starts_with_dot_slash(sb.buf))
 		out = xstrdup(sb.buf + 2);
@@ -153,7 +156,6 @@ static char *relative_url(const char *remote_url,
 		out = xstrdup(sb.buf);
 	strbuf_reset(&sb);
 
-	free(remoteurl);
 	if (!up_path || !is_relative)
 		return out;
 
@@ -299,7 +301,7 @@ static int module_init(int argc, const char **argv, const char *prefix)
 		OPT_STRING(0, "prefix", &prefix,
 			   N_("path"),
 			   N_("alternative anchor for relative paths")),
-		OPT__QUIET(&quiet, "Suppress output for initialzing a submodule"),
+		OPT__QUIET(&quiet, N_("Suppress output for initializing a submodule")),
 		OPT_END()
 	};
 
diff --git a/t/t0060-path-utils.sh b/t/t0060-path-utils.sh
index 8a1579c..579c1fa 100755
--- a/t/t0060-path-utils.sh
+++ b/t/t0060-path-utils.sh
@@ -293,35 +293,36 @@ test_git_path GIT_COMMON_DIR=bar config                   bar/config
 test_git_path GIT_COMMON_DIR=bar packed-refs              bar/packed-refs
 test_git_path GIT_COMMON_DIR=bar shallow                  bar/shallow
 
-test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
+test_submodule_relative_url "../" "../foo" "../submodule" "../../submodule"
+test_submodule_relative_url "../" "../foo/bar" "../submodule" "../../foo/submodule"
+test_submodule_relative_url "../" "../foo/submodule" "../submodule" "../../foo/submodule"
+test_submodule_relative_url "../" "./foo" "../submodule" "../submodule"
+test_submodule_relative_url "../" "./foo/bar" "../submodule" "../foo/submodule"
 test_submodule_relative_url "../../../" "../foo/bar" "../sub/a/b/c" "../../../../foo/sub/a/b/c"
+test_submodule_relative_url "../" "$PWD/addtest" "../repo" "$PWD/repo"
+test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
+test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
+
+test_submodule_relative_url "(null)" "../foo/bar" "../sub/a/b/c" "../foo/sub/a/b/c"
 test_submodule_relative_url "(null)" "../foo/bar" "../submodule" "../foo/submodule"
-test_submodule_relative_url "../" "../foo/bar" "../submodule" "../../foo/submodule"
 test_submodule_relative_url "(null)" "../foo/submodule" "../submodule" "../foo/submodule"
-test_submodule_relative_url "../" "../foo/submodule" "../submodule" "../../foo/submodule"
 test_submodule_relative_url "(null)" "../foo" "../submodule" "../submodule"
-test_submodule_relative_url "../" "../foo" "../submodule" "../../submodule"
 test_submodule_relative_url "(null)" "./foo/bar" "../submodule" "foo/submodule"
-test_submodule_relative_url "../" "./foo/bar" "../submodule" "../foo/submodule"
 test_submodule_relative_url "(null)" "./foo" "../submodule" "submodule"
-test_submodule_relative_url "../" "./foo" "../submodule" "../submodule"
 test_submodule_relative_url "(null)" "//somewhere else/repo" "../subrepo" "//somewhere else/subrepo"
-test_submodule_relative_url "(null)" "/u//trash directory.t7406-submodule-update/subsuper_update_r" "../subsubsuper_update_r" "/u//trash directory.t7406-submodule-update/subsubsuper_update_r"
-test_submodule_relative_url "(null)" "/u//trash directory.t7406-submodule-update/super_update_r2" "../subsuper_update_r" "/u//trash directory.t7406-submodule-update/subsuper_update_r"
-test_submodule_relative_url "(null)" "/u/trash directory.t3600-rm/." "../." "/u/trash directory.t3600-rm/."
-test_submodule_relative_url "(null)" "/u/trash directory.t3600-rm" "./." "/u/trash directory.t3600-rm/."
-test_submodule_relative_url "(null)" "/u/trash directory.t7400-submodule-basic/addtest" "../repo" "/u/trash directory.t7400-submodule-basic/repo"
-test_submodule_relative_url "../" "/u/trash directory.t7400-submodule-basic/addtest" "../repo" "/u/trash directory.t7400-submodule-basic/repo"
-test_submodule_relative_url "(null)" "/u/trash directory.t7400-submodule-basic" "./å äö" "/u/trash directory.t7400-submodule-basic/å äö"
-test_submodule_relative_url "(null)" "/u/trash directory.t7403-submodule-sync/." "../submodule" "/u/trash directory.t7403-submodule-sync/submodule"
-test_submodule_relative_url "(null)" "/u/trash directory.t7407-submodule-foreach/submodule" "../submodule" "/u/trash directory.t7407-submodule-foreach/submodule"
-test_submodule_relative_url "(null)" "/u/trash directory.t7409-submodule-detached-worktree/home2/../remote" "../bundle1" "/u/trash directory.t7409-submodule-detached-worktree/home2/../bundle1"
-test_submodule_relative_url "(null)" "/u/trash directory.t7613-merge-submodule/submodule_update_repo" "./." "/u/trash directory.t7613-merge-submodule/submodule_update_repo/."
+test_submodule_relative_url "(null)" "$PWD/subsuper_update_r" "../subsubsuper_update_r" "$PWD/subsubsuper_update_r"
+test_submodule_relative_url "(null)" "$PWD/super_update_r2" "../subsuper_update_r" "$PWD/subsuper_update_r"
+test_submodule_relative_url "(null)" "$PWD/." "../." "$PWD/."
+test_submodule_relative_url "(null)" "$PWD" "./." "$PWD/."
+test_submodule_relative_url "(null)" "$PWD/addtest" "../repo" "$PWD/repo"
+test_submodule_relative_url "(null)" "$PWD" "./å äö" "$PWD/å äö"
+test_submodule_relative_url "(null)" "$PWD/." "../submodule" "$PWD/submodule"
+test_submodule_relative_url "(null)" "$PWD/submodule" "../submodule" "$PWD/submodule"
+test_submodule_relative_url "(null)" "$PWD/home2/../remote" "../bundle1" "$PWD/home2/../bundle1"
+test_submodule_relative_url "(null)" "$PWD/submodule_update_repo" "./." "$PWD/submodule_update_repo/."
 test_submodule_relative_url "(null)" "file:///tmp/repo" "../subrepo" "file:///tmp/subrepo"
 test_submodule_relative_url "(null)" "foo/bar" "../submodule" "foo/submodule"
-test_submodule_relative_url "../" "foo/bar" "../submodule" "../foo/submodule"
 test_submodule_relative_url "(null)" "foo" "../submodule" "submodule"
-test_submodule_relative_url "../" "foo" "../submodule" "../submodule"
 test_submodule_relative_url "(null)" "helper:://hostname/repo" "../subrepo" "helper:://hostname/subrepo"
 test_submodule_relative_url "(null)" "ssh://hostname/repo" "../subrepo" "ssh://hostname/subrepo"
 test_submodule_relative_url "(null)" "ssh://hostname:22/repo" "../subrepo" "ssh://hostname:22/subrepo"


-- 
2.7.0.rc0.46.g8f16ed4.dirty

^ permalink raw reply related	[flat|nested] 31+ messages in thread
* [PATCH 0/2] Port `git submodule init` from shell to C
@ 2016-04-13  0:18 Stefan Beller
  2016-04-13  1:04 ` Junio C Hamano
  0 siblings, 1 reply; 31+ messages in thread
From: Stefan Beller @ 2016-04-13  0:18 UTC (permalink / raw)
  To: git; +Cc: gitster, pclouds, j6t, Stefan Beller

This is a resend of origin/sb/submodule-init (and it still applies on 
top of submodule-parallel-update)

I squashed a change which Michael Haggerty proposed in one of the
large cleanup series preparing for the new refs backend. (18/21)
As that is the only fix in that series touching submodules,
picking it up here would untangle sb/submodule-init from that series.

Thanks,
Stefan

diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
index d942463..3078790 100644
--- a/builtin/submodule--helper.c
+++ b/builtin/submodule--helper.c
@@ -17,9 +17,8 @@ static char *get_default_remote(void)
 {
        char *dest = NULL, *ret;
        unsigned char sha1[20];
-       int flag = 0;
        struct strbuf sb = STRBUF_INIT;
-       const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, &flag);
+       const char *refname = resolve_ref_unsafe("HEAD", 0, sha1, NULL);
 
        if (!refname)
                die(_("No such ref: %s"), "HEAD");


Stefan Beller (2):
  submodule: port resolve_relative_url from shell to C
  submodule: port init from shell to C

 builtin/submodule--helper.c | 316 +++++++++++++++++++++++++++++++++++++++++++-
 git-submodule.sh            | 118 +----------------
 submodule.c                 |  21 +++
 submodule.h                 |   1 +
 t/t0060-path-utils.sh       |  43 ++++++
 5 files changed, 384 insertions(+), 115 deletions(-)

-- 
2.5.0.264.gc776916.dirty

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

end of thread, other threads:[~2016-04-13  1:41 UTC | newest]

Thread overview: 31+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2016-01-15 23:37 [PATCH 0/2] Port `git submodule init` from shell to C Stefan Beller
2016-01-15 23:37 ` [PATCH 1/2] submodule: Port resolve_relative_url " Stefan Beller
2016-01-15 23:37 ` [PATCH 2/2] submodule: Port init " Stefan Beller
2016-01-19 23:17 ` [PATCH 0/2] Port `git submodule init` " Junio C Hamano
2016-01-20  2:03   ` [PATCHv2 " Stefan Beller
2016-01-20  2:03     ` [PATCHv2 1/2] submodule: port resolve_relative_url " Stefan Beller
2016-01-22 19:03       ` Johannes Sixt
2016-01-22 20:23         ` Stefan Beller
2016-01-20  2:03     ` [PATCHv2 2/2] submodule: port init " Stefan Beller
2016-01-20  3:24       ` [PATCHv3 " Stefan Beller
2016-01-20 21:01         ` Junio C Hamano
2016-01-20 22:33           ` Stefan Beller
2016-01-20 23:04             ` Junio C Hamano
2016-01-21 23:18         ` [PATCHv4 " Stefan Beller
2016-01-22 22:30           ` Junio C Hamano
2016-01-22 22:32             ` Stefan Beller
2016-01-22 23:32             ` [PATCHv3 0/2] Port `git submodule init` " Stefan Beller
2016-01-25 22:46               ` Junio C Hamano
2016-01-28  2:30                 ` [PATCHv4 " Stefan Beller
2016-01-28  2:30                   ` [PATCHv4 1/2] submodule: port resolve_relative_url " Stefan Beller
2016-01-28 22:03                     ` Junio C Hamano
2016-01-28 22:11                       ` Stefan Beller
2016-01-28  2:30                   ` [PATCHv4 2/2] submodule: port init " Stefan Beller
2016-02-27  8:30                     ` Duy Nguyen
2016-01-22 23:32             ` [PATCHv3 1/2] submodule: port resolve_relative_url " Stefan Beller
2016-01-22 23:32             ` [PATCHv3 2/2] submodule: port init " Stefan Beller
  -- strict thread matches above, loose matches on Subject: below --
2016-02-12 23:39 [PATCH 0/2] Port `git submodule init` " Stefan Beller
2016-03-15  0:15 Stefan Beller
2016-04-13  0:18 Stefan Beller
2016-04-13  1:04 ` Junio C Hamano
2016-04-13  1:41   ` 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).