Skip to content

only show git config warnings for lfs keys - #861

Merged
technoweenie merged 1 commit into
masterfrom
lfs-config-warnings
Dec 4, 2015
Merged

technoweenie merged 1 commit into
masterfrom
lfs-config-warnings

Conversation

@technoweenie

Copy link
Copy Markdown
Contributor

We don't care if other git values clash.

@sinbad

sinbad commented Dec 2, 2015

Copy link
Copy Markdown
Contributor

👍

technoweenie added a commit that referenced this pull request Dec 4, 2015
only show git config warnings for lfs keys
@technoweenie
technoweenie merged commit e467a11 into master Dec 4, 2015
@technoweenie
technoweenie deleted the lfs-config-warnings branch December 4, 2015 15:22
@technoweenie technoweenie mentioned this pull request Feb 2, 2016
15 tasks done
chrisd8088 added a commit that referenced this pull request Oct 22, 2026
In commits dcb2d4e and
265feee of PR #837 we
updated the "git lfs env" command to output a warning when
a Git configuration option was defined more than once.  Later,
in commit dcae83d of PR #861,
we limited these warnings so they are only reported for options
in the "lfs" configuration section.

At present, the readGitConfig() function in our "config" package
tracks which configuration options it has parsed so far using an
internal map named "uniqKeys".  During a "git lfs env" command,
the function refers to the map to check if an option in the "lfs"
configuration section has been encountered previously.  If so,
and if the value of the current option differs from the value
set previously for the option, then the function outputs a warning
message.

In a subsequent commit, we expect to revise the readGitConfig()
function and simplify the variables it uses to populate the
"uniqKeys" map.

Before we do so, though, we first add a shell integration test
which verifies that the "git lfs env" command reports the expected
warnings when an option in the "lfs" section has multiple different
values.  The test also checks that the "git lfs env" command does
not report duplicate values of configuration options that are not
in the "lfs" section.

Our new test will then serve to guarantee that when we update
the readGitConfig() function in subsequent commits, we do not
inadvertently alter its handling of duplicate option values.

Co-authored-by: Chris Darroch <[email protected]>
chrisd8088 added a commit that referenced this pull request Oct 22, 2026
In commits dcb2d4e and
265feee of PR #837 we
updated the "git lfs env" command to output a warning when
a Git configuration option was defined more than once.  Later,
in commit dcae83d of PR #861,
we limited these warnings so they are only reported for options
in the "lfs" configuration section.

At present, the readGitConfig() function in our "config" package
tracks which configuration options it has parsed so far using an
internal map named "uniqKeys".  During a "git lfs env" command,
the function refers to the map to check if an option in the "lfs"
configuration section has been encountered previously.  If so,
and if the value of the current option differs from the value
set previously for the option, then the function outputs a warning
message.

The readGitConfig() function accepts Git configuration data in
the form generated by the ParseConfigLines() function of our
"git" package.  Currently, this function splits the output of
"git config -l" commands on each line feed (LF) character, so
the readGitConfig() function then iterates over those lines and
splits each one on the first equals sign ("=") character to
determine the name and value of a configuration option.

As each option is processed, its name and value are stored in a
slice variable named "pieces", whose two elements are then
assigned to variables named "key" and "val", respectively.
For the most part, the remainder of the per-option loop refers
to the current option's name and value via the "key" and "val"
variables.

However, when populating the "uniqKeys" map and when generating
warning messages about multiple values for a single option, we
refer directly to the first element of the "pieces" slice even
though this element's value will always be identical to that
of the "key" variable.

In a subsequent commit, we expect to revise our parsing of Git
configuration sources to support values which contain line feed
(LF) characters.  The readGitConfig() function will therefore iterate
over a slice of configuration entry structures rather than parse
individual lines, and so will no longer require a "pieces" slice.

Before we make these changes, we first update the two instances
where we refer to the first element of the "pieces" slice so they
instead refer to the "key" variable.  This will permit us to more
easily remove the "pieces" slice entirely in a subsequent commit.
Since the "key" variable and the first element of the "pieces"
slice are always identical, this change will not alter either the
option names stored in the "uniqKeys" map or those reported in
warnings by the "git lfs env" command.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants