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

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

From
Jens Lehmann <jens.lehmann@web.de>
Date
Mar 31, 2014, 20:37 UTC
Message-ID
<5339D213.4070303@web.de>
In-Reply-To
<5339BAE4.8020306@web.de>
Am 31.03.2014 20:58, schrieb Jens Lehmann:
Show 13 quoted lines
> Am 31.03.2014 02:07, schrieb Ronald Weiss:
>> The tests immediately revealed, that the patch was not complete. It
>> didn't work with commit message given on command line (-m). To make
>> that work, I had to also patch the index_differs_from function in
>> diff-lib.c.
> 
> Which is exactly the same function I have to tweak to make my
> "status/commit: always show staged submodules regardless of
> ignore config" patch work for "git commit -m" too ;-)
> 
> I was doing that slightly differently but it seems that your way
> of adding the "ignore_submodules_arg" parameter could serve us
> both. Will update my upcoming patch accordingly.

I've been hacking on that some more (I'll post it as soon as I have all new tests up and running) and think we might be able to handle that even easier. Please see below:

Show 20 quoted lines
>> diff --git a/diff-lib.c b/diff-lib.c
>> index 2eddc66..fec5ad4 100644
>> --- a/diff-lib.c
>> +++ b/diff-lib.c
>> @@ -508,7 +508,8 @@ int do_diff_cache(const unsigned char *tree_sha1, struct diff_options *opt)
>>  	return 0;
>>  }
>>  
>> -int index_differs_from(const char *def, int diff_flags)
>> +int index_differs_from(const char *def, int diff_flags,
>> +		       const char *ignore_submodules_arg)
>>  {
>>  	struct rev_info rev;
>>  	struct setup_revision_opt opt;
>> @@ -520,6 +521,10 @@ int index_differs_from(const char *def, int diff_flags)
>>  	DIFF_OPT_SET(&rev.diffopt, QUICK);
>>  	DIFF_OPT_SET(&rev.diffopt, EXIT_WITH_STATUS);
>>  	rev.diffopt.flags |= diff_flags;
>> +	if (ignore_submodules_arg) {
>> +		DIFF_OPT_SET(&rev.diffopt, OVERRIDE_SUBMODULE_CONFIG);

You'll have to do this unconditionally, as this option tells the diff machinery to ignore any submodule configurations, which is what we want in either case. But ...

Show 5 quoted lines
>> +		handle_ignore_submodules_arg(&rev.diffopt, ignore_submodules_arg);
>> +	}
>>  	run_diff_index(&rev, 1);
>>  	if (rev.pending.alloc)
>>  		free(rev.pending.objects);

... maybe the best way is to leave index_differs_from() unchanged and call that function with the correct diff_flags instead:

+ int diff_flags = DIFF_OPT_OVERRIDE_SUBMODULE_CONFIG; + if (ignore_submodule_arg && + !strcmp(ignore_submodule_arg, "all")) + diff_flags |= DIFF_OPT_IGNORE_SUBMODULES; + commitable = index_differs_from(parent, diff_flags);

Not thoroughly tested yet, but that'd also prevent any fallout for the two callsites of index_differs_from() in sequencer.c.

Previous: Jens LehmannNext: Ronald Weiss
Message 11 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.