git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: "git add -u" broken in git 1.7.4?

From
SZEDER Gábor <szeder@ira.uka.de>
Date
Feb 7, 2011, 18:34 UTC
Message-ID
<20110207183412.GB1900@neumann>
In-Reply-To
<7vhbcguytf.fsf@alter.siamese.dyndns.org>
On Sun, Feb 06, 2011 at 10:46:20PM -0800, Junio C Hamano wrote:
Show 36 quoted lines
> Jeff King <peff@peff.net> writes:
> 
> > Is "git add -p" broken, then? It takes pathspecs relative to the current
> > directory, but "git add -p" without arguments operates from the root,
> > not from the current subdirectory.
> 
> I would say so; "add -p" was an ill-executed afterthought.  The codepath
> was originally meant to be used from "-i" as the top-level interface that
> was a fully interactive way to prepare for the next commit, which is an
> operation that is inherently full-tree.
> 
> There are two schools of thought in previous threads discussing full-tree
> vs current-directory-relative.  I think each side has merits.
> 
> If we defaulted to the current directory (i.e. "git grep"), that would
> feel more natural as it is more consistent with how tools that are not git
> aware (e.g. "GNU grep" run in the same directory) behave.  A downside is
> when you are somewhere deep in a working tree, you have to know how deep
> you are and repeat "../" that many times, i.e. "git grep pattern ../../"
> 
> If we defaulted to the root-level (i.e. "git diff"), you do not have that
> downside (iow, "git diff" run from a deep directory is a full tree
> operation), and you can limit the scope to the current directory by a
> single dot, i.e. "git diff .".  A huge downside is that this may feel
> awkward for new people who do not yet breath git [*1*], as no other git
> aware tool would behave like this, limiting its scope to some directory
> that is higher above.
> 
> In the past, I have took the third position, saying that tools that
> semantically needs to be full-tree should be full-tree (i.e. ones that
> make or format commits), and others should be relative to the current
> directory (i.e. ones that are used to inspect your progress, such as
> grep), but that is not a very understandable guideline that people can
> easily follow.  If we have to choose between the two and make things
> consistent, my personal preference is to make everything relative to the
> current working directory.

_Everything_ relative to the current working directory? I can't imagine how would that work in practice. Could you explain what would the following commands do, for example, when they are relative to the current working directory?

  $ cd t
  $ git checkout next
  $ git merge somebranch
  $ git reset HEAD^

Best, Gábor

Previous: Nguyen Thai Ngoc DuyNext: Junio C Hamano
Message 11 of 34 in “"git add -u" broken in git 1.7.4?”
  1. Sebastian PippingFeb 6, 2011
  2. Jeff KingFeb 6, 2011
  3. Sebastian PippingFeb 6, 2011
  4. Matthieu MoyFeb 6, 2011
  5. SZEDER GáborFeb 6, 2011
  6. Sebastian PippingFeb 6, 2011
  7. Junio C HamanoFeb 7, 2011
  8. Jeff KingFeb 7, 2011
  9. Junio C HamanoFeb 7, 2011
  10. Nguyen Thai Ngoc DuyFeb 7, 2011
  11. SZEDER GáborFeb 7, 2011
  12. Junio C HamanoFeb 7, 2011
  13. Jeff KingFeb 7, 2011
  14. SZEDER GáborFeb 8, 2011
  15. Jeff KingFeb 9, 2011
  16. Junio C HamanoFeb 9, 2011
  17. Jeff KingFeb 9, 2011
  18. Nguyen Thai Ngoc DuyFeb 10, 2011
  19. Jeff KingFeb 10, 2011
  20. Junio C HamanoFeb 10, 2011
  21. Johannes SixtFeb 10, 2011
  22. Joshua JuranFeb 10, 2011
  23. Matthieu MoyFeb 10, 2011
  24. command-list.txt: mark git-archive plumbingNguyen Thai Ngoc Duy, Feb 15, 2011
  25. Junio C HamanoFeb 15, 2011
  26. Nguyen Thai Ngoc DuyFeb 16, 2011
  27. Matthieu MoyFeb 7, 2011
  28. Jeff KingFeb 7, 2011
  29. Junio C HamanoFeb 7, 2011
  30. Eric RaibleFeb 8, 2011
  31. Junio C HamanoFeb 8, 2011
  32. Matthieu MoyFeb 7, 2011
  33. Michael J GruberFeb 7, 2011
  34. SZEDER GáborFeb 7, 2011

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.