{"thread":{"id":"20325","subject":"[JGIT] Request For Help/Directions","startedAt":"2009-08-01T03:15:18Z","lastAt":"2009-08-10T15:23:08Z","messageCount":2,"participants":["Douglas Campos","Shawn O. Pearce"],"isPatch":false,"patchVersion":null,"patchTotal":null},"messages":[{"id":"119314","messageId":"ed88cb980907312015q5eb89bf3k73b6664c4f3cbcfd@mail.gmail.com","threadId":"20325","inReplyTo":null,"subject":"[JGIT] Request For Help/Directions","fromName":"Douglas Campos","fromEmail":"douglas@theros.info","sentAt":"2009-08-01T03:15:18Z","receivedAt":"2009-08-01T03:15:18Z","isPatch":false,"sender":{"key":"douglas@theros.info","avatar":"https://gravatar.com/avatar/bca8e0e43e860dab00ec17dd3f1b60df6af911655fae70a0bbdeebeb889de421?d=mp&s=160"},"body":"Hi to all\n\nI'm interested in helping with the implementation, can someone gimme\nlittle directions?\n\nI was thinking on implement \"git checkout <file>\" functionality.\n\nAny tips?\n\nPS: I'm reading the testcases & code to find directions, but got\nstruck at some deprecated types (GitIndex -> DirCache).\n\nSorry for the noise\n\nqmx\n"},{"id":"120169","messageId":"20090810152308.GQ1033@spearce.org","threadId":"20325","inReplyTo":"ed88cb980907312015q5eb89bf3k73b6664c4f3cbcfd@mail.gmail.com","subject":"Re: [JGIT] Request For Help/Directions","fromName":"Shawn O. Pearce","fromEmail":"spearce@spearce.org","sentAt":"2009-08-10T15:23:08Z","receivedAt":"2009-08-10T15:23:08Z","isPatch":false,"sender":{"key":"spearce@spearce.org","avatar":"https://avatars.githubusercontent.com/u/34844?v=4"},"body":"Douglas Campos <douglas@theros.info> wrote:\n> I'm interested in helping with the implementation, can someone gimme\n> little directions?\n> \n> I was thinking on implement \"git checkout <file>\" functionality.\n> \n> Any tips?\n> \n> PS: I'm reading the testcases & code to find directions, but got\n> struck at some deprecated types (GitIndex -> DirCache).\n\nSorry for the late reply, things tend to get lost in my inbox.\n\nGitIndex vs. DirCache... that's an ugly issue at the momement in the\ncode base.  I really want to move to DirCache because it tends to\nbe quicker at reading and writing the index out, plus it honors the\n'TREE' extension, at least some of the time.  But its API is said\nto be harder to work with, and I can't disagree with that, using the\nDirCacheBuilder vs. DirCacheEditor to make updates is horribly ugly.\n\nFWIW, DirCacheBuilder is really meant to be used inside of a\nTreeWalk, alongside other iterators, like a FileTreeIterator.\n\nIn theory, you should be able to create a 3 way TreeWalk between:\n\n 1) DirCacheBuilderIterator\n 2) FileTreeIterator\n 3) CanonicalTreeParser\n\nwhere 1 represents the current state of the .git/index file,\n2 represents the current state of the working directory, and 3\nrepresents the tree you are performing the checkout from.\n\nIIRC you could attach a TreeFilter.ANY_DIFF to this TreeWalk and\nonly have it stop where there are differences between the 3 trees.\nThough with a FileTreeIterator ANY_DIFF is probably a bad idea,\nas the SHA-1 isn't readily available in a FileTreeIterator and\nthat is one of the things ANY_DIFF relies upon.  Instead you'd\nneed to write your own TreeFilter to check stat data between 1-2,\nand SHA-1 data between 2-3.\n\nAt a difference point, you then need to apply the basic 3-way merge\nlogic to determine if you should checkout the file in 3 to 1 and 2,\nor if you should abort because the file in 2 (the working tree)\ndiffers and needs to be merged.\n\nA really good reason for using the TreeWalk is it has a subclass\ncalled NameConflictTreeWalk that knows how to heal around\ndirectory/file conflicts (aka D/F conflicts) and reports both D/F\npaths under a single entry, so that the merge alogrithm can attempt\nto deal with D->F or F->D type changes.\n\nBut a good chunk of this is pie-in-the-sky.  I've built these APIs\nwith this in mind... but haven't gotten as far as actually putting\nthe implementation into practice.\n\n-- \nShawn.\n"}]}