Skip to content

Commit 53fcfbc

Browse files
jeffhostetlergitster
authored andcommitted
fsmonitor--daemon: allow --super-prefix argument
Create a test in t7527 to verify that we get a stray warning from `git fsmonitor--daemon start` when indirectly called from `git submodule absorbgitdirs`. Update `git fsmonitor--daemon` to take (and ignore) the `--super-prefix` argument to suppress the warning. When we have: 1. a submodule with a `sub/.git/` directory (rather than a `sub/.git` file). 2. `core.fsmonitor` is turned on in the submodule, but the daemon is not yet started in the submodule. 3. and someone does a `git submodule absorbgitdirs` in the super. Git will recursively invoke `git submodule--helper absorb-git-dirs` in the submodule. This will read the index and may attempt to start the fsmonitor--daemon with the `--super-prefix` argument. `git fsmonitor--daemon start` does not accept the `--super-prefix` argument and causes a warning to be issued. This does not cause a problem because the `refresh_index()` code assumes a trivial response if the daemon does not start. The net-net is a harmelss, but stray warning. Lets eliminate the warning. Signed-off-by: Jeff Hostetler <[email protected]> Signed-off-by: Junio C Hamano <[email protected]>
1 parent eb29901 commit 53fcfbc

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed

git.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -537,7 +537,7 @@ static struct cmd_struct commands[] = {
537537
{ "format-patch", cmd_format_patch, RUN_SETUP },
538538
{ "fsck", cmd_fsck, RUN_SETUP },
539539
{ "fsck-objects", cmd_fsck, RUN_SETUP },
540-
{ "fsmonitor--daemon", cmd_fsmonitor__daemon, RUN_SETUP },
540+
{ "fsmonitor--daemon", cmd_fsmonitor__daemon, SUPPORT_SUPER_PREFIX | RUN_SETUP },
541541
{ "gc", cmd_gc, RUN_SETUP },
542542
{ "get-tar-commit-id", cmd_get_tar_commit_id, NO_PARSEOPT },
543543
{ "grep", cmd_grep, RUN_SETUP_GENTLY },

t/t7527-builtin-fsmonitor.sh

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -832,6 +832,56 @@ test_expect_success 'submodule always visited' '
832832
my_match_and_clean
833833
'
834834

835+
# If a submodule has a `sub/.git/` directory (rather than a file
836+
# pointing to the super's `.git/modules/sub`) and `core.fsmonitor`
837+
# turned on in the submodule and the daemon is not yet started in
838+
# the submodule, and someone does a `git submodule absorbgitdirs`
839+
# in the super, Git will recursively invoke `git submodule--helper`
840+
# to do the work and this may try to read the index. This will
841+
# try to start the daemon in the submodule *and* pass (either
842+
# directly or via inheritance) the `--super-prefix` arg to the
843+
# `git fsmonitor--daemon start` command inside the submodule.
844+
# This causes a warning because fsmonitor--daemon does take that
845+
# global arg (see the table in git.c)
846+
#
847+
# This causes a warning when trying to start the daemon that is
848+
# somewhat confusing. It does not seem to hurt anything because
849+
# the fsmonitor code maps the query failure into a trivial response
850+
# and does the work anyway.
851+
#
852+
# It would be nice to silence the warning, however.
853+
854+
have_t2_error_event () {
855+
log=$1
856+
msg="fsmonitor--daemon doesnQt support --super-prefix" &&
857+
858+
tr '\047' Q <$1 | grep -e "$msg"
859+
}
860+
861+
test_expect_success "stray submodule super-prefix warning" '
862+
test_when_finished "rm -rf super; \
863+
rm -rf sub; \
864+
rm super-sub.trace" &&
865+
866+
create_super super &&
867+
create_sub sub &&
868+
869+
# Copy rather than submodule add so that we get a .git dir.
870+
cp -R ./sub ./super/dir_1/dir_2/sub &&
871+
872+
git -C super/dir_1/dir_2/sub config core.fsmonitor true &&
873+
874+
git -C super submodule add ../sub ./dir_1/dir_2/sub &&
875+
git -C super commit -m "add sub" &&
876+
877+
test_path_is_dir super/dir_1/dir_2/sub/.git &&
878+
879+
GIT_TRACE2_EVENT="$PWD/super-sub.trace" \
880+
git -C super submodule absorbgitdirs &&
881+
882+
! have_t2_error_event super-sub.trace
883+
'
884+
835885
# On a case-insensitive file system, confirm that the daemon
836886
# notices when the .git directory is moved/renamed/deleted
837887
# regardless of how it is spelled in the the FS event.

0 commit comments

Comments
 (0)