Skip to content

Commit 62e83d4

Browse files
committed
Merge branch 'js/scalar'
Add pieces from "scalar" to contrib/. * js/scalar: scalar: implement the `version` command scalar: implement the `delete` command scalar: teach 'reconfigure' to optionally handle all registered enlistments scalar: allow reconfiguring an existing enlistment scalar: implement the `run` command scalar: teach 'clone' to support the --single-branch option scalar: implement the `clone` subcommand scalar: implement 'scalar list' scalar: let 'unregister' handle a deleted enlistment directory gracefully scalar: 'unregister' stops background maintenance scalar: 'register' sets recommended config and starts maintenance scalar: create test infrastructure scalar: start documenting the command scalar: create a rudimentary executable scalar: add a README with a roadmap
2 parents 8d2c373 + ddc35d8 commit 62e83d4

File tree

8 files changed

+1275
-0
lines changed

8 files changed

+1275
-0
lines changed

Makefile

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2492,6 +2492,11 @@ OBJECTS += $(REFTABLE_OBJS) $(REFTABLE_TEST_OBJS)
24922492
ifndef NO_CURL
24932493
OBJECTS += http.o http-walker.o remote-curl.o
24942494
endif
2495+
2496+
SCALAR_SOURCES := contrib/scalar/scalar.c
2497+
SCALAR_OBJECTS := $(SCALAR_SOURCES:c=o)
2498+
OBJECTS += $(SCALAR_OBJECTS)
2499+
24952500
.PHONY: objects
24962501
objects: $(OBJECTS)
24972502

