git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Duy Nguyen <pclouds@gmail.com>
To: Jonathan Nieder <jrnieder@gmail.com>
Cc: Git Mailing List <git@vger.kernel.org>
Subject: Re: [PATCH/RFC] commit: new option to abort -a something is already staged
Date: Tue, 21 Aug 2018 16:43:33 +0200	[thread overview]
Message-ID: <CACsJy8DsEhV6p=cE6FC6Ka4=E0c-8JG0LRU_DEq-Ser5PqMcGw@mail.gmail.com> (raw)
In-Reply-To: <20180820193007.GB31020@aiede.svl.corp.google.com>

On Mon, Aug 20, 2018 at 9:30 PM Jonathan Nieder <jrnieder@gmail.com> wrote:
>
> Hi,
>
> Nguyễn Thái Ngọc Duy wrote:
>
> > So many times I have carefully cherry picked changes to the index with
> > `git add -p` then accidentally did `git commit -am ....` (usually by
> > retrieving a command from history and pressing Enter too quickly)
> > which destroyed beautiful index.
> >
> > One way to deal with this is some form of `git undo` that allows me to
> > retrieve the old index.
>
> Yes, I would love such an undo feature!
>
> How would you imagine that this information would get stored?  We can
> start with adding that and a low-level (plumbing) interface to it, to
> avoid being blocked on getting the user-facing (porcelain) "git undo"
> interface right.  (Or we can go straight for the porcelain.  It's fine
> for it to start minimal and gain switches later.)

Yeah I'd love to see "git undo" too, but unfortunately I don't have a
clear model how it should operate. Which is why I still hesitate to
implement one. :P

All I have is something close to how undo is done in an editor, where
we could save a list of actions and corresponding undo ones, but
editors are wysiwyg and we can't just let the user undo, see the
result elsewhere and redo if they're not happy.

> > Instead, let's handle just this problem for now. This new option
> > commit.preciousDirtyIndex, if set to false, will not allow `commit -a`
> > to continue if the final index is different from the existing one. I
> > don't think this can be achieved with hooks because the hooks don't
> > know about "-a" or different commit modes.
>
> 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).

> 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?

There is not much to say. But at least to be able to undo changes in
the index, I made two attempts in the past [1] [2] (and forgot about
them until I got bitten by the lack of undo again this time). I guess
I could push for one of those approaches again because it will help me
and also lay the foundation for any git-undo in the future.

Once we have can restore index, undoing "git reset --hard" is also
possible (by hashing everything and putting them in a temporary index
first).

[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/
-- 
Duy

  reply	other threads:[~2018-08-21 14:44 UTC|newest]

Thread overview: 28+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2018-08-20 15:41 [PATCH/RFC] commit: new option to abort -a something is already staged Nguyễn Thái Ngọc Duy
2018-08-20 15:55 ` Junio C Hamano
2018-08-20 17:48 ` Eric Sunshine
2018-08-20 19:30 ` Jonathan Nieder
2018-08-21 14:43   ` Duy Nguyen [this message]
2018-08-23  2:11     ` Jonathan Nieder
2018-08-23  2:15       ` Jonathan Nieder
2018-08-23 14:49         ` Duy Nguyen
2018-08-23 15:28           ` Junio C Hamano
2018-08-24  3:02             ` Jacob Keller
2018-08-24 14:42               ` Duy Nguyen
2018-08-24 23:23                 ` Jacob Keller
2018-08-24  2:59 ` Jacob Keller
2018-09-16  6:31 ` [PATCH v2 0/1] Make 'git commit' not accidentally lose staged content Nguyễn Thái Ngọc Duy
2018-09-16  6:31   ` [PATCH v2 1/1] commit: do not clobber the index Nguyễn Thái Ngọc Duy
2018-09-17 17:09   ` [PATCH v2 0/1] Make 'git commit' not accidentally lose staged content Junio C Hamano
2018-09-17 17:29     ` Duy Nguyen
2018-09-17 18:15       ` Jeff King
2018-09-17 18:41         ` Duy Nguyen
2018-09-18 17:35           ` Jeff King
2018-09-18 19:36         ` Jacob Keller
2018-09-18 23:19           ` Jeff King
2018-09-19 16:12             ` Duy Nguyen
2018-09-19 16:16               ` Jeff King
2018-09-17 19:26       ` Junio C Hamano
2018-09-18 19:41         ` Jacob Keller
2018-09-18 21:11           ` Eckhard Maaß
2018-09-18 19:33     ` Jacob Keller

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

  List information: http://vger.kernel.org/majordomo-info.html

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to='CACsJy8DsEhV6p=cE6FC6Ka4=E0c-8JG0LRU_DEq-Ser5PqMcGw@mail.gmail.com' \
    --to=pclouds@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=jrnieder@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://80x24.org/mirrors/git.git

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for read-only IMAP folder(s) and NNTP newsgroup(s).