git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Jonathan Nieder <jrnieder@gmail.com>
To: Stefan Beller <sbeller@google.com>
Cc: gitster@pobox.com, git@vger.kernel.org
Subject: Re: [PATCH 1/2] short status: improve reporting for submodule changes
Date: Tue, 28 Mar 2017 16:24:46 -0700	[thread overview]
Message-ID: <20170328232446.GT31294@aiede.mtv.corp.google.com> (raw)
In-Reply-To: <20170328230938.9887-2-sbeller@google.com>

Hi,

Stefan Beller wrote:

[...]
> +++ b/t/t7506-status-submodule.sh
[...]
> @@ -287,4 +311,82 @@ test_expect_success 'diff --submodule with merge conflict in .gitmodules' '
>  	test_cmp diff_submodule_actual diff_submodule_expect
>  '
>  
> +test_expect_success 'setup superproject with untracked file in nested submodule' '
> +	(
> +		cd super &&
> +		git clean -dfx &&
> +		rm .gitmodules &&
> +		git submodule add -f ./sub1 &&
> +		git submodule add -f ./sub2 &&
> +		git commit -a -m "messy merge in superproject" &&
> +		(
> +			cd sub1 &&
> +			git submodule add ../sub2 &&
> +			git commit -a -m "add sub2 to sub1"
> +		) &&
> +		git add sub1 &&
> +		git commit -a -m "update sub1 to contain nested sub"
> +	) &&
> +	echo "{ \$7=\"HASH\"; \$8=\"HASH\"; print }" >suppress_hashes.awk &&
> +	echo "suppress_hashes.awk" >>.git/info/exclude &&

I had some trouble following what suppress_hashes.awk does at first.

Some other examples that could be worth imitating:

- diff-lib.sh has some sanitize_diff functions using 'sed'
- t4202 has a sanitize_output functino, also using 'sed'
- grepping for $_x40 finds some other examples (these will be fun to
  change when the hash function changes, but at least they're easy to
  find).

The main general idea I have in mind is that providing a function at the
top of the file for the test to use instead of a script that interacts
with what git is tracking can make things easier to understand.

Also, could there be a comment with a diagram describing the setup
(sub1 vs sub2, etc)?

[...]
> +test_expect_success 'status with untracked file in nested submodule (porcelain)' '
> +	git -C super status --porcelain >output &&
> +	diff output - <<-\EOF
> +	 M sub1
> +	 M sub2
> +	EOF
> +'
> +
> +test_expect_success 'status with untracked file in nested submodule (porcelain=2)' '
> +	git -C super status --porcelain=2 >output &&
> +	awk -f suppress_hashes.awk output >output2 &&
> +	diff output2 - <<-\EOF
> +	1 .M S.M. 160000 160000 160000 HASH HASH sub1
> +	1 .M S..U 160000 160000 160000 HASH HASH sub2
> +	EOF
> +'
> +
> +test_expect_success 'status with untracked file in nested submodule (short)' '
> +	git -C super status --short >output &&
> +	diff output - <<-\EOF
> +	 m sub1
> +	 ? sub2
> +	EOF
> +'
> +
> +test_expect_success 'setup superproject with modified file in nested submodule' '
> +	git -C super/sub1/sub2 add file &&
> +	git -C super/sub2 add file
> +'
> +
> +test_expect_success 'status with added file in nested submodule (porcelain)' '
> +	git -C super status --porcelain >output &&
> +	diff output - <<-\EOF
> +	 M sub1
> +	 M sub2
> +	EOF
> +'
> +
> +test_expect_success 'status with added file in nested submodule (porcelain=2)' '
> +	git -C super status --porcelain=2 >output &&
> +	awk -f suppress_hashes.awk output >output2 &&
> +	diff output2 - <<-\EOF
> +	1 .M S.M. 160000 160000 160000 HASH HASH sub1
> +	1 .M S.M. 160000 160000 160000 HASH HASH sub2
> +	EOF
> +'
> +
> +test_expect_success 'status with added file in nested submodule (short)' '
> +	git -C super status --short >output &&
> +	diff output - <<-\EOF
> +	 m sub1
> +	 m sub2
> +	EOF

How does ordinary non --short "git status" handle these cases?

What should happen when there is a new untracked repository within a
submodule?

What should happen if there is both a modified tracked file and an
untracked file in a sub-submodule?


> +'
> +
>  test_done

Very nice.  Thanks --- this was exactly what I was looking for.

The rest looks good.

Sincerely,
Jonathan

  reply	other threads:[~2017-03-28 23:24 UTC|newest]

