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

Re: [PATCH v2.1] commit: add --ignore-submodules[=<when>] parameter

From
RWRonald Weiss <weiss.ronald@gmail.com>
Date
Apr 22, 2014, 22:21 UTC
Message-ID
<5356EB5D.2030503@gmail.com>
In-Reply-To
<53511A59.6000402@web.de>
On 18. 4. 2014 14:28, Jens Lehmann wrote:
Show 25 quoted lines
> Am 13.04.2014 01:41, schrieb Ronald Weiss:
>> Second, there are some differences between adding standard ignored
>> files, and ignored submodules:
>>
>> 1) Already tracked files are never ignored, regardless of .gitignore.
>>   However, tracked submodules should be ignored by "add -u", if told so
>>   by their ignore setting.
>>
>> 2) So .gitignore seems to only do something when adding new files to
>>   the repo. However, when adding new submodules, they are probably never
>>   ignored (setting the ignore setting for non existent submodule seems
>>   like non-sense, although possible).
> 
> What about "diff.ignoreSubmodules=all"?
> 
>> 3) Ignored files can be ignored less explicitely (in global gitignore,
>>   or using a wildcard, or by ignoring parent folder). So it makes sense
>>   to warn the user if he tries to explicitely add an ignored file, as he
>>   might not be aware that the file is ignored. Submodules, however, can
>>   only be ignored explicitely. And when user explicitely specifies the
>>   submodule in an add command, he most probably really wants to add it,
>>   so I don't see the point in warning him and requiring the -f option.
> 
> But we do have "diff.ignoreSubmodules=all", so I do not agree with
> your conclusion.

Ah, I didn't know about diff.ignoreSubmodules. I agree that it defeats two of my points :-(.

And how about the point 1), should submodules never be ignored once already tracked, like standard ignored files? I'm almost sure that in this case the behavior should be different, otherwise it would drop the most useful use case of the proposed change.

Show 13 quoted lines
>> So, I think that the use cases are completely different, for submodules
>> and ignored files. So trying to make add behave the same for both, might
>> not be that good idea.
>>
>> I would propose - let's make add honor the ignore setting by just
>> parsing if from config like the other commands do, and pass it to
>> underlying diff invocations. And at the same the, let's override it for
>> submodules explicitely specified on the command line, to never ignore
>> such submodules, without requiring the -f option. That seems to be
>> pretty easy, see below.
> 
> What about doing that only when '-f' is given? Would that do what we
> want?
OK then, seems right with diff.ignoreSubmodules in mind.

But one question stays - what to do with submodules not explicitly specified on command line (when their parent folder is being added)? You adviced already to do what we do with standard ignored files. That seems to be:

A) if the file is already tracked, add it B) if not tracked, without -f, silently ignore it C) if not tracked, with -f, add it

A) is same like point 1 above, let's forget it until we settle that one. But B) is even more problematic, we would probably have to modify the directory parsing code in dir.c to handle ignored submodules. Is that what we want? If so, then I'm afraid this is getting overly complicated.

Show 8 quoted lines
>> @@ -320,6 +324,7 @@ int cmd_add(int argc, const char **argv, const char *prefix)
>>   	char *seen = NULL;
>>   
>>   	git_config(add_config, NULL);
>> +	gitmodules_config();
> 
> Wrong order, gitmodules_config() must be called before git_config()
> to make the .gitmodules settings overridable by the users config.
Right. I noticed that too just after sending the patch.
Show 19 quoted lines
>> @@ -440,6 +446,18 @@ int cmd_add(int argc, const char **argv, const char *prefix)
>>   					die(_("pathspec '%s' did not match any files"),
>>   					    pathspec.items[i].original);
>>   			}
>> +
>> +			/* disable ignore setting for any submodules specified explicitly in the pathspec */
>> +			if (path[0] &&
>> +				(cachepos = cache_name_pos(path, pathspec.items[i].len)) >= 0 &&
>> +				S_ISGITLINK(active_cache[cachepos]->ce_mode)) {
>> +				char *optname;
>> +				int optnamelen = pathspec.items[i].len + 17;
>> +				optname = xcalloc(optnamelen + 1, 1);
>> +				snprintf(optname, optnamelen + 1, "submodule.%s.ignore", path);
>> +				parse_submodule_config_option(optname, "none");
> 
> We should use "dirty" instead of "none" here. Modifications inside
> the submodule cannot be added without committing them there first
> and using "none" might incur an extra preformance penalty for
> looking through the submodule directories for such changes.
OK, that's right too.
Previous: Jens LehmannNext: Junio C Hamano
Message 45 of 51 in “git commit vs. ignore-submodules”
  1. Ronald WeissMar 27, 2014
  2. Jens LehmannMar 28, 2014
  3. Junio C HamanoMar 28, 2014
  4. Ronald WeissMar 29, 2014
  5. 1/2 commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Mar 29, 2014
  6. Jens LehmannMar 29, 2014
  7. Jens LehmannMar 30, 2014
  8. commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Mar 30, 2014
  9. commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Mar 31, 2014
  10. Jens LehmannMar 31, 2014
  11. Jens LehmannMar 31, 2014
  12. Ronald WeissMar 31, 2014
  13. Ronald WeissMar 31, 2014
  14. Ronald WeissMar 31, 2014
  15. Ronald WeissMar 31, 2014
  16. Jens LehmannApr 1, 2014
  17. Ronald WeissApr 1, 2014
  18. Jens LehmannApr 2, 2014
  19. Ronald WeissApr 2, 2014
  20. Jens LehmannApr 6, 2014
  21. Ronald WeissApr 7, 2014
  22. 1/2 add: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 7, 2014
  23. 2/2 commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 7, 2014
  24. Jens LehmannApr 8, 2014
  25. Ronald WeissApr 8, 2014
  26. Ronald WeissApr 12, 2014
  27. 1/2 add: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 12, 2014
  28. Jens LehmannApr 18, 2014
  29. Ronald WeissApr 21, 2014
  30. 2/2 commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 12, 2014
  31. Jens LehmannApr 18, 2014
  32. Ronald WeissApr 21, 2014
  33. Jens LehmannApr 22, 2014
  34. 1/2 add: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 22, 2014
  35. Eric SunshineApr 23, 2014
  36. 1/2 add: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 24, 2014
  37. 2/2 commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 24, 2014
  38. 2/2 commit: add --ignore-submodules[=<when>] parameterRonald Weiss, Apr 22, 2014
  39. Junio C HamanoApr 14, 2014
  40. Ronald WeissApr 14, 2014
  41. Junio C HamanoApr 14, 2014
  42. Jens LehmannApr 8, 2014
  43. Ronald WeissApr 12, 2014
  44. Jens LehmannApr 18, 2014
  45. Ronald WeissApr 22, 2014
  46. Junio C HamanoMar 31, 2014
  47. 2/2 status: don't ignore submodules added to indexRonald Weiss, Mar 29, 2014
  48. Jens LehmannMar 29, 2014
  49. Ronald WeissMar 29, 2014
  50. Ronald WeissMar 30, 2014
  51. status/commit: always show staged submodules regardless of ignore configJens Lehmann, Mar 30, 2014

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.