DESIGN DOCUMENT Classes:
- Gitlet
- CommitTree (private, nested inside Gitlet)
- Commit (private, nested inside Gitlet)
- Branch (private, nested inside Gitlet) Gitlet -Instance variables:
- CommitTree myCommitTree
- HashSet untracking
- HashSet staged
- Int currentID
- Boolean conflicted -Methods (feel the need to clean this up):
- clearFiles – clear files from untracking and staged after a commit
- initCommand – makes the .gitlet folder with the staging_area folder inside
- addCommand – adds to staging area or unmarks from untracking
- rmCommand – removes from staging or adds to the “untracking” list
- logCommand – calls the reportInfo method of the headCommit, which invokes the -reportInfo command recursively on its parentCommit
- findCommand – prints the ID of all commits sharing the specified message
- statusCommand – iterate through myCommitTree.branches, staged, and untracking instance variables
- checkoutCommand – uses the myCommitTree headCommit version of the file to overwrite the file in the current directory. OR uses the commit with the given commit id to find the version of the file used to overwrite. OR uses the commit at the head of the given branch to overwrite the files.
- branchCommand – makes a new branch in branches; points at the same commit that the current branch is pointing to.
- rmbranchCommand – remove a branch from the branches list
- mergeCommand – very complicated. Need to know how to recognize a split point.Requires checking the contents of the files at the current branch and the given branch to see if they are different. If the current branch has not been modified but the given branch has, then use the given branch’s files. If the other way, leave the current branch’s files as they are. If they are both modified, then make .conflicted files.
- rebaseCommand – requires being able to find a split point. Replay a branch, making copies of the commits in the current branch and “sticking” them onto the given branch. Propagate changes as well. -Other
- No argument constructor: instantiates myCommitTree CommitTree CommitTree - likely to remove and move all the instance variables to gitlet -Instance variables:
- Commit headCommit
- HashSet branches
- HashSet history -Methods
- addCommit -Other
- No argument constructor: instantiates headCommit, branches, and history Commit -Instance variables:
- int id
- String message
- String time
- Commit parent
- HashSet tracking -Methods
- reportInfo – reports all its relevant info for the sake of log and globallog
- hashCode – for quicker access in history, for the sake of find Branch - likely to remove altogether -instance variables:
- String myName
- Commit myCommit -Methods:
- changeCommit – changes myCommit to the commit in the argument