Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion evt_apply.go
Original file line number Diff line number Diff line change
Expand Up @@ -582,9 +582,11 @@ func apply__def_param(tr2 *trace2Dataset, evt *TrEvent) (err error) {
_, havePrevVal := tr2.process.paramSetValues[key]
priCur, havePrevPri := tr2.process.paramSetPriorities[key]

if havePrevVal && havePrevPri && priNew <= priCur {
if havePrevVal && havePrevPri && priNew < priCur {
// We already have a value for this key with a higher
// priority, so ignore this value.
// Note: When priorities are equal, we accept the new value
// to match Git's "last one wins" behavior.
return nil
}

Expand Down
35 changes: 35 additions & 0 deletions evt_apply_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -500,6 +500,41 @@ func Test_Dataset_DefParam_Scoped(t *testing.T) {
assert.Equal(t, tr2.process.paramSetValues["bar"], x_param_local_bar)
}

// Verify that when multiple def_param events are sent for the same parameter
// with the SAME scope, the last one wins (matching Git's behavior).
// This happens when using includeIf to include config files.
func Test_Dataset_DefParam_SameScope_LastWins(t *testing.T) {

var events []string = []string{
x_make_version(),
x_make_start(),

// Multiple values for "ruleset" with the same scope (local).
// The last one should win, matching git's "last one wins" behavior.
x_make_def_param("local", "ruleset", "dl:drop"),
x_make_def_param("local", "ruleset", "dl:verbose"),

// Also test with global scope
x_make_def_param("global", "nickname", "first"),
x_make_def_param("global", "nickname", "second"),
x_make_def_param("global", "nickname", "last"),

x_make_atexit(), // Should be last
}

tr2, sufficient, _ := load_test_dataset(t, events)
assert.True(t, sufficient, "have sufficient data")

assert.Equal(t, len(tr2.process.paramSetValues), 2)

// For same-priority configs, the LAST one should win (not first)
assert.NotNil(t, tr2.process.paramSetValues["ruleset"])
assert.Equal(t, tr2.process.paramSetValues["ruleset"], "dl:verbose")

assert.NotNil(t, tr2.process.paramSetValues["nickname"])
assert.Equal(t, tr2.process.paramSetValues["nickname"], "last")
}

func Test_Dataset_ChildProcesses(t *testing.T) {

var events []string = []string{
Expand Down