git@vger.kernel.org mailing list mirror (one of many)
 help / color / mirror / code / Atom feed
From: Josef Weidendorfer <Josef.Weidendorfer@gmx.de>
To: Junio C Hamano <junkio@cox.net>
Cc: git@vger.kernel.org, Johannes Schindelin <Johannes.Schindelin@gmx.de>
Subject: Re: [PATCH] git-add --interactive (wip)
Date: Wed, 13 Dec 2006 04:15:58 +0100	[thread overview]
Message-ID: <200612130415.59038.Josef.Weidendorfer@gmx.de> (raw)
In-Reply-To: <7vwt4wpytm.fsf@assigned-by-dhcp.cox.net>

On Tuesday 12 December 2006 22:51, Junio C Hamano wrote:
> I've updated my "git add --interactive" in 'pu' and it now knows
> how to split a hunk into smaller pieces and recounting the diff
> offsets before applying

Nice.
Yes, this seems to be a missing piece in this hunk-wise staging.

> To make it easier, one possibility might be to add a subcommand
> to "git add --interactive" that lets you edit what is currently
> staged in the index by opening a temporary copy in your favorite
> editor, and stage the result of your edit in the index.

Yes. Sounds interesting.
Another would be to open the editor with the diff of this hunk.

> But I 
> feel quite uneasy to introduce ways to update the index with
> something _wildly_ different from what you ever had in your
> working tree as a whole.

Hmm... yes.
Is this not a general problem with staging, of course to
a lesser degree if you work at file granularity, because
the probability of dependence of changes in multiple files,
which could lead to a wrong commit, is less.

> I think it is wrong to commit partially, purely from the index,
> when you are building a series that has complex changes that
> come during the series but go away at the end.  The user should
> be able to verify all the steps in the middle in such a complex
> series, but it is not easy if you have it only in the index.

What you really want is to test the commit afterwards. If
you did it wrong, you always can do "git reset --mixed HEAD^"
or "git commit --amend".

However, testing a commit with a dirty working tree is not
possible. For this to work, you would want that
"git-checkout --store" can store away a dirty working state when
going to another revision, e.g. store it into a temporary ref
"<current branch>.dirtywork".
You would need a "git-checkout --restore" which would restore
the dirty state of the branch you are switching too.

Then, to check the commit of staged things, it should be enough
to do "git-checkout --store", check the commit, and do a
"git-checkout --restore" afterwards to get the dirty state back.

> You could do
> 
> 	$ git checkout-index --prefix=testarea/ -f -q -u -a
> 
> and run your tests there, but that takes a discipline, and is
> cumbersome to do.

IMHO that is too tricky for the average git user.

> So in short, I think per-hunk update-index is a cute hack and
> may be useful in a narrow simple cases, but it would not be so
> useful in the real life.

No. It currently is starting to get useful. With the ability
to temporarily store away a dirty state of the working directory,
it really could become very good.
 
> > Just as a sidenote: after deciding to not apply hunks, you
> > lose them in this WIP, as you will find nothing in "unstaged" mode
> > afterwards :-(
> 
> I do not understand this part.  You can 'revert' to match the
> index to HEAD and run 'patch' to pick what you want again.

Hmmm...
I lost my changes in the working directory; there was nothing to
pick again any more.
Perhaps I did something wrong.


  parent reply	other threads:[~2006-12-13  3:23 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-08 12:36 git-commit: select which files to commit while editing the commit message Pazu
2006-12-08 19:18 ` Junio C Hamano
2006-12-08 19:32   ` Jakub Narebski
2006-12-08 20:45     ` Luben Tuikov
2006-12-08 22:10       ` Josef Weidendorfer
2006-12-08 23:59         ` Seth Falcon
2006-12-09  0:07           ` Jakub Narebski
2006-12-09  0:37             ` Seth Falcon
2006-12-09  0:59               ` Junio C Hamano
2006-12-10  0:46                 ` Josef Weidendorfer
2006-12-10  0:54                   ` Junio C Hamano
2006-12-11  9:23                     ` [PATCH] git-add --interactive (wip) Junio C Hamano
2006-12-11 10:47                       ` Josef Weidendorfer
2006-12-12 21:51                         ` Junio C Hamano
2006-12-12 22:15                           ` Johannes Schindelin
2006-12-13  9:20                             ` Andreas Ericsson
2006-12-13  3:15                           ` Josef Weidendorfer [this message]
2006-12-13  5:34                             ` Junio C Hamano
2006-12-13 10:42                               ` Johannes Schindelin
2006-12-13 10:57                                 ` Shawn Pearce
2006-12-13 11:20                                   ` Johannes Schindelin
2006-12-13 20:31                               ` Josef Weidendorfer
2006-12-09  7:02   ` git-commit: select which files to commit while editing the commit message Sean

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=200612130415.59038.Josef.Weidendorfer@gmx.de \
    --to=josef.weidendorfer@gmx.de \
    --cc=Johannes.Schindelin@gmx.de \
    --cc=git@vger.kernel.org \
    --cc=junkio@cox.net \
    /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).