git.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Karsten Blees <karsten.blees@gmail.com>
To: Matthieu Moy <Matthieu.Moy@grenoble-inp.fr>
Cc: Eric Sunshine <sunshine@sunshineco.com>,
	Tanay Abhra <tanayabh@gmail.com>, Git List <git@vger.kernel.org>,
	Ramkumar Ramachandra <artagnon@gmail.com>
Subject: Re: [RFC/PATCH] pager.c: replace git_config with git_config_get_string
Date: Sat, 28 Jun 2014 16:29:17 +0200	[thread overview]
Message-ID: <53AED13D.60705@gmail.com> (raw)
In-Reply-To: <vpqy4whshbj.fsf@anie.imag.fr>

[-- Attachment #1: Type: text/plain, Size: 2186 bytes --]

Am 28.06.2014 08:01, schrieb Matthieu Moy:
> Karsten Blees <karsten.blees@gmail.com> writes:
> 
>> I still don't like that the invalidation is done in git_config_set, though, as
>> this is also used to write completely unrelated files.
> 
> I don't get it. It is used to write the config files. Yes, we trigger a
> complete reload instead of just changing this particular value in the
> hashmap, but I do not see "unrelated files" in the picture.
> 

git-cherry-pick, revert: writes '.git/sequencer/opts' (sequencer.c:save_opts)
git-mv <submodule>: writes '.gitmodules' (submodule.c:update_path_in_gitmodules)
  ...and the submodule's '.git/config' (submodule.c:connect_work_tree_and_git_dir)


Note that the typical configuration commands git-config/remote/branch seem
to call git_config_set* immediately before exit, so no need to invalidate
the config cache here either.

Which leaves clone, init and push (transport.c:set_upstreams, seems to be
just before exit as well).

I didn't look further after finding the example in cmd_clone, so with the
statistics above, it may well be the only instance of {git_config; 
git_config_set; git_config}, I don't know.

I've attached the reverse call hierarchy as generated by Eclipse - quite
useful for things like this.

>> Wouldn't it be better to have a 'git_config_refresh()' that could be
>> used in place of (or before) current 'git_config(callback)' calls? The
>> initial implementation could just invalidate the config cache. If
>> there's time and energy to spare, a more advanced version could first
>> check if any of the involved config files has changed.
> 
> That would not change the "xstrdup" vs "no xstrdup" issue, right?
> 

Right. (Unless it turns out invalidation isn't needed after all. But even
then using interned strings for the config would be a Good Thing IMO.)

>> The xstrdup() problem could be solved by interning strings (see the
>> attached patch for a trivial implementation). I.e. allocate each distinct
>> string only once (and keep it allocated).
> 
> That's an option. We need to be carefull not to modify any string
> in-place,

Hopefully an illegal non-const cast will be caught in the review process.



[-- Attachment #2: git-config-set-callers.txt --]
[-- Type: text/plain, Size: 6597 bytes --]

git_config_set_multivar_in_file(const char *, const char *, const char *, const char *, int) : int - /git/config.c
	cmd_config(int, const char * *, const char *) : int - /git/builtin/config.c (5 matches)
	git_config_set_in_file(const char *, const char *, const char *) : int - /git/config.c
		cmd_config(int, const char * *, const char *) : int - /git/builtin/config.c (2 matches)
		connect_work_tree_and_git_dir(const char *, const char *) : void - /git/submodule.c
			cmd_mv(int, const char * *, const char *) : int - /git/builtin/mv.c
		save_opts(replay_opts *) : void - /git/sequencer.c (8 matches)
			sequencer_pick_revisions(replay_opts *) : int - /git/sequencer.c
				cmd_cherry_pick(int, const char * *, const char *) : int - /git/builtin/revert.c
				cmd_revert(int, const char * *, const char *) : int - /git/builtin/revert.c
		update_path_in_gitmodules(const char *, const char *) : int - /git/submodule.c
			cmd_mv(int, const char * *, const char *) : int - /git/builtin/mv.c
	git_config_set_multivar(const char *, const char *, const char *, int) : int - /git/config.c
		add_branch(const char *, const char *, const char *, int, strbuf *) : int - /git/builtin/remote.c
			add_branches(remote *, const char * *, const char *) : int - /git/builtin/remote.c
				set_remote_branches(const char *, const char * *, int) : int - /git/builtin/remote.c
					set_branches(int, const char * *) : int - /git/builtin/remote.c
						cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
			add(int, const char * *) : int - /git/builtin/remote.c
				cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
		cmd_branch(int, const char * *, const char *) : int - /git/builtin/branch.c (2 matches)
		git_config_set(const char *, const char *) : int - /git/config.c
			add(int, const char * *) : int - /git/builtin/remote.c (3 matches)
				cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
			cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c (2 matches)
			create_default_files(const char *) : int - /git/builtin/init-db.c (8 matches)
				init_db(const char *, unsigned int) : int - /git/builtin/init-db.c
					cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
					cmd_init_db(int, const char * *, const char *) : int - /git/builtin/init-db.c
			edit_branch_description(const char *) : int - /git/builtin/branch.c
				cmd_branch(int, const char * *, const char *) : int - /git/builtin/branch.c
			init_db(const char *, unsigned int) : int - /git/builtin/init-db.c (2 matches)
				cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
				cmd_init_db(int, const char * *, const char *) : int - /git/builtin/init-db.c
			install_branch_config(int, const char *, const char *, const char *) : void - /git/branch.c (3 matches)
				cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
				set_upstreams(transport *, ref *, int) : void - /git/transport.c
					transport_push(transport *, int, const char * *, int, unsigned int *) : int - /git/transport.c
						push_with_options(transport *, int) : int - /git/builtin/push.c
							do_push(const char *, int) : int - /git/builtin/push.c (2 matches)
								cmd_push(int, const char * *, const char *) : int - /git/builtin/push.c
				setup_tracking(const char *, const char *, enum branch_track, int) : int - /git/branch.c
					create_branch(const char *, const char *, const char *, int, int, int, int, enum branch_track) : void - /git/branch.c
						cmd_branch(int, const char * *, const char *) : int - /git/builtin/branch.c (2 matches)
						update_refs_for_switch(const checkout_opts *, branch_info *, branch_info *) : void - /git/builtin/checkout.c
							switch_branches(const checkout_opts *, branch_info *) : int - /git/builtin/checkout.c
								checkout_branch(checkout_opts *, branch_info *) : int - /git/builtin/checkout.c
									cmd_checkout(int, const char * *, const char *) : int - /git/builtin/checkout.c
				update_head(const ref *, const ref *, const char *) : void - /git/builtin/clone.c
					cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
			mingw_mark_as_git_dir(const char *) : void - /git/compat/mingw.c
				init_db(const char *, unsigned int) : int - /git/builtin/init-db.c
					cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
					cmd_init_db(int, const char * *, const char *) : int - /git/builtin/init-db.c
			mv(int, const char * *) : int - /git/builtin/remote.c
				cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
			rm(int, const char * *) : int - /git/builtin/remote.c
				cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
			set_url(int, const char * *) : int - /git/builtin/remote.c
				cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
			write_refspec_config(const char *, const ref *, const ref *, strbuf *) : void - /git/builtin/clone.c
				cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
		migrate_file(remote *) : int - /git/builtin/remote.c (3 matches)
			mv(int, const char * *) : int - /git/builtin/remote.c
				cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
		mv(int, const char * *) : int - /git/builtin/remote.c (2 matches)
			cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
		remove_all_fetch_refspecs(const char *, const char *) : int - /git/builtin/remote.c
			set_remote_branches(const char *, const char * *, int) : int - /git/builtin/remote.c
				set_branches(int, const char * *) : int - /git/builtin/remote.c
					cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
		set_url(int, const char * *) : int - /git/builtin/remote.c (3 matches)
			cmd_remote(int, const char * *, const char *) : int - /git/builtin/remote.c
		write_one_config(const char *, const char *, void *) : int - /git/builtin/clone.c
			write_config(string_list *) : void - /git/builtin/clone.c
				cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
		write_refspec_config(const char *, const ref *, const ref *, strbuf *) : void - /git/builtin/clone.c
			cmd_clone(int, const char * *, const char *) : int - /git/builtin/clone.c
	save_opts(replay_opts *) : void - /git/sequencer.c
		sequencer_pick_revisions(replay_opts *) : int - /git/sequencer.c
			cmd_cherry_pick(int, const char * *, const char *) : int - /git/builtin/revert.c
			cmd_revert(int, const char * *, const char *) : int - /git/builtin/revert.c

  reply	other threads:[~2014-06-28 14:29 UTC|newest]

Thread overview: 41+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-06-23 10:41 [RFC/PATCH V2] alias.c: replace git_config with git_config_get_string Tanay Abhra
2014-06-23 10:41 ` [RFC/PATCH V2] branch.c: " Tanay Abhra
2014-06-25  4:45   ` Eric Sunshine
2014-06-26  8:09     ` Tanay Abhra
2014-06-29 11:06       ` Eric Sunshine
2014-06-23 10:41 ` [RFC/PATCH] imap-send.c: " Tanay Abhra
2014-06-25  7:09   ` Eric Sunshine
2014-06-26  8:14     ` Tanay Abhra
2014-06-26 16:50   ` Matthieu Moy
2014-06-26 23:57     ` Karsten Blees
2014-06-23 10:41 ` [RFC/PATCH] notes-util.c: " Tanay Abhra
2014-06-25  7:54   ` Eric Sunshine
2014-06-26  8:19     ` Tanay Abhra
2014-06-29 11:01       ` Eric Sunshine
2014-06-30 13:34         ` Karsten Blees
2014-06-30 14:32           ` Eric Sunshine
2014-06-30 14:54             ` Karsten Blees
2014-06-30 14:39           ` Tanay Abhra
2014-06-30 15:56             ` Karsten Blees
2014-06-30 16:21               ` Tanay Abhra
2014-06-30 17:52               ` Junio C Hamano
2014-07-01  8:36             ` Matthieu Moy
2014-06-23 10:41 ` [RFC/PATCH] notes.c: " Tanay Abhra
2014-06-25  8:06   ` Eric Sunshine
2014-06-26  8:20     ` Tanay Abhra
2014-06-23 10:41 ` [RFC/PATCH] pager.c: " Tanay Abhra
2014-06-25  3:59   ` Eric Sunshine
2014-06-26  8:24     ` Tanay Abhra
2014-06-26 18:46     ` Karsten Blees
2014-06-27 11:55       ` Matthieu Moy
2014-06-27 16:57         ` Karsten Blees
2014-06-27 19:19           ` Matthieu Moy
2014-06-28  5:20             ` Karsten Blees
2014-06-28  6:01               ` Matthieu Moy
2014-06-28 14:29                 ` Karsten Blees [this message]
2014-06-29 12:04                   ` Matthieu Moy
2014-06-23 22:38 ` [RFC/PATCH V2] alias.c: " Jonathan Nieder
2014-06-24  1:50   ` Tanay Abhra
2014-06-25  2:12 ` Eric Sunshine
2014-06-26  8:24   ` Tanay Abhra
2014-06-26 16:39 ` Matthieu Moy

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=53AED13D.60705@gmail.com \
    --to=karsten.blees@gmail.com \
    --cc=Matthieu.Moy@grenoble-inp.fr \
    --cc=artagnon@gmail.com \
    --cc=git@vger.kernel.org \
    --cc=sunshine@sunshineco.com \
    --cc=tanayabh@gmail.com \
    /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).