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

Re: [RFC PATCH v3 8/8] --sparse for porcelains

From
Junio C Hamano <gitster@pobox.com>
Date
Aug 17, 2009, 16:46 UTC
Message-ID
<7vvdkmwfqs.fsf@alter.siamese.dyndns.org>
In-Reply-To
<7vtz06xxao.fsf@alter.siamese.dyndns.org>
Junio C Hamano <gitster@pobox.com> writes:
Show 14 quoted lines
> Local changes in git do not belong to any particular branch.  They belong
> to the work tree and the index.  Hence you (1) can switch from branch A to
> branch B iff the branches do not have difference in the path with local
> changes, and (2) have to stash save, switch branches and then stash pop if
> you have local changes to paths that are different between branches you
> are switching between.
>
> How should assume-unchanged play with this philosophy?
>
> I'd say that assume-unchanged is a promise you make git that you won't
> change these paths, and in return to the promise git will give you faster
> response by not running lstat on them.  Having changes in such paths is
> your problem and you deserve these chanegs to be lost.  At least, that is
> the interpretation according to the original assume-unchanged semantics.

Having said that, we could (re)define assume-unchanged to mean "I may or may not have changes to these paths, but I do not mean to commit them, so do not show them as modified when I ask you for diff. But the changes are precious nevertheless".

I think the writeout codepath pays attention to assume-unchanged bit already for that reason (CE_MATCH_IGNORE_VALID is all about this issue).

So with that, how should assume-unchanged play with the "local changes belong to the index and the work tree"?

 - When adding to the index, the changes should be ignored;
 - When checking out of the index?  I.e. the user tells "git checkout
   path" when path is marked as assume-unchanged.  Such an explicit
   request should probably lose the local changes in the work tree.
 - When checking out of a commit?  The same deal.
 - When switching branches?
   - If the branches do not touch assume-unchanged paths, we should keep
     changes _and_ assume-unchanged bit.  I do not know if that is what
     the current code does.
   - If the branches do touch assume-unchanged paths, what should happen?
     We shouldn't blindly overwrite the local changes, so at least we
     should change the code to error out if we do not already do so.  But
     then what?  How does the user deal with this?  Perhaps...
     - Drop assume-unchanged temporarily;
     - Stash save;
     - Switch;
     - Stash pop;
     - Add assume-unchanged again.
     ???

Is such an updated (or "corrected") assume-unchanged any different from a sparse checkout? After all, paths that are not to be checked out in a sparse checkout are "pretend that the lack of these paths are illusion--they are logically there. I do not intend to commit their removal, and I do not want to lose the sparseness across branch switch".

There is one nit about this. If a path is outside the checkout area, should it unconditionally stay outside the checkout area when you switch branches? I may be interested in not checking out Documentation/ subdirectory and that may hold true for all _my_ branches, and it is a sane thing not to complain "Oops, you actually removed Makefile in Documentation/ in your work tree in reality, and you are switching to another branch that has a different Makefile --- it is a delete-modify conflict you need to resolve, and we won't let you switch branches" in such a case.

But is that generally true in all "sparse checkout" settings?

It is unfortunate that this message raises more questions than it answers, but I think a sparse checkout will have to answer them, whether it uses a bit separate from assume-unchanged or it reuses the assume-unchanged bit.

Previous: skillzero@gmail.comNext: Johannes Schindelin
Message 40 of 53 in “Sparse checkout”
  1. 0/8 Sparse checkoutNguyễn Thái Ngọc Duy, Aug 11, 2009
  2. 1/8 Prevent diff machinery from examining assume-unchanged entries on worktreeNguyễn Thái Ngọc Duy, Aug 11, 2009
  3. 2/8 Avoid writing to buffer in add_excludes_from_file_1()Nguyễn Thái Ngọc Duy, Aug 11, 2009
  4. 3/8 Read .gitignore from index if it is assume-unchangedNguyễn Thái Ngọc Duy, Aug 11, 2009
  5. 4/8 excluded_1(): support exclude "directories" in indexNguyễn Thái Ngọc Duy, Aug 11, 2009
  6. 5/8 dir.c: export excluded_1() and add_excludes_from_file_1()Nguyễn Thái Ngọc Duy, Aug 11, 2009
  7. 6/8 unpack-trees.c: generalize verify_* functionsNguyễn Thái Ngọc Duy, Aug 11, 2009
  8. 7/8 Support sparse checkout in unpack_trees() and read-treeNguyễn Thái Ngọc Duy, Aug 11, 2009
  9. 8/8 --sparse for porcelainsNguyễn Thái Ngọc Duy, Aug 11, 2009
  10. Junio C HamanoAug 12, 2009
  11. Nguyen Thai Ngoc DuyAug 12, 2009
  12. Nguyen Thai Ngoc DuyAug 13, 2009
  13. Jakub NarebskiAug 13, 2009
  14. Nguyen Thai Ngoc DuyAug 13, 2009
  15. Jakub NarebskiAug 14, 2009
  16. Junio C HamanoAug 15, 2009
  17. Jakub NarebskiAug 15, 2009
  18. Johannes SchindelinAug 16, 2009
  19. Johannes SchindelinAug 17, 2009
  20. Nguyen Thai Ngoc DuyAug 17, 2009
  21. Johannes SchindelinAug 17, 2009
  22. Nguyen Thai Ngoc DuyAug 17, 2009
  23. Johannes SchindelinAug 17, 2009
  24. Nguyen Thai Ngoc DuyAug 17, 2009
  25. Junio C HamanoAug 17, 2009
  26. Nguyen Thai Ngoc DuyAug 17, 2009
  27. Johannes SchindelinAug 17, 2009
  28. Junio C HamanoAug 17, 2009
  29. Johannes SchindelinAug 17, 2009
  30. skillzero@gmail.comAug 17, 2009
  31. Johannes SchindelinAug 17, 2009
  32. Jakub NarebskiAug 18, 2009
  33. skillzero@gmail.comAug 18, 2009
  34. Nguyen Thai Ngoc DuyAug 18, 2009
  35. git find (was: [RFC PATCH v3 8/8] --sparse for porcelains)Jakub Narebski, Aug 18, 2009
  36. Nguyen Thai Ngoc DuyAug 18, 2009
  37. Jakub NarebskiAug 18, 2009
  38. Jakub NarebskiAug 18, 2009
  39. skillzero@gmail.comAug 18, 2009
  40. Junio C HamanoAug 17, 2009
  41. Johannes SchindelinAug 17, 2009
  42. Jakub NarebskiAug 17, 2009
  43. Johannes SixtAug 12, 2009
  44. Nguyen Thai Ngoc DuyAug 12, 2009
  45. Raja R HarinathAug 12, 2009
  46. Johannes SixtAug 13, 2009
  47. skillzero@gmail.comAug 11, 2009
  48. Jakub NarebskiAug 11, 2009
  49. skillzero@gmail.comAug 11, 2009
  50. Nguyen Thai Ngoc DuyAug 12, 2009
  51. skillzero@gmail.comAug 12, 2009
  52. Junio C HamanoAug 12, 2009
  53. Nguyen Thai Ngoc DuyAug 13, 2009

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.