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

Re: [RFC/PATCH] git put: an alternative to add/reset/checkout

From
Junio C Hamano <gitster@pobox.com>
Date
Jun 7, 2011, 21:04 UTC
Message-ID
<7vvcwh4ako.fsf@alter.siamese.dyndns.org>
In-Reply-To
<20110607200659.GA6177@sigill.intra.peff.net>
Jeff King <peff@peff.net> writes:
> As you can see, this handles only three typoes of locations: the
Is that a recursive typo, or a typo of type?
> worktree, the index, and an arbitrary commit (really a tree-ish).
> Some other types I've thought of are:
>
>   - stashes; you can already use stashes a source with "stash@{0}". They
>     could also be a destination, chaining to "git stash".
No opinion on this.
Show 13 quoted lines
>   - branches as destinations; obviously we can't change an existing
>     commit, but what about something like:
>
>       git put WORKTREE BRANCH:foo
>
>     to optionally create a new branch "refs/heads/foo" based on the
>     current HEAD, push changes into a temporary index that matches its
>     tip, and then making a new commit based on top.
>
>     This would serve a similar purpose to stashes, except that they
>     would be named and could operate as full branches. I would find it
>     useful for picking apart a mass of worktree changes into discrete
>     commits.
Should "git put WORKTREE HEAD" be equivalent to "git commit -A" then?
>   - allow multiple destinations, like
>
>      # equivalent to "git checkout --"
>      git put HEAD INDEX,WORKTREE
This is close to going overboard, but OK.
Show 13 quoted lines
>   - blobs as locations. We could allow something like:
>
>       git put v1.7.5:Makefile WORKTREE:Makefile
>
>     which would be equivalent to
>
>       git put v1.7.5 WORKTREE -- Makefile
>
>     but sometimes matches the user's mental model better. It also allows
>     pulling blobs from index stages, like:
>
>       # Resolve in favor of "ours"
>       git put :2:Makefile INDEX,WORKTREE
More importantly, it would allow people to do things like...
	git put v1.7.5:Makefile WORKTREE:oMakefile
        magicdiff oMakefile Makefile
>   - subtrees as locations. This allows a form of renaming between old
>     versions.
>
>       git put gitgui-0.10.0: WORKTREE:git-gui
This is a natural extension of the above "we could rename" theme, right?
> ...  Of course, it may also just introduce insane
> confusion.

The only worry about confusion is if people incorrectly think these magic tokens are not mere syntax sugars available only in "put", especially, they look so similar to "HEAD" which is _not_ syntax sugar and can be used elsewhere. Other than that, I think this is a nice approach.

Previous: Jeff KingNext: Jeff King
Message 2 of 18 in “git put: an alternative to add/reset/checkout”
  1. git put: an alternative to add/reset/checkoutJeff King, Jun 7, 2011
  2. Junio C HamanoJun 7, 2011
  3. Jeff KingJun 7, 2011
  4. Michael NahasJun 8, 2011
  5. Jakub NarebskiJun 8, 2011
  6. Matthieu MoyJun 8, 2011
  7. Jeff KingJun 8, 2011
  8. Matthieu MoyJun 8, 2011
  9. Jakub NarebskiJun 8, 2011
  10. Matthieu MoyJun 8, 2011
  11. Jakub NarebskiJun 8, 2011
  12. Nguyen Thai Ngoc DuyJun 10, 2011
  13. Nguyen Thai Ngoc DuyJun 8, 2011
  14. Nguyen Thai Ngoc DuyJan 23, 2012
  15. Michael NahasJan 23, 2012
  16. Nguyen Thai Ngoc DuyJan 23, 2012
  17. Michael NahasJan 23, 2012
  18. Junio C HamanoJan 23, 2012

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.