threads / patch / 62375

patcht1400: fix --no-create-reflog test and description

Subject: [PATCH] t1400: fix --no-create-reflog test and description

## tl;dr

8 messages between Oct 20, 2024 and Nov 8, 2024. Diffs are folded; open one to read it.

replies: 7people: 5as markdown or json

kristofferhaugsbakk@fastmail.com· Oct 20, 2024, 16:12 UTC · lore
From: Kristoffer Haugsbakk <code@khaugsbakk.name>

This test has had the wrong title since it was created.[1] Use `always` like the description says and negate the expected outcome.

The test works since `core.logAllRefUpdates` set to `true` does not create a reflog for that ref namespace. So the test is testing the config variable, not the option.

The test itself is fine and does not hide a bug: `--no-create-reflog` is not supposed to override `core.logAllRefUpdates`.

† 1: 341fb286212 (refs: add option core.logAllRefUpdates = always,
    2017-01-27)
Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
---
Notes (series):
    From the commit message:
    
      “ The test itself is fine and does not hide a bug:
        `--no-create-reflog` is not supposed to override
    
    A source for that: roundabout through git-branch(1):
    
      “ The negated form --no-create-reflog only overrides an earlier
        --create-reflog, but currently does not negate the setting of
        core.logAllRefUpdates.
    
    I *suppose* that the same applies to update-ref since (I suppose) they
    use the same underlying machinery.
    
    See also git-tag(1) which says the same thing.
    
    update-ref should document the same thing, then.  I have that marked as
    a todo item.  The changes there are a bit too involved to implicate in
    this submission.
 t/t1400-update-ref.sh | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
Show changes to t/t1400-update-ref.sh +3 −3
diff --git a/t/t1400-update-ref.sh b/t/t1400-update-ref.sh
index eb1691860da..9bf87db4775 100755
--- a/t/t1400-update-ref.sh
+++ b/t/t1400-update-ref.sh
@@ -169,14 +169,14 @@ test_expect_success 'core.logAllRefUpdates=always creates reflog for ORIG_HEAD'
 	git reflog exists ORIG_HEAD
 '
 
-test_expect_success '--no-create-reflog overrides core.logAllRefUpdates=always' '
-	test_config core.logAllRefUpdates true &&
+test_expect_success '--no-create-reflog does not override core.logAllRefUpdates=always' '
+	test_config core.logAllRefUpdates always &&
 	test_when_finished "git update-ref -d $outside" &&
 	git update-ref --no-create-reflog $outside $A &&
 	git rev-parse $A >expect &&
 	git rev-parse $outside >actual &&
 	test_cmp expect actual &&
-	test_must_fail git reflog exists $outside
+	git reflog exists $outside
 '
 
 test_expect_success "create $m (by HEAD)" '

base-commit: 34b6ce9b30747131b6e781ff718a45328aa887d0
-- 
2.46.1.641.g54e7913fcb6
Patrick Steinhardt· Oct 21, 2024, 12:08 UTC · re: kristofferhaugsbakk@fastmail.com · lore

Re: [PATCH] t1400: fix --no-create-reflog test and description

On Sun, Oct 20, 2024 at 06:12:03PM +0200, kristofferhaugsbakk@fastmail.com wrote:
Show 11 quoted lines
> From: Kristoffer Haugsbakk <code@khaugsbakk.name>
> 
> This test has had the wrong title since it was created.[1]  Use `always`
> like the description says and negate the expected outcome.
> 
> The test works since `core.logAllRefUpdates` set to `true` does not
> create a reflog for that ref namespace.  So the test is testing the
> config variable, not the option.
> 
> The test itself is fine and does not hide a bug: `--no-create-reflog` is
> not supposed to override `core.logAllRefUpdates`.

That's actually surprising to me, as command line options tend to override configuration.

Show 17 quoted lines
> † 1: 341fb286212 (refs: add option core.logAllRefUpdates = always,
>     2017-01-27)
> 
> Signed-off-by: Kristoffer Haugsbakk <code@khaugsbakk.name>
> ---
> 
> Notes (series):
>     From the commit message:
>     
>       “ The test itself is fine and does not hide a bug:
>         `--no-create-reflog` is not supposed to override
>     
>     A source for that: roundabout through git-branch(1):
>     
>       “ The negated form --no-create-reflog only overrides an earlier
>         --create-reflog, but currently does not negate the setting of
>         core.logAllRefUpdates.

