Skip to content

Commit

Permalink
Merge pull request microsoft#366 from dscho/features/scalar-2.32.0
Browse files Browse the repository at this point in the history
Integrate Scalar (ported to C) into vfs-2.32.0
  • Loading branch information
dscho authored and ldennington committed Jan 12, 2022
2 parents 49e109e + 795e06b commit 62b469d
Show file tree
Hide file tree
Showing 16 changed files with 1,439 additions and 16 deletions.
1 change: 1 addition & 0 deletions .github/workflows/main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ on: [push, pull_request]

env:
DEVELOPER: 1
INCLUDE_SCALAR: YesPlease

jobs:
ci-config:
Expand Down
9 changes: 9 additions & 0 deletions Documentation/config/core.txt
Original file line number Diff line number Diff line change
Expand Up @@ -743,3 +743,12 @@ core.abbrev::
If set to "no", no abbreviation is made and the object names
are shown in their full length.
The minimum length is 4.

core.configWriteLockTimeoutMS::
When processes try to write to the config concurrently, it is likely
that one process "wins" and the other process(es) fail to lock the
config file. By configuring a timeout larger than zero, Git can be
told to try to lock the config again a couple times within the
specified timeout. If the timeout is configure to zero (which is the
default), Git will fail immediately when the config is already
locked.
39 changes: 38 additions & 1 deletion Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -1994,6 +1994,10 @@ ifndef PAGER_ENV
PAGER_ENV = LESS=FRX LV=-c
endif

ifneq (,$(INCLUDE_SCALAR))
EXTRA_PROGRAMS += contrib/scalar/scalar$X
endif

QUIET_SUBDIR0 = +$(MAKE) -C # space to separate -C and subdir
QUIET_SUBDIR1 =

Expand Down Expand Up @@ -2537,7 +2541,7 @@ ifndef NO_CURL
OBJECTS += http.o http-walker.o remote-curl.o
endif

SCALAR_SOURCES := contrib/scalar/scalar.c
SCALAR_SOURCES := contrib/scalar/scalar.c contrib/scalar/json-parser.c
SCALAR_OBJECTS := $(SCALAR_SOURCES:c=o)
OBJECTS += $(SCALAR_OBJECTS)

Expand Down Expand Up @@ -2685,6 +2689,9 @@ contrib/scalar/scalar$X: $(SCALAR_OBJECTS) GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
$(filter %.o,$^) $(LIBS)

bin-wrappers/scalar: contrib/scalar/Makefile
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) ../../bin-wrappers/scalar

git-gvfs-helper$X: gvfs-helper.o http.o GIT-LDFLAGS $(GITLIBS)
$(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) $(filter %.o,$^) \
$(CURL_LIBCURL) $(EXPAT_LIBEXPAT) $(LIBS)
Expand Down Expand Up @@ -2714,14 +2721,23 @@ Documentation/GIT-EXCLUDED-PROGRAMS: FORCE
.PHONY: doc man man-perl html info pdf
doc: man-perl
$(MAKE) -C Documentation all
ifneq (,$(INCLUDE_SCALAR))
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) scalar.html scalar.1
endif

man: man-perl
$(MAKE) -C Documentation man
ifneq (,$(INCLUDE_SCALAR))
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) scalar.1
endif

man-perl: perl/build/man/man3/Git.3pm

html:
$(MAKE) -C Documentation html
ifneq (,$(INCLUDE_SCALAR))
$(QUIET_SUBDIR0)contrib/scalar $(QUIET_SUBDIR1) scalar.html
endif

info:
$(MAKE) -C Documentation info
Expand Down Expand Up @@ -2975,6 +2991,10 @@ endif

test_bindir_programs := $(patsubst %,bin-wrappers/%,$(BINDIR_PROGRAMS_NEED_X) $(BINDIR_PROGRAMS_NO_X) $(TEST_PROGRAMS_NEED_X))

