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

Re: [PATCH v2 2/4] update-index: use the same structure for chmod as add

From
Thomas Gummerer <t.gummerer@gmail.com>
Date
Sep 12, 2016, 19:30 UTC
Message-ID
<20160912193016.GD8254@hank>
In-Reply-To
<xmqqinu26ph0.fsf@gitster.mtv.corp.google.com>
On 09/11, Junio C Hamano wrote:
Show 58 quoted lines
> Thomas Gummerer <t.gummerer@gmail.com> writes:
> 
> > @@ -955,10 +941,8 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
> >  			PARSE_OPT_NOARG | /* disallow --cacheinfo=<mode> form */
> >  			PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
> >  			(parse_opt_cb *) cacheinfo_callback},
> > -		{OPTION_CALLBACK, 0, "chmod", &set_executable_bit, N_("(+/-)x"),
> > -			N_("override the executable bit of the listed files"),
> > -			PARSE_OPT_NONEG | PARSE_OPT_LITERAL_ARGHELP,
> > -			chmod_callback},
> > +		OPT_STRING( 0, "chmod", &chmod_arg, N_("(+/-)x"),
> > +			N_("override the executable bit of the listed files")),
> >  		{OPTION_SET_INT, 0, "assume-unchanged", &mark_valid_only, NULL,
> >  			N_("mark files as \"not changing\""),
> >  			PARSE_OPT_NOARG | PARSE_OPT_NONEG, NULL, MARK_FLAG},
> > @@ -1018,6 +1002,15 @@ int cmd_update_index(int argc, const char **argv, const char *prefix)
> >  	if (argc == 2 && !strcmp(argv[1], "-h"))
> >  		usage_with_options(update_index_usage, options);
> >  
> > +	if (!chmod_arg)
> > +		force_mode = 0;
> > +	else if (!strcmp(chmod_arg, "-x"))
> > +		force_mode = 0666;
> > +	else if (!strcmp(chmod_arg, "+x"))
> > +		force_mode = 0777;
> > +	else
> > +		die(_("option 'chmod' expects \"+x\" or \"-x\""));
> > +
> 
> I am afraid that this changes the behaviour drastically.
> 
> "git update-index" is an oddball command that takes options and then
> processes them immediately, exactly because it was designed to take
> 
> 	git update-index --chmod=-x A --chmod=+x B --add C
> 
> and say things like "A and B are not in the index and you are
> attempting to add them before giving me --add option".
> 
> 	git update-index --add --chmod=-x A --chmod=+x B C
> 
> is expected to add A as non-executable, and B and C as executable.
> Many exotic parse-options callback mechanisms used in this command
> were invented exactly to support its quirky way of not doing "get a
> list of options and use the last one".  And this patch breaks it for
> only one option without changing the others.
> 
> If we were willing to take such a big backward compatiblity hit in
> the upcoming release (which I personally won't be affected, but old
> scripts by others need to be audited and adjusted, which I won't
> volunteer to do myself), we should make such a change consistently,
> e.g. "git update-index A --add --remove B" should no longer error
> out when it sees A and it is not yet in the index because "--add"
> hasn't been given yet, or A is in the index but is missing from the
> working tree because "--remove" hasn't been given yet.  Then it may
> be more justifiable if "update-index --chmod=-x A --chmod=+x B"
> added A as an executable.  With the current form of this patch, it
> is not.

Thanks for the explanation, this change in backwards compatibility is certainly not what I intended, but rather something I missed while cooking up this patch.

> Can we do this "fix" without this change?
Yeah, let me see what I can come up with in a re-roll.

Thanks, Thomas

Previous: Junio C HamanoNext: Thomas Gummerer
Message 20 of 40 in “`make profile-install` fails in 2.9.3”
  1. Jan KeromnesSep 1, 2016
  2. Dennis KaarsemakerSep 1, 2016
  3. Thomas GummererSep 1, 2016
  4. Jeff KingSep 1, 2016
  5. Junio C HamanoSep 1, 2016
  6. Jeff KingSep 1, 2016
  7. Junio C HamanoSep 1, 2016
  8. 0/4 git add --chmod: always change the fileThomas Gummerer, Sep 4, 2016
  9. 1/4 add: document the chmod optionThomas Gummerer, Sep 4, 2016
  10. Johannes SchindelinSep 5, 2016
  11. Thomas GummererSep 5, 2016
  12. Junio C HamanoSep 7, 2016
  13. 3/4 read-cache: introduce chmod_index_entryThomas Gummerer, Sep 4, 2016
  14. 2/4 update-index: use the same structure for chmod as addThomas Gummerer, Sep 4, 2016
  15. 4/4 add: modify already added files when --chmod is givenThomas Gummerer, Sep 4, 2016
  16. 0/4 git add --chmod: always change the fileThomas Gummerer, Sep 11, 2016
  17. 1/4 add: document the chmod optionThomas Gummerer, Sep 11, 2016
  18. 2/4 update-index: use the same structure for chmod as addThomas Gummerer, Sep 11, 2016
  19. Junio C HamanoSep 11, 2016
  20. Thomas GummererSep 12, 2016
  21. 3/4 read-cache: introduce chmod_index_entryThomas Gummerer, Sep 11, 2016
  22. 4/4 add: modify already added files when --chmod is givenThomas Gummerer, Sep 11, 2016
  23. 0/4 git add --chmod: always change the fileThomas Gummerer, Sep 12, 2016
  24. 1/4 add: document the chmod optionThomas Gummerer, Sep 12, 2016
  25. 2/4 update-index: use the same structure for chmod as addThomas Gummerer, Sep 12, 2016
  26. Junio C HamanoSep 12, 2016
  27. 3/4 read-cache: introduce chmod_index_entryThomas Gummerer, Sep 12, 2016
  28. 4/4 add: modify already added files when --chmod is givenThomas Gummerer, Sep 12, 2016
  29. Junio C HamanoSep 12, 2016
  30. 0/4 git add --chmod: always change the fileThomas Gummerer, Sep 14, 2016
  31. 1/4 add: document the chmod optionThomas Gummerer, Sep 14, 2016
  32. 2/4 update-index: add test for chmod flagsThomas Gummerer, Sep 14, 2016
  33. 3/4 read-cache: introduce chmod_index_entryThomas Gummerer, Sep 14, 2016
  34. Junio C HamanoSep 14, 2016
  35. Junio C HamanoSep 14, 2016
  36. Thomas GummererSep 15, 2016
  37. 4/4 add: modify already added files when --chmod is givenThomas Gummerer, Sep 14, 2016
  38. Junio C HamanoSep 14, 2016
  39. René ScharfeAug 7, 2017
  40. Thomas GummererAug 12, 2017

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.