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

Re: [PATCH/RFC] commit: new option to abort -a something is already staged

From
Jonathan Nieder <jrnieder@gmail.com>
Date
Aug 23, 2018, 02:11 UTC
Message-ID
<20180823021156.GD92374@aiede.svl.corp.google.com>
In-Reply-To
<CACsJy8DsEhV6p=cE6FC6Ka4=E0c-8JG0LRU_DEq-Ser5PqMcGw@mail.gmail.com>
Duy Nguyen wrote:
> On Mon, Aug 20, 2018 at 9:30 PM Jonathan Nieder <jrnieder@gmail.com> wrote:
Show 13 quoted lines
>> I frequently use "git commit -a" this way intentionally, so I would be
>> unlikely to turn this config on.  That leads me to suspect it's not a
>> good candidate for configuration:
>>
>> - it's not configuration for the sake of a transition period, since some
>>   people would keep it on forever
>>
>> - it's not configuration based on different project needs, either
>>
>> So configuration doesn't feel like a good fit.
>
> I think it falls under personal preference (yes some people like me
> will keep it on forever in fear of losing staged changes).

Sorry for the lack of clarity. I meant "some people would keep it off forever".

>> That said, I lean toward your initial thought, that this is papering
>> over a missing undo feature.  Can you say more about how you'd imagine
>> undo working?
[...]
> [1] https://public-inbox.org/git/1375597720-13236-1-git-send-email-pclouds@gmail.com/
> [2] https://public-inbox.org/git/1375966270-10968-1-git-send-email-pclouds@gmail.com/
Thanks for the links!  That's very helpful.

I'm starting to lean toward having this on unconditionally, with a message that points the user who really doesn't want to clobber their index toward "git add -u", as a good idea. I think that for humans, that would be okay and that configuration doesn't really help much for this.

The remaining question becomes scripts.  A script might do
	... modify old-file and create new-file ...
	git add new-file
	git commit -m "some great message"

which would trip this error. For that matter, humans might do that, too. Could the check detect this case (where the only changes in the index are additions of new files) and treat it as non-destructive?

Thanks, Jonathan

Previous: Duy NguyenNext: Jonathan Nieder
Message 6 of 28 in “commit: new option to abort -a something is already staged”
  1. commit: new option to abort -a something is already stagedNguyễn Thái Ngọc Duy, Aug 20, 2018
  2. Junio C HamanoAug 20, 2018
  3. Eric SunshineAug 20, 2018
  4. Jonathan NiederAug 20, 2018
  5. Duy NguyenAug 21, 2018
  6. Jonathan NiederAug 23, 2018
  7. Jonathan NiederAug 23, 2018
  8. Duy NguyenAug 23, 2018
  9. Junio C HamanoAug 23, 2018
  10. Jacob KellerAug 24, 2018
  11. Duy NguyenAug 24, 2018
  12. Jacob KellerAug 24, 2018
  13. Jacob KellerAug 24, 2018
  14. 0/1 Make 'git commit' not accidentally lose staged contentNguyễn Thái Ngọc Duy, Sep 16, 2018
  15. 1/1 commit: do not clobber the indexNguyễn Thái Ngọc Duy, Sep 16, 2018
  16. Junio C HamanoSep 17, 2018
  17. Duy NguyenSep 17, 2018
  18. Jeff KingSep 17, 2018
  19. Duy NguyenSep 17, 2018
  20. Jeff KingSep 18, 2018
  21. Jacob KellerSep 18, 2018
  22. Jeff KingSep 18, 2018
  23. Duy NguyenSep 19, 2018
  24. Jeff KingSep 19, 2018
  25. Junio C HamanoSep 17, 2018
  26. Jacob KellerSep 18, 2018
  27. Eckhard MaaßSep 18, 2018
  28. Jacob KellerSep 18, 2018

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.