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

[PATCH v3 0/3] scalar: two downstream improvements

From
Derrick Stolee via GitGitGadget <gitgitgadget@gmail.com>
Date
Aug 28, 2023, 13:52 UTC
Message-ID
<pull.1569.v3.git.1693230746.gitgitgadget@gmail.com>
In-Reply-To
<pull.1569.v2.git.1692725056.gitgitgadget@gmail.com>

While updating git-for-windows/git and microsoft/git for the 2.42.0 release window, a few patches that we've been running in those forks for a while came to light as something that would be beneficial to the core Git project. Here are some that are focused on the 'scalar' command.

 * Patch 1 adds a --no-src option to scalar clone to appease users who want
   to use scalar but object to the creation of the src directory.
 * Patches 2 and 3 help when scalar reconfigure -a fails. Patch 2 is a
   possibly helpful change on its own for other uses in the future.

Updates in V3 =============

 * Several commit message edits.
 * An important case that was dropped in v2's patch 2 is reintroduced (even
   though it is modified in patch 3).
 * An error message is added for corrupt Git repositories.

Updates in V2 =============

Thanks, Junio, for the helpful review!
 * In Patch 1, the '--[no-]src' documentation is tightened and the tests
   check the contents of the repository worktree.
 * In Patch 2, the commit message is reworded to be more clear about
   positive values of the enum.
 * In Patch 2, the GIT_DIR_NONE option of the enum is never returned, so it
   does not need to exist. A case in scalar.c referenced it, so it is
   removed as part of the patch (though that case was removed later by patch
   3 anyway).
 * In Patch 2, the discover_git_directory() wrapper is updated to return -1
   instead of 1, as it did before this patch.
 * In Patch 3, the 'failed' variable is renamed to 'succeeded' and the cases
   that update the value are swapped. The return code is set to -1 for any
   error instead of having a custom value based on the return from error()
   or error_errno().
Thanks, -Stolee
Derrick Stolee (3):
  scalar: add --[no-]src option
  setup: add discover_git_directory_reason()
  scalar reconfigure: help users remove buggy repos
 Documentation/scalar.txt |  8 ++++-
 scalar.c                 | 70 +++++++++++++++++++++++++++++-----------
 setup.c                  | 34 +++++++------------
 setup.h                  | 35 ++++++++++++++++++--
 t/t9211-scalar-clone.sh  | 12 +++++++
 5 files changed, 115 insertions(+), 44 deletions(-)
