git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH 2/7] Refactor of RefUpdate force to call common updateImpl instead of duplication

From
Shawn O. Pearce <spearce@spearce.org>
Date
Aug 14, 2008, 22:23 UTC
Message-ID
<20080814222345.GU3782@spearce.org>
In-Reply-To
<1218708829-8175-3-git-send-email-charleso@charleso.org>
Charles O'Farrell <charleso@charleso.org> wrote:
> @@ -266,31 +266,8 @@ public class RefUpdate {
>  	 *             an unexpected IO error occurred while writing changes.
>  	 */
>  	public Result forceUpdate() throws IOException {
[clipped uinteresting deletions to show only the postimage]
Show 25 quoted lines
> +		force = true;
> +		return update();
>  	}
>  
>  	/**
> @@ -347,6 +324,12 @@ public class RefUpdate {
>  			if (oldValue == null)
>  				return store(lock, Result.NEW);
>  
> +			if (isForceUpdate()) {
> +				if (oldValue.equals(newValue))
> +					return Result.NO_CHANGE;
> +				return store(lock, Result.FORCED);
> +			}
> +
>  			newObj = walk.parseAny(newValue);
>  			oldObj = walk.parseAny(oldValue);
>  			if (newObj == oldObj)
> @@ -355,13 +338,8 @@ public class RefUpdate {
>  			if (newObj instanceof RevCommit && oldObj instanceof RevCommit) {
>  				if (walk.isMergedInto((RevCommit) oldObj, (RevCommit) newObj))
>  					return store(lock, Result.FAST_FORWARD);
> -				if (isForceUpdate())
> -					return store(lock, Result.FORCED);
> -				return Result.REJECTED;

The problem with this change is that calls to just update() which have isForceUpdate() true but actually turn out to be FAST_FORWARD types of updates now report FORCED as the result. We don't want to always report FORCED if the application is using just update().

Its nice to know that the remote side didn't rewind since we last saw them (for example).

-- 
Shawn.
Previous: Charles O'FarrellNext: Charles O'Farrell
Message 9 of 11 in “jgit: Branch command now supports deletion”
  1. 0/7 jgit: Branch command now supports deletionCharles O'Farrell, Aug 14, 2008
  2. 1/7 Refactor of WalkRemoteObjectDatabase ref writing into common classCharles O'Farrell, Aug 14, 2008
  3. 2/7 Refactor of RefUpdate force to call common updateImpl instead of duplicationCharles O'Farrell, Aug 14, 2008
  4. 3/7 Minor refactor of constants, including log and ROOT_DIRCharles O'Farrell, Aug 14, 2008
  5. 4/7 Extract lockAndWriteFile method in RefDatabase for reuseCharles O'Farrell, Aug 14, 2008
  6. 5/7 Added removePackedRef method to RefDatabase for packed branch deletionCharles O'Farrell, Aug 14, 2008
  7. 6/7 Added ref deletion to RefUpdateCharles O'Farrell, Aug 14, 2008
  8. 7/7 jgit: Added branch deletion to jgit commandCharles O'Farrell, Aug 14, 2008
  9. Shawn O. PearceAug 14, 2008
  10. 2/7 Refactor of RefUpdate force to call common updateImpl instead of duplicationCharles O'Farrell, Aug 15, 2008
  11. 6/7 Added ref deletion to RefUpdateCharles O'Farrell, Aug 15, 2008

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.