git_libgit2_init();
const char * REPO_PATH = path.c_str();
git_repository * repo = nullptr;
git_repository_open(&repo, REPO_PATH);
git_diff_options diffopts = GIT_DIFF_OPTIONS_INIT;
git_diff *diff;
diffopts.flags = GIT_CHECKOUT_NOTIFY_CONFLICT;
git_diff_index_to_workdir(&diff, repo, NULL, &diffopts);
size_t num_deltas = git_diff_num_deltas(diff);
if (num_deltas != 0){
const git_diff_delta *delta = git_diff_get_delta(diff, 0);
int i = 0;
cerr << "Your local changes to the following files would be overwritten by checkout : " << endl;
while (i<num_deltas) {
delta = git_diff_get_delta(diff, i);
git_diff_file file = delta->new_file;
cerr << "\t" << file.path << endl;
i++;
}
cerr << "Please commit your changes before you switch branches. " << endl;
}
else cout << "All files OK, can checkout now" << endl;
git_diff_free(diff);
git_repository_free(repo);
git_libgit2_shutdown();
//初始化时遇到异常。
import org.apache.poi.hssf.usermodel.HSSFCellStyle;
import org.apache.poi.hssf.usermodel.HSSFWorkbook;
import org.apache.poi.hssf.util.HSSFColor;
import org.apache.poi.ss.usermodel.Cell;
import org.apache.poi.ss.usermodel.CellStyle;
import org.apache.poi.ss.usermodel.Row;
import org.apache.poi.ss.usermodel.Sheet;
//例外是这个。
HSSFWorkbook wb = new HSSFWorkbook();
//我尝试poi的其他jar文件,但无法解决。