Repository navigation
pr-2252/becm/fix-fast-import-commit-from-existing-v3
tagged this
14 Oct 16:27
From: Marc Becker <becm@gmx.de> During a 'git fast-import' session, newly created objects are written to an in-progress packfile and recorded in fast-import's internal object table. Until a 'checkpoint' command or the end of the session finalizes and indexes that packfile, these objects are not visible to the repository's object database via odb_read_object_peeled(). Commands such as 'ls' (via parse_treeish_dataref() and dereference()) and 'cat-blob' already account for this when given a hex object name: they look up the object in fast-import's internal object table with find_object() first and read it from the in-progress packfile with gfi_unpack_entry() when its '.pack_id' is not MAX_PACK_ID. By contrast, when 'from <committish>' (in a 'commit' or 'reset' command) is given a hex object name instead of a mark or branch name, parse_objectish() parses the hex string into 'b->oid' and calls parse_from_existing(), which unconditionally looks up the object via odb_read_object_peeled(). If the object is a commit or tag created in the current pack cycle, odb_read_object_peeled() returns NULL and fast-import dies with "fatal: not a valid commit: <oid>". Teach parse_from_existing() to look up 'b->oid' with find_object() first, peel any tag objects in the object table using dereference(), and unpack the target commit with gfi_unpack_entry() if it resides in the in-progress packfile, before falling back to odb_read_object_peeled() for objects in the repository's object database. Signed-off-by: Marc Becker <becm@gmx.de> Submitted-As: https://lore.kernel.org/git/pull.2252.v3.git.1791995252623.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2252.git.1791653078449.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2252.v2.git.1791845420568.gitgitgadget@gmail.com