{"record":{"id":"95523bfa33c28f81","repo":"pcottle/learnGitBranching","slug":"git-error-origin-fetch-uptodate","errorCode":null,"errorMessage":"git-error-origin-fetch-uptodate","messagePattern":"git-error-origin-fetch-uptodate","errorType":"validation","errorClass":"GitError","httpStatus":null,"severity":"warning","filePath":"src/js/git/index.js","lineNumber":1057,"sourceCode":"  targetBranch,\n  sourceBranch,\n  options\n) {\n  options = options || {};\n  sourceBranch = source.resolveID(sourceBranch);\n\n  var targetSet = Graph.getUpstreamSet(target, targetBranch);\n  var sourceStartCommit = source.getCommitFromRef(sourceBranch);\n\n  var sourceTree = source.exportTree();\n  var sourceStartCommitJSON = sourceTree.commits[sourceStartCommit.get('id')];\n\n  if (targetSet[sourceStartCommitJSON.id]) {\n    // either we throw since theres no work to be done, or we return an empty array\n    if (options.dontThrowOnNoFetch) {\n      return [];\n    } else {\n      throw new GitError({\n        msg: intl.str('git-error-origin-fetch-uptodate')\n      });\n    }\n  }\n\n  // ok great, we have our starting point and our stopping set. lets go ahead\n  // and traverse upwards and keep track of depth manually\n  sourceStartCommitJSON.depth = 0;\n  var difference = [];\n  var toExplore = [sourceStartCommitJSON];\n\n  var pushParent = function(parentID) {\n    if (targetSet[parentID]) {\n      // we already have that commit, lets bounce\n      return;\n    }\n\n    var parentJSON = sourceTree.commits[parentID];","sourceCodeStart":1039,"sourceCodeEnd":1075,"githubUrl":"https://github.com/pcottle/learnGitBranching/blob/5b09d0ff9678cad164f5a7488a279a44f90d7256/src/js/git/index.js#L1039-L1075","documentation":"Thrown during fetch when the source branch's starting commit is already present in the target repository's commit set, meaning there is nothing new to fetch. It mirrors git's 'Already up to date.' message.","triggerScenarios":"Calling fetch where targetSet[sourceStartCommitJSON.id] is truthy and options.dontThrowOnNoFetch is not set — i.e. fetching a remote branch whose head commit you already have.","commonSituations":"Running fetch twice in a row in a level; scripted tests that fetch without checking state first.","solutions":["Treat this as informational — nothing needs fetching; continue your workflow","If scripting automated fetches, pass options.dontThrowOnFetch true (dontThrowOnNoFetch) so an empty array is returned instead","Catch CommandResult/GitError and ignore the up-to-date case"],"exampleFix":"// before\nthis.fetch('origin', 'main'); // throws when up to date\n// after\nthis.fetch('origin', 'main', { dontThrowOnNoFetch: true });","handlingStrategy":"try-catch","validationCode":"var targetSet = Graph.getCommitSet(target, targetBranch);\nif (targetSet[sourceStart.id]) { /* skip fetch */ }","typeGuard":null,"tryCatchPattern":"try { engine.fetch(...); } catch (e) { if (e instanceof GitError && e.msg === intl.str('git-error-origin-fetch-uptodate')) return; throw e; }","preventionTips":["Pass dontThrowOnNoFetch when scripting repeated fetches","Check commit presence before fetching"],"tags":["git","fetch","up-to-date"],"backgroundTag":"git-already-up-to-date","analyzedSha":"5b09d0ff9678cad164f5a7488a279a44f90d7256","analyzedAt":"2026-08-27T13:53:49.057Z","schemaVersion":2},"datasetVersion":"2026-08-27T19:17:21.184Z"}