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

Re: RFC: git status --amend

From
Jeff King <peff@peff.net>
Date
Apr 3, 2015, 22:05 UTC
Message-ID
<20150403220546.GA14195@peff.net>
In-Reply-To
<20150403215744.GA39695@gmail.com>
On Fri, Apr 03, 2015 at 02:57:48PM -0700, David Aguilar wrote:
Show 16 quoted lines
> > But I discarded it as a useless suggestion before writing it down,
> > primarily because I couldn't come up with an explanation _why_ being
> > able to say "git status --relative-to=next Makefile" is useful when
> > on the 'master' branch.
> 
> Aesthetically it's appealing because it mirrors commands like
> "git diff HEAD^", etc.
> 
> I can see it being useful for script writers but it's a minority
> case that's already handled by having "status --amend" for the
> common case of needing to mimic "commit --amend".
> 
> Beyond that use case, someone could use it to write a butchery
> tool that gets a quick high-level diff of changes for both index
> and worktree against an arbitrary ref, and then apply those
> changes selectively using other git tools.

Hmm. What if you had a tool that created commits out of an alternate working tree and index, and then committed directly to a branch without touching HEAD? Then you might run:

  GIT_WORK_TREE=... GIT_INDEX_FILE=... git status --relative-to=mybranch
right before running:
  old=$(git rev-parse refs/heads/mybranch) &&
  tree=$(GIT_INDEX_FILE=... git commit-tree) &&
  commit=$(echo whatever | git commit-tree -p $old $tree) &&
  git update-ref refs/heads/mybranch $old

or similar. That is basically "git-new-workdir", but with no per-workdir HEAD. Which is probably crazy, but maybe useful for a one-off commit to another branch or something.

I dunno. I do not have such a tool or plan to work on one, but it is at least plausible to me.

-Peff
Previous: David Aguilar
Message 7 of 7 in “RFC: git status --amend”
  1. Sven StrickrothMar 31, 2015
  2. Jeff KingMar 31, 2015
  3. Junio C HamanoMar 31, 2015
  4. David AguilarApr 1, 2015
  5. Junio C HamanoApr 1, 2015
  6. David AguilarApr 3, 2015
  7. Jeff KingApr 3, 2015

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.