propigateAdjustedCommits in seekExportContent

push: When on an adjusted branch, propagate changes to parent branch before
updating export remotes.

This is a somewhat redundant call to propigateAdjustedCommits, since it
also gets called at pushLocal time. That other one needs to come after
importing from importtree remotes though, and seekExportContent has to come
earlier, so I don't see a way to avoid doing it twice.

Note that git-annex sync also manages to avoid the problem, it's only
git-annex push that had the bug.

Sponsored-by: Leon Schuermann on Patreon
This commit is contained in:
Joey Hess 2023-09-11 14:54:26 -04:00
parent aeaadb8eb8
commit 7be8950138
No known key found for this signature in database
GPG key ID: DB12DB0FF05F8F38
4 changed files with 44 additions and 3 deletions

View file

@ -9,6 +9,8 @@ git-annex (10.20230829) UNRELEASED; urgency=medium
* Fix linker optimisation in linux standalone tarballs.
* adb: Avoid some problems with unusual character in exporttree
filenames that confuse adb shell commands.
* push: When on an adjusted branch, propagate changes to parent branch
before updating export remotes.
-- Joey Hess <id@joeyh.name> Mon, 28 Aug 2023 13:10:17 -0400

View file

@ -979,7 +979,17 @@ syncFile o ebloom rs af k = do
- Returns True if any file transfers were made.
-}
seekExportContent :: Maybe SyncOptions -> [Remote] -> CurrBranch -> Annex Bool
seekExportContent o rs (currbranch, _) = or <$> forM rs go
seekExportContent o rs (mcurrbranch, madj)
| null rs = return False
| otherwise = do
-- Propigate commits from the adjusted branch, so that
-- when the remoteAnnexTrackingBranch is set to the parent
-- branch, it will be up-to-date.
case (mcurrbranch, madj) of
(Just currbranch, Just adj) ->
propigateAdjustedCommits currbranch adj
_ -> noop
or <$> forM rs go
where
go r
| maybe False (\o' -> operationMode o' == SatisfyMode) o =
@ -1000,7 +1010,7 @@ seekExportContent o rs (currbranch, _) = or <$> forM rs go
Nothing -> id
mcurrtree <- maybe (pure Nothing)
(inRepo . Git.Ref.tree . addsubdir)
currbranch
mcurrbranch
mtbcommitsha <- Command.Export.getExportCommit r b
case (mtree, mcurrtree, mtbcommitsha) of
(Just tree, Just currtree, Just _)
@ -1021,7 +1031,7 @@ seekExportContent o rs (currbranch, _) = or <$> forM rs go
cannotupdateexport r db mreason showwarning = do
exported <- getExport (Remote.uuid r)
when showwarning $
maybe noop (warncannotupdateexport r mreason exported) currbranch
maybe noop (warncannotupdateexport r mreason exported) mcurrbranch
fillexistingexport r db (exportedTreeishes exported) Nothing
warncannotupdateexport r mreason exported currb = case mreason of

View file

@ -103,3 +103,5 @@ C:\win-push-bug\push-win-repo>
### Have you had any luck using git-annex before? (Sometimes we get tired of reading bug reports all day and a lil' positive end note does wonders)
Yes. I am developing the easy-git-annex api.
> [[fixed|done]] --[[Joey]]

View file

@ -0,0 +1,27 @@
[[!comment format=mdwn
username="joey"
subject="""comment 2"""
date="2023-09-11T17:23:12Z"
content="""
The same behavior can be observed on linux. I just ran `git annex adjust
--unlock` after committing to get into the same state as on Windows.
It's actually not supported to set annex-tracking-branch to an adjusted
branch. Instead, you ought to set:
git config remote.push-win-remote.annex-tracking-branch main
When pulling a new file, as in comment #1, that results in the change
getting merged into main, and then the adjusted branch is automatically
updated as well.
When pushing a newly added file, I first had to run
`git-annex adjust --unlock` in order to update main. That was a
bug in `git-annex push`; it ought to update main for you in this case;
it already does when pushing to a regular git remote. Fixed that.
The "Not updating export to push-win-remote because adjusted/main(unlocked)
does not exist" message is misleading. I've improved that to be
"Not updating export to push-win-remote because tracking branch name is not valid"
which at least hints in the right direction.
"""]]