|
|
@ -52,6 +52,7 @@ import java.util.ArrayList; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.Collection; |
|
|
|
import java.util.List; |
|
|
|
import java.util.List; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
import org.eclipse.jgit.annotations.Nullable; |
|
|
|
import org.eclipse.jgit.internal.JGitText; |
|
|
|
import org.eclipse.jgit.internal.JGitText; |
|
|
|
import org.eclipse.jgit.lib.AnyObjectId; |
|
|
|
import org.eclipse.jgit.lib.AnyObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
|
import org.eclipse.jgit.lib.ObjectId; |
|
|
@ -218,6 +219,12 @@ public class ReceiveCommand { |
|
|
|
|
|
|
|
|
|
|
|
private String message; |
|
|
|
private String message; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean customRefLog; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private String refLogMessage; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private boolean refLogIncludeResult; |
|
|
|
|
|
|
|
|
|
|
|
private boolean typeIsCorrect; |
|
|
|
private boolean typeIsCorrect; |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
@ -342,6 +349,90 @@ public class ReceiveCommand { |
|
|
|
return message; |
|
|
|
return message; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Set the message to include in the reflog. |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Overrides the default set by {@code setRefLogMessage} on any containing |
|
|
|
|
|
|
|
* {@link org.eclipse.jgit.lib.BatchRefUpdate}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param msg |
|
|
|
|
|
|
|
* the message to describe this change. If null and appendStatus is |
|
|
|
|
|
|
|
* false, the reflog will not be updated. |
|
|
|
|
|
|
|
* @param appendStatus |
|
|
|
|
|
|
|
* true if the status of the ref change (fast-forward or |
|
|
|
|
|
|
|
* forced-update) should be appended to the user supplied message. |
|
|
|
|
|
|
|
* @since 4.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void setRefLogMessage(String msg, boolean appendStatus) { |
|
|
|
|
|
|
|
customRefLog = true; |
|
|
|
|
|
|
|
if (msg == null && !appendStatus) { |
|
|
|
|
|
|
|
disableRefLog(); |
|
|
|
|
|
|
|
} else if (msg == null && appendStatus) { |
|
|
|
|
|
|
|
refLogMessage = ""; //$NON-NLS-1$
|
|
|
|
|
|
|
|
refLogIncludeResult = true; |
|
|
|
|
|
|
|
} else { |
|
|
|
|
|
|
|
refLogMessage = msg; |
|
|
|
|
|
|
|
refLogIncludeResult = appendStatus; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Don't record this update in the ref's associated reflog. |
|
|
|
|
|
|
|
* <p> |
|
|
|
|
|
|
|
* Equivalent to {@code setRefLogMessage(null, false)}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @since 4.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public void disableRefLog() { |
|
|
|
|
|
|
|
customRefLog = true; |
|
|
|
|
|
|
|
refLogMessage = null; |
|
|
|
|
|
|
|
refLogIncludeResult = false; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Check whether this command has a custom reflog setting that should override |
|
|
|
|
|
|
|
* defaults in any containing {@link org.eclipse.jgit.lib.BatchRefUpdate}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return whether a custom reflog is set. |
|
|
|
|
|
|
|
* @since 4.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean hasCustomRefLog() { |
|
|
|
|
|
|
|
return customRefLog; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Check whether log has been disabled by {@link #disableRefLog()}. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return true if disabled. |
|
|
|
|
|
|
|
* @since 4.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean isRefLogDisabled() { |
|
|
|
|
|
|
|
return refLogMessage == null; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Get the message to include in the reflog. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return message the caller wants to include in the reflog; null if the |
|
|
|
|
|
|
|
* update should not be logged. |
|
|
|
|
|
|
|
* @since 4.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
@Nullable |
|
|
|
|
|
|
|
public String getRefLogMessage() { |
|
|
|
|
|
|
|
return refLogMessage; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* Check whether the reflog message should include the result of the update, |
|
|
|
|
|
|
|
* such as fast-forward or force-update. |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @return true if the message should include the result. |
|
|
|
|
|
|
|
* @since 4.9 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public boolean isRefLogIncludingResult() { |
|
|
|
|
|
|
|
return refLogIncludeResult; |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* Set the status of this command. |
|
|
|
* Set the status of this command. |
|
|
|
* |
|
|
|
* |
|
|
@ -408,6 +499,7 @@ public class ReceiveCommand { |
|
|
|
try { |
|
|
|
try { |
|
|
|
final RefUpdate ru = rp.getRepository().updateRef(getRefName()); |
|
|
|
final RefUpdate ru = rp.getRepository().updateRef(getRefName()); |
|
|
|
ru.setRefLogIdent(rp.getRefLogIdent()); |
|
|
|
ru.setRefLogIdent(rp.getRefLogIdent()); |
|
|
|
|
|
|
|
ru.setRefLogMessage(refLogMessage, refLogIncludeResult); |
|
|
|
switch (getType()) { |
|
|
|
switch (getType()) { |
|
|
|
case DELETE: |
|
|
|
case DELETE: |
|
|
|
if (!ObjectId.zeroId().equals(getOldId())) { |
|
|
|
if (!ObjectId.zeroId().equals(getOldId())) { |
|
|
|