diff --git a/src/workflow/ArcanistDiffWorkflow.php b/src/workflow/ArcanistDiffWorkflow.php --- a/src/workflow/ArcanistDiffWorkflow.php +++ b/src/workflow/ArcanistDiffWorkflow.php @@ -2882,8 +2882,8 @@ $commit = $api->getHeadCommit(); $prefix = idx($staging, 'prefix', 'phabricator'); - $base_tag = "refs/tags/{$prefix}/base/{$id}"; - $diff_tag = "refs/tags/{$prefix}/diff/{$id}"; + $base_tag = "refs/heads/{$prefix}/base/{$id}"; + $diff_tag = "refs/heads/{$prefix}/diff/{$id}"; $this->writeOkay( pht('PUSH STAGING'), @@ -2900,6 +2900,32 @@ 'uri' => $staging_uri, ); + // Make a consistent name go that `git lfs` will cache which files need + // pushing and not just walk the whole directory. As recommend in: + // https://github.com/git-lfs/git-lfs/issues/4076 + $staging_remote = 'phabriactor-staging'; + $err = phutil_passthru( + 'git remote add %s %s', + $staging_remote, + $staging_uri); + if ($err) { + $this->writeWarn( + pht('STAGING FAILED'), + pht('Unable add %s remote branch. Does it already exist?', + $staging_remote)); + return self::STAGING_CLIENT_UNSUPPORTED; + } + + list($err, $stdout, $stderr) = exec_manual('git fetch %s', $staging_remote); + if ($err) { + $this->writeWarn( + pht('STAGING FAILED'), + pht('Unable to fetch %s.', $staging_remote)); + return self::STAGING_CLIENT_UNSUPPORTED; + } + + $push_flags[] = $staging_remote; + // If the base commit is a real commit, we're going to push it. We don't // use this, but pushing it to a ref reduces the amount of redundant work // that Git does on later pushes by helping it figure out that the remote @@ -2933,9 +2959,8 @@ } $err = phutil_passthru( - 'git push %Ls -- %s %Ls', + 'git push %Ls -- %Ls', $push_flags, - $staging_uri, $ref_list); if ($err) { @@ -2949,6 +2974,10 @@ 'use --skip-staging to skip this step.')); } + phutil_passthru( + 'git remote remove %s', + $staging_remote); + return $refs; }