Skip to main content

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [List Home]
Re: [jgit-dev] Push Result

2011/12/6 Eduardo Falcão <edu.falcao@xxxxxxxxx>:
> I'm trying to push to a repository that is already updated. If I use
> command-line git a "no fast-forward" error is shown. How can I get this
> message using Jgit Api? My code looks like this:
>         PushCommand pc = GetRepository().push();
>         pc.add(GetRepository().getRepository().getBranch());
>         pc.setCredentialsProvider(credential);
>         for (PushResult r : {
>         System.out.println(r.getMessages());
>         }
> But the method getMessages() is not returning the "no fast-forward" message.
> In fact it is returning an empty string...

Look at the PushResult type. I think there is a getResult() that
returns an enum of some sort, the enum tells you a few different
states. The getMessages() method is only for when the enum is the push
failed other reason enum value. There is are special enum case for non
fast forward, force update, etc.

(This is all from memory, I don't have the code open, so I apologize
if the method names aren't exactly correct...)

Back to the top