summaryrefslogtreecommitdiff
path: root/shortlog.h
diff options
context:
space:
mode:
authorPatrick Steinhardt <ps@pks.im>2021-01-12 12:27:35 (GMT)
committerJunio C Hamano <gitster@pobox.com>2021-01-12 20:06:14 (GMT)
commit58a646a3688ea3c15adaf481e440e9ca2d3bce06 (patch)
tree80a8b3dc704040eadae7bdbcad8f60f98139b08a /shortlog.h
parent72c4083ddf91b489b7b7b812df67ee8842177d98 (diff)
downloadgit-58a646a3688ea3c15adaf481e440e9ca2d3bce06.zip
git-58a646a3688ea3c15adaf481e440e9ca2d3bce06.tar.gz
git-58a646a3688ea3c15adaf481e440e9ca2d3bce06.tar.bz2
fetch: extract writing to FETCH_HEAD
When performing a fetch with the default `--write-fetch-head` option, we write all updated references to FETCH_HEAD while the updates are performed. Given that updates are not performed atomically, it means that we we write to FETCH_HEAD even if some or all of the reference updates fail. Given that we simply update FETCH_HEAD ad-hoc with each reference, the logic is completely contained in `store_update_refs` and thus quite hard to extend. This can already be seen by the way we skip writing to the FETCH_HEAD: instead of having a conditional which simply skips writing, we instead open "/dev/null" and needlessly write all updates there. We are about to extend git-fetch(1) to accept an `--atomic` flag which will make the fetch an all-or-nothing operation with regards to the reference updates. This will also require us to make the updates to FETCH_HEAD an all-or-nothing operation, but as explained doing so is not easy with the current layout. This commit thus refactors the wa we write to FETCH_HEAD and pulls out the logic to open, append to, commit and close the file. While this may seem rather over-the top at first, pulling out this logic will make it a lot easier to update the code in a subsequent commit. It also allows us to easily skip writing completely in case `--no-write-fetch-head` was passed. Signed-off-by: Patrick Steinhardt <ps@pks.im> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'shortlog.h')
0 files changed, 0 insertions, 0 deletions