ifneq (,$(INCLUDE_SCALAR))
test_bindir_programs += bin-wrappers/scalar
endif

all:: $(TEST_PROGRAMS) $(test_bindir_programs)

bin-wrappers/%: wrap-for-bin.sh
Expand All @@ -2995,6 +3015,9 @@ export TEST_NO_MALLOC_CHECK

test: all
$(MAKE) -C t/ all
ifneq (,$(INCLUDE_SCALAR))
$(MAKE) -C contrib/scalar/t
endif

perf: all
$(MAKE) -C t/perf/ all
Expand Down Expand Up @@ -3129,6 +3152,9 @@ install: all
$(INSTALL) $(INSTALL_STRIP) $(install_bindir_xprograms) '$(DESTDIR_SQ)$(bindir_SQ)'
$(INSTALL) $(BINDIR_PROGRAMS_NO_X) '$(DESTDIR_SQ)$(bindir_SQ)'

ifneq (,$(INCLUDE_SCALAR))
$(INSTALL) contrib/scalar/scalar$X '$(DESTDIR_SQ)$(bindir_SQ)'
endif
ifdef MSVC
# We DO NOT install the individual foo.o.pdb files because they
# have already been rolled up into the exe's pdb file.
Expand Down Expand Up @@ -3221,6 +3247,10 @@ install-doc: install-man-perl

install-man: install-man-perl
$(MAKE) -C Documentation install-man
ifneq (,$(INCLUDE_SCALAR))
$(MAKE) -C contrib/scalar scalar.1
$(INSTALL) contrib/scalar/scalar.1 '$(DESTDIR_SQ)$(mandir_SQ)/man1'
endif

install-man-perl: man-perl
$(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(mandir_SQ)/man3'
Expand All @@ -3229,6 +3259,10 @@ install-man-perl: man-perl

install-html:
$(MAKE) -C Documentation install-html
ifneq (,$(INCLUDE_SCALAR))
$(MAKE) -C contrib/scalar scalar.html
$(INSTALL) contrib/scalar/scalar.html '$(DESTDIR_SQ)$(htmldir)'
endif

install-info:
$(MAKE) -C Documentation install-info
Expand Down Expand Up @@ -3367,6 +3401,9 @@ endif
ifndef NO_TCLTK
$(MAKE) -C gitk-git clean
$(MAKE) -C git-gui clean
endif
ifneq (,$(INCLUDE_SCALAR))
$(MAKE) -C contrib/scalar clean
endif
$(RM) GIT-VERSION-FILE GIT-CFLAGS GIT-LDFLAGS GIT-BUILD-OPTIONS
$(RM) GIT-USER-AGENT GIT-PREFIX
Expand Down
2 changes: 2 additions & 0 deletions builtin/help.c
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,8 @@ static const char *cmd_to_page(const char *git_cmd)
return git_cmd;
else if (is_git_command(git_cmd))
return xstrfmt("git-%s", git_cmd);
else if (!strcmp("scalar", git_cmd))
return xstrdup(git_cmd);
else
return xstrfmt("git%s", git_cmd);
}
Expand Down
5 changes: 5 additions & 0 deletions ci/run-test-slice.sh
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,9 @@ make --quiet -C t T="$(cd t &&
# Run the git subtree tests only if main tests succeeded
test 0 != "$1" || make -C contrib/subtree test

if test 0 = "$1" && test -n "$INCLUDE_SCALAR"
then
make -C contrib/scalar/t
fi

