{"record":{"id":"a9d2f3a551a7d2d0","repo":"phacility/phabricator","slug":"specify-a-commit-to-extract-the-diff-from","errorCode":null,"errorMessage":"Specify a commit to extract the diff from.","messagePattern":"Specify a commit to extract the diff from\\.","errorType":"console","errorClass":"PhutilArgumentUsageException","httpStatus":null,"severity":"warning","filePath":"src/applications/differential/management/PhabricatorDifferentialExtractWorkflow.php","lineNumber":27,"sourceCode":"      ->setExamples('**extract** __commit__')\n      ->setSynopsis(pht('Extract a diff from a commit.'))\n      ->setArguments(\n        array(\n          array(\n            'name' => 'extract',\n            'wildcard' => true,\n            'help' => pht('Commit to extract.'),\n          ),\n        ));\n  }\n\n  public function execute(PhutilArgumentParser $args) {\n    $viewer = $this->getViewer();\n\n    $extract = $args->getArg('extract');\n\n    if (!$extract) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify a commit to extract the diff from.'));\n    }\n\n    if (count($extract) > 1) {\n      throw new PhutilArgumentUsageException(\n        pht('Specify exactly one commit to extract.'));\n    }\n\n    $extract = head($extract);\n\n    $commit = id(new DiffusionCommitQuery())\n      ->setViewer($viewer)\n      ->withIdentifiers(array($extract))\n      ->executeOne();\n\n    if (!$commit) {\n      throw new PhutilArgumentUsageException(\n        pht(","sourceCodeStart":9,"sourceCodeEnd":45,"githubUrl":"https://github.com/phacility/phabricator/blob/5720a38cfe95b00ca4be5016dd0d2f3195f4fa04/src/applications/differential/management/PhabricatorDifferentialExtractWorkflow.php#L9-L45","documentation":"PhabricatorDifferentialExtractWorkflow (./bin/differential extract) requires at least one commit identifier in its 'extract' wildcard arguments. When none is supplied the workflow throws this usage exception immediately, before touching the database.","triggerScenarios":"Running './bin/differential extract' with no arguments; an empty shell variable expanding to nothing ($COMMIT unset); a script passing an empty array of commits.","commonSituations":"Deploy scripts referencing an unset environment variable; CI jobs where the commit-ref step failed silently and passed an empty value.","solutions":["Re-run with one commit identifier: ./bin/differential extract <commit>","Guard scripts: test -n \"$COMMIT\" && phabricator/./bin/differential extract \"$COMMIT\"","Fix the upstream step that was supposed to populate the commit variable"],"exampleFix":"# before\nphabricator/ $ ./bin/differential extract\nUsage Exception: Specify a commit to extract the diff from.\n\n# after\nphabricator/ $ ./bin/differential extract rP703dcf56d0b6a4e01a52b1c6a1a1a8d1f8e2ab3c","handlingStrategy":"validation","validationCode":"# Guard against unset commit variables before invoking\n: \"${COMMIT:?COMMIT must be set to a commit identifier}\"\nphabricator/bin/differential extract \"$COMMIT\"","typeGuard":null,"tryCatchPattern":"try {\n  $workflow->execute($args);\n} catch (PhutilArgumentUsageException $ex) {\n  // Missing argument: populate it and re-run; nothing was modified.\n}","preventionTips":["Fail fast in scripts when the commit variable is empty (set -u or :? expansion)","Pass exactly one fully qualified commit identifier per invocation"],"tags":["phabricator","differential","cli","extract","missing-argument","usage-error"],"backgroundTag":"cli-usage-error","analyzedSha":"5720a38cfe95b00ca4be5016dd0d2f3195f4fa04","analyzedAt":"2026-08-21T05:07:25.672Z","schemaVersion":2},"datasetVersion":"2026-08-21T11:28:35.574Z"}