From b068be71a063e2290e85cfad3a1922ab96a98216 Mon Sep 17 00:00:00 2001 From: Aaryan Bansal Date: Wed, 11 Mar 2026 22:00:41 +0530 Subject: [PATCH 1/3] setup: suggest 'git init' when no repository is found When Git cannot find a .git directory, the error message now includes a helpful hint suggesting to run 'git init' to initialize a new repository. This helps new developers understand what to do when they encounter this common error. This follows the pattern established by the 'detected dubious ownership' error message which provides actionable guidance to users. --- setup.c | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/setup.c b/setup.c index 393b970ae4f96d..324a312ae8bff3 100644 --- a/setup.c +++ b/setup.c @@ -1881,14 +1881,16 @@ const char *setup_git_directory_gently(int *nongit_ok) break; case GIT_DIR_HIT_CEILING: if (!nongit_ok) - die(_("not a git repository (or any of the parent directories): %s"), + die(_("not a git repository (or any of the parent directories): %s\n" + "See also the 'git init' command for initializing a new repository."), DEFAULT_GIT_DIR_ENVIRONMENT); *nongit_ok = 1; break; case GIT_DIR_HIT_MOUNT_POINT: if (!nongit_ok) die(_("not a git repository (or any parent up to mount point %s)\n" - "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."), + "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n" + "See also the 'git init' command for initializing a new repository."), dir.buf); *nongit_ok = 1; break; From f4d984690a97f5f4636f8e642f7482e9851c8f30 Mon Sep 17 00:00:00 2001 From: Aaryan Bansal Date: Thu, 12 Mar 2026 12:23:40 +0530 Subject: [PATCH 2/3] Revert "setup: suggest 'git init' when no repository is found" This reverts commit b068be71a063e2290e85cfad3a1922ab96a98216. --- setup.c | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/setup.c b/setup.c index 324a312ae8bff3..393b970ae4f96d 100644 --- a/setup.c +++ b/setup.c @@ -1881,16 +1881,14 @@ const char *setup_git_directory_gently(int *nongit_ok) break; case GIT_DIR_HIT_CEILING: if (!nongit_ok) - die(_("not a git repository (or any of the parent directories): %s\n" - "See also the 'git init' command for initializing a new repository."), + die(_("not a git repository (or any of the parent directories): %s"), DEFAULT_GIT_DIR_ENVIRONMENT); *nongit_ok = 1; break; case GIT_DIR_HIT_MOUNT_POINT: if (!nongit_ok) die(_("not a git repository (or any parent up to mount point %s)\n" - "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set).\n" - "See also the 'git init' command for initializing a new repository."), + "Stopping at filesystem boundary (GIT_DISCOVERY_ACROSS_FILESYSTEM not set)."), dir.buf); *nongit_ok = 1; break; From ce2944042dd0a9b11363b2056c373949211f31a4 Mon Sep 17 00:00:00 2001 From: Aaryan Bansal Date: Thu, 12 Mar 2026 12:24:13 +0530 Subject: [PATCH 3/3] merge: respect overwrite_ignore config in trivial merges Fix the read_tree_trivial() function to properly respect the overwrite_ignore configuration. Previously, the code was hardcoding preserve_ignored=0, ignoring both the command-line option and config setting. Also fix a typo in a submodule.c comment (overwright -> overwrite). --- builtin/merge.c | 2 +- submodule.c | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/builtin/merge.c b/builtin/merge.c index 4e456a381c192d..aad6c083654362 100644 --- a/builtin/merge.c +++ b/builtin/merge.c @@ -755,7 +755,7 @@ static int read_tree_trivial(struct object_id *common, struct object_id *head, opts.verbose_update = 1; opts.trivial_merges_only = 1; opts.merge = 1; - opts.preserve_ignored = 0; /* FIXME: !overwrite_ignore */ + opts.preserve_ignored = !overwrite_ignore; trees[nr_trees] = repo_parse_tree_indirect(the_repository, common); if (!trees[nr_trees++]) return -1; diff --git a/submodule.c b/submodule.c index 4f9aaa2c75679b..b1a5ba494a84f0 100644 --- a/submodule.c +++ b/submodule.c @@ -2095,7 +2095,7 @@ static void submodule_reset_index(const char *path, const char *super_prefix) cp.no_stdin = 1; cp.dir = path; - /* TODO: determine if this might overwright untracked files */ + /* TODO: determine if this might overwrite untracked files */ strvec_pushl(&cp.args, "read-tree", "-u", "--reset", NULL); strvec_pushf(&cp.args, "--super-prefix=%s%s/", (super_prefix ? super_prefix : ""), path);