From: "A. Christine Spang" <spang@MIT.EDU>
To: git@vger.kernel.org
Subject: [BUG] git config --rename-section and variable replacement can lose config data
Date: Sat, 6 Jun 2009 04:52:12 -0400 [thread overview]
Message-ID: <20090606085212.GA17461@how-about-a-nice-game-of-chess.mit.edu> (raw)
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
reply other threads:[~2009-06-06 8:52 UTC|newest]
Thread overview: [no followups] expand[flat|nested] mbox.gz Atom feed
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20090606085212.GA17461@how-about-a-nice-game-of-chess.mit.edu \
--to=spang@mit.edu \
--cc=git@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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 NNTP newsgroup(s).