Skip to content

Commit

Permalink
Add files via upload
Browse files Browse the repository at this point in the history
  • Loading branch information
ffanyt authored Jan 27, 2023
1 parent d93d9df commit 2274f66
Showing 1 changed file with 9 additions and 3 deletions.
12 changes: 9 additions & 3 deletions proj2/gitlet/Repository.java
Original file line number Diff line number Diff line change
Expand Up @@ -449,8 +449,8 @@ public static void merge(String branchName) {
String givenHash = readHashByBrchNm(branchName);
Commit commitOther = Commit.readCommit(givenHash);
Commit commitSplit = findSplitPoint(commiHead, commitOther);
checkIf2CommitDiffBranch(commitSplit, commiHead);
checkIf2CommitDiffBranch(commitSplit, commitOther);
checkIf2SplitDiffHead(commitSplit, commiHead, branchName);
checkIfSplitDiffOther(commitSplit, commitOther);
String message = "Merged " + branchName + " into " + HEAD_BRANCH + ".";
Commit mergeCommit = merge2NewCommit(commitSplit, commiHead, commitOther, message);

Expand Down Expand Up @@ -588,7 +588,13 @@ private static List calAllFile(Commit split, Commit head, Commit other) {
getFileFromBlob(splitBlob, allFile);
return allFile;
}
private static void checkIf2CommitDiffBranch(Commit split, Commit given) {
private static void checkIf2SplitDiffHead(Commit split, Commit head, String branchName) {
if (split.getHashcode().equals(head.getHashcode())) {
checkout(branchName, 0);
printError("Current branch fast-forwarded.");
}
}
private static void checkIfSplitDiffOther(Commit split, Commit given) {
if (split.getHashcode().equals(given.getHashcode())) {
printError("Given branch is an ancestor of the current branch.");
}
Expand Down

0 comments on commit 2274f66

Please sign in to comment.