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

RE: [PATCH 13/16] submodule: teach unpack_trees() to update submodules

From
DTDavid Turner <david.turner@twosigma.com>
Date
Nov 16, 2016, 00:22 UTC
Message-ID
<f54d446aa7734cb4aec4b51c7b81a2b6@exmbdft7.ad.twosigma.com>
In-Reply-To
<20161115230651.23953-14-sbeller@google.com>
[I've reviewed up-to and including 13; I'll look at 14-16 tomorrow-ish]
Show 7 quoted lines
> -----Original Message-----
> From: Stefan Beller [mailto:sbeller@google.com]
> Sent: Tuesday, November 15, 2016 6:07 PM
> Cc: git@vger.kernel.org; bmwill@google.com; gitster@pobox.com;
> jrnieder@gmail.com; mogulguy10@gmail.com; David Turner; Stefan Beller
> Subject: [PATCH 13/16] submodule: teach unpack_trees() to update
> submodules
...
Show 7 quoted lines
>  	msgs[ERROR_NOT_UPTODATE_DIR] =
>  		_("Updating the following directories would lose untracked
> files in it:\n%s");
> +	msgs[ERROR_NOT_UPTODATE_SUBMODULE] =
> +		_("Updating the following submodules would lose modifications
> in
> +it:\n%s");
s/it/them/
Show 23 quoted lines
>  	if (!strcmp(cmd, "checkout"))
>  		msg = advice_commit_before_merge
> @@ -1315,19 +1320,18 @@ static int verify_uptodate_1(const struct
> cache_entry *ce,
>  		return 0;
> 
>  	if (!lstat(ce->name, &st)) {
> -		int flags =
> CE_MATCH_IGNORE_VALID|CE_MATCH_IGNORE_SKIP_WORKTREE;
> -		unsigned changed = ie_match_stat(o->src_index, ce, &st,
> flags);
> -		if (!changed)
> -			return 0;
> -		/*
> -		 * NEEDSWORK: the current default policy is to allow
> -		 * submodule to be out of sync wrt the superproject
> -		 * index.  This needs to be tightened later for
> -		 * submodules that are marked to be automatically
> -		 * checked out.
> -		 */
> -		if (S_ISGITLINK(ce->ce_mode))
> -			return 0;
> +		if (!S_ISGITLINK(ce->ce_mode)) {
I generally prefer to avoid if (!x) { A } else { B } -- I would rather just see if (x) { B } else { A }.
Show 20 quoted lines
> +		if (!changed) {
> +			/* old is always a submodule */
> +			if (S_ISGITLINK(new->ce_mode)) {
> +				/*
> +				 * new is also a submodule, so check if we care
> +				 * and then if can checkout the new sha1 safely
> +				 */
> +				if (submodule_is_interesting(old->name, null_sha1)
> +				    && is_submodule_checkout_safe(new->name, &new-
> >oid))
> +					return 0;
> +			} else {
> +				/*
> +				 * new is not a submodule any more, so only
> +				 * care if we care:
> +				 */
> +				if (submodule_is_interesting(old->name, null_sha1)
> +				    && ok_to_remove_submodule(old->name))
> +					return 0;
> +			}
Do we need a return 1 in here somewhere?  Because otherwise, we fall through and return 0 later.
Previous: Stefan BellerNext: Stefan Beller
Message 26 of 50 in “Checkout aware of Submodules!”
  1. 00/16 Checkout aware of Submodules!Stefan Beller, Nov 15, 2016
  2. 01/16 submodule.h: add extern keyword to functions, break line before 80Stefan Beller, Nov 15, 2016
  3. Junio C HamanoNov 16, 2016
  4. Stefan BellerNov 17, 2016
  5. 06/16 update submodules: add a config option to determine if submodules are updatedStefan Beller, Nov 15, 2016
  6. 08/16 update submodules: add depopulate_submoduleStefan Beller, Nov 15, 2016
  7. Brandon WilliamsNov 15, 2016
  8. Stefan BellerNov 17, 2016
  9. Brandon WilliamsNov 17, 2016
  10. Stefan BellerNov 17, 2016
  11. Stefan BellerNov 18, 2016
  12. Brandon WilliamsNov 18, 2016
  13. Stefan BellerNov 18, 2016
  14. 11/16 teach unpack_trees() to remove submodule contentsStefan Beller, Nov 15, 2016
  15. Brandon WilliamsNov 16, 2016
  16. 09/16 update submodules: add scheduling to update submodulesStefan Beller, Nov 15, 2016
  17. Brandon WilliamsNov 16, 2016
  18. David TurnerNov 16, 2016
  19. Stefan BellerNov 18, 2016
  20. 12/16 entry: write_entry to write populate submodulesStefan Beller, Nov 15, 2016
  21. 14/16 checkout: recurse into submodules if asked toStefan Beller, Nov 15, 2016
  22. Brandon WilliamsNov 16, 2016
  23. David TurnerNov 16, 2016
  24. David TurnerNov 16, 2016
  25. 13/16 submodule: teach unpack_trees() to update submodulesStefan Beller, Nov 15, 2016
  26. David TurnerNov 16, 2016
  27. Stefan BellerNov 18, 2016
  28. David TurnerNov 21, 2016
  29. Brandon WilliamsNov 16, 2016
  30. Stefan BellerNov 18, 2016
  31. 16/16 checkout: add config option to recurse into submodules by defaultStefan Beller, Nov 15, 2016
  32. 07/16 update submodules: introduce submodule_is_interestingStefan Beller, Nov 15, 2016
  33. Brandon WilliamsNov 15, 2016
  34. David TurnerNov 16, 2016
  35. Stefan BellerNov 17, 2016
  36. 03/16 submodule: use absolute path for computing relative path connectingStefan Beller, Nov 15, 2016
  37. 04/16 update submodules: add is_submodule_populatedStefan Beller, Nov 15, 2016
  38. Brandon WilliamsNov 15, 2016
  39. 02/16 submodule: modernize ok_to_remove_submodule to use argv_arrayStefan Beller, Nov 15, 2016
  40. David TurnerNov 15, 2016
  41. Junio C HamanoNov 16, 2016
  42. Stefan BellerNov 17, 2016
  43. 10/16 update submodules: is_submodule_checkout_safeStefan Beller, Nov 15, 2016
  44. Brandon WilliamsNov 16, 2016
  45. 05/16 update submodules: add submodule config parsingStefan Beller, Nov 15, 2016
  46. 15/16 completion: add '--recurse-submodules' to checkoutStefan Beller, Nov 15, 2016
  47. Xiaodong QiDec 3, 2016
  48. Stefan BellerNov 17, 2016
  49. Stefan BellerNov 17, 2016
  50. Stefan BellerNov 18, 2016

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.