git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Stefan Beller <sbeller@google.com>
To: git@vger.kernel.org
Cc: Stefan Beller <sbeller@google.com>
Subject: [PATCH v2 0/6] git-submodule.sh: convert part of cmd_update to C
Date: Mon, 16 Jul 2018 17:26:48 -0700	[thread overview]
Message-ID: <20180717002654.120375-1-sbeller@google.com> (raw)

v2:
addressed review comments, renaming the struct, improving the commit message.

v1:
https://public-inbox.org/git/20180712194754.71979-1-sbeller@google.com/
I thought about writing it all in one go, but the series got too large,
so let's chew one bite at a time.

Thanks,
Stefan

Stefan Beller (6):
  git-submodule.sh: align error reporting for update mode to use path
  git-submodule.sh: rename unused variables
  builtin/submodule--helper: factor out submodule updating
  builtin/submodule--helper: store update_clone information in a struct
  builtin/submodule--helper: factor out method to update a single
    submodule
  submodule--helper: introduce new update-module-mode helper

 builtin/submodule--helper.c | 152 ++++++++++++++++++++++++++++--------
 git-submodule.sh            |  22 +-----
 2 files changed, 122 insertions(+), 52 deletions(-)

-- 
2.18.0.203.gfac676dfb9-goog

1:  d4e1ec45740 ! 1:  bbc8697a8ca git-submodule.sh: align error reporting for update mode to use path
    @@ -6,7 +6,6 @@
         on its path, so let's do that for invalid update modes, too.
     
         Signed-off-by: Stefan Beller <sbeller@google.com>
    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
     diff --git a/git-submodule.sh b/git-submodule.sh
     --- a/git-submodule.sh
2:  9c5ec3fccea ! 2:  7e26af17578 git-submodule.sh: rename unused variables
    @@ -14,8 +14,12 @@
         using its own function starting in 48308681b07 (git submodule update:
         have a dedicated helper for cloning, 2016-02-29), its removal was missed.
     
    +    A later patch in this series also touches the communication between
    +    the submodule helper and git-submodule.sh, but let's have this as
    +    a preparatory patch, as it eases the next patch, which stores the
    +    raw data instead of the line printed for this communication.
    +
         Signed-off-by: Stefan Beller <sbeller@google.com>
    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
     diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
     --- a/builtin/submodule--helper.c
3:  a3fb4e5539f ! 3:  3e8d22b0c70 builtin/submodule--helper: factor out submodule updating
    @@ -7,7 +7,6 @@
         most of it is still in git-submodule.sh.
     
         Signed-off-by: Stefan Beller <sbeller@google.com>
    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
     diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
     --- a/builtin/submodule--helper.c
