]> dgit.raspbian.org Git - git-annex.git/commitdiff
push synced/master before synced/git-annex
authorJoey Hess <joeyh@joeyh.name>
Mon, 21 Jun 2021 16:32:21 +0000 (12:32 -0400)
committerJoey Hess <joeyh@joeyh.name>
Mon, 21 Jun 2021 16:32:21 +0000 (12:32 -0400)
sync: Partly work around github behavior that first branch to be pushed to
a new repository is assumed to be the head branch, by not pushing
synced/git-annex first.

github expects master (or whatever the name is) to be pushed first, but
git-annex sync can't, because it's got to also support pushes to non-bare
repos where pushing master fails, as explained in the big comment. So
pushing synced/master is not entirely a fix, but at least it makes github
default to a branch with the stuff the user expects in it, not a bunch of
annex log files.

Aside from fixing github to not make this assumption, or improving
the git push protocol to include what the current HEAD is, the only other
approach I can think of is to identify git push's progress messages and
display those when pushing master, while filtering out error messages
about non-fast-forward etc. But git doesn't provide a way to separate out
or identify its progress messages.

Sponsored-by: Luke Shumaker on Patreon
CHANGELOG
Command/Sync.hs
doc/forum/Issues_with_IPFS_special_remote/comment_11_e53b0158471605950896cafac7aac4da._comment [new file with mode: 0644]

index 42c636b88b64f3eaf085737b3d56175a87c6a149..c0629ad3b87710ad73f762cf5edcbfbcc356aff6 100644 (file)
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,11 @@
+git-annex (8.20210622) UNRELEASED; urgency=medium
+
+  * sync: Partly work around github behavior that first branch to be pushed
+    to a new repository is assumed to be the head branch, by not pushing
+    synced/git-annex first.
+
+ -- Joey Hess <id@joeyh.name>  Mon, 21 Jun 2021 12:25:25 -0400
+
 git-annex (8.20210621) upstream; urgency=medium
 
   * New matching options --excludesamecontent and --includesamecontent
index 167d271cdcb6b44e7f8d4933ff446c1d7308cd32..8ab5b0adaf90c14fef3b8c13f6ade51a42d9b7b4 100644 (file)
@@ -604,8 +604,15 @@ pushRemote o remote (Just branch, _) = do
  - direct push is tried, with stderr discarded, to update the branch ref
  - on the remote.
  -
- - The sync push forces the update of the remote synced/git-annex branch.
- - This is necessary if a transition has rewritten the git-annex branch.
+ - The sync push first sends the synced/master branch,
+ - and then forces the update of the remote synced/git-annex branch.
+ -
+ - Since some providers like github may treat the first branch sent
+ - as the default branch, it's better to make that be synced/master than
+ - synced/git-annex. (Although neither is ideal, it's the best that
+ - can be managed given the constraints on order.)
+ -
+ - The forcing is necessary if a transition has rewritten the git-annex branch.
  - Normally any changes to the git-annex branch get pulled and merged before
  - this push, so this forcing is unlikely to overwrite new data pushed
  - in from another repository that is also syncing.
@@ -618,8 +625,8 @@ pushBranch :: Remote -> Maybe Git.Branch -> Git.Repo -> IO Bool
 pushBranch remote mbranch g = directpush `after` annexpush `after` syncpush
   where
        syncpush = flip Git.Command.runBool g $ pushparams $ catMaybes
-               [ Just $ Git.Branch.forcePush $ refspec Annex.Branch.name
-               , (refspec . fromAdjustedBranch) <$> mbranch
+               [ (refspec . fromAdjustedBranch) <$> mbranch
+               , Just $ Git.Branch.forcePush $ refspec Annex.Branch.name
                ]
        annexpush = void $ tryIO $ flip Git.Command.runQuiet g $ pushparams
                [ Git.fromRef $ Git.Ref.base $ Annex.Branch.name ]
diff --git a/doc/forum/Issues_with_IPFS_special_remote/comment_11_e53b0158471605950896cafac7aac4da._comment b/doc/forum/Issues_with_IPFS_special_remote/comment_11_e53b0158471605950896cafac7aac4da._comment
new file mode 100644 (file)
index 0000000..30c0245
--- /dev/null
@@ -0,0 +1,7 @@
+[[!comment format=mdwn
+ username="joey"
+ subject="""comment 11"""
+ date="2021-06-21T16:25:13Z"
+ content="""
+Changed the sync order as I discussed.
+"""]]