All of lore.kernel.org
 help / color / mirror / Atom feed
From: "SZEDER Gábor" <szeder@ira.uka.de>
To: Jeff King <peff@peff.net>
Cc: Junio C Hamano <gitster@pobox.com>,
	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: Tue, 8 Feb 2011 11:05:18 +0100	[thread overview]
Message-ID: <20110208100518.GA9505@neumann> (raw)
In-Reply-To: <20110207195035.GA13461@sigill.intra.peff.net>

On Mon, Feb 07, 2011 at 02:50:35PM -0500, Jeff King wrote:
> On Sun, Feb 06, 2011 at 10:46:20PM -0800, Junio C Hamano wrote:
> 
> > I actually do not mind too much myself if all commands that can take
> > pathspecs consistently defaulted to "full-tree" pathspec given no
> > pathspec.  But if we were to go that route, everybody should join their
> > voice to defend that decision when outside people say "in 1.8.0 'git grep'
> > run from a subdirectory shows matches from all the irrelevant parts of the
> > tree; with all the cruft its output is unreadable". I won't be the sole
> > champion of such a behaviour when I do not fully believe in it.
> 
> The problem is that I don't feel comfortable writing an RFC that says
> "in 1.8.0 we will default to full-tree because it is somehow better".
> Because I don't think it is better; it is simply a different way of
> thinking about it, and different people will have different preferences.
> 
> I think even the same people may different preferences from project to
> project. For most of my projects, the scope of the repo is well-defined,
> and I want full-tree semantics (e.g., I hack on a bug, go into t/ to
> tweak and run the tests, and then want to "git add -u" the whole thing
> when everything looks good). But I also recently worked on a gigantic
> project that was split into several sub-components. I would cd 3 or 4
> levels deep into the sub-component that I was working on, and I would
> prefer my "git add -u" to stay in that sub-component, and my "git grep"
> to look only in that sub-component.

It sounds like your work focused solely on the sub-component you cd-d
into.  Did you have any other changes outside of that sub-component?
Because when not, then both the current and the whole-tree "git add -u"
would have the same effect.

The current and the whole-tree "git grep" would behave differently, of
course.  But even then a whole-tree "git grep" would be harmless and
easy to limit in scope, though might be a bit annoying in the "cd deep
down" case.  In that case you would immediately see the matches
outside of cwd, know that you forgot to limit the operation to cwd, so
you hit the up key, simply append the "." to the last command, and you
get what you wanted.

As mentioned in this or other related threads, this is not at all that
simple the other way around, i.e. with current "git grep" when you are
in the sub-component and you happen to need a grep on the whole tree,
because you have to pay attention to use the right number of "../"s.

A whole-tree "git add -u" is just as easy to limit in scope as the
whole-tree "git grep" would be, but certainly more annoying when you
forget to limit it to cwd.  But even in that case there is no harm
done, because all the changes you've made are there, but you have to
unstage changes from the index or split the commit.

Current "git add -u" is worst of all, because it's not just difficult
to circumvent (how many "../" do I need?), but it's downright
dangerous, because you can lose changes when forget that it's limited
in scope.  I managed to do something like this while fixing two
already bisected bugs:

  git checkout deadbeef         # BugA was introduced in that commit
  vim git.c                     # fix BugA
  cd t
  test ; vim test ; test
  git add -u                    # again forgetting that a
                                # fundamentally whole-tree oriented 
                                # tool has operations with
                                # non-whole-tree defaults...
  git commit -m 'Fix BugA'      # will write proper commit msg later
  git branch fix_BugA           # to find the commit later
  git reset --hard babefeed     # instead of "git checkout babefeed"
                                # BugB was introduced there
                                # goodbye bugfix!
  # hack away to fix BugB       # until realisation sets in
  # Damn.

You could argue that there are several ways I could have prevented
shooting myself in the foot, e.g. using "git checkout" instead of "git
reset --hard", or by using plain "git commit" without the "-m" option
I might have noticed the unstaged changes in the commit template.  I
would even tend to agree, but I still think that git should be
consistent with _itself_ in the first place, and since git's
fundamental concepts are whole-tree oriented and there are many
commands that only make sense on the whole tree, defaulting to
whole-tree operations for commands taking a pathspec is indeed better.
And safer too.


Best,
Gábor

  reply	other threads:[~2011-02-08 10:05 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 [this message]
2011-02-09 21:03                 ` Jeff King
2011-02-09 22:40                   ` Junio C Hamano
2011-02-09 23:46                     ` Jeff King
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=20110208100518.GA9505@neumann \
    --to=szeder@ira.uka.de \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=git@vger.kernel.org \
    --cc=gitster@pobox.com \
    --cc=peff@peff.net \
    --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.