* [BUG] git config --rename-section and variable replacement can lose config data
@ 2009-06-06 8:52 A. Christine Spang
0 siblings, 0 replies; only message in thread
From: A. Christine Spang @ 2009-06-06 8:52 UTC (permalink / raw)
To: git
Hi,
While working on a Perl module that parses git-style config files I noticed
the following bug while replicating the --rename-section functionality:
spang@loki:~/tmp> cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[valid] foo = bar
hello = world
spang@loki:~/tmp> git config --get valid.foo
bar
spang@loki:~/tmp> git config --rename-section valid lost-data
spang@loki:~/tmp> cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[lost-data]
hello = world
As you can see, --rename-section just replaces the entire line
containing the section header that is being renamed, and if there is a
config variable (or a comment, for that matter) following the section
header on the same line (which is valid according to the config format
documentation and the test suite), it is lost.
On further investigation, git config also blows away comments at the end
of the line when replacing variable values, e.g.:
spang@loki:~/tmp> cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[test]
foo = bar ; a comment
spang@loki:~/tmp> git config test.foo baz
spang@loki:~/tmp> cat .git/config
[core]
repositoryformatversion = 0
filemode = true
bare = false
logallrefupdates = true
[test]
foo = baz
IMHO, it would be saner to, when a section header or variable value is to be
replaced, just replace the substring of the line in question that needs
replacing, rather than writing whole new lines and having to check if there is
a variable and/or a comment following the data that is being replaced and then
writing those to new lines as well. (Where would the comment be moved to?)
I'm using git v1.6.3.1, but I've looked at the code and the bug is still
present in HEAD.
cheers,
Christine
^ permalink raw reply [flat|nested] only message in thread
only message in thread, other threads:[~2009-06-06 8:52 UTC | newest]
Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2009-06-06 8:52 [BUG] git config --rename-section and variable replacement can lose config data A. Christine Spang
Code repositories for project(s) associated with this public inbox
https://80x24.org/mirrors/git.git
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 read-only IMAP folder(s) and NNTP newsgroup(s).