convert: add "status=delayed" to filter process protocol
v4 cover convert: add "status=delayed" to filter process protocol
Hi,
here is the 4th iteration of my "status delayed" topic. I am sorry for the large delays between iterations. Patch 1 to 3 are minor t0021 test adjustments and haven't been changed since v3. Patch 4 is the new feature.
Most significant changes since v3:
* removed "delay-id" approach. Delayed blobs are identified by their pathname (suggested by Taylor, the main user of this new API, see
http://public-inbox.org/git/20170412173404.GA49694@Ida/ )
* rebased the topic onto master (2.13)
* moved "struct delayed_checkout" and "enum ce_delay_state" to convert.h
If you review this series then please read the "Delay" section in "Documentation/gitattributes.txt" first for an overview of the delay mechanism. The changes in "t/t0021/rot13-filter.pl" are easier to review if you ignore whitespace changes.
Thanks,
Lars
RFC: http://public-inbox.org/git/[email protected]/
v1: http://public-inbox.org/git/[email protected]/
v2: http://public-inbox.org/git/[email protected]/
v3: http://public-inbox.org/git/[email protected]/
Lars Schneider (4):
t0021: keep filter log files on comparison
t0021: make debug log file name configurable
t0021: write "OUT" only on success
convert: add "status=delayed" to filter process protocol
Documentation/gitattributes.txt | 65 ++++++++++++- builtin/checkout.c | 3 + cache.h | 6 +- convert.c | 131 ++++++++++++++++++++++---- convert.h | 21 +++++ entry.c | 110 +++++++++++++++++++++- t/t0021-conversion.sh | 136 ++++++++++++++++++++------- t/t0021/rot13-filter.pl | 199 ++++++++++++++++++++++++++-------------- unpack-trees.c | 2 + 9 files changed, 544 insertions(+), 129 deletions(-)
base-commit: 10c78a162fa821ee85203165b805ff46be454091 --
2.13.0
PATCH v4 1/4 t0021: keep filter log files on comparison
The filter log files are modified on comparison. Write the modified log files to temp files for comparison to fix this.
This is useful for the subsequent patch 'convert: add "status=delayed" to filter process protocol'.
--- t/t0021-conversion.sh | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-)
t/t0021-conversion.sh +6 -6
@@ -42,10 +42,10 @@ test_cmp_count () { for FILE in "$expect" "$actual" do sort "$FILE" | uniq -c | - sed -e "s/^ *[0-9][0-9]*[ ]*IN: /x IN: /" >"$FILE.tmp" && - mv "$FILE.tmp" "$FILE" || return + sed -e "s/^ *[0-9][0-9]*[ ]*IN: /x IN: /" >"$FILE.tmp" done && - test_cmp "$expect" "$actual" + test_cmp "$expect.tmp" "$actual.tmp" && + rm "$expect.tmp" "$actual.tmp" } # Compare two files but exclude all `clean` invocations because Git can
@@ -56,10 +56,10 @@ test_cmp_exclude_clean () { actual=$2 for FILE in "$expect" "$actual" do - grep -v "IN: clean" "$FILE" >"$FILE.tmp" && - mv "$FILE.tmp" "$FILE" + grep -v "IN: clean" "$FILE" >"$FILE.tmp" done && - test_cmp "$expect" "$actual" + test_cmp "$expect.tmp" "$actual.tmp" && + rm "$expect.tmp" "$actual.tmp" } # Check that the contents of two files are equal and that their rot13 version
Signature · 1 line
2.13.0
PATCH v4 2/4 t0021: make debug log file name configurable
In reply to Lars SchneiderThe "rot13-filter.pl" helper wrote its debug logs always to "rot13-filter.log". Make this configurable by defining the log file as first parameter of "rot13-filter.pl".
This is useful if "rot13-filter.pl" is configured multiple times similar to the subsequent patch 'convert: add "status=delayed" to filter process protocol'.
--- t/t0021-conversion.sh | 44 ++++++++++++++++++++++---------------------- t/t0021/rot13-filter.pl | 8 +++++--- 2 files changed, 27 insertions(+), 25 deletions(-)
t/t0021-conversion.sh +22 -22
@@ -28,7 +28,7 @@ file_size () { } filter_git () { - rm -f rot13-filter.log && + rm -f *.log && git "$@" }
@@ -342,7 +342,7 @@ test_expect_success 'diff does not reuse worktree files that need cleaning' ' ' test_expect_success PERL 'required process filter should filter data' ' - test_config_global filter.protocol.process "rot13-filter.pl clean smudge" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo && mkdir repo &&
@@ -375,7 +375,7 @@ test_expect_success PERL 'required process filter should filter data' ' IN: clean testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK] STOP EOF - test_cmp_count expected.log rot13-filter.log && + test_cmp_count expected.log debug.log && git commit -m "test commit 2" && rm -f test2.r "testsubdir/test3 '\''sq'\'',\$x=.r" &&
@@ -388,7 +388,7 @@ test_expect_success PERL 'required process filter should filter data' ' IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && filter_git checkout --quiet --no-progress empty-branch && cat >expected.log <<-EOF &&
@@ -397,7 +397,7 @@ test_expect_success PERL 'required process filter should filter data' ' IN: clean test.r $S [OK] -- OUT: $S . [OK] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && filter_git checkout --quiet --no-progress master && cat >expected.log <<-EOF &&
@@ -409,7 +409,7 @@ test_expect_success PERL 'required process filter should filter data' ' IN: smudge testsubdir/test3 '\''sq'\'',\$x=.r $S3 [OK] -- OUT: $S3 . [OK] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r && test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -419,7 +419,7 @@ test_expect_success PERL 'required process filter should filter data' ' test_expect_success PERL 'required process filter takes precedence' ' test_config_global filter.protocol.clean false && - test_config_global filter.protocol.process "rot13-filter.pl clean" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" && test_config_global filter.protocol.required true && rm -rf repo && mkdir repo &&
@@ -439,12 +439,12 @@ test_expect_success PERL 'required process filter takes precedence' ' IN: clean test.r $S [OK] -- OUT: $S . [OK] STOP EOF - test_cmp_count expected.log rot13-filter.log + test_cmp_count expected.log debug.log ) ' test_expect_success PERL 'required process filter should be used only for "clean" operation only' ' - test_config_global filter.protocol.process "rot13-filter.pl clean" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean" && rm -rf repo && mkdir repo && (
@@ -462,7 +462,7 @@ test_expect_success PERL 'required process filter should be used only for "clean IN: clean test.r $S [OK] -- OUT: $S . [OK] STOP EOF - test_cmp_count expected.log rot13-filter.log && + test_cmp_count expected.log debug.log && rm test.r &&
@@ -474,12 +474,12 @@ test_expect_success PERL 'required process filter should be used only for "clean init handshake complete STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log + test_cmp_exclude_clean expected.log debug.log ) ' test_expect_success PERL 'required process filter should process multiple packets' ' - test_config_global filter.protocol.process "rot13-filter.pl clean smudge" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo &&
@@ -514,7 +514,7 @@ test_expect_success PERL 'required process filter should process multiple packet IN: clean 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK] STOP EOF - test_cmp_count expected.log rot13-filter.log && + test_cmp_count expected.log debug.log && rm -f *.file &&
@@ -529,7 +529,7 @@ test_expect_success PERL 'required process filter should process multiple packet IN: smudge 3pkt_2+1.file $(($S*2+1)) [OK] -- OUT: $(($S*2+1)) ... [OK] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && for FILE in *.file do
@@ -539,7 +539,7 @@ test_expect_success PERL 'required process filter should process multiple packet ' test_expect_success PERL 'required process filter with clean error should fail' ' - test_config_global filter.protocol.process "rot13-filter.pl clean smudge" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && test_config_global filter.protocol.required true && rm -rf repo && mkdir repo &&
@@ -558,7 +558,7 @@ test_expect_success PERL 'required process filter with clean error should fail' ' test_expect_success PERL 'process filter should restart after unexpected write failure' ' - test_config_global filter.protocol.process "rot13-filter.pl clean smudge" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && rm -rf repo && mkdir repo && (
@@ -579,7 +579,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f git add . && rm -f *.r && - rm -f rot13-filter.log && + rm -f debug.log && git checkout --quiet --no-progress . 2>git-stderr.log && grep "smudge write error at" git-stderr.log &&
@@ -595,7 +595,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r && test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -609,7 +609,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f ' test_expect_success PERL 'process filter should not be restarted if it signals an error' ' - test_config_global filter.protocol.process "rot13-filter.pl clean smudge" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && rm -rf repo && mkdir repo && (
@@ -639,7 +639,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && test_cmp_committed_rot13 "$TEST_ROOT/test.o" test.r && test_cmp_committed_rot13 "$TEST_ROOT/test2.o" test2.r &&
@@ -648,7 +648,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a ' test_expect_success PERL 'process filter abort stops processing of all further files' ' - test_config_global filter.protocol.process "rot13-filter.pl clean smudge" && + test_config_global filter.protocol.process "rot13-filter.pl debug.log clean smudge" && rm -rf repo && mkdir repo && (
@@ -676,7 +676,7 @@ test_expect_success PERL 'process filter abort stops processing of all further f IN: smudge abort.r $SA [OK] -- OUT: 0 [ABORT] STOP EOF - test_cmp_exclude_clean expected.log rot13-filter.log && + test_cmp_exclude_clean expected.log debug.log && test_cmp "$TEST_ROOT/test.o" test.r && test_cmp "$TEST_ROOT/test2.o" test2.r &&
t/t0021/rot13-filter.pl +5 -3
@@ -2,8 +2,9 @@ # Example implementation for the Git filter protocol version 2 # See Documentation/gitattributes.txt, section "Filter Protocol" # -# The script takes the list of supported protocol capabilities as -# arguments ("clean", "smudge", etc). +# The first argument defines a debug log file that the script write to. +# All remaining arguments define a list of supported protocol +# capabilities ("clean", "smudge", etc). # # This implementation supports special test cases: # (1) If data with the pathname "clean-write-fail.r" is processed with
@@ -24,9 +25,10 @@ use warnings; use IO::File; my $MAX_PACKET_CONTENT_SIZE = 65516; +my $log_file = shift @ARGV; my @capabilities = @ARGV; -open my $debug, ">>", "rot13-filter.log" or die "cannot open log file: $!"; +open my $debug, ">>", $log_file or die "cannot open log file: $!"; sub rot13 { my $str = shift;
Signature · 1 line
2.13.0
PATCH v4 3/4 t0021: write "OUT" only on success
In reply to Lars Schneider"rot13-filter.pl" used to write "OUT <size>" to the debug log even in case of an abort or error. Fix this by writing "OUT <size>" to the debug log only in the successful case if output is actually written.
This is useful for the subsequent patch 'convert: add "status=delayed" to filter process protocol'.
--- t/t0021-conversion.sh | 6 +++--- t/t0021/rot13-filter.pl | 6 +++--- 2 files changed, 6 insertions(+), 6 deletions(-)
t/t0021-conversion.sh +3 -3
@@ -588,7 +588,7 @@ test_expect_success PERL 'process filter should restart after unexpected write f cat >expected.log <<-EOF && START init handshake complete - IN: smudge smudge-write-fail.r $SF [OK] -- OUT: $SF [WRITE FAIL] + IN: smudge smudge-write-fail.r $SF [OK] -- [WRITE FAIL] START init handshake complete IN: smudge test.r $S [OK] -- OUT: $S . [OK]
@@ -634,7 +634,7 @@ test_expect_success PERL 'process filter should not be restarted if it signals a cat >expected.log <<-EOF && START init handshake complete - IN: smudge error.r $SE [OK] -- OUT: 0 [ERROR] + IN: smudge error.r $SE [OK] -- [ERROR] IN: smudge test.r $S [OK] -- OUT: $S . [OK] IN: smudge test2.r $S2 [OK] -- OUT: $S2 . [OK] STOP
@@ -673,7 +673,7 @@ test_expect_success PERL 'process filter abort stops processing of all further f cat >expected.log <<-EOF && START init handshake complete - IN: smudge abort.r $SA [OK] -- OUT: 0 [ABORT] + IN: smudge abort.r $SA [OK] -- [ABORT] STOP EOF test_cmp_exclude_clean expected.log debug.log &&
t/t0021/rot13-filter.pl +3 -3
@@ -153,9 +153,6 @@ while (1) { die "bad command '$command'"; } - print $debug "OUT: " . length($output) . " "; - $debug->flush(); - if ( $pathname eq "error.r" ) { print $debug "[ERROR]\n"; $debug->flush();
@@ -178,6 +175,9 @@ while (1) { die "${command} write error"; } + print $debug "OUT: " . length($output) . " "; + $debug->flush(); + while ( length($output) > 0 ) { my $packet = substr( $output, 0, $MAX_PACKET_CONTENT_SIZE ); packet_bin_write($packet);
Signature · 1 line
2.13.0
PATCH v4 4/4 convert: add "status=delayed" to filter process protocol
In reply to Lars SchneiderSome clean / smudge filters might require a significant amount of time to process a single blob (e.g. the Git LFS smudge filter might perform network requests). During this process the Git checkout operation is blocked and Git needs to wait until the filter is done to continue with the checkout.
Teach the filter process protocol (introduced in edcc858) to accept the status "delayed" as response to a filter request. Upon this response Git continues with the checkout operation. After the checkout operation Git calls "finish_delayed_checkout" which queries the filter for remaining blobs. If the filter is still working on the completion, then the filter is expected to block. If the filter has completed all remaining blobs then an empty response is expected.
Git has a multiple code paths that checkout a blob. Support delayed checkouts only in clone (in unpack-trees.c) and checkout operations.
--- Documentation/gitattributes.txt | 65 +++++++++++++- builtin/checkout.c | 3 + cache.h | 6 +- convert.c | 131 +++++++++++++++++++++++----- convert.h | 21 +++++ entry.c | 110 +++++++++++++++++++++-- t/t0021-conversion.sh | 74 ++++++++++++++++ t/t0021/rot13-filter.pl | 189 ++++++++++++++++++++++++++-------------- unpack-trees.c | 2 + 9 files changed, 507 insertions(+), 94 deletions(-)
Documentation/gitattributes.txt +61 -4
@@ -425,8 +425,8 @@ packet: git< capability=clean packet: git< capability=smudge packet: git< 0000 ------------------------ -Supported filter capabilities in version 2 are "clean" and -"smudge". +Supported filter capabilities in version 2 are "clean", "smudge", +and "delay". Afterwards Git sends a list of "key=value" pairs terminated with a flush packet. The list will contain at least the filter command
@@ -512,12 +512,69 @@ the protocol then Git will stop the filter process and restart it with the next file that needs to be processed. Depending on the `filter.<driver>.required` flag Git will interpret that as error. -After the filter has processed a blob it is expected to wait for -the next "key=value" list containing a command. Git will close +After the filter has processed a command it is expected to wait for +a "key=value" list containing the next command. Git will close the command pipe on exit. The filter is expected to detect EOF and exit gracefully on its own. Git will wait until the filter process has stopped. +Delay +^^^^^ + +If the filter supports the "delay" capability, then Git can send the +flag "can-delay" after the filter command and pathname. This flag +denotes that the filter can delay filtering the current blob (e.g. to +compensate network latencies) by responding with no content but with +the status "delayed" and a flush packet. +------------------------ +packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> can-delay=1 +packet: git> 0000 +packet: git> CONTENT +packet: git> 0000 +packet: git< status=delayed +packet: git< 0000 +------------------------ + +If the filter supports the "delay" capability then it must support the +"list_available_blobs" command. If Git sends this command, then the +filter is expected to return a list of pathnames of blobs that are +available. The list must be terminated with a flush packet followed +by a "success" status that is also terminated with a flush packet. If +no blobs for the delayed paths are available, yet, then the filter is +expected to block the response until at least one blob becomes +available. The filter can tell Git that it has no more delayed blobs +by sending an empty list. +------------------------ +packet: git> command=list_available_blobs +packet: git> 0000 +packet: git< pathname=path/testfile.dat +packet: git< pathname=path/otherfile.dat +packet: git< 0000 +packet: git< status=success +packet: git< 0000 +------------------------ + +After Git received the pathnames, it will request the corresponding +blobs again. These requests contain a pathname and an empty content +section. The filter is expected to respond with the smudged content +in the usual way as explained above. +------------------------ +packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> 0000 +packet: git> 0000 # empty content! +packet: git< status=success +packet: git< 0000 +packet: git< SMUDGED_CONTENT +packet: git< 0000 +packet: git< 0000 +------------------------ + +Example +^^^^^^^ + A long running filter demo implementation can be found in `contrib/long-running-filter/example.pl` located in the Git core repository. If you develop your own long running filter
builtin/checkout.c +3 -0
@@ -374,6 +374,8 @@ static int checkout_paths(const struct checkout_opts *opts, state.force =1 ; state.refresh_cache =1 ; state.istate = &the_index; + +enable_delayed_checkout (&state);for (pos =0 ; pos < active_nr; pos++) {struct cache_entry *ce = active_cache[pos];if (ce->ce_flags &CE_MATCHED ) {
@@ -388,6 +390,7 @@ static int checkout_paths(const struct checkout_opts *opts, pos =skip_same_name (ce, pos) -1 ; } } + errs |=finish_delayed_checkout (&state);if (write_locked_index (&the_index, lock_file,COMMIT_LOCK ))die (_ ("unable to write new index file" ));
cache.h +5 -1
@@ -1542,16 +1542,20 @@ extern int ident_cmp(const struct ident_split *, const struct ident_split *);struct checkout {struct index_state *istate;const char *base_dir; +struct delayed_checkout *delayed_checkout;int base_dir_len;unsigned force:1 , quiet:1 , not_new:1 , refresh_cache:1 ; }; -#define CHECKOUT_INIT { NULL, "" } +#define CHECKOUT_INIT { NULL, "", NULL } +#define TEMPORARY_FILENAME_LENGTH 25extern int checkout_entry (struct cache_entry *ce,const struct checkout *state,char *topath); +extern void enable_delayed_checkout (struct checkout *state); +extern int finish_delayed_checkout (struct checkout *state);struct cache_def {struct strbuf path;
convert.c +111 -20
230 lines not on this page · raw message
convert.h +21 -0
@@ -4,6 +4,8 @@#ifndef CONVERT_H #define CONVERT_H +#include "string-list.h" +enum safe_crlf {SAFE_CRLF_FALSE =0 , SAFE_CRLF_FAIL = 1,
@@ -32,6 +34,21 @@ enum eol {#endif }; +enum ce_delay_state { +CE_NO_DELAY =0 , +CE_CAN_DELAY =1 , +CE_DELAYED =2 , +CE_RETRY =3 +}; + +struct delayed_checkout { +enum ce_delay_state state; +/* List of filter drivers that signaled delayed blobs. */ +struct string_list filters; +/* List of delayed blobs identified by their path. */ +struct string_list paths; +}; +extern enum eol core_eol;extern const char *get_cached_convert_stats_ascii (const char *path);extern const char *get_wt_convert_stats_ascii (const char *path);
@@ -42,6 +59,10 @@ extern int convert_to_git(const char *path, const char *src, size_t len, struct strbuf *dst, enum safe_crlf checksafe);extern int convert_to_working_tree (const char *path,const char *src,size_t len,struct strbuf *dst); +extern int async_convert_to_working_tree (const char *path,const char *src, +size_t len,struct strbuf *dst, +void *dco); +extern int async_query_available_blobs (const char *cmd,struct string_list *delayed_paths);extern int renormalize_buffer (const char *path,const char *src,size_t len,struct strbuf *dst);static inline int would_convert_to_git (const char *path)
entry.c +105 -5
122 lines not on this page · raw message
t/t0021-conversion.sh +74 -0
78 lines not on this page · raw message
t/t0021/rot13-filter.pl +125 -64
234 lines not on this page · raw message
unpack-trees.c +2 -0
@@ -374,6 +374,7 @@ static int check_updates(struct unpack_trees_options *o)if (should_update_submodules () && o->update && !o->dry_run)reload_gitmodules_file (index, &state); +enable_delayed_checkout (&state);for (i =0 ; i < index->cache_nr; i++) {struct cache_entry *ce = index->cache[i];
@@ -388,6 +389,7 @@ static int check_updates(struct unpack_trees_options *o) } } } + errs |=finish_delayed_checkout (&state);stop_progress (&progress);if (o->update)git_attr_set_direction (GIT_ATTR_CHECKIN ,NULL );
Signature · 1 line
2.13.0
I have no remaining concerns about the protocol specification in terms of implementing a filter with this capability.
Quoted 5 lines · Lars Schneider
Documentation/gitattributes.txt +5
-0+After Git received the pathnames, it will request the corresponding +blobs again. These requests contain a pathname and an empty content +section. The filter is expected to respond with the smudged content +in the usual way as explained above. +------------------------
Documentation/gitattributes.txt the protocol then Git will stop the filter process and restart it · line 573
Quoted 10 lines
Documentation/gitattributes.txt +10
-0+packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> 0000 +packet: git> 0000 # empty content! +packet: git< status=success +packet: git< 0000 +packet: git< SMUDGED_CONTENT +packet: git< 0000 +packet: git< 0000 +------------------------
The documentation mentions "0000" 2 times.
Is this a bug in the docu ? Or a feature which may need a comment ?
Quoted 14 lines · Torsten Bögershausen
Quoted 10 lines · Lars Schneider
Documentation/gitattributes.txt +10
-0+After Git received the pathnames, it will request the corresponding +blobs again. These requests contain a pathname and an empty content +section. The filter is expected to respond with the smudged content +in the usual way as explained above. +------------------------ +packet: git> command=smudge +packet: git> pathname=path/testfile.dat +packet: git> 0000 +packet: git> 0000 # empty content! +packet: git< status=success
Quoted 8 lines
Documentation/gitattributes.txt the protocol then Git will stop the filter process and restart it · line 573
Quoted 5 lines
Documentation/gitattributes.txt +5
-0+packet: git< 0000 +packet: git< SMUDGED_CONTENT +packet: git< 0000 +packet: git< 0000 +------------------------The documentation mentions "0000" 2 times.
Is this a bug in the docu ? Or a feature which may need a comment ?
The first 0000 marks the end of the content and the second 0000 marks the end of an empty status list.
Explained in the existing protocol here:
https://github.com/git/git/blob/10c78a162fa821ee85203165b805ff46be454091/Documentation/gitattributes.txt#L451-L457
https://github.com/git/git/blob/10c78a162fa821ee85203165b805ff46be454091/Documentation/gitattributes.txt#L464
For clarity I should probably change it to this:
...
packet: git< status=success packet: git< 0000 packet: git< SMUDGED_CONTENT packet: git< 0000 packet: git< 0000 # empty list, keep "status=success" unchanged!
Thanks,
Lars
Quoted 36 lines · Lars Schneider
convert.c +36
-0+ +int async_query_available_blobs (const char *cmd,struct string_list *delayed_paths) +{ +int err; +char *line; +struct cmd2process *entry; +struct child_process *process; +struct strbuf filter_status =STRBUF_INIT ; + + entry =find_multi_file_filter_entry (&cmd_process_map, cmd); +if (!entry) { +error ("external filter '%s' is not available anymore although " +"not all paths have been filtered" , cmd); +return 0 ; + } + process = &entry->process; +sigchain_push (SIGPIPE ,SIG_IGN ); + + err =packet_write_fmt_gently ( + process->in,"command=list_available_blobs\n" ); +if (err) + goto done; + + err =packet_flush_gently (process->in); +if (err) + goto done; + +for (;;) { +const char * pre ="pathname=" ; +const int pre_len =strlen (pre); + line =packet_read_line (process->out,NULL ); +if (!line) +break ; + err =strlen (line) <= pre_len ||strncmp (line, pre, pre_len); +if (err) + goto done;
convert.c static int apply_multi_file_filter(const char *path, const char *src, size_t len · line 845
Quoted 10 lines
convert.c +10
-0+string_list_insert (delayed_paths,xstrdup (line+pre_len)); + } + +read_multi_file_filter_status (process->out, &filter_status); + err =strcmp (filter_status.buf,"success" ); + +done: +sigchain_pop (SIGPIPE ); + +if (err || errno ==EPIPE ) {
This looks strange, at first glance.
Do we set errno to 0 before ?
Or is there a trick that EPIPE can only be reached, if it is "our" error ?
Quoted 15 lines
convert.c +15
-0+if (!strcmp (filter_status.buf,"error" )) { +/* The filter signaled a problem with the file. */ + }else { +/* +* Something went wrong with the protocol filter. +* Force shutdown and restart if another blob requires +* filtering. +*/ +error ("external filter '%s' failed" , cmd); +kill_multi_file_filter (&cmd_process_map, entry); + } + } +return !err; +} +
Quoted 47 lines · Torsten Bögershausen
Quoted 43 lines · Lars Schneider
convert.c +43
-0+ +int async_query_available_blobs (const char *cmd,struct string_list *delayed_paths) +{ +int err; +char *line; +struct cmd2process *entry; +struct child_process *process; +struct strbuf filter_status =STRBUF_INIT ; + + entry =find_multi_file_filter_entry (&cmd_process_map, cmd); +if (!entry) { +error ("external filter '%s' is not available anymore although " +"not all paths have been filtered" , cmd); +return 0 ; + } + process = &entry->process; +sigchain_push (SIGPIPE ,SIG_IGN ); + + err =packet_write_fmt_gently ( + process->in,"command=list_available_blobs\n" ); +if (err) + goto done; + + err =packet_flush_gently (process->in); +if (err) + goto done; + +for (;;) { +const char * pre ="pathname=" ; +const int pre_len =strlen (pre); + line =packet_read_line (process->out,NULL ); +if (!line) +break ; + err =strlen (line) <= pre_len ||strncmp (line, pre, pre_len); +if (err) + goto done; +string_list_insert (delayed_paths,xstrdup (line+pre_len)); + } + +read_multi_file_filter_status (process->out, &filter_status); + err =strcmp (filter_status.buf,"success" ); + +done:
Quoted 8 lines
convert.c static int apply_multi_file_filter(const char *path, const char *src, size_t len · line 845
Quoted 3 lines
convert.c +3
-0+sigchain_pop (SIGPIPE ); + +if (err || errno ==EPIPE ) {This looks strange, at first glance.
Do we set errno to 0 before ?
Or is there a trick that EPIPE can only be reached, if it is "our" error ?
You are right and I'll fix it!
Thanks for reminding me!
Peff also noticed that some time ago:
http://public-inbox.org/git/[email protected]/
Thanks,
Lars
Quoted 9 lines · Lars Schneider
Quoted 8 lines
convert.c static int apply_multi_file_filter(const char *path, const char *src, size_t len · line 845
Quoted 3 lines
convert.c +3
-0+sigchain_pop (SIGPIPE ); + +if (err || errno ==EPIPE ) {This looks strange, at first glance.
Do we set errno to 0 before ?
Or is there a trick that EPIPE can only be reached, if it is "our" error ?
Quoted 4 lines
You are right and I'll fix it!
Thanks for reminding me!
Peff also noticed that some time ago:
http://public-inbox.org/git/[email protected]/
Ben Peart's bp/sub-process-convert-filter topic also had the same EPIPE issues in its earlier incarnation, IIRC. I haven't looked at this topic for some time, but I wonder if we can share code with it.
Quoted 14 lines · Junio C Hamano
Quoted 9 lines · Lars Schneider
Quoted 8 lines
convert.c static int apply_multi_file_filter(const char *path, const char *src, size_t len · line 845
Quoted 3 lines
convert.c +3
-0+sigchain_pop (SIGPIPE ); + +if (err || errno ==EPIPE ) {This looks strange, at first glance.
Do we set errno to 0 before ?
Or is there a trick that EPIPE can only be reached, if it is "our" error ?
Quoted 8 lines
Quoted 4 lines
You are right and I'll fix it!
Thanks for reminding me!
Peff also noticed that some time ago:
http://public-inbox.org/git/[email protected]/Ben Peart's bp/sub-process-convert-filter topic also had the same EPIPE issues in its earlier incarnation, IIRC. I haven't looked at this topic for some time, but I wonder if we can share code with it.
That's right. There might be some code sharing opportunity with Ben's code that is already in "next":
https://github.com/git/git/blob/next/convert.c#L660-L677
Would it be useful for you if I send v5 with the changes rebased onto "next"?
Thanks,
Lars
Quoted 26 lines · Lars Schneider
Quoted 15 lines · Junio C Hamano
Quoted 9 lines · Lars Schneider
Quoted 8 lines
convert.c static int apply_multi_file_filter(const char *path, const char *src, size_t len · line 845
Quoted 3 lines
convert.c +3
-0+sigchain_pop (SIGPIPE ); + +if (err || errno ==EPIPE ) {This looks strange, at first glance.
Do we set errno to 0 before ?
Or is there a trick that EPIPE can only be reached, if it is "our" error ?Quoted 8 lines
Quoted 4 lines
You are right and I'll fix it!
Thanks for reminding me!
Peff also noticed that some time ago:
http://public-inbox.org/git/[email protected]/Ben Peart's bp/sub-process-convert-filter topic also had the same EPIPE issues in its earlier incarnation, IIRC. I haven't looked at this topic for some time, but I wonder if we can share code with it.
Quoted 6 lines
That's right. There might be some code sharing opportunity with Ben's code that is already in "next":
https://github.com/git/git/blob/next/convert.c#L660-L677Would it be useful for you if I send v5 with the changes rebased onto "next"?
Hi Junio,
sorry for bugging you again, but Ben's topic did not make it to "master" today. Is it OK if I rebase my topic onto "next" and resend?
Thanks,
Lars
Quoted 11 lines · Lars Schneider
Quoted 6 lines
That's right. There might be some code sharing opportunity with Ben's code that is already in "next":
https://github.com/git/git/blob/next/convert.c#L660-L677Would it be useful for you if I send v5 with the changes rebased onto "next"?
Hi Junio,
sorry for bugging you again, but Ben's topic did not make it to "master" today. Is it OK if I rebase my topic onto "next" and resend?
Sorry, your earlier question was lost in the noise and I should have picked it up during my last sweep of leftover bits.
If you are depending on a single topic in 'next', it is better to build on the tip of that topic, not on 'next', if you can figure out where the tip is. In practice, while we are exchanging patches via e-mail, there should be no noticeable difference either way [*1*], but once you start throwing a complex and long series, you may want to publish it to a public repository for reviewers and the maintainer to pull, and that workflow might give us an easier way to review, but a topic based on 'next' will never have a chance to be pulled to be merged for real, as merging its tip to 'master' means it will bring all other junk that may not ready. So if you anticipate that to happen someday, practicing to build on things that are only needed (e.g. if you depend on two topics, you may start by merging them on top of 'master' and then building your change on top) is a good idea.
No matter what you do, please mention on top of what you built your work.
Thanks.
Quoted 5 lines · Junio C Hamano
If you are depending on a single topic in 'next', it is better to build on the tip of that topic, not on 'next', if you can figure out where the tip is. In practice, while we are exchanging patches via e-mail, there should be no noticeable difference either way [*1*],
...
And the forgotten foot note would have said something like this:
*1* If you are depending only on a single topic in 'next', and
other topics in 'next' do not interfere with your work, then by definition, your patches that apply cleanly on 'next' ought to apply cleanly on the tip of that single topic.
;-)