@@ -2625,6 +2630,10 @@ $(REMOTE_CURL_PRIMARY): remote-curl.o http.o http-walker.o GIT-LDFLAGS $(GITLIBS
26252630
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
26262631
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
26272632

2633+
contrib/scalar/scalar$X: $(SCALAR_OBJECTS) GIT-LDFLAGS $(GITLIBS)
2634+
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
2635+
$(filter %.o,$^) $(LIBS)
2636+
26282637
$(LIB_FILE): $(LIB_OBJS)
26292638
$(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
26302639

contrib/scalar/.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
/*.exe
2+
/scalar

contrib/scalar/Makefile

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,45 @@
1+
QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
2+
QUIET_SUBDIR1 =
3+
4+
ifneq ($(findstring s,$(MAKEFLAGS)),s)
5+
ifndef V
6+
QUIET_GEN = @echo ' ' GEN $@;
7+
QUIET_SUBDIR0 = +@subdir=
8+
QUIET_SUBDIR1 = ;$(NO_SUBDIR) echo ' ' SUBDIR $$subdir; \
9+
$(MAKE) $(PRINT_DIR) -C $$subdir
10+
else
11+
export V
12+
endif
13+
endif
14+
15+
all:
16+
17+
include ../../config.mak.uname
18+
-include ../../config.mak.autogen
19+
-include ../../config.mak
20+
21+
TARGETS = scalar$(X) scalar.o
22+
GITLIBS = ../../common-main.o ../../libgit.a ../../xdiff/lib.a
23+
24+
all: scalar$(X) ../../bin-wrappers/scalar
25+
26+
$(GITLIBS):
27+
$(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $(subst ../../,,$@)
28+
29+
$(TARGETS): $(GITLIBS) scalar.c
30+
$(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $(patsubst %,contrib/scalar/%,$@)
31+
32+
clean:
33+
$(RM) $(TARGETS) ../../bin-wrappers/scalar
34+
35+
../../bin-wrappers/scalar: ../../wrap-for-bin.sh Makefile
36+
@mkdir -p ../../bin-wrappers
37+
$(QUIET_GEN)sed -e '1s|#!.*/sh|#!$(SHELL_PATH_SQ)|' \
38+
-e 's|@@BUILD_DIR@@|$(shell cd ../.. && pwd)|' \
39+
-e 's|@@PROG@@|contrib/scalar/scalar$(X)|' < $< > $@ && \
40+
chmod +x $@
41+
42+
test: all
43+
$(MAKE) -C t
44+
45+
.PHONY: $(GITLIBS) all clean test FORCE

contrib/scalar/README.md

Lines changed: 82 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,82 @@
1+
# Scalar - an opinionated repository management tool
2+
3+
Scalar is an add-on to Git that helps users take advantage of advanced
4+
performance features in Git. Originally implemented in C# using .NET Core,
5+
based on the learnings from the VFS for Git project, most of the techniques
6+
developed by the Scalar project have been integrated into core Git already:
7+
8+
* partial clone,
9+
* commit graphs,
10+
* multi-pack index,
11+
* sparse checkout (cone mode),
12+
* scheduled background maintenance,
13+
* etc
14+
15+
This directory contains the remaining parts of Scalar that are not (yet) in
16+
core Git.
17+
18+
## Roadmap
19+
20+
The idea is to populate this directory via incremental patch series and
21+
eventually move to a top-level directory next to `gitk-git/` and to `git-gui/`. The
22+
current plan involves the following patch series:
23+
24+
- `scalar-the-beginning`: The initial patch series which sets up
25+
`contrib/scalar/` and populates it with a minimal `scalar` command that
26+
demonstrates the fundamental ideas.
27+
28+
- `scalar-c-and-C`: The `scalar` command learns about two options that can be
29+
specified before the command, `-c <key>=<value>` and `-C <directory>`.
30+
31+
- `scalar-diagnose`: The `scalar` command is taught the `diagnose` subcommand.
32+
33+
- `scalar-and-builtin-fsmonitor`: The built-in FSMonitor is enabled in `scalar
34+
register` and in `scalar clone`, for an enormous performance boost when
35+
working in large worktrees. This patch series necessarily depends on Jeff
36+
Hostetler's FSMonitor patch series to be integrated into Git.
37+
38+
- `scalar-gentler-config-locking`: Scalar enlistments are registered in the
39+
user's Git config. This usually does not represent any problem because it is
40+
rare for a user to register an enlistment. However, in Scalar's functional
41+
tests, Scalar enlistments are created galore, and in parallel, which can lead
42+
to lock contention. This patch series works around that problem by re-trying
43+
to lock the config file in a gentle fashion.
44+
45+
- `scalar-extra-docs`: Add some extensive documentation that has been written
46+
in the original Scalar project (all subject to discussion, of course).
47+
48+
- `optionally-install-scalar`: Now that Scalar is feature (and documentation)
49+
complete and is verified in CI builds, let's offer to install it.
50+
51+
- `move-scalar-to-toplevel`: Now that Scalar is complete, let's move it next to
52+
`gitk-git/` and to `git-gui/`, making it a top-level command.
53+
54+
The following two patch series exist in Microsoft's fork of Git and are
55+
publicly available. There is no current plan to upstream them, not because I
56+
want to withhold these patches, but because I don't think the Git community is
57+
interested in these patches.
58+
59+
There are some interesting ideas there, but the implementation is too specific
60+
to Azure Repos and/or VFS for Git to be of much help in general (and also: my
61+
colleagues tried to upstream some patches already and the enthusiasm for
62+
integrating things related to Azure Repos and VFS for Git can be summarized in
63+
very, very few words).
64+
65+
These still exist mainly because the GVFS protocol is what Azure Repos has
66+
instead of partial clone, while Git is focused on improving partial clone:
67+
68+
- `scalar-with-gvfs`: The primary purpose of this patch series is to support
69+
existing Scalar users whose repositories are hosted in Azure Repos (which
70+
does not support Git's partial clones, but supports its predecessor, the GVFS
71+
protocol, which is used by Scalar to emulate the partial clone).
72+
73+
Since the GVFS protocol will never be supported by core Git, this patch
74+
series will remain in Microsoft's fork of Git.
75+
76+
- `run-scalar-functional-tests`: The Scalar project developed a quite
77+
comprehensive set of integration tests (or, "Functional Tests"). They are the
78+
sole remaining part of the original C#-based Scalar project, and this patch
79+
adds a GitHub workflow that runs them all.
80+
81+
Since the tests partially depend on features that are only provided in the
82+
`scalar-with-gvfs` patch series, this patch cannot be upstreamed.

0 commit comments

Comments
 (0)