diff options
author | Jiang Xin <zhiyou.jx@alibaba-inc.com> | 2021-01-11 21:27:02 -0500 |
---|---|---|
committer | Junio C Hamano <gitster@pobox.com> | 2021-01-11 21:50:41 -0800 |
commit | ce1d6d9f1641d87a66c3933255531ee2c15d3143 (patch) | |
tree | bdcafca3cf3b249ffe6b0d347b8317fb11f0ff38 /bundle.c | |
parent | test: add helper functions for git-bundle (diff) | |
download | tgif-ce1d6d9f1641d87a66c3933255531ee2c15d3143.tar.xz |
bundle: lost objects when removing duplicate pendings
`git rev-list` will list one commit for the following command:
$ git rev-list 'main^!'
<tip-commit-of-main-branch>
But providing the same rev-list args to `git bundle`, fail to create
a bundle file.
$ git bundle create - 'main^!'
# v2 git bundle
-<OID> <one-line-message>
fatal: Refusing to create empty bundle.
This is because when removing duplicate objects in function
`object_array_remove_duplicates()`, one unique pending object which has
the same name is deleted by mistake. The revision arg 'main^!' in the
above example is parsed by `handle_revision_arg()`, and at lease two
different objects will be appended to `revs.pending`, one points to the
parent commit of the "main" branch, and the other points to the tip
commit of the "main" branch. These two objects have the same name
"main". Only one object is left with the name "main" after calling the
function `object_array_remove_duplicates()`.
And what's worse, when adding boundary commits into pending list, we use
one-line commit message as names, and the arbitory names may surprise
git-bundle.
Only comparing objects themselves (".item") is also not good enough,
because user may want to create a bundle with two identical objects but
with different reference names, such as: "HEAD" and "refs/heads/main".
Add new function `contains_object()` which compare both the address and
the name of the object.
Signed-off-by: Jiang Xin <zhiyou.jx@alibaba-inc.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
Diffstat (limited to 'bundle.c')
0 files changed, 0 insertions, 0 deletions