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

Re: [PATCH 5/6] builtin-commit.c: further refactor branch switching

From
Linus Torvalds <torvalds@linux-foundation.org>
Date
Dec 6, 2008, 02:08 UTC
Message-ID
<alpine.LFD.2.00.0812051802570.3425@nehalem.linux-foundation.org>
In-Reply-To
<1228528455-3089-6-git-send-email-gitster@pobox.com>
The whole series looks good, I think.
But one thing I reacted to is exemplified best by this one:
On Fri, 5 Dec 2008, Junio C Hamano wrote:
>
> +int reset_index_and_worktree(int force, int merge, int quiet, int *wt_error,
> +			     struct commit *old_commit, const char *old_label,
> +			     struct commit *new_commit, const char *new_label)
This takes three flags (force, merge, quiet) as three parameters.

And in the series, 3/6 and 4/6 had other cases where the same flags (just not _all_ of them) were passed around to other functions. In 4/6, you had "switch_trees()" taking "int merge, int quiet", and in 3/6 you had "reset_tree()" taking "int quiet" and also have a "int worktree" flag.

I think it would be really nice to have a unified namespace for these flags. There are lots of commonalities between "checkout" and "reset" (and certainly differences too), wouldn't it be nice to have something like

	#define CO_FORCE 0x001
	#define CO_MERGE 0x002
	#define CO_QUIET 0x004
	#define CO_WORKTREE 0x008
and just pass in a single "unsigned int checkout_flags" as an argument?
Having eight parameters is obscene.
		Linus
Previous: Junio C Hamano
Message 8 of 8 in “Reusing "checkout [-m]" logic for "reset --merge"”
  1. 0/6 Reusing "checkout [-m]" logic for "reset --merge"Junio C Hamano, Dec 6, 2008
  2. 1/6 builtin-checkout.c: check error return from read_cache()Junio C Hamano, Dec 6, 2008
  3. 2/6 read-cache.c: typofix in commentJunio C Hamano, Dec 6, 2008
  4. 3/6 Make reset_tree() in builtin-checkout.c a bit more library-ishJunio C Hamano, Dec 6, 2008
  5. 4/6 builtin-checkout.c: refactor merge_working_tree()Junio C Hamano, Dec 6, 2008
  6. 5/6 builtin-commit.c: further refactor branch switchingJunio C Hamano, Dec 6, 2008
  7. 6/6 builtin-reset.c: use reset_index_and_worktree()Junio C Hamano, Dec 6, 2008
  8. Linus TorvaldsDec 6, 2008

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.