git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: Git revert cannot be aborted if the repository directory has been copied

From
PWPhillip Wood <phillip.wood123@gmail.com>
Date
Nov 4, 2024, 09:55 UTC
Message-ID
<c1a8eb10-ac62-49f2-a40e-36c41bbdc991@gmail.com>
In-Reply-To
<AM0PR02MB4980D186BDC087336C760132E6502@AM0PR02MB4980.eurprd02.prod.outlook.com>
On 03/11/2024 01:25, Marco Stephan wrote:
Show 6 quoted lines
> Hello,
> 
> I have encountered the following bug:
> If you copy a Git repository directory to another path while there is a revert in progress for the Git repository, "git revert --abort" does not work anymore for the copied repository. Instead, it will report an error of the following format:
>       error: Entry '...' not uptodate. Cannot merge.
>       fatal: Could not reset index file to revision '...'.

"git revert --abort" is a wrapper around "git reset --merge" so I wonder if we should change "git reset --merge" to refresh the index.

Best Wishes
Phillip
Show 21 quoted lines
> I can reproduce the bug consistently with the latest version of Git that is available for Windows (git version 2.47.0.windows.2) by performing the following steps (all command line except step 12):
> 1. mkdir test_repo
> 2. cd test_repo
> 3. git init
> 4. type nul > test.txt
> 5. git add .
> 6. git commit -m "Initial commit"
> 7. echo test > test.txt
> 8. git add .
> 9. git commit -m "Changes"
> 10. git revert HEAD --no-commit
> 11. cd ..
> 12. Manually copy test_repo to a new directory test_repo_copy using the file explorer (using e.g. "robocopy test_repo test_repo_copy /E" does not corrupt the repository)
> 13. cd test_repo_copy
> 14. git revert --abort
> This consistently produces the error "error: Entry 'test.txt' not uptodate. Cannot merge.". I would expect step 14 to work regardless of how the repository directory itself has been created. Running "git status" or "git update --really-refresh" fixes the seemingly corrupt data and the revert in progress can be aborted.
> 
> I have not verified if the bug is present on other operation systems, too.
> 
> With best regards
> Marco Stephan
Previous: Marco StephanNext: Marco Stephan
Message 7 of 8 in “Git revert cannot be aborted if the repository directory has been copied”
  1. Marco StephanNov 3, 2024
  2. Junio C HamanoNov 3, 2024
  3. Kristoffer HaugsbakkNov 3, 2024
  4. Kristoffer HaugsbakkNov 3, 2024
  5. Kristoffer HaugsbakkNov 3, 2024
  6. AW: Git revert cannot be aborted if the repository directory has been copiedMarco Stephan, Nov 3, 2024
  7. Phillip WoodNov 4, 2024
  8. AW: Git revert cannot be aborted if the repository directory has been copiedMarco Stephan, Nov 7, 2024

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.