Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update GetEffectiveGitSetting to provide status and value #11146

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

vbjay
Copy link
Contributor

@vbjay vbjay commented Aug 12, 2023

Updates the method to return not only the value of the config but also the status based on the ExitCodes from git config documentation. This allows for deciding what to do if config key doesn't exist by the user of GetEffectiveGitSetting

Fixes #11145

Proposed changes

  • Don't treat exit codes as failures when running git config command

Test methodology

  • No exceptions in clean machine when I wrote code to retrieve gpg.program and commit.gpgSign and such settings

Test environment(s)

  • GIT
  • Windows

Merge strategy

I agree that the maintainer squash merge this PR (if the commit message is clear).


✒️ I contribute this code under The Developer Certificate of Origin.

@ghost ghost assigned vbjay Aug 12, 2023
@vbjay
Copy link
Contributor Author

vbjay commented Aug 12, 2023

Result from running test on my dev machine
ConfigKeyInvalidOrNotSet (exit code 1)
	add.ignoreErrors
	add.interactive.useBuiltin
	advice.addEmbeddedRepo
	advice.addEmptyPathspec
	advice.addIgnoredFile
	advice.amWorkDir
	advice.ambiguousFetchRefspec
	advice.checkoutAmbiguousRemoteBranchName
	advice.commitBeforeMerge
	advice.detachedHead
	advice.diverging
	advice.fetchShowForcedUpdates
	advice.graftFileDeprecated
	advice.ignoredHook
	advice.implicitIdentity
	advice.nameTooLong
	advice.nestedTag
	advice.objectNameWarning
	advice.pushAlreadyExists
	advice.pushFetchFirst
	advice.pushNeedsForce
	advice.pushNonFFCurrent
	advice.pushNonFFMatching
	advice.pushNonFastForward
	advice.pushRefNeedsUpdate
	advice.pushUnqualifiedRefName
	advice.pushUpdateRejected
	advice.resetNoRefresh
	advice.resolveConflict
	advice.rmHints
	advice.sequencerInUse
	advice.setUpstreamFailure
	advice.skippedCherryPicks
	advice.statusAheadBehindWarning
	advice.statusHints
	advice.statusUoption
	advice.submoduleAlternateErrorStrategyDie
	advice.submodulesNotUpdated
	advice.suggestDetachingHead
	advice.updateSparsePath
	advice.useCoreFSMonitorConfig
	advice.waitingForEditor
	alias.*
	am.keepcr
	am.threeWay
	apply.ignoreWhitespace
	apply.whitespace
	author.email
	author.name
	blame.blankBoundary
	blame.coloring
	blame.date
	blame.ignoreRevsFile
	blame.markIgnoredLines
	blame.markUnblamableLines
	blame.showEmail
	blame.showRoot
	branch.<name>.description
	branch.<name>.merge
	branch.<name>.mergeOptions
	branch.<name>.pushRemote
	branch.<name>.rebase
	branch.<name>.remote
	branch.autoSetupMerge
	branch.autoSetupRebase
	branch.sort
	browser.<tool>.cmd
	browser.<tool>.path
	bundle.*
	bundle.<id>.*
	bundle.<id>.uri
	bundle.heuristic
	bundle.mode
	bundle.version
	checkout.defaultRemote
	checkout.guess
	checkout.thresholdForParallelism
	checkout.workers
	clean.requireForce
	clone.defaultRemoteName
	clone.filterSubmodules
	clone.rejectShallow
	color.advice
	color.advice.hint
	color.blame.highlightRecent
	color.blame.repeatedLines
	color.branch
	color.branch.current
	color.branch.local
	color.branch.plain
	color.branch.remote
	color.branch.reset
	color.branch.upstream
	color.branch.worktree
	color.decorate.HEAD
	color.decorate.branch
	color.decorate.grafted
	color.decorate.remoteBranch
	color.decorate.stash
	color.decorate.tag
	color.diff
	color.diff.commit
	color.diff.context
	color.diff.contextBold
	color.diff.contextDimmed
	color.diff.frag
	color.diff.func
	color.diff.meta
	color.diff.new
	color.diff.newBold
	color.diff.newDimmed
	color.diff.newMoved
	color.diff.newMovedAlternative
	color.diff.newMovedAlternativeDimmed
	color.diff.newMovedDimmed
	color.diff.old
	color.diff.oldBold
	color.diff.oldDimmed
	color.diff.oldMoved
	color.diff.oldMovedAlternative
	color.diff.oldMovedAlternativeDimmed
	color.diff.oldMovedDimmed
	color.diff.plain
	color.diff.whitespace
	color.grep
	color.grep.column
	color.grep.context
	color.grep.filename
	color.grep.function
	color.grep.lineNumber
	color.grep.match
	color.grep.matchContext
	color.grep.matchSelected
	color.grep.selected
	color.grep.separator
	color.interactive
	color.interactive.error
	color.interactive.header
	color.interactive.help
	color.interactive.plain
	color.interactive.prompt
	color.interactive.reset
	color.pager
	color.push
	color.push.error
	color.remote
	color.remote.error
	color.remote.hint
	color.remote.success
	color.remote.warning
	color.showBranch
	color.status
	color.status.added
	color.status.branch
	color.status.changed
	color.status.header
	color.status.localBranch
	color.status.noBranch
	color.status.remoteBranch
	color.status.unmerged
	color.status.untracked
	color.status.updated
	color.transport
	color.transport.rejected
	color.ui
	column.branch
	column.clean
	column.status
	column.tag
	column.ui
	commit.cleanup
	commit.status
	commit.template
	commit.verbose
	commitGraph.generationVersion
	commitGraph.maxNewFilters
	commitGraph.readChangedPaths
	committer.email
	committer.name
	completion.commands
	core.abbrev
	core.alternateRefsCommand
	core.alternateRefsPrefixes
	core.askPass
	core.attributesFile
	core.bigFileThreshold
	core.checkRoundtripEncoding
	core.checkStat
	core.commentChar
	core.compression
	core.createObject
	core.deltaBaseCacheLimit
	core.eol
	core.excludesFile
	core.filesRefLockTimeout
	core.fsmonitor
	core.fsmonitorHookVersion
	core.fsync
	core.fsyncMethod
	core.fsyncObjectFiles
	core.gitProxy
	core.hideDotFiles
	core.hooksPath
	core.ignoreStat
	core.longpaths
	core.looseCompression
	core.multiPackIndex
	core.notesRef
	core.packedGitLimit
	core.packedGitWindowSize
	core.packedRefsTimeout
	core.pager
	core.precomposeUnicode
	core.preferSymlinkRefs
	core.protectHFS
	core.protectNTFS
	core.quotePath
	core.restrictinheritedhandles
	core.sharedRepository
	core.sparseCheckout
	core.sparseCheckoutCone
	core.splitIndex
	core.sshCommand
	core.trustctime
	core.unsetenvvars
	core.untrackedCache
	core.useReplaceRefs
	core.warnAmbiguousRefs
	core.whitespace
	core.worktree
	credential.<url>.*
	credential.useHttpPath
	credential.username
	credentialCache.ignoreSIGHUP
	credentialStore.lockTimeoutMS
	diff.<driver>.binary
	diff.<driver>.cachetextconv
	diff.<driver>.command
	diff.<driver>.textconv
	diff.<driver>.wordRegex
	diff.<driver>.xfuncname
	diff.algorithm
	diff.autoRefreshIndex
	diff.colorMoved
	diff.colorMovedWS
	diff.context
	diff.dirstat
	diff.external
	diff.ignoreSubmodules
	diff.indentHeuristic
	diff.interHunkContext
	diff.mnemonicPrefix
	diff.noprefix
	diff.orderFile
	diff.relative
	diff.renameLimit
	diff.renames
	diff.statGraphWidth
	diff.submodule
	diff.suppressBlankEmpty
	diff.wordRegex
	diff.wsErrorHighlight
	difftool.<tool>.cmd
	difftool.<tool>.path
	difftool.guiDefault
	difftool.trustExitCode
	extensions.objectFormat
	extensions.worktreeConfig
	fastimport.unpackLimit
	feature.*
	feature.experimental
	feature.manyFiles
	fetch.bundleCreationToken
	fetch.bundleURI
	fetch.fsck.<msg-id>
	fetch.fsck.skipList
	fetch.fsckObjects
	fetch.negotiationAlgorithm
	fetch.output
	fetch.parallel
	fetch.pruneTags
	fetch.recurseSubmodules
	fetch.showForcedUpdates
	fetch.unpackLimit
	fetch.writeCommitGraph
	filter.<driver>.clean
	filter.<driver>.smudge
	format.attach
	format.cc
	format.coverFromDescription
	format.coverLetter
	format.encodeEmailHeaders
	format.filenameMaxLength
	format.forceInBodyFrom
	format.from
	format.headers
	format.mboxrd
	format.noprefix
	format.notes
	format.numbered
	format.outputDirectory
	format.pretty
	format.signOff
	format.signature
	format.signatureFile
	format.subjectPrefix
	format.suffix
	format.thread
	format.to
	format.useAutoBase
	fsck.badDate
	fsck.badDateOverflow
	fsck.badEmail
	fsck.badFilemode
	fsck.badName
	fsck.badObjectSha1
	fsck.badParentSha1
	fsck.badTagName
	fsck.badTimezone
	fsck.badTree
	fsck.badTreeSha1
	fsck.badType
	fsck.duplicateEntries
	fsck.emptyName
	fsck.extraHeaderEntry
	fsck.fullPathname
	fsck.gitattributesBlob
	fsck.gitattributesLarge
	fsck.gitattributesLineLength
	fsck.gitattributesMissing
	fsck.gitattributesSymlink
	fsck.gitignoreSymlink
	fsck.gitmodulesBlob
	fsck.gitmodulesLarge
	fsck.gitmodulesMissing
	fsck.gitmodulesName
	fsck.gitmodulesParse
	fsck.gitmodulesPath
	fsck.gitmodulesSymlink
	fsck.gitmodulesUpdate
	fsck.gitmodulesUrl
	fsck.hasDot
	fsck.hasDotdot
	fsck.hasDotgit
	fsck.mailmapSymlink
	fsck.missingAuthor
	fsck.missingCommitter
	fsck.missingEmail
	fsck.missingNameBeforeEmail
	fsck.missingObject
	fsck.missingSpaceBeforeDate
	fsck.missingSpaceBeforeEmail
	fsck.missingTag
	fsck.missingTagEntry
	fsck.missingTaggerEntry
	fsck.missingTree
	fsck.missingType
	fsck.missingTypeEntry
	fsck.multipleAuthors
	fsck.nulInCommit
	fsck.nulInHeader
	fsck.nullSha1
	fsck.skipList
	fsck.treeNotSorted
	fsck.unknownType
	fsck.unterminatedHeader
	fsck.zeroPaddedDate
	fsck.zeroPaddedFilemode
	fsmonitor.allowRemote
	fsmonitor.socketDir
	gc.<pattern>.reflogExpire
	gc.<pattern>.reflogExpireUnreachable
	gc.aggressiveDepth
	gc.aggressiveWindow
	gc.auto
	gc.autoDetach
	gc.autoPackLimit
	gc.bigPackThreshold
	gc.cruftPacks
	gc.logExpiry
	gc.packRefs
	gc.pruneExpire
	gc.reflogExpire
	gc.reflogExpireUnreachable
	gc.rerereResolved
	gc.rerereUnresolved
	gc.worktreePruneExpire
	gc.writeCommitGraph
	gitcvs.allBinary
	gitcvs.commitMsgAnnotation
	gitcvs.dbDriver
	gitcvs.dbName
	gitcvs.dbPass
	gitcvs.dbTableNamePrefix
	gitcvs.dbUser
	gitcvs.enabled
	gitcvs.logFile
	gitcvs.usecrlfattr
	gitweb.avatar
	gitweb.blame
	gitweb.category
	gitweb.description
	gitweb.grep
	gitweb.highlight
	gitweb.owner
	gitweb.patches
	gitweb.pickaxe
	gitweb.remote_heads
	gitweb.showSizes
	gitweb.snapshot
	gitweb.url
	gpg.<format>.program
	gpg.format
	gpg.minTrustLevel
	gpg.ssh.allowedSignersFile
	gpg.ssh.defaultKeyCommand
	gpg.ssh.revocationFile
	grep.column
	grep.extendedRegexp
	grep.fallbackToNoIndex
	grep.fullName
	grep.lineNumber
	grep.patternType
	grep.threads
	gui.blamehistoryctx
	gui.commitMsgWidth
	gui.copyBlameThreshold
	gui.diffContext
	gui.displayUntracked
	gui.encoding
	gui.fastCopyBlame
	gui.matchTrackingBranch
	gui.newBranchTemplate
	gui.pruneDuringFetch
	gui.spellingDictionary
	gui.trustmtime
	guitool.<name>.argPrompt
	guitool.<name>.cmd
	guitool.<name>.confirm
	guitool.<name>.needsFile
	guitool.<name>.noConsole
	guitool.<name>.noRescan
	guitool.<name>.prompt
	guitool.<name>.revPrompt
	guitool.<name>.revUnmerged
	guitool.<name>.title
	help.autoCorrect
	help.browser
	help.format
	help.htmlPath
	http.<url>.*
	http.cookieFile
	http.curloptResolve
	http.delegation
	http.emptyAuth
	http.extraHeader
	http.followRedirects
	http.lowSpeedLimit
	http.lowSpeedTime
	http.maxRequests
	http.minSessions
	http.noEPSV
	http.pinnedPubkey
	http.postBuffer
	http.proxy
	http.proxyAuthMethod
	http.proxySSLCAInfo
	http.proxySSLCert
	http.proxySSLCertPasswordProtected
	http.proxySSLKey
	http.saveCookies
	http.schannelCheckRevoke
	http.schannelUseSSLCAInfo
	http.sslAutoClientCert
	http.sslCAPath
	http.sslCert
	http.sslCertPasswordProtected
	http.sslCipherList
	http.sslKey
	http.sslTry
	http.sslVerify
	http.sslVersion
	http.userAgent
	http.version
	i18n.logOutputEncoding
	imap.authMethod
	imap.folder
	imap.host
	imap.pass
	imap.port
	imap.preformattedHTML
	imap.sslverify
	imap.tunnel
	imap.user
	include.path
	includeIf.<condition>.path
	index.recordEndOfIndexEntries
	index.recordOffsetTable
	index.skipHash
	index.sparse
	index.threads
	index.version
	init.templateDir
	instaweb.browser
	instaweb.httpd
	instaweb.local
	instaweb.modulePath
	instaweb.port
	interactive.diffFilter
	interactive.singleKey
	log.abbrevCommit
	log.date
	log.decorate
	log.diffMerges
	log.excludeDecoration
	log.follow
	log.graphColors
	log.initialDecorationSet
	log.mailmap
	log.showRoot
	log.showSignature
	lsrefs.unborn
	mailinfo.scissors
	mailmap.blob
	mailmap.file
	maintenance.<task>.enabled
	maintenance.<task>.schedule
	maintenance.auto
	maintenance.commit-graph.auto
	maintenance.incremental-repack.auto
	maintenance.loose-objects.auto
	maintenance.strategy
	man.<tool>.cmd
	man.<tool>.path
	man.viewer
	merge.<driver>.driver
	merge.<driver>.name
	merge.<driver>.recursive
	merge.autoStash
	merge.branchdesc
	merge.conflictStyle
	merge.defaultToUpstream
	merge.directoryRenames
	merge.ff
	merge.log
	merge.renameLimit
	merge.renames
	merge.renormalize
	merge.stat
	merge.suppressDest
	merge.verbosity
	merge.verifySignatures
	mergetool.<tool>.cmd
	mergetool.<tool>.hideResolved
	mergetool.<tool>.path
	mergetool.<tool>.trustExitCode
	mergetool.guiDefault
	mergetool.hideResolved
	mergetool.keepTemporaries
	mergetool.meld.hasOutput
	mergetool.meld.useAutoMerge
	mergetool.prompt
	mergetool.vimdiff.layout
	mergetool.writeToTemp
	notes.<name>.mergeStrategy
	notes.displayRef
	notes.mergeStrategy
	notes.rewrite.<command>
	notes.rewriteMode
	notes.rewriteRef
	pack.allowPackReuse
	pack.compression
	pack.deltaCacheLimit
	pack.deltaCacheSize
	pack.depth
	pack.indexVersion
	pack.island
	pack.islandCore
	pack.packSizeLimit
	pack.preferBitmapTips
	pack.readReverseIndex
	pack.threads
	pack.useBitmaps
	pack.useSparse
	pack.window
	pack.windowMemory
	pack.writeBitmapHashCache
	pack.writeBitmapLookupTable
	pack.writeReverseIndex
	pager.<cmd>
	pretty.<name>
	protocol.<name>.allow
	protocol.allow
	protocol.version
	pull.ff
	pull.octopus
	pull.twohead
	push.autoSetupRemote
	push.default
	push.followTags
	push.gpgSign
	push.negotiate
	push.pushOption
	push.recurseSubmodules
	push.useBitmaps
	push.useForceIfIncludes
	rebase.abbreviateCommands
	rebase.backend
	rebase.forkPoint
	rebase.instructionFormat
	rebase.missingCommitsCheck
	rebase.rebaseMerges
	rebase.rescheduleFailedExec
	rebase.stat
	receive.advertiseAtomic
	receive.advertisePushOptions
	receive.autogc
	receive.certNonceSeed
	receive.certNonceSlop
	receive.denyCurrentBranch
	receive.denyDeleteCurrent
	receive.denyDeletes
	receive.denyNonFastForwards
	receive.fsck.badDate
	receive.fsck.badDateOverflow
	receive.fsck.badEmail
	receive.fsck.badFilemode
	receive.fsck.badName
	receive.fsck.badObjectSha1
	receive.fsck.badParentSha1
	receive.fsck.badTagName
	receive.fsck.badTimezone
	receive.fsck.badTree
	receive.fsck.badTreeSha1
	receive.fsck.badType
	receive.fsck.duplicateEntries
	receive.fsck.emptyName
	receive.fsck.extraHeaderEntry
	receive.fsck.fullPathname
	receive.fsck.gitattributesBlob
	receive.fsck.gitattributesLarge
	receive.fsck.gitattributesLineLength
	receive.fsck.gitattributesMissing
	receive.fsck.gitattributesSymlink
	receive.fsck.gitignoreSymlink
	receive.fsck.gitmodulesBlob
	receive.fsck.gitmodulesLarge
	receive.fsck.gitmodulesMissing
	receive.fsck.gitmodulesName
	receive.fsck.gitmodulesParse
	receive.fsck.gitmodulesPath
	receive.fsck.gitmodulesSymlink
	receive.fsck.gitmodulesUpdate
	receive.fsck.gitmodulesUrl
	receive.fsck.hasDot
	receive.fsck.hasDotdot
	receive.fsck.hasDotgit
	receive.fsck.mailmapSymlink
	receive.fsck.missingAuthor
	receive.fsck.missingCommitter
	receive.fsck.missingEmail
	receive.fsck.missingNameBeforeEmail
	receive.fsck.missingObject
	receive.fsck.missingSpaceBeforeDate
	receive.fsck.missingSpaceBeforeEmail
	receive.fsck.missingTag
	receive.fsck.missingTagEntry
	receive.fsck.missingTaggerEntry
	receive.fsck.missingTree
	receive.fsck.missingType
	receive.fsck.missingTypeEntry
	receive.fsck.multipleAuthors
	receive.fsck.nulInCommit
	receive.fsck.nulInHeader
	receive.fsck.nullSha1
	receive.fsck.skipList
	receive.fsck.treeNotSorted
	receive.fsck.unknownType
	receive.fsck.unterminatedHeader
	receive.fsck.zeroPaddedDate
	receive.fsck.zeroPaddedFilemode
	receive.fsckObjects
	receive.hideRefs
	receive.keepAlive
	receive.maxInputSize
	receive.procReceiveRefs
	receive.shallowUpdate
	receive.unpackLimit
	receive.updateServerInfo
	remote.<name>.fetch
	remote.<name>.mirror
	remote.<name>.partialclonefilter
	remote.<name>.promisor
	remote.<name>.proxy
	remote.<name>.proxyAuthMethod
	remote.<name>.prune
	remote.<name>.pruneTags
	remote.<name>.push
	remote.<name>.pushurl
	remote.<name>.receivepack
	remote.<name>.skipDefaultUpdate
	remote.<name>.skipFetchAll
	remote.<name>.tagOpt
	remote.<name>.uploadpack
	remote.<name>.url
	remote.<name>.vcs
	remote.pushDefault
	remotes.<group>
	repack.cruftDepth
	repack.cruftThreads
	repack.cruftWindow
	repack.cruftWindowMemory
	repack.packKeptObjects
	repack.updateServerInfo
	repack.useDeltaBaseOffset
	repack.useDeltaIslands
	repack.writeBitmaps
	rerere.autoUpdate
	revert.reference
	safe.bareRepository
	safe.directory
	sendemail.<identity>.*
	sendemail.aliasFileType
	sendemail.aliasesFile
	sendemail.annotate
	sendemail.bcc
	sendemail.cc
	sendemail.ccCmd
	sendemail.chainReplyTo
	sendemail.confirm
	sendemail.envelopeSender
	sendemail.forbidSendmailVariables
	sendemail.from
	sendemail.headerCmd
	sendemail.identity
	sendemail.multiEdit
	sendemail.signedoffbycc
	sendemail.smtpBatchSize
	sendemail.smtpDomain
	sendemail.smtpEncryption
	sendemail.smtpPass
	sendemail.smtpReloginDelay
	sendemail.smtpServer
	sendemail.smtpServerOption
	sendemail.smtpServerPort
	sendemail.smtpUser
	sendemail.smtpsslcertpath
	sendemail.suppressFrom
	sendemail.suppresscc
	sendemail.thread
	sendemail.to
	sendemail.tocmd
	sendemail.transferEncoding
	sendemail.validate
	sendemail.xmailer
	sendpack.sideband
	sequence.editor
	showBranch.default
	sparse.expectFilesOutsideOfPatterns
	splitIndex.maxPercentChange
	splitIndex.sharedIndexExpire
	ssh.variant
	stash.showIncludeUntracked
	stash.showPatch
	stash.showStat
	status.aheadBehind
	status.branch
	status.displayCommentPrefix
	status.relativePaths
	status.renameLimit
	status.renames
	status.short
	status.showStash
	status.showUntrackedFiles
	status.submoduleSummary
	submodule.<name>.active
	submodule.<name>.branch
	submodule.<name>.fetchRecurseSubmodules
	submodule.<name>.ignore
	submodule.<name>.update
	submodule.<name>.url
	submodule.active
	submodule.alternateErrorStrategy
	submodule.alternateLocation
	submodule.fetchJobs
	submodule.propagateBranches
	submodule.recurse
	tag.forceSignAnnotated
	tag.sort
	tar.umask
	trace2.configParams
	trace2.destinationDebug
	trace2.envVars
	trace2.eventBrief
	trace2.eventNesting
	trace2.eventTarget
	trace2.maxFiles
	trace2.normalBrief
	trace2.normalTarget
	trace2.perfBrief
	trace2.perfTarget
	transfer.advertiseSID
	transfer.bundleURI
	transfer.credentialsInUrl
	transfer.fsckObjects
	transfer.hideRefs
	transfer.unpackLimit
	uploadarchive.allowUnreachable
	uploadpack.allowAnySHA1InWant
	uploadpack.allowFilter
	uploadpack.allowReachableSHA1InWant
	uploadpack.allowRefInWant
	uploadpack.allowTipSHA1InWant
	uploadpack.hideRefs
	uploadpack.keepAlive
	uploadpack.packObjectsHook
	uploadpackfilter.<filter>.allow
	uploadpackfilter.allow
	uploadpackfilter.tree.maxDepth
	url.<base>.insteadOf
	url.<base>.pushInsteadOf
	user.useConfigOnly
	versionsort.suffix
	web.browser
	windows.appendAtomically
	worktree.guessRemote
	a.a.C
	$#@@#$%&#@
	1234
	~x.Y
