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

[PATCH 1/2] tests: add test case for autocorrect in work tree for bare clone

From
Simon Gerber via GitGitGadget <gitgitgadget@gmail.com>
Date
Oct 28, 2022, 15:24 UTC
Message-ID
<d0a6eea93b58f5a267352690adde00a5b0f3f089.1666970645.git.gitgitgadget@gmail.com>
In-Reply-To
<pull.1373.git.git.1666970645.gitgitgadget@gmail.com>
From: Simon Gerber <gesimu@gmail.com>

Currently, auto correction doesn't work reliably for commands which must run in a work tree (e.g. `git status`) in Git work trees which are created from a bare repository.

This commit adds a test which shows the broken autocompletion by calling `git stauts` which gets autocorrected to `git status`. This works fine in a work tree created with `git worktree add` from a regular clone, but doesn't work in a work tree created with `git worktree add` from a bare clone.

Signed-off-by: Simon Gerber <gesimu@gmail.com>
---
 t/t9005-help-autocorrect-worktree.sh | 29 ++++++++++++++++++++++++++++
 1 file changed, 29 insertions(+)
 create mode 100755 t/t9005-help-autocorrect-worktree.sh
diff --git a/t/t9005-help-autocorrect-worktree.sh b/t/t9005-help-autocorrect-worktree.sh
new file mode 100755
index 00000000000..4fecc8a8e01
--- /dev/null
+++ b/t/t9005-help-autocorrect-worktree.sh
@@ -0,0 +1,29 @@
+#!/bin/sh
+
+test_description='test autocorrect in work tree based on bare repository'
+. ./test-lib.sh
+
+test_expect_success 'setup non-bare' '
+	echo one >file &&
+	git add file &&
+	git commit -m one &&
+	echo two >file &&
+	git commit -a -m two
+'
+
+test_expect_success 'setup bare' '
+	git clone --bare . bare.git &&
+	cd bare.git
+'
+
+test_expect_success 'setup worktree from bare' '
+	git worktree add ../bare-wt &&
+	cd ../bare-wt
+'
+
+test_expect_success 'autocorrect works in work tree created from bare repo' '
+	git config help.autocorrect immediate &&
+	git stauts
+'
+
+test_done
-- 
gitgitgadget
Previous: Simon Gerber via GitGitGadgetNext: Junio C Hamano
Message 3 of 9 in “Fix autocorrect in work tree for bare repository”
  1. 0/2 Fix autocorrect in work tree for bare repositorySimon Gerber via GitGitGadget, Oct 28, 2022
  2. 2/2 help.c: don't call git_default_config in git_unknown_cmd_configSimon Gerber via GitGitGadget, Oct 28, 2022
  3. 1/2 tests: add test case for autocorrect in work tree for bare cloneSimon Gerber via GitGitGadget, Oct 28, 2022
  4. Junio C HamanoOct 28, 2022
  5. Simon GerberOct 29, 2022
  6. help.c: fix autocorrect in work tree for bare repositorySimon Gerber via GitGitGadget, Oct 29, 2022
  7. Simon GerberDec 12, 2022
  8. Junio C HamanoDec 13, 2022
  9. Simon GerberDec 13, 2022

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.