Hm. The "currently" reads as if this was a known shortcoming rather than by design.

Show 8 quoted lines
>     I *suppose* that the same applies to update-ref since (I suppose) they
>     use the same underlying machinery.
>     
>     See also git-tag(1) which says the same thing.
>     
>     update-ref should document the same thing, then.  I have that marked as
>     a todo item.  The changes there are a bit too involved to implicate in
>     this submission.

So I'm quite torn here. It's documented, even though the documentation doesn't exactly feel like this was designed, but rather like it was a side effect. The test also contradicts the documentation, even though it only worked by chance. And as mentioned above, everywhere else we typically have a design where the command line option overrides the config.

Overall I'm rather leaning into the direction of making this work properly. But that would of course be a backwards-incompatible change.

Patrick
Kristoffer Haugsbakk· Oct 21, 2024, 16:48 UTC · re: Patrick Steinhardt · lore

Re: [PATCH] t1400: fix --no-create-reflog test and description

On Mon, Oct 21, 2024, at 14:08, Patrick Steinhardt wrote:
Show 15 quoted lines
>> […]
>> Notes (series):
>>     From the commit message:
>>
>>       “ The test itself is fine and does not hide a bug:
>>         `--no-create-reflog` is not supposed to override
>>
>>     A source for that: roundabout through git-branch(1):
>>
>>       “ The negated form --no-create-reflog only overrides an earlier
>>         --create-reflog, but currently does not negate the setting of
>>         core.logAllRefUpdates.
>
> Hm. The "currently" reads as if this was a known shortcoming rather than
> by design.
I read it as “we might change our minds here—watch out”.  ;)

It feels very emphasized. Like the documentation was expecting your surprise.

Show 18 quoted lines
>>     I *suppose* that the same applies to update-ref since (I suppose) they
>>     use the same underlying machinery.
>>
>>     See also git-tag(1) which says the same thing.
>>
>>     update-ref should document the same thing, then.  I have that marked as
>>     a todo item.  The changes there are a bit too involved to implicate in
>>     this submission.
>
> So I'm quite torn here. It's documented, even though the documentation
> doesn't exactly feel like this was designed, but rather like it was a
> side effect. The test also contradicts the documentation, even though it
> only worked by chance. And as mentioned above, everywhere else we
> typically have a design where the command line option overrides the
> config.
>
> Overall I'm rather leaning into the direction of making this work
> properly. But that would of course be a backwards-incompatible change.

Good point. It does feel inconsistent. I agree that the conventional pattern (to my knowledge) is to have options override config when the options are given.

Taylor Blau· Oct 21, 2024, 19:02 UTC · re: Kristoffer Haugsbakk · lore

Re: [PATCH] t1400: fix --no-create-reflog test and description

On Mon, Oct 21, 2024 at 06:48:20PM +0200, Kristoffer Haugsbakk wrote:
Show 44 quoted lines
> On Mon, Oct 21, 2024, at 14:08, Patrick Steinhardt wrote:
> >> […]
> >> Notes (series):
> >>     From the commit message:
> >>
> >>       “ The test itself is fine and does not hide a bug:
> >>         `--no-create-reflog` is not supposed to override
> >>
> >>     A source for that: roundabout through git-branch(1):
> >>
> >>       “ The negated form --no-create-reflog only overrides an earlier
> >>         --create-reflog, but currently does not negate the setting of
> >>         core.logAllRefUpdates.
> >
> > Hm. The "currently" reads as if this was a known shortcoming rather than
> > by design.
>
> I read it as “we might change our minds here—watch out”.  ;)
>
> It feels very emphasized.  Like the documentation was expecting
> your surprise.
>
> >>     I *suppose* that the same applies to update-ref since (I suppose) they
> >>     use the same underlying machinery.
> >>
> >>     See also git-tag(1) which says the same thing.
> >>
> >>     update-ref should document the same thing, then.  I have that marked as
> >>     a todo item.  The changes there are a bit too involved to implicate in
> >>     this submission.
> >
> > So I'm quite torn here. It's documented, even though the documentation
> > doesn't exactly feel like this was designed, but rather like it was a
> > side effect. The test also contradicts the documentation, even though it
> > only worked by chance. And as mentioned above, everywhere else we
> > typically have a design where the command line option overrides the
> > config.
> >
> > Overall I'm rather leaning into the direction of making this work
> > properly. But that would of course be a backwards-incompatible change.
>
> Good point.  It does feel inconsistent.  I agree that the conventional
> pattern (to my knowledge) is to have options override config when the
> options are given.

