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

Re: suggestion: git status = restored

From
Junio C Hamano <gitster@pobox.com>
Date
Mar 29, 2011, 18:51 UTC
Message-ID
<7voc4trc8w.fsf@alter.siamese.dyndns.org>
In-Reply-To
<4D92179D.6050102@gmail.com>
Neal Kreitzinger <nkreitzinger@gmail.com> writes:
Show 5 quoted lines
> I see your point about the current worktree/index/HEAD.  I'm not a git
> developer, but my idea is based on the concept that the sha-1 of the
> content already exists in the object store regardless of its
> path(s). I'm talking about identical blob sha-1's, not "similar"
> content.

One thing you seem to be missing is that you would need to prove that a commit that had that blob existed in the ancestor of the commit you are standing on in order to call that restore. You cannot restore something that you didn't lose, and if you never had it in your history, there is no way you lost it in the first place. And that means you have to run around in the history potentially digging down to the root.

Also a file that happens to have the same content is not necessarily "restore". If you are using a boilerplate to start a new file in a verbose language, you may "git add" the initial state of such a file before you start adding your own lines (perhaps adding a real method implementation to a class), and then run another "git add" to record your changes. It wouldn't be surprising if such an initial snapshot for different paths were identical.

A more trivial example would be a .gitignore file that has '*.o'; that can appear in src/ and then in lib/ but the project may not want to have it at the toplevel of the source tree.

Previous: Neal KreitzingerNext: Matthieu Moy
Message 4 of 6 in “suggestion: git status = restored”
  1. Neal KreitzingerMar 25, 2011
  2. Jeff KingMar 29, 2011
  3. Neal KreitzingerMar 29, 2011
  4. Junio C HamanoMar 29, 2011
  5. Matthieu MoyMar 29, 2011
  6. Jeff KingMar 29, 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.