static int push_commit(git_revwalk *walk, const git_oid *oid, int hide) { if (hide) return git_revwalk_hide(walk, oid); else return git_revwalk_push(walk, oid); }
static git_revwalk *gbr_revwalk_setup_fromto(git_repository *repo, git_oid *base, const git_oid *head) { git_revwalk *walker; if (git_revwalk_new(&walker, repo) != 0) { gbr_perror("gbr_revwalk_setup_fromto()"); return NULL; } git_revwalk_sorting(walker, GIT_SORT_REVERSE); git_revwalk_push(walker, head); git_revwalk_hide(walker, base); return walker; }
PyObject * Walker_hide(Walker *self, PyObject *py_hex) { int err; git_oid oid; err = py_str_to_git_oid_expand(self->repo->repo, py_hex, &oid); if (err < 0) return Error_set(err); err = git_revwalk_hide(self->walk, &oid); if (err < 0) return Error_set(err); Py_RETURN_NONE; }
static int rebase_init_operations( git_rebase *rebase, git_repository *repo, const git_annotated_commit *branch, const git_annotated_commit *upstream, const git_annotated_commit *onto) { git_revwalk *revwalk = NULL; git_commit *commit; git_oid id; bool merge; git_rebase_operation *operation; int error; if (!upstream) upstream = onto; if ((error = git_revwalk_new(&revwalk, rebase->repo)) < 0 || (error = git_revwalk_push(revwalk, git_annotated_commit_id(branch))) < 0 || (error = git_revwalk_hide(revwalk, git_annotated_commit_id(upstream))) < 0) goto done; git_revwalk_sorting(revwalk, GIT_SORT_REVERSE | GIT_SORT_TIME); while ((error = git_revwalk_next(&id, revwalk)) == 0) { if ((error = git_commit_lookup(&commit, repo, &id)) < 0) goto done; merge = (git_commit_parentcount(commit) > 1); git_commit_free(commit); if (merge) continue; operation = git_array_alloc(rebase->operations); operation->type = GIT_REBASE_OPERATION_PICK; git_oid_cpy((git_oid *)&operation->id, &id); } error = 0; done: git_revwalk_free(revwalk); return error; }
/* * call-seq: * walker.hide(commit) -> nil * * Hide the given +commit+ (and all its parents) from the * output in the revision walk. */ static VALUE rb_git_walker_hide(VALUE self, VALUE rb_commit) { git_revwalk *walk; git_commit *commit; int error; Data_Get_Struct(self, git_revwalk, walk); commit = (git_commit *)rugged_object_get( git_revwalk_repository(walk), rb_commit, GIT_OBJ_COMMIT); error = git_revwalk_hide(walk, git_object_id((git_object *)commit)); git_commit_free(commit); rugged_exception_check(error); return Qnil; }
int QGitRevWalk::hide(const QGitOId& oid) const { return git_revwalk_hide(m_revWalk, oid.constData()); }
static git_commit* FindFileRecentCommit(git_repository* repository, const CString& path) { CAutoRevwalk walk; if (git_revwalk_new(walk.GetPointer(), repository)) return nullptr; CStringA pathA = CUnicodeUtils::GetUTF8(path); if (pathA.GetLength() >= MAX_PATH) return nullptr; const char *pathC = pathA; char folder[MAX_PATH] = {0}, file[MAX_PATH] = {0}; const char *slash = strrchr(pathC, '/'); if (slash) { strncpy(folder, pathC, slash - pathC + 1); folder[slash - pathC + 1] = '\0'; strcpy(file, slash + 1); } else { folder[0] = '\0'; strcpy(file, pathC); } TreewalkStruct treewalkstruct = { folder, file }; if (git_revwalk_push_head(walk)) return nullptr; git_oid oid; CAutoCommit commit; while (!git_revwalk_next(&oid, walk)) { if (git_commit_lookup(commit.GetPointer(), repository, &oid)) return nullptr; CAutoTree tree; if (git_commit_tree(tree.GetPointer(), commit)) return nullptr; memset(&treewalkstruct.oid.id, 0, sizeof(treewalkstruct.oid.id)); int ret = git_tree_walk(tree, GIT_TREEWALK_PRE, TreewalkCB_FindFileRecentCommit, &treewalkstruct); if (ret < 0 && ret != GIT_EUSER) return nullptr; // check if file not found if (git_oid_iszero(&treewalkstruct.oid)) return nullptr; bool diff = true; // for merge point, check if it is different to all parents, if yes then there are real change in the merge point. // if no parent then of course it is different for (unsigned int i = 0; i < git_commit_parentcount(commit); ++i) { CAutoCommit commit2; if (git_commit_parent(commit2.GetPointer(), commit, i)) return nullptr; CAutoTree tree2; if (git_commit_tree(tree2.GetPointer(), commit2)) return nullptr; TreewalkStruct treewalkstruct2 = { folder, file }; memset(&treewalkstruct2.oid.id, 0, sizeof(treewalkstruct2.oid.id)); int ret = git_tree_walk(tree2, GIT_TREEWALK_PRE, TreewalkCB_FindFileRecentCommit, &treewalkstruct2); if (ret < 0 && ret != GIT_EUSER) return nullptr; if (!git_oid_cmp(&treewalkstruct.oid, &treewalkstruct2.oid)) diff = false; else if (git_revwalk_hide(walk, git_commit_parent_id(commit, i))) return nullptr; } if (diff) break; } return commit.Detach(); }