git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Nicolas Pitre <nico@cam.org>
To: Carl Worth <cworth@cworth.org>
Cc: Junio C Hamano <junkio@cox.net>,
	Peter Baumann <Peter.B.Baumann@stud.informatik.uni-erlangen.de>,
	git@vger.kernel.org
Subject: Re: Separating "add path to index" from "update content in index"
Date: Fri, 22 Dec 2006 00:06:32 -0500 (EST)	[thread overview]
Message-ID: <Pine.LNX.4.64.0612212337180.18171@xanadu.home> (raw)
In-Reply-To: <87d56cirs8.wl%cworth@cworth.org>

On Thu, 21 Dec 2006, Carl Worth wrote:

> So, I think what I really want here is a complete separation in the
> interface between adding a path to the index and updating content into
> the index.

Strangely enough I think this separation is unnecessary and redundent.

> We've long had a command that updates content to the index, and it
> takes a command-line option (--add) to allow it to first do the
> necessary path addition as well.

And it is still there.

> The symmetry I would like is if we
> had a command, ("git add", say), that just did the path addition and
> could accept a command-line option (--update, say) to get it to the
> the updating of the content as well.

And you can do just that with git-update-index.

> And I think that any talk about "git cannot accept a file name without
> content" is misplaced. The proposal here does not change any internal
> models of git. I'm talking about an interface issue, and if the
> interface isn't helping the user then it's wrong. That "git diff"
> usually shows me what I've just typed but I can't (easily[*]) get it
> to do that when I'm adding a new file is really annoying.

The problem lies with the git-diff interface then, not git-add.

> [*] Well, I could get it to do that by carefully creating the file,
> running "git add" immediately, and only _then_ going on to type
> content into the file. But that's not how I work. I do a bunch of file
> manipulations without thinking about git at all, and then when I'm
> happy with that, only then do I want to turn to git and use "git add",
> "git diff", and "git commit" to get the results I want.
> 
> So I suppose I could implement the "add path without updating content"
> I want by doing something like:
> 
> 	mv file file.tmp
> 	touch file
> 	git update-index --add file
> 	mv file.tmp file
> 
> There. That gives me the result I want without breaking any git
> internals, (since I'm just building a new operation on top of existing
> git primitives).
> 
> > Carl talks about would be useful in practice.  I do not know
> > what the option should be called.
> >
> > 	"git add --modified"?
> >         "git add --tracked"?
> >         "git add --updated"?
> >
> > It would work in the same way as the pre-commit step of "git
> > commit -a".
> 
> I think the best would be:
> 
> 	git update-index --all
> 
> which would still allow room for:
> 
> 	git add --all
> 
> as a consistent way to get at the current behavior of "git add .".

There is no consistency needed between git-add and git-update-index.  
The first is for users while the second is more suited for scripting 
your own interface.

> So here I'm arguing against "git add" being a more convenient synonym
> for "git update-index". I still think it would be nice to have a more
> convenient synonym. I've proposed "stage" before but that wasn't well
> accepted. Just shortening "update-index" to "update" would be
> problematic as many other RCSs use "update" as a way of picking up new
> content that has become available on the remote end. So, the best
> suggestion I have at this point is "refresh". So I'd be happy if
> either:
> 
> 	git refresh --add
> or:
> 	git add --refresh
> 
> would provide the behavior that currently is provided by "git add",
> (that is, add a new path to the index and update the content of that
> path in the index from the content of the named file in the working
> tree). But it would be great if "git add" without the --refresh would
> add the path without updating the content.

I think you are trying to solve the wrong problem, or at least solve a 
problem the wrong way.  The problem is that git-diff doesn't give you 
the output you expect because of the index interfering in your work 
flow.  And I understand that.

But the best solution is really for git-diff to have a mode where you 
could display a diff between the work tree and the index, _or_ the index 
and HEAD, for each file listed in the index while giving priority to the 
former.

This would let you see a diff of everything that would be committed, 
including new files, if you were to do commit -a.  Maybe -a/--all should 
be used with git-diff for such a mode by symetry with git-commit -a. (OK 
-a is already taken but I doubt it is really used and it already has a 
longer equivalent so changing it would not do real harm).

With this, for users acustomed to "commit -a", the natural and pretty 
consistent way to see a diff for such a commit before actually 
performing it would bi "diff -a".  Isn't it logical?


Nicolas

  parent reply	other threads:[~2006-12-22  5:07 UTC|newest]

Thread overview: 22+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2006-12-19 20:33 GIT - error: no such remote ref refs/heads/TestBranch Sean Kelley
2006-12-19 22:06 ` Junio C Hamano
2006-12-20 22:31   ` Carl Worth
2006-12-20 22:36     ` Junio C Hamano
2006-12-20 22:57       ` Carl Worth
2006-12-20 23:36         ` Junio C Hamano
2006-12-21  6:55           ` Carl Worth
2006-12-21 10:49             ` Peter Baumann
2006-12-22  0:52               ` Junio C Hamano
2006-12-22  2:32                 ` Separating "add path to index" from "update content in index" Carl Worth
2006-12-22  3:06                   ` Sean
2006-12-22  5:06                   ` Nicolas Pitre [this message]
2006-12-22 21:57                     ` Carl Worth
2006-12-23  5:27                       ` Nicolas Pitre
2006-12-24 21:38                         ` Daniel Barkalow
2006-12-22  5:10                   ` Junio C Hamano
2006-12-22  5:21                     ` Shawn Pearce
2006-12-22  8:24                     ` Jakub Narebski
2006-12-22 16:18                     ` Carl Worth
2006-12-22 17:28                       ` Nicolas Pitre
2006-12-22 16:55                     ` Carl Worth
2006-12-23  2:56                     ` Daniel Barkalow

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

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

  git send-email \
    --in-reply-to=Pine.LNX.4.64.0612212337180.18171@xanadu.home \
    --to=nico@cam.org \
    --cc=Peter.B.Baumann@stud.informatik.uni-erlangen.de \
    --cc=cworth@cworth.org \
    --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.
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 NNTP newsgroup(s).