4:  e680684139d ! 4:  5e0a39015df builtin/submodule--helper: store update_clone information in a struct
    @@ -11,7 +11,6 @@
         struct.
     
         Signed-off-by: Stefan Beller <sbeller@google.com>
    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
     diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
     --- a/builtin/submodule--helper.c
    @@ -20,7 +19,7 @@
      	return 0;
      }
      
    -+struct submodule_update_clone_information {
    ++struct update_clone_data {
     +	const struct submodule *sub;
     +	struct object_id oid;
     +	unsigned just_cloned;
    @@ -36,8 +35,8 @@
     -	/* Machine-readable status lines to be consumed by git-submodule.sh */
     -	struct string_list projectlines;
     +	/* to be consumed by git-submodule.sh */
    -+	struct submodule_update_clone_information *submodule_lines;
    -+	int submodule_lines_nr; int submodule_lines_alloc;
    ++	struct update_clone_data *update_clone;
    ++	int update_clone_nr; int update_clone_alloc;
      
      	/* If we want to stop as fast as possible and return an error */
      	unsigned quickstop : 1;
    @@ -58,12 +57,12 @@
     -	strbuf_addf(&sb, "dummy %s %d\t%s\n",
     -		    oid_to_hex(&ce->oid), needs_cloning, ce->name);
     -	string_list_append(&suc->projectlines, sb.buf);
    -+	ALLOC_GROW(suc->submodule_lines, suc->submodule_lines_nr + 1,
    -+					 suc->submodule_lines_alloc);
    -+	oidcpy(&suc->submodule_lines[suc->submodule_lines_nr].oid, &ce->oid);
    -+	suc->submodule_lines[suc->submodule_lines_nr].just_cloned = needs_cloning;
    -+	suc->submodule_lines[suc->submodule_lines_nr].sub = sub;
    -+	suc->submodule_lines_nr++;
    ++	ALLOC_GROW(suc->update_clone, suc->update_clone_nr + 1,
    ++		   suc->update_clone_alloc);
    ++	oidcpy(&suc->update_clone[suc->update_clone_nr].oid, &ce->oid);
    ++	suc->update_clone[suc->update_clone_nr].just_cloned = needs_cloning;
    ++	suc->update_clone[suc->update_clone_nr].sub = sub;
    ++	suc->update_clone_nr++;
      
      	if (!needs_cloning)
      		goto cleanup;
    @@ -83,11 +82,11 @@
      
     -	for_each_string_list_item(item, &suc->projectlines)
     -		fprintf(stdout, "%s", item->string);
    -+	for (i = 0; i < suc->submodule_lines_nr; i++) {
    ++	for (i = 0; i < suc->update_clone_nr; i++) {
     +		strbuf_addf(&sb, "dummy %s %d\t%s\n",
    -+			oid_to_hex(&suc->submodule_lines[i].oid),
    -+			suc->submodule_lines[i].just_cloned,
    -+			suc->submodule_lines[i].sub->path);
    ++			oid_to_hex(&suc->update_clone[i].oid),
    ++			suc->update_clone[i].just_cloned,
    ++			suc->update_clone[i].sub->path);
     +		fprintf(stdout, "%s", sb.buf);
     +		strbuf_reset(&sb);
     +	}
5:  95409e47b0d ! 5:  ecee68506eb builtin/submodule--helper: factor out method to update a single submodule
    @@ -5,7 +5,6 @@
         In a later patch we'll find this method handy.
     
         Signed-off-by: Stefan Beller <sbeller@google.com>
    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
     diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
     --- a/builtin/submodule--helper.c
    @@ -14,12 +13,12 @@
      	return 0;
      }
      
    -+static void update_submodule(struct submodule_update_clone_information *suci)
    ++static void update_submodule(struct update_clone_data *ucd)
     +{
     +	fprintf(stdout, "dummy %s %d\t%s\n",
    -+		oid_to_hex(&suci->oid),
    -+		suci->just_cloned,
    -+		suci->sub->path);
    ++		oid_to_hex(&ucd->oid),
    ++		ucd->just_cloned,
    ++		ucd->sub->path);
     +}
     +
      static int update_submodules(struct submodule_update_clone *suc)
    @@ -33,16 +32,16 @@
      	if (suc->quickstop)
      		return 1;
      
    --	for (i = 0; i < suc->submodule_lines_nr; i++) {
    +-	for (i = 0; i < suc->update_clone_nr; i++) {
     -		strbuf_addf(&sb, "dummy %s %d\t%s\n",
    --			oid_to_hex(&suc->submodule_lines[i].oid),
    --			suc->submodule_lines[i].just_cloned,
    --			suc->submodule_lines[i].sub->path);
    +-			oid_to_hex(&suc->update_clone[i].oid),
    +-			suc->update_clone[i].just_cloned,
    +-			suc->update_clone[i].sub->path);
     -		fprintf(stdout, "%s", sb.buf);
     -		strbuf_reset(&sb);
     -	}
    -+	for (i = 0; i < suc->submodule_lines_nr; i++)
    -+		update_submodule(&suc->submodule_lines[i]);
    ++	for (i = 0; i < suc->update_clone_nr; i++)
    ++		update_submodule(&suc->update_clone[i]);
      
     -	strbuf_release(&sb);
      	return 0;
6:  05bb02e6ea8 ! 6:  b80e60a9d11 submodule--helper: introduce new update-module-mode helper
    @@ -10,7 +10,6 @@
         for arbitrary repositories.
     
         Signed-off-by: Stefan Beller <sbeller@google.com>
    -    Signed-off-by: Junio C Hamano <gitster@pobox.com>
     
     diff --git a/builtin/submodule--helper.c b/builtin/submodule--helper.c
     --- a/builtin/submodule--helper.c
    @@ -79,7 +78,7 @@
     +	return 0;
     +}
     +
    - struct submodule_update_clone_information {
    + struct update_clone_data {
      	const struct submodule *sub;
      	struct object_id oid;
     @@

             reply	other threads:[~2018-07-17  0:27 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-07-17  0:26 Stefan Beller [this message]
2018-07-17  0:26 ` [PATCH v2 1/6] git-submodule.sh: align error reporting for update mode to use path Stefan Beller
2018-07-17  0:26 ` [PATCH v2 2/6] git-submodule.sh: rename unused variables Stefan Beller
2018-07-17  0:26 ` [PATCH v2 3/6] builtin/submodule--helper: factor out submodule updating Stefan Beller
2018-07-17  0:26 ` [PATCH v2 4/6] builtin/submodule--helper: store update_clone information in a struct Stefan Beller
2018-07-17  0:26 ` [PATCH v2 5/6] builtin/submodule--helper: factor out method to update a single submodule Stefan Beller
2018-07-17  0:26 ` [PATCH v2 6/6] submodule--helper: introduce new update-module-mode helper Stefan Beller
2018-07-17  7:59   ` SZEDER Gábor
2018-07-17 21:44     ` Junio C Hamano
2018-07-17 18:39 ` [PATCH v2 0/6] git-submodule.sh: convert part of cmd_update to C Junio C Hamano
2018-07-17 18:53   ` Stefan Beller
2018-07-17 18:59     ` Eric Sunshine
2018-07-18 19:34       ` Stefan Beller
2018-07-18 19:55         ` Eric Sunshine
2018-07-18 21:57           ` Junio C Hamano
2018-07-17 19:51     ` Junio C Hamano
2018-07-17 20:56       ` Stefan Beller
2018-07-17 21:39         ` Junio C Hamano
2018-07-26 10:47     ` Johannes Schindelin
2018-07-26 18:14       ` Stefan Beller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20180717002654.120375-1-sbeller@google.com \
    --to=sbeller@google.com \
    --cc=git@vger.kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

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 read-only IMAP folder(s) and NNTP newsgroup(s).