Skip to content

Rebase shears/seen: 6 conflict(s) (1 skipped, 5 resolved) (#39023444532) - #535

Open
gitforwindowshelper[bot] wants to merge 324 commits into
base/shears/seen-39023444532from
shears/seen-39023444532
Open

gitforwindowshelper[bot] wants to merge 324 commits into
base/shears/seen-39023444532from
shears/seen-39023444532

Conversation

@gitforwindowshelper

Copy link
Copy Markdown

Workflow run

Rebase Summary: seen

From: 6b9d27973b (Backport fix for now-flaky HTTP-auth tests (git-for-windows#6489), 2026-10-16) (f9d493ee07..6b9d27973b)

Resolved: 11eb79f (repo: split annotated tags out from total tag count in structure, 2026-06-05)

preserved annotated-tag counting while adapting initialization to upstream's removal of add_to_pending

Range-diff
  • 1: 11eb79f ! 1: 8dfc23a repo: split annotated tags out from total tag count in structure

    @@ builtin/repo.c: static void structure_keyvalue_print(struct repo_structure *stat
      	struct rev_info *revs;
     +	struct repository *repo;
      	struct progress *progress;
    - 	bool add_to_pending;
      };
    + 
     @@ builtin/repo.c: static int count_references(const struct reference *ref, void *cb_data)
      		break;
      	case FILTER_REFS_TAGS:
    @@ builtin/repo.c: static void structure_count_references(struct ref_stats *stats,
      	struct count_references_data data = {
      		.stats = stats,
      		.revs = revs,
    --		.add_to_pending = add_to_pending
     +		.repo = repo,
    -+		.add_to_pending = add_to_pending,
      	};
      
      	if (show_progress)

Skipped: 98fb28a (repo: filter the structure scope via --ref-filter=, 2026-06-06)

Upstream equivalent: 83b910b (survey: add command line opts to select references, 2024-04-29)

Range-diff
  • 1: 98fb28a ! 1: 83b910b repo: filter the structure scope via --ref-filter=

    @@
      ## Metadata ##
    -Author: Johannes Schindelin <Johannes.Schindelin@gmx.de>
    +Author: Jeff Hostetler <git@jeffhostetler.com>
     
      ## Commit message ##
    -    repo: filter the structure scope via --ref-filter=<pattern>
    +    survey: add command line opts to select references
     
    -    `git repo structure` walks every reference enumerated by
    -    `refs_for_each_ref()` and feeds each reference's tip into the path
    -    walk that produces the object counts. There is no way to scope the
    -    inquiry to a subset of refs, even though that is the most common
    -    need when an operator is investigating what part of the history is
    -    driving cost: only branches, only release tags, only one remote's
    -    view, etc.
    +    By default we will scan all references in "refs/heads/", "refs/tags/"
    +    and "refs/remotes/".
     
    -    Add a single `--ref-filter=<pattern>` option that, when given,
    -    restricts both the reference count and the object walk to refs whose
    -    full name matches one of the patterns. The option is repeatable;
    -    multiple patterns form a union, so `--ref-filter='refs/heads/*'
    -    --ref-filter='refs/tags/v*'` includes local branches and tags whose
    -    short name starts with `v`. Patterns use `wildmatch()` with
    -    `WM_PATHNAME` semantics so a `*` does not cross `/`, matching the
    -    convention used by `git for-each-ref` positional arguments.
    +    Add command line opts let the use ask for all refs or a subset of them
    +    and to include a detached HEAD.
     
    -    Choosing a single flexible filter, rather than a proliferation of
    -    per-kind flags like `--branches`, `--tags`, `--remotes`, keeps the
    -    option surface small and lets the same mechanism express
    -    narrow selections the per-kind flags could not, such as "only release
    -    tags" (`'refs/tags/v*'`) or "only one remote's branches"
    -    (`'refs/remotes/origin/*'`). Without `--ref-filter`, behaviour is
    -    unchanged: every ref `refs_for_each_ref()` enumerates contributes.
    +    Signed-off-by: Jeff Hostetler <git@jeffhostetler.com>
    +    Signed-off-by: Derrick Stolee <stolee@gmail.com>
    +    Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
     
    -    Both the reference counter and the path-walk seeding (via
    -    `add_pending_oid()`) sit on the same callback, so an early return
    -    when no pattern matches naturally excludes a ref from both. No
    -    separate object-walk machinery is needed.
    -
    -    Cover the two interesting code paths with tests in t1901: a single
    -    filter narrowing to branches, and two filters unioning to include
    -    both branches and tags.
    -
    -    Assisted-by: Opus 4.7
    -    Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
    -
    - ## Documentation/git-repo.adoc ##
    -@@ Documentation/git-repo.adoc: SYNOPSIS
    - [synopsis]
    - git repo info [--format=(lines|nul) | -z] [--all | <key>...]
    - git repo info --keys [--format=(lines|nul) | -z]
    --git repo structure [--format=(table|lines|nul) | -z] [<revs>...]
    -+git repo structure [<options>] [<revs>...]
    + ## Documentation/git-survey.adoc ##
    +@@ Documentation/git-survey.adoc: As repositories grow to "monorepo" size, certain data shapes can cause
    + performance problems.  `git-survey` attempts to measure and report on
    + known problem areas.
      
    - DESCRIPTION
    - -----------
    -@@ Documentation/git-repo.adoc: supported:
    - `nul`:::
    - 	Similar to `lines`, but using a _NUL_ character after each value.
    ++Ref Selection and Reachable Objects
    ++~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    ++
    ++In this first analysis phase, `git survey` will iterate over the set of
    ++requested branches, tags, and other refs and treewalk over all of the
    ++reachable commits, trees, and blobs and generate various statistics.
    ++
    + OPTIONS
    + -------
    + 
    + --progress::
    + 	Show progress.  This is automatically enabled when interactive.
    + 
    ++Ref Selection
    ++~~~~~~~~~~~~~
    ++
    ++The following options control the set of refs that `git survey` will examine.
    ++By default, `git survey` will look at tags, local branches, and remote refs.
    ++If any of the following options are given, the default set is cleared and
    ++only refs for the given options are added.
    ++
    ++--all-refs::
    ++	Use all refs.  This includes local branches, tags, remote refs,
    ++	notes, and stashes.  This option overrides all of the following.
    ++
    ++--branches::
    ++	Add local branches (`refs/heads/`) to the set.
    ++
    ++--tags::
    ++	Add tags (`refs/tags/`) to the set.
    ++
    ++--remotes::
    ++	Add remote branches (`refs/remote/`) to the set.
    ++
    ++--detached::
    ++	Add HEAD to the set.
    ++
    ++--other::
    ++	Add notes (`refs/notes/`) and stashes (`refs/stash/`) to the set.
    ++
    + OUTPUT
    + ------
      
    --`structure [--format=(table|lines|nul) | -z] [<revs>...]`::
    -+`structure [<options>] [<revs>...]`::
    - 	Retrieve statistics about the current repository structure. The
    - 	following kinds of information are reported:
    - +
    -@@ Documentation/git-repo.adoc: of revisions to select which objects will be counted. These parameters
    - follow the same syntax as the parameters to similar commands like
    - `git log`. Defaults to all objects reachable from a reference.
    - +
    -+By default every reference enumerated by `for-each-ref` contributes to
    -+the reference counts and, when no revisions are given, the object walk.
    -+Use `--ref-filter` to narrow the scope.
    -+
    -+	`--ref-filter=<pattern>`;;
    -+		Only count references whose full name matches one of the
    -+		given <pattern>s. When no revisions are given, only seed
    -+		the object walk from those references. The option is
    -+		repeatable; multiple patterns form a union. Patterns use
    -+		the same `wildmatch` semantics as `git for-each-ref`'s
    -+		positional arguments, so `*` does not cross `/`. Examples:
    -+		`--ref-filter='refs/heads/*'` for local branches,
    -+		`--ref-filter='refs/tags/v*'` for release tags,
    -+		`--ref-filter='refs/remotes/origin/*'` for a single
    -+		remote's branches.
    -++
    - The output format can be chosen through the flag `--format`. Three formats are
    - supported:
    - +
     
    - ## builtin/repo.c ##
    + ## builtin/survey.c ##
     @@
    - #include "tree.h"
    - #include "tree-walk.h"
    - #include "utf8.h"
    -+#include "wildmatch.h"
    + #include "builtin.h"
    + #include "config.h"
    + #include "environment.h"
    ++#include "object.h"
    ++#include "odb.h"
    + #include "parse-options.h"
    ++#include "progress.h"
    ++#include "ref-filter.h"
    ++#include "strvec.h"
    ++#include "trace2.h"
    + 
    + static const char * const survey_usage[] = {
    + 	N_("(EXPERIMENTAL!) git survey <options>"),
    + 	NULL,
    + };
      
    - #define REPO_INFO_USAGE \
    - 	"git repo info [--format=(lines|nul) | -z] [--all | <key>...]", \
    - 	"git repo info --keys [--format=(lines|nul) | -z]"
    ++struct survey_refs_wanted {
    ++	int want_all_refs; /* special override */
    ++
    ++	int want_branches;
    ++	int want_tags;
    ++	int want_remotes;
    ++	int want_detached;
    ++	int want_other; /* see FILTER_REFS_OTHERS -- refs/notes/, refs/stash/ */
    ++};
    ++
    ++static struct survey_refs_wanted default_ref_options = {
    ++	.want_all_refs = 1,
    ++};
    ++
    + struct survey_opts {
    + 	int verbose;
    + 	int show_progress;
    ++	struct survey_refs_wanted refs;
    ++};
    ++
    ++struct survey_report_ref_summary {
    ++	size_t refs_nr;
    ++	size_t branches_nr;
    ++	size_t remote_refs_nr;
    ++	size_t tags_nr;
    ++	size_t tags_annotated_nr;
    ++	size_t others_nr;
    ++	size_t unknown_nr;
    ++};
    ++
    ++/**
    ++ * This struct contains all of the information that needs to be printed
    ++ * at the end of the exploration of the repository and its references.
    ++ */
    ++struct survey_report {
    ++	struct survey_report_ref_summary refs;
    + };
      
    - #define REPO_STRUCTURE_USAGE \
    --	"git repo structure [--format=(table|lines|nul) | -z] [<revs>...]"
    -+	"git repo structure [<options>] [<revs>...]"
    + struct survey_context {
    +@@ builtin/survey.c: struct survey_context {
      
    - static const char *const repo_usage[] = {
    - 	REPO_INFO_USAGE,
    -@@ builtin/repo.c: struct count_references_data {
    - 	struct ref_stats *stats;
    - 	struct rev_info *revs;
    - 	struct repository *repo;
    -+	const struct string_list *filters;
    - 	struct progress *progress;
    - 	bool add_to_pending;
    + 	/* Options that control what is done. */
    + 	struct survey_opts opts;
    ++
    ++	/* Info for output only. */
    ++	struct survey_report report;
    ++
    ++	/*
    ++	 * The rest of the members are about enabling the activity
    ++	 * of the 'git survey' command, including ref listings, object
    ++	 * pointers, and progress.
    ++	 */
    ++
    ++	struct progress *progress;
    ++	size_t progress_nr;
    ++	size_t progress_total;
    ++
    ++	struct strvec refs;
      };
      
    -+static int ref_matches_any_filter(const char *refname,
    -+				  const struct string_list *filters)
    ++static void clear_survey_context(struct survey_context *ctx)
     +{
    -+	if (!filters->nr)
    -+		return 1;
    -+	for (size_t i = 0, namelen = strlen(refname); i < filters->nr; i++) {
    -+		const char *p = filters->items[i].string;
    -+		size_t plen = strlen(p);
    -+		if (plen <= namelen &&
    -+		    !strncmp(refname, p, plen) &&
    -+		    (refname[plen] == '\0' || refname[plen] == '/' ||
    -+		     (plen && p[plen - 1] == '/')))
    -+			return 1;
    -+		if (!wildmatch(p, refname, WM_PATHNAME))
    -+			return 1;
    ++	strvec_clear(&ctx->refs);
    ++}
    ++
    ++/*
    ++ * After parsing the command line arguments, figure out which refs we
    ++ * should scan.
    ++ *
    ++ * If ANY were given in positive sense, then we ONLY include them and
    ++ * do not use the builtin values.
    ++ */
    ++static void fixup_refs_wanted(struct survey_context *ctx)
    ++{
    ++	struct survey_refs_wanted *rw = &ctx->opts.refs;
    ++
    ++	/*
    ++	 * `--all-refs` overrides and enables everything.
    ++	 */
    ++	if (rw->want_all_refs == 1) {
    ++		rw->want_branches = 1;
    ++		rw->want_tags = 1;
    ++		rw->want_remotes = 1;
    ++		rw->want_detached = 1;
    ++		rw->want_other = 1;
    ++		return;
     +	}
    -+	return 0;
    ++
    ++	/*
    ++	 * If none of the `--<ref-type>` were given, we assume all
    ++	 * of the builtin unspecified values.
    ++	 */
    ++	if (rw->want_branches == -1 &&
    ++	    rw->want_tags == -1 &&
    ++	    rw->want_remotes == -1 &&
    ++	    rw->want_detached == -1 &&
    ++	    rw->want_other == -1) {
    ++		*rw = default_ref_options;
    ++		return;
    ++	}
    ++
    ++	/*
    ++	 * Since we only allow positive boolean values on the command
    ++	 * line, we will only have true values where they specified
    ++	 * a `--<ref-type>`.
    ++	 *
    ++	 * So anything that still has an unspecified value should be
    ++	 * set to false.
    ++	 */
    ++	if (rw->want_branches == -1)
    ++		rw->want_branches = 0;
    ++	if (rw->want_tags == -1)
    ++		rw->want_tags = 0;
    ++	if (rw->want_remotes == -1)
    ++		rw->want_remotes = 0;
    ++	if (rw->want_detached == -1)
    ++		rw->want_detached = 0;
    ++	if (rw->want_other == -1)
    ++		rw->want_other = 0;
     +}
     +
    - static int count_references(const struct reference *ref, void *cb_data)
    + static int survey_load_config_cb(const char *var, const char *value,
    + 				 const struct config_context *cctx, void *pvoid)
      {
    - 	struct count_references_data *data = cb_data;
    - 	struct ref_stats *stats = data->stats;
    - 	size_t ref_count;
    +@@ builtin/survey.c: static void survey_load_config(struct survey_context *ctx)
    + 	repo_config(the_repository, survey_load_config_cb, ctx);
    + }
      
    -+	if (!ref_matches_any_filter(ref->name, data->filters))
    -+		return 0;
    -+
    - 	switch (ref_kind_from_refname(ref->name)) {
    - 	case FILTER_REFS_BRANCHES:
    - 		stats->branches++;
    -@@ builtin/repo.c: static int count_references(const struct reference *ref, void *cb_data)
    - static void structure_count_references(struct ref_stats *stats,
    - 				       struct rev_info *revs,
    - 				       struct repository *repo,
    -+				       const struct string_list *filters,
    - 				       int show_progress,
    - 				       bool add_to_pending)
    ++static void do_load_refs(struct survey_context *ctx,
    ++			 struct ref_array *ref_array)
    ++{
    ++	struct ref_filter filter = REF_FILTER_INIT;
    ++	struct ref_sorting *sorting;
    ++	struct string_list sorting_options = STRING_LIST_INIT_DUP;
    ++
    ++	string_list_append(&sorting_options, "objectname");
    ++	sorting = ref_sorting_options(&sorting_options);
    ++
    ++	if (ctx->opts.refs.want_detached)
    ++		strvec_push(&ctx->refs, "HEAD");
    ++
    ++	if (ctx->opts.refs.want_all_refs) {
    ++		strvec_push(&ctx->refs, "refs/");
    ++	} else {
    ++		if (ctx->opts.refs.want_branches)
    ++			strvec_push(&ctx->refs, "refs/heads/");
    ++		if (ctx->opts.refs.want_tags)
    ++			strvec_push(&ctx->refs, "refs/tags/");
    ++		if (ctx->opts.refs.want_remotes)
    ++			strvec_push(&ctx->refs, "refs/remotes/");
    ++		if (ctx->opts.refs.want_other) {
    ++			strvec_push(&ctx->refs, "refs/notes/");
    ++			strvec_push(&ctx->refs, "refs/stash/");
    ++		}
    ++	}
    ++
    ++	filter.name_patterns = ctx->refs.v;
    ++	filter.ignore_case = 0;
    ++	filter.match_as_path = 1;
    ++
    ++	if (ctx->opts.show_progress) {
    ++		ctx->progress_total = 0;
    ++		ctx->progress = start_progress(ctx->repo,
    ++					       _("Scanning refs..."), 0);
    ++	}
    ++
    ++	filter_refs(ref_array, &filter, FILTER_REFS_KIND_MASK);
    ++
    ++	if (ctx->opts.show_progress) {
    ++		ctx->progress_total = ref_array->nr;
    ++		display_progress(ctx->progress, ctx->progress_total);
    ++	}
    ++
    ++	ref_array_sort(sorting, ref_array);
    ++
    ++	stop_progress(&ctx->progress);
    ++	ref_filter_clear(&filter);
    ++	ref_sorting_release(sorting);
    ++}
    ++
    ++/*
    ++ * The REFS phase:
    ++ *
    ++ * Load the set of requested refs and assess them for scalablity problems.
    ++ * Use that set to start a treewalk to all reachable objects and assess
    ++ * them.
    ++ *
    ++ * This data will give us insights into the repository itself (the number
    ++ * of refs, the size and shape of the DAG, the number and size of the
    ++ * objects).
    ++ *
    ++ * Theoretically, this data is independent of the on-disk representation
    ++ * (e.g. independent of packing concerns).
    ++ */
    ++static void survey_phase_refs(struct survey_context *ctx)
    ++{
    ++	struct ref_array ref_array = { 0 };
    ++
    ++	trace2_region_enter("survey", "phase/refs", ctx->repo);
    ++	do_load_refs(ctx, &ref_array);
    ++
    ++	ctx->report.refs.refs_nr = ref_array.nr;
    ++	for (int i = 0; i < ref_array.nr; i++) {
    ++		size_t size;
    ++		struct ref_array_item *item = ref_array.items[i];
    ++
    ++		switch (item->kind) {
    ++		case FILTER_REFS_TAGS:
    ++			ctx->report.refs.tags_nr++;
    ++			if (odb_read_object_info(ctx->repo->objects,
    ++						 &item->objectname,
    ++						 &size) == OBJ_TAG)
    ++				ctx->report.refs.tags_annotated_nr++;
    ++			break;
    ++
    ++		case FILTER_REFS_BRANCHES:
    ++			ctx->report.refs.branches_nr++;
    ++			break;
    ++
    ++		case FILTER_REFS_REMOTES:
    ++			ctx->report.refs.remote_refs_nr++;
    ++			break;
    ++
    ++		case FILTER_REFS_OTHERS:
    ++			ctx->report.refs.others_nr++;
    ++			break;
    ++
    ++		default:
    ++			ctx->report.refs.unknown_nr++;
    ++			break;
    ++		}
    ++	}
    ++
    ++	trace2_region_leave("survey", "phase/refs", ctx->repo);
    ++
    ++	ref_array_clear(&ref_array);
    ++}
    ++
    + int cmd_survey(int argc, const char **argv, const char *prefix, struct repository *repo)
      {
    -@@ builtin/repo.c: static void structure_count_references(struct ref_stats *stats,
    - 		.stats = stats,
    - 		.revs = revs,
    - 		.repo = repo,
    -+		.filters = filters,
    - 		.add_to_pending = add_to_pending,
    + 	static struct survey_context ctx = {
    + 		.opts = {
    + 			.verbose = 0,
    + 			.show_progress = -1, /* defaults to isatty(2) */
    ++
    ++			.refs.want_all_refs = -1,
    ++
    ++			.refs.want_branches = -1, /* default these to undefined */
    ++			.refs.want_tags = -1,
    ++			.refs.want_remotes = -1,
    ++			.refs.want_detached = -1,
    ++			.refs.want_other = -1,
    + 		},
    ++		.refs = STRVEC_INIT,
      	};
      
    -@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    - 	struct rev_info revs;
    - 	int show_progress = -1;
    - 	bool included_revision_args = false;
    -+	struct string_list ref_filters = STRING_LIST_INIT_DUP;
    - 	struct option options[] = {
    - 		OPT_CALLBACK_F(0, "format", &format, N_("format"),
    - 			       N_("output format"),
    -@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    - 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
    - 			       parse_format_cb),
    - 		OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
    -+		OPT_STRING_LIST(0, "ref-filter", &ref_filters, N_("pattern"),
    -+				N_("only count refs matching <pattern>; "
    -+				   "repeat to union multiple patterns")),
    - 		OPT_END()
    + 	static struct option survey_options[] = {
    + 		OPT__VERBOSE(&ctx.opts.verbose, N_("verbose output")),
    + 		OPT_BOOL(0, "progress", &ctx.opts.show_progress, N_("show progress")),
    ++
    ++		OPT_BOOL_F(0, "all-refs", &ctx.opts.refs.want_all_refs, N_("include all refs"),          PARSE_OPT_NONEG),
    ++
    ++		OPT_BOOL_F(0, "branches", &ctx.opts.refs.want_branches, N_("include branches"),          PARSE_OPT_NONEG),
    ++		OPT_BOOL_F(0, "tags",     &ctx.opts.refs.want_tags,     N_("include tags"),              PARSE_OPT_NONEG),
    ++		OPT_BOOL_F(0, "remotes",  &ctx.opts.refs.want_remotes,  N_("include all remotes refs"),  PARSE_OPT_NONEG),
    ++		OPT_BOOL_F(0, "detached", &ctx.opts.refs.want_detached, N_("include detached HEAD"),     PARSE_OPT_NONEG),
    ++		OPT_BOOL_F(0, "other",    &ctx.opts.refs.want_other,    N_("include notes and stashes"), PARSE_OPT_NONEG),
    ++
    + 		OPT_END(),
      	};
      
    -@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    - 			return error(_("unrecognized argument: %s"), argv[1]);
    - 	}
    - 
    --	structure_count_references(&stats.refs, &revs, repo, show_progress, !included_revision_args);
    -+	structure_count_references(&stats.refs, &revs, repo, &ref_filters,
    -+				   show_progress, !included_revision_args);
    - 	structure_count_objects(&stats.objects, &revs, repo, show_progress);
    - 
    - 	switch (format) {
    -@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    - 	}
    - 
    - 	stats_table_clear(&table);
    -+	string_list_clear(&ref_filters, 0);
    - 	release_revisions(&revs);
    +@@ builtin/survey.c: int cmd_survey(int argc, const char **argv, const char *prefix, struct repositor
    + 	if (ctx.opts.show_progress < 0)
    + 		ctx.opts.show_progress = isatty(2);
      
    ++	fixup_refs_wanted(&ctx);
    ++
    ++	survey_phase_refs(&ctx);
    ++
    ++	clear_survey_context(&ctx);
      	return 0;
    + }
     
    - ## t/t1901-repo-structure.sh ##
    -@@ t/t1901-repo-structure.sh: test_expect_success 'progress meter option' '
    - 	)
    + ## t/t8100-git-survey.sh ##
    +@@ t/t8100-git-survey.sh: test_expect_success 'git survey -h shows experimental warning' '
    + 	test_grep "EXPERIMENTAL!" usage
      '
      
    -+test_expect_success '--ref-filter narrows the set of refs' '
    -+	test_when_finished "rm -rf repo" &&
    -+	git init repo &&
    -+	(
    -+		cd repo &&
    -+		test_commit foo &&
    -+		git tag v1 &&
    -+		git update-ref refs/remotes/origin/main HEAD &&
    -+
    -+		git repo structure --format=lines \
    -+			--ref-filter="refs/heads/*" >out &&
    -+		test_grep "^references.branches.count=1$" out &&
    -+		test_grep "^references.tags.count=0$" out &&
    -+		test_grep "^references.remotes.count=0$" out
    -+	)
    ++test_expect_success 'create a semi-interesting repo' '
    ++	test_commit_bulk 10
     +'
     +
    -+test_expect_success '--ref-filter unions multiple patterns' '
    -+	test_when_finished "rm -rf repo" &&
    -+	git init repo &&
    -+	(
    -+		cd repo &&
    -+		test_commit foo &&
    -+		git tag v1 &&
    -+		git update-ref refs/remotes/origin/main HEAD &&
    -+
    -+		git repo structure --format=lines \
    -+			--ref-filter="refs/heads/*" \
    -+			--ref-filter="refs/tags/*" >out &&
    -+		test_grep "^references.branches.count=1$" out &&
    -+		test_grep "^references.tags.count=2$" out &&
    -+		test_grep "^references.remotes.count=0$" out
    -+	)
    ++test_expect_success 'git survey (default)' '
    ++	git survey >out 2>err &&
    ++	test_line_count = 0 err
     +'
     +
    - test_expect_success 'git repo structure -h shows only repo structure usage' '
    - 	git repo structure -h >actual &&
    - 	test_grep "git repo structure" actual &&
    + test_done

Resolved: 8fff863 (repo: report top-N paths by count, disk, and inflated size in structure, 2026-06-06)

added top-path reporting while preserving upstream command parsing and staged both resolved files

Range-diff
  • 1: 8fff863 ! 1: 3487bab repo: report top-N paths by count, disk, and inflated size in structure

    @@ Documentation/git-repo.adoc: supported:
      * Largest reachable objects in the repository by type
     +* Optionally, the top-_N_ largest paths by count, on-disk size, and
     +  inflated size (see `--top` below)
    - +
    - The set of objects counted can be filtered by specifying a collection
    - of revisions to select which objects will be counted. These parameters
    -@@ Documentation/git-repo.adoc: Use `--ref-filter` to narrow the scope.
    - 		`--ref-filter='refs/tags/v*'` for release tags,
    - 		`--ref-filter='refs/remotes/origin/*'` for a single
    - 		remote's branches.
    -+
    +++
     +	`--top=<n>`;;
     +		Also report the _n_ largest paths in the repository,
     +		separately for trees and blobs and separately ranked by
    @@ builtin/repo.c: static int count_objects(const char *path UNUSED, struct oid_arr
      
      	info.revs = revs;
     @@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    + 	struct repo_structure stats = { 0 };
      	struct rev_info revs;
      	int show_progress = -1;
    - 	bool included_revision_args = false;
     +	int top_nr = 0;
    - 	struct string_list ref_filters = STRING_LIST_INIT_DUP;
      	struct option options[] = {
      		OPT_CALLBACK_F(0, "format", &format, N_("format"),
    + 			       N_("output format"),
     @@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    - 		OPT_STRING_LIST(0, "ref-filter", &ref_filters, N_("pattern"),
    - 				N_("only count refs matching <pattern>; "
    - 				   "repeat to union multiple patterns")),
    + 			       PARSE_OPT_NONEG | PARSE_OPT_NOARG,
    + 			       parse_format_cb),
    + 		OPT_BOOL(0, "progress", &show_progress, N_("show progress")),
     +		OPT_INTEGER(0, "top", &top_nr,
     +			    N_("report the top <n> largest paths "
     +			       "per category")),
      		OPT_END()
      	};
      
    - 	argc = parse_options(argc, argv, prefix, options, repo_structure_usage,
    - 			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT);
    + 	argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);
    + 	if (argc)
    + 		usage(_("too many arguments"));
     +	if (top_nr < 0)
     +		die(_("--top=<n> must be non-negative"));
    + 
    + 	repo_init_revisions(repo, &revs, prefix);
    + 
      	if (show_progress < 0)
      		show_progress = isatty(2);
      
    -@@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    - 			return error(_("unrecognized argument: %s"), argv[1]);
    - 	}
    - 
     +	if (top_nr) {
     +		init_top_paths(&stats.objects.top_trees, top_nr);
     +		init_top_paths(&stats.objects.top_blobs, top_nr);
     +	}
     +
    - 	structure_count_references(&stats.refs, &revs, repo, &ref_filters,
    - 				   show_progress, !included_revision_args);
    + 	structure_count_references(&stats.refs, &revs, repo, show_progress);
     -	structure_count_objects(&stats.objects, &revs, repo, show_progress);
     +	structure_count_objects(&stats.objects, &revs, repo, top_nr,
     +				show_progress);
    @@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const
      		break;
      	case FORMAT_NEWLINE_TERMINATED:
     @@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const char *prefix,
    + 	}
      
      	stats_table_clear(&table);
    - 	string_list_clear(&ref_filters, 0);
     +	if (top_nr) {
     +		clear_top_paths(&stats.objects.top_trees);
     +		clear_top_paths(&stats.objects.top_blobs);

Resolved: b13a4a7 (t1901: cover the --top option of git repo structure, 2026-06-06)

retained --top coverage on the updated upstream test file

Range-diff
  • 1: b13a4a7 ! 1: 6138901 t1901: cover the --top option of git repo structure

    @@ Commit message
         Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
     
      ## t/t1901-repo-structure.sh ##
    -@@ t/t1901-repo-structure.sh: test_expect_success '--ref-filter unions multiple patterns' '
    +@@ t/t1901-repo-structure.sh: test_expect_success 'progress meter option' '
      	)
      '
      
    @@ t/t1901-repo-structure.sh: test_expect_success '--ref-filter unions multiple pat
     +	test_must_fail git repo structure --top=-1 2>err &&
     +	test_grep "must be non-negative" err
     +'
    -+
      test_expect_success 'git repo structure -h shows only repo structure usage' '
      	git repo structure -h >actual &&
      	test_grep "git repo structure" actual &&

Resolved: a5ed505 (repo: read the --top default from repo.structure.top, 2026-06-06)

preserved upstream argument parsing, added repo.structure.top config default, retained tests, and staged both files

Range-diff
  • 1: a5ed505 ! 1: c415d04 repo: read the --top default from repo.structure.top

    @@ builtin/repo.c: static int cmd_repo_structure(int argc, const char **argv, const
      
     +	repo_config(repo, repo_structure_config_cb, &top_nr);
     +
    - 	argc = parse_options(argc, argv, prefix, options, repo_structure_usage,
    - 			     PARSE_OPT_KEEP_ARGV0 | PARSE_OPT_KEEP_UNKNOWN_OPT);
    - 	if (top_nr < 0)
    + 	argc = parse_options(argc, argv, prefix, options, repo_structure_usage, 0);
    + 	if (argc)
    + 		usage(_("too many arguments"));
     
      ## t/t1901-repo-structure.sh ##
     @@ t/t1901-repo-structure.sh: test_expect_success '--top rejects negative values' '
    + 	test_must_fail git repo structure --top=-1 2>err &&
      	test_grep "must be non-negative" err
      '
    - 
     +test_expect_success 'repo.structure.top supplies the default for --top' '
     +	test_when_finished "rm -rf repo" &&
     +	git init repo &&

Resolved: 6b9d279 (Backport fix for now-flaky HTTP-auth tests (git-for-windows#6489), 2026-10-16)

retained and staged the libcurl URL API lazy-loading shim on upstream code

Range-diff
  • 1: 6b9d279 ! 1: 90a9327 Backport fix for now-flaky HTTP-auth tests (Backport fix for now-flaky HTTP-auth tests git#6489)

    @@ Commit message
         fast-track the same fix into Git for Windows.
     
      ## compat/lazyload-curl.c ##
    + remerge CONFLICT (add/add): Merge conflict in compat/lazyload-curl.c
    + index 8cded9d769..c361eab85c 100644
    + --- compat/lazyload-curl.c
    + +++ compat/lazyload-curl.c
     @@ compat/lazyload-curl.c: static curl_easy_setopt_pointer_type curl_easy_setopt_pointer_func;
      typedef CURLcode (*curl_easy_setopt_off_t_type)(CURL *curl, CURLoption opt, curl_off_t value);
      static curl_easy_setopt_off_t_type curl_easy_setopt_off_t_func;
      
    -+typedef CURLU *(*curl_url_type)(void);
    -+static curl_url_type curl_url_func;
    -+
    -+typedef void (*curl_url_cleanup_type)(CURLU *u);
    -+static curl_url_cleanup_type curl_url_cleanup_func;
    -+
    -+typedef CURLUcode (*curl_url_get_type)(const CURLU *u, CURLUPart what,
    -+				       char **part, unsigned int flags);
    -+static curl_url_get_type curl_url_get_func;
    -+
    -+typedef CURLUcode (*curl_url_set_type)(CURLU *u, CURLUPart what,
    -+				       const char *part, unsigned int flags);
    -+static curl_url_set_type curl_url_set_func;
    -+
    +-<<<<<<< 1dab2f4359 (ci: bump actions/setup-python from 6 to 7)
    +-=======
    + typedef CURLU *(*curl_url_type)(void);
    + static curl_url_type curl_url_func;
    + 
    +@@ compat/lazyload-curl.c: typedef CURLUcode (*curl_url_set_type)(CURLU *u, CURLUPart what,
    + 				       const char *part, unsigned int flags);
    + static curl_url_set_type curl_url_set_func;
    + 
    +->>>>>>> ad514b3878 (Merge branch 'jk/http-curl-strip-creds')
      static char ssl_backend[64];
      
      static void lazy_load_curl(void)
    @@ compat/lazyload-curl.c: static void lazy_load_curl(void)
      	curl_easy_setopt_long_func = (curl_easy_setopt_long_type)curl_easy_setopt_func;
      	curl_easy_setopt_pointer_func = (curl_easy_setopt_pointer_type)curl_easy_setopt_func;
      	curl_easy_setopt_off_t_func = (curl_easy_setopt_off_t_type)curl_easy_setopt_func;
    -+
    -+	curl_url_func = (curl_url_type)load_function(libcurl, "curl_url");
    -+	curl_url_cleanup_func = (curl_url_cleanup_type)load_function(libcurl, "curl_url_cleanup");
    -+	curl_url_get_func = (curl_url_get_type)load_function(libcurl, "curl_url_get");
    -+	curl_url_set_func = (curl_url_set_type)load_function(libcurl, "curl_url_set");
    +-<<<<<<< 1dab2f4359 (ci: bump actions/setup-python from 6 to 7)
    +-=======
    + 
    + 	curl_url_func = (curl_url_type)load_function(libcurl, "curl_url");
    + 	curl_url_cleanup_func = (curl_url_cleanup_type)load_function(libcurl, "curl_url_cleanup");
    + 	curl_url_get_func = (curl_url_get_type)load_function(libcurl, "curl_url_get");
    + 	curl_url_set_func = (curl_url_set_type)load_function(libcurl, "curl_url_set");
    +->>>>>>> ad514b3878 (Merge branch 'jk/http-curl-strip-creds')
      }
      
      struct curl_version_info_data *curl_version_info(CURLversion version)
    @@ compat/lazyload-curl.c: CURLcode curl_easy_setopt(CURL *curl, CURLoption opt, ..
      	va_end(ap);
      	return res;
      }
    -+
    -+CURLU *curl_url(void)
    -+{
    -+	return curl_url_func();
    -+}
    -+
    -+void curl_url_cleanup(CURLU *u)
    -+{
    -+	curl_url_cleanup_func(u);
    -+}
    -+
    -+CURLUcode curl_url_get(const CURLU *u, CURLUPart what,
    -+		       char **part, unsigned int flags)
    -+{
    -+	return curl_url_get_func(u, what, part, flags);
    -+}
    -+
    -+CURLUcode curl_url_set(CURLU *u, CURLUPart what,
    -+		       const char *part, unsigned int flags)
    -+{
    -+	return curl_url_set_func(u, what, part, flags);
    -+}
    +-<<<<<<< 1dab2f4359 (ci: bump actions/setup-python from 6 to 7)
    +-=======
    + 
    + CURLU *curl_url(void)
    + {
    +@@ compat/lazyload-curl.c: CURLUcode curl_url_set(CURLU *u, CURLUPart what,
    + {
    + 	return curl_url_set_func(u, what, part, flags);
    + }
    +->>>>>>> ad514b3878 (Merge branch 'jk/http-curl-strip-creds')

To: 90a9327955 (Backport fix for now-flaky HTTP-auth tests (git-for-windows#6489), 2026-10-16) (5cb0ffc12f..90a9327955)

Statistics

Metric Count
Total conflicts 6
Skipped (upstreamed) 1
Resolved surgically 5
Range-diff (click to expand)

Truncated; see the full conflict report in the workflow run summary.

derrickstolee and others added 30 commits October 17, 2026 10:04
The 'git survey' builtin provides several detail tables, such as "top
files by on-disk size". The size of these tables defaults to 10,
currently.

Allow the user to specify this number via a new --top=<N> option or the
new survey.top config key.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
headless-git is a git executable without opening a console window. It is
useful when other GUI executables want to call git. We should install it
together with git on Windows.

Signed-off-by: Yuyi Wang <Strawberry_Str@hotmail.com>
winuser.h contains the definition of RT_MANIFEST that our LLVM based
toolchain needs to understand that we want to embed
compat/win32/git.manifest as an application manifest. It currently just
embeds it as additional data that Windows doesn't understand.

This also helps our GCC based toolchain understand that we only want one
copy embedded. It currently embeds one working assembly manifest and one
nearly identical, but useless copy as additional data.

This also teaches our Visual Studio based buildsystems to pick up the
manifest file from git.rc. This means we don't have to explicitly specify
it in contrib/buildsystems/Generators/Vcxproj.pm anymore. Slightly
counter-intuitively this also means we have to explicitly tell Cmake
not to embed a default manifest.

This fixes git-for-windows#4707

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
This will help with Git for Windows' maintenance going forward: It
allows Git for Windows to switch its primary libcurl to a variant
without the OpenSSL backend, while still loading an alternate when
setting `http.sslBackend = openssl`.

This is necessary to avoid maintenance headaches with upgrading OpenSSL:
its major version name is encoded in the shared library's file name and
hence major version updates (temporarily) break libraries that are
linked against the OpenSSL library.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In Git for Windows v2.39.0, we fixed a regression where `git.exe` would
no longer work in Windows Nano Server (frequently used in Docker
containers).

This GitHub workflow can be used to verify manually that the Git/Scalar
executables work in Nano Server.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When running Git for Windows on a remote APFS filesystem, it would
appear that the `mingw_open_append()`/`write()` combination would fail
almost exactly like on some CIFS-mounted shares as had been reported in
git-for-windows#2753, albeit with a
different `errno` value.

Let's handle that `errno` value just the same, by suggesting to set
`windows.appendAtomically=false`.

Signed-off-by: David Lomas <dl3@pale-eds.co.uk>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Windows 10 version 1511 (also known as Anniversary Update), according to
https://learn.microsoft.com/en-us/windows/console/console-virtual-terminal-sequences
introduced native support for ANSI sequence processing. This allows
using colors from the entire 24-bit color range.

All we need to do is test whether the console's "virtual processing
support" can be enabled. If it can, we do not even need to start the
`console_thread` to handle ANSI sequences.

Or, almost all we need to do: When `console_thread()` does its work, it
uses the Unicode-aware `write_console()` function to write to the Win32
Console, which supports Git for Windows' implicit convention that all
text that is written is encoded in UTF-8. The same is not necessarily
true if native ANSI sequence processing is used, as the output is then
subject to the current code page. Let's ensure that the code page is set
to `CP_UTF8` as long as Git writes to it.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
By default, the buffer type of Windows' `stdout` is unbuffered (_IONBF),
and there is no need to manually fflush `stdout`.

But some programs, such as the Windows Filtering Platform driver
provided by the security software, may change the buffer type of
`stdout` to full buffering. This nees `fflush(stdout)` to be called
manually, otherwise there will be no output to `stdout`.

Signed-off-by: MinarKotonoha <chengzhuo5@qq.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
A long time ago, we decided to run tests in Git for Windows' SDK with
the default `winsymlinks` mode: copying instead of linking. This is
still the default mode of MSYS2 to this day.

However, this is not how most users run Git for Windows: As the majority
of Git for Windows' users seem to be on Windows 10 and newer, likely
having enabled Developer Mode (which allows creating symbolic links
without administrator privileges), they will run with symlink support
enabled.

This is the reason why it is crucial to get the fixes for CVE-2024-? to
the users, and also why it is crucial to ensure that the test suite
exercises the related test cases. This commit ensures the latter.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
In order to be a better Windows citizenship, Git should
save its configuration files on AppData folder. This can
enables git configuration files be replicated between machines
using the same Microsoft account logon which would reduce the
friction of setting up Git on new systems. Therefore, if
%APPDATA%\Git\config exists, we use it; otherwise
$HOME/.config/git/config is used.

Signed-off-by: Ariel Lourenco <ariellourenco@users.noreply.github.com>
The sparse tree walk algorithm was created in d5d2e93 (revision:
implement sparse algorithm, 2019-01-16) and involves using the
mark_trees_uninteresting_sparse() method. This method takes a repository
and an oidset of tree IDs, some of which have the UNINTERESTING flag and
some of which do not.

Create a method that has an equivalent set of preconditions but uses a
"dense" walk (recursively visits all reachable trees, as long as they
have not previously been marked UNINTERESTING). This is an important
difference from mark_tree_uninteresting(), which short-circuits if the
given tree has the UNINTERESTING flag.

A use of this method will be added in a later change, with a condition
set whether the sparse or dense approach should be used.

Signed-off-by: Derrick Stolee <stolee@gmail.com>
While this command is definitely something we _want_, chances are that
upstreaming this will require substantial changes.

We still want to be able to experiment with this before that, to focus
on what we need out of this command: To assist with diagnosing issues
with large repositories, as well as to help monitoring the growth and
the associated painpoints of such repositories.

To that end, we are about to integrate this command into
`microsoft/git`, to get the tool into the hands of users who need it
most, with the idea to iterate in close collaboration between these
users and the developers familar with Git's internals.

However, we will definitely want to avoid letting anybody have the
impression that this command, its exact inner workings, as well as its
output format, are anywhere close to stable. To make that fact utterly
clear (and thereby protect the freedom to iterate and innovate freely
before upstreaming the command), let's mark its output as experimental
in all-caps, as the first thing we do.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Mirror what git survey already reports: lightweight tags
(pointing straight at a commit/tree/blob) and annotated tags
(pointing at an OBJ_TAG that is itself stored as a separate
object) are different things in many monorepo contexts, and one
of the differences git survey users routinely care about. Add
an annotated_tags counter to struct ref_stats, populate it in
count_references() by peeking at the ref OID's object type, and
expose it as a sub-row under Tags in the table output and as
references.tags.annotated.count in the machine-readable formats.

Step toward pivoting the standalone git survey command onto
git repo structure; this fills the first of the four feature
gaps documented in the assessment.

Tests in t1901 widened to assert the new row and key.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
`git survey` distinguishes itself from `git repo structure` largely by
its path-level reporting: in addition to whole-repo totals it lists the
paths whose object histories dominate the repository, ranked by raw
count, on-disk size, and inflated size, separately for trees and blobs.
That is often the most actionable output from `git survey`, since it
points an operator at the directories and files that should be reviewed
for cleanup, sparse-checkout exclusion, or rewriting.

`git repo structure` already drives the same path-walk traversal that
`git survey` uses to gather its per-path numbers; the callback simply
discards the path. Aggregate per-(path, type) summaries inside that
existing callback and add a bounded, descending-sorted "top-N" table
keyed by each of the three axes. Gate the feature behind a new
`--top=<n>` option, defaulting to 0, so unadorned invocations are
unaffected and pay no extra work for the top-N tracking.

Mirror the sort and eviction strategy from `builtin/survey.c`: keep an
array of at most N entries sorted from largest to smallest, walk it
from the bottom on each candidate, and shift entries down when a new
one belongs. Compared to `builtin/survey.c`, drop the void-pointer
indirection in the table data, type the comparator's arguments, and
fold the trivial comparators into the `(a > b) - (a < b)` idiom.

For the human-readable `table` output, extend the existing nested
bullet layout with two new top-level sections, `* Top trees` and
`* Top blobs`, each containing three sub-tables (`Top by count`,
`Top by disk size`, `Top by inflated size`). The path becomes the row
name and the relevant scalar becomes the value, reusing
`stats_table_count_addf` and `stats_table_size_addf` so units and
column alignment match the rest of the table.

For the `lines`/`nul` key-value formats, emit one
`objects.<type>.top.by_<axis>.<rank>.path=<path>` entry alongside an
`objects.<type>.top.by_<axis>.<rank>.<axis>=<value>` entry per ranked
path, so consumers can dispatch by axis without parsing the schema.
The root tree's path is the empty string as produced by the path-walk
machinery; preserve that as-is to stay faithful to the upstream
representation rather than fabricating a placeholder.

This is the first piece of folding `git survey`'s functionality into
`git repo structure`. Subsequent commits will add the corresponding
configuration knob and, eventually, turn `git survey` into a thin
deprecated shim over `git repo structure`.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The preceding commit added `--top=<n>` to `git repo structure`,
reporting the top-N paths per type ranked by count, on-disk size, and
inflated size. Cover the three behaviors that matter for that option:

  * Without `--top`, the key-value output emits no `top.*` keys, so
    existing parsers stay unaffected.

  * `--top=N` produces exactly N ranked entries on each of the six
    `objects.<type>.top.by_<axis>` axes (count/disk_size/inflated_size
    crossed with trees/blobs), and a constructed input where one blob
    is several orders of magnitude bigger than the other lets us
    assert the ordering on the disk-size and inflated-size axes.

  * A negative `--top` is rejected with a non-zero exit and a message
    naming the constraint, so a typo cannot silently degrade into the
    default zero.

Avoid grep patterns starting with `--`; grep would parse the leading
double dash as an option terminator.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
`git survey` exposes its `--top` default via `survey.top` so that a
site or per-repository operator can switch the detail tables on once
and have every subsequent invocation include them. Mirror that
ergonomics for `git repo structure` so that, as `git survey`'s
functionality is folded into `git repo structure`, the configuration
side of the migration story stays equivalent.

Add a small `git_config_int` callback bound to `repo.structure.top`
and invoke it before `parse_options()`, so a `--top=<N>` on the
command line cleanly overrides the configured default (including
`--top=0` to opt out of the detail tables when configuration enables
them). Reject negative configured values with the same wording as the
command-line guard, since `git_config_int()` happily returns negative
integers.

Document the new variable in a fresh `Documentation/config/repo.adoc`
and wire it into the alphabetical includes in `Documentation/config.adoc`
between `repack.adoc` and `rerere.adoc`. Cover the precedence
behaviour with a t1901 test: a configured value enables the tables by
default, and a command-line `--top=0` suppresses them again.

Note that the reported paths respect the `core.quotePath` setting.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Continue the size_t evacuation around large object handling: with
deflate_it() and the locals around it widened, the
cast_size_t_to_ulong() shim the prior delta_delta() widening had to
leave behind in emit_binary_diff_body() goes away. deflate_it() is
file-static; the only callers are the two in emit_binary_diff_body()
already touched here.

emit_diff_symbol() formats the resulting sizes via uintmax_t / %"PRIuMAX",
so the diff output is not affected; only the per-process upper bound
on a binary patch chunk that this function can address grows beyond
4 GiB on Windows.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Prep for the upcoming read_blob_data_from_index() widening, whose
callers in convert.c feed the size they receive straight into these
two helpers. Both are file-static, so the change is contained.

Also fixes a small pre-existing narrowing on the get_wt_convert_stats_ascii()
path, where strbuf.len (size_t) was passed to a unsigned long
parameter.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Continue the size_t evacuation. read_blob_data_from_index() reads
the blob through the size_t odb_read_object() API but writes the
size back through an unsigned long out-parameter, silently
truncating anything past 4 GiB on Windows. Widen the out-parameter,
drop the cast_size_t_to_ulong() shim, and move the matching locals
in the two convert.c callers and the one in attr.c. Their
downstream consumers (gather_convert_stats() widened in the prior
commit and read_attr_from_buf() already size_t) take the new type
directly.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The winsock2 library provides functions that work on different data
types than file descriptors, therefore we wrap them.

But that is not the only difference: they also do not set `errno` but
expect the callers to enquire about errors via `WSAGetLastError()`.

Let's translate that into appropriate `errno` values whenever the socket
operations fail so that Git's code base does not have to change its
expectations.

This closes git-for-windows#2404

Helped-by: Jeff Hostetler <jeffhost@microsoft.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Prep for the widenings of its callers, where size-receiving locals
will become size_t (combine-diff's result_size in the immediately
following commit, struct diff_filespec.size in a later topic). Body
caps the parameter at 8000 anyway, so the type change is mechanical.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Smallest piece of the tree topic. link_len is only used as
strbuf_splice()'s size_t length and as an array index; widening it
outright removes the cast_size_t_to_ulong() shim and the bridge
local that fed it. odb_read_object() now writes straight into
link_len.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
We map WSAGetLastError() errors to errno errors in winsock_error_to_errno(),
but the MSVC strerror() implementation only produces "Unknown error" for
most of them. Produce some more meaningful error messages in these
cases.

Our builds for ARM64 link against the newer UCRT strerror() that does know
these errors, so we won't change the strerror() used there.

The wording of the messages is copied from glibc strerror() messages.

Reported-by: M Hickford <mirth.hickford@gmail.com>
Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Although NTLM authentication is considered weak (extending even to
NTLMv2, which purportedly allows brute-forcing reasonably complex
8-character passwords in a matter of days, given ample compute
resources), it _is_ one of the authentication methods supported by
libcurl.

Note: The added test case *cannot* reuse the existing `custom_auth`
facility. The reason is that that facility is backed by an NPH script
("No Parse Headers"), which does not allow handling the 3-phase NTLM
authentication correctly (in my hands, the NPH script would not even be
called upon the Type 3 message, a "200 OK" would be returned, but no
headers, let alone the `git http-backend` output as payload). Having a
separate NTLM authentication script makes the exact workings clearer and
more readable, anyway.

Co-authored-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This will come in handy in the next commit.

Signed-off-by: JiSeop Moon <zcube@zcube.kr>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Bert Belder <bertbelder@gmail.com>
Continue the size_t evacuation. With buffer_is_binary() widened
in the prior commit, every consumer that the size flows into in
combine-diff.c is size_t-ready, so widen grab_blob()'s out-param
outright and move the matching locals at its three call sites
together. grab_blob()'s body collapses to a direct
odb_read_object(&size) since the bridge variable is no longer
needed.

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Prep for dropping the cast_size_t_to_ulong() shim in
add_preferred_base() (pack-objects.c), and aligns the public API
with the size_t shape the rest of the tree topic is moving toward.

struct tree_desc.size stays unsigned int -- the on-disk tree format
hard-caps each tree at 4 GiB, so the field is intentionally narrow
and the assignment in init_tree_desc_internal() already truncated
unsigned long inputs the same way it now truncates size_t inputs.
The widening is purely about the call-side type-correctness; the
internal cap is unchanged.

All 30+ callers pass values that promote cleanly (unsigned long,
size_t, or smaller integer types).

Assisted-by: Opus 4.7
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This comment has been true for the longest time; The combination of the
two preceding commits made it incorrect, so let's drop that comment.

Signed-off-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
NTLM authentication is relatively weak. This is the case even with the
default setting of modern Windows versions, where NTLMv1 and LanManager
are disabled and only NTLMv2 is enabled: NTLMv2 hashes of even
reasonably complex 8-character passwords can be broken in a matter of
days, given enough compute resources.

Even worse: On Windows, NTLM authentication uses Security Support
Provider Interface ("SSPI"), which provides the credentials without
requiring the user to type them in.

Which means that an attacker could talk an unsuspecting user into
cloning from a server that is under the attacker's control and extracts
the user's NTLMv2 hash without their knowledge.

For that reason, let's disallow NTLM authentication by default.

NTLM authentication is quite simple to set up, though, and therefore
there are still some on-prem Azure DevOps setups out there whose users
and/or automation rely on this type of authentication. To give them an
escape hatch, introduce the `http.<url>.allowNTLMAuth` config setting
that can be set to `true` to opt back into using NTLM for a specific
remote repository.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
derrickstolee and others added 30 commits October 17, 2026 10:09
Getting started contributing to Git can be difficult on a Windows
machine. CONTRIBUTING.md contains a guide to getting started, including
detailed steps for setting up build tools, running tests, and
submitting patches to upstream.

[includes an example by Pratik Karki how to submit v2, v3, v4, etc.]

Signed-off-by: Derrick Stolee <dstolee@microsoft.com>
While it may seem super convenient to some old Unix hands to simpy
require Perl to be available when running the test suite, this is a
major hassle on Windows, where we want to verify that Perl is not,
actually, required in a NO_PERL build.

As a super ugly workaround, we "install" a script into /usr/bin/perl
reading like this:

	#!/bin/sh

	# We'd much rather avoid requiring Perl altogether when testing
	# an installed Git. Oh well, that's why we cannot have nice
	# things.
	exec c:/git-sdk-64/usr/bin/perl.exe "$@"

The problem with that is that BusyBox assumes that the #! line in a
script refers to an executable, not to a script. So when it encounters
the line #!/usr/bin/perl in t5532's proxy-get-cmd, it barfs.

Let's help this situation by simply executing the Perl script with the
"interpreter" specified explicitly.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When trying to ensure that long paths are handled correctly, we
first normalize absolute paths as we encounter them.

However, if the path is a so-called "drive-less" absolute path, i.e. if
it is relative to the current drive but _does_ start with a directory
separator, we would want the normalized path to be such a drive-less
absolute path, too.

Let's do that, being careful to still include the drive prefix when we
need to go through the `\\?\` dance (because there, the drive prefix is
absolutely required).

This fixes git-for-windows#4586.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Includes touch-ups by 마누엘, Philip Oakley and 孙卓识.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
When t5605 tries to verify that files are hardlinked (or that they are
not), it uses the `-links` option of the `find` utility.

BusyBox' implementation does not support that option, and BusyBox-w32's
lstat() does not even report the number of hard links correctly (for
performance reasons).

So let's just switch to a different method that actually works on
Windows.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Update wchar_t buffers to use MAX_LONG_PATH instead of MAX_PATH and call
xutftowcs_long_path() in the Win32 backend source files.

Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
With improvements by Clive Chan, Adric Norris, Ben Bodenmiller and
Philip Oakley.

Helped-by: Clive Chan <cc@clive.io>
Helped-by: Adric Norris <landstander668@gmail.com>
Helped-by: Ben Bodenmiller <bbodenmiller@hotmail.com>
Helped-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Brendan Forster <brendan@github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Git for Windows uses MSYS2's Bash to run the test suite, which comes
with benefits but also at a heavy price: on the plus side, MSYS2's
POSIX emulation layer allows us to continue pretending that we are on a
Unix system, e.g. use Unix paths instead of Windows ones, yet this is
bought at a rather noticeable performance penalty.

There *are* some more native ports of Unix shells out there, though,
most notably BusyBox-w32's ash. These native ports do not use any POSIX
emulation layer (or at most a *very* thin one, choosing to avoid
features such as fork() that are expensive to emulate on Windows), and
they use native Windows paths (usually with forward slashes instead of
backslashes, which is perfectly legal in almost all use cases).

And here comes the problem: with a $PWD looking like, say,
C:/git-sdk-64/usr/src/git/t/trash directory.t5813-proto-disable-ssh
Git's test scripts get quite a bit confused, as their assumptions have
been shattered. Not only does this path contain a colon (oh no!), it
also does not start with a slash.

This is a problem e.g. when constructing a URL as t5813 does it:
ssh://remote$PWD. Not only is it impossible to separate the "host" from
the path with a $PWD as above, even prefixing $PWD by a slash won't
work, as /C:/git-sdk-64/... is not a valid path.

As a workaround, detect when $PWD does not start with a slash on
Windows, and simply strip the drive prefix, using an obscure feature of
Windows paths: if an absolute Windows path starts with a slash, it is
implicitly prefixed by the drive prefix of the current directory. As we
are talking about the current directory here, anyway, that strategy
works.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
On Windows, git repositories may have extra files which need cleaned
(e.g., a build directory) that may be arbitrarily deep. Suggest using
`core.longPaths` if such situations are encountered.

Fixes: git-for-windows#2715
Signed-off-by: Ben Boeckel <mathstuf@gmail.com>
These are Git for Windows' Git GUI and gitk patches. We will have to
decide at some point what to do about them, but that's a little lower
priority (as Git GUI seems to be unmaintained for the time being, and
the gitk maintainer keeps a very low profile on the Git mailing list,
too).

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Git for Windows accepts pull requests; Core Git does not. Therefore we
need to adjust the template (because it only matches core Git's
project management style, not ours).

Also: direct Git for Windows enhancements to their contributions page,
space out the text for easy reading, and clarify that the mailing list
is plain text, not HTML.

Signed-off-by: Philip Oakley <philipoakley@iee.org>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
On Windows, the current working directory is pretty much guaranteed to
contain a colon. If we feed that path to CVS, it mistakes it for a
separator between host and port, though.

This has not been a problem so far because Git for Windows uses MSYS2's
Bash using a POSIX emulation layer that also pretends that the current
directory is a Unix path (at least as long as we're in a shell script).

However, that is rather limiting, as Git for Windows also explores other
ports of other Unix shells. One of those is BusyBox-w32's ash, which is
a native port (i.e. *not* using any POSIX emulation layer, and certainly
not emulating Unix paths).

So let's just detect if there is a colon in $PWD and punt in that case.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Rather than using private IFTTT Applets that send mails to this
maintainer whenever a new version of a Git for Windows component was
released, let's use the power of GitHub workflows to make this process
publicly visible.

This workflow monitors the Atom/RSS feeds, and opens a ticket whenever a
new version was released.

Note: Bash sometimes releases multiple patched versions within a few
minutes of each other (i.e. 5.1p1 through 5.1p4, 5.0p15 and 5.0p16). The
MSYS2 runtime also has a similar system. We can address those patches as
a group, so we shouldn't get multiple issues about them.

Note further: We're not acting on newlib releases, OpenSSL alphas, Perl
release candidates or non-stable Perl releases. There's no need to open
issues about them.

Co-authored-by: Matthias Aßhauer <mha1993@live.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This is the recommended way on GitHub to describe policies revolving around
security issues and about supported versions.

Helped-by: Sven Strickroth <email@cs-ware.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…ITOR"

In e3f7e01 (Revert "editor: save and reset terminal after calling
EDITOR", 2021-11-22), we reverted the commit wholesale where the
terminal state would be saved and restored before/after calling an
editor.

The reverted commit was intended to fix a problem with Windows Terminal
where simply calling `vi` would cause problems afterwards.

To fix the problem addressed by the revert, but _still_ keep the problem
with Windows Terminal fixed, let's revert the revert, with a twist: we
restrict the save/restore _specifically_ to the case where `vi` (or
`vim`) is called, and do not do the same for any other editor.

This should still catch the majority of the cases, and will bridge the
time until the original patch is re-done in a way that addresses all
concerns.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
The `--stdin` option was a well-established paradigm in other commands,
therefore we implemented it in `git reset` for use by Visual Studio.

Unfortunately, upstream Git decided that it is time to introduce
`--pathspec-from-file` instead.

To keep backwards-compatibility for some grace period, we therefore
reinstate the `--stdin` option on top of the `--pathspec-from-file`
option, but mark it firmly as deprecated.

Helped-by: Victoria Dye <vdye@github.com>
Helped-by: Matthew John Cheetham <mjcheetham@outlook.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Reintroduce the 'core.useBuiltinFSMonitor' config setting (originally added
in 0a756b2 (fsmonitor: config settings are repository-specific,
2021-03-05)) after its removal from the upstream version of FSMonitor.

Upstream, the 'core.useBuiltinFSMonitor' setting was rendered obsolete by
"overloading" the 'core.fsmonitor' setting to take a boolean value. However,
several applications (e.g., 'scalar') utilize the original config setting,
so it should be preserved for a deprecation period before complete removal:

* if 'core.fsmonitor' is a boolean, the user is correctly using the new
  config syntax; do not use 'core.useBuiltinFSMonitor'.
* if 'core.fsmonitor' is unspecified, use 'core.useBuiltinFSMonitor'.
* if 'core.fsmonitor' is a path, override and use the builtin FSMonitor if
  'core.useBuiltinFSMonitor' is 'true'; otherwise, use the FSMonitor hook
  indicated by the path.

Additionally, for this deprecation period, advise users to switch to using
'core.fsmonitor' to specify their use of the builtin FSMonitor.

Signed-off-by: Victoria Dye <vdye@github.com>
Upstream Git does not test their tags with the expensive set of tests,
so a couple of them seem quite broken for now, even so much as hanging
indefinitely.

It is outside of the responsibility of the Git for Windows project to
fix upstream's own tests for platforms other than Windows, so let's not
exercise them.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
A fix for calling `vim` in Windows Terminal caused a regression and was
reverted. We partially un-revert this, to get the fix again.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
This topic branch re-adds the deprecated --stdin/-z options to `git
reset`. Those patches were overridden by a different set of options in
the upstream Git project before we could propose `--stdin`.

We offered this in MinGit to applications that wanted a safer way to
pass lots of pathspecs to Git, and these applications will need to be
adjusted.

Instead of `--stdin`, `--pathspec-from-file=-` should be used, and
instead of `-z`, `--pathspec-file-nul`.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Originally introduced as `core.useBuiltinFSMonitor` in Git for Windows
and developed, improved and stabilized there, the built-in FSMonitor
only made it into upstream Git (after unnecessarily long hemming and
hawing and throwing overly perfectionist style review sticks into the
spokes) as `core.fsmonitor = true`.

In Git for Windows, with this topic branch, we re-introduce the
now-obsolete config setting, with warnings suggesting to existing users
how to switch to the new config setting, with the intention to
ultimately drop the patch at some stage.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…updates

Start monitoring updates of Git for Windows' component in the open
The special-casing of `NUL` in `mingw_access()` was added in
9160068 (msvc: avoid calling `access("NUL", flags)`, 2021-04-16)
because the Universal C Runtime's ("UCRT") `_waccess()` rejects `NUL` as
an invalid argument.

With the switch of GIt for Windows from the MSVCRT-based MINGW64 build
to the UCRT-based UCRT64 build in 2.56.0, any spelling other than
lowercase `nul` now reaches `_waccess()` and fails. Windows device names
are case-insensitive, and `NUL` is the canonical spelling, but even
`Nul` is allowed, so a case-insensitive comparison is needed.

Note that we cannot use `fspathcmp()` here, as we would usually do: This
function is in the code path when reading the config, and
`core.ignoreCase` would therefore not be set correctly yet e.g. when
running under `GIT_CONFIG_GLOBAL=NUL`.

This fixes git-for-windows#6449

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
Add a README.md for GitHub goodness.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
…r-windows#6450)

Currently, when running `GIT_CONFIG_GLOBAL=NUL git config --list`, it
fails with:

```
fatal: unable to access 'NUL': Invalid argument
```

The underlying reason is the different behavior of the C runtime used by
MINGW64 vs UCRT64. Let's accommodate for that.

This fixes git-for-windows#6449
This bumps `actions/setup-python from version 6 to 7. The main change is
that this is now an ECMAScript Module, which bumps the minimum
requirements for GitHub Enterprise Server setups enough to warrant a
full major version bump.

Release notes: https://github.com/actions/setup-python/releases
Commits: actions/setup-python@v6...v7

Originally-authored-by: dependabot[bot] <support@github.com>
Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
I ran into these new failures (caused by an upgrade to libcurl v8.23.0
in CI builds) in Microsoft Git and fixed them via
microsoft#1007; This is a companion to
fast-track the same fix into Git for Windows.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.