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

[PATCH v3 05/14] checkout: move 'confict_style' and 'dwim_..' to checkout_opts

From
Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
Date
Nov 29, 2018, 21:58 UTC
Message-ID
<20181129215850.7278-6-pclouds@gmail.com>
In-Reply-To
<20181129215850.7278-1-pclouds@gmail.com>

These local variables are referenced by struct option[]. This struct will soon be broken down, moved away and we can't rely on local variables anymore. Move these two to struct checkout_opts in preparation for that.

Signed-off-by: Nguyễn Thái Ngọc Duy <pclouds@gmail.com>
---
 builtin/checkout.c | 16 +++++++++-------
 1 file changed, 9 insertions(+), 7 deletions(-)
diff --git a/builtin/checkout.c b/builtin/checkout.c
index 1b19328d0a..2423fdbf94 100644
--- a/builtin/checkout.c
+++ b/builtin/checkout.c
@@ -44,6 +44,8 @@ struct checkout_opts {
 	int ignore_skipworktree;
 	int ignore_other_worktrees;
 	int show_progress;
+	int dwim_new_local_branch;
+
 	/*
 	 * If new checkout options are added, skip_merge_working_tree
 	 * should be updated accordingly.
@@ -55,6 +57,7 @@ struct checkout_opts {
 	int new_branch_log;
 	enum branch_track track;
 	struct diff_options diff_options;
+	char *conflict_style;
 
 	int branch_exists;
 	const char *prefix;
@@ -1239,8 +1242,6 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	struct checkout_opts real_opts;
 	struct checkout_opts *opts = &real_opts;
 	struct branch_info new_branch_info;
-	char *conflict_style = NULL;
-	int dwim_new_local_branch = 1;
 	int dwim_remotes_matched = 0;
 	struct option options[] = {
 		OPT__QUIET(&opts->quiet, N_("suppress progress reporting")),
@@ -1265,12 +1266,12 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 		OPT_BOOL_F(0, "overwrite-ignore", &opts->overwrite_ignore,
 			   N_("update ignored files (default)"),
 			   PARSE_OPT_NOCOMPLETE),
-		OPT_STRING(0, "conflict", &conflict_style, N_("style"),
+		OPT_STRING(0, "conflict", &opts->conflict_style, N_("style"),
 			   N_("conflict style (merge or diff3)")),
 		OPT_BOOL('p', "patch", &opts->patch_mode, N_("select hunks interactively")),
 		OPT_BOOL(0, "ignore-skip-worktree-bits", &opts->ignore_skipworktree,
 			 N_("do not limit pathspecs to sparse entries only")),
-		OPT_HIDDEN_BOOL(0, "guess", &dwim_new_local_branch,
+		OPT_HIDDEN_BOOL(0, "guess", &opts->dwim_new_local_branch,
 				N_("second guess 'git checkout <no-such-branch>'")),
 		OPT_BOOL(0, "ignore-other-worktrees", &opts->ignore_other_worktrees,
 			 N_("do not check if another worktree is holding the given ref")),
@@ -1286,6 +1287,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 	opts->overwrite_ignore = 1;
 	opts->prefix = prefix;
 	opts->show_progress = -1;
+	opts->dwim_new_local_branch = 1;
 
 	git_config(git_checkout_config, opts);
 
@@ -1301,9 +1303,9 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 			opts->show_progress = isatty(2);
 	}
 
-	if (conflict_style) {
+	if (opts->conflict_style) {
 		opts->merge = 1; /* implied */
-		git_xmerge_config("merge.conflictstyle", conflict_style, NULL);
+		git_xmerge_config("merge.conflictstyle", opts->conflict_style, NULL);
 	}
 
 	if ((!!opts->new_branch + !!opts->new_branch_force + !!opts->new_orphan_branch) > 1)
@@ -1350,7 +1352,7 @@ int cmd_checkout(int argc, const char **argv, const char *prefix)
 		struct object_id rev;
 		int dwim_ok =
 			!opts->patch_mode &&
