git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: "Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
To: git@vger.kernel.org
Cc: "Junio C Hamano" <gitster@pobox.com>,
	"Glen Choo" <chooglen@google.com>,
	"Emily Shaffer" <emilyshaffer@google.com>,
	"Ævar Arnfjörð Bjarmason" <avarab@gmail.com>
Subject: [PATCH v2 0/9] submodule: tests, cleanup to prepare for built-in
Date: Tue,  8 Nov 2022 15:10:31 +0100	[thread overview]
Message-ID: <cover-v2-0.9-00000000000-20221108T140501Z-avarab@gmail.com> (raw)
In-Reply-To: <cover-0.8-00000000000-20221102T074148Z-avarab@gmail.com>

As noted in the v1[1] this is a prep series for getting us to a
built-in submodule.c, with a "git rm git-submodule.sh". As noted in
the v1 discussion (e.g. Taylor's [2]) this was mostly ready, but just
needed some final finishing touches.

Changes since v1:

* Noted the history of when "submodule--helper config" was last used,
  per Glen's comment.
* Re-titled the tests htat no longer use the now-removed
  "submodule--helper config", per Glen's comment.
* I removed _() from a string in what's left of "submodule--helper
  config", which is now a test helper. We should not be translating
  test helper strings.
* Fixed a buggy for-loop in the t7422-submodule-output.sh test I'm
  adding.
* Fixed a trivial typo in a comment in that test & in another nearby
  comment.

Passing CI run & branch for this available at[3].

1. https://lore.kernel.org/git/cover-0.8-00000000000-20221102T074148Z-avarab@gmail.com/
2. https://lore.kernel.org/git/Y2Vi95r+RqHPwbw8@nand.local/
3. https://github.com/avar/git/tree/avar/submodule-builtin-final-prep-2

Ævar Arnfjörð Bjarmason (9):
  submodule--helper: move "config" to a test-tool
  submodule tests: add tests for top-level flag output
  submodule--helper: fix  a memory leak in "status"
  submodule tests: test for a "foreach" blind-spot
  submodule.c: refactor recursive block out of absorb function
  submodule API & "absorbgitdirs": remove "----recursive" option
  submodule--helper: remove --prefix from "absorbgitdirs"
  submodule--helper: drop "update --prefix <pfx>" for "-C <pfx> update"
  submodule--helper: use OPT_SUBCOMMAND() API

 builtin/rm.c                           |   3 +-
 builtin/submodule--helper.c            | 146 +++++++--------------
 git-submodule.sh                       |   3 +-
 git.c                                  |   2 +-
 submodule.c                            |  41 +++---
 submodule.h                            |   4 +-
 t/helper/test-submodule.c              |  84 ++++++++++++
 t/t7400-submodule-basic.sh             |  10 ++
 t/t7407-submodule-foreach.sh           |   5 +
 t/t7411-submodule-config.sh            |  36 +++---
 t/t7418-submodule-sparse-gitmodules.sh |   4 +-
 t/t7422-submodule-output.sh            | 170 +++++++++++++++++++++++++
 12 files changed, 358 insertions(+), 150 deletions(-)
 create mode 100755 t/t7422-submodule-output.sh

Range-diff against v1:
 1:  b2649f96715 !  1:  ca8f8b4bf63 submodule--helper: move "config" to a test-tool
    @@ Commit message
         'ab/submodule-helper-prep', 2022-09-13) the "config" sub-command was
         only used by our own tests.
     
    +    It was last used by "git submodule" itself in code that went away with
    +    a6226fd772b (submodule--helper: convert the bulk of cmd_add() to C,
    +    2021-08-10).
    +
         Let's move it over, and while doing so make it easier to reason about
         by splitting up the various uses for it into separate sub-commands, so
         that we don't need to count arguments to see what it does.
     
    +    This also has the advantage that we stop wasting future translator
    +    time on this command, currently the usage information for this
    +    internal-only tool has been translated into several languages. The use
    +    of the "_" function has also been removed from the "please make
    +    sure..." message.
    +
         Signed-off-by: Ævar Arnfjörð Bjarmason <avarab@gmail.com>
     
      ## builtin/submodule--helper.c ##
    @@ t/helper/test-submodule.c: static int cmd__submodule_resolve_relative_url(int ar
     +	/* Equivalent to ACTION_SET in builtin/config.c */
     +	if (argc == 3) {
     +		if (!is_writing_gitmodules_ok())
    -+			die(_("please make sure that the .gitmodules file is in the working tree"));
    ++			die("please make sure that the .gitmodules file is in the working tree");
     +
     +		return config_set_in_gitmodules_file_gently(argv[1], argv[2]);
     +	}
    @@ t/helper/test-submodule.c: static int cmd__submodule_resolve_relative_url(int ar
     +
     +	if (argc == 2) {
     +		if (!is_writing_gitmodules_ok())
    -+			die(_("please make sure that the .gitmodules file is in the working tree"));
    ++			die("please make sure that the .gitmodules file is in the working tree");
     +		return config_set_in_gitmodules_file_gently(argv[1], NULL);
     +	}
     +	usage_with_options(usage, options);
    @@ t/helper/test-submodule.c: static int cmd__submodule_resolve_relative_url(int ar
     
      ## t/t7411-submodule-config.sh ##
     @@ t/t7411-submodule-config.sh: test_expect_success 'error in history in fetchrecursesubmodule lets continue' '
    - test_expect_success 'reading submodules config from the working tree with "submodule--helper config"' '
    + 	)
    + '
    + 
    +-test_expect_success 'reading submodules config from the working tree with "submodule--helper config"' '
    ++test_expect_success 'reading submodules config from the working tree' '
      	(cd super &&
      		echo "../submodule" >expect &&
     -		git submodule--helper config submodule.submodule.url >actual &&
    @@ t/t7411-submodule-config.sh: test_expect_success 'error in history in fetchrecur
      	)
      '
      
    - test_expect_success 'unsetting submodules config from the working tree with "submodule--helper config --unset"' '
    +-test_expect_success 'unsetting submodules config from the working tree with "submodule--helper config --unset"' '
    ++test_expect_success 'unsetting submodules config from the working tree' '
      	(cd super &&
     -		git submodule--helper config --unset submodule.submodule.url &&
     -		git submodule--helper config submodule.submodule.url >actual &&
    @@ t/t7411-submodule-config.sh: test_expect_success 'error in history in fetchrecur
      		test_must_be_empty actual
      	)
      '
    -@@ t/t7411-submodule-config.sh: test_expect_success 'unsetting submodules config from the working tree with "sub
    - test_expect_success 'writing submodules config with "submodule--helper config"' '
    + 
    + 
    +-test_expect_success 'writing submodules config with "submodule--helper config"' '
    ++test_expect_success 'writing submodules config' '
      	(cd super &&
      		echo "new_url" >expect &&
     -		git submodule--helper config submodule.submodule.url "new_url" &&
    @@ t/t7411-submodule-config.sh: test_expect_success 'unsetting submodules config fr
      		test_cmp expect actual
      	)
      '
    -@@ t/t7411-submodule-config.sh: test_expect_success 'overwriting unstaged submodules config with "submodule--hel
    + 
    +-test_expect_success 'overwriting unstaged submodules config with "submodule--helper config"' '
    ++test_expect_success 'overwriting unstaged submodules config' '
      	test_when_finished "git -C super checkout .gitmodules" &&
      	(cd super &&
      		echo "newer_url" >expect &&
 2:  cda36b5b6e0 !  2:  5508c27f653 submodule tests: add tests for top-level flag output
    @@ t/t7422-submodule-output.sh (new)
     +	git -C X pull &&
     +	GIT_ALLOW_PROTOCOL=file git -C X submodule update --init &&
     +
    -+	# dirty p
    ++	# dirty
     +	for d in S.D X/S.D
     +	do
    -+		echo dirty >S.D/A.t || return 1
    ++		echo dirty >"$d"/A.t || return 1
     +	done &&
     +
     +	# commit (for --cached)
    @@ t/t7422-submodule-output.sh (new)
     +
     +	for ref in A B C
     +	do
    -+		# Not different with SHA-1 and SHA-256, just (ab)usign
    ++		# Not different with SHA-1 and SHA-256, just (ab)using
     +		# test_oid_cache as a variable bag to avoid using
     +		# $(git rev-parse ...).
     +		oid=$(git rev-parse $ref) &&
 -:  ----------- >  3:  a3529d7f9e0 submodule--helper: fix  a memory leak in "status"
 3:  0ed1fc7fdf8 =  4:  c14cc0e14b8 submodule tests: test for a "foreach" blind-spot
 4:  f7adfbc13ae =  5:  459ea25125b submodule.c: refactor recursive block out of absorb function
 5:  2b8afd73b9b =  6:  322a02c30fc submodule API & "absorbgitdirs": remove "----recursive" option
 6:  91208241070 =  7:  d1f4ac20a4f submodule--helper: remove --prefix from "absorbgitdirs"
 7:  77d4d5a6c09 =  8:  ac9ff05ef68 submodule--helper: drop "update --prefix <pfx>" for "-C <pfx> update"
 8:  105853cd358 =  9:  cccd92a829c submodule--helper: use OPT_SUBCOMMAND() API
-- 
2.38.0.1464.gea6794aacbc


  parent reply	other threads:[~2022-11-08 14:12 UTC|newest]

Thread overview: 35+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-11-02  7:53 [PATCH 0/8] submodule: tests, cleanup to prepare for built-in Ævar Arnfjörð Bjarmason
2022-11-02  7:53 ` [PATCH 1/8] submodule--helper: move "config" to a test-tool Ævar Arnfjörð Bjarmason
2022-11-03 22:09   ` Glen Choo
2022-11-02  7:53 ` [PATCH 2/8] submodule tests: add tests for top-level flag output Ævar Arnfjörð Bjarmason
2022-11-03 22:30   ` Glen Choo
2022-11-02  7:54 ` [PATCH 3/8] submodule tests: test for a "foreach" blind-spot Ævar Arnfjörð Bjarmason
2022-11-02  7:54 ` [PATCH 4/8] submodule.c: refactor recursive block out of absorb function Ævar Arnfjörð Bjarmason
2022-11-02  7:54 ` [PATCH 5/8] submodule API & "absorbgitdirs": remove "----recursive" option Ævar Arnfjörð Bjarmason
2022-11-03 22:53   ` Glen Choo
2022-11-04  1:42     ` Ævar Arnfjörð Bjarmason
2022-11-04 13:07       ` FW: " Simpson, Phyllis
2022-11-04 17:08       ` Glen Choo
2022-11-02  7:54 ` [PATCH 6/8] submodule--helper: remove --prefix from "absorbgitdirs" Ævar Arnfjörð Bjarmason
2022-11-02  7:54 ` [PATCH 7/8] submodule--helper: drop "update --prefix <pfx>" for "-C <pfx> update" Ævar Arnfjörð Bjarmason
2022-11-02  7:54 ` [PATCH 8/8] submodule--helper: use OPT_SUBCOMMAND() API Ævar Arnfjörð Bjarmason
2022-11-03 23:31   ` Glen Choo
2022-11-04  1:22     ` Ævar Arnfjörð Bjarmason
2022-11-04 17:02       ` Glen Choo
2022-11-05 14:23         ` Ævar Arnfjörð Bjarmason
2022-11-07 17:16           ` Glen Choo
2022-11-04 17:10 ` [PATCH 0/8] submodule: tests, cleanup to prepare for built-in Glen Choo
2022-11-04 19:07   ` Taylor Blau
2022-11-08 14:10 ` Ævar Arnfjörð Bjarmason [this message]
2022-11-08 14:10   ` [PATCH v2 1/9] submodule--helper: move "config" to a test-tool Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 2/9] submodule tests: add tests for top-level flag output Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 3/9] submodule--helper: fix a memory leak in "status" Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 4/9] submodule tests: test for a "foreach" blind-spot Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 5/9] submodule.c: refactor recursive block out of absorb function Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 6/9] submodule API & "absorbgitdirs": remove "----recursive" option Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 7/9] submodule--helper: remove --prefix from "absorbgitdirs" Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 8/9] submodule--helper: drop "update --prefix <pfx>" for "-C <pfx> update" Ævar Arnfjörð Bjarmason
2022-11-08 14:10   ` [PATCH v2 9/9] submodule--helper: use OPT_SUBCOMMAND() API Ævar Arnfjörð Bjarmason
2022-11-08 18:30   ` [PATCH v2 0/9] submodule: tests, cleanup to prepare for built-in Glen Choo
2022-11-08 18:34     ` Ævar Arnfjörð Bjarmason
2022-11-08 19:20       ` Glen Choo

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=cover-v2-0.9-00000000000-20221108T140501Z-avarab@gmail.com \
    --to=avarab@gmail.com \
    --cc=chooglen@google.com \
    --cc=emilyshaffer@google.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    /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).