git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 1/2] short status: improve reporting for submodule changes

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Mar 28, 2017, 23:24 UTC
Message-ID
<20170328232446.GT31294@aiede.mtv.corp.google.com>
In-Reply-To
<20170328230938.9887-2-sbeller@google.com>
Hi,
Stefan Beller wrote:
[...]
> +++ b/t/t7506-status-submodule.sh
[...]
Show 22 quoted lines
> @@ -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)?

[...]
Show 53 quoted lines
> +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

Previous: Stefan BellerNext: Stefan Beller
Message 65 of 73 in “[PATCHv3 0/3] short status: improve reporting for submodule changes”
  1. Stefan BellerMar 23, 2017
  2. 1/3 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  3. Jonathan NiederMar 23, 2017
  4. Junio C HamanoMar 23, 2017
  5. Stefan BellerMar 23, 2017
  6. 2/3 submodule.c, is_submodule_modified: stricter checking for submodulesStefan Beller, Mar 23, 2017
  7. Jonathan NiederMar 23, 2017
  8. 3/3 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  9. Jonathan NiederMar 23, 2017
  10. 0/8 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  11. 3/8 submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fdStefan Beller, Mar 23, 2017
  12. 1/8 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  13. 5/8 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 23, 2017
  14. 2/8 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 23, 2017
  15. 4/8 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  16. 8/8 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017
  17. 6/8 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017
  18. 7/8 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  19. Stefan BellerMar 23, 2017
  20. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  21. 1/7 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 23, 2017
  22. Jonathan NiederMar 23, 2017
  23. 4/7 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 23, 2017
  24. 5/7 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017
  25. 2/7 submodule.c: convert is_submodule_modified to use strbuf_getwholeline_fdStefan Beller, Mar 23, 2017
  26. Jonathan NiederMar 23, 2017
  27. Stefan BellerMar 23, 2017
  28. Stefan BellerMar 23, 2017
  29. 6/7 short status: improve reporting for submodule changesStefan Beller, Mar 23, 2017
  30. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 24, 2017
  31. 1/7 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 24, 2017
  32. Jonathan NiederMar 24, 2017
  33. 2/7 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 24, 2017
  34. Jonathan NiederMar 24, 2017
  35. 3/7 submodule.c: convert is_submodule_modified to use strbuf_getwholelineStefan Beller, Mar 24, 2017
  36. Jonathan NiederMar 24, 2017
  37. Stefan BellerMar 25, 2017
  38. 5/7 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 24, 2017
  39. Jonathan NiederMar 24, 2017
  40. 6/7 short status: improve reporting for submodule changesStefan Beller, Mar 24, 2017
  41. Jonathan NiederMar 24, 2017
  42. 7/7 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 24, 2017
  43. Jonathan NiederMar 24, 2017
  44. Stefan BellerMar 25, 2017
  45. 4/7 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 24, 2017
  46. Jonathan NiederMar 24, 2017
  47. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 25, 2017
  48. 1/7 submodule.c: use argv_array in is_submodule_modifiedStefan Beller, Mar 25, 2017
  49. 2/7 submodule.c: factor out early loop termination in is_submodule_modifiedStefan Beller, Mar 25, 2017
  50. 3/7 submodule.c: convert is_submodule_modified to use strbuf_getwholelineStefan Beller, Mar 25, 2017
  51. 4/7 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 25, 2017
  52. 7/7 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 25, 2017
  53. Junio C HamanoMar 27, 2017
  54. Jonathan NiederMar 28, 2017
  55. Junio C HamanoMar 30, 2017
  56. Stefan BellerMar 28, 2017
  57. 6/7 short status: improve reporting for submodule changesStefan Beller, Mar 25, 2017
  58. 5/7 submodule.c: stricter checking for submodules in is_submodule_modifiedStefan Beller, Mar 25, 2017
  59. Jonathan NiederMar 25, 2017
  60. 0/7 short status: improve reporting for submodule changesStefan Beller, Mar 28, 2017
  61. 2/2 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 28, 2017
  62. Jonathan NiederMar 28, 2017
  63. Stefan BellerMar 29, 2017
  64. 1/2 short status: improve reporting for submodule changesStefan Beller, Mar 28, 2017
  65. Jonathan NiederMar 28, 2017
  66. [PATCHv9 (6,7)/7] short status: improve reporting for submodule changesStefan Beller, Mar 29, 2017
  67. 1/2 short status: improve reporting for submodule changesStefan Beller, Mar 29, 2017
  68. Jonathan NiederMar 29, 2017
  69. 2/2 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 29, 2017
  70. Jonathan NiederMar 29, 2017
  71. Junio C HamanoMar 30, 2017
  72. 3/7 submodule.c: port is_submodule_modified to use porcelain 2Stefan Beller, Mar 23, 2017
  73. 7/7 submodule.c: correctly handle nested submodules in is_submodule_modifiedStefan Beller, Mar 23, 2017

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.