Success (exit code 0)
	commit.gpgSign
	core.autocrlf
	core.bare
	core.commitGraph
	core.editor
	core.fileMode
	core.fscache
	core.ignoreCase
	core.logAllRefUpdates
	core.preloadIndex
	core.repositoryFormatVersion
	core.safecrlf
	core.symlinks
	credential.helper
	diff.guitool
	diff.tool
	difftool.prompt
	fetch.prune
	gpg.program
	http.sslBackend
	http.sslCAInfo
	i18n.commitEncoding
	init.defaultBranch
	merge.guitool
	merge.tool
	mergetool.keepBackup
	pull.rebase
	rebase.autoSquash
	rebase.autoStash
	rebase.updateRefs
	rerere.enabled
	tag.gpgSign
	user.email
	user.name
	user.signingKey

return GitExecutable.GetOutput(args, cache: cache ? GitCommandCache : null).Trim();
ExecutionResult result = GitExecutable.Execute(args, cache: cache ? GitCommandCache : null, throwOnErrorExit: false);

int resultCode = result.ExitCode ?? 0;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do not hide execution errors, should be an error.

Copy link
Contributor Author

@vbjay vbjay Aug 12, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Wrong. Kind of what I am pointing out. It is NOT a failure. You and @mstv need to understand exit codes and when they are and not a failure. I detailed in related issue if you will read tied issue.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Git config on a config value that is not set still returns a config value. Bash scripts don't go nuts because value isn't set. We shouldn't either. What I have done is provide not only the config value but a yes I got a value(config key found) Succes status or here your value is blank but you know config value was unset and if we run a set and get an exit code not 0 we have the reason. How about you take the time to read the related issue and understand the change instead of knee jerk reviewing.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no exit code, it is definitely an error.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If there is no exit code, it is definitely an error.

