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

Re: [PATCH v2 8/9] stash show: teach --include-untracked and --only-untracked

From
Denton Liu <liu.denton@gmail.com>
Date
Feb 16, 2021, 03:15 UTC
Message-ID
<YCs46VzamjuDrQR9@generichostname>
In-Reply-To
<xmqqa6sc4avx.fsf@gitster.c.googlers.com>
Hi Junio,
On Tue, Feb 09, 2021 at 11:53:06PM -0800, Junio C Hamano wrote:
Show 14 quoted lines
> > Do this via something like
> >
> > 	GIT_INDEX_FILE=... git read-tree stash stash^3
> >
> > and diffing the resulting tree object against the stash base.
> 
> That explains the implementation, but does not make it clear what
> the implementation wants to achieve.  So we read the tree from stash
> (i.e. working tree) into a temporary index, and then overlay the
> tree of stash^3 (i.e. untracked) on top---which means the resulting
> "index" has the state of the working tree plus the untracked cruft
> in it.  And comparing that with "stash base" (by the way is that a
> term well understood?  I borrowed it for the above review comment,
> which shows that there certainly is need for such a term) would show

I'm not sure if it's a well-understood term but I can't think of any other meanings for the term so it doesn't seem very ambiguous.

Show 11 quoted lines
> the diff between the "HEAD" and the state that would have result if
> you were to do an "git add ." in the working tree.  OK.
> 
> > One improvement that this could use for the future is performing the
> > action without writing anything to disk as one would expect this to be a
> > read-only operation. This can be fixed in the future, however.
> 
> Is it so difficult that we have to delay the fix for "the future"?
> After reading two trees into an in-core index, without writing it
> out to any file, all that remains to be done is just a matter of
> running diff-lib.c::do_diff_cache(), no?  I must be missing something.q

No, I don't think it's difficult. It's just my inexperience with this area of the code.

Show 8 quoted lines
> > Another limitation of this is that it would be possible to manually
> > craft a stash entry where duplicate untracked files in the stash entry
> > will mask tracked files. This seems like an instance of "Doctor, it
> > hurts when I do this! So don't do that!" so this can be written off.
> 
> Well, when you read the second tree into the in-core index to
> overlay what you read from the working tree state, you can certainly
> report the collision and error it out.

I'll send out my revised patch later today and I was unable to figure out an easy way of doing this.

Thanks, Denton

Previous: Junio C HamanoNext: Junio C Hamano
Message 28 of 45 in “stash show: learn --include-untracked and --only-untracked”
  1. 0/9 stash show: learn --include-untracked and --only-untrackedDenton Liu, Feb 2, 2021
  2. 1/9 git-stash.txt: be explicit about subcommand optionsDenton Liu, Feb 2, 2021
  3. Eric SunshineFeb 2, 2021
  4. 4/9 t3905: remove nested git in command substitutionDenton Liu, Feb 2, 2021
  5. 2/9 t3905: remove spaces after redirect operatorsDenton Liu, Feb 2, 2021
  6. 3/9 t3905: move all commands into test casesDenton Liu, Feb 2, 2021
  7. Junio C HamanoFeb 2, 2021
  8. 5/9 t3905: replace test -s with test_file_not_emptyDenton Liu, Feb 2, 2021
  9. 8/9 stash show: teach --include-tracked and --only-untrackedDenton Liu, Feb 2, 2021
  10. Junio C HamanoFeb 2, 2021
  11. 9/9 stash show: learn stash.showIncludeUntrackedDenton Liu, Feb 2, 2021
  12. 7/9 stash: declare ref_stash as an arrayDenton Liu, Feb 2, 2021
  13. Junio C HamanoFeb 2, 2021
  14. 6/9 t3905: use test_cmp() to check file contentsDenton Liu, Feb 2, 2021
  15. 0/9 stash show: learn --include-untracked and --only-untrackedDenton Liu, Feb 9, 2021
  16. 1/9 git-stash.txt: be explicit about subcommand optionsDenton Liu, Feb 9, 2021
  17. Junio C HamanoFeb 10, 2021
  18. fixup! git-stash.txt: be explicit about subcommand optionsDenton Liu, Feb 11, 2021
  19. 2/9 t3905: remove spaces after redirect operatorsDenton Liu, Feb 9, 2021
  20. Junio C HamanoFeb 10, 2021
  21. 3/9 t3905: move all commands into test casesDenton Liu, Feb 9, 2021
  22. 4/9 t3905: remove nested git in command substitutionDenton Liu, Feb 9, 2021
  23. Junio C HamanoFeb 10, 2021
  24. 5/9 t3905: replace test -s with test_file_not_emptyDenton Liu, Feb 9, 2021
  25. 6/9 t3905: use test_cmp() to check file contentsDenton Liu, Feb 9, 2021
  26. 8/9 stash show: teach --include-untracked and --only-untrackedDenton Liu, Feb 9, 2021
  27. Junio C HamanoFeb 10, 2021
  28. Denton LiuFeb 16, 2021
  29. Junio C HamanoFeb 16, 2021
  30. 7/9 stash: declare ref_stash as an arrayDenton Liu, Feb 9, 2021
  31. Junio C HamanoFeb 10, 2021
  32. 9/9 stash show: learn stash.showIncludeUntrackedDenton Liu, Feb 9, 2021
  33. 0/2 stash show: learn --include-untracked and --only-untrackedDenton Liu, Feb 16, 2021
  34. 1/2 stash show: teach --include-untracked and --only-untrackedDenton Liu, Feb 16, 2021
  35. Junio C HamanoFeb 16, 2021
  36. Denton LiuFeb 17, 2021
  37. Junio C HamanoFeb 17, 2021
  38. Junio C HamanoFeb 17, 2021
  39. 2/2 stash show: learn stash.showIncludeUntrackedDenton Liu, Feb 16, 2021
  40. 0/2 stash show: learn --include-untracked and --only-untrackedDenton Liu, Mar 3, 2021
  41. 2/2 stash show: learn stash.showIncludeUntrackedDenton Liu, Mar 3, 2021
  42. 1/2 stash show: teach --include-untracked and --only-untrackedDenton Liu, Mar 3, 2021
  43. Junio C HamanoMar 4, 2021
  44. Denton LiuMar 4, 2021
  45. Denton LiuMar 4, 2021

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.