git/list[1] front-page[2] threads[3] people[4] search[5] about
 

Re: [PATCH v2 1/2] config: allow giving separate author and committer idents

From
William Hubbs <williamh@gentoo.org>
Date
Jan 29, 2019, 22:42 UTC
Message-ID
<20190129224209.GA3392@whubbs1.gaikai.biz>
In-Reply-To
<877ees4a65.fsf@evledraar.gmail.com>
On Fri, Jan 25, 2019 at 11:58:10PM +0100, Ævar Arnfjörð Bjarmason wrote:
Show 51 quoted lines
> 
> On Fri, Jan 25 2019, William Hubbs wrote:
> 
> > @@ -480,6 +515,46 @@ int git_ident_config(const char *var, const char *value, void *data)
> >  		return 0;
> >  	}
> >
> > +	if (!strcmp(var, "author.name")) {
> > +		if (!value)
> > +			return config_error_nonbool(var);
> > +		strbuf_reset(&git_author_name);
> > +		strbuf_addstr(&git_author_name, value);
> > +		author_ident_explicitly_given |= IDENT_NAME_GIVEN;
> > +		ident_config_given |= IDENT_NAME_GIVEN;
> > +		return 0;
> > +	}
> > +
> > +	if (!strcmp(var, "author.email")) {
> > +		if (!value)
> > +			return config_error_nonbool(var);
> > +		strbuf_reset(&git_author_email);
> > +		strbuf_addstr(&git_author_email, value);
> > +		author_ident_explicitly_given |= IDENT_MAIL_GIVEN;
> > +		ident_config_given |= IDENT_MAIL_GIVEN;
> > +		return 0;
> > +	}
> > +
> > +	if (!strcmp(var, "committer.name")) {
> > +		if (!value)
> > +			return config_error_nonbool(var);
> > +		strbuf_reset(&git_committer_name);
> > +		strbuf_addstr(&git_committer_name, value);
> > +		committer_ident_explicitly_given |= IDENT_NAME_GIVEN;
> > +		ident_config_given |= IDENT_NAME_GIVEN;
> > +		return 0;
> > +	}
> > +
> > +	if (!strcmp(var, "committer.email")) {
> > +		if (!value)
> > +			return config_error_nonbool(var);
> > +		strbuf_reset(&git_committer_email);
> > +		strbuf_addstr(&git_committer_email, value);
> > +		committer_ident_explicitly_given |= IDENT_MAIL_GIVEN;
> > +		ident_config_given |= IDENT_MAIL_GIVEN;
> > +		return 0;
> > +	}
> > +
> 
> This whole thing should be split into a static function. It's the same
> code copy/pasted 4x times just with a differnet value for "var", the
> strbuf variable & IDENT_*_GIVEN.

I have moved most of this into a separate function in the next version of the patch. However, I do not see a way to factor it down further. Let me know what you think when I resend.

Also, if you see anything longer than 79 characters, please let me know where the long lines are and I have no problem reformatting them.

Thanks much.
William
Previous: William HubbsNext: William Hubbs
Message 9 of 15 in “Add author and committer configuration settings”
  1. William HubbsJan 25, 2019
  2. 1/2 config: allow giving separate author and committer identsWilliam Hubbs, Jan 25, 2019
  3. Ævar Arnfjörð BjarmasonJan 25, 2019
  4. William HubbsJan 28, 2019
  5. Junio C HamanoJan 28, 2019
  6. Ævar Arnfjörð BjarmasonJan 28, 2019
  7. Junio C HamanoJan 28, 2019
  8. William HubbsJan 28, 2019
  9. William HubbsJan 29, 2019
  10. 2/2 tests: add test for separate author and committer identsWilliam Hubbs, Jan 25, 2019
  11. Ævar Arnfjörð BjarmasonJan 25, 2019
  12. William HubbsJan 26, 2019
  13. Ævar Arnfjörð BjarmasonJan 26, 2019
  14. Eric SunshineJan 27, 2019
  15. Ævar Arnfjörð BjarmasonJan 28, 2019

Read the whole thread, see it on lore, or plain text.

$ cat FOOTERMessages come from the public archive at lore.kernel.org/git, fetched every hour. The front page is chosen and written each morning by an AI editor and can be wrong; the threads themselves are the record. About and API. For agents: an MCP server at https://gitlist.dev/mcp, and any thread, story or person page as Markdown by adding .md to its URL (or sending Accept: text/markdown). Details in /llms.txt.