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

Re: git add -i doesn't update permissions

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 27, 2008, 16:08 UTC
Message-ID
<7vfxucb15o.fsf@gitster.siamese.dyndns.org>
In-Reply-To
<20080327055746.GA8469@coredump.intra.peff.net>
Jeff King <peff@peff.net> writes:
> Now, if you are interested in adding the mode change of a file but _not_
> its content, I think that is a reasonable thing to ask for. And it's
> something that is not possible with "add -i" right now, I don't think.

It's worse than that. It _theoretically_ is possible that this limitation becomes problematic if you are in this situation:

 1. Notice a problem in the gostak script that it should distim doshes but
    it doesn't.
 2. Start working to change the gostak script.
 3. Notice that the gistak script itself needs the +x bit but it doesn't.
 4. Being a very disciplined person, you want to make sequence of commits
    that record each separate logical change as a separate commit.  You
    would want to record "Add executable bit to the gostak script" first,
    and then work further on the contents of the script to make "Enhance
    the gostak script to distim doshes" as two logically separate steps.
	
This is not something you can do with "git add" in general, although I do
not see how this can be an issue in real life.
Two already available solutions are:
 (1) git reset HEAD -- gostak ;# undo staged content changes
     git update-index --chmod=+x gostak
     git commit -m "Add executable bit to the gostak script"
     edit gostak ;# work more
     git add gostak
     git commit -m "Enhance the gostak script to distim doshes"
 (2) git stash ;# undo changes
     chmod +x gostak
     git add gostak
     git commit -m "Add executable bit to the gostak script"
     git stash pop ;# take the wip changes back
     edit gostak ;# work more
     git add gostak
     git commit -m "Enhance the gostak script to distim doshes"
Previous: Wincent Colaiuta
Message 5 of 5 in “git add -i doesn't update permissions”
  1. Jörg SommerMar 26, 2008
  2. Jeff KingMar 27, 2008
  3. Jeff KingMar 27, 2008
  4. Wincent ColaiutaMar 27, 2008
  5. Junio C HamanoMar 27, 2008

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.