From 23125abc20758f06aae9877306ceca6651750b3c Mon Sep 17 00:00:00 2001 From: Tim Neumann Date: Thu, 28 Nov 2019 15:56:50 +0100 Subject: Add ability to redirect stderr from git hooks This will change the behavior in the CLI to resemble that of C-Git more closely by printing the stderr of the hooks to the CLI stderr independently of the exit code of the hook. This is also useful for the corresponding EGIT-Change, which will add the ability to show the hook output in eclipse. With this also the stderr can be shown even if the exit code is 0. Bug: 553471 Change-Id: Ie7bc503fe39e270e9b93dd1108b5879f02a12b4c Signed-off-by: Tim Neumann --- .../src/org/eclipse/jgit/lfs/BuiltinLFS.java | 10 ++++++++++ .../src/org/eclipse/jgit/lfs/LfsPrePushHook.java | 14 ++++++++++++++ 2 files changed, 24 insertions(+) (limited to 'org.eclipse.jgit.lfs') diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java index 3c5826362c..e90d92976a 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/BuiltinLFS.java @@ -106,6 +106,16 @@ public class BuiltinLFS extends LfsFactory { return null; } + @Override + @Nullable + public PrePushHook getPrePushHook(Repository repo, PrintStream outputStream, + PrintStream errorStream) { + if (isEnabled(repo)) { + return new LfsPrePushHook(repo, outputStream, errorStream); + } + return null; + } + /** * @param db * the repository diff --git a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java index 3e6a26159b..b3e304fea2 100644 --- a/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java +++ b/org.eclipse.jgit.lfs/src/org/eclipse/jgit/lfs/LfsPrePushHook.java @@ -107,6 +107,20 @@ public class LfsPrePushHook extends PrePushHook { super(repo, outputStream); } + /** + * @param repo + * the repository + * @param outputStream + * not used by this implementation + * @param errorStream + * not used by this implementation + * @since 5.6 + */ + public LfsPrePushHook(Repository repo, PrintStream outputStream, + PrintStream errorStream) { + super(repo, outputStream, errorStream); + } + @Override public void setRefs(Collection toRefs) { this.refs = toRefs; -- cgit v1.2.3