base-commit: a82fb66fed250e16d3010c75404503bea3f0ab61
Published-As: https://github.com/gitgitgadget/git/releases/tag/pr-1569%2Fderrickstolee%2Fscalar-no-src-v3
Fetch-It-Via: git fetch https://github.com/gitgitgadget/git pr-1569/derrickstolee/scalar-no-src-v3
Pull-Request: https://github.com/gitgitgadget/git/pull/1569
Range-diff vs v2:
 1:  0b6957beccb ! 1:  e9858b31db6 scalar: add --[no-]src option
     @@ Commit message
          scalar: add --[no-]src option
      
          Some users have strong aversions to Scalar's opinion that the repository
     -    should be in a 'src' directory, even though it creates a clean slate for
     -    placing build outputs in adjacent directories.
     +    should be in a 'src' directory, even though this creates a clean slate
     +    for placing build artifacts in adjacent directories.
      
     -    The --no-src option allows users to opt-out of the default behavior.
     +    The new --no-src option allows users to opt out of the default behavior.
      
          While adding options, make sure the usage output by 'scalar clone -h'
          reports the same as the SYNOPSIS line in Documentation/scalar.txt.
 2:  787af0f9744 ! 2:  3c16fa6897f setup: add discover_git_directory_reason()
     @@ Commit message
      
          Callers attempting to set up a Git directory may want to inform the user
          about the reason for the failure. For that, expose the enum
     -    discovery_result from within setup.c and into cache.h where
     +    discovery_result from within setup.c and move it into cache.h where
          discover_git_directory() is defined.
      
          I initially wanted to change the return type of discover_git_directory()
     @@ Commit message
          It is worth noting that GIT_DIR_NONE is not returned, so we remove this
          option from the enum. We must be careful to keep the successful reasons
          as positive values, so they are given explicit positive values.
     -    Further, a use in scalar.c was previously impossible, so it is removed.
      
          Instead of updating all callers immediately, add a new method,
          discover_git_directory_reason(), and convert discover_git_directory() to
     @@ Commit message
      
          Signed-off-by: Derrick Stolee <derrickstolee@github.com>
      
     - ## scalar.c ##
     -@@ scalar.c: static int cmd_reconfigure(int argc, const char **argv)
     - 				warning(_("removing stale scalar.repo '%s'"),
     - 					dir);
     - 			strbuf_release(&buf);
     --		} else if (discover_git_directory(&commondir, &gitdir) < 0) {
     --			warning_errno(_("git repository gone in '%s'"), dir);
     --			res = -1;
     - 		} else {
     - 			git_config_clear();
     - 
     -
       ## setup.c ##
      @@ setup.c: static const char *allowed_bare_repo_to_string(
       	return NULL;
 3:  7ac7311863d ! 3:  ac234b15755 scalar reconfigure: help users remove buggy repos
     @@ scalar.c: static int cmd_reconfigure(int argc, const char **argv)
      +				succeeded = 1;
      +			}
       			strbuf_release(&buf);
     +-		} else if (discover_git_directory(&commondir, &gitdir) < 0) {
     +-			warning_errno(_("git repository gone in '%s'"), dir);
     +-			res = -1;
      -		} else {
      -			git_config_clear();
      +			goto loop_end;
     @@ scalar.c: static int cmd_reconfigure(int argc, const char **argv)
      +			warning(_("repository at '%s' has different owner"), dir);
      +			goto loop_end;
      +
     ++		case GIT_DIR_INVALID_GITFILE:
     ++		case GIT_DIR_INVALID_FORMAT:
     ++			warning(_("repository at '%s' has a format issue"), dir);
     ++			goto loop_end;
     ++
      +		case GIT_DIR_DISCOVERED:
      +			succeeded = 1;
      +			break;
     @@ scalar.c: static int cmd_reconfigure(int argc, const char **argv)
      +			warning(_("repository not found in '%s'"), dir);
      +			break;
      +		}
     -+
     -+		git_config_clear();
     -+
     -+		the_repository = &r;
     -+		r.commondir = commondir.buf;
     -+		r.gitdir = gitdir.buf;
       
      -			the_repository = &r;
      -			r.commondir = commondir.buf;
      -			r.gitdir = gitdir.buf;
     -+		if (set_recommended_config(1) >= 0)
     -+			succeeded = 1;
     ++		git_config_clear();
       
      -			if (set_recommended_config(1) < 0)
      -				res = -1;
     ++		the_repository = &r;
     ++		r.commondir = commondir.buf;
     ++		r.gitdir = gitdir.buf;
     ++
     ++		if (set_recommended_config(1) >= 0)
     ++			succeeded = 1;
     ++
      +loop_end:
      +		if (!succeeded) {
      +			res = -1;
-- 
gitgitgadget
Previous: Oswald BuddenhagenNext: Derrick Stolee via GitGitGadget
Message 21 of 25 in “scalar: two downstream improvements”
  1. 0/3 scalar: two downstream improvementsDerrick Stolee via GitGitGadget, Aug 14, 2023
  2. 1/3 scalar: add --[no-]src optionDerrick Stolee via GitGitGadget, Aug 14, 2023
  3. Junio C HamanoAug 14, 2023
  4. Derrick StoleeAug 14, 2023
  5. 3/3 scalar reconfigure: help users remove buggy reposDerrick Stolee via GitGitGadget, Aug 14, 2023
  6. Junio C HamanoAug 14, 2023
  7. 2/3 setup: add discover_git_directory_reason()Derrick Stolee via GitGitGadget, Aug 14, 2023
  8. Junio C HamanoAug 14, 2023
  9. Junio C HamanoAug 14, 2023
  10. 0/3 scalar: two downstream improvementsDerrick Stolee via GitGitGadget, Aug 22, 2023
  11. 1/3 scalar: add --[no-]src optionDerrick Stolee via GitGitGadget, Aug 22, 2023
  12. Oswald BuddenhagenAug 23, 2023
  13. 3/3 scalar reconfigure: help users remove buggy reposDerrick Stolee via GitGitGadget, Aug 22, 2023
  14. Junio C HamanoAug 22, 2023
  15. Derrick StoleeAug 25, 2023
  16. Junio C HamanoAug 25, 2023
  17. 2/3 setup: add discover_git_directory_reason()Derrick Stolee via GitGitGadget, Aug 22, 2023
  18. Junio C HamanoAug 22, 2023
  19. Derrick StoleeAug 22, 2023
  20. Oswald BuddenhagenAug 23, 2023
  21. 0/3 scalar: two downstream improvementsDerrick Stolee via GitGitGadget, Aug 28, 2023
  22. 1/3 scalar: add --[no-]src optionDerrick Stolee via GitGitGadget, Aug 28, 2023
  23. 3/3 scalar reconfigure: help users remove buggy reposDerrick Stolee via GitGitGadget, Aug 28, 2023
  24. 2/3 setup: add discover_git_directory_reason()Derrick Stolee via GitGitGadget, Aug 28, 2023
  25. Junio C HamanoAug 28, 2023

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.