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

Re: [PATCH] Show submodules as modified when they contain a dirty work tree

From
Junio C Hamano <gitster@pobox.com>
Date
Jan 14, 2010, 23:13 UTC
Message-ID
<7v3a288em2.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4B4F8EF1.3080709@web.de>
Jens Lehmann <Jens.Lehmann@web.de> writes:
Show 23 quoted lines
> Subject: Show a modified submodule directory as dirty even if the refs match
>
> When the submodules HEAD and the ref committed in the HEAD of the
> superproject were the same, "git diff[-index] HEAD" did not show the
> submodule as dirty when it should.
>
> Signed-off-by: Jens Lehmann <Jens.Lehmann@web.de>
> ---
>  diff-lib.c                |    3 ++-
>  t/t4027-diff-submodule.sh |   35 +++++++++++++++++++++++++++++++++++
>  2 files changed, 37 insertions(+), 1 deletions(-)
>
> diff --git a/diff-lib.c b/diff-lib.c
> index 5ce226b..9cdf6da 100644
> --- a/diff-lib.c
> +++ b/diff-lib.c
> @@ -233,7 +233,8 @@ static int get_stat_data(struct cache_entry *ce,
>  			return -1;
>  		}
>  		changed = ce_match_stat(ce, &st, 0);
> -		if (changed) {
> +		if (changed
> +		    || (S_ISGITLINK(ce->ce_mode) && is_submodule_modified(ce->name))) {

You had a check in your previous patch that decides to call or skip diff_change() based on is_submodule_modified() for diff-files, but forgot to have the same for diff-index, which this patch does. Perhaps we want to squash this into 4519d9c (Show submodules as modified when they contain a dirty work tree, 2010-01-13).

The existing code is a bit unfortunate; by the time we come to the output routine, the information we found from is_submodule_modified() is lost; that is why my "would look like this" patch calls is_submodule_modified().

We may want to add one parameter to diff_change() and diff_addremove(), to tell them if the work-tree side (if we are comparing something with the work tree) is a modified submodule, and add one bit to the diff_filespec structure to record that in diff_change() and diff_addremove() (obviously only when adding). That way, my "would looks like this" patch needs to check the result of is_submodule_modified() the front-ends left in the filespec, instead of running it again.

Previous: Jens LehmannNext: Jens Lehmann
Message 9 of 14 in “Show a dirty working tree and a detached HEAD in status for submodule”
  1. Show a dirty working tree and a detached HEAD in status for submoduleJens Lehmann, Jan 11, 2010
  2. Junio C HamanoJan 11, 2010
  3. Jens LehmannJan 12, 2010
  4. Junio C HamanoJan 13, 2010
  5. Show submodules as modified when they contain a dirty work treeJens Lehmann, Jan 13, 2010
  6. Junio C HamanoJan 13, 2010
  7. Jens LehmannJan 14, 2010
  8. Jens LehmannJan 14, 2010
  9. Junio C HamanoJan 14, 2010
  10. Jens LehmannJan 15, 2010
  11. Performance optimization for detection of modified submodulesJens Lehmann, Jan 17, 2010
  12. Junio C HamanoJan 17, 2010
  13. Jens LehmannJan 17, 2010
  14. Nanako ShiraishiJan 15, 2010

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.