check_unignored_build_artifacts
8 changes: 7 additions & 1 deletion config.c
Original file line number Diff line number Diff line change
Expand Up @@ -3003,6 +3003,7 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
const char *value_pattern,
unsigned flags)
{
static unsigned long timeout_ms = ULONG_MAX;
int fd = -1, in_fd = -1;
int ret;
struct lock_file lock = LOCK_INIT;
Expand All @@ -3023,11 +3024,16 @@ int git_config_set_multivar_in_file_gently(const char *config_filename,
if (!config_filename)
config_filename = filename_buf = git_pathdup("config");

if ((long)timeout_ms < 0 &&
git_config_get_ulong("core.configWriteLockTimeoutMS", &timeout_ms))
timeout_ms = 0;

/*
* The lock serves a purpose in addition to locking: the new
* contents of .git/config will be written into it.
*/
fd = hold_lock_file_for_update(&lock, config_filename, 0);
fd = hold_lock_file_for_update_timeout(&lock, config_filename, 0,
timeout_ms);
if (fd < 0) {
error_errno(_("could not lock config file %s"), config_filename);
ret = CONFIG_NO_LOCK;
Expand Down
15 changes: 14 additions & 1 deletion contrib/buildsystems/CMakeLists.txt
Original file line number Diff line number Diff line change
Expand Up @@ -791,6 +791,13 @@ if(CURL_FOUND)
target_link_libraries(git-gvfs-helper http_obj common-main ${CURL_LIBRARIES} )
endif()

if(DEFINED ENV{INCLUDE_SCALAR} AND NOT ENV{INCLUDE_SCALAR} STREQUAL "")
add_executable(scalar ${CMAKE_SOURCE_DIR}/contrib/scalar/scalar.c ${CMAKE_SOURCE_DIR}/contrib/scalar/json-parser.c)
target_link_libraries(scalar common-main)
set_target_properties(scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY_DEBUG ${CMAKE_BINARY_DIR}/contrib/scalar)
set_target_properties(scalar PROPERTIES RUNTIME_OUTPUT_DIRECTORY_RELEASE ${CMAKE_BINARY_DIR}/contrib/scalar)
endif()

parse_makefile_for_executables(git_builtin_extra "BUILT_INS")

option(SKIP_DASHED_BUILT_INS "Skip hardlinking the dashed versions of the built-ins")
Expand Down Expand Up @@ -1012,7 +1019,6 @@ if(CURL_FOUND)
endif()
endif()


foreach(script ${wrapper_scripts})
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
Expand All @@ -1032,6 +1038,13 @@ string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
string(REPLACE "@@PROG@@" "git-cvsserver" content "${content}")
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/git-cvsserver ${content})

if(DEFINED ENV{INCLUDE_SCALAR} AND NOT ENV{INCLUDE_SCALAR} STREQUAL "")
file(STRINGS ${CMAKE_SOURCE_DIR}/wrap-for-bin.sh content NEWLINE_CONSUME)
string(REPLACE "@@BUILD_DIR@@" "${CMAKE_BINARY_DIR}" content "${content}")
string(REPLACE "@@PROG@@" "contrib/scalar/scalar${EXE_EXTENSION}" content "${content}")
file(WRITE ${CMAKE_BINARY_DIR}/bin-wrappers/scalar ${content})
endif()

#options for configuring test options
option(PERL_TESTS "Perform tests that use perl" ON)
option(PYTHON_TESTS "Perform tests that use python" ON)
Expand Down
4 changes: 2 additions & 2 deletions contrib/scalar/Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -18,15 +18,15 @@ include ../../config.mak.uname
-include ../../config.mak.autogen
-include ../../config.mak

TARGETS = scalar$(X) scalar.o
TARGETS = scalar$(X) scalar.o json-parser.o
GITLIBS = ../../common-main.o ../../libgit.a ../../xdiff/lib.a

all: scalar$(X) ../../bin-wrappers/scalar

$(GITLIBS):
$(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $(subst ../../,,$@)

$(TARGETS): $(GITLIBS) scalar.c
$(TARGETS): $(GITLIBS) scalar.c json-parser.c json-parser.h
$(QUIET_SUBDIR0)../.. $(QUIET_SUBDIR1) $(patsubst %,contrib/scalar/%,$@)

clean:
Expand Down
Loading

0 comments on commit 62b469d

Please sign in to comment.