* [PATCH] refs: return conflict error when checking packed refs
@ 2024-04-30 14:50 Ivan Tse via GitGitGadget
2024-05-02 12:38 ` Patrick Steinhardt
2024-05-03 4:50 ` [PATCH v2] " Ivan Tse via GitGitGadget
0 siblings, 2 replies; 11+ messages in thread
From: Ivan Tse via GitGitGadget @ 2024-04-30 14:50 UTC (permalink / raw)
To: git; +Cc: Ivan Tse, Ivan Tse
From: Ivan Tse <ivan.tse1@gmail.com>
The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
ref due to a name conflict with another ref. An example of this is a
directory/file conflict such as ref names A/B and A.
"git fetch" uses this error code to more accurately describe the error
by recommending to the user that they try running "git remote prune" to
remove any old refs that are deleted by the remote which would clear up
any directory/file conflicts.
This helpful error message is not displayed when the conflicted ref is
stored in packed refs. This change fixes this by ensuring error return
code consistency in `lock_raw_ref`.
Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
---
refs: return conflict error when checking packed refs
I wanted to provide extra context around the error message I'm referring
to so it's clear what I'm trying to achieve.
First, let's get into a directory/file conflict situation:
git branch dir_file_conflict
git push origin dir_file_conflict
git update-ref -d refs/remotes/origin/dir_file_conflict
git update-ref -d refs/heads/dir_file_conflict
git update-ref refs/remotes/origin/dir_file_conflict/file master
From above, the remote origin has a dir_file_conflict ref name and the
local repository has a dir_file_conflict/file ref name for the remote.
This situation can occur if dir_file_conflict/file used to exist and but
was later deleted in the remote.
Then when we git fetch:
yolo10[master] $ git fetch
error: cannot lock ref 'refs/remotes/origin/dir_file_conflict': 'refs/remotes/origin/dir_file_conflict/file' exists; cannot create 'refs/remotes/origin/dir_file_conflict'
From github.com:ivantsepp/yolo10
! [new branch] dir_file_conflict -> origin/dir_file_conflict (unable to update local ref)
error: some local refs could not be updated; try running
'git remote prune origin' to remove any old, conflicting branches
We get the helpful error message to run git remote prune origin to
remove old, conflicting branches.
However, when the ref is stored in packed refs:
yolo10[master] $ git pack-refs --all
yolo10[master] $ git fetch
error: cannot lock ref 'refs/remotes/origin/dir_file_conflict': 'refs/remotes/origin/dir_file_conflict/file' exists; cannot create 'refs/remotes/origin/dir_file_conflict'
From github.com:ivantsepp/yolo10
! [new branch] dir_file_conflict -> origin/dir_file_conflict (unable to update local ref)
The helpful message is not there! I believe this error message should
show up regardless of how the ref is stored (loose vs packed-refs). I
attempted to track down the necessary change to make this happen and it
seems like a straightforward change. I hope I didn't overlook anything!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1716%2Fivantsepp%2Freturn_name_conflict_error_for_packed_refs-v1
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1716/ivantsepp/return_name_conflict_error_for_packed_refs-v1
Pull-Request: https://github.com/git/git/pull/1716
refs/files-backend.c | 4 +++-
1 file changed, 3 insertions(+), 1 deletion(-)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a098d14ea00..97473f377d1 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
*/
if (refs_verify_refname_available(
refs->packed_ref_store, refname,
- extras, NULL, err))
+ extras, NULL, err)) {
+ ret = TRANSACTION_NAME_CONFLICT;
goto error_return;
+ }
}
ret = 0;
base-commit: 786a3e4b8d754d2b14b1208b98eeb0a554ef19a8
--
gitgitgadget
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH] refs: return conflict error when checking packed refs
2024-04-30 14:50 [PATCH] refs: return conflict error when checking packed refs Ivan Tse via GitGitGadget
@ 2024-05-02 12:38 ` Patrick Steinhardt
2024-05-03 4:50 ` [PATCH v2] " Ivan Tse via GitGitGadget
1 sibling, 0 replies; 11+ messages in thread
From: Patrick Steinhardt @ 2024-05-02 12:38 UTC (permalink / raw)
To: Ivan Tse via GitGitGadget; +Cc: git, Ivan Tse
[-- Attachment #1: Type: text/plain, Size: 948 bytes --]
On Tue, Apr 30, 2024 at 02:50:47PM +0000, Ivan Tse via GitGitGadget wrote:
> From: Ivan Tse <ivan.tse1@gmail.com>
>
> The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
> ref due to a name conflict with another ref. An example of this is a
> directory/file conflict such as ref names A/B and A.
>
> "git fetch" uses this error code to more accurately describe the error
> by recommending to the user that they try running "git remote prune" to
> remove any old refs that are deleted by the remote which would clear up
> any directory/file conflicts.
>
> This helpful error message is not displayed when the conflicted ref is
> stored in packed refs. This change fixes this by ensuring error return
> code consistency in `lock_raw_ref`.
The change itself makes sense to me. But I'd like to see a test that
demonstrates the new behaviour so that we don't regress this in the
future.
Thanks!
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v2] refs: return conflict error when checking packed refs
2024-04-30 14:50 [PATCH] refs: return conflict error when checking packed refs Ivan Tse via GitGitGadget
2024-05-02 12:38 ` Patrick Steinhardt
@ 2024-05-03 4:50 ` Ivan Tse via GitGitGadget
2024-05-03 6:38 ` Patrick Steinhardt
2024-05-04 3:04 ` [PATCH v3] " Ivan Tse via GitGitGadget
1 sibling, 2 replies; 11+ messages in thread
From: Ivan Tse via GitGitGadget @ 2024-05-03 4:50 UTC (permalink / raw)
To: git; +Cc: Ivan Tse, Ivan Tse
From: Ivan Tse <ivan.tse1@gmail.com>
The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
ref due to a name conflict with another ref. An example of this is a
directory/file conflict such as ref names A/B and A.
"git fetch" uses this error code to more accurately describe the error
by recommending to the user that they try running "git remote prune" to
remove any old refs that are deleted by the remote which would clear up
any directory/file conflicts.
This helpful error message is not displayed when the conflicted ref is
stored in packed refs. This change fixes this by ensuring error return
code consistency in `lock_raw_ref`.
Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
---
refs: return conflict error when checking packed refs
Changes against v1:
* added test for the error message during git fetch
Thanks for reviewing! I've gone ahead and attempted to add tests for
this behavior. It tests that the error message is shown for both cases
when the ref is stored as loose vs packed-refs. How does this test look?
Also, should this test have a REFFILES prerequisite?
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1716%2Fivantsepp%2Freturn_name_conflict_error_for_packed_refs-v2
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1716/ivantsepp/return_name_conflict_error_for_packed_refs-v2
Pull-Request: https://github.com/git/git/pull/1716
Range-diff vs v1:
1: a87ba267e44 ! 1: 58b2cda5c18 refs: return conflict error when checking packed refs
@@ refs/files-backend.c: static int lock_raw_ref(struct files_ref_store *refs,
}
ret = 0;
+
+ ## t/t5510-fetch.sh ##
+@@ t/t5510-fetch.sh: test_expect_success 'branchname D/F conflict resolved by --prune' '
+ test_cmp expect actual
+ '
+
++test_expect_success 'branchname D/F conflict rejected with targeted error message' '
++ git clone . df-conflict-error &&
++ git branch dir_conflict &&
++ (
++ cd df-conflict-error &&
++ git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
++ test_must_fail git fetch 2>../err &&
++ git pack-refs --all &&
++ test_must_fail git fetch 2>../err-packed
++ ) &&
++ test_grep "error: some local refs could not be updated; try running" err &&
++ test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err &&
++ test_grep "error: some local refs could not be updated; try running" err-packed &&
++ test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err-packed
++'
++
+ test_expect_success 'fetching a one-level ref works' '
+ test_commit extra &&
+ git reset --hard HEAD^ &&
refs/files-backend.c | 4 +++-
t/t5510-fetch.sh | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a098d14ea00..97473f377d1 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
*/
if (refs_verify_refname_available(
refs->packed_ref_store, refname,
- extras, NULL, err))
+ extras, NULL, err)) {
+ ret = TRANSACTION_NAME_CONFLICT;
goto error_return;
+ }
}
ret = 0;
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 33d34d5ae9e..ae0828e26a1 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -1091,6 +1091,22 @@ test_expect_success 'branchname D/F conflict resolved by --prune' '
test_cmp expect actual
'
+test_expect_success 'branchname D/F conflict rejected with targeted error message' '
+ git clone . df-conflict-error &&
+ git branch dir_conflict &&
+ (
+ cd df-conflict-error &&
+ git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
+ test_must_fail git fetch 2>../err &&
+ git pack-refs --all &&
+ test_must_fail git fetch 2>../err-packed
+ ) &&
+ test_grep "error: some local refs could not be updated; try running" err &&
+ test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err &&
+ test_grep "error: some local refs could not be updated; try running" err-packed &&
+ test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err-packed
+'
+
test_expect_success 'fetching a one-level ref works' '
test_commit extra &&
git reset --hard HEAD^ &&
base-commit: d4cc1ec35f3bcce816b69986ca41943f6ce21377
--
gitgitgadget
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v2] refs: return conflict error when checking packed refs
2024-05-03 4:50 ` [PATCH v2] " Ivan Tse via GitGitGadget
@ 2024-05-03 6:38 ` Patrick Steinhardt
2024-05-04 3:04 ` [PATCH v3] " Ivan Tse via GitGitGadget
1 sibling, 0 replies; 11+ messages in thread
From: Patrick Steinhardt @ 2024-05-03 6:38 UTC (permalink / raw)
To: Ivan Tse via GitGitGadget; +Cc: git, Ivan Tse
[-- Attachment #1: Type: text/plain, Size: 3285 bytes --]
On Fri, May 03, 2024 at 04:50:29AM +0000, Ivan Tse via GitGitGadget wrote:
> From: Ivan Tse <ivan.tse1@gmail.com>
>
> The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
> ref due to a name conflict with another ref. An example of this is a
> directory/file conflict such as ref names A/B and A.
>
> "git fetch" uses this error code to more accurately describe the error
> by recommending to the user that they try running "git remote prune" to
> remove any old refs that are deleted by the remote which would clear up
> any directory/file conflicts.
>
> This helpful error message is not displayed when the conflicted ref is
> stored in packed refs. This change fixes this by ensuring error return
> code consistency in `lock_raw_ref`.
>
> Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
> ---
> refs: return conflict error when checking packed refs
>
> Changes against v1:
>
> * added test for the error message during git fetch
>
> Thanks for reviewing! I've gone ahead and attempted to add tests for
> this behavior. It tests that the error message is shown for both cases
> when the ref is stored as loose vs packed-refs. How does this test look?
> Also, should this test have a REFFILES prerequisite?
There is no need for the REFFILES prerequisite as you never access refs
on disk directly, but instead use our plumbing commands. Furthermore, we
do want to verify that both backends behave the same here. If the test
failed with the "reftable" backend I'd consider that to be a bug in the
backend.
[snip]
> diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
> index 33d34d5ae9e..ae0828e26a1 100755
> --- a/t/t5510-fetch.sh
> +++ b/t/t5510-fetch.sh
> @@ -1091,6 +1091,22 @@ test_expect_success 'branchname D/F conflict resolved by --prune' '
> test_cmp expect actual
> '
>
> +test_expect_success 'branchname D/F conflict rejected with targeted error message' '
> + git clone . df-conflict-error &&
> + git branch dir_conflict &&
> + (
> + cd df-conflict-error &&
> + git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
> + test_must_fail git fetch 2>../err &&
> + git pack-refs --all &&
> + test_must_fail git fetch 2>../err-packed
> + ) &&
> + test_grep "error: some local refs could not be updated; try running" err &&
> + test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err &&
> + test_grep "error: some local refs could not be updated; try running" err-packed &&
> + test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err-packed
I would personally add those calls to `test_grep` right after the
respective fetches to make the test a bit easier to follow.
Also, instead of using '\''`, you can use the "${SQ}" variable to insert
single quotes. So, something like this:
test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err &&
Other than that this patch looks good to me, thanks!
Patrick
> +'
> +
> test_expect_success 'fetching a one-level ref works' '
> test_commit extra &&
> git reset --hard HEAD^ &&
>
> base-commit: d4cc1ec35f3bcce816b69986ca41943f6ce21377
> --
> gitgitgadget
>
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* [PATCH v3] refs: return conflict error when checking packed refs
2024-05-03 4:50 ` [PATCH v2] " Ivan Tse via GitGitGadget
2024-05-03 6:38 ` Patrick Steinhardt
@ 2024-05-04 3:04 ` Ivan Tse via GitGitGadget
2024-05-06 6:47 ` Patrick Steinhardt
2024-05-06 11:40 ` Karthik Nayak
1 sibling, 2 replies; 11+ messages in thread
From: Ivan Tse via GitGitGadget @ 2024-05-04 3:04 UTC (permalink / raw)
To: git; +Cc: Patrick Steinhardt, Ivan Tse, Ivan Tse
From: Ivan Tse <ivan.tse1@gmail.com>
The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
ref due to a name conflict with another ref. An example of this is a
directory/file conflict such as ref names A/B and A.
"git fetch" uses this error code to more accurately describe the error
by recommending to the user that they try running "git remote prune" to
remove any old refs that are deleted by the remote which would clear up
any directory/file conflicts.
This helpful error message is not displayed when the conflicted ref is
stored in packed refs. This change fixes this by ensuring error return
code consistency in `lock_raw_ref`.
Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
---
refs: return conflict error when checking packed refs
Changes against v2:
* move test_grep to follow after their respective git fetch commands
* Use "${SQ}" instead of '\''
Thanks for the explanation and for the comments. I've updated the
changes to incorporate your feedback!
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-git-1716%2Fivantsepp%2Freturn_name_conflict_error_for_packed_refs-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-git-1716/ivantsepp/return_name_conflict_error_for_packed_refs-v3
Pull-Request: https://github.com/git/git/pull/1716
Range-diff vs v2:
1: 58b2cda5c18 ! 1: 943a8629b5f refs: return conflict error when checking packed refs
@@ t/t5510-fetch.sh: test_expect_success 'branchname D/F conflict resolved by --pru
+ (
+ cd df-conflict-error &&
+ git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
-+ test_must_fail git fetch 2>../err &&
++ test_must_fail git fetch 2>err &&
++ test_grep "error: some local refs could not be updated; try running" err &&
++ test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err &&
+ git pack-refs --all &&
-+ test_must_fail git fetch 2>../err-packed
-+ ) &&
-+ test_grep "error: some local refs could not be updated; try running" err &&
-+ test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err &&
-+ test_grep "error: some local refs could not be updated; try running" err-packed &&
-+ test_grep " '\''git remote prune origin'\'' to remove any old, conflicting branches" err-packed
++ test_must_fail git fetch 2>err-packed &&
++ test_grep "error: some local refs could not be updated; try running" err-packed &&
++ test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err-packed
++ )
+'
+
test_expect_success 'fetching a one-level ref works' '
refs/files-backend.c | 4 +++-
t/t5510-fetch.sh | 16 ++++++++++++++++
2 files changed, 19 insertions(+), 1 deletion(-)
diff --git a/refs/files-backend.c b/refs/files-backend.c
index a098d14ea00..97473f377d1 100644
--- a/refs/files-backend.c
+++ b/refs/files-backend.c
@@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
*/
if (refs_verify_refname_available(
refs->packed_ref_store, refname,
- extras, NULL, err))
+ extras, NULL, err)) {
+ ret = TRANSACTION_NAME_CONFLICT;
goto error_return;
+ }
}
ret = 0;
diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
index 33d34d5ae9e..530369266fd 100755
--- a/t/t5510-fetch.sh
+++ b/t/t5510-fetch.sh
@@ -1091,6 +1091,22 @@ test_expect_success 'branchname D/F conflict resolved by --prune' '
test_cmp expect actual
'
+test_expect_success 'branchname D/F conflict rejected with targeted error message' '
+ git clone . df-conflict-error &&
+ git branch dir_conflict &&
+ (
+ cd df-conflict-error &&
+ git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
+ test_must_fail git fetch 2>err &&
+ test_grep "error: some local refs could not be updated; try running" err &&
+ test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err &&
+ git pack-refs --all &&
+ test_must_fail git fetch 2>err-packed &&
+ test_grep "error: some local refs could not be updated; try running" err-packed &&
+ test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err-packed
+ )
+'
+
test_expect_success 'fetching a one-level ref works' '
test_commit extra &&
git reset --hard HEAD^ &&
base-commit: d4cc1ec35f3bcce816b69986ca41943f6ce21377
--
gitgitgadget
^ permalink raw reply related [flat|nested] 11+ messages in thread
* Re: [PATCH v3] refs: return conflict error when checking packed refs
2024-05-04 3:04 ` [PATCH v3] " Ivan Tse via GitGitGadget
@ 2024-05-06 6:47 ` Patrick Steinhardt
2024-05-06 11:40 ` Karthik Nayak
1 sibling, 0 replies; 11+ messages in thread
From: Patrick Steinhardt @ 2024-05-06 6:47 UTC (permalink / raw)
To: Ivan Tse via GitGitGadget; +Cc: git, Ivan Tse
[-- Attachment #1: Type: text/plain, Size: 882 bytes --]
On Sat, May 04, 2024 at 03:04:08AM +0000, Ivan Tse via GitGitGadget wrote:
> From: Ivan Tse <ivan.tse1@gmail.com>
>
> The TRANSACTION_NAME_CONFLICT error code refers to a failure to create a
> ref due to a name conflict with another ref. An example of this is a
> directory/file conflict such as ref names A/B and A.
>
> "git fetch" uses this error code to more accurately describe the error
> by recommending to the user that they try running "git remote prune" to
> remove any old refs that are deleted by the remote which would clear up
> any directory/file conflicts.
>
> This helpful error message is not displayed when the conflicted ref is
> stored in packed refs. This change fixes this by ensuring error return
> code consistency in `lock_raw_ref`.
>
> Signed-off-by: Ivan Tse <ivan.tse1@gmail.com>
This version looks good to me, thanks!
Patrick
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 833 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] refs: return conflict error when checking packed refs
2024-05-04 3:04 ` [PATCH v3] " Ivan Tse via GitGitGadget
2024-05-06 6:47 ` Patrick Steinhardt
@ 2024-05-06 11:40 ` Karthik Nayak
2024-05-06 19:01 ` Junio C Hamano
1 sibling, 1 reply; 11+ messages in thread
From: Karthik Nayak @ 2024-05-06 11:40 UTC (permalink / raw)
To: Ivan Tse via GitGitGadget, git; +Cc: Patrick Steinhardt, Ivan Tse
[-- Attachment #1: Type: text/plain, Size: 1949 bytes --]
Hello Ivan,
"Ivan Tse via GitGitGadget" <gitgitgadget@gmail.com> writes:
> From: Ivan Tse <ivan.tse1@gmail.com>
[snip]
> diff --git a/refs/files-backend.c b/refs/files-backend.c
> index a098d14ea00..97473f377d1 100644
> --- a/refs/files-backend.c
> +++ b/refs/files-backend.c
> @@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
> */
> if (refs_verify_refname_available(
> refs->packed_ref_store, refname,
> - extras, NULL, err))
> + extras, NULL, err)) {
> + ret = TRANSACTION_NAME_CONFLICT;
> goto error_return;
> + }
> }
>
> ret = 0;
>
Shouldn't we also do this change in `lock_ref_oid_basic` where we gather
the same lock again for creating the reflog entry?
> diff --git a/t/t5510-fetch.sh b/t/t5510-fetch.sh
> index 33d34d5ae9e..530369266fd 100755
> --- a/t/t5510-fetch.sh
> +++ b/t/t5510-fetch.sh
> @@ -1091,6 +1091,22 @@ test_expect_success 'branchname D/F conflict resolved by --prune' '
> test_cmp expect actual
> '
>
> +test_expect_success 'branchname D/F conflict rejected with targeted error message' '
> + git clone . df-conflict-error &&
> + git branch dir_conflict &&
> + (
> + cd df-conflict-error &&
> + git update-ref refs/remotes/origin/dir_conflict/file HEAD &&
> + test_must_fail git fetch 2>err &&
> + test_grep "error: some local refs could not be updated; try running" err &&
> + test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err &&
> + git pack-refs --all &&
> + test_must_fail git fetch 2>err-packed &&
> + test_grep "error: some local refs could not be updated; try running" err-packed &&
> + test_grep " ${SQ}git remote prune origin${SQ} to remove any old, conflicting branches" err-packed
> + )
> +'
> +
> test_expect_success 'fetching a one-level ref works' '
> test_commit extra &&
> git reset --hard HEAD^ &&
>
> base-commit: d4cc1ec35f3bcce816b69986ca41943f6ce21377
> --
> gitgitgadget
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] refs: return conflict error when checking packed refs
2024-05-06 11:40 ` Karthik Nayak
@ 2024-05-06 19:01 ` Junio C Hamano
2024-05-07 5:51 ` Ivan Tse
0 siblings, 1 reply; 11+ messages in thread
From: Junio C Hamano @ 2024-05-06 19:01 UTC (permalink / raw)
To: Karthik Nayak
Cc: Ivan Tse via GitGitGadget, git, Patrick Steinhardt, Ivan Tse
Karthik Nayak <karthik.188@gmail.com> writes:
>> diff --git a/refs/files-backend.c b/refs/files-backend.c
>> index a098d14ea00..97473f377d1 100644
>> --- a/refs/files-backend.c
>> +++ b/refs/files-backend.c
>> @@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
>> */
>> if (refs_verify_refname_available(
>> refs->packed_ref_store, refname,
>> - extras, NULL, err))
>> + extras, NULL, err)) {
>> + ret = TRANSACTION_NAME_CONFLICT;
>> goto error_return;
>> + }
>> }
>>
>> ret = 0;
>>
>
> Shouldn't we also do this change in `lock_ref_oid_basic` where we gather
> the same lock again for creating the reflog entry?
An interesting question.
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] refs: return conflict error when checking packed refs
2024-05-06 19:01 ` Junio C Hamano
@ 2024-05-07 5:51 ` Ivan Tse
2024-05-07 13:37 ` Karthik Nayak
0 siblings, 1 reply; 11+ messages in thread
From: Ivan Tse @ 2024-05-07 5:51 UTC (permalink / raw)
To: Junio C Hamano
Cc: Karthik Nayak, Ivan Tse via GitGitGadget, git, Patrick Steinhardt
On Mon, May 6, 2024 at 3:01 PM Junio C Hamano <gitster@pobox.com> wrote:
> >> diff --git a/refs/files-backend.c b/refs/files-backend.c
> >> index a098d14ea00..97473f377d1 100644
> >> --- a/refs/files-backend.c
> >> +++ b/refs/files-backend.c
> >> @@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
> >> */
> >> if (refs_verify_refname_available(
> >> refs->packed_ref_store, refname,
> >> - extras, NULL, err))
> >> + extras, NULL, err)) {
> >> + ret = TRANSACTION_NAME_CONFLICT;
> >> goto error_return;
> >> + }
> >> }
> >>
> >> ret = 0;
> >>
> >
> > Shouldn't we also do this change in `lock_ref_oid_basic` where we gather
> > the same lock again for creating the reflog entry?
>
> An interesting question.
Hi!
Apologies but I'm not sure I follow - could you elaborate? I am not
too familiar with the Git source code (or C language) but from looking
at `lock_ref_oid_basic`, it looks like that function returns a lock
struct and not an integer success/error code. I'm not sure how we
would apply this change in that function as well?
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] refs: return conflict error when checking packed refs
2024-05-07 5:51 ` Ivan Tse
@ 2024-05-07 13:37 ` Karthik Nayak
2024-05-08 1:39 ` Ivan Tse
0 siblings, 1 reply; 11+ messages in thread
From: Karthik Nayak @ 2024-05-07 13:37 UTC (permalink / raw)
To: Ivan Tse, Junio C Hamano
Cc: Ivan Tse via GitGitGadget, git, Patrick Steinhardt
[-- Attachment #1: Type: text/plain, Size: 1660 bytes --]
Hello Ivan,
Ivan Tse <ivan.tse1@gmail.com> writes:
> On Mon, May 6, 2024 at 3:01 PM Junio C Hamano <gitster@pobox.com> wrote:
>> >> diff --git a/refs/files-backend.c b/refs/files-backend.c
>> >> index a098d14ea00..97473f377d1 100644
>> >> --- a/refs/files-backend.c
>> >> +++ b/refs/files-backend.c
>> >> @@ -794,8 +794,10 @@ static int lock_raw_ref(struct files_ref_store *refs,
>> >> */
>> >> if (refs_verify_refname_available(
>> >> refs->packed_ref_store, refname,
>> >> - extras, NULL, err))
>> >> + extras, NULL, err)) {
>> >> + ret = TRANSACTION_NAME_CONFLICT;
>> >> goto error_return;
>> >> + }
>> >> }
>> >>
>> >> ret = 0;
>> >>
>> >
>> > Shouldn't we also do this change in `lock_ref_oid_basic` where we gather
>> > the same lock again for creating the reflog entry?
>>
>> An interesting question.
>
> Hi!
>
> Apologies but I'm not sure I follow - could you elaborate? I am not
> too familiar with the Git source code (or C language) but from looking
> at `lock_ref_oid_basic`, it looks like that function returns a lock
> struct and not an integer success/error code. I'm not sure how we
> would apply this change in that function as well?
That's correct, my question was merely that we also have a
`refs_verify_refname_available` function call there and was wondering if
we somehow need to catch and propagate the same error from there. Like
you mentioned the way it is currently structured doesn't make that
possible.
[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 690 bytes --]
^ permalink raw reply [flat|nested] 11+ messages in thread
* Re: [PATCH v3] refs: return conflict error when checking packed refs
2024-05-07 13:37 ` Karthik Nayak
@ 2024-05-08 1:39 ` Ivan Tse
0 siblings, 0 replies; 11+ messages in thread
From: Ivan Tse @ 2024-05-08 1:39 UTC (permalink / raw)
To: Karthik Nayak
Cc: Junio C Hamano, Ivan Tse via GitGitGadget, git,
Patrick Steinhardt
Hi Karthik!
On Tue, May 7, 2024 at 9:37 AM Karthik Nayak <karthik.188@gmail.com> wrote:
>
> Hello Ivan,
>
[snip]
>
> That's correct, my question was merely that we also have a
> `refs_verify_refname_available` function call there and was wondering if
> we somehow need to catch and propagate the same error from there. Like
> you mentioned the way it is currently structured doesn't make that
> possible.
Ah I see, that makes sense. Thanks for the clarification and for the
initial question!
^ permalink raw reply [flat|nested] 11+ messages in thread
end of thread, other threads:[~2024-05-08 1:39 UTC | newest]
Thread overview: 11+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2024-04-30 14:50 [PATCH] refs: return conflict error when checking packed refs Ivan Tse via GitGitGadget
2024-05-02 12:38 ` Patrick Steinhardt
2024-05-03 4:50 ` [PATCH v2] " Ivan Tse via GitGitGadget
2024-05-03 6:38 ` Patrick Steinhardt
2024-05-04 3:04 ` [PATCH v3] " Ivan Tse via GitGitGadget
2024-05-06 6:47 ` Patrick Steinhardt
2024-05-06 11:40 ` Karthik Nayak
2024-05-06 19:01 ` Junio C Hamano
2024-05-07 5:51 ` Ivan Tse
2024-05-07 13:37 ` Karthik Nayak
2024-05-08 1:39 ` Ivan Tse
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).