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

Re: [PATCH 11/16] teach unpack_trees() to remove submodule contents

From
BWBrandon Williams <bmwill@google.com>
Date
Nov 16, 2016, 00:14 UTC
Message-ID
<20161116001402.GH66382@google.com>
In-Reply-To
<20161115230651.23953-12-sbeller@google.com>
On 11/15, Stefan Beller wrote:
Show 38 quoted lines
> Extend rmdir_or_warn() to remove the directories of those submodules which
> are scheduled for removal. Also teach verify_clean_submodule() to check
> that a submodule configured to be removed is not modified before scheduling
> it for removal.
> 
> Signed-off-by: Stefan Beller <sbeller@google.com>
> ---
>  unpack-trees.c | 6 ++----
>  wrapper.c      | 4 ++++
>  2 files changed, 6 insertions(+), 4 deletions(-)
> 
> diff --git a/unpack-trees.c b/unpack-trees.c
> index ea6bdd2..576e1d5 100644
> --- a/unpack-trees.c
> +++ b/unpack-trees.c
> @@ -9,6 +9,7 @@
>  #include "refs.h"
>  #include "attr.h"
>  #include "split-index.h"
> +#include "submodule.h"
>  #include "dir.h"
>  
>  /*
> @@ -1361,15 +1362,12 @@ static void invalidate_ce_path(const struct cache_entry *ce,
>  /*
>   * Check that checking out ce->sha1 in subdir ce->name is not
>   * going to overwrite any working files.
> - *
> - * Currently, git does not checkout subprojects during a superproject
> - * checkout, so it is not going to overwrite anything.
>   */
>  static int verify_clean_submodule(const struct cache_entry *ce,
>  				  enum unpack_trees_error_types error_type,
>  				  struct unpack_trees_options *o)
>  {
> -	return 0;
> +	return submodule_is_interesting(ce->name, null_sha1) && is_submodule_modified(ce->name, 0);
>  }

So what does the return value from this function meant to mean? Is '1' mean the submodule is clean while '0' indicates it is dirty or is it the reverse of that? Reading this it seems to me a value of '1' means "yes the submodule is clean!" but the way the return value is calculated tells a different story. Either I'm understanding it incorrectly or I think the return should be something like this:

  return submodule_is_interesting(ce->name, null_sha1) && !is_submodule_modified(ce->name, 0);

Where we return '1' if the submodule is interesting and it hasn't been modified.

Show 23 quoted lines
>  
>  static int verify_clean_subdirectory(const struct cache_entry *ce,
> diff --git a/wrapper.c b/wrapper.c
> index e7f1979..17c08de 100644
> --- a/wrapper.c
> +++ b/wrapper.c
> @@ -2,6 +2,7 @@
>   * Various trivial helper wrappers around standard functions
>   */
>  #include "cache.h"
> +#include "submodule.h"
>  
>  static void do_nothing(size_t size)
>  {
> @@ -592,6 +593,9 @@ int unlink_or_warn(const char *file)
>  
>  int rmdir_or_warn(const char *file)
>  {
> +	if (submodule_is_interesting(file, null_sha1)
> +	    && depopulate_submodule(file))
> +		return -1;
>  	return warn_if_unremovable("rmdir", file, rmdir(file));
>  }

It seems weird to me that rmdir is doing checks to see if the file being removed is a submodule. Shouldn't those checks have occurred before calling rmdir?

-- 
Brandon Williams
Previous: Stefan BellerNext: Stefan Beller
Message 15 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.