-			dwim_new_local_branch &&
+			opts->dwim_new_local_branch &&
 			opts->track == BRANCH_TRACK_UNSPECIFIED &&
 			!opts->new_branch;
 		int n = parse_branchname_arg(argc, argv, dwim_ok,
-- 
2.20.0.rc1.380.g3eb999425c.dirty
Previous: Nguyễn Thái Ngọc DuyNext: Nguyễn Thái Ngọc Duy
Message 57 of 110 in “checkout: print something when checking out paths”
  1. checkout: print something when checking out pathsNguyễn Thái Ngọc Duy, Nov 10, 2018
  2. Junio C HamanoNov 12, 2018
  3. Duy NguyenNov 12, 2018
  4. Junio C HamanoNov 12, 2018
  5. Ævar Arnfjörð BjarmasonNov 19, 2018
  6. Duy NguyenNov 19, 2018
  7. Junio C HamanoNov 20, 2018
  8. [RFC] Introduce two new commands, switch-branch and restore-pathsDuy Nguyen, Nov 20, 2018
  9. Thomas GummererNov 25, 2018
  10. Junio C HamanoNov 26, 2018
  11. Duy NguyenNov 26, 2018
  12. Ævar Arnfjörð BjarmasonNov 26, 2018
  13. Duy NguyenNov 26, 2018
  14. Stefan BellerNov 26, 2018
  15. Junio C HamanoNov 27, 2018
  16. 0/7 Introduce new commands switch-branch and checkout-filesNguyễn Thái Ngọc Duy, Nov 27, 2018
  17. 1/7 parse-options: allow parse_options_concat(NULL, options)Nguyễn Thái Ngọc Duy, Nov 27, 2018
  18. Stefan BellerNov 27, 2018
  19. Duy NguyenNov 28, 2018
  20. Junio C HamanoNov 28, 2018
  21. 2/7 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Nov 27, 2018
  22. 5/7 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Nov 27, 2018
  23. Junio C HamanoNov 29, 2018
  24. 6/7 checkout: split into switch-branch and checkout-filesNguyễn Thái Ngọc Duy, Nov 27, 2018
  25. Junio C HamanoNov 28, 2018
  26. Duy NguyenNov 28, 2018
  27. Stefan BellerNov 28, 2018
  28. Duy NguyenNov 28, 2018
  29. Junio C HamanoNov 29, 2018
  30. Stefan XenosNov 28, 2018
  31. Stefan XenosNov 28, 2018
  32. Stefan XenosNov 28, 2018
  33. Junio C HamanoNov 29, 2018
  34. Duy NguyenNov 29, 2018
  35. Duy NguyenNov 29, 2018
  36. Stefan BellerNov 29, 2018
  37. Duy NguyenNov 29, 2018
  38. Stefan XenosNov 29, 2018
  39. 4/7 checkout: move dwim_new_local_branch to checkout_optsNguyễn Thái Ngọc Duy, Nov 27, 2018
  40. Stefan BellerNov 27, 2018
  41. 7/7 Suggest other commands instead of "git checkout"Nguyễn Thái Ngọc Duy, Nov 27, 2018
  42. Junio C HamanoNov 28, 2018
  43. Duy NguyenNov 28, 2018
  44. Junio C HamanoNov 29, 2018
  45. 3/7 checkout: move 'confict_style' to checkout_optsNguyễn Thái Ngọc Duy, Nov 27, 2018
  46. Stefan BellerNov 27, 2018
  47. Duy NguyenNov 28, 2018
  48. Duy NguyenNov 28, 2018
  49. Stefan BellerNov 28, 2018
  50. Duy NguyenNov 29, 2018
  51. Stefan BellerDec 3, 2018
  52. Junio C HamanoNov 30, 2018
  53. 00/14 Introduce new commands switch-branch and restore-filesNguyễn Thái Ngọc Duy, Nov 29, 2018
  54. 01/14 git-checkout.txt: fix one syntax lineNguyễn Thái Ngọc Duy, Nov 29, 2018
  55. 03/14 checkout: factor out some code in parse_branchname_arg()Nguyễn Thái Ngọc Duy, Nov 29, 2018
  56. 04/14 checkout: make "opts" in cmd_checkout() a pointerNguyễn Thái Ngọc Duy, Nov 29, 2018
  57. 05/14 checkout: move 'confict_style' and 'dwim_..' to checkout_optsNguyễn Thái Ngọc Duy, Nov 29, 2018
  58. 06/14 checkout: split options[] array in three piecesNguyễn Thái Ngọc Duy, Nov 29, 2018
  59. 08/14 switch-branch: better names for -b and -BNguyễn Thái Ngọc Duy, Nov 29, 2018
  60. 09/14 switch-branch: stop accepting pathspecNguyễn Thái Ngọc Duy, Nov 29, 2018
  61. 10/14 switch-branch: reject "do nothing" caseNguyễn Thái Ngọc Duy, Nov 29, 2018
  62. 11/14 switch-branch: only allow explicit detached HEADNguyễn Thái Ngọc Duy, Nov 29, 2018
  63. Eckhard MaaßMar 10, 2019
  64. Duy NguyenMar 11, 2019
  65. 12/14 restore-files: take tree-ish from --from option insteadNguyễn Thái Ngọc Duy, Nov 29, 2018
  66. 13/14 restore-files: make pathspec mandatoryNguyễn Thái Ngọc Duy, Nov 29, 2018
  67. 14/14 doc: promote "git switch-branch" and "git restore-files"Nguyễn Thái Ngọc Duy, Nov 29, 2018
  68. 07/14 checkout: split into switch-branch and restore-filesNguyễn Thái Ngọc Duy, Nov 29, 2018
  69. Elijah NewrenDec 4, 2018
  70. Junio C HamanoDec 4, 2018
  71. Duy NguyenDec 4, 2018
  72. Elijah NewrenDec 4, 2018
  73. Duy NguyenDec 4, 2018
  74. Junio C HamanoDec 5, 2018
  75. Elijah NewrenDec 5, 2018
  76. Junio C HamanoDec 5, 2018
  77. Junio C HamanoDec 5, 2018
  78. Elijah NewrenDec 5, 2018
  79. 02/14 git-checkout.txt: split detached head section outNguyễn Thái Ngọc Duy, Nov 29, 2018
  80. Ævar Arnfjörð BjarmasonNov 29, 2018
  81. Ævar Arnfjörð BjarmasonNov 29, 2018
  82. Dan FabulichNov 29, 2018
  83. Dan FabulichNov 30, 2018
  84. Duy NguyenNov 30, 2018
  85. Duy NguyenNov 30, 2018
  86. Junio C HamanoNov 30, 2018
  87. Ævar Arnfjörð BjarmasonNov 30, 2018
  88. Duy NguyenNov 30, 2018
  89. Junio C HamanoNov 30, 2018
  90. Duy NguyenNov 30, 2018
  91. Junio C HamanoNov 30, 2018
  92. Thomas GummererDec 2, 2018
  93. Junio C HamanoDec 2, 2018
  94. Elijah NewrenDec 4, 2018
  95. Duy NguyenDec 4, 2018
  96. Elijah NewrenDec 4, 2018
  97. Duy NguyenDec 4, 2018
  98. Elijah NewrenDec 4, 2018
  99. Duy NguyenDec 4, 2018
  100. Eric SunshineDec 4, 2018
  101. checkout: print something when checking out pathsNguyễn Thái Ngọc Duy, Nov 13, 2018
  102. Junio C HamanoNov 14, 2018
  103. Duy NguyenNov 14, 2018
  104. Junio C HamanoJan 28, 2019
  105. Duy NguyenJan 29, 2019
  106. 0/2 nd/checkout-noisy updatesNguyễn Thái Ngọc Duy, Feb 6, 2019
  107. 1/2 checkout: update count-checkouts messagesNguyễn Thái Ngọc Duy, Feb 6, 2019
  108. 2/2 checkout: count and print -m paths separatelyNguyễn Thái Ngọc Duy, Feb 6, 2019
  109. Stefan XenosNov 28, 2018
  110. Junio C HamanoNov 29, 2018

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.