All of lore.kernel.org
 help / color / mirror / Atom feed
From: Jeff King <peff@peff.net>
To: Junio C Hamano <gitster@pobox.com>
Cc: "SZEDER Gábor" <szeder@ira.uka.de>,
	"Matthieu Moy" <Matthieu.Moy@grenoble-inp.fr>,
	"Sebastian Pipping" <webmaster@hartwork.org>,
	"Git ML" <git@vger.kernel.org>
Subject: Re: "git add -u" broken in git 1.7.4?
Date: Wed, 9 Feb 2011 18:46:21 -0500	[thread overview]
Message-ID: <20110209234621.GA12575@sigill.intra.peff.net> (raw)
In-Reply-To: <7vipwsomq8.fsf@alter.siamese.dyndns.org>

On Wed, Feb 09, 2011 at 02:40:47PM -0800, Junio C Hamano wrote:

> > The most compelling I have seen is "you tend to notice accidental
> > full-tree sooner than accidental relative behavior". Which you mentioned
> > in your email.
> 
> Hmph.  You earlier mentioned "oops, I just pushed this commit and it turns
> out that I screwed up "git add" five minutes ago and it only had half of
> the files I intended" problem, but "oops, I just pushed this commit and it
> turns out that I screwed up "git add" five minutes ago and it had more
> changes than I intended" problem would be equally annoying, and I don't
> think one is inherently more likely to be noticed than the other; IOW, it
> is not compelling, but is just an arbitrary and a biased observation, no?

Yeah, thinking on it more, it is not so much that you notice sooner[1],
as the behavior may be less destructive when you do notice. That is,
accidentally adding too much has put things into the object db.
Accidentally not adding enough means your changes are susceptible to
"git reset --hard" or other destructive actions.

[1] I seem to remember this argument about noticing sooner coming up in
previous discussions, and so I was taking it for granted. But thinking
on it, I can't really come up with a solid reason why one might notice
errors sooner in full tree rather than relative behavior.

> Can somebody volunteer to come up with a comprehensive list of operations
> that will change their behaviour when we switch to "full-tree without
> pathspec" semantics?  We mentioned "grep" and "add -u" already.

I went through the whole list of "git help -a" and considered each
command. Quite a few don't take pathspecs, or would be very odd to be
not full-tree (e.g., read-tree reads the whole tree, not just some
subset based on where you are in the project. Anything else would be
kind of insane). I omitted those. If you don't see something in this
list, it's either because I thought it was irrelevant, or I just missed
it going through the list; feel free to mention more.

I think everything which takes a pathspec takes it relative to the
current directory. So we are really just considering the behavior when
_no_ pathspecs are provided.

The current behavior is:

  add:    error (and suggest "git add .")
  add -u: relative
  add -A: relative
  add -i: full-tree
  add -p: full-tree
  archive: relative
  checkout: full-tree (e.g., "git checkout -f")[1]
  checkout-index: n/a (only checks out arguments)
  clean: relative
  commit -a: full-tree[2]
  diff: full-tree
  diff-files: full-tree
  grep: relative
  ls-files: relative
  ls-tree: relative[3]
  status: shows full-tree, relative by default, absolute
          with status.relativePaths
  reset --hard: full-tree[4]
  log/show/etc: full-tree[5]
  blame: error[6]

Notes:

[1] checkout being full-tree without pathspecs is mostly due to "git
    checkout" meaning "switch to this branch" and not "checkout some part of
    the index". So naturally it is a full-tree operation.

[2] The inconsistency in "git commit -a" versus "git add -u" is to me
    one of the worst, as I think it is a useful mental model to think of
    "commit -a" as "add -u; commit".

[3] I can understand ls-files being relative, though I don't agree with
    it. But ls-tree looking at a relative subset of the tree is just
    insane (you were the one who pointed this out to me last time this
    subject came up, too).

