Skip to content

Commit

Permalink
Merge pull request #300: Drop --no-update-remote-refs based on upstre…
Browse files Browse the repository at this point in the history
…am feedback

As I was upstreaming the `--no-update-remote-refs` option, Peff pointed out that we already have a way to do what I was trying to do. It's a little obscure, but the `--refmap=` option will override the configured refspec that is normally populating the remote refs.

This will allow me to revert [the `--no-update-remote-refs` option](microsoft/git@7f8481b) in microsoft/git.
  • Loading branch information
derrickstolee authored Jan 22, 2020
2 parents 3dfab39 + 51132af commit a10fb55
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
6 changes: 4 additions & 2 deletions Scalar.Common/Git/GitProcess.cs
Original file line number Diff line number Diff line change
Expand Up @@ -432,10 +432,12 @@ public Result BackgroundFetch(string remote)
string refspec = $"+{ScalarConstants.DotGit.Refs.Heads.RefName}/*"
+ $":{ScalarConstants.DotGit.Refs.Scalar.Hidden.RefName}/{remote}/*";

// By using "--no-update-remote-refs", the user will see their remote refs update
// By using "--refmap", we override the configured refspec,
// ignoring the normal "+refs/heads/*:refs/remotes/<remote>/*".
// The user will see their remote refs update
// normally when they do a foreground fetch.
return this.InvokeGitInWorkingDirectoryRoot(
$"fetch {remote} --quiet --prune --no-update-remote-refs \"{refspec}\"",
$"fetch {remote} --quiet --prune --no-tags --refmap= \"{refspec}\"",
fetchMissingObjects: true);
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -106,13 +106,17 @@ public void FetchStep()
string refsRemotesOrigin = Path.Combine(refsRoot, "remotes", "origin");
string refsHidden = Path.Combine(refsRoot, "scalar", "hidden");
string refsHiddenOriginFake = Path.Combine(refsHidden, "origin", "fake");
string packedRefs = Path.Combine(this.Enlistment.RepoRoot, ".git", "packed-refs");

// Removing refs makes the next fetch need to download a new pack
this.fileSystem.DeleteDirectory(refsHeads);
this.fileSystem.DeleteDirectory(refsRemotesOrigin);
this.fileSystem.DeleteDirectory(this.PackRoot);
this.fileSystem.CreateDirectory(this.PackRoot);
this.fileSystem.DirectoryExists(refsRemotesOrigin).ShouldBeFalse($"{refsRemotesOrigin} was not deleted");
if (this.fileSystem.FileExists(packedRefs))
{
this.fileSystem.DeleteFile(packedRefs);
}

this.Enlistment.RunVerb("fetch");

Expand Down

0 comments on commit a10fb55

Please sign in to comment.