From da32ae34b603e57f5182f88f48f60fd6daeb4d35 Mon Sep 17 00:00:00 2001 From: Rajiv Sharma Date: Wed, 13 Mar 2024 04:32:41 -0700 Subject: [PATCH] Enable HEAD symref importing the default in gitimport Summary: Recently, when trying to clone `whatsapp/voip` through Mononoke, we realized that its missing the HEAD symref so if the user clones with `-c init.defaultBranch=<>`, they would get a `remote HEAD refers to nonexistent ref, unable to checkout` error. To avoid this problem in the future, I am enabling symref HEAD importing by default so if the user forgets to pass the flag, they will still end up importing it. Reviewed By: singhsrb, mzr Differential Revision: D54800331 fbshipit-source-id: 2c08dd76262fd5573164f54005d1d2c89dc00139 --- eden/mononoke/git/gitimport/src/main.rs | 6 +++--- .../test-gitbundle-mononoke-add-remove-repo-offset-delta.t | 2 +- .../integration/test-gitbundle-mononoke-add-remove-repo.t | 2 +- .../test-gitbundle-mononoke-multidirectory-repo.t | 2 +- .../integration/test-gitbundle-mononoke-non-ascii-repo.t | 2 +- .../integration/test-gitbundle-mononoke-octopus-repo.t | 2 +- .../integration/test-gitbundle-mononoke-repo-new-commits.t | 2 +- ...t-gitbundle-mononoke-repo-packfileitem-fetch-and-store.t | 2 +- .../test-gitbundle-mononoke-repo-packfileitem-fetch-only.t | 2 +- .../test-gitbundle-mononoke-repo-partial-clone.t | 4 ++-- .../test-gitbundle-mononoke-repo-recursive-tag.t | 4 ++-- .../integration/test-gitbundle-mononoke-repo-submodule.t | 2 +- .../tests/integration/test-gitbundle-mononoke-repo.t | 2 +- .../tests/integration/test-gitimport-discard-submodules.t | 2 +- eden/mononoke/tests/integration/test-gitimport.t | 4 ++-- .../integration/test-mononoke-git-server-clone-with-tag.t | 2 +- .../tests/integration/test-mononoke-git-server-clone.t | 2 +- .../integration/test-mononoke-git-server-fresh-clone.t | 2 +- .../test-mononoke-git-server-pull-with-delta-cycle.t | 4 ++-- .../tests/integration/test-mononoke-git-server-pull.t | 4 ++-- 20 files changed, 27 insertions(+), 27 deletions(-) diff --git a/eden/mononoke/git/gitimport/src/main.rs b/eden/mononoke/git/gitimport/src/main.rs index 8a944f2ba0b0c..221d94424d140 100644 --- a/eden/mononoke/git/gitimport/src/main.rs +++ b/eden/mononoke/git/gitimport/src/main.rs @@ -119,9 +119,9 @@ struct GitimportArgs { /// Use at your own risk! #[clap(long)] generate_bookmarks: bool, - /// If set, will record the HEAD symref in Mononoke for the given repo + /// If set, will skip recording the HEAD symref in Mononoke for the given repo #[clap(long)] - record_head_symref: bool, + skip_head_symref: bool, /// When set, the gitimport tool would bypass the read-only check while creating and moving bookmarks. #[clap(long)] bypass_readonly: bool, @@ -299,7 +299,7 @@ async fn async_main(app: MononokeApp) -> Result<(), Error> { .await .context("derive_hg failed")?; } - if args.record_head_symref { + if !args.skip_head_symref { let symref_entry = import_tools::read_symref(HEAD_SYMREF, path, &prefs) .await .context("read_symrefs failed")?; diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo-offset-delta.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo-offset-delta.t index 5917609e389ed..0dddb3abce5d0 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo-offset-delta.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo-offset-delta.t @@ -72,7 +72,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 6 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 6 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo.t index fdbb61b5b4b09..33e00323b8dec 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-add-remove-repo.t @@ -72,7 +72,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 6 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 6 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-multidirectory-repo.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-multidirectory-repo.t index 5c05c6e8c3228..7c2f6d7db0daf 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-multidirectory-repo.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-multidirectory-repo.t @@ -81,7 +81,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:$TESTTMP/repo-git commit 1 of 7 - Oid:8ce3eae4 => Bid:032cd4dc (glob) * GitRepo:$TESTTMP/repo-git commit 2 of 7 - Oid:a612a217 => Bid:148f9770 (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-non-ascii-repo.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-non-ascii-repo.t index 76d0ee87796f3..e36d764fbc76e 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-non-ascii-repo.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-non-ascii-repo.t @@ -41,7 +41,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-octopus-repo.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-octopus-repo.t index 1bb0012155956..e3963c17e5ed3 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-octopus-repo.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-octopus-repo.t @@ -65,7 +65,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 5 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 5 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-new-commits.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-new-commits.t index 4732e8d3c0b04..08af073df8c33 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-new-commits.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-new-commits.t @@ -45,7 +45,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-and-store.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-and-store.t index d1f87ad55d23e..7b87bf83e410c 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-and-store.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-and-store.t @@ -81,7 +81,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:$TESTTMP/repo-git commit 1 of 7 - Oid:8ce3eae4 => Bid:032cd4dc (glob) * GitRepo:$TESTTMP/repo-git commit 2 of 7 - Oid:a612a217 => Bid:148f9770 (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-only.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-only.t index b9967dc69d618..301697f5da631 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-only.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-packfileitem-fetch-only.t @@ -81,7 +81,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:$TESTTMP/repo-git commit 1 of 7 - Oid:8ce3eae4 => Bid:032cd4dc (glob) * GitRepo:$TESTTMP/repo-git commit 2 of 7 - Oid:a612a217 => Bid:148f9770 (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-partial-clone.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-partial-clone.t index 1283c6004e238..9a8a48abd6590 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-partial-clone.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-partial-clone.t @@ -35,7 +35,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) @@ -88,7 +88,7 @@ # Import the new commits into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:$TESTTMP/repo-git commit 1 of 4 - Oid:8ce3eae4 => Bid:032cd4dc (already exists) (glob) * GitRepo:$TESTTMP/repo-git commit 2 of 4 - Oid:e8615d6f => Bid:da93dc81 (already exists) (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-recursive-tag.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-recursive-tag.t index 1eccd32326e2f..87c0fc8b9d1da 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-recursive-tag.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-recursive-tag.t @@ -44,7 +44,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) @@ -99,7 +99,7 @@ $ git rev-list --objects --all | git cat-file --batch-check='%(objectname) %(objecttype) %(rest)' | sort > $TESTTMP/object_list # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-submodule.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-submodule.t index ba4b8f8f71250..eb2e1febacafe 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-submodule.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo-submodule.t @@ -62,7 +62,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 3 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 3 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo.t b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo.t index 1c459ec9a735d..7788ecaf249b5 100644 --- a/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo.t +++ b/eden/mononoke/tests/integration/test-gitbundle-mononoke-repo.t @@ -45,7 +45,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-gitimport-discard-submodules.t b/eden/mononoke/tests/integration/test-gitimport-discard-submodules.t index b21f2b0f22a3a..aa88466845df2 100644 --- a/eden/mononoke/tests/integration/test-gitimport-discard-submodules.t +++ b/eden/mononoke/tests/integration/test-gitimport-discard-submodules.t @@ -104,7 +104,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ with_stripped_logs gitimport --record-head-symref "$GIT_REPO" --generate-bookmarks --discard-submodules full-repo + $ with_stripped_logs gitimport "$GIT_REPO" --generate-bookmarks --discard-submodules full-repo using repo "repo" repoid RepositoryId(0) GitRepo:$TESTTMP/repo-git commit 1 of 3 - Oid:8ce3eae4 => Bid:032cd4dc GitRepo:$TESTTMP/repo-git commit 2 of 3 - Oid:e8615d6f => Bid:da93dc81 diff --git a/eden/mononoke/tests/integration/test-gitimport.t b/eden/mononoke/tests/integration/test-gitimport.t index f31dc3c0b49ae..9b754470e1d14 100644 --- a/eden/mononoke/tests/integration/test-gitimport.t +++ b/eden/mononoke/tests/integration/test-gitimport.t @@ -35,7 +35,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --concurrency 100 --derive-hg full-repo + $ gitimport "$GIT_REPO" --concurrency 100 --derive-hg full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 1 - Oid:* => Bid:* (glob) * Hg: Sha1(8ce3eae44760b500bf3f2c3922a95dcd3c908e9e): HgManifestId(HgNodeHash(Sha1(*))) (glob) @@ -137,7 +137,7 @@ * Nothing to import for repo *repo-git. (glob) # Also check that a readonly import works - $ gitimport "$GIT_REPO" --with-readonly-storage=true --derive-hg full-repo + $ gitimport "$GIT_REPO" --with-readonly-storage=true --derive-hg --skip-head-symref full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-mononoke-git-server-clone-with-tag.t b/eden/mononoke/tests/integration/test-mononoke-git-server-clone-with-tag.t index 7a79ddbff89b7..872e7f55681a2 100644 --- a/eden/mononoke/tests/integration/test-mononoke-git-server-clone-with-tag.t +++ b/eden/mononoke/tests/integration/test-mononoke-git-server-clone-with-tag.t @@ -42,7 +42,7 @@ Go back to the master branch # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null + $ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null # Start up the Mononoke Git Service $ mononoke_git_service diff --git a/eden/mononoke/tests/integration/test-mononoke-git-server-clone.t b/eden/mononoke/tests/integration/test-mononoke-git-server-clone.t index b44fe093e0f86..8c761722208ad 100644 --- a/eden/mononoke/tests/integration/test-mononoke-git-server-clone.t +++ b/eden/mononoke/tests/integration/test-mononoke-git-server-clone.t @@ -39,7 +39,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-mononoke-git-server-fresh-clone.t b/eden/mononoke/tests/integration/test-mononoke-git-server-fresh-clone.t index acb845856d2b2..63f3589219f1b 100644 --- a/eden/mononoke/tests/integration/test-mononoke-git-server-fresh-clone.t +++ b/eden/mononoke/tests/integration/test-mononoke-git-server-fresh-clone.t @@ -39,7 +39,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo * using repo "repo" repoid RepositoryId(0) (glob) * GitRepo:*repo-git commit 1 of 2 - Oid:* => Bid:* (glob) * GitRepo:*repo-git commit 2 of 2 - Oid:* => Bid:* (glob) diff --git a/eden/mononoke/tests/integration/test-mononoke-git-server-pull-with-delta-cycle.t b/eden/mononoke/tests/integration/test-mononoke-git-server-pull-with-delta-cycle.t index 6c5b84bf0c786..980e53dc95460 100644 --- a/eden/mononoke/tests/integration/test-mononoke-git-server-pull-with-delta-cycle.t +++ b/eden/mononoke/tests/integration/test-mononoke-git-server-pull-with-delta-cycle.t @@ -41,7 +41,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null # Start up the Mononoke Git Service $ mononoke_git_service @@ -71,7 +71,7 @@ # Import the newly added commits to Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null + $ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null # Pull the Git repo from Mononoke $ cd $REPONAME $ git_client pull $MONONOKE_GIT_SERVICE_BASE_URL/$REPONAME.git &> /dev/null diff --git a/eden/mononoke/tests/integration/test-mononoke-git-server-pull.t b/eden/mononoke/tests/integration/test-mononoke-git-server-pull.t index 4c5d6ed008771..f69e29d07df34 100644 --- a/eden/mononoke/tests/integration/test-mononoke-git-server-pull.t +++ b/eden/mononoke/tests/integration/test-mononoke-git-server-pull.t @@ -40,7 +40,7 @@ # Import it into Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null + $ gitimport "$GIT_REPO" --derive-hg --generate-bookmarks full-repo &> /dev/null # Start up the Mononoke Git Service $ mononoke_git_service @@ -69,7 +69,7 @@ # Import the newly added commits to Mononoke $ cd "$TESTTMP" - $ gitimport --record-head-symref "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null + $ gitimport "$GIT_REPO_ORIGIN" --derive-hg --generate-bookmarks full-repo &> /dev/null # Pull the Git repo from Mononoke $ cd $REPONAME $ git_client pull $MONONOKE_GIT_SERVICE_BASE_URL/$REPONAME.git &> /dev/null