Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion logCommand/log.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ int logMain(int argc, const char* argv[]) {
commit currCommit;
while (readCommit(sha1, currCommit)) {
std::cout << yellow << "[commit " << currCommit.sha1 << ']' << Reset << std::endl;
std::cout << cyan << "mmessage:" << Reset << std::endl;
std::cout << cyan << "message:" << Reset << std::endl;
std::cout << std::endl;

std::cout << currCommit.message;
Expand Down
32 changes: 29 additions & 3 deletions merge/merge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,14 +7,40 @@
#include <vector>
#include <functional>

int merge(int argc, const char* argv[]);
int mergeMain(int argc, const char* argv[]);

struct MergeResult{
std::vector<commit> parents;
std::string sha1;
};
Command MergeCommand{
merge,
mergeMain,
"Join two or more development histories together"
};

int merge(int argc, const char* argv[]){
//数据结构定义先

int mergeMain(int argc, const char* argv[]){
cmdline::parser argParser;
argParser.add<std::string>("message", 'm', "merge message", true, "");
argParser.footer("<merge from> ...");

argParser.parse_check(argc, argv);
// 首先获得当前分支的,
if (argParser.rest().size() == 0) {
std::cout << argParser.usage();
return 0;
}
for (auto branch : argParser.rest()) {
std::cout << branch << std::endl;
}

// 参数解析

// 判断是否需要 merge 是否可以merege先
// 1. 判断是否有冲突
// 2. 判断是否有未提交的修改

std::cout << "Join two or more development histories together" << std::endl;
return 1;
}
6 changes: 5 additions & 1 deletion object/object.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,11 @@ bool checkSha1(const std::string &sha1) {
bool readCommit(const std::string &sha1, commit& thisCommit) {
if (sha1 == ""){
// not error, but also not commit
std::cerr << red << "Error: " << GIT_NAME << " your current branch 'master' does not have any commits yet" << Reset << std::endl;
// if this commit is empty ,then means there is no commit
if (thisCommit.sha1 == "")
std::cerr << red << "Error: " << GIT_NAME << " your current branch 'master' does not have any commits yet" << Reset << std::endl;


return false;
}

Expand Down
5 changes: 3 additions & 2 deletions test/test.py
Original file line number Diff line number Diff line change
Expand Up @@ -294,8 +294,9 @@ def main():
parser.add_argument("exe", metavar = "executable-path")
args = parser.parse_args()

app = os.path.abspath(args.exe)

app = os.path.abspath('D:\learn\programming\s-git\s-git.exe')

print(app)
LoadTmpDir()
try:
ret = main()
Expand Down