I can change that. It was just a nullable so had to handle that to make it a value. Doubt it would ever be null.

/// </summary>
public enum GitConfigStatus
{
CannotWriteToConfigFile = 4,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

With this tight dependency on Git, the behaviour should be tested with real Git commands, where reasonable

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Read on further and note the tests.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

There are no tests to see that for instance CannotWriteToConfigFile is set when expected. This behavior can be changed in Git updates.

If this knowledge is not needed, no need to add the enums.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am providing all known git config values in the enum. Just because we use a custom config file work instead of actually reading from parsing git config list run doesn't mean the value can't be used in the future. The idea being we can call git config value and get back an EffectiveGitSetting or what not. Still thinking about correct type name that makes sense for both potentials. So I disagree. I am laying groundwork for both sets and gets. For now doing get but the full potential git config exit codes are represented in enum. I can look at git source code and look for what causes each exit code to better understand that. The rest I have makes sure that GetEffectiveGitSetting does not fail and also lists each config key with the exit code grouping. Running the code for every config so far shows exit code 1 and 0. If you want to pull my branch and run the test and verify...you can do so to provide verification of just 1 and 0.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you add something, it must be maintainable. If just 0/1 are expected, all others can be ignored, I see no direct need to handle them in the future. The extra values can be comments.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I am providing the full enum at time of creation of the enum. I have done the research of the git source code and understand each exit code and when it shows up. I have documented it. This is one of a few prs I am going to be doing in git config. For example down the road I plan on still keeping file source classes from the git config file stuff but I want all git config reads to be read in by actually reading git config instead of us doing something custom with file reads and writes. Still looking into the setting side where we want to set multiple keys. That will be in a whole different pr/ issue. I am laying the foundation for full git config driving and handling things we don't currently handle like multi valued configs and such.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both points are valid. The risk of git changing these return codes is probably quite low, likely they'd break a lot of people worldwide. At the same time, I find @gerhardol point about maintainability slightly more compelling, if we don't have an immediate use for some piece of code, I prefer not to add it. IMO it's totally valid to note all the possible return codes git may return for the config reading operation (thank you @vbjay for spending time finding those), but only expose the values we need. In the future, if a need to handle other return code arise, we can uncomment the necessary lines.

{
public record struct EffectiveGitSetting(GitConfigStatus? Status, string Value)
{
public static implicit operator (GitConfigStatus? status, string value)(EffectiveGitSetting value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Avoid value for arguments, there are several layers with the same name

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

What do you suggest instead of the "Value" from the config entry and still having status and config key?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

or something, instead of the contextual keyword https://learn.microsoft.com/en-us/dotnet/csharp/language-reference/keywords/value

Suggested change
public static implicit operator (GitConfigStatus? status, string value)(EffectiveGitSetting value)
public static implicit operator (GitConfigStatus? status, string errorMessage)(EffectiveGitSetting gitSetting)

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this instance Value represents git setting value, so I think the name is appropriate. I would ask for xml-docs clearly explaining the nature and the purpose for all public API though.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yep. Def was going to do so once feedback was provided.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

But Value vs value is confusing here, i specific name would add value, this is not a generic interface. What is it that the value holds?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

GitCommands/Git/GitModule.cs Outdated Show resolved Hide resolved
{
public record struct EffectiveGitSetting(GitConfigStatus? Status, string Value)
{
public static implicit operator (GitConfigStatus? status, string value)(EffectiveGitSetting value)
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

In this instance Value represents git setting value, so I think the name is appropriate. I would ask for xml-docs clearly explaining the nature and the purpose for all public API though.

Plugins/GitUIPluginInterfaces/GitConfigStatus.cs Outdated Show resolved Hide resolved
Comment on lines 18 to 24
CannotWriteToConfigFile = 4,
CannotUnsetOrSet = 5,
ConfigKeyInvalidOrNotSet = 1,
InvalidConfigFileGiven = 3,
InvalidRegexp = 6,
NoConfigKeyGiven = 2,
Success = 0,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please order in ascending order by value.
Xml-docs for each.

@RussKie RussKie added the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Aug 14, 2023
@ghost ghost removed the 📭 needs: author feedback More info/confirmation awaited from OP; issues typically get closed after 30 days of inactivity label Aug 14, 2023
@vbjay vbjay force-pushed the bug/GetEffectiveGitSetting_Error branch 3 times, most recently from 7221db4 to 91c192a Compare August 14, 2023 19:58
@gerhardol
Copy link
Member

I would prefer to replace current method with public string GetEffectiveGitSettingOrDefault(string setting) that returns "" if exitcode==1 and simplify the change.

@vbjay vbjay force-pushed the bug/GetEffectiveGitSetting_Error branch from 91c192a to 1a541a2 Compare August 14, 2023 20:55
Updates the method to return not only the value of the config but also the status
based on the ExitCodes from git config documentation.
This allows for deciding what to do if config key doesn't exist by the user of GetEffectiveGitSetting
@vbjay vbjay force-pushed the bug/GetEffectiveGitSetting_Error branch from 1a541a2 to 5bdb122 Compare August 14, 2023 21:03
@vbjay
Copy link
Contributor Author

vbjay commented Aug 14, 2023

I would prefer to replace current method with public string GetEffectiveGitSettingOrDefault(string setting) that returns "" if exitcode==1 and simplify the change.

No on the if. I am making it so it is readable and understood by all.

image

Is a TON clearer. It reads and you can look at the enum for what it is doing
image

@gerhardol you aren't seeing the direction I am going. That's ok. The whole point is to actually have a ful git config running feature where we can do the following:

  • run a git config -l and parse output and generate our scoped effective, local and so on config values by grouping by scope replacing custom file work so that we remain consistent with git config results
  • handle git config multi values search https://git-scm.com/docs/git-config for muti-valued
  • allow for setting configs using git config and already have the exit codes defined. I know I am not modifying setting yet but the groundwork is there for the potential in the near future.

Notice the metadata I have now. Run the test and look at the output. Read the comments. You need to stop with keeping it the same and look for what I am trying to do. I am trying to go for how to make it better and not just tweak. I have told you i am against creating a whole one way or another. I am following the principle of don't use exception's for program flow. How about you actually take the time to see the vision of where I am going and see that I am actually making it better.

I challenge you to pull my pr and actually debug it and read the git source code I linked and actually understand my direction instead of whining on complexity or not following stuff.

I AM STRONGLY against creating multiple directions of this api. I am trying to make it so it can eventually grow into a overload where we can have a GetEffectiveGitSettings where the same idea instead generates a hashmap, dictionary.... whatever of the keys fetched from a git config -l run and still knowing the scope and file and whatnot. Heck, we already have 2 that are named alike and make it too easy to mix up the one desired. I am trying to actually go in the direction of eliminating ways of getting config.

I want @RussKie to chime in and provide feedback. You aren't seeing it and I think he does.

Also, I am thinking in the part where i do the set part is where i will split the GitConfigGetResult into base and have a GitConfigGetResult and a GitConfigSetResult

@gerhardol
Copy link
Member

you aren't seeing the direction I am going. That's ok. The whole point is to actually have a ful git config running feature where we can do the following:

What other exit code than 1 do you plan to handle and why?
How is those error codes etc related to the objectives you have?

This PR hides the error that the setting do not exists, it should be visible for the user.

I challenge you to pull my pr and actually debug it and read the git source code I linked and actually understand my direction instead of whining on complexity or not following stuff.

Can you please take it a little easier with your comments and not go full frontal attacks on everything you do not agree with. It sure demotivates other than me.

Note: Please do not squash and rebase so often for the PR branches. It is very hard to follow changes and see when there actually are changes.

@vbjay
Copy link
Contributor Author

vbjay commented Aug 14, 2023

you aren't seeing the direction I am going. That's ok. The whole point is to actually have a ful git config running feature where we can do the following:

What other exit code than 1 do you plan to handle and why?
How is those error codes etc related to the objectives you have?

I am not interested in making a partial enum that I have to fix later. I have provided all exit codes and clearly documented them. The enum is named clearly. It is not just exit codes for get. It is all exit codes from git config.

This PR hides the error that the setting do not exists, it should be visible for the user.

It is. They have at their chosing ability to inspect status and react as needed. If they need to handle not set, they can code for it. I did not lose the fact it is unset. It is just not exceptional flow which it shouldn't be. It should just be known state. You shouldn't be looking at 1 as exceptional state. Git returns an exit code telling you the value isn't just a set blank. Inspecting status and handling that if desired is not hard. Being unset and requesting the value should not result in exceptional state. Git provides a default value when requested and doesn't blow up in shell. We shouldn't either.

I challenge you to pull my pr and actually debug it and read the git source code I linked and actually understand my direction instead of whining on complexity or not following stuff.

Can you please take it a little easier with your comments and not go full frontal attacks on everything you do not agree with. It sure demotivates other than me.

Sure. But your reviews have felt a lot like drive by reviews without understanding so a tad bothered.

Note: Please do not squash and rebase so often for the PR branches. It is very hard to follow changes and see when there actually are changes.

I can try to keep fixups until final review but I also rebase to keep up to date with master to catch and conflicts and test on what would go if meged without having jay merged origin/master into pr branch over and over.

@gerhardol
Copy link
Member

Note: Please do not squash and rebase so often for the PR branches. It is very hard to follow changes and see when there actually are changes.

I can try to keep fixups until final review but I also rebase to keep up to date with master to catch and conflicts and test on what would go if meged without having jay merged origin/master into pr branch over and over.

Do that in private branches.
Rebase "just" resets the review status per file and context related comments may be lost so that can be done when reviews are 'stable'.

Copy link
Contributor Author

@vbjay vbjay left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Just something I noticed while away and don't want to forget.

string value = result.StandardOutput?.Trim() ?? "" + Delimiters.Null;

// Scope, file, value split by null.
string[] values = value.Split(Delimiters.Null, StringSplitOptions.RemoveEmptyEntries);
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'll fix. Realized I shouldn't remove empty here. Just a by default thing I do because it makes sense most times.

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use spans here to reduce allocations?

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

image
image

string value = result.StandardOutput?.Trim() ?? "" + Delimiters.Null;

// Scope, file, value split by null.
string[] values = value.Split(Delimiters.Null, StringSplitOptions.RemoveEmptyEntries);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we use spans here to reduce allocations?

Comment on lines +380 to +387
foreach (var g in settings.GroupBy(s => s.Status))
{
Console.WriteLine(g.Key?.ToString() ?? "NULL");
foreach (var s in g)
{
Console.WriteLine($"\t{s}");
}
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why do we need this?
TBH, I very much dislike it when I run tests the console is getting full of random output. It's not really helpful and often it's extremely difficult to find out where that random output originated from.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Console writes can be removed. It was more to show the result. Can wrap if debug.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The main point is that I didn't wrap in a try catch and that the test will cause a failure if an exception occurs which should not happen. The select gathering the values and the shoulds are the actual test. I was just using the console outputs to show the items in the test for now.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I also use Devexpress Code Rush Test Runner
image
So outputs for each test are contained and I can do this
image

/// </summary>
public enum GitConfigStatus
{
CannotWriteToConfigFile = 4,
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think both points are valid. The risk of git changing these return codes is probably quite low, likely they'd break a lot of people worldwide. At the same time, I find @gerhardol point about maintainability slightly more compelling, if we don't have an immediate use for some piece of code, I prefer not to add it. IMO it's totally valid to note all the possible return codes git may return for the config reading operation (thank you @vbjay for spending time finding those), but only expose the values we need. In the future, if a need to handle other return code arise, we can uncomment the necessary lines.

@vbjay
Copy link
Contributor Author

vbjay commented Aug 15, 2023

One more point, if I get git config all wrapped under our program using actual git config for retrieving values no matter what with the caching and such still working, we can then eliminate the system file not being read issue also. Our git config reading will be consistent with the values as if you called git config --get some.key. See the issues tied to editor and such for an example of what I mean. I don't like that we have a custom read files. Heck we probably have the same issue with worktree git config. Haven't looked and don't want to digress into another issue but I am trying to get to a point of being as consistent as possible with git config results.

vbjay and others added 4 commits August 16, 2023 08:51
Take reformat of comment

Co-authored-by: Igor Velikorossov <RussKie@users.noreply.github.com>
wrap #if debug for output to be ignored on release build
Extract method to support use in other methods down the road
@gerhardol
Copy link
Member

Note: This PR is for some future handling (not described in the description, possibly in some comments that I fail to find).
It will give a bad error message to the user, see below.

GetEffectiveGitSetting() was added in #10843 (from #5492 (comment)) to show the email address in FormCommit
All other GE usage parses the logfiles directly, not using git-config. However, the GE parser is incomplete and do not handle include (?) and if (may be more). (This should be implemented regardless.)
These keys should be cached too (but the cache key must include the current repo if not already like that.) The info is read async, so not affecting the startup here.

image

If email (or name?) is not set, it is not possible to commit in Git.
You should get a notification about that when starting, but since conditionals are incomplete, the check can fail.
You therefore get a message in the popup with the text below, which is easier to ignore.

Other GE uses should use the internal parsing for performance reasons too, unless there are very specific reasons.
Together with the error message I see no argument to merge this now.

"C:\Program Files\Git\bin\git.exe" commit --amend -F "C:/dev/gc/gitextensions/.git/worktrees/gitextensions_4/COMMITMESSAGE" --allow-empty
Committer identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'user@pc.(none)')
Done

Press Enter or Esc to exit...

@RussKie
Copy link
Member

RussKie commented Aug 17, 2023

All other GE usage parses the logfiles directly, not using git-config.

That'd be great to change in the future.

These keys should be cached too (but the cache key must include the current repo if not already like that.)

The values can change though while the app is running, so implmentations must be conscience of that.

Together with the error message I see no argument to merge this now.

Apologies, I'm struggling to parse this. Are you saying you have "no reasons to merge this" or you have "no objections to merging this".

@vbjay
Copy link
Contributor Author

vbjay commented Aug 17, 2023

Note: This PR is for some future handling (not described in the description, possibly in some comments that I fail to find).
It will give a bad error message to the user, see below.

GetEffectiveGitSetting() was added in #10843 (from #5492 (comment)) to show the email address in FormCommit
All other GE usage parses the logfiles directly, not using git-config. However, the GE parser is incomplete and do not handle include (?) and if (may be more). (This should be implemented regardless.)
These keys should be cached too (but the cache key must include the current repo if not already like that.) The info is read async, so not affecting the startup here.

image

If email (or name?) is not set, it is not possible to commit in Git.
You should get a notification about that when starting, but since conditionals are incomplete, the check can fail.
You therefore get a message in the popup with the text below, which is easier to ignore.

Other GE uses should use the internal parsing for performance reasons too, unless there are very specific reasons.
Together with the error message I see no argument to merge this now.

"C:\Program Files\Git\bin\git.exe" commit --amend -F "C:/dev/gc/gitextensions/.git/worktrees/gitextensions_4/COMMITMESSAGE" --allow-empty
Committer identity unknown

*** Please tell me who you are.

Run

  git config --global user.email "you@example.com"
  git config --global user.name "Your Name"

to set your account's default identity.
Omit --global to set the identity only in this repository.

fatal: unable to auto-detect email address (got 'user@pc.(none)')
Done

Press Enter or Esc to exit...

Exactly why I hit this one first. The next work will be looking at the other ways we read git config. Goal is to get it so all git config reading is actually done by using git config so stuff like our skipping system reading and worktree level settings will be fixed. Either git config --get or --get-all or git config -l to get all values. Still managing the different scopes with --show-scope and --show-origin and such. So still being able to show this is distributed with repo, this local, this global and so on. I dislike the internal processing that lacks reading all levels.

Other GE uses should use the internal parsing for performance reasons too,

Kinda where I'm disagreeing. Our internal reading stinks. It doesn't support --system level config along with --workreee along with multiple value configs.

Think of it this way.

git config -z --show-origin --show-scope -l.

Group by scope and you have your config levels and can even include file paths to go further in grouping. The issues like #1018 and #10579 shows that even if global is not set we should be reading system level. With the -l we can cache the whole config set in one shot. The fact we diverged from actual git config output is part of the problem.

system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^diff.astextplain.textconv
astextplain^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^filter.lfs.clean
git-lfs clean -- %f^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^filter.lfs.smudge
git-lfs smudge -- %f^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^filter.lfs.process
git-lfs filter-process^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^filter.lfs.required
true^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^http.sslbackend
openssl^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^http.sslcainfo
C:/Program Files/Git/mingw64/etc/ssl/certs/ca-bundle.crt^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^core.autocrlf
true^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^core.fscache
true^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^core.symlinks
false^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^pull.rebase
false^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^credential.helper
manager^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^credential.https://dev.azure.com.usehttppath
true^Null^system^Null^file:C:/Program Files/Git/etc/gitconfig^Null^init.defaultbranch
master^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^rebase.autosquash
true^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^rebase.autostash
true^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^rebase.updaterefs
true^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^i18n.filesencoding
utf-8^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^core.autocrlf
true^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^difftool.p4merge.path
C:/Program Files/Perforce/p4merge.exe^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^difftool.p4merge.cmd
"C:/Program Files/Perforce/p4merge.exe" "$LOCAL" "$REMOTE"^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^mergetool.p4merge.path
C:/Program Files/Perforce/p4merge.exe^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^mergetool.p4merge.cmd
"C:/Program Files/Perforce/p4merge.exe" "$BASE" "$LOCAL" "$REMOTE" "$MERGED"^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^merge.guitool
p4merge^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^diff.guitool
p4merge^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^user.name
John Smith^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^user.email
123@123.com^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^pull.rebase
false^Null^global^Null^file:C:/Users/WDAGUtilityAccount/.gitconfig^Null^fetch.prune
false^Null^local^Null^file:.git/config^Null^core.repositoryformatversion
0^Null^local^Null^file:.git/config^Null^core.filemode
false^Null^local^Null^file:.git/config^Null^core.bare
false^Null^local^Null^file:.git/config^Null^core.logallrefupdates
true^Null^local^Null^file:.git/config^Null^core.symlinks
false^Null^local^Null^file:.git/config^Null^core.ignorecase
true^Null^

@vbjay
Copy link
Contributor Author

vbjay commented Aug 17, 2023

Ran git config --global -unset user.name and email .
image
image
which in this case works. It tels them that it won't work at the right time, along with if they fix and acivate window again,it will show updated info

image
image

So I don't see the problem here. If just installed we get them to setup. The window shows that the user info is blank and user can click link in status bar to fix.

@gerhardol
Copy link
Member

I do not want to merge this PR.

In the short run, I find the error message worse. Not occurring often and nothing major but still worse.
Sure, the caller in FormCommit could check the status but a separate popup for this would be overkill.
So from a functionality point of view, I say -1.

From implementation point of view (if we want to have the changes above), I find this to add complexity that is not needed. Only exit code 1 is checked, a lot of extra handling added.
Also from a longer perspective, if this is to be used elsewhere only 1 is needed what I see. Other are external exceptions, should not happen, they are user errors (so a bad GE implementation).

From a longer perspective, replacing GE config parsing with Git config parsing in general will add a lot of delays to the application, adding hundreds of ms to opening of forms and delays in other situations (no analyze).
The benefit is quite minor, fixing the parsing is better spent time then.

@vbjay
Copy link
Contributor Author

vbjay commented Aug 17, 2023

image
You mean the same error you get if in master?
image

With mine you can see the fact that the committer is blank and it doesn't just silently bomb. I am sick and tired of you bull with the timing.
image
and that is getting all configs.

A. I did mention we could still cache and run a git config -l and capture all of config.
B. The user name and email should be captured at activate since the user potentially adjusted and we want to reflect current value in status bar.
C. We currently diverged from getting current git config and I am trying to get it so we are not diverged from actual git config

I think you are just wanting to not change into something that is different. I think you sit in your chair and look at github pull requests and don't take the time to investigate and actually try it out and compare before and after. You just sit there on github.com and don't pull it down and compare behavior.

At least I know @mstv and @RussKie actually try stuff out. With you you just quickly and blindly without understanding do reviews and it irritates the snot out of me. @mstv raises points that are issues that are advised to change.

@vbjay
Copy link
Contributor Author

vbjay commented Aug 17, 2023

Do the following before you review.

build latest master and run the following
git config --unset -global user.name
git config --unset -global user.email

Run your build and act like you are going to commit. note the behaviour and status bar. Even better debug it while doing so.

Pull my pull request and do the same. Note any behaviour changes.

@vbjay
Copy link
Contributor Author

vbjay commented Aug 17, 2023

https://git-scm.com/docs/git-worktree#_configuration_file work tree
https://git-scm.com/docs/git-config#Documentation/git-config.txt---system system

There are things that cna be done like have a memory cacheof settings and have it expire after x time and for only specific settings we always fetch current like user name and email. Others can be fetched from the cache. When the cache expires, make a git config fetcher reload it. All kinds of solutions for timing and when to run git config but still hav equick load times but still fight stale config issue. But the first part is to get it so that stuff is using the official git config parsing all the way through.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

GetEffectiveGitSetting treats non 0 results as failures
4 participants