如何在STL中实现Stack?(How is Stack implemented in STL?)
I came across this:
It triggered me the question, how are stacks implemented in STL?
I am looking for a description similar to:
原文:https://stackoverflow.com/questions/35930251
最满意答案
git merge --abort
没有直接的等价物 - 在JGit中是不可用的。 这段代码可以作为一个起点:// clear the merge state repository.writeMergeCommitMsg( null ); repository.writeMergeHeads( null ); // reset the index and work directory to HEAD Git.wrap( repository ).reset().setMode( ResetType.HARD ).call();
它清空合并状态文件,然后将索引和工作目录重置为当前HEAD提交的内容。
为了测试两个提交是否可以合并,您还可以使用内核合并 。 这将避免检查工作目录中的冲突提交,以便稍后重置它们。
RevCommit parentCommit = mergeCommit.getParent( 0 ); revWalk.parseHeaders( parentCommit ); ResolveMerger merger = ( ResolveMerger )MergeStrategy.RESOLVE.newMerger( repository, true ); merger.setWorkingTreeIterator( new FileTreeIterator( repository ) ); merger.setBase( parentCommit.getTree() ); if( !merger.merge( headCommit, mergeCommit ) ) { if( merger.failed() { throw new IllegalStateException( "Should not happen with in-core mergers" ); } // inspect merger.getMergeResults() for further details }
There is no direct equivalent for
git merge --abort
in JGit. This code snippet may serve as a starting point:// clear the merge state repository.writeMergeCommitMsg( null ); repository.writeMergeHeads( null ); // reset the index and work directory to HEAD Git.wrap( repository ).reset().setMode( ResetType.HARD ).call();
It empties the merge state files and then resets index and work directory to the contents of the current HEAD commit.
In order to test if two commits can be merged, you could also use an in-core merger. This would avoid checking out the conflicting commit into the work directory just to reset them later on.
RevCommit parentCommit = mergeCommit.getParent( 0 ); revWalk.parseHeaders( parentCommit ); ResolveMerger merger = ( ResolveMerger )MergeStrategy.RESOLVE.newMerger( repository, true ); merger.setWorkingTreeIterator( new FileTreeIterator( repository ) ); merger.setBase( parentCommit.getTree() ); if( !merger.merge( headCommit, mergeCommit ) ) { if( merger.failed() { throw new IllegalStateException( "Should not happen with in-core mergers" ); } // inspect merger.getMergeResults() for further details }
相关问答
更多-
jgit 如何区分哪些commit是merge的[2021-11-11]
user this commond check merged commit $ git log $(git merge-base --octopus $(git log -1 --merges --pretty=format:%P)).. --boundary -
使用JGit和CLI git(Using JGit and CLI git)[2023-08-01]
使用GitSCM的checkout步骤,它具有扩展名以指定要使用的Git工具。 为方便起见, git步骤只有少数最常见的选项。 Use the checkout step with GitSCM, which has an extension to specify the Git tool to use. The git step has only a handful of the most common options as a convenience. -
使用JGit中止合并(Abort merge using JGit)[2023-08-10]
git merge --abort没有直接的等价物 - 在JGit中是不可用的。 这段代码可以作为一个起点: // clear the merge state repository.writeMergeCommitMsg( null ); repository.writeMergeHeads( null ); // reset the index and work directory to HEAD Git.wrap( repository ).reset().setMode( ResetType.HAR ... -
如何用JGit确定哪些分支已合并为master?(How to determine with JGit which branches have been merged to master?)[2022-11-03]
RevWalk::isMergedInto()可用于确定提交是否已合并到另一个提交。 也就是说,如果第一个参数中给出的提交是第二个给定提交的祖先,则isMergedInto返回true。 try( RevWalk revWalk = new RevWalk( repository ) ) { RevCommit masterHead = revWalk.parseCommit( repository.resolve( "refs/heads/master" ); RevCommit otherHea ... -
Jgit-如何使用Jgit获取两个日期之间的合并提交列表?(Jgit- How to get list of merge commits between two dates using Jgit?)[2024-05-11]
您可以CommitTimeRevFilter#between(Date,Date)使用带有CommitTimeRevFilter#between(Date,Date) LogCommand#setRevFilter(RevFilter) CommitTimeRevFilter#between(Date,Date) ,例如: ObjectId masterId = git.getRepository().exactRef("refs/heads/master").getObjectId(); Date sin ... -
在Windows上运行代码,我可以重现您描述的内容。 这看起来像JGit中的一个错误。 我建议打开一个bugzilla或将你的发现发布到邮件列表中 。 Running the code on Windows, I can reproduce what you describe. This looks like a bug in JGit to me. I recommend to open a bugzilla or post your findings to the mailing list.
-
Scala版本的Jgit(Scala version of Jgit)[2023-09-21]
我前段时间做了同样的搜索,但我得出结论,最好在Scala中使用JGit(即使它是一个Java库)。 它被具有大量用户的产品(eclipse,netbeans,gerrit,...)使用,甚至一些像Gitbucket这样的Scala产品也使用它。 它的API可以很容易地从Scala中调用,并且不会导致丑陋的代码,也不需要繁重的包装器。 就个人而言,我更喜欢使用广泛使用的Java lib而不是纯Scala lib,我不知道路线图,也不知道它是否仍在维护。 我想到了ScalaGit,但它看起来很年轻(只有67次提 ... -
MergeCommand不是为了解决合并冲突。 相反,如果纳入的参考文献不能没有冲突地合并,将导致合并冲突。 PullCommand是一个复合命令 ,它首先从上游获取提交,然后尝试使用MergeCommand合并它们。 为了以编程方式解决合并冲突,您需要相应地更改本地工作目录中的文件,将它们添加到索引中,然后发出合并提交 。 有关冲突文件的信息可以在pullResult.getMergeResult()找到。 可以使用常规的CommitCommand创建合并提交 。 The MergeCommand is ...
-
在JGit中使用Mergetool(Use Mergetool in JGit)[2023-11-16]
JGit是Git的Java专用实现。 如果支持git mergetool ,则需要为可能执行JGit的每个平台包含各种本机mergetools。 我认为这就是为什么没有实施的原因。 此外, EGit (可能是主要的JGit使用者)使用Eclipse Compare Editor来解决冲突,因此不需要合并工具AFAIK。 以下是关于向EGit添加mergetool支持的讨论: https ://bugs.eclipse.org/bugs/show_bug.cgi ? id = 356832 如果您认为这应该在 ... -
JGit Connection拒绝了(JGit Connection refused)[2022-09-16]
如果您收到“拒绝连接”错误消息,那么(通常)意味着没有服务正在侦听客户端尝试连接的IP地址+端口。 确认此问题的常见技巧是使用其他一些实用程序尝试连接到问题IP +端口。 telnet实用程序通常用于此目的。 安装它(如有必要)并检查手动输入以查找用于指定端口号的命令行选项。 (这取决于你的操作系统......) 鉴于您说localhost正常工作,并且您使用的端口未被本地防火墙阻止,最可能的解释是您只配置了Git服务器软件以侦听localhost IP地址(通常为127.0.0.1 ) If you ge ...