Thread overview: 73+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2017-03-23  0:43 [PATCHv3 0/3] short status: improve reporting for submodule changes Stefan Beller
2017-03-23  0:43 ` [PATCH 1/3] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23  0:53   ` Jonathan Nieder
2017-03-23  6:09     ` Junio C Hamano
2017-03-23 18:47       ` Stefan Beller
2017-03-23  0:43 ` [PATCH 2/3] submodule.c, is_submodule_modified: stricter checking for submodules Stefan Beller
2017-03-23  0:54   ` Jonathan Nieder
2017-03-23  0:43 ` [PATCH 3/3] short status: improve reporting for submodule changes Stefan Beller
2017-03-23  1:06   ` Jonathan Nieder
2017-03-23 21:09 ` [PATCH 0/8] " Stefan Beller
2017-03-23 21:09   ` [PATCH 1/8] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 21:09   ` [PATCH 2/8] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-23 21:09   ` [PATCH 3/8] submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fd Stefan Beller
2017-03-23 21:09   ` [PATCH 4/8] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 21:09   ` [PATCH 5/8] submodule.c: factor out early loop termination in is_submodule_modified Stefan Beller
2017-03-23 21:09   ` [PATCH 6/8] submodule.c: stricter checking for submodules " Stefan Beller
2017-03-23 21:09   ` [PATCH 7/8] short status: improve reporting for submodule changes Stefan Beller
2017-03-23 21:09   ` [PATCH 8/8] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-23 21:11   ` [PATCH 0/8] short status: improve reporting for submodule changes Stefan Beller
2017-03-23 22:33     ` [PATCH v5 0/7] " Stefan Beller
2017-03-23 22:33       ` [PATCH 1/7] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-23 22:36         ` Jonathan Nieder
2017-03-23 22:33       ` [PATCH 2/7] submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fd Stefan Beller
2017-03-23 22:50         ` Jonathan Nieder
2017-03-23 23:04           ` Stefan Beller
2017-03-23 23:11             ` Stefan Beller
2017-03-23 22:33       ` [PATCH 3/7] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-23 22:33       ` [PATCH 4/7] submodule.c: factor out early loop termination in is_submodule_modified Stefan Beller
2017-03-23 22:33       ` [PATCH 5/7] submodule.c: stricter checking for submodules " Stefan Beller
2017-03-23 22:33       ` [PATCH 6/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-24 18:28         ` [PATCH v6 0/7] " Stefan Beller
2017-03-24 18:28           ` [PATCH 1/7] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-24 22:25             ` Jonathan Nieder
2017-03-24 18:28           ` [PATCH 2/7] submodule.c: factor out early loop termination " Stefan Beller
2017-03-24 22:30             ` Jonathan Nieder
2017-03-24 18:28           ` [PATCH 3/7] submodule.c: convert is_submodule_modified to use strbuf_getwholeline Stefan Beller
2017-03-24 22:38             ` Jonathan Nieder
2017-03-25  0:12               ` Stefan Beller
2017-03-24 18:28           ` [PATCH 4/7] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-24 22:41             ` Jonathan Nieder
2017-03-24 18:29           ` [PATCH 5/7] submodule.c: stricter checking for submodules in is_submodule_modified Stefan Beller
2017-03-24 22:42             ` Jonathan Nieder
2017-03-24 18:29           ` [PATCH 6/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-24 23:06             ` Jonathan Nieder
2017-03-24 18:29           ` [PATCH 7/7] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-24 23:31             ` Jonathan Nieder
2017-03-25  0:25               ` Stefan Beller
2017-03-25  0:36           ` [PATCH v7 0/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-25  0:36             ` [PATCH 1/7] submodule.c: use argv_array in is_submodule_modified Stefan Beller
2017-03-25  0:36             ` [PATCH 2/7] submodule.c: factor out early loop termination " Stefan Beller
2017-03-25  0:36             ` [PATCH 3/7] submodule.c: convert is_submodule_modified to use strbuf_getwholeline Stefan Beller
2017-03-25  0:36             ` [PATCH 4/7] submodule.c: port is_submodule_modified to use porcelain 2 Stefan Beller
2017-03-25  0:36             ` [PATCH 5/7] submodule.c: stricter checking for submodules in is_submodule_modified Stefan Beller
2017-03-25  0:36             ` [PATCH 6/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-25  0:36             ` [PATCH 7/7] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-27 21:46               ` Junio C Hamano
2017-03-28  1:05                 ` Jonathan Nieder
2017-03-30 18:18                   ` Junio C Hamano
2017-03-28 21:20                 ` Stefan Beller
2017-03-25  1:35             ` [PATCH v7 0/7] short status: improve reporting for submodule changes Jonathan Nieder
2017-03-28 23:09             ` [PATCH v8 " Stefan Beller
2017-03-28 23:09               ` [PATCH 1/2] " Stefan Beller
2017-03-28 23:24                 ` Jonathan Nieder [this message]
2017-03-28 23:09               ` [PATCH 2/2] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-28 23:42                 ` Jonathan Nieder
2017-03-29 22:00                   ` Stefan Beller
2017-03-29 22:26               ` [PATCHv9 (6,7)/7] short status: improve reporting for submodule changes Stefan Beller
2017-03-29 22:26                 ` [PATCH 1/2] " Stefan Beller
2017-03-29 23:09                   ` Jonathan Nieder
2017-03-29 22:26                 ` [PATCH 2/2] submodule.c: correctly handle nested submodules in is_submodule_modified Stefan Beller
2017-03-29 23:13                   ` Jonathan Nieder
2017-03-30 18:28                     ` Junio C Hamano
2017-03-23 22:33       ` [PATCH 7/7] " 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=20170328232446.GT31294@aiede.mtv.corp.google.com \
    --to=jrnieder@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=sbeller@google.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).