[4] I think reset --hard is just a tree operation, since it is "set HEAD
    to this ref, check it out into the index, _and_ reset the worktree
    to match". So obviously it should be full-tree. But I think a common
    mental model, especially when resetting to HEAD implicitly, is that
    it is about "reset my working tree to the HEAD state". So I included
    it in this list.

[5] Revision traversal is not about the worktree at all, so it has
    always been about the full project. I don't think there's any
    argument there, but I put it in the list as a contrast to ls-tree,
    to which the same argument should apply.

[6] Blame obviously does nothing without a path right now. In theory it
    could eventually grow whole-directory blame. In that case, I would
    expect it to be full-tree (and "git blame ." would do what you
    want).

Assuming we move from relative to full-tree, I think the possible things
to move are:

  add -u/-A
  archive
  grep
  clean
  ls-files/ls-tree

I don't think it's worth moving ls-files/ls-tree. They're plumbing that
people don't use frequently. So the cost of moving them is high (because
we are breaking something meant to be scriptable) and the benefit is low
(because users don't type them a lot).

Obviously add and grep are the two that people have talked about. The
archive behavior surprised me, and I would think it should be full-tree
by default. But it is sort of plumbing-ish, in that people have probably
scripted around and people _don't_ tend to create archives a lot. So it
may fall into the same category as ls-files/ls-tree.

That leaves clean. I would say from a consistency standpoint that it
should go full-tree to match the other commands. But it is one of the
most destructive commands, and making it full-tree makes it easier to
accidentally delete, instead of accidentally fail to delete. So that
makes me hesitate to switch it to full-tree behavior (though a "clean
reflog" would be a pretty cool feature in general).

So depending on your view of the above, it may just be "add -u/-A" and
"grep" that are worth switching.

-Peff

  reply	other threads:[~2011-02-09 23:46 UTC|newest]

Thread overview: 34+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2011-02-06  0:39 "git add -u" broken in git 1.7.4? Sebastian Pipping
2011-02-06  5:13 ` Jeff King
2011-02-06 19:35   ` Sebastian Pipping
2011-02-06 20:48     ` Matthieu Moy
2011-02-06 23:19       ` SZEDER Gábor
2011-02-06 23:49         ` Sebastian Pipping
2011-02-07  5:50       ` Junio C Hamano
2011-02-07  5:53         ` Jeff King
2011-02-07  6:46           ` Junio C Hamano
2011-02-07  7:29             ` Nguyen Thai Ngoc Duy
2011-02-07 18:34             ` SZEDER Gábor
2011-02-07 19:31               ` Junio C Hamano
2011-02-07 19:50             ` Jeff King
2011-02-08 10:05               ` SZEDER Gábor
2011-02-09 21:03                 ` Jeff King
2011-02-09 22:40                   ` Junio C Hamano
2011-02-09 23:46                     ` Jeff King [this message]
2011-02-10  2:24                       ` Nguyen Thai Ngoc Duy
2011-02-10  2:31                         ` Jeff King
2011-02-10  2:46                           ` Junio C Hamano
2011-02-10  7:46                       ` Johannes Sixt
2011-02-10  8:13                       ` Joshua Juran
2011-02-10 18:00                       ` Matthieu Moy
2011-02-15  7:04                       ` [PATCH] command-list.txt: mark git-archive plumbing Nguyen Thai Ngoc Duy
2011-02-15 19:11                         ` Junio C Hamano
2011-02-16  9:32                           ` Nguyen Thai Ngoc Duy
2011-02-07 20:57             ` "git add -u" broken in git 1.7.4? Matthieu Moy
2011-02-07 21:02               ` Jeff King
2011-02-07 21:49                 ` Junio C Hamano
2011-02-08  1:25             ` Eric Raible
2011-02-08  2:16               ` Junio C Hamano
2011-02-07  6:48           ` Matthieu Moy
2011-02-07  8:27             ` Michael J Gruber
2011-02-07 11:15         ` SZEDER Gábor

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=20110209234621.GA12575@sigill.intra.peff.net \
    --to=peff@peff.net \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=szeder@ira.uka.de \
    --cc=webmaster@hartwork.org \
    /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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.