I agree with you both that it feels inconsistent, but I feel somewhat uncomfortable changing the behavior here in a backwards incompatible way.

Even if the original documentation leaves the door open to changing the behavior, I think that probably a non-zero number of users has either (a) never read that documentation, or (b) come to rely on it, or (c) both ;-).

I think if anything we might consider updating the documentation to more clearly capture the status-quo, but I'd be very hesitant to see a patch changing the behavior here.

Thanks, Taylor

Kristoffer Haugsbakk· Oct 21, 2024, 21:02 UTC · re: Taylor Blau · lore

Re: [PATCH] t1400: fix --no-create-reflog test and description

On Mon, Oct 21, 2024, at 21:02, Taylor Blau wrote:
Show 7 quoted lines
>> […]
>> > Overall I'm rather leaning into the direction of making this work
>> > properly. But that would of course be a backwards-incompatible change.
>>
>> Good point.  It does feel inconsistent.  I agree that the conventional
>> pattern (to my knowledge) is to have options override config when the
>> options are given.
Agreed, to be clear. ;)
Show 12 quoted lines
> I agree with you both that it feels inconsistent, but I feel somewhat
> uncomfortable changing the behavior here in a backwards incompatible
> way.
>
> Even if the original documentation leaves the door open to changing the
> behavior, I think that probably a non-zero number of users has either
> (a) never read that documentation, or (b) come to rely on it, or (c)
> both ;-).
>
> I think if anything we might consider updating the documentation to more
> clearly capture the status-quo, but I'd be very hesitant to see a patch
> changing the behavior here.

My background (how I ended up in this test) was that I learnt yesterday that `--create-reflog` and this config variable controls whether reflog files are created. I thought that they toggled when entries were made.

I have some work in progress patches for clarifying this mechanism in git-config(1) and other places.

Now git-tag(1) and git-branch(1) seem decently clear on this point[1] but update-ref is lagging behind IMO. I will be looking at that one as well.

† 1: There is also the `--create-reflog` case vs. when the config is
   `false` but I can’t check that right now
Taylor Blau· Oct 21, 2024, 21:10 UTC · re: Kristoffer Haugsbakk · lore

Re: [PATCH] t1400: fix --no-create-reflog test and description

On Mon, Oct 21, 2024 at 11:02:48PM +0200, Kristoffer Haugsbakk wrote:
Show 10 quoted lines
> On Mon, Oct 21, 2024, at 21:02, Taylor Blau wrote:
> >> […]
> >> > Overall I'm rather leaning into the direction of making this work
> >> > properly. But that would of course be a backwards-incompatible change.
> >>
> >> Good point.  It does feel inconsistent.  I agree that the conventional
> >> pattern (to my knowledge) is to have options override config when the
> >> options are given.
>
> Agreed, to be clear. ;)
;-).
> Now git-tag(1) and git-branch(1) seem decently clear on this point[1]
> but update-ref is lagging behind IMO.  I will be looking at that one as
> well.
Thanks very much.

Thanks, Taylor

Junio C Hamano· Nov 8, 2024, 03:13 UTC · re: Kristoffer Haugsbakk · lore

Re: [PATCH] t1400: fix --no-create-reflog test and description

"Kristoffer Haugsbakk" <code@khaugsbakk.name> writes:
> I didn’t get the impression that this is expecting a reroll.  But I
> haven’t seen it mentioned or applied to `seen`/`next`?

If the interim maintainer did not think it is ready to be queued to 'seen', I won't go back to the list archive to pick it up (after all, that is part of trusting interim maintainer is about---otherwise I have to go back and consume all the list backlog, which does not make sense).

If a topic is worth resurrecting, do resend it for discussion. Looking at the archived discussion (for this topic I am making an exception), I did not get an impression that this got a "yeah this is a good thing to do" support, only a lukewarm "it may be a starting point in a good direction".

Thanks.

← back to recent threads