* Git revert cannot be aborted if the repository directory has been copied
@ 2024-11-03 1:25 Marco Stephan
2024-11-03 2:34 ` Junio C Hamano
` (2 more replies)
0 siblings, 3 replies; 8+ messages in thread
From: Marco Stephan @ 2024-11-03 1:25 UTC (permalink / raw)
To: git@vger.kernel.org
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 '...'.
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
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Git revert cannot be aborted if the repository directory has been copied
2024-11-03 1:25 Git revert cannot be aborted if the repository directory has been copied Marco Stephan
@ 2024-11-03 2:34 ` Junio C Hamano
2024-11-03 15:04 ` Kristoffer Haugsbakk
2024-11-03 15:13 ` Kristoffer Haugsbakk
2024-11-04 9:55 ` Phillip Wood
2 siblings, 1 reply; 8+ messages in thread
From: Junio C Hamano @ 2024-11-03 2:34 UTC (permalink / raw)
To: Marco Stephan; +Cc: git@vger.kernel.org
Marco Stephan <marc.stephan96@hotmail.de> writes:
> 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 '...'.
I wonder if
$ git update-index --refresh
is all it takes. The symptom, i.e. Git declares that an otherwise
unmodifed path is not uptodate, is not limited to "revert" or
aborting it, but is a common thing a newbie sees after copyihg a
working tree to elsewhere, and "refresh the index" is an often given
recovery procedure for such a situation.
I'll not comment if this is a bug or not, and let others argue.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Git revert cannot be aborted if the repository directory has been copied
2024-11-03 2:34 ` Junio C Hamano
@ 2024-11-03 15:04 ` Kristoffer Haugsbakk
2024-11-03 15:07 ` Kristoffer Haugsbakk
0 siblings, 1 reply; 8+ messages in thread
From: Kristoffer Haugsbakk @ 2024-11-03 15:04 UTC (permalink / raw)
To: Junio C Hamano, Marco Stephan; +Cc: git@vger.kernel.org
On Sun, Nov 3, 2024, at 03:34, Junio C Hamano wrote:
> Marco Stephan <marc.stephan96@hotmail.de> writes:
>
>> 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 '...'.
>
> I wonder if
>
> $ git update-index --refresh
>
> is all it takes.
This is correct. This successful test can be added to
t3501-revert-cherry-pick.sh:
```
test_expect_success 'cp -r repo in the middle of a revert' '
test_when_finished rm -r new-repo &&
test_when_finished rm -r copy-repo &&
test_create_repo new-repo &&
(
cd new-repo &&
echo nul >test.txt &&
git add test.txt &&
git commit -m "Initial commit" &&
echo test >test.txt &&
git add test.txt &&
git commit -m "Changes" &&
git revert HEAD --no-commit
) &&
cp -r new-repo copy-repo &&
(
cd copy-repo &&
# Needed in order to avoid
# error: Entry test.txt not uptodate. Cannot merge.
git update-index --refresh &&
git revert --abort
)
'
```
--
Kristoffer Haugsbakk
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Git revert cannot be aborted if the repository directory has been copied
2024-11-03 15:04 ` Kristoffer Haugsbakk
@ 2024-11-03 15:07 ` Kristoffer Haugsbakk
0 siblings, 0 replies; 8+ messages in thread
From: Kristoffer Haugsbakk @ 2024-11-03 15:07 UTC (permalink / raw)
To: Junio C Hamano, Marco Stephan; +Cc: git@vger.kernel.org
On Sun, Nov 3, 2024, at 16:04, Kristoffer Haugsbakk wrote:
> On Sun, Nov 3, 2024, at 03:34, Junio C Hamano wrote:
>> Marco Stephan <marc.stephan96@hotmail.de> writes:
>>
>>> 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 '...'.
>>
>> I wonder if
>>
>> $ git update-index --refresh
>>
>> is all it takes.
>
>
> This is correct. This successful test can be added to
> t3501-revert-cherry-pick.sh:
(Meaning one can add it there if one wants to see for themselves)
--
Kristoffer Haugsbakk
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Git revert cannot be aborted if the repository directory has been copied
2024-11-03 1:25 Git revert cannot be aborted if the repository directory has been copied Marco Stephan
2024-11-03 2:34 ` Junio C Hamano
@ 2024-11-03 15:13 ` Kristoffer Haugsbakk
2024-11-03 17:33 ` AW: " Marco Stephan
2024-11-04 9:55 ` Phillip Wood
2 siblings, 1 reply; 8+ messages in thread
From: Kristoffer Haugsbakk @ 2024-11-03 15:13 UTC (permalink / raw)
To: Marco Stephan, git@vger.kernel.org
On Sun, Nov 3, 2024, at 02:25, Marco Stephan wrote:
> 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.
Okay, I missed that `git update-index --really-refresh` previously.
I’m not a technical expert but is there a use-case here? Or did you
find this by accident while doing something else?
--
Kristoffer Haugsbakk
^ permalink raw reply [flat|nested] 8+ messages in thread
* AW: Git revert cannot be aborted if the repository directory has been copied
2024-11-03 15:13 ` Kristoffer Haugsbakk
@ 2024-11-03 17:33 ` Marco Stephan
0 siblings, 0 replies; 8+ messages in thread
From: Marco Stephan @ 2024-11-03 17:33 UTC (permalink / raw)
To: Kristoffer Haugsbakk, git@vger.kernel.org
On Sun, Nov 3, 2024, at 16:13, Kristoffer Haugsbakk wrote:
> Okay, I missed that `git update-index --really-refresh` previously.
>
> I’m not a technical expert but is there a use-case here? Or did you
> find this by accident while doing something else?
I stumbled upon this behavior while working on some Git scripts. For these, I've prepared template repositories which I then copy and run the scripts on. This specific scenario in which I want to abort a revert in progress is, so far, the only scenario where this copying causes problems. All other Git commands I've used seem to simply ignore it or "refresh the index" on their own. For example, "git cherry-pick --abort" does not run into this problems for me.
^ permalink raw reply [flat|nested] 8+ messages in thread
* Re: Git revert cannot be aborted if the repository directory has been copied
2024-11-03 1:25 Git revert cannot be aborted if the repository directory has been copied Marco Stephan
2024-11-03 2:34 ` Junio C Hamano
2024-11-03 15:13 ` Kristoffer Haugsbakk
@ 2024-11-04 9:55 ` Phillip Wood
2024-11-07 19:52 ` AW: " Marco Stephan
2 siblings, 1 reply; 8+ messages in thread
From: Phillip Wood @ 2024-11-04 9:55 UTC (permalink / raw)
To: Marco Stephan, git@vger.kernel.org; +Cc: Junio C Hamano
On 03/11/2024 01:25, Marco Stephan wrote:
> 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
> 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
^ permalink raw reply [flat|nested] 8+ messages in thread
* AW: Git revert cannot be aborted if the repository directory has been copied
2024-11-04 9:55 ` Phillip Wood
@ 2024-11-07 19:52 ` Marco Stephan
0 siblings, 0 replies; 8+ messages in thread
From: Marco Stephan @ 2024-11-07 19:52 UTC (permalink / raw)
To: git@vger.kernel.org, phillip.wood@dunelm.org.uk; +Cc: Junio C Hamano
On Sun, Nov 4, 2024, at 10:55, Phillip Wood wrote:
> "git revert --abort" is a wrapper around "git reset --merge" so I wonder
> if we should change "git reset --merge" to refresh the index.
In my novice opinion I agree. If "git revert --abort" is just a wrapper for "git reset --merge" then I think "git reset --merge" should itself refresh the index. Other commands (e.g. "git cherry-pick --abort") seem to perform a refresh as well.
^ permalink raw reply [flat|nested] 8+ messages in thread
end of thread, other threads:[~2024-11-07 19:52 UTC | newest]
Thread overview: 8+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-11-03 1:25 Git revert cannot be aborted if the repository directory has been copied Marco Stephan
2024-11-03 2:34 ` Junio C Hamano
2024-11-03 15:04 ` Kristoffer Haugsbakk
2024-11-03 15:07 ` Kristoffer Haugsbakk
2024-11-03 15:13 ` Kristoffer Haugsbakk
2024-11-03 17:33 ` AW: " Marco Stephan
2024-11-04 9:55 ` Phillip Wood
2024-11-07 19:52 ` AW: " Marco Stephan
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).