diff options
172 files changed, 4991 insertions, 6740 deletions
diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index 83ca8e4182..49bcd0a2a9 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -408,12 +408,27 @@ jobs: jobname: ${{matrix.vector.jobname}} CC: ${{matrix.vector.cc}} CI_JOB_IMAGE: ${{matrix.vector.image}} + CUSTOM_PATH: /custom runs-on: ubuntu-latest container: ${{matrix.vector.image}} steps: - name: prepare libc6 for actions if: matrix.vector.jobname == 'linux32' run: apt -q update && apt -q -y install libc6-amd64 lib64stdc++6 + - name: install git in container + run: | + if command -v git + then + : # nothing to do + elif command -v apk + then + apk add --update git + elif command -v dnf + then + dnf -yq update && dnf -yq install git + else + apt-get -q update && apt-get -q -y install git + fi - uses: actions/checkout@v4 - run: ci/install-dependencies.sh - run: useradd builder --create-home diff --git a/Documentation/Makefile b/Documentation/Makefile index 0d3a2c6bfe..b109d25e9c 100644 --- a/Documentation/Makefile +++ b/Documentation/Makefile @@ -317,8 +317,8 @@ cmds_txt = cmds-ancillaryinterrogators.adoc \ $(cmds_txt): cmd-list.made -cmd-list.made: cmd-list.perl ../command-list.txt $(MAN1_TXT) - $(QUIET_GEN)$(PERL_PATH) ./cmd-list.perl .. . $(cmds_txt) && \ +cmd-list.made: cmd-list.sh ../command-list.txt $(MAN1_TXT) + $(QUIET_GEN)$(SHELL_PATH) ./cmd-list.sh .. . $(cmds_txt) && \ date >$@ mergetools-%.adoc: generate-mergetool-list.sh ../git-mergetool--lib.sh $(wildcard ../mergetools/*) @@ -398,9 +398,9 @@ user-manual.html: user-manual.xml $(XSLT) git.info: user-manual.texi $(QUIET_MAKEINFO)$(MAKEINFO) --no-split -o $@ user-manual.texi -user-manual.texi: user-manual.xml +user-manual.texi: user-manual.xml fix-texi.sh $(QUIET_DB2TEXI)$(DOCBOOK2X_TEXI) user-manual.xml --encoding=UTF-8 --to-stdout >$@+ && \ - $(PERL_PATH) fix-texi.perl <$@+ >$@ && \ + $(SHELL_PATH) fix-texi.sh <$@+ >$@ && \ $(RM) $@+ user-manual.pdf: user-manual.xml diff --git a/Documentation/RelNotes/2.50.0.adoc b/Documentation/RelNotes/2.50.0.adoc index 3ab82ac3a2..7ae05bdbd6 100644 --- a/Documentation/RelNotes/2.50.0.adoc +++ b/Documentation/RelNotes/2.50.0.adoc @@ -51,6 +51,17 @@ UI, Workflows & Features * "git blame --porcelain" mode now talks about unblamable lines and lines that are blamed to an ignored commit. + * The build procedure installs bash (but not zsh) completion script. + + * send-email has been updated to work better with Outlook's smtp server. + + * "git diff --minimal" used to give non-minimal output when its + optimization kicked in, which has been disabled. + + * "git index-pack --fix-thin" used to abort to prevent a cycle in + delta chains from forming in a corner case even when there is no + such cycle. + Performance, Internal Implementation, Development Support etc. -------------------------------------------------------------- @@ -115,6 +126,25 @@ Performance, Internal Implementation, Development Support etc. * Update parse-options API to catch mistakes to pass address of an integral variable of a wrong type/size. + * Since a call to repo_config() can be called with repo set to NULL + these days, a command that is marked as RUN_SETUP in the builtin + command table does not have to check repo with NULL before making + the call. + + * Overhaul of the reftable API. + + * Reduce requirement for Perl in our documentation build and a few + scripts. + + * The build procedure based on Meson learned to drive the + benchmarking tests. + + * Code clean-up for meson-based build infrastructure. + + * Add an equivalent to "make hdr-check" target to meson based builds. + + * Further code clean-up in the object-store layer. + Fixes since v2.49 ----------------- @@ -224,6 +254,38 @@ Fixes since v2.49 * Various build tweaks, including CSPRNG selection on some platforms. (merge cdda67de03 rj/build-tweaks later to maint). + * Developer support fix.. + (merge 32b74b9809 js/git-perf-env-override later to maint). + + * Fix for scheduled maintenance tasks on platforms using launchctl. + (merge eb2d7beb0e jh/gc-launchctl-schedule-fix later to maint). + + * Update to arm64 Windows port. + (merge 436a42215e js/windows-arm64 later to maint). + * hashmap API clean-up to ensure hashmap_clear() leaves a cleared map + in a reusable state. + (merge 9481877de3 en/hashmap-clear-fix later to maint). + + * "git mv a a/b dst" would ask to move the directory 'a' itself, as + well as its contents, in a single destination directory, which is + a contradicting request that is impossible to satisfy. This case is + now detected and the command errors out. + (merge 974f0d4664 ps/mv-contradiction-fix later to maint). + + * Further refinement on CI messages when an optional external + software is unavailable (e.g. due to third-party service outage). + (merge 956acbefbd jc/ci-skip-unavailable-external-software later to maint). + + * Test result aggregation did not work in Meson based CI jobs. + (merge bd38ed5be1 ps/ci-test-aggreg-fix-for-meson later to maint). + + * Code clean-up around stale CI elements and building with Visual Studio. + (merge a7b060f67f js/ci-buildsystems-cleanup later to maint). + + * "git add 'f?o'" did not add 'foo' if 'f?o', an unusual pathname, + also existed on the working tree, which has been corrected. + (merge ec727e189c kj/glob-path-with-special-char later to maint). + * Other code cleanup, docfix, build fix, etc. (merge 227c4f33a0 ja/doc-block-delimiter-markup-fix later to maint). (merge 2bfd3b3685 ab/decorate-code-cleanup later to maint). @@ -244,3 +306,10 @@ Fixes since v2.49 (merge 107d889303 md/t1403-path-is-file later to maint). (merge abd4192b07 js/comma-semicolon-confusion later to maint). (merge 27b7264206 ab/environment-clean-header later to maint). + (merge ff4a749354 as/typofix-in-env-h-header later to maint). + (merge 86eef3541e az/tighten-string-array-constness later to maint). + (merge 25292c301d lo/remove-log-reencode-from-rev-info later to maint). + (merge 1aa50636fd jk/p5332-testfix later to maint). + (merge 42cf4ac552 ps/ci-resurrect-p4-on-github later to maint). + (merge 104add8368 js/diff-codeql-false-positive-workaround later to maint). + (merge f62977b93c en/get-tree-entry-doc later to maint). diff --git a/Documentation/cmd-list.perl b/Documentation/cmd-list.perl deleted file mode 100755 index 0a0c1b3f61..0000000000 --- a/Documentation/cmd-list.perl +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/perl -w - -use File::Compare qw(compare); - -sub format_one { - my ($source_dir, $out, $nameattr) = @_; - my ($name, $attr) = @$nameattr; - my ($path) = "$source_dir/Documentation/$name.adoc"; - my ($state, $description); - my $mansection; - $state = 0; - open I, '<', "$path" or die "No such file $path.adoc"; - while (<I>) { - if (/^(?:git|scalar)[a-z0-9-]*\(([0-9])\)$/) { - $mansection = $1; - next; - } - if (/^NAME$/) { - $state = 1; - next; - } - if ($state == 1 && /^----$/) { - $state = 2; - next; - } - next if ($state != 2); - chomp; - $description = $_; - last; - } - close I; - if (!defined $description) { - die "No description found in $path.adoc"; - } - if (my ($verify_name, $text) = ($description =~ /^($name) - (.*)/)) { - print $out "linkgit:$name\[$mansection\]::\n\t"; - if ($attr =~ / deprecated /) { - print $out "(deprecated) "; - } - print $out "$text.\n\n"; - } - else { - die "Description does not match $name: $description"; - } -} - -my ($source_dir, $build_dir, @categories) = @ARGV; - -open IN, "<$source_dir/command-list.txt"; -while (<IN>) { - last if /^### command list/; -} - -my %cmds = (); -for (sort <IN>) { - next if /^#/; - - chomp; - my ($name, $cat, $attr) = /^(\S+)\s+(.*?)(?:\s+(.*))?$/; - $attr = '' unless defined $attr; - push @{$cmds{$cat}}, [$name, " $attr "]; -} -close IN; - -for my $out (@categories) { - my ($cat) = $out =~ /^cmds-(.*)\.adoc$/; - my ($path) = "$build_dir/$out"; - open O, '>', "$path+" or die "Cannot open output file $out+"; - for (@{$cmds{$cat}}) { - format_one($source_dir, \*O, $_); - } - close O; - - if (-f "$path" && compare("$path", "$path+") == 0) { - unlink "$path+"; - } - else { - rename "$path+", "$path"; - } -} diff --git a/Documentation/cmd-list.sh b/Documentation/cmd-list.sh new file mode 100755 index 0000000000..077def3b72 --- /dev/null +++ b/Documentation/cmd-list.sh @@ -0,0 +1,104 @@ +#!/bin/sh + +set -e + +format_one () { + source_dir="$1" + command="$2" + attributes="$3" + + path="$source_dir/Documentation/$command.adoc" + if ! test -f "$path" + then + echo >&2 "No such file $path" + exit 1 + fi + + state=0 + while read line + do + case "$state" in + 0) + case "$line" in + git*\(*\)|scalar*\(*\)) + mansection="${line##*\(}" + mansection="${mansection%\)}" + ;; + NAME) + state=1;; + esac + ;; + 1) + if test "$line" = "----" + then + state=2 + fi + ;; + 2) + description="$line" + break + ;; + esac + done <"$path" + + if test -z "$mansection" + then + echo "No man section found in $path" >&2 + exit 1 + fi + + if test -z "$description" + then + echo >&2 "No description found in $path" + exit 1 + fi + + case "$description" in + "$command - "*) + text="${description#$command - }" + + printf "linkgit:%s[%s]::\n\t" "$command" "$mansection" + case "$attributes" in + *" deprecated "*) + printf "(deprecated) " + ;; + esac + printf "$text.\n\n" + ;; + *) + echo >&2 "Description does not match $command: $description" + exit 1 + ;; + esac +} + +source_dir="$1" +build_dir="$2" +shift 2 + +for out +do + category="${out#cmds-}" + category="${category%.adoc}" + path="$build_dir/$out" + + while read command command_category attributes + do + case "$command" in + "#"*) + continue;; + esac + + case "$command_category" in + "$category") + format_one "$source_dir" "$command" " $attributes ";; + esac + done <"$source_dir/command-list.txt" >"$build_dir/$out+" + + if cmp "$build_dir/$out+" "$build_dir/$out" >/dev/null 2>&1 + then + rm "$build_dir/$out+" + else + mv "$build_dir/$out+" "$build_dir/$out" + fi +done diff --git a/Documentation/fix-texi.perl b/Documentation/fix-texi.perl deleted file mode 100755 index ff7d78f620..0000000000 --- a/Documentation/fix-texi.perl +++ /dev/null @@ -1,15 +0,0 @@ -#!/usr/bin/perl -w - -while (<>) { - if (/^\@setfilename/) { - $_ = "\@setfilename git.info\n"; - } elsif (/^\@direntry/) { - print '@dircategory Development -@direntry -* Git: (git). A fast distributed revision control system -@end direntry -'; } - unless (/^\@direntry/../^\@end direntry/) { - print; - } -} diff --git a/Documentation/fix-texi.sh b/Documentation/fix-texi.sh new file mode 100755 index 0000000000..bc300f7b0f --- /dev/null +++ b/Documentation/fix-texi.sh @@ -0,0 +1,21 @@ +#!/bin/sh + +awk ' + /^@setfilename/{ + print "@setfilename git.info" + next + } + /^@direntry/{ + direntry=1 + print "@dircategory Development" + print "@direntry" + print "* Git: (git). A fast distributed revision control system" + print "@end direntry" + next + } + /^@end direntry/{ + direntry=0 + next + } + !direntry +' diff --git a/Documentation/git-branch.adoc b/Documentation/git-branch.adoc index 50a1e13e1f..c0afddc424 100644 --- a/Documentation/git-branch.adoc +++ b/Documentation/git-branch.adoc @@ -373,7 +373,7 @@ $ git branch -D test <2> ------------ + <1> Delete the remote-tracking branches "todo", "html" and "man". The next - `git fetch` or `git pullè will create them again unless you configure them not to. + `git fetch` or `git pull` will create them again unless you configure them not to. See linkgit:git-fetch[1]. <2> Delete the "test" branch even if the "master" branch (or whichever branch is currently checked out) does not have all commits from the test branch. diff --git a/Documentation/git-reflog.adoc b/Documentation/git-reflog.adoc index b55c060569..412f06b8fe 100644 --- a/Documentation/git-reflog.adoc +++ b/Documentation/git-reflog.adoc @@ -138,7 +138,7 @@ Options for `delete` used with `expire`. Options for `drop` -~~~~~~~~~~~~~~~~~~~~ +~~~~~~~~~~~~~~~~~~ --all:: Drop the reflogs of all references from all worktrees. diff --git a/Documentation/git-send-email.adoc b/Documentation/git-send-email.adoc index 7f223db42d..92389036fa 100644 --- a/Documentation/git-send-email.adoc +++ b/Documentation/git-send-email.adoc @@ -115,6 +115,19 @@ illustration below where `[PATCH v2 0/3]` is in reply to `[PATCH 0/2]`: Only necessary if --compose is also set. If --compose is not set, this will be prompted for. +--[no-]outlook-id-fix:: + Microsoft Outlook SMTP servers discard the Message-ID sent via email and + assign a new random Message-ID, thus breaking threads. ++ +With `--outlook-id-fix`, 'git send-email' uses a mechanism specific to +Outlook servers to learn the Message-ID the server assigned to fix the +threading. Use it only when you know that the server reports the +rewritten Message-ID the same way as Outlook servers do. ++ +Without this option specified, the fix is done by default when talking +to 'smtp.office365.com' or 'smtp-mail.outlook.com'. Use +`--no-outlook-id-fix` to disable even when talking to these two servers. + --subject=<string>:: Specify the initial subject of the email thread. Only necessary if --compose is also set. If --compose diff --git a/Documentation/howto/recover-corrupted-object-harder.adoc b/Documentation/howto/recover-corrupted-object-harder.adoc index 5efb4fe81f..86a1ba75cf 100644 --- a/Documentation/howto/recover-corrupted-object-harder.adoc +++ b/Documentation/howto/recover-corrupted-object-harder.adoc @@ -125,7 +125,7 @@ static int try_zlib(unsigned char *buf, int len) { /* make this absurdly large so we don't have to loop */ static unsigned char out[1024*1024]; - z_stream z; + struct z_stream_s z; int ret; memset(&z, 0, sizeof(z)); @@ -278,7 +278,7 @@ int main(int argc, char **argv) static unsigned char buf[25 * 1024 * 1024]; static unsigned char out[25 * 1024 * 1024]; int len; - z_stream z; + struct z_stream_s z; int ret; len = read(0, buf, sizeof(buf)); diff --git a/Documentation/meson.build b/Documentation/meson.build index 0d4de28aca..1433acfd31 100644 --- a/Documentation/meson.build +++ b/Documentation/meson.build @@ -335,12 +335,12 @@ cmd_lists = [ documentation_deps += custom_target( command: [ - perl, + shell, '@INPUT@', meson.project_source_root(), meson.current_build_dir(), ] + cmd_lists, - input: 'cmd-list.perl', + input: 'cmd-list.sh', output: cmd_lists ) @@ -615,6 +615,7 @@ prefix = $(HOME) bindir = $(prefix)/bin mandir = $(prefix)/share/man infodir = $(prefix)/share/info +bash_completion_dir = $(prefix)/share/bash-completion/completions gitexecdir = libexec/git-core mergetoolsdir = $(gitexecdir)/mergetools sharedir = $(prefix)/share @@ -818,6 +819,7 @@ TEST_BUILTINS_OBJS += test-mergesort.o TEST_BUILTINS_OBJS += test-mktemp.o TEST_BUILTINS_OBJS += test-name-hash.o TEST_BUILTINS_OBJS += test-online-cpus.o +TEST_BUILTINS_OBJS += test-pack-deltas.o TEST_BUILTINS_OBJS += test-pack-mtimes.o TEST_BUILTINS_OBJS += test-parse-options.o TEST_BUILTINS_OBJS += test-parse-pathspec-file.o @@ -1377,10 +1379,10 @@ UNIT_TEST_PROGRAMS += t-reftable-basics UNIT_TEST_PROGRAMS += t-reftable-block UNIT_TEST_PROGRAMS += t-reftable-merged UNIT_TEST_PROGRAMS += t-reftable-pq -UNIT_TEST_PROGRAMS += t-reftable-reader UNIT_TEST_PROGRAMS += t-reftable-readwrite UNIT_TEST_PROGRAMS += t-reftable-record UNIT_TEST_PROGRAMS += t-reftable-stack +UNIT_TEST_PROGRAMS += t-reftable-table UNIT_TEST_PROGS = $(patsubst %,$(UNIT_TEST_BIN)/%$X,$(UNIT_TEST_PROGRAMS)) UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/test-lib.o UNIT_TEST_OBJS += $(UNIT_TEST_DIR)/lib-reftable.o @@ -2327,6 +2329,7 @@ bindir_relative_SQ = $(subst ','\'',$(bindir_relative)) mandir_SQ = $(subst ','\'',$(mandir)) mandir_relative_SQ = $(subst ','\'',$(mandir_relative)) infodir_relative_SQ = $(subst ','\'',$(infodir_relative)) +bash_completion_dir_SQ = $(subst ','\'',$(bash_completion_dir)) perllibdir_SQ = $(subst ','\'',$(perllibdir)) localedir_SQ = $(subst ','\'',$(localedir)) localedir_relative_SQ = $(subst ','\'',$(localedir_relative)) @@ -2737,10 +2740,10 @@ REFTABLE_OBJS += reftable/blocksource.o REFTABLE_OBJS += reftable/iter.o REFTABLE_OBJS += reftable/merged.o REFTABLE_OBJS += reftable/pq.o -REFTABLE_OBJS += reftable/reader.o REFTABLE_OBJS += reftable/record.o REFTABLE_OBJS += reftable/stack.o REFTABLE_OBJS += reftable/system.o +REFTABLE_OBJS += reftable/table.o REFTABLE_OBJS += reftable/tree.o REFTABLE_OBJS += reftable/writer.o @@ -3332,8 +3335,10 @@ HCC = $(HCO:hco=hcc) $(HCO): %.hco: %.hcc $(GENERATED_H) FORCE $(QUIET_HDR)$(CC) $(ALL_CFLAGS) -o /dev/null -c -xc $< -.PHONY: hdr-check $(HCO) +# TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+ +.PHONY: hdr-check check-headers $(HCO) hdr-check: $(HCO) +check-headers: hdr-check .PHONY: style style: @@ -3571,6 +3576,10 @@ endif ifneq (,$X) $(foreach p,$(patsubst %$X,%,$(filter %$X,$(ALL_COMMANDS_TO_INSTALL) $(OTHER_PROGRAMS))), test '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p' -ef '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p$X' || $(RM) '$(DESTDIR_SQ)$(gitexec_instdir_SQ)/$p';) endif +ifndef NO_BASH_COMPLETION + $(INSTALL) -d -m 755 '$(DESTDIR_SQ)$(bash_completion_dir_SQ)' && \ + $(INSTALL) -m 644 contrib/completion/git-completion.bash '$(DESTDIR_SQ)$(bash_completion_dir_SQ)/git' +endif bindir=$$(cd '$(DESTDIR_SQ)$(bindir_SQ)' && pwd) && \ execdir=$$(cd '$(DESTDIR_SQ)$(gitexec_instdir_SQ)' && pwd) && \ diff --git a/builtin/add.c b/builtin/add.c index 78dfb26577..747511b68b 100644 --- a/builtin/add.c +++ b/builtin/add.c @@ -386,8 +386,7 @@ int cmd_add(int argc, char *ps_matched = NULL; struct lock_file lock_file = LOCK_INIT; - if (repo) - repo_config(repo, add_config, NULL); + repo_config(repo, add_config, NULL); argc = parse_options(argc, argv, prefix, builtin_add_options, builtin_add_usage, PARSE_OPT_KEEP_ARGV0); diff --git a/builtin/blame.c b/builtin/blame.c index 5bf11c2a3c..944952e30e 100644 --- a/builtin/blame.c +++ b/builtin/blame.c @@ -36,17 +36,17 @@ #include "tag.h" #include "write-or-die.h" -static char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>"); -static char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>"); +static const char blame_usage[] = N_("git blame [<options>] [<rev-opts>] [<rev>] [--] <file>"); +static const char annotate_usage[] = N_("git annotate [<options>] [<rev-opts>] [<rev>] [--] <file>"); -static const char *blame_opt_usage[] = { +static const char *const blame_opt_usage[] = { blame_usage, "", N_("<rev-opts> are documented in git-rev-list(1)"), NULL }; -static const char *annotate_opt_usage[] = { +static const char *const annotate_opt_usage[] = { annotate_usage, "", N_("<rev-opts> are documented in git-rev-list(1)"), @@ -944,7 +944,7 @@ int cmd_blame(int argc, long anchor; long num_lines = 0; const char *str_usage = cmd_is_annotate ? annotate_usage : blame_usage; - const char **opt_usage = cmd_is_annotate ? annotate_opt_usage : blame_opt_usage; + const char *const *opt_usage = cmd_is_annotate ? annotate_opt_usage : blame_opt_usage; setup_default_color_by_age(); git_config(git_blame_config, &output_option); diff --git a/builtin/cat-file.c b/builtin/cat-file.c index 0e3f10a946..3914a2a3f6 100644 --- a/builtin/cat-file.c +++ b/builtin/cat-file.c @@ -169,7 +169,8 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name, goto cleanup; case 'e': - ret = !repo_has_object_file(the_repository, &oid); + ret = !has_object(the_repository, &oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR); goto cleanup; case 'w': diff --git a/builtin/clone.c b/builtin/clone.c index b6f378c438..91b9cd0d16 100644 --- a/builtin/clone.c +++ b/builtin/clone.c @@ -504,9 +504,7 @@ static void write_followtags(const struct ref *refs, const char *msg) continue; if (ends_with(ref->name, "^{}")) continue; - if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid, - OBJECT_INFO_QUICK | - OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!has_object(the_repository, &ref->old_oid, 0)) continue; refs_update_ref(get_main_ref_store(the_repository), msg, ref->name, &ref->old_oid, NULL, 0, diff --git a/builtin/commit-graph.c b/builtin/commit-graph.c index be06d0a811..a783a86e79 100644 --- a/builtin/commit-graph.c +++ b/builtin/commit-graph.c @@ -22,12 +22,12 @@ " [--changed-paths] [--[no-]max-new-filters <n>] [--[no-]progress]\n" \ " <split-options>") -static const char * builtin_commit_graph_verify_usage[] = { +static const char * const builtin_commit_graph_verify_usage[] = { BUILTIN_COMMIT_GRAPH_VERIFY_USAGE, NULL }; -static const char * builtin_commit_graph_write_usage[] = { +static const char * const builtin_commit_graph_write_usage[] = { BUILTIN_COMMIT_GRAPH_WRITE_USAGE, NULL }; diff --git a/builtin/count-objects.c b/builtin/count-objects.c index 0bb5360b2f..a88c0c9c09 100644 --- a/builtin/count-objects.c +++ b/builtin/count-objects.c @@ -12,7 +12,7 @@ #include "parse-options.h" #include "quote.h" #include "packfile.h" -#include "object-store.h" +#include "object-file.h" static unsigned long garbage; static off_t size_garbage; diff --git a/builtin/difftool.c b/builtin/difftool.c index f17a55b3cf..a3b64ce694 100644 --- a/builtin/difftool.c +++ b/builtin/difftool.c @@ -753,8 +753,7 @@ int cmd_difftool(int argc, }; struct child_process child = CHILD_PROCESS_INIT; - if (repo) - repo_config(repo, difftool_config, &dt_options); + repo_config(repo, difftool_config, &dt_options); dt_options.symlinks = dt_options.has_symlinks; argc = parse_options(argc, argv, prefix, builtin_difftool_options, diff --git a/builtin/fast-export.c b/builtin/fast-export.c index afacd228b5..37c01d6c6f 100644 --- a/builtin/fast-export.c +++ b/builtin/fast-export.c @@ -30,7 +30,7 @@ #include "remote.h" #include "blob.h" -static const char *fast_export_usage[] = { +static const char *const fast_export_usage[] = { N_("git fast-export [<rev-list-opts>]"), NULL }; diff --git a/builtin/fast-import.c b/builtin/fast-import.c index c1e198f4e3..b2839c5f43 100644 --- a/builtin/fast-import.c +++ b/builtin/fast-import.c @@ -811,7 +811,8 @@ static char *keep_pack(const char *curr_index_name) int keep_fd; odb_pack_name(pack_data->repo, &name, pack_data->hash, "keep"); - keep_fd = odb_pack_keep(name.buf); + keep_fd = safe_create_file_with_leading_directories(pack_data->repo, + name.buf); if (keep_fd < 0) die_errno("cannot create keep file"); write_or_die(keep_fd, keep_msg, strlen(keep_msg)); diff --git a/builtin/fetch.c b/builtin/fetch.c index 5279997c96..cda6eaf1fd 100644 --- a/builtin/fetch.c +++ b/builtin/fetch.c @@ -337,7 +337,6 @@ static void find_non_local_tags(const struct ref *refs, struct string_list_item *remote_ref_item; const struct ref *ref; struct refname_hash_entry *item = NULL; - const int quick_flags = OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT; refname_hash_init(&existing_refs); refname_hash_init(&remote_refs); @@ -367,9 +366,9 @@ static void find_non_local_tags(const struct ref *refs, */ if (ends_with(ref->name, "^{}")) { if (item && - !repo_has_object_file_with_flags(the_repository, &ref->old_oid, quick_flags) && + !has_object(the_repository, &ref->old_oid, 0) && !oidset_contains(&fetch_oids, &ref->old_oid) && - !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) && + !has_object(the_repository, &item->oid, 0) && !oidset_contains(&fetch_oids, &item->oid)) clear_item(item); item = NULL; @@ -383,7 +382,7 @@ static void find_non_local_tags(const struct ref *refs, * fetch. */ if (item && - !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) && + !has_object(the_repository, &item->oid, 0) && !oidset_contains(&fetch_oids, &item->oid)) clear_item(item); @@ -404,7 +403,7 @@ static void find_non_local_tags(const struct ref *refs, * checked to see if it needs fetching. */ if (item && - !repo_has_object_file_with_flags(the_repository, &item->oid, quick_flags) && + !has_object(the_repository, &item->oid, 0) && !oidset_contains(&fetch_oids, &item->oid)) clear_item(item); @@ -911,7 +910,8 @@ static int update_local_ref(struct ref *ref, struct commit *current = NULL, *updated; int fast_forward = 0; - if (!repo_has_object_file(the_repository, &ref->new_oid)) + if (!has_object(the_repository, &ref->new_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) die(_("object %s not found"), oid_to_hex(&ref->new_oid)); if (oideq(&ref->old_oid, &ref->new_oid)) { @@ -1330,8 +1330,7 @@ static int check_exist_and_connected(struct ref *ref_map) * we need all direct targets to exist. */ for (r = rm; r; r = r->next) { - if (!repo_has_object_file_with_flags(the_repository, &r->old_oid, - OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!has_object(the_repository, &r->old_oid, HAS_OBJECT_RECHECK_PACKED)) return -1; } diff --git a/builtin/gc.c b/builtin/gc.c index 3393d2535d..e33ba946e4 100644 --- a/builtin/gc.c +++ b/builtin/gc.c @@ -29,7 +29,7 @@ #include "commit.h" #include "commit-graph.h" #include "packfile.h" -#include "object-store.h" +#include "object-file.h" #include "pack.h" #include "pack-objects.h" #include "path.h" @@ -2241,7 +2241,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit case SCHEDULE_DAILY: repeat = "<dict>\n" - "<key>Day</key><integer>%d</integer>\n" + "<key>Weekday</key><integer>%d</integer>\n" "<key>Hour</key><integer>0</integer>\n" "<key>Minute</key><integer>%d</integer>\n" "</dict>\n"; @@ -2252,7 +2252,7 @@ static int launchctl_schedule_plist(const char *exec_path, enum schedule_priorit case SCHEDULE_WEEKLY: strbuf_addf(&plist, "<dict>\n" - "<key>Day</key><integer>0</integer>\n" + "<key>Weekday</key><integer>0</integer>\n" "<key>Hour</key><integer>0</integer>\n" "<key>Minute</key><integer>%d</integer>\n" "</dict>\n", diff --git a/builtin/index-pack.c b/builtin/index-pack.c index 60a8ee05db..bb7925bd29 100644 --- a/builtin/index-pack.c +++ b/builtin/index-pack.c @@ -892,9 +892,8 @@ static void sha1_object(const void *data, struct object_entry *obj_entry, if (startup_info->have_repository) { read_lock(); - collision_test_needed = - repo_has_object_file_with_flags(the_repository, oid, - OBJECT_INFO_QUICK); + collision_test_needed = has_object(the_repository, oid, + HAS_OBJECT_FETCH_PROMISOR); read_unlock(); } @@ -1109,8 +1108,8 @@ static void *threaded_second_pass(void *data) set_thread_data(data); for (;;) { struct base_data *parent = NULL; - struct object_entry *child_obj; - struct base_data *child; + struct object_entry *child_obj = NULL; + struct base_data *child = NULL; counter_lock(); display_progress(progress, nr_resolved_deltas); @@ -1137,15 +1136,18 @@ static void *threaded_second_pass(void *data) parent = list_first_entry(&work_head, struct base_data, list); - if (parent->ref_first <= parent->ref_last) { + while (parent->ref_first <= parent->ref_last) { int offset = ref_deltas[parent->ref_first++].obj_no; child_obj = objects + offset; - if (child_obj->real_type != OBJ_REF_DELTA) - die("REF_DELTA at offset %"PRIuMAX" already resolved (duplicate base %s?)", - (uintmax_t) child_obj->idx.offset, - oid_to_hex(&parent->obj->idx.oid)); + if (child_obj->real_type != OBJ_REF_DELTA) { + child_obj = NULL; + continue; + } child_obj->real_type = parent->obj->real_type; - } else { + break; + } + + if (!child_obj && parent->ofs_first <= parent->ofs_last) { child_obj = objects + ofs_deltas[parent->ofs_first++].obj_no; assert(child_obj->real_type == OBJ_OFS_DELTA); @@ -1178,29 +1180,32 @@ static void *threaded_second_pass(void *data) } work_unlock(); - if (parent) { - child = resolve_delta(child_obj, parent); - if (!child->children_remaining) - FREE_AND_NULL(child->data); - } else { - child = make_base(child_obj, NULL); - if (child->children_remaining) { - /* - * Since this child has its own delta children, - * we will need this data in the future. - * Inflate now so that future iterations will - * have access to this object's data while - * outside the work mutex. - */ - child->data = get_data_from_pack(child_obj); - child->size = child_obj->size; + if (child_obj) { + if (parent) { + child = resolve_delta(child_obj, parent); + if (!child->children_remaining) + FREE_AND_NULL(child->data); + } else{ + child = make_base(child_obj, NULL); + if (child->children_remaining) { + /* + * Since this child has its own delta children, + * we will need this data in the future. + * Inflate now so that future iterations will + * have access to this object's data while + * outside the work mutex. + */ + child->data = get_data_from_pack(child_obj); + child->size = child_obj->size; + } } } work_lock(); if (parent) parent->retain_data--; - if (child->data) { + + if (child && child->data) { /* * This child has its own children, so add it to * work_head. @@ -1209,7 +1214,7 @@ static void *threaded_second_pass(void *data) base_cache_used += child->size; prune_base_data(NULL); free_base_data(child); - } else { + } else if (child) { /* * This child does not have its own children. It may be * the last descendant of its ancestors; free those @@ -1565,7 +1570,7 @@ static void write_special_file(const char *suffix, const char *msg, else filename = odb_pack_name(the_repository, &name_buf, hash, suffix); - fd = odb_pack_keep(filename); + fd = safe_create_file_with_leading_directories(the_repository, filename); if (fd < 0) { if (errno != EEXIST) die_errno(_("cannot write %s file '%s'"), diff --git a/builtin/mktree.c b/builtin/mktree.c index 7ffe6eefd8..4b47803467 100644 --- a/builtin/mktree.c +++ b/builtin/mktree.c @@ -67,7 +67,7 @@ static void write_tree(struct object_id *oid) strbuf_release(&buf); } -static const char *mktree_usage[] = { +static const char *const mktree_usage[] = { "git mktree [-z] [--missing] [--batch]", NULL }; diff --git a/builtin/mv.c b/builtin/mv.c index 54b323fff7..07548fe96a 100644 --- a/builtin/mv.c +++ b/builtin/mv.c @@ -39,6 +39,13 @@ enum update_mode { INDEX = (1 << 2), SPARSE = (1 << 3), SKIP_WORKTREE_DIR = (1 << 4), + /* + * A file gets moved implicitly via a move of one of its parent + * directories. This flag causes us to skip the check that we don't try + * to move a file and any of its parent directories at the same point + * in time. + */ + MOVE_VIA_PARENT_DIR = (1 << 5), }; #define DUP_BASENAME 1 @@ -183,6 +190,21 @@ static void remove_empty_src_dirs(const char **src_dir, size_t src_dir_nr) strbuf_release(&a_src_dir); } +struct pathmap_entry { + struct hashmap_entry ent; + const char *path; +}; + +static int pathmap_cmp(const void *cmp_data UNUSED, + const struct hashmap_entry *a, + const struct hashmap_entry *b, + const void *key UNUSED) +{ + const struct pathmap_entry *e1 = container_of(a, struct pathmap_entry, ent); + const struct pathmap_entry *e2 = container_of(b, struct pathmap_entry, ent); + return fspathcmp(e1->path, e2->path); +} + int cmd_mv(int argc, const char **argv, const char *prefix, @@ -213,6 +235,8 @@ int cmd_mv(int argc, struct cache_entry *ce; struct string_list only_match_skip_worktree = STRING_LIST_INIT_DUP; struct string_list dirty_paths = STRING_LIST_INIT_DUP; + struct hashmap moved_dirs = HASHMAP_INIT(pathmap_cmp, NULL); + struct strbuf pathbuf = STRBUF_INIT; int ret; git_config(git_default_config, NULL); @@ -331,6 +355,7 @@ int cmd_mv(int argc, dir_check: if (S_ISDIR(st.st_mode)) { + struct pathmap_entry *entry; char *dst_with_slash; size_t dst_with_slash_len; int j, n; @@ -348,6 +373,11 @@ dir_check: goto act_on_entry; } + entry = xmalloc(sizeof(*entry)); + entry->path = src; + hashmap_entry_init(&entry->ent, fspathhash(src)); + hashmap_add(&moved_dirs, &entry->ent); + /* last - first >= 1 */ modes[i] |= WORKING_DIRECTORY; @@ -368,8 +398,7 @@ dir_check: strvec_push(&sources, path); strvec_push(&destinations, prefixed_path); - memset(modes + argc + j, 0, sizeof(enum update_mode)); - modes[argc + j] |= ce_skip_worktree(ce) ? SPARSE : INDEX; + modes[argc + j] = MOVE_VIA_PARENT_DIR | (ce_skip_worktree(ce) ? SPARSE : INDEX); submodule_gitfiles[argc + j] = NULL; free(prefixed_path); @@ -465,6 +494,32 @@ remove_entry: } } + for (i = 0; i < argc; i++) { + const char *slash_pos; + + if (modes[i] & MOVE_VIA_PARENT_DIR) + continue; + + strbuf_reset(&pathbuf); + strbuf_addstr(&pathbuf, sources.v[i]); + + slash_pos = strrchr(pathbuf.buf, '/'); + while (slash_pos > pathbuf.buf) { + struct pathmap_entry needle; + + strbuf_setlen(&pathbuf, slash_pos - pathbuf.buf); + + needle.path = pathbuf.buf; + hashmap_entry_init(&needle.ent, fspathhash(pathbuf.buf)); + + if (hashmap_get_entry(&moved_dirs, &needle, ent, NULL)) + die(_("cannot move both '%s' and its parent directory '%s'"), + sources.v[i], pathbuf.buf); + + slash_pos = strrchr(pathbuf.buf, '/'); + } + } + if (only_match_skip_worktree.nr) { advise_on_updating_sparse_paths(&only_match_skip_worktree); if (!ignore_errors) { @@ -507,7 +562,8 @@ remove_entry: continue; pos = index_name_pos(the_repository->index, src, strlen(src)); - assert(pos >= 0); + if (pos < 0) + BUG("could not find source in index: '%s'", src); if (!(mode & SPARSE) && !lstat(src, &st)) sparse_and_dirty = ie_modified(the_repository->index, the_repository->index->cache[pos], @@ -589,6 +645,8 @@ out: strvec_clear(&dest_paths); strvec_clear(&destinations); strvec_clear(&submodule_gitfiles_to_free); + hashmap_clear_and_free(&moved_dirs, struct pathmap_entry, ent); + strbuf_release(&pathbuf); free(submodule_gitfiles); free(modes); return ret; diff --git a/builtin/pack-objects.c b/builtin/pack-objects.c index 72ebe13fe0..8b33edc2ff 100644 --- a/builtin/pack-objects.c +++ b/builtin/pack-objects.c @@ -183,7 +183,7 @@ static inline void oe_set_delta_size(struct packing_data *pack, #define SET_DELTA_CHILD(obj, val) oe_set_delta_child(&to_pack, obj, val) #define SET_DELTA_SIBLING(obj, val) oe_set_delta_sibling(&to_pack, obj, val) -static const char *pack_usage[] = { +static const char *const pack_usage[] = { N_("git pack-objects --stdout [<options>] [< <ref-list> | < <object-list>]"), N_("git pack-objects [<options>] <base-name> [< <ref-list> | < <object-list>]"), NULL diff --git a/builtin/receive-pack.c b/builtin/receive-pack.c index be314879e8..c92e57ba18 100644 --- a/builtin/receive-pack.c +++ b/builtin/receive-pack.c @@ -1506,7 +1506,9 @@ static const char *update(struct command *cmd, struct shallow_info *si) } } - if (!is_null_oid(new_oid) && !repo_has_object_file(the_repository, new_oid)) { + if (!is_null_oid(new_oid) && + !has_object(the_repository, new_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { error("unpack should have generated %s, " "but I can't find it!", oid_to_hex(new_oid)); ret = "bad pack"; diff --git a/builtin/remote.c b/builtin/remote.c index b4baa34e66..0d6755bcb7 100644 --- a/builtin/remote.c +++ b/builtin/remote.c @@ -454,7 +454,8 @@ static int get_push_ref_states(const struct ref *remote_refs, info->status = PUSH_STATUS_UPTODATE; else if (is_null_oid(&ref->old_oid)) info->status = PUSH_STATUS_CREATE; - else if (repo_has_object_file(the_repository, &ref->old_oid) && + else if (has_object(the_repository, &ref->old_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) && ref_newer(&ref->new_oid, &ref->old_oid)) info->status = PUSH_STATUS_FASTFORWARD; else diff --git a/builtin/show-branch.c b/builtin/show-branch.c index b549d8c3f5..525b231d87 100644 --- a/builtin/show-branch.c +++ b/builtin/show-branch.c @@ -19,7 +19,7 @@ #include "date.h" #include "wildmatch.h" -static const char* show_branch_usage[] = { +static const char*const show_branch_usage[] = { N_("git show-branch [-a | --all] [-r | --remotes] [--topo-order | --date-order]\n" " [--current] [--color[=<when>] | --no-color] [--sparse]\n" " [--more=<n> | --list | --independent | --merge-base]\n" diff --git a/builtin/show-ref.c b/builtin/show-ref.c index f81209f23c..623a52a45f 100644 --- a/builtin/show-ref.c +++ b/builtin/show-ref.c @@ -35,7 +35,8 @@ static void show_one(const struct show_one_options *opts, const char *hex; struct object_id peeled; - if (!repo_has_object_file(the_repository, oid)) + if (!has_object(the_repository, oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) die("git show-ref: bad ref %s (%s)", refname, oid_to_hex(oid)); diff --git a/builtin/unpack-objects.c b/builtin/unpack-objects.c index 661be789f1..e905d5f4e1 100644 --- a/builtin/unpack-objects.c +++ b/builtin/unpack-objects.c @@ -449,7 +449,8 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size, delta_data = get_data(delta_size); if (!delta_data) return; - if (repo_has_object_file(the_repository, &base_oid)) + if (has_object(the_repository, &base_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) ; /* Ok we have this one */ else if (resolve_against_held(nr, &base_oid, delta_data, delta_size)) diff --git a/bulk-checkin.c b/bulk-checkin.c index c31c31b18d..678e2ecc2c 100644 --- a/bulk-checkin.c +++ b/bulk-checkin.c @@ -130,7 +130,8 @@ static void flush_batch_fsync(void) static int already_written(struct bulk_checkin_packfile *state, struct object_id *oid) { /* The object may already exist in the repository */ - if (repo_has_object_file(the_repository, oid)) + if (has_object(the_repository, oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return 1; /* Might want to keep the list sorted */ diff --git a/cache-tree.c b/cache-tree.c index c0e1e9ee1d..fa3858e282 100644 --- a/cache-tree.c +++ b/cache-tree.c @@ -238,7 +238,9 @@ int cache_tree_fully_valid(struct cache_tree *it) int i; if (!it) return 0; - if (it->entry_count < 0 || !repo_has_object_file(the_repository, &it->oid)) + if (it->entry_count < 0 || + has_object(the_repository, &it->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return 0; for (i = 0; i < it->subtree_nr; i++) { if (!cache_tree_fully_valid(it->down[i]->cache_tree)) @@ -289,7 +291,9 @@ static int update_one(struct cache_tree *it, } } - if (0 <= it->entry_count && repo_has_object_file(the_repository, &it->oid)) + if (0 <= it->entry_count && + has_object(the_repository, &it->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return it->entry_count; /* @@ -395,7 +399,8 @@ static int update_one(struct cache_tree *it, ce_missing_ok = mode == S_IFGITLINK || missing_ok || !must_check_existence(ce); if (is_null_oid(oid) || - (!ce_missing_ok && !repo_has_object_file(the_repository, oid))) { + (!ce_missing_ok && !has_object(the_repository, oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR))) { strbuf_release(&buffer); if (expected_missing) return -1; @@ -443,7 +448,7 @@ static int update_one(struct cache_tree *it, struct object_id oid; hash_object_file(the_hash_algo, buffer.buf, buffer.len, OBJ_TREE, &oid); - if (repo_has_object_file_with_flags(the_repository, &oid, OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (has_object(the_repository, &oid, HAS_OBJECT_RECHECK_PACKED)) oidcpy(&it->oid, &oid); else to_invalidate = 1; diff --git a/ci/install-dependencies.sh b/ci/install-dependencies.sh index da19dada2c..d061a47293 100755 --- a/ci/install-dependencies.sh +++ b/ci/install-dependencies.sh @@ -9,7 +9,7 @@ begin_group "Install dependencies" P4WHENCE=https://cdist2.perforce.com/perforce/r23.2 LFSWHENCE=https://github.com/github/git-lfs/releases/download/v$LINUX_GIT_LFS_VERSION -JGITWHENCE=https://repo.eclipse.org/content/groups/releases//org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh +JGITWHENCE=https://repo1.maven.org/maven2/org/eclipse/jgit/org.eclipse.jgit.pgm/6.8.0.202311291450-r/org.eclipse.jgit.pgm-6.8.0.202311291450-r.sh # Make sudo a no-op and execute the command directly when running as root. # While using sudo would be fine on most platforms when we are root already, @@ -71,7 +71,6 @@ ubuntu-*|i386/ubuntu-*|debian-*) chmod a+x "$CUSTOM_PATH/p4d" "$CUSTOM_PATH/p4" || { rm -f "$CUSTOM_PATH/p4" rm -f "$CUSTOM_PATH/p4d" - echo >&2 "P4 download (optional) failed" } wget --quiet \ @@ -79,16 +78,12 @@ ubuntu-*|i386/ubuntu-*|debian-*) tar -xzf "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" \ -C "$CUSTOM_PATH" --strip-components=1 \ "git-lfs-$LINUX_GIT_LFS_VERSION/git-lfs" && - rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" || { - rm -f "$CUSTOM_PATH/git-lfs" - echo >&2 "LFS download (optional) failed" - } + rm "git-lfs-linux-amd64-$LINUX_GIT_LFS_VERSION.tar.gz" || + rm -f "$CUSTOM_PATH/git-lfs" wget --quiet "$JGITWHENCE" --output-document="$CUSTOM_PATH/jgit" && - chmod a+x "$CUSTOM_PATH/jgit" || { - rm -f "$CUSTOM_PATH/jgit" - echo >&2 "JGit download (optional) failed" - } + chmod a+x "$CUSTOM_PATH/jgit" || + rm -f "$CUSTOM_PATH/jgit" ;; esac ;; @@ -151,7 +146,7 @@ then echo "$(tput setaf 6)Perforce Client Version$(tput sgr0)" p4 -V else - echo >&2 "WARNING: perforce wasn't installed, see above for clues why" + echo >&2 "::warning:: perforce wasn't installed, see above for clues why" fi if type git-lfs >/dev/null 2>&1 @@ -159,7 +154,7 @@ then echo "$(tput setaf 6)Git-LFS Version$(tput sgr0)" git-lfs version else - echo >&2 "WARNING: git-lfs wasn't installed, see above for clues why" + echo >&2 "::warning:: git-lfs wasn't installed, see above for clues why" fi if type jgit >/dev/null 2>&1 @@ -167,7 +162,7 @@ then echo "$(tput setaf 6)JGit Version$(tput sgr0)" jgit version else - echo >&2 "WARNING: JGit wasn't installed, see above for clues why" + echo >&2 "::warning:: JGit wasn't installed, see above for clues why" fi end_group "Install dependencies" diff --git a/ci/run-build-and-tests.sh b/ci/run-build-and-tests.sh index f99b7db2ee..01823fd0f1 100755 --- a/ci/run-build-and-tests.sh +++ b/ci/run-build-and-tests.sh @@ -5,11 +5,6 @@ . ${0%/*}/lib.sh -case "$CI_OS_NAME" in -windows*) cmd //c mklink //j t\\.prove "$(cygpath -aw "$cache_dir/.prove")";; -*) ln -s "$cache_dir/.prove" t/.prove;; -esac - run_tests=t case "$jobname" in @@ -56,6 +51,7 @@ case "$jobname" in --warnlevel 2 --werror \ --wrap-mode nofallback \ -Dfuzzers=true \ + -Dtest_output_directory="${TEST_OUTPUT_DIRECTORY:-$(pwd)/t}" \ $MESONFLAGS group "Build" meson compile -C build -- if test -n "$run_tests" diff --git a/ci/run-static-analysis.sh b/ci/run-static-analysis.sh index ae714e020a..9e9c72681d 100755 --- a/ci/run-static-analysis.sh +++ b/ci/run-static-analysis.sh @@ -26,7 +26,7 @@ then exit 1 fi -make hdr-check || +make check-headers || exit 1 make check-pot diff --git a/ci/run-test-slice.sh b/ci/run-test-slice.sh index e167e646f7..0444c79c02 100755 --- a/ci/run-test-slice.sh +++ b/ci/run-test-slice.sh @@ -5,11 +5,6 @@ . ${0%/*}/lib.sh -case "$CI_OS_NAME" in -windows*) cmd //c mklink //j t\\.prove "$(cygpath -aw "$cache_dir/.prove")";; -*) ln -s "$cache_dir/.prove" t/.prove;; -esac - group "Run tests" make --quiet -C t T="$(cd t && ./helper/test-tool path-utils slice-tests "$1" "$2" t[0-9]*.sh | tr '\n' ' ')" || diff --git a/compat/bswap.h b/compat/bswap.h index b34054f2bd..9e0f98e00b 100644 --- a/compat/bswap.h +++ b/compat/bswap.h @@ -35,7 +35,19 @@ static inline uint64_t default_bswap64(uint64_t val) #undef bswap32 #undef bswap64 -#if defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) +/** + * __has_builtin is available since Clang 10 and GCC 10. + * Below is a fallback for older compilers. + */ +#ifndef __has_builtin + #define __has_builtin(x) 0 +#endif + +#if __has_builtin(__builtin_bswap32) && __has_builtin(__builtin_bswap64) +#define bswap32(x) __builtin_bswap32((x)) +#define bswap64(x) __builtin_bswap64((x)) + +#elif defined(__GNUC__) && (defined(__i386__) || defined(__x86_64__)) #define bswap32 git_bswap32 static inline uint32_t git_bswap32(uint32_t x) diff --git a/compat/zlib-compat.h b/compat/zlib-compat.h index 0c60e3af33..ac08276622 100644 --- a/compat/zlib-compat.h +++ b/compat/zlib-compat.h @@ -4,8 +4,8 @@ #ifdef HAVE_ZLIB_NG # include <zlib-ng.h> -# define z_stream zng_stream -#define gz_header_s zng_gz_header_s +# define z_stream_s zng_stream_s +# define gz_header_s zng_gz_header_s # define crc32(crc, buf, len) zng_crc32(crc, buf, len) diff --git a/config.mak.uname b/config.mak.uname index db22a8fb31..7fc2c5bf8d 100644 --- a/config.mak.uname +++ b/config.mak.uname @@ -439,7 +439,11 @@ ifeq ($(uname_S),Windows) ifeq (MINGW32,$(MSYSTEM)) prefix = /mingw32 else - prefix = /mingw64 + ifeq (CLANGARM64,$(MSYSTEM)) + prefix = /clangarm64 + else + prefix = /mingw64 + endif endif # Prepend MSVC 64-bit tool-chain to PATH. # @@ -492,7 +496,7 @@ ifeq ($(uname_S),Windows) NO_POSIX_GOODIES = UnfortunatelyYes NATIVE_CRLF = YesPlease DEFAULT_HELP_FORMAT = html -ifeq (/mingw64,$(subst 32,64,$(prefix))) +ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix)))) # Move system config into top-level /etc/ ETC_GITCONFIG = ../etc/gitconfig ETC_GITATTRIBUTES = ../etc/gitattributes @@ -731,6 +735,10 @@ ifeq ($(uname_S),MINGW) prefix = /mingw64 HOST_CPU = x86_64 BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup + else ifeq (CLANGARM64,$(MSYSTEM)) + prefix = /clangarm64 + HOST_CPU = aarch64 + BASIC_LDFLAGS += -Wl,--pic-executable,-e,mainCRTStartup else COMPAT_CFLAGS += -D_USE_32BIT_TIME_T BASIC_LDFLAGS += -Wl,--large-address-aware @@ -745,8 +753,10 @@ ifeq ($(uname_S),MINGW) HAVE_LIBCHARSET_H = YesPlease USE_GETTEXT_SCHEME = fallthrough USE_LIBPCRE = YesPlease - USE_NED_ALLOCATOR = YesPlease - ifeq (/mingw64,$(subst 32,64,$(prefix))) + ifneq (CLANGARM64,$(MSYSTEM)) + USE_NED_ALLOCATOR = YesPlease + endif + ifeq (/mingw64,$(subst 32,64,$(subst clangarm,mingw,$(prefix)))) # Move system config into top-level /etc/ ETC_GITCONFIG = ../etc/gitconfig ETC_GITATTRIBUTES = ../etc/gitattributes @@ -766,79 +776,3 @@ ifeq ($(uname_S),QNX) NO_STRCASESTR = YesPlease NO_STRLCPY = YesPlease endif - -vcxproj: - # Require clean work tree - git update-index -q --refresh && \ - git diff-files --quiet && \ - git diff-index --cached --quiet HEAD -- - - # Make .vcxproj files and add them - perl contrib/buildsystems/generate -g Vcxproj - git add -f git.sln {*,*/lib,t/helper/*}/*.vcxproj - - # Generate the LinkOrCopyBuiltins.targets and LinkOrCopyRemoteHttp.targets file - (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \ - echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \ - for name in $(BUILT_INS);\ - do \ - echo ' <Copy SourceFiles="$$(OutDir)\git.exe" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \ - done && \ - echo ' </Target>' && \ - echo '</Project>') >git/LinkOrCopyBuiltins.targets - (echo '<Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003">' && \ - echo ' <Target Name="CopyBuiltins_AfterBuild" AfterTargets="AfterBuild">' && \ - for name in $(REMOTE_CURL_ALIASES); \ - do \ - echo ' <Copy SourceFiles="$$(OutDir)\'"$(REMOTE_CURL_PRIMARY)"'" DestinationFiles="$$(OutDir)\'"$$name"'" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" />'; \ - done && \ - echo ' </Target>' && \ - echo '</Project>') >git-remote-http/LinkOrCopyRemoteHttp.targets - git add -f git/LinkOrCopyBuiltins.targets git-remote-http/LinkOrCopyRemoteHttp.targets - - # Add generated headers - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(GENERATED_H) - git add -f $(GENERATED_H) - - # Add scripts - rm -f perl/perl.mak - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(SCRIPT_LIB) $(SCRIPTS) - # Strip out the sane tool path, needed only for building - sed -i '/^git_broken_path_fix ".*/d' git-sh-setup - git add -f $(SCRIPT_LIB) $(SCRIPTS) - - # Add Perl module - $(MAKE) $(LIB_PERL_GEN) - git add -f perl/build - - # Add bin-wrappers, for testing - rm -rf bin-wrappers/ - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(test_bindir_programs) - # Ensure that the GIT_EXEC_PATH is a Unix-y one, and that the absolute - # path of the repository is not hard-coded (GIT_EXEC_PATH will be set - # by test-lib.sh according to the current setup) - sed -i -e 's/^\(GIT_EXEC_PATH\)=.*/test -n "$${\1##*:*}" ||\ - \1="$$(cygpath -u "$$\1")"/' \ - -e "s|'$$(pwd)|\"\$$GIT_EXEC_PATH\"'|g" bin-wrappers/* - # Ensure that test-* helpers find the .dll files copied to top-level - sed -i 's|^PATH=.*|&:"$$GIT_EXEC_PATH"|' bin-wrappers/test-* - # We do not want to force hard-linking builtins - sed -i 's|\(git\)-\([-a-z]*\)\.exe"|\1.exe" \2|g' \ - bin-wrappers/git-{receive-pack,upload-archive} - git add -f $(test_bindir_programs) - - # Add templates - $(MAKE) -C templates - git add -f templates/boilerplates.made templates/blt/ - - # Add the translated messages - make MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 $(MOFILES) - git add -f $(MOFILES) - - # Add build options - $(MAKE) MSVC=1 SKIP_VCPKG=1 prefix=/mingw64 GIT-BUILD-OPTIONS - git add -f GIT-BUILD-OPTIONS - - # Commit the whole shebang - git commit -m "Generate Visual Studio solution" \ - -m "Auto-generated by \`$(MAKE)$(MAKEFLAGS) $@\`" diff --git a/contrib/buildsystems/Generators.pm b/contrib/buildsystems/Generators.pm deleted file mode 100644 index aa4cbaa2ad..0000000000 --- a/contrib/buildsystems/Generators.pm +++ /dev/null @@ -1,42 +0,0 @@ -package Generators; -require Exporter; - -use strict; -use File::Basename; -no strict 'refs'; -use vars qw($VERSION @AVAILABLE); - -our $VERSION = '1.00'; -our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); -@ISA = qw(Exporter); - -BEGIN { - local(*D); - my $me = $INC{"Generators.pm"}; - die "Couldn't find myself in \@INC, which is required to load the generators!" if ("$me" eq ""); - $me = dirname($me); - if (opendir(D,"$me/Generators")) { - foreach my $gen (readdir(D)) { - next unless ($gen =~ /\.pm$/); - require "${me}/Generators/$gen"; - $gen =~ s,\.pm,,; - push(@AVAILABLE, $gen); - } - closedir(D); - my $gens = join(', ', @AVAILABLE); - } - - push @EXPORT_OK, qw(available); -} - -sub available { - return @AVAILABLE; -} - -sub generate { - my ($gen, $git_dir, $out_dir, $rel_dir, %build_structure) = @_; - return eval("Generators::${gen}::generate(\$git_dir, \$out_dir, \$rel_dir, \%build_structure)") if grep(/^$gen$/, @AVAILABLE); - die "Generator \"${gen}\" is not available!\nAvailable generators are: @AVAILABLE\n"; -} - -1; diff --git a/contrib/buildsystems/Generators/QMake.pm b/contrib/buildsystems/Generators/QMake.pm deleted file mode 100644 index ff3b657e61..0000000000 --- a/contrib/buildsystems/Generators/QMake.pm +++ /dev/null @@ -1,189 +0,0 @@ -package Generators::QMake; -require Exporter; - -use strict; -use vars qw($VERSION); - -our $VERSION = '1.00'; -our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); -@ISA = qw(Exporter); - -BEGIN { - push @EXPORT_OK, qw(generate); -} - -sub generate { - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; - - my @libs = @{$build_structure{"LIBS"}}; - foreach (@libs) { - createLibProject($_, $git_dir, $out_dir, $rel_dir, %build_structure); - } - - my @apps = @{$build_structure{"APPS"}}; - foreach (@apps) { - createAppProject($_, $git_dir, $out_dir, $rel_dir, %build_structure); - } - - createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); - return 0; -} - -sub createLibProject { - my ($libname, $git_dir, $out_dir, $rel_dir, %build_structure) = @_; - print "Generate $libname lib project\n"; - $rel_dir = "../$rel_dir"; - - my $sources = join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"LIBS_${libname}_SOURCES"}}))); - my $defines = join(" \\\n\t", sort(@{$build_structure{"LIBS_${libname}_DEFINES"}})); - my $includes= join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"LIBS_${libname}_INCLUDES"}}))); - my $cflags = join(" ", sort(@{$build_structure{"LIBS_${libname}_CFLAGS"}})); - - my $cflags_debug = $cflags; - $cflags_debug =~ s/-MT/-MTd/; - $cflags_debug =~ s/-O.//; - - my $cflags_release = $cflags; - $cflags_release =~ s/-MTd/-MT/; - - my @tmp = @{$build_structure{"LIBS_${libname}_LFLAGS"}}; - my @tmp2 = (); - foreach (@tmp) { - if (/^-LTCG/) { - } elsif (/^-L/) { - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; - } - push(@tmp2, $_); - } - my $lflags = join(" ", sort(@tmp)); - - my $target = $libname; - $target =~ s/\//_/g; - $defines =~ s/-D//g; - $defines =~ s/"/\\\\"/g; - $includes =~ s/-I//g; - mkdir "$target" || die "Could not create the directory $target for lib project!\n"; - open F, ">$target/$target.pro" || die "Could not open $target/$target.pro for writing!\n"; - print F << "EOM"; -TEMPLATE = lib -TARGET = $target -DESTDIR = $rel_dir - -CONFIG -= qt -CONFIG += static - -QMAKE_CFLAGS = -QMAKE_CFLAGS_RELEASE = $cflags_release -QMAKE_CFLAGS_DEBUG = $cflags_debug -QMAKE_LIBFLAGS = $lflags - -DEFINES += \\ - $defines - -INCLUDEPATH += \\ - $includes - -SOURCES += \\ - $sources -EOM - close F; -} - -sub createAppProject { - my ($appname, $git_dir, $out_dir, $rel_dir, %build_structure) = @_; - print "Generate $appname app project\n"; - $rel_dir = "../$rel_dir"; - - my $sources = join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"APPS_${appname}_SOURCES"}}))); - my $defines = join(" \\\n\t", sort(@{$build_structure{"APPS_${appname}_DEFINES"}})); - my $includes= join(" \\\n\t", sort(map("$rel_dir/$_", @{$build_structure{"APPS_${appname}_INCLUDES"}}))); - my $cflags = join(" ", sort(@{$build_structure{"APPS_${appname}_CFLAGS"}})); - - my $cflags_debug = $cflags; - $cflags_debug =~ s/-MT/-MTd/; - $cflags_debug =~ s/-O.//; - - my $cflags_release = $cflags; - $cflags_release =~ s/-MTd/-MT/; - - my $libs; - foreach (sort(@{$build_structure{"APPS_${appname}_LIBS"}})) { - $_ =~ s/\//_/g; - $libs .= " $_"; - } - my @tmp = @{$build_structure{"APPS_${appname}_LFLAGS"}}; - my @tmp2 = (); - foreach (@tmp) { - # next if ($_ eq "-NODEFAULTLIB:MSVCRT.lib"); - if (/^-LTCG/) { - } elsif (/^-L/) { - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; - } - push(@tmp2, $_); - } - my $lflags = join(" ", sort(@tmp)); - - my $target = $appname; - $target =~ s/\.exe//; - $target =~ s/\//_/g; - $defines =~ s/-D//g; - $defines =~ s/"/\\\\"/g; - $includes =~ s/-I//g; - mkdir "$target" || die "Could not create the directory $target for app project!\n"; - open F, ">$target/$target.pro" || die "Could not open $target/$target.pro for writing!\n"; - print F << "EOM"; -TEMPLATE = app -TARGET = $target -DESTDIR = $rel_dir - -CONFIG -= qt embed_manifest_exe -CONFIG += console - -QMAKE_CFLAGS = -QMAKE_CFLAGS_RELEASE = $cflags_release -QMAKE_CFLAGS_DEBUG = $cflags_debug -QMAKE_LFLAGS = $lflags -LIBS = $libs - -DEFINES += \\ - $defines - -INCLUDEPATH += \\ - $includes - -win32:QMAKE_LFLAGS += -LIBPATH:$rel_dir -else: QMAKE_LFLAGS += -L$rel_dir - -SOURCES += \\ - $sources -EOM - close F; -} - -sub createGlueProject { - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; - my $libs = join(" \\ \n", map("\t$_|$_.pro", @{$build_structure{"LIBS"}})); - my $apps = join(" \\ \n", map("\t$_|$_.pro", @{$build_structure{"APPS"}})); - $libs =~ s/\.a//g; - $libs =~ s/\//_/g; - $libs =~ s/\|/\//g; - $apps =~ s/\.exe//g; - $apps =~ s/\//_/g; - $apps =~ s/\|/\//g; - - my $filename = $out_dir; - $filename =~ s/.*\/([^\/]+)$/$1/; - $filename =~ s/\/$//; - print "Generate glue project $filename.pro\n"; - open F, ">$filename.pro" || die "Could not open $filename.pro for writing!\n"; - print F << "EOM"; -TEMPLATE = subdirs -CONFIG += ordered -SUBDIRS += \\ -$libs \\ -$apps -EOM - close F; -} - -1; diff --git a/contrib/buildsystems/Generators/Vcproj.pm b/contrib/buildsystems/Generators/Vcproj.pm deleted file mode 100644 index 737647e76a..0000000000 --- a/contrib/buildsystems/Generators/Vcproj.pm +++ /dev/null @@ -1,579 +0,0 @@ -package Generators::Vcproj; -require Exporter; - -use strict; -use vars qw($VERSION); -use Digest::SHA qw(sha256_hex); - -our $VERSION = '1.00'; -our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); -@ISA = qw(Exporter); - -BEGIN { - push @EXPORT_OK, qw(generate); -} - -sub generate_guid ($) { - my $hex = sha256_hex($_[0]); - $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*/{$1-$2-$3-$4-$5}/; - $hex =~ tr/a-z/A-Z/; - return $hex; -} - -sub generate { - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; - my @libs = @{$build_structure{"LIBS"}}; - foreach (@libs) { - createLibProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure); - } - - my @apps = @{$build_structure{"APPS"}}; - foreach (@apps) { - createAppProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure); - } - - createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); - return 0; -} - -sub createLibProject { - my ($libname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_; - print "Generate $libname vcproj lib project\n"; - $rel_dir = "..\\$rel_dir"; - $rel_dir =~ s/\//\\/g; - - my $target = $libname; - $target =~ s/\//_/g; - $target =~ s/\.a//; - - my $uuid = generate_guid($libname); - $$build_structure{"LIBS_${target}_GUID"} = $uuid; - - my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"LIBS_${libname}_SOURCES"}})); - my @sources; - foreach (@srcs) { - $_ =~ s/\//\\/g; - push(@sources, $_); - } - my $defines = join(",", sort(@{$$build_structure{"LIBS_${libname}_DEFINES"}})); - my $includes= join(";", sort(map(""$rel_dir\\$_"", @{$$build_structure{"LIBS_${libname}_INCLUDES"}}))); - my $cflags = join(" ", sort(@{$$build_structure{"LIBS_${libname}_CFLAGS"}})); - $cflags =~ s/\"/"/g; - $cflags =~ s/</</g; - $cflags =~ s/>/>/g; - - my $cflags_debug = $cflags; - $cflags_debug =~ s/-MT/-MTd/; - $cflags_debug =~ s/-O.//; - - my $cflags_release = $cflags; - $cflags_release =~ s/-MTd/-MT/; - - my @tmp = @{$$build_structure{"LIBS_${libname}_LFLAGS"}}; - my @tmp2 = (); - foreach (@tmp) { - if (/^-LTCG/) { - } elsif (/^-L/) { - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; - } - push(@tmp2, $_); - } - my $lflags = join(" ", sort(@tmp)); - - $defines =~ s/-D//g; - $defines =~ s/\"/\\"/g; - $defines =~ s/</</g; - $defines =~ s/>/>/g; - $defines =~ s/\'//g; - $includes =~ s/-I//g; - mkdir "$target" || die "Could not create the directory $target for lib project!\n"; - open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n"; - binmode F, ":crlf"; - print F << "EOM"; -<?xml version="1.0" encoding = "Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="$target" - ProjectGUID="$uuid"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="$rel_dir" - ConfigurationType="4" - CharacterSet="0" - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalOptions="$cflags_debug" - Optimization="0" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="$includes" - PreprocessorDefinitions="WIN32,_DEBUG,$defines" - MinimalRebuild="true" - RuntimeLibrary="1" - UsePrecompiledHeader="0" - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - SuppressStartupBanner="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="$rel_dir" - ConfigurationType="4" - CharacterSet="0" - WholeProgramOptimization="1" - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalOptions="$cflags_release" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="$includes" - PreprocessorDefinitions="WIN32,NDEBUG,$defines" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLibrarianTool" - SuppressStartupBanner="true" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> -EOM - foreach(@sources) { - print F << "EOM"; - <File - RelativePath="$_"/> -EOM - } - print F << "EOM"; - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> -EOM - close F; -} - -sub createAppProject { - my ($appname, $git_dir, $out_dir, $rel_dir, $build_structure) = @_; - print "Generate $appname vcproj app project\n"; - $rel_dir = "..\\$rel_dir"; - $rel_dir =~ s/\//\\/g; - - my $target = $appname; - $target =~ s/\//_/g; - $target =~ s/\.exe//; - - my $uuid = generate_guid($appname); - $$build_structure{"APPS_${target}_GUID"} = $uuid; - - my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"APPS_${appname}_SOURCES"}})); - my @sources; - foreach (@srcs) { - $_ =~ s/\//\\/g; - push(@sources, $_); - } - my $defines = join(",", sort(@{$$build_structure{"APPS_${appname}_DEFINES"}})); - my $includes= join(";", sort(map(""$rel_dir\\$_"", @{$$build_structure{"APPS_${appname}_INCLUDES"}}))); - my $cflags = join(" ", sort(@{$$build_structure{"APPS_${appname}_CFLAGS"}})); - $cflags =~ s/\"/"/g; - $cflags =~ s/</</g; - $cflags =~ s/>/>/g; - - my $cflags_debug = $cflags; - $cflags_debug =~ s/-MT/-MTd/; - $cflags_debug =~ s/-O.//; - - my $cflags_release = $cflags; - $cflags_release =~ s/-MTd/-MT/; - - my $libs; - foreach (sort(@{$$build_structure{"APPS_${appname}_LIBS"}})) { - $_ =~ s/\//_/g; - $libs .= " $_"; - } - my @tmp = @{$$build_structure{"APPS_${appname}_LFLAGS"}}; - my @tmp2 = (); - foreach (@tmp) { - if (/^-LTCG/) { - } elsif (/^-L/) { - $_ =~ s/^-L/-LIBPATH:$rel_dir\//; - } - push(@tmp2, $_); - } - my $lflags = join(" ", sort(@tmp)) . " -LIBPATH:$rel_dir"; - - $defines =~ s/-D//g; - $defines =~ s/\"/\\"/g; - $defines =~ s/</</g; - $defines =~ s/>/>/g; - $defines =~ s/\'//g; - $defines =~ s/\\\\/\\/g; - $includes =~ s/-I//g; - mkdir "$target" || die "Could not create the directory $target for lib project!\n"; - open F, ">$target/$target.vcproj" || die "Could not open $target/$target.pro for writing!\n"; - binmode F, ":crlf"; - print F << "EOM"; -<?xml version="1.0" encoding = "Windows-1252"?> -<VisualStudioProject - ProjectType="Visual C++" - Version="9,00" - Name="$target" - ProjectGUID="$uuid"> - <Platforms> - <Platform - Name="Win32"/> - </Platforms> - <ToolFiles> - </ToolFiles> - <Configurations> - <Configuration - Name="Debug|Win32" - OutputDirectory="$rel_dir" - ConfigurationType="1" - CharacterSet="0" - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalOptions="$cflags_debug" - Optimization="0" - InlineFunctionExpansion="1" - AdditionalIncludeDirectories="$includes" - PreprocessorDefinitions="WIN32,_DEBUG,$defines" - MinimalRebuild="true" - RuntimeLibrary="1" - UsePrecompiledHeader="0" - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="$libs" - AdditionalOptions="$lflags" - LinkIncremental="2" - GenerateDebugInformation="true" - SubSystem="1" - TargetMachine="1" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - <Configuration - Name="Release|Win32" - OutputDirectory="$rel_dir" - ConfigurationType="1" - CharacterSet="0" - WholeProgramOptimization="1" - IntermediateDirectory="\$(ProjectDir)\$(ConfigurationName)" - > - <Tool - Name="VCPreBuildEventTool" - /> - <Tool - Name="VCCustomBuildTool" - /> - <Tool - Name="VCXMLDataGeneratorTool" - /> - <Tool - Name="VCMIDLTool" - /> - <Tool - Name="VCCLCompilerTool" - AdditionalOptions="$cflags_release" - Optimization="2" - InlineFunctionExpansion="1" - EnableIntrinsicFunctions="true" - AdditionalIncludeDirectories="$includes" - PreprocessorDefinitions="WIN32,NDEBUG,$defines" - RuntimeLibrary="0" - EnableFunctionLevelLinking="true" - UsePrecompiledHeader="0" - ProgramDataBaseFileName="\$(IntDir)\\\$(TargetName).pdb" - WarningLevel="3" - DebugInformationFormat="3" - /> - <Tool - Name="VCManagedResourceCompilerTool" - /> - <Tool - Name="VCResourceCompilerTool" - /> - <Tool - Name="VCPreLinkEventTool" - /> - <Tool - Name="VCLinkerTool" - AdditionalDependencies="$libs" - AdditionalOptions="$lflags" - LinkIncremental="1" - GenerateDebugInformation="true" - SubSystem="1" - TargetMachine="1" - OptimizeReferences="2" - EnableCOMDATFolding="2" - /> - <Tool - Name="VCALinkTool" - /> - <Tool - Name="VCXDCMakeTool" - /> - <Tool - Name="VCBscMakeTool" - /> - <Tool - Name="VCFxCopTool" - /> - <Tool - Name="VCPostBuildEventTool" - /> - </Configuration> - </Configurations> - <Files> - <Filter - Name="Source Files" - Filter="cpp;c;cxx;def;odl;idl;hpj;bat;asm;asmx" - UniqueIdentifier="{4FC737F1-C7A5-4376-A066-2A32D752A2FF}"> -EOM - foreach(@sources) { - print F << "EOM"; - <File - RelativePath="$_"/> -EOM - } - print F << "EOM"; - </Filter> - </Files> - <Globals> - </Globals> -</VisualStudioProject> -EOM - close F; -} - -sub createGlueProject { - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; - print "Generate solutions file\n"; - $rel_dir = "..\\$rel_dir"; - $rel_dir =~ s/\//\\/g; - my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 10.00\n# Visual Studio 2008\n"; - my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = "; - my $SLN_POST = "\nEndProject\n"; - - my @libs = @{$build_structure{"LIBS"}}; - my @tmp; - foreach (@libs) { - $_ =~ s/\//_/g; - $_ =~ s/\.a//; - push(@tmp, $_); - } - @libs = @tmp; - - my @apps = @{$build_structure{"APPS"}}; - @tmp = (); - foreach (@apps) { - $_ =~ s/\//_/g; - $_ =~ s/\.exe//; - if ($_ eq "git" ) { - unshift(@tmp, $_); - } else { - push(@tmp, $_); - } - } - @apps = @tmp; - - open F, ">git.sln" || die "Could not open git.sln for writing!\n"; - binmode F, ":crlf"; - print F "$SLN_HEAD"; - - my $uuid_libgit = $build_structure{"LIBS_libgit_GUID"}; - my $uuid_xdiff_lib = $build_structure{"LIBS_xdiff_lib_GUID"}; - foreach (@apps) { - my $appname = $_; - my $uuid = $build_structure{"APPS_${appname}_GUID"}; - print F "$SLN_PRE"; - print F "\"${appname}\", \"${appname}\\${appname}.vcproj\", \"${uuid}\"\n"; - print F " ProjectSection(ProjectDependencies) = postProject\n"; - print F " ${uuid_libgit} = ${uuid_libgit}\n"; - print F " ${uuid_xdiff_lib} = ${uuid_xdiff_lib}\n"; - print F " EndProjectSection"; - print F "$SLN_POST"; - } - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; - print F "$SLN_PRE"; - print F "\"${libname}\", \"${libname}\\${libname}.vcproj\", \"${uuid}\""; - print F "$SLN_POST"; - } - - print F << "EOM"; -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|Win32 = Debug|Win32 - Release|Win32 = Release|Win32 - EndGlobalSection -EOM - print F << "EOM"; - GlobalSection(ProjectConfigurationPlatforms) = postSolution -EOM - foreach (@apps) { - my $appname = $_; - my $uuid = $build_structure{"APPS_${appname}_GUID"}; - print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; - print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; - print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; - print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n"; - } - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; - print F "\t\t${uuid}.Debug|Win32.ActiveCfg = Debug|Win32\n"; - print F "\t\t${uuid}.Debug|Win32.Build.0 = Debug|Win32\n"; - print F "\t\t${uuid}.Release|Win32.ActiveCfg = Release|Win32\n"; - print F "\t\t${uuid}.Release|Win32.Build.0 = Release|Win32\n"; - } - - print F << "EOM"; - EndGlobalSection -EndGlobal -EOM - close F; -} - -1; diff --git a/contrib/buildsystems/Generators/Vcxproj.pm b/contrib/buildsystems/Generators/Vcxproj.pm deleted file mode 100644 index b2e68a1671..0000000000 --- a/contrib/buildsystems/Generators/Vcxproj.pm +++ /dev/null @@ -1,402 +0,0 @@ -package Generators::Vcxproj; -require Exporter; - -use strict; -use vars qw($VERSION); -use Digest::SHA qw(sha256_hex); - -our $VERSION = '1.00'; -our(@ISA, @EXPORT, @EXPORT_OK, @AVAILABLE); -@ISA = qw(Exporter); - -BEGIN { - push @EXPORT_OK, qw(generate); -} - -sub generate_guid ($) { - my $hex = sha256_hex($_[0]); - $hex =~ s/^(.{8})(.{4})(.{4})(.{4})(.{12}).*/{$1-$2-$3-$4-$5}/; - $hex =~ tr/a-z/A-Z/; - return $hex; -} - -sub generate { - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; - my @libs = @{$build_structure{"LIBS"}}; - foreach (@libs) { - createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 1); - } - - my @apps = @{$build_structure{"APPS"}}; - foreach (@apps) { - createProject($_, $git_dir, $out_dir, $rel_dir, \%build_structure, 0); - } - - createGlueProject($git_dir, $out_dir, $rel_dir, %build_structure); - return 0; -} - -sub createProject { - my ($name, $git_dir, $out_dir, $rel_dir, $build_structure, $static_library) = @_; - my $label = $static_library ? "lib" : "app"; - my $prefix = $static_library ? "LIBS_" : "APPS_"; - my $config_type = $static_library ? "StaticLibrary" : "Application"; - print "Generate $name vcxproj $label project\n"; - my $cdup = $name; - $cdup =~ s/[^\/]+/../g; - $cdup =~ s/\//\\/g; - $rel_dir = $rel_dir eq "." ? $cdup : "$cdup\\$rel_dir"; - $rel_dir =~ s/\//\\/g; - - my $target = $name; - if ($static_library) { - $target =~ s/\.a//; - } else { - $target =~ s/\.exe//; - } - - my $uuid = generate_guid($name); - $$build_structure{"$prefix${target}_GUID"} = $uuid; - my $vcxproj = $target; - $vcxproj =~ s/(.*\/)?(.*)/$&\/$2.vcxproj/; - $vcxproj =~ s/([^\/]*)(\/lib)\/(lib.vcxproj)/$1$2\/$1_$3/; - $$build_structure{"$prefix${target}_VCXPROJ"} = $vcxproj; - - my @srcs = sort(map("$rel_dir\\$_", @{$$build_structure{"$prefix${name}_SOURCES"}})); - my @sources; - foreach (@srcs) { - $_ =~ s/\//\\/g; - push(@sources, $_); - } - my $defines = join(";", sort(@{$$build_structure{"$prefix${name}_DEFINES"}})); - my $includes= join(";", sort(map { s/^-I//; s/\//\\/g; File::Spec->file_name_is_absolute($_) ? $_ : "$rel_dir\\$_" } @{$$build_structure{"$prefix${name}_INCLUDES"}})); - my $cflags = join(" ", sort(map { s/^-[GLMOWZ].*//; s/.* .*/"$&"/; $_; } @{$$build_structure{"$prefix${name}_CFLAGS"}})); - $cflags =~ s/</</g; - $cflags =~ s/>/>/g; - - my $libs_release = "\n "; - my $libs_debug = "\n "; - if (!$static_library && $name ne 'headless-git') { - $libs_release = join(";", sort(grep /^(?!libgit\.lib|xdiff\/lib\.lib|vcs-svn\/lib\.lib|reftable\/libreftable\.lib)/, @{$$build_structure{"$prefix${name}_LIBS"}})); - $libs_debug = $libs_release; - $libs_debug =~ s/zlib\.lib/zlibd\.lib/g; - $libs_debug =~ s/libexpat\.lib/libexpatd\.lib/g; - $libs_debug =~ s/libcurl\.lib/libcurl-d\.lib/g; - } - - $defines =~ s/-D//g; - $defines =~ s/</</g; - $defines =~ s/>/>/g; - $defines =~ s/\'//g; - - die "Could not create the directory $target for $label project!\n" unless (-d "$target" || mkdir "$target"); - - open F, ">$vcxproj" or die "Could not open $vcxproj for writing!\n"; - binmode F, ":crlf :utf8"; - print F chr(0xFEFF); - print F << "EOM"; -<?xml version="1.0" encoding="utf-8"?> -<Project DefaultTargets="Build" ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003"> - <ItemGroup Label="ProjectConfigurations"> - <ProjectConfiguration Include="Debug|Win32"> - <Configuration>Debug</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|Win32"> - <Configuration>Release</Configuration> - <Platform>Win32</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Debug|x64"> - <Configuration>Debug</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - <ProjectConfiguration Include="Release|x64"> - <Configuration>Release</Configuration> - <Platform>x64</Platform> - </ProjectConfiguration> - </ItemGroup> - <PropertyGroup Label="Globals"> - <ProjectGuid>$uuid</ProjectGuid> - <Keyword>Win32Proj</Keyword> - <VCPKGArch Condition="'\$(Platform)'=='Win32'">x86-windows</VCPKGArch> - <VCPKGArch Condition="'\$(Platform)'!='Win32'">x64-windows</VCPKGArch> - <VCPKGArchDirectory>$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)</VCPKGArchDirectory> - <VCPKGBinDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\bin</VCPKGBinDirectory> - <VCPKGLibDirectory Condition="'\$(Configuration)'=='Debug'">\$(VCPKGArchDirectory)\\debug\\lib</VCPKGLibDirectory> - <VCPKGBinDirectory Condition="'\$(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\bin</VCPKGBinDirectory> - <VCPKGLibDirectory Condition="'\$(Configuration)'!='Debug'">\$(VCPKGArchDirectory)\\lib</VCPKGLibDirectory> - <VCPKGIncludeDirectory>\$(VCPKGArchDirectory)\\include</VCPKGIncludeDirectory> - <VCPKGLibs Condition="'\$(Configuration)'=='Debug'">$libs_debug</VCPKGLibs> - <VCPKGLibs Condition="'\$(Configuration)'!='Debug'">$libs_release</VCPKGLibs> - </PropertyGroup> - <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.Default.props" /> - <PropertyGroup Condition="'\$(Configuration)'=='Debug'" Label="Configuration"> - <UseDebugLibraries>true</UseDebugLibraries> - <LinkIncremental>true</LinkIncremental> - </PropertyGroup> - <PropertyGroup Condition="'\$(Configuration)'=='Release'" Label="Configuration"> - <UseDebugLibraries>false</UseDebugLibraries> - <WholeProgramOptimization>true</WholeProgramOptimization> - </PropertyGroup> - <PropertyGroup> - <ConfigurationType>$config_type</ConfigurationType> - <PlatformToolset>v140</PlatformToolset> - <!-- <CharacterSet>UTF-8</CharacterSet> --> - <OutDir>..\\</OutDir> - <!-- <IntDir>\$(ProjectDir)\$(Configuration)\\</IntDir> --> - </PropertyGroup> - <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.props" /> - <ImportGroup Label="ExtensionSettings"> - </ImportGroup> - <ImportGroup Label="Shared"> - </ImportGroup> - <ImportGroup Label="PropertySheets"> - <Import Project="\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props" Condition="exists('\$(UserRootDir)\\Microsoft.Cpp.\$(Platform).user.props')" Label="LocalAppDataPlatform" /> - </ImportGroup> - <PropertyGroup Label="UserMacros" /> - <PropertyGroup> - <GenerateManifest>false</GenerateManifest> - <EnableManagedIncrementalBuild>true</EnableManagedIncrementalBuild> - </PropertyGroup> - <ItemDefinitionGroup> - <ClCompile> - <AdditionalOptions>$cflags %(AdditionalOptions)</AdditionalOptions> - <AdditionalIncludeDirectories>$cdup;$cdup\\compat;$cdup\\compat\\regex;$cdup\\compat\\win32;$cdup\\compat\\poll;$cdup\\compat\\vcbuild\\include;\$(VCPKGIncludeDirectory);%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories> - <EnableParallelCodeGeneration /> - <InlineFunctionExpansion>OnlyExplicitInline</InlineFunctionExpansion> - <PrecompiledHeader /> - <DebugInformationFormat>ProgramDatabase</DebugInformationFormat> - </ClCompile> - <Lib> - <SuppressStartupBanner>true</SuppressStartupBanner> - </Lib> - <Link> - <AdditionalLibraryDirectories>\$(VCPKGLibDirectory);%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> - <AdditionalDependencies>\$(VCPKGLibs);\$(AdditionalDependencies)</AdditionalDependencies> - <AdditionalOptions>invalidcontinue.obj %(AdditionalOptions)</AdditionalOptions> - <EntryPointSymbol>wmainCRTStartup</EntryPointSymbol> - <ManifestFile>$cdup\\compat\\win32\\git.manifest</ManifestFile> - <SubSystem>Console</SubSystem> - </Link> -EOM - if ($target eq 'libgit') { - print F << "EOM"; - <PreBuildEvent Condition="!Exists('$cdup\\compat\\vcbuild\\vcpkg\\installed\\\$(VCPKGArch)\\include\\openssl\\ssl.h')"> - <Message>Initialize VCPKG</Message> - <Command>del "$cdup\\compat\\vcbuild\\vcpkg"</Command> - <Command>call "$cdup\\compat\\vcbuild\\vcpkg_install.bat"</Command> - </PreBuildEvent> -EOM - } - print F << "EOM"; - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'\$(Platform)'=='Win32'"> - <Link> - <TargetMachine>MachineX86</TargetMachine> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'\$(Configuration)'=='Debug'"> - <ClCompile> - <Optimization>Disabled</Optimization> - <PreprocessorDefinitions>WIN32;_DEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - </Link> - </ItemDefinitionGroup> - <ItemDefinitionGroup Condition="'\$(Configuration)'=='Release'"> - <ClCompile> - <Optimization>MaxSpeed</Optimization> - <IntrinsicFunctions>true</IntrinsicFunctions> - <PreprocessorDefinitions>WIN32;NDEBUG;$defines;%(PreprocessorDefinitions)</PreprocessorDefinitions> - <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary> - <FunctionLevelLinking>true</FunctionLevelLinking> - <FavorSizeOrSpeed>Speed</FavorSizeOrSpeed> - </ClCompile> - <Link> - <GenerateDebugInformation>true</GenerateDebugInformation> - <EnableCOMDATFolding>true</EnableCOMDATFolding> - <OptimizeReferences>true</OptimizeReferences> - </Link> - </ItemDefinitionGroup> - <ItemGroup> -EOM - foreach(@sources) { - print F << "EOM"; - <ClCompile Include="$_" /> -EOM - } - print F << "EOM"; - </ItemGroup> -EOM - if ((!$static_library || $target =~ 'vcs-svn' || $target =~ 'xdiff') && !($name =~ /headless-git/)) { - my $uuid_libgit = $$build_structure{"LIBS_libgit_GUID"}; - my $uuid_libreftable = $$build_structure{"LIBS_reftable/libreftable_GUID"}; - my $uuid_xdiff_lib = $$build_structure{"LIBS_xdiff/lib_GUID"}; - - print F << "EOM"; - <ItemGroup> - <ProjectReference Include="$cdup\\libgit\\libgit.vcxproj"> - <Project>$uuid_libgit</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> -EOM - if (!($name =~ /xdiff|libreftable/)) { - print F << "EOM"; - <ProjectReference Include="$cdup\\reftable\\libreftable\\libreftable.vcxproj"> - <Project>$uuid_libreftable</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> -EOM - } - if (!($name =~ 'xdiff')) { - print F << "EOM"; - <ProjectReference Include="$cdup\\xdiff\\lib\\xdiff_lib.vcxproj"> - <Project>$uuid_xdiff_lib</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> -EOM - } - if ($name =~ /(test-(line-buffer|svn-fe)|^git-remote-testsvn)\.exe$/) { - my $uuid_vcs_svn_lib = $$build_structure{"LIBS_vcs-svn/lib_GUID"}; - print F << "EOM"; - <ProjectReference Include="$cdup\\vcs-svn\\lib\\vcs-svn_lib.vcxproj"> - <Project>$uuid_vcs_svn_lib</Project> - <ReferenceOutputAssembly>false</ReferenceOutputAssembly> - </ProjectReference> -EOM - } - print F << "EOM"; - </ItemGroup> -EOM - } - print F << "EOM"; - <Import Project="\$(VCTargetsPath)\\Microsoft.Cpp.targets" /> -EOM - if (!$static_library) { - print F << "EOM"; - <Target Name="${target}_AfterBuild" AfterTargets="AfterBuild"> - <ItemGroup> - <DLLsAndPDBs Include="\$(VCPKGBinDirectory)\\*.dll;\$(VCPKGBinDirectory)\\*.pdb" /> - </ItemGroup> - <Copy SourceFiles="@(DLLsAndPDBs)" DestinationFolder="\$(OutDir)" SkipUnchangedFiles="true" UseHardlinksIfPossible="true" /> - <MakeDir Directories="..\\templates\\blt\\branches" /> - </Target> -EOM - } - if ($target eq 'git') { - print F " <Import Project=\"LinkOrCopyBuiltins.targets\" />\n"; - } - if ($target eq 'git-remote-http') { - print F " <Import Project=\"LinkOrCopyRemoteHttp.targets\" />\n"; - } - print F << "EOM"; -</Project> -EOM - close F; -} - -sub createGlueProject { - my ($git_dir, $out_dir, $rel_dir, %build_structure) = @_; - print "Generate solutions file\n"; - $rel_dir = "..\\$rel_dir"; - $rel_dir =~ s/\//\\/g; - my $SLN_HEAD = "Microsoft Visual Studio Solution File, Format Version 11.00\n# Visual Studio 2010\n"; - my $SLN_PRE = "Project(\"{8BC9CEB8-8B4A-11D0-8D11-00A0C91BC942}\") = "; - my $SLN_POST = "\nEndProject\n"; - - my @libs = @{$build_structure{"LIBS"}}; - my @tmp; - foreach (@libs) { - $_ =~ s/\.a//; - push(@tmp, $_); - } - @libs = @tmp; - - my @apps = @{$build_structure{"APPS"}}; - @tmp = (); - foreach (@apps) { - $_ =~ s/\.exe//; - if ($_ eq "git" ) { - unshift(@tmp, $_); - } else { - push(@tmp, $_); - } - } - @apps = @tmp; - - open F, ">git.sln" || die "Could not open git.sln for writing!\n"; - binmode F, ":crlf :utf8"; - print F chr(0xFEFF); - print F "$SLN_HEAD"; - - foreach (@apps) { - my $appname = $_; - my $uuid = $build_structure{"APPS_${appname}_GUID"}; - print F "$SLN_PRE"; - my $vcxproj = $build_structure{"APPS_${appname}_VCXPROJ"}; - $vcxproj =~ s/\//\\/g; - $appname =~ s/.*\///; - print F "\"${appname}\", \"${vcxproj}\", \"${uuid}\""; - print F "$SLN_POST"; - } - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; - print F "$SLN_PRE"; - my $vcxproj = $build_structure{"LIBS_${libname}_VCXPROJ"}; - $vcxproj =~ s/\//\\/g; - $libname =~ s/\//_/g; - print F "\"${libname}\", \"${vcxproj}\", \"${uuid}\""; - print F "$SLN_POST"; - } - - print F << "EOM"; -Global - GlobalSection(SolutionConfigurationPlatforms) = preSolution - Debug|x64 = Debug|x64 - Debug|x86 = Debug|x86 - Release|x64 = Release|x64 - Release|x86 = Release|x86 - EndGlobalSection -EOM - print F << "EOM"; - GlobalSection(ProjectConfigurationPlatforms) = postSolution -EOM - foreach (@apps) { - my $appname = $_; - my $uuid = $build_structure{"APPS_${appname}_GUID"}; - print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n"; - print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n"; - print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n"; - print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n"; - print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n"; - print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n"; - print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n"; - print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n"; - } - foreach (@libs) { - my $libname = $_; - my $uuid = $build_structure{"LIBS_${libname}_GUID"}; - print F "\t\t${uuid}.Debug|x64.ActiveCfg = Debug|x64\n"; - print F "\t\t${uuid}.Debug|x64.Build.0 = Debug|x64\n"; - print F "\t\t${uuid}.Debug|x86.ActiveCfg = Debug|Win32\n"; - print F "\t\t${uuid}.Debug|x86.Build.0 = Debug|Win32\n"; - print F "\t\t${uuid}.Release|x64.ActiveCfg = Release|x64\n"; - print F "\t\t${uuid}.Release|x64.Build.0 = Release|x64\n"; - print F "\t\t${uuid}.Release|x86.ActiveCfg = Release|Win32\n"; - print F "\t\t${uuid}.Release|x86.Build.0 = Release|Win32\n"; - } - - print F << "EOM"; - EndGlobalSection - GlobalSection(SolutionProperties) = preSolution - HideSolutionNode = FALSE - EndGlobalSection -EndGlobal -EOM - close F; -} - -1; diff --git a/contrib/buildsystems/engine.pl b/contrib/buildsystems/engine.pl deleted file mode 100755 index 069be7e4be..0000000000 --- a/contrib/buildsystems/engine.pl +++ /dev/null @@ -1,395 +0,0 @@ -#!/usr/bin/perl -w -###################################################################### -# Do not call this script directly! -# -# The generate script ensures that @INC is correct before the engine -# is executed. -# -# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> -###################################################################### -use strict; -use File::Basename; -use File::Spec; -use Cwd; -use Generators; -use Text::ParseWords; - -my (%build_structure, %compile_options, @makedry); -my $out_dir = getcwd(); -my $git_dir = $out_dir; -$git_dir =~ s=\\=/=g; -$git_dir = dirname($git_dir) while (!-e "$git_dir/git.c" && "$git_dir" ne ""); -die "Couldn't find Git repo" if ("$git_dir" eq ""); - -my @gens = Generators::available(); -my $gen = "Vcproj"; - -sub showUsage -{ - my $genlist = join(', ', @gens); - print << "EOM"; -generate usage: - -g <GENERATOR> --gen <GENERATOR> Specify the buildsystem generator (default: $gen) - Available: $genlist - -o <PATH> --out <PATH> Specify output directory generation (default: .) - --make-out <PATH> Write the output of GNU Make into a file - -i <FILE> --in <FILE> Specify input file, instead of running GNU Make - -h,-? --help This help -EOM - exit 0; -} - -# Parse command-line options -my $make_out; -while (@ARGV) { - my $arg = shift @ARGV; - if ("$arg" eq "-h" || "$arg" eq "--help" || "$arg" eq "-?") { - showUsage(); - exit(0); - } elsif("$arg" eq "--out" || "$arg" eq "-o") { - $out_dir = shift @ARGV; - } elsif("$arg" eq "--make-out") { - $make_out = shift @ARGV; - } elsif("$arg" eq "--gen" || "$arg" eq "-g") { - $gen = shift @ARGV; - } elsif("$arg" eq "--in" || "$arg" eq "-i") { - my $infile = shift @ARGV; - open(F, "<$infile") || die "Couldn't open file $infile"; - @makedry = <F>; - close(F); - } else { - die "Unknown option: " . $arg; - } -} - -# NOT using File::Spec->rel2abs($path, $base) here, as -# it fails badly for me in the msysgit environment -$git_dir = File::Spec->rel2abs($git_dir); -$out_dir = File::Spec->rel2abs($out_dir); -my $rel_dir = makeOutRel2Git($git_dir, $out_dir); - -# Print some information so the user feels informed -print << "EOM"; ------ -Generator: $gen -Git dir: $git_dir -Out dir: $out_dir ------ -Running GNU Make to figure out build structure... -EOM - -# Pipe a make --dry-run into a variable, if not already loaded from file -# Capture the make dry stderr to file for review (will be empty for a release build). - -my $ErrsFile = "msvc-build-makedryerrors.txt"; -@makedry = `make -C $git_dir -n MSVC=1 SKIP_VCPKG=1 V=1 2>$ErrsFile` -if !@makedry; -# test for an empty Errors file and remove it -unlink $ErrsFile if -f -z $ErrsFile; - -if (defined $make_out) { - open OUT, ">" . $make_out; - print OUT @makedry; - close OUT; -} - -# Parse the make output into usable info -parseMakeOutput(); - -# Finally, ask the generator to start generating.. -Generators::generate($gen, $git_dir, $out_dir, $rel_dir, %build_structure); - -# main flow ends here -# ------------------------------------------------------------------------------------------------- - - -# 1) path: /foo/bar/baz 2) path: /foo/bar/baz 3) path: /foo/bar/baz -# base: /foo/bar/baz/temp base: /foo/bar base: /tmp -# rel: .. rel: baz rel: ../foo/bar/baz -sub makeOutRel2Git -{ - my ($path, $base) = @_; - my $rel; - if ("$path" eq "$base") { - return "."; - } elsif ($base =~ /^$path/) { - # case 1 - my $tmp = $base; - $tmp =~ s/^$path//; - foreach (split('/', $tmp)) { - $rel .= "../" if ("$_" ne ""); - } - } elsif ($path =~ /^$base/) { - # case 2 - $rel = $path; - $rel =~ s/^$base//; - $rel = "./$rel"; - } else { - my $tmp = $base; - foreach (split('/', $tmp)) { - $rel .= "../" if ("$_" ne ""); - } - $rel .= $path; - } - $rel =~ s/\/\//\//g; # simplify - $rel =~ s/\/$//; # don't end with / - return $rel; -} - -sub parseMakeOutput -{ - print "Parsing GNU Make output to figure out build structure...\n"; - my $line = 0; - while (my $text = shift @makedry) { - my $ate_next; - do { - $ate_next = 0; - $line++; - chomp $text; - chop $text if ($text =~ /\r$/); - if ($text =~ /\\$/) { - $text =~ s/\\$//; - $text .= shift @makedry; - $ate_next = 1; - } - } while($ate_next); - - if ($text =~ /^test /) { - # options to test (eg -o) may be mistaken for linker options - next; - } - - if ($text =~ /^(mkdir|msgfmt) /) { - # options to the Portable Object translations - # the line "mkdir ... && msgfmt ..." contains no linker options - next; - } - - if($text =~ / -c /) { - # compilation - handleCompileLine($text, $line); - - } elsif ($text =~ / -o /) { - # linking executable - handleLinkLine($text, $line); - - } elsif ($text =~ /\.o / && $text =~ /\.a /) { - # libifying - handleLibLine($text, $line); -# -# } elsif ($text =~ /^cp /) { -# # copy file around -# -# } elsif ($text =~ /^rm -f /) { -# # shell command -# -# } elsif ($text =~ /^make[ \[]/) { -# # make output -# -# } elsif ($text =~ /^echo /) { -# # echo to file -# -# } elsif ($text =~ /^if /) { -# # shell conditional -# -# } elsif ($text =~ /^tclsh /) { -# # translation stuff -# -# } elsif ($text =~ /^umask /) { -# # handling boilerplates -# -# } elsif ($text =~ /\$\(\:\)/) { -# # ignore -# -# } elsif ($text =~ /^FLAGS=/) { -# # flags check for dependencies -# -# } elsif ($text =~ /^'\/usr\/bin\/perl' -MError -e/) { -# # perl commands for copying files -# -# } elsif ($text =~ /generate-cmdlist\.sh/) { -# # command for generating list of commands -# -# } elsif ($text =~ /new locations or Tcl/) { -# # command for detecting Tcl/Tk changes -# -# } elsif ($text =~ /mkdir -p/) { -# # command creating path -# -# } elsif ($text =~ /: no custom templates yet/) { -# # whatever -# -# } else { -# print "Unhandled (line: $line): $text\n"; - } - } - -# use Data::Dumper; -# print "Parsed build structure:\n"; -# print Dumper(%build_structure); -} - -# variables for the compilation part of each step -my (@defines, @incpaths, @cflags, @sources); - -sub clearCompileStep -{ - @defines = (); - @incpaths = (); - @cflags = (); - @sources = (); -} - -sub removeDuplicates -{ - my (%dupHash, $entry); - %dupHash = map { $_, 1 } @defines; - @defines = keys %dupHash; - - %dupHash = map { $_, 1 } @incpaths; - @incpaths = keys %dupHash; - - %dupHash = map { $_, 1 } @cflags; - @cflags = keys %dupHash; -} - -sub handleCompileLine -{ - my ($line, $lineno) = @_; - my @parts = shellwords($line); - my $sourcefile; - shift(@parts); # ignore cmd - while (my $part = shift @parts) { - if ("$part" eq "-o") { - # ignore object file - shift @parts; - } elsif ("$part" eq "-c") { - # ignore compile flag - } elsif ("$part" eq "-c") { - } elsif ($part =~ /^.?-I/) { - push(@incpaths, $part); - } elsif ($part =~ /^.?-D/) { - push(@defines, $part); - } elsif ($part =~ /^-/) { - push(@cflags, $part); - } elsif ($part =~ /\.(c|cc|cpp)$/) { - $sourcefile = $part; - } else { - die "Unhandled compiler option @ line $lineno: $part"; - } - } - @{$compile_options{"${sourcefile}_CFLAGS"}} = @cflags; - @{$compile_options{"${sourcefile}_DEFINES"}} = @defines; - @{$compile_options{"${sourcefile}_INCPATHS"}} = @incpaths; - clearCompileStep(); -} - -sub handleLibLine -{ - my ($line, $lineno) = @_; - my (@objfiles, @lflags, $libout, $part); - # kill cmd and rm 'prefix' - $line =~ s/^rm -f .* && .* rcs //; - my @parts = shellwords($line); - while ($part = shift @parts) { - if ($part =~ /^-/) { - push(@lflags, $part); - } elsif ($part =~ /\.(o|obj)$/) { - push(@objfiles, $part); - } elsif ($part =~ /\.(a|lib)$/) { - $libout = $part; - $libout =~ s/\.a$//; - } else { - die "Unhandled lib option @ line $lineno: $part"; - } - } -# print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n"; -# exit(1); - foreach (@objfiles) { - my $sourcefile = $_; - $sourcefile =~ s/\.o$/.c/; - push(@sources, $sourcefile); - push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}}); - push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}}); - push(@incpaths, @{$compile_options{"${sourcefile}_INCPATHS"}}); - } - removeDuplicates(); - - push(@{$build_structure{"LIBS"}}, $libout); - @{$build_structure{"LIBS_${libout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_SOURCES", - "_OBJECTS"); - @{$build_structure{"LIBS_${libout}_DEFINES"}} = @defines; - @{$build_structure{"LIBS_${libout}_INCLUDES"}} = @incpaths; - @{$build_structure{"LIBS_${libout}_CFLAGS"}} = @cflags; - @{$build_structure{"LIBS_${libout}_LFLAGS"}} = @lflags; - @{$build_structure{"LIBS_${libout}_SOURCES"}} = @sources; - @{$build_structure{"LIBS_${libout}_OBJECTS"}} = @objfiles; - clearCompileStep(); -} - -sub handleLinkLine -{ - my ($line, $lineno) = @_; - my (@objfiles, @lflags, @libs, $appout, $part); - my @parts = shellwords($line); - shift(@parts); # ignore cmd - while ($part = shift @parts) { - if ($part =~ /^-IGNORE/) { - push(@lflags, $part); - } elsif ($part =~ /^-[GRIMDO]/) { - # eat compiler flags - } elsif ("$part" eq "-o") { - $appout = shift @parts; - } elsif ("$part" eq "-lz") { - push(@libs, "zlib.lib"); - } elsif ("$part" eq "-lcrypto") { - push(@libs, "libcrypto.lib"); - } elsif ("$part" eq "-lssl") { - push(@libs, "libssl.lib"); - } elsif ("$part" eq "-lcurl") { - push(@libs, "libcurl.lib"); - } elsif ("$part" eq "-lexpat") { - push(@libs, "libexpat.lib"); - } elsif ("$part" eq "-liconv") { - push(@libs, "iconv.lib"); - } elsif ($part =~ /^[-\/]/) { - push(@lflags, $part); - } elsif ($part =~ /\.(a|lib)$/) { - $part =~ s/\.a$/.lib/; - push(@libs, $part); - } elsif ($part eq 'invalidcontinue.obj') { - # ignore - known to MSVC - } elsif ($part =~ /\.o$/) { - push(@objfiles, $part); - } elsif ($part =~ /\.obj$/) { - # do nothing, 'make' should not be producing .obj, only .o files - } else { - die "Unhandled link option @ line $lineno: $part"; - } - } -# print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n"; -# exit(1); - foreach (@objfiles) { - my $sourcefile = $_; - $sourcefile =~ s/^headless-git\.o$/compat\/win32\/headless.c/; - $sourcefile =~ s/\.o$/.c/; - push(@sources, $sourcefile); - push(@cflags, @{$compile_options{"${sourcefile}_CFLAGS"}}); - push(@defines, @{$compile_options{"${sourcefile}_DEFINES"}}); - push(@incpaths, @{$compile_options{"${sourcefile}_INCPATHS"}}); - } - removeDuplicates(); - - removeDuplicates(); - push(@{$build_structure{"APPS"}}, $appout); - @{$build_structure{"APPS_${appout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_LFLAGS", - "_SOURCES", "_OBJECTS", "_LIBS"); - @{$build_structure{"APPS_${appout}_DEFINES"}} = @defines; - @{$build_structure{"APPS_${appout}_INCLUDES"}} = @incpaths; - @{$build_structure{"APPS_${appout}_CFLAGS"}} = @cflags; - @{$build_structure{"APPS_${appout}_LFLAGS"}} = @lflags; - @{$build_structure{"APPS_${appout}_SOURCES"}} = @sources; - @{$build_structure{"APPS_${appout}_OBJECTS"}} = @objfiles; - @{$build_structure{"APPS_${appout}_LIBS"}} = @libs; - clearCompileStep(); -} diff --git a/contrib/buildsystems/generate b/contrib/buildsystems/generate deleted file mode 100755 index bc10f25ff2..0000000000 --- a/contrib/buildsystems/generate +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/perl -w -###################################################################### -# Generate buildsystem files -# -# This script generate buildsystem files based on the output of a -# GNU Make --dry-run, enabling Windows users to develop Git with their -# trusted IDE with native projects. -# -# Note: -# It is not meant as *the* way of building Git with MSVC, but merely a -# convenience. The correct way of building Git with MSVC is to use the -# GNU Make tool to build with the maintained Makefile in the root of -# the project. If you have the msysgit environment installed and -# available in your current console, together with the Visual Studio -# environment you wish to build for, all you have to do is run the -# command: -# make MSVC=1 -# -# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> -###################################################################### -use strict; -use File::Basename; -use Cwd; - -my $git_dir = getcwd(); -$git_dir =~ s=\\=/=g; -$git_dir = dirname($git_dir) while (!-e "$git_dir/git.c" && "$git_dir" ne ""); -die "Couldn't find Git repo" if ("$git_dir" eq ""); -exec join(" ", ("PERL5LIB=${git_dir}/contrib/buildsystems ${git_dir}/contrib/buildsystems/engine.pl", @ARGV)); diff --git a/contrib/buildsystems/parse.pl b/contrib/buildsystems/parse.pl deleted file mode 100755 index c9656ece99..0000000000 --- a/contrib/buildsystems/parse.pl +++ /dev/null @@ -1,228 +0,0 @@ -#!/usr/bin/perl -w -###################################################################### -# Do not call this script directly! -# -# The generate script ensures that @INC is correct before the engine -# is executed. -# -# Copyright (C) 2009 Marius Storm-Olsen <mstormo@gmail.com> -###################################################################### -use strict; -use File::Basename; -use Cwd; - -my $file = $ARGV[0]; -die "No file provided!" if !defined $file; - -my ($cflags, $target, $type, $line); - -open(F, "<$file") || die "Couldn't open file $file"; -my @data = <F>; -close(F); - -while (my $text = shift @data) { - my $ate_next; - do { - $ate_next = 0; - $line++; - chomp $text; - chop $text if ($text =~ /\r$/); - if ($text =~ /\\$/) { - $text =~ s/\\$//; - $text .= shift @data; - $ate_next = 1; - } - } while($ate_next); - - if($text =~ / -c /) { - # compilation - handleCompileLine($text, $line); - - } elsif ($text =~ / -o /) { - # linking executable - handleLinkLine($text, $line); - - } elsif ($text =~ /\.o / && $text =~ /\.a /) { - # libifying - handleLibLine($text, $line); - -# } elsif ($text =~ /^cp /) { -# # copy file around -# -# } elsif ($text =~ /^rm -f /) { -# # shell command -# -# } elsif ($text =~ /^make[ \[]/) { -# # make output -# -# } elsif ($text =~ /^echo /) { -# # echo to file -# -# } elsif ($text =~ /^if /) { -# # shell conditional -# -# } elsif ($text =~ /^tclsh /) { -# # translation stuff -# -# } elsif ($text =~ /^umask /) { -# # handling boilerplates -# -# } elsif ($text =~ /\$\(\:\)/) { -# # ignore -# -# } elsif ($text =~ /^FLAGS=/) { -# # flags check for dependencies -# -# } elsif ($text =~ /^'\/usr\/bin\/perl' -MError -e/) { -# # perl commands for copying files -# -# } elsif ($text =~ /generate-cmdlist\.sh/) { -# # command for generating list of commands -# -# } elsif ($text =~ /^test / && $text =~ /|| rm -f /) { -# # commands removing executables, if they exist -# -# } elsif ($text =~ /new locations or Tcl/) { -# # command for detecting Tcl/Tk changes -# -# } elsif ($text =~ /mkdir -p/) { -# # command creating path -# -# } elsif ($text =~ /: no custom templates yet/) { -# # whatever - - } else { -# print "Unhandled (line: $line): $text\n"; - } -} -close(F); - -# use Data::Dumper; -# print "Parsed build structure:\n"; -# print Dumper(%build_structure); - -# ------------------------------------------------------------------- -# Functions under here -# ------------------------------------------------------------------- -my (%build_structure, @defines, @incpaths, @cflags, @sources); - -sub clearCompileStep -{ - @defines = (); - @incpaths = (); - @cflags = (); - @sources = (); -} - -sub removeDuplicates -{ - my (%dupHash, $entry); - %dupHash = map { $_, 1 } @defines; - @defines = keys %dupHash; - - %dupHash = map { $_, 1 } @incpaths; - @incpaths = keys %dupHash; - - %dupHash = map { $_, 1 } @cflags; - @cflags = keys %dupHash; - - %dupHash = map { $_, 1 } @sources; - @sources = keys %dupHash; -} - -sub handleCompileLine -{ - my ($line, $lineno) = @_; - my @parts = split(' ', $line); - shift(@parts); # ignore cmd - while (my $part = shift @parts) { - if ("$part" eq "-o") { - # ignore object file - shift @parts; - } elsif ("$part" eq "-c") { - # ignore compile flag - } elsif ("$part" eq "-c") { - } elsif ($part =~ /^.?-I/) { - push(@incpaths, $part); - } elsif ($part =~ /^.?-D/) { - push(@defines, $part); - } elsif ($part =~ /^-/) { - push(@cflags, $part); - } elsif ($part =~ /\.(c|cc|cpp)$/) { - push(@sources, $part); - } else { - die "Unhandled compiler option @ line $lineno: $part"; - } - } - #print "Sources: @sources\nCFlags: @cflags\nDefine: @defines\nIncpat: @incpaths\n"; - #exit(1); -} - -sub handleLibLine -{ - my ($line, $lineno) = @_; - my (@objfiles, @lflags, $libout, $part); - # kill cmd and rm 'prefix' - $line =~ s/^rm -f .* && .* rcs //; - my @parts = split(' ', $line); - while ($part = shift @parts) { - if ($part =~ /^-/) { - push(@lflags, $part); - } elsif ($part =~ /\.(o|obj)$/) { - push(@objfiles, $part); - } elsif ($part =~ /\.(a|lib)$/) { - $libout = $part; - } else { - die "Unhandled lib option @ line $lineno: $part"; - } - } - #print "LibOut: '$libout'\nLFlags: @lflags\nOfiles: @objfiles\n"; - #exit(1); - removeDuplicates(); - push(@{$build_structure{"LIBS"}}, $libout); - @{$build_structure{"LIBS_${libout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_SOURCES", - "_OBJECTS"); - @{$build_structure{"LIBS_${libout}_DEFINES"}} = @defines; - @{$build_structure{"LIBS_${libout}_INCLUDES"}} = @incpaths; - @{$build_structure{"LIBS_${libout}_CFLAGS"}} = @cflags; - @{$build_structure{"LIBS_${libout}_SOURCES"}} = @sources; - @{$build_structure{"LIBS_${libout}_OBJECTS"}} = @objfiles; - clearCompileStep(); -} - -sub handleLinkLine -{ - my ($line, $lineno) = @_; - my (@objfiles, @lflags, @libs, $appout, $part); - my @parts = split(' ', $line); - shift(@parts); # ignore cmd - while ($part = shift @parts) { - if ($part =~ /^-[GRIDO]/) { - # eat compiler flags - } elsif ("$part" eq "-o") { - $appout = shift @parts; - } elsif ($part =~ /^-/) { - push(@lflags, $part); - } elsif ($part =~ /\.(a|lib)$/) { - push(@libs, $part); - } elsif ($part =~ /\.(o|obj)$/) { - push(@objfiles, $part); - } else { - die "Unhandled lib option @ line $lineno: $part"; - } - } - #print "AppOut: '$appout'\nLFlags: @lflags\nLibs : @libs\nOfiles: @objfiles\n"; - #exit(1); - removeDuplicates(); - push(@{$build_structure{"APPS"}}, $appout); - @{$build_structure{"APPS_${appout}"}} = ("_DEFINES", "_INCLUDES", "_CFLAGS", "_LFLAGS", - "_SOURCES", "_OBJECTS", "_LIBS"); - @{$build_structure{"APPS_${appout}_DEFINES"}} = @defines; - @{$build_structure{"APPS_${appout}_INCLUDES"}} = @incpaths; - @{$build_structure{"APPS_${appout}_CFLAGS"}} = @cflags; - @{$build_structure{"APPS_${appout}_LFLAGS"}} = @lflags; - @{$build_structure{"APPS_${appout}_SOURCES"}} = @sources; - @{$build_structure{"APPS_${appout}_OBJECTS"}} = @objfiles; - @{$build_structure{"APPS_${appout}_LIBS"}} = @libs; - clearCompileStep(); -} diff --git a/contrib/coccinelle/meson.build b/contrib/coccinelle/meson.build index ea054c924f..dc3f73c2e7 100644 --- a/contrib/coccinelle/meson.build +++ b/contrib/coccinelle/meson.build @@ -8,21 +8,6 @@ if not spatch.found() subdir_done() endif -third_party_sources = [ - ':!contrib', - ':!compat/inet_ntop.c', - ':!compat/inet_pton.c', - ':!compat/nedmalloc', - ':!compat/obstack.*', - ':!compat/poll', - ':!compat/regex', - ':!sha1collisiondetection', - ':!sha1dc', - ':!t/unit-tests/clar', - ':!t/unit-tests/clar', - ':!t/t[0-9][0-9][0-9][0-9]*', -] - rules = [ 'array.cocci', 'commit.cocci', @@ -55,18 +40,18 @@ concatenated_rules = custom_target( capture: true, ) -sources = [ ] -foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_sources, check: true).stdout().split() - sources += source +coccinelle_sources = [] +foreach source : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.c', third_party_excludes, check: true).stdout().split() + coccinelle_sources += source endforeach -headers = [ ] -foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_sources, check: true).stdout().split() - headers += meson.project_source_root() / header +coccinelle_headers = [] +foreach header : headers_to_check + coccinelle_headers += meson.project_source_root() / header endforeach patches = [ ] -foreach source : sources +foreach source : coccinelle_sources patches += custom_target( command: [ spatch, @@ -78,7 +63,7 @@ foreach source : sources input: meson.project_source_root() / source, output: source.underscorify() + '.patch', capture: true, - depend_files: headers, + depend_files: coccinelle_headers, ) endforeach diff --git a/contrib/completion/meson.build b/contrib/completion/meson.build index 3a9ddab594..576125b083 100644 --- a/contrib/completion/meson.build +++ b/contrib/completion/meson.build @@ -14,3 +14,21 @@ foreach script : [ ) endif endforeach + +# We have to discern between the test dependency and the installed file. Our +# tests assume the completion scripts to have the same name as the in-tree +# files, but the installed filenames need to match the executable's basename. +if meson.version().version_compare('>=1.3.0') + fs.copyfile('git-completion.bash', 'git', + install: true, + install_dir: get_option('datadir') / 'bash-completion/completions', + ) +else + configure_file( + input: 'git-completion.bash', + output: 'git', + copy: true, + install: true, + install_dir: get_option('datadir') / 'bash-completion/completions', + ) +endif @@ -8,7 +8,7 @@ #include "copy.h" #include "gettext.h" #include "hex.h" -#include "object-store.h" +#include "object-file.h" #include "attr.h" #include "run-command.h" #include "quote.h" @@ -892,7 +892,7 @@ static void fill_es_indent_data(struct emitted_diff_symbol *es) /* skip any \v \f \r at start of indentation */ while (s[off] == '\f' || s[off] == '\v' || - (s[off] == '\r' && off < len - 1)) + (off < len - 1 && s[off] == '\r')) off++; /* calculate the visual width of indentation */ diff --git a/diffcore-rename.c b/diffcore-rename.c index 179731462b..7723bc3334 100644 --- a/diffcore-rename.c +++ b/diffcore-rename.c @@ -8,7 +8,7 @@ #include "git-compat-util.h" #include "diff.h" #include "diffcore.h" -#include "object-store.h" +#include "object-file.h" #include "hashmap.h" #include "mem-pool.h" #include "oid-array.h" @@ -17,7 +17,7 @@ #include "environment.h" #include "gettext.h" #include "name-hash.h" -#include "object-store.h" +#include "object-file.h" #include "path.h" #include "refs.h" #include "repository.h" @@ -518,7 +518,8 @@ static int do_match_pathspec(struct index_state *istate, ( exclude && !(ps->items[i].magic & PATHSPEC_EXCLUDE))) continue; - if (seen && seen[i] == MATCHED_EXACTLY) + if (seen && seen[i] == MATCHED_EXACTLY && + ps->items[i].nowildcard_len == ps->items[i].len) continue; /* * Make exclude patterns optional and never report diff --git a/environment.c b/environment.c index 3c32367c28..c61d773e7e 100644 --- a/environment.c +++ b/environment.c @@ -81,6 +81,16 @@ int max_allowed_tree_depth = * the stack overflow can occur. */ 512; +#elif defined(GIT_WINDOWS_NATIVE) && defined(__clang__) && defined(__aarch64__) + /* + * Similar to Visual C, it seems that on Windows/ARM64 the clang-based + * builds have a smaller stack space available. When running out of + * that stack space, a `STATUS_STACK_OVERFLOW` is produced. When the + * Git command was run from an MSYS2 Bash, this unfortunately results + * in an exit code 127. Let's prevent that by lowering the maximal + * tree depth; This value seems to be low enough. + */ + 1280; #else 2048; #endif @@ -106,7 +116,7 @@ int auto_comment_line_char; /* Parallel index stat data preload? */ int core_preload_index = 1; -/* This is set by setup_git_dir_gently() and/or git_default_config() */ +/* This is set by setup_git_directory_gently() and/or git_default_config() */ char *git_work_tree_cfg; /* diff --git a/fetch-pack.c b/fetch-pack.c index 210dc30d50..fa4231fee7 100644 --- a/fetch-pack.c +++ b/fetch-pack.c @@ -769,9 +769,7 @@ static void mark_complete_and_common_ref(struct fetch_negotiator *negotiator, if (!commit) { struct object *o; - if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid, - OBJECT_INFO_QUICK | - OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!has_object(the_repository, &ref->old_oid, 0)) continue; o = parse_object(the_repository, &ref->old_oid); if (!o || o->type != OBJ_COMMIT) @@ -1985,7 +1983,8 @@ static void update_shallow(struct fetch_pack_args *args, struct oid_array extra = OID_ARRAY_INIT; struct object_id *oid = si->shallow->oid; for (i = 0; i < si->shallow->nr; i++) - if (repo_has_object_file(the_repository, &oid[i])) + if (has_object(the_repository, &oid[i], + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) oid_array_append(&extra, &oid[i]); if (extra.nr) { setup_alternate_shallow(&shallow_lock, diff --git a/git-filter-branch.sh b/git-filter-branch.sh index 3a51d4507c..24fa317aaa 100755 --- a/git-filter-branch.sh +++ b/git-filter-branch.sh @@ -295,15 +295,18 @@ then if test -n "$state_commit" then echo "Populating map from $state_branch ($state_commit)" 1>&2 - perl -e'open(MAP, "-|", "git show $ARGV[0]:filter.map") or die; - while (<MAP>) { - m/(.*):(.*)/ or die; - open F, ">../map/$1" or die; - print F "$2" or die; - close(F) or die; - } - close(MAP) or die;' "$state_commit" \ - || die "Unable to load state from $state_branch:filter.map" + + git show "$state_commit:filter.map" >"$tempdir"/filter-map || + die "Unable to load state from $state_branch:filter.map" + while read line + do + case "$line" in + *:*) + echo "${line%:*}" >../map/"${line#*:}";; + *) + die "Unable to load state from $state_branch:filter.map";; + esac + done <"$tempdir"/filter-map else echo "Branch $state_branch does not exist. Will create" 1>&2 fi @@ -633,15 +636,13 @@ if test -n "$state_branch" then echo "Saving rewrite state to $state_branch" 1>&2 state_blob=$( - perl -e'opendir D, "../map" or die; - open H, "|-", "git hash-object -w --stdin" or die; - foreach (sort readdir(D)) { - next if m/^\.\.?$/; - open F, "<../map/$_" or die; - chomp($f = <F>); - print H "$_:$f\n" or die; - } - close(H) or die;' || die "Unable to save state") + for file in ../map/* + do + from_commit=$(basename "$file") + to_commit=$(cat "$file") + echo "$from_commit:$to_commit" + done | git hash-object -w --stdin || die "Unable to save state" + ) state_tree=$(printf '100644 blob %s\tfilter.map\n' "$state_blob" | git mktree) if test -n "$state_commit" then diff --git a/git-gui/Makefile b/git-gui/Makefile index 6c5a12bc32..e3b4f324b6 100644 --- a/git-gui/Makefile +++ b/git-gui/Makefile @@ -322,7 +322,7 @@ dist-version: @echo $(GITGUI_VERSION) > $(TARDIR)/version clean:: - $(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg + $(RM_RF) $(GITGUI_MAIN) lib/tclIndex po/*.msg $(PO_TEMPLATE) $(RM_RF) GIT-VERSION-FILE GIT-GUI-VARS ifdef GITGUI_MACOSXAPP $(RM_RF) 'Git Gui.app'* git-gui diff --git a/git-gui/git-gui.sh b/git-gui/git-gui.sh index 887d6d596c..28572c889c 100755 --- a/git-gui/git-gui.sh +++ b/git-gui/git-gui.sh @@ -880,6 +880,12 @@ proc apply_config {} { color::sync_with_theme } } + + global comment_string + set comment_string [get_config core.commentstring] + if {$comment_string eq {}} { + set comment_string [get_config core.commentchar] + } } set default_config(branch.autosetupmerge) true @@ -890,6 +896,8 @@ set default_config(merge.summary) false set default_config(merge.verbosity) 2 set default_config(user.name) {} set default_config(user.email) {} +set default_config(core.commentchar) "#" +set default_config(core.commentstring) {} set default_config(gui.encoding) [encoding system] set default_config(gui.matchtrackingbranch) false diff --git a/git-gui/lib/commit.tcl b/git-gui/lib/commit.tcl index 208dc2817c..a570f9cdc6 100644 --- a/git-gui/lib/commit.tcl +++ b/git-gui/lib/commit.tcl @@ -211,7 +211,9 @@ You must stage at least 1 file before you can commit. # Strip trailing whitespace regsub -all -line {[ \t\r]+$} $msg {} msg # Strip comment lines - regsub -all {(^|\n)#[^\n]*} $msg {\1} msg + global comment_string + set cmt_rx [strcat {(^|\n)} [regsub -all {\W} $comment_string {\\&}] {[^\n]*}] + regsub -all $cmt_rx $msg {\1} msg # Strip leading empty lines regsub {^\n*} $msg {} msg # Compress consecutive empty lines diff --git a/git-gui/po/.gitignore b/git-gui/po/.gitignore index a89cf44969..b900bb98d5 100644 --- a/git-gui/po/.gitignore +++ b/git-gui/po/.gitignore @@ -1,2 +1,3 @@ *.msg *~ +/git-gui.pot diff --git a/git-gui/po/README b/git-gui/po/README index 116233100d..4a1aa79a49 100644 --- a/git-gui/po/README +++ b/git-gui/po/README @@ -21,8 +21,8 @@ them. You would then need to clone the git-gui project repository and create a feature branch to begin working: - $ git clone git://repo.or.cz/git-gui.git - $ cd git-gui.git + $ git clone https://github.com/j6t/git-gui + $ cd git-gui $ git checkout -b my-translation The "git checkout" command creates a new branch to keep your work @@ -47,6 +47,10 @@ language, you do not have to perform any step in this section, but keep reading, because we are covering the basics. If you did not find your language, you would need to start one yourself. +Generate po/git-gui.pot using + + $ make po/git-gui.pot + Copy po/git-gui.pot file to po/af.po (replace "af" with the code for your language). Edit the first several lines to match existing *.po files to make it clear this is a translation table for git-gui project, @@ -153,7 +157,7 @@ your patch series to the maintainer and the Git mailing list: $ git add po/af.po $ git commit -s -m 'git-gui: added Afrikaans translation.' $ git send-email --to 'git@vger.kernel.org' \ - --cc 'Pat Thoyts <patthoyts@users.sourceforge.net>' \ + --cc 'Johannes Sixt <j6t@kdbg.org>' \ --subject 'git-gui: Afrikaans translation' \ master.. @@ -169,18 +173,7 @@ In any case, make sure you are up to date before starting your work: $ git checkout master $ git pull - -In the former case, you will edit po/af.po (again, replace "af" with -your language code), and after testing and updating the Last-Translator: -and PO-Revision-Date: lines, "add/commit/push" as in the previous -section. - -By comparing "POT-Creation-Date:" line in po/git-gui.pot file and -po/af.po file, you can tell if there are new messages that need to be -translated. You would need the GNU gettext package to perform this -step. - - $ msgmerge -U po/af.po po/git-gui.pot + $ make ALL_POFILES=po/af.po update-po This updates po/af.po (again, replace "af" with your language code) so that it contains msgid lines (i.e. the original) that @@ -200,52 +193,5 @@ watch out for: - New messages added to the software will have msgstr lines with empty strings. You would need to translate them. -The po/git-gui.pot file is updated by the internationalization -coordinator from time to time. You _could_ update it yourself, but -translators are discouraged from doing so because we would want all -language teams to be working off of the same version of git-gui.pot. - -**************************************************************** - -This section is a note to the internationalization coordinator, and -translators do not have to worry about it too much. - -The message template file po/git-gui.pot needs to be kept up to date -relative to the software the translations apply to, and it is the -responsibility of the internationalization coordinator. - -When updating po/git-gui.pot file, however, _never_ run "msgmerge -U -po/xx.po" for individual language translations, unless you are absolutely -sure that there is no outstanding work on translation for language xx. -Doing so will create unnecessary merge conflicts and force needless -re-translation on translators. The translator however may not have access -to the msgmerge tool, in which case the coordinator may run it for the -translator as a service. - -But mistakes do happen. Suppose a translation was based on an older -version X, the POT file was updated at version Y and then msgmerge was run -at version Z for the language, and the translator sent in a patch based on -version X: - - ? translated - / - ---X---Y---Z (master) - -The coordinator could recover from such a mistake by first applying the -patch to X, replace the translated file in Z, and then running msgmerge -again based on the updated POT file and commit the result. The sequence -would look like this: - - $ git checkout X - $ git am -s xx.patch - $ git checkout master - $ git checkout HEAD@{1} po/xx.po - $ msgmerge -U po/xx.po po/git-gui.pot - $ git commit -c HEAD@{1} po/xx.po - -State in the message that the translated messages are based on a slightly -older version, and msgmerge was run to incorporate changes to message -templates from the updated POT file. The result needs to be further -translated, but at least the messages that were updated by the patch that -were not changed by the POT update will survive the process and do not -need to be re-translated. +After testing and updating the Last-Translator: and PO-Revision-Date: +lines, "add/commit/push" as in the previous section. diff --git a/git-gui/po/git-gui.pot b/git-gui/po/git-gui.pot deleted file mode 100644 index b79ed4e133..0000000000 --- a/git-gui/po/git-gui.pot +++ /dev/null @@ -1,2666 +0,0 @@ -# SOME DESCRIPTIVE TITLE. -# Copyright (C) YEAR THE PACKAGE'S COPYRIGHT HOLDER -# This file is distributed under the same license as the PACKAGE package. -# FIRST AUTHOR <EMAIL@ADDRESS>, YEAR. -# -#, fuzzy -msgid "" -msgstr "" -"Project-Id-Version: PACKAGE VERSION\n" -"Report-Msgid-Bugs-To: \n" -"POT-Creation-Date: 2020-02-08 22:54+0100\n" -"PO-Revision-Date: YEAR-MO-DA HO:MI+ZONE\n" -"Last-Translator: FULL NAME <EMAIL@ADDRESS>\n" -"Language-Team: LANGUAGE <LL@li.org>\n" -"Language: \n" -"MIME-Version: 1.0\n" -"Content-Type: text/plain; charset=CHARSET\n" -"Content-Transfer-Encoding: 8bit\n" - -#: git-gui.sh:847 -#, tcl-format -msgid "Invalid font specified in %s:" -msgstr "" - -#: git-gui.sh:901 -msgid "Main Font" -msgstr "" - -#: git-gui.sh:902 -msgid "Diff/Console Font" -msgstr "" - -#: git-gui.sh:917 git-gui.sh:931 git-gui.sh:944 git-gui.sh:1034 git-gui.sh:1053 -#: git-gui.sh:3212 -msgid "git-gui: fatal error" -msgstr "" - -#: git-gui.sh:918 -msgid "Cannot find git in PATH." -msgstr "" - -#: git-gui.sh:945 -msgid "Cannot parse Git version string:" -msgstr "" - -#: git-gui.sh:970 -#, tcl-format -msgid "" -"Git version cannot be determined.\n" -"\n" -"%s claims it is version '%s'.\n" -"\n" -"%s requires at least Git 1.5.0 or later.\n" -"\n" -"Assume '%s' is version 1.5.0?\n" -msgstr "" - -#: git-gui.sh:1267 -msgid "Git directory not found:" -msgstr "" - -#: git-gui.sh:1301 -msgid "Cannot move to top of working directory:" -msgstr "" - -#: git-gui.sh:1309 -msgid "Cannot use bare repository:" -msgstr "" - -#: git-gui.sh:1317 -msgid "No working directory" -msgstr "" - -#: git-gui.sh:1491 lib/checkout_op.tcl:306 -msgid "Refreshing file status..." -msgstr "" - -#: git-gui.sh:1551 -msgid "Scanning for modified files ..." -msgstr "" - -#: git-gui.sh:1629 -msgid "Calling prepare-commit-msg hook..." -msgstr "" - -#: git-gui.sh:1646 -msgid "Commit declined by prepare-commit-msg hook." -msgstr "" - -#: git-gui.sh:1804 lib/browser.tcl:252 -msgid "Ready." -msgstr "" - -#: git-gui.sh:1968 -#, tcl-format -msgid "" -"Display limit (gui.maxfilesdisplayed = %s) reached, not showing all %s files." -msgstr "" - -#: git-gui.sh:2091 -msgid "Unmodified" -msgstr "" - -#: git-gui.sh:2093 -msgid "Modified, not staged" -msgstr "" - -#: git-gui.sh:2094 git-gui.sh:2106 -msgid "Staged for commit" -msgstr "" - -#: git-gui.sh:2095 git-gui.sh:2107 -msgid "Portions staged for commit" -msgstr "" - -#: git-gui.sh:2096 git-gui.sh:2108 -msgid "Staged for commit, missing" -msgstr "" - -#: git-gui.sh:2098 -msgid "File type changed, not staged" -msgstr "" - -#: git-gui.sh:2099 git-gui.sh:2100 -msgid "File type changed, old type staged for commit" -msgstr "" - -#: git-gui.sh:2101 -msgid "File type changed, staged" -msgstr "" - -#: git-gui.sh:2102 -msgid "File type change staged, modification not staged" -msgstr "" - -#: git-gui.sh:2103 -msgid "File type change staged, file missing" -msgstr "" - -#: git-gui.sh:2105 -msgid "Untracked, not staged" -msgstr "" - -#: git-gui.sh:2110 -msgid "Missing" -msgstr "" - -#: git-gui.sh:2111 -msgid "Staged for removal" -msgstr "" - -#: git-gui.sh:2112 -msgid "Staged for removal, still present" -msgstr "" - -#: git-gui.sh:2114 git-gui.sh:2115 git-gui.sh:2116 git-gui.sh:2117 -#: git-gui.sh:2118 git-gui.sh:2119 -msgid "Requires merge resolution" -msgstr "" - -#: git-gui.sh:2164 -msgid "Couldn't find gitk in PATH" -msgstr "" - -#: git-gui.sh:2210 git-gui.sh:2245 -#, tcl-format -msgid "Starting %s... please wait..." -msgstr "" - -#: git-gui.sh:2224 -msgid "Couldn't find git gui in PATH" -msgstr "" - -#: git-gui.sh:2726 lib/choose_repository.tcl:53 -msgid "Repository" -msgstr "" - -#: git-gui.sh:2727 -msgid "Edit" -msgstr "" - -#: git-gui.sh:2729 lib/choose_rev.tcl:567 -msgid "Branch" -msgstr "" - -#: git-gui.sh:2732 lib/choose_rev.tcl:554 -msgid "Commit@@noun" -msgstr "" - -#: git-gui.sh:2735 lib/merge.tcl:127 lib/merge.tcl:174 -msgid "Merge" -msgstr "" - -#: git-gui.sh:2736 lib/choose_rev.tcl:563 -msgid "Remote" -msgstr "" - -#: git-gui.sh:2739 -msgid "Tools" -msgstr "" - -#: git-gui.sh:2748 -msgid "Explore Working Copy" -msgstr "" - -#: git-gui.sh:2763 -msgid "Git Bash" -msgstr "" - -#: git-gui.sh:2772 -msgid "Browse Current Branch's Files" -msgstr "" - -#: git-gui.sh:2776 -msgid "Browse Branch Files..." -msgstr "" - -#: git-gui.sh:2781 -msgid "Visualize Current Branch's History" -msgstr "" - -#: git-gui.sh:2785 -msgid "Visualize All Branch History" -msgstr "" - -#: git-gui.sh:2792 -#, tcl-format -msgid "Browse %s's Files" -msgstr "" - -#: git-gui.sh:2794 -#, tcl-format -msgid "Visualize %s's History" -msgstr "" - -#: git-gui.sh:2799 lib/database.tcl:40 -msgid "Database Statistics" -msgstr "" - -#: git-gui.sh:2802 lib/database.tcl:33 -msgid "Compress Database" -msgstr "" - -#: git-gui.sh:2805 -msgid "Verify Database" -msgstr "" - -#: git-gui.sh:2812 git-gui.sh:2816 git-gui.sh:2820 -msgid "Create Desktop Icon" -msgstr "" - -#: git-gui.sh:2828 lib/choose_repository.tcl:209 lib/choose_repository.tcl:217 -msgid "Quit" -msgstr "" - -#: git-gui.sh:2836 -msgid "Undo" -msgstr "" - -#: git-gui.sh:2839 -msgid "Redo" -msgstr "" - -#: git-gui.sh:2843 git-gui.sh:3461 -msgid "Cut" -msgstr "" - -#: git-gui.sh:2846 git-gui.sh:3464 git-gui.sh:3540 git-gui.sh:3633 -#: lib/console.tcl:69 -msgid "Copy" -msgstr "" - -#: git-gui.sh:2849 git-gui.sh:3467 -msgid "Paste" -msgstr "" - -#: git-gui.sh:2852 git-gui.sh:3470 lib/remote_branch_delete.tcl:39 -#: lib/branch_delete.tcl:28 -msgid "Delete" -msgstr "" - -#: git-gui.sh:2856 git-gui.sh:3474 git-gui.sh:3637 lib/console.tcl:71 -msgid "Select All" -msgstr "" - -#: git-gui.sh:2865 -msgid "Create..." -msgstr "" - -#: git-gui.sh:2871 -msgid "Checkout..." -msgstr "" - -#: git-gui.sh:2877 -msgid "Rename..." -msgstr "" - -#: git-gui.sh:2882 -msgid "Delete..." -msgstr "" - -#: git-gui.sh:2887 -msgid "Reset..." -msgstr "" - -#: git-gui.sh:2897 -msgid "Done" -msgstr "" - -#: git-gui.sh:2899 -msgid "Commit@@verb" -msgstr "" - -#: git-gui.sh:2908 git-gui.sh:3400 -msgid "Amend Last Commit" -msgstr "" - -#: git-gui.sh:2918 git-gui.sh:3361 lib/remote_branch_delete.tcl:101 -msgid "Rescan" -msgstr "" - -#: git-gui.sh:2924 -msgid "Stage To Commit" -msgstr "" - -#: git-gui.sh:2930 -msgid "Stage Changed Files To Commit" -msgstr "" - -#: git-gui.sh:2936 -msgid "Unstage From Commit" -msgstr "" - -#: git-gui.sh:2942 lib/index.tcl:521 -msgid "Revert Changes" -msgstr "" - -#: git-gui.sh:2950 git-gui.sh:3700 git-gui.sh:3731 -msgid "Show Less Context" -msgstr "" - -#: git-gui.sh:2954 git-gui.sh:3704 git-gui.sh:3735 -msgid "Show More Context" -msgstr "" - -#: git-gui.sh:2961 git-gui.sh:3374 git-gui.sh:3485 -msgid "Sign Off" -msgstr "" - -#: git-gui.sh:2977 -msgid "Local Merge..." -msgstr "" - -#: git-gui.sh:2982 -msgid "Abort Merge..." -msgstr "" - -#: git-gui.sh:2994 git-gui.sh:3022 -msgid "Add..." -msgstr "" - -#: git-gui.sh:2998 -msgid "Push..." -msgstr "" - -#: git-gui.sh:3002 -msgid "Delete Branch..." -msgstr "" - -#: git-gui.sh:3012 git-gui.sh:3666 -msgid "Options..." -msgstr "" - -#: git-gui.sh:3023 -msgid "Remove..." -msgstr "" - -#: git-gui.sh:3032 lib/choose_repository.tcl:67 -msgid "Help" -msgstr "" - -#: git-gui.sh:3036 git-gui.sh:3040 lib/choose_repository.tcl:61 -#: lib/choose_repository.tcl:70 lib/about.tcl:14 -#, tcl-format -msgid "About %s" -msgstr "" - -#: git-gui.sh:3064 -msgid "Online Documentation" -msgstr "" - -#: git-gui.sh:3067 lib/choose_repository.tcl:64 lib/choose_repository.tcl:73 -msgid "Show SSH Key" -msgstr "" - -#: git-gui.sh:3097 git-gui.sh:3229 -msgid "usage:" -msgstr "" - -#: git-gui.sh:3101 git-gui.sh:3233 -msgid "Usage" -msgstr "" - -#: git-gui.sh:3182 lib/blame.tcl:575 -msgid "Error" -msgstr "" - -#: git-gui.sh:3213 -#, tcl-format -msgid "fatal: cannot stat path %s: No such file or directory" -msgstr "" - -#: git-gui.sh:3246 -msgid "Current Branch:" -msgstr "" - -#: git-gui.sh:3271 -msgid "Unstaged Changes" -msgstr "" - -#: git-gui.sh:3293 -msgid "Staged Changes (Will Commit)" -msgstr "" - -#: git-gui.sh:3367 -msgid "Stage Changed" -msgstr "" - -#: git-gui.sh:3386 lib/transport.tcl:137 -msgid "Push" -msgstr "" - -#: git-gui.sh:3413 -msgid "Initial Commit Message:" -msgstr "" - -#: git-gui.sh:3414 -msgid "Amended Commit Message:" -msgstr "" - -#: git-gui.sh:3415 -msgid "Amended Initial Commit Message:" -msgstr "" - -#: git-gui.sh:3416 -msgid "Amended Merge Commit Message:" -msgstr "" - -#: git-gui.sh:3417 -msgid "Merge Commit Message:" -msgstr "" - -#: git-gui.sh:3418 -msgid "Commit Message:" -msgstr "" - -#: git-gui.sh:3477 git-gui.sh:3641 lib/console.tcl:73 -msgid "Copy All" -msgstr "" - -#: git-gui.sh:3501 lib/blame.tcl:106 -msgid "File:" -msgstr "" - -#: git-gui.sh:3549 lib/choose_repository.tcl:1100 -msgid "Open" -msgstr "" - -#: git-gui.sh:3629 -msgid "Refresh" -msgstr "" - -#: git-gui.sh:3650 -msgid "Decrease Font Size" -msgstr "" - -#: git-gui.sh:3654 -msgid "Increase Font Size" -msgstr "" - -#: git-gui.sh:3662 lib/blame.tcl:296 -msgid "Encoding" -msgstr "" - -#: git-gui.sh:3673 -msgid "Apply/Reverse Hunk" -msgstr "" - -#: git-gui.sh:3678 -msgid "Apply/Reverse Line" -msgstr "" - -#: git-gui.sh:3684 git-gui.sh:3794 git-gui.sh:3805 -msgid "Revert Hunk" -msgstr "" - -#: git-gui.sh:3689 git-gui.sh:3801 git-gui.sh:3812 -msgid "Revert Line" -msgstr "" - -#: git-gui.sh:3694 git-gui.sh:3791 -msgid "Undo Last Revert" -msgstr "" - -#: git-gui.sh:3713 -msgid "Run Merge Tool" -msgstr "" - -#: git-gui.sh:3718 -msgid "Use Remote Version" -msgstr "" - -#: git-gui.sh:3722 -msgid "Use Local Version" -msgstr "" - -#: git-gui.sh:3726 -msgid "Revert To Base" -msgstr "" - -#: git-gui.sh:3744 -msgid "Visualize These Changes In The Submodule" -msgstr "" - -#: git-gui.sh:3748 -msgid "Visualize Current Branch History In The Submodule" -msgstr "" - -#: git-gui.sh:3752 -msgid "Visualize All Branch History In The Submodule" -msgstr "" - -#: git-gui.sh:3757 -msgid "Start git gui In The Submodule" -msgstr "" - -#: git-gui.sh:3793 -msgid "Unstage Hunk From Commit" -msgstr "" - -#: git-gui.sh:3797 -msgid "Unstage Lines From Commit" -msgstr "" - -#: git-gui.sh:3798 git-gui.sh:3809 -msgid "Revert Lines" -msgstr "" - -#: git-gui.sh:3800 -msgid "Unstage Line From Commit" -msgstr "" - -#: git-gui.sh:3804 -msgid "Stage Hunk For Commit" -msgstr "" - -#: git-gui.sh:3808 -msgid "Stage Lines For Commit" -msgstr "" - -#: git-gui.sh:3811 -msgid "Stage Line For Commit" -msgstr "" - -#: git-gui.sh:3861 -msgid "Initializing..." -msgstr "" - -#: git-gui.sh:4017 -#, tcl-format -msgid "" -"Possible environment issues exist.\n" -"\n" -"The following environment variables are probably\n" -"going to be ignored by any Git subprocess run\n" -"by %s:\n" -"\n" -msgstr "" - -#: git-gui.sh:4046 -msgid "" -"\n" -"This is due to a known issue with the\n" -"Tcl binary distributed by Cygwin." -msgstr "" - -#: git-gui.sh:4051 -#, tcl-format -msgid "" -"\n" -"\n" -"A good replacement for %s\n" -"is placing values for the user.name and\n" -"user.email settings into your personal\n" -"~/.gitconfig file.\n" -msgstr "" - -#: lib/spellcheck.tcl:57 -msgid "Unsupported spell checker" -msgstr "" - -#: lib/spellcheck.tcl:65 -msgid "Spell checking is unavailable" -msgstr "" - -#: lib/spellcheck.tcl:68 -msgid "Invalid spell checking configuration" -msgstr "" - -#: lib/spellcheck.tcl:70 -#, tcl-format -msgid "Reverting dictionary to %s." -msgstr "" - -#: lib/spellcheck.tcl:73 -msgid "Spell checker silently failed on startup" -msgstr "" - -#: lib/spellcheck.tcl:80 -msgid "Unrecognized spell checker" -msgstr "" - -#: lib/spellcheck.tcl:186 -msgid "No Suggestions" -msgstr "" - -#: lib/spellcheck.tcl:388 -msgid "Unexpected EOF from spell checker" -msgstr "" - -#: lib/spellcheck.tcl:392 -msgid "Spell Checker Failed" -msgstr "" - -#: lib/transport.tcl:6 lib/remote_add.tcl:132 -#, tcl-format -msgid "fetch %s" -msgstr "" - -#: lib/transport.tcl:7 -#, tcl-format -msgid "Fetching new changes from %s" -msgstr "" - -#: lib/transport.tcl:18 -#, tcl-format -msgid "remote prune %s" -msgstr "" - -#: lib/transport.tcl:19 -#, tcl-format -msgid "Pruning tracking branches deleted from %s" -msgstr "" - -#: lib/transport.tcl:25 -msgid "fetch all remotes" -msgstr "" - -#: lib/transport.tcl:26 -msgid "Fetching new changes from all remotes" -msgstr "" - -#: lib/transport.tcl:40 -msgid "remote prune all remotes" -msgstr "" - -#: lib/transport.tcl:41 -msgid "Pruning tracking branches deleted from all remotes" -msgstr "" - -#: lib/transport.tcl:54 lib/transport.tcl:92 lib/transport.tcl:110 -#: lib/remote_add.tcl:162 -#, tcl-format -msgid "push %s" -msgstr "" - -#: lib/transport.tcl:55 -#, tcl-format -msgid "Pushing changes to %s" -msgstr "" - -#: lib/transport.tcl:93 -#, tcl-format -msgid "Mirroring to %s" -msgstr "" - -#: lib/transport.tcl:111 -#, tcl-format -msgid "Pushing %s %s to %s" -msgstr "" - -#: lib/transport.tcl:132 -msgid "Push Branches" -msgstr "" - -#: lib/transport.tcl:141 lib/checkout_op.tcl:580 lib/remote_add.tcl:34 -#: lib/browser.tcl:292 lib/branch_checkout.tcl:30 lib/branch_rename.tcl:32 -#: lib/choose_font.tcl:45 lib/option.tcl:127 lib/tools_dlg.tcl:41 -#: lib/tools_dlg.tcl:202 lib/tools_dlg.tcl:345 lib/remote_branch_delete.tcl:43 -#: lib/branch_create.tcl:37 lib/branch_delete.tcl:34 lib/merge.tcl:178 -msgid "Cancel" -msgstr "" - -#: lib/transport.tcl:147 -msgid "Source Branches" -msgstr "" - -#: lib/transport.tcl:162 -msgid "Destination Repository" -msgstr "" - -#: lib/transport.tcl:165 lib/remote_branch_delete.tcl:51 -msgid "Remote:" -msgstr "" - -#: lib/transport.tcl:187 lib/remote_branch_delete.tcl:72 -msgid "Arbitrary Location:" -msgstr "" - -#: lib/transport.tcl:205 -msgid "Transfer Options" -msgstr "" - -#: lib/transport.tcl:207 -msgid "Force overwrite existing branch (may discard changes)" -msgstr "" - -#: lib/transport.tcl:211 -msgid "Use thin pack (for slow network connections)" -msgstr "" - -#: lib/transport.tcl:215 -msgid "Include tags" -msgstr "" - -#: lib/transport.tcl:229 -#, tcl-format -msgid "%s (%s): Push" -msgstr "" - -#: lib/checkout_op.tcl:85 -#, tcl-format -msgid "Fetching %s from %s" -msgstr "" - -#: lib/checkout_op.tcl:133 -#, tcl-format -msgid "fatal: Cannot resolve %s" -msgstr "" - -#: lib/checkout_op.tcl:146 lib/sshkey.tcl:58 lib/console.tcl:81 -#: lib/database.tcl:30 -msgid "Close" -msgstr "" - -#: lib/checkout_op.tcl:175 -#, tcl-format -msgid "Branch '%s' does not exist." -msgstr "" - -#: lib/checkout_op.tcl:194 -#, tcl-format -msgid "Failed to configure simplified git-pull for '%s'." -msgstr "" - -#: lib/checkout_op.tcl:202 lib/branch_rename.tcl:102 -#, tcl-format -msgid "Branch '%s' already exists." -msgstr "" - -#: lib/checkout_op.tcl:229 -#, tcl-format -msgid "" -"Branch '%s' already exists.\n" -"\n" -"It cannot fast-forward to %s.\n" -"A merge is required." -msgstr "" - -#: lib/checkout_op.tcl:243 -#, tcl-format -msgid "Merge strategy '%s' not supported." -msgstr "" - -#: lib/checkout_op.tcl:262 -#, tcl-format -msgid "Failed to update '%s'." -msgstr "" - -#: lib/checkout_op.tcl:274 -msgid "Staging area (index) is already locked." -msgstr "" - -#: lib/checkout_op.tcl:289 -msgid "" -"Last scanned state does not match repository state.\n" -"\n" -"Another Git program has modified this repository since the last scan. A " -"rescan must be performed before the current branch can be changed.\n" -"\n" -"The rescan will be automatically started now.\n" -msgstr "" - -#: lib/checkout_op.tcl:345 -#, tcl-format -msgid "Updating working directory to '%s'..." -msgstr "" - -#: lib/checkout_op.tcl:346 -msgid "files checked out" -msgstr "" - -#: lib/checkout_op.tcl:377 -#, tcl-format -msgid "Aborted checkout of '%s' (file level merging is required)." -msgstr "" - -#: lib/checkout_op.tcl:378 -msgid "File level merge required." -msgstr "" - -#: lib/checkout_op.tcl:382 -#, tcl-format -msgid "Staying on branch '%s'." -msgstr "" - -#: lib/checkout_op.tcl:453 -msgid "" -"You are no longer on a local branch.\n" -"\n" -"If you wanted to be on a branch, create one now starting from 'This Detached " -"Checkout'." -msgstr "" - -#: lib/checkout_op.tcl:504 lib/checkout_op.tcl:508 -#, tcl-format -msgid "Checked out '%s'." -msgstr "" - -#: lib/checkout_op.tcl:536 -#, tcl-format -msgid "Resetting '%s' to '%s' will lose the following commits:" -msgstr "" - -#: lib/checkout_op.tcl:558 -msgid "Recovering lost commits may not be easy." -msgstr "" - -#: lib/checkout_op.tcl:563 -#, tcl-format -msgid "Reset '%s'?" -msgstr "" - -#: lib/checkout_op.tcl:568 lib/tools_dlg.tcl:336 lib/merge.tcl:170 -msgid "Visualize" -msgstr "" - -#: lib/checkout_op.tcl:572 lib/branch_create.tcl:85 -msgid "Reset" -msgstr "" - -#: lib/checkout_op.tcl:636 -#, tcl-format -msgid "" -"Failed to set current branch.\n" -"\n" -"This working directory is only partially switched. We successfully updated " -"your files, but failed to update an internal Git file.\n" -"\n" -"This should not have occurred. %s will now close and give up." -msgstr "" - -#: lib/remote_add.tcl:20 -#, tcl-format -msgid "%s (%s): Add Remote" -msgstr "" - -#: lib/remote_add.tcl:25 -msgid "Add New Remote" -msgstr "" - -#: lib/remote_add.tcl:30 lib/tools_dlg.tcl:37 -msgid "Add" -msgstr "" - -#: lib/remote_add.tcl:39 -msgid "Remote Details" -msgstr "" - -#: lib/remote_add.tcl:41 lib/tools_dlg.tcl:51 lib/branch_create.tcl:44 -msgid "Name:" -msgstr "" - -#: lib/remote_add.tcl:50 -msgid "Location:" -msgstr "" - -#: lib/remote_add.tcl:60 -msgid "Further Action" -msgstr "" - -#: lib/remote_add.tcl:63 -msgid "Fetch Immediately" -msgstr "" - -#: lib/remote_add.tcl:69 -msgid "Initialize Remote Repository and Push" -msgstr "" - -#: lib/remote_add.tcl:75 -msgid "Do Nothing Else Now" -msgstr "" - -#: lib/remote_add.tcl:100 -msgid "Please supply a remote name." -msgstr "" - -#: lib/remote_add.tcl:113 -#, tcl-format -msgid "'%s' is not an acceptable remote name." -msgstr "" - -#: lib/remote_add.tcl:124 -#, tcl-format -msgid "Failed to add remote '%s' of location '%s'." -msgstr "" - -#: lib/remote_add.tcl:133 -#, tcl-format -msgid "Fetching the %s" -msgstr "" - -#: lib/remote_add.tcl:156 -#, tcl-format -msgid "Do not know how to initialize repository at location '%s'." -msgstr "" - -#: lib/remote_add.tcl:163 -#, tcl-format -msgid "Setting up the %s (at %s)" -msgstr "" - -#: lib/browser.tcl:17 -msgid "Starting..." -msgstr "" - -#: lib/browser.tcl:27 -#, tcl-format -msgid "%s (%s): File Browser" -msgstr "" - -#: lib/browser.tcl:132 lib/browser.tcl:149 -#, tcl-format -msgid "Loading %s..." -msgstr "" - -#: lib/browser.tcl:193 -msgid "[Up To Parent]" -msgstr "" - -#: lib/browser.tcl:275 -#, tcl-format -msgid "%s (%s): Browse Branch Files" -msgstr "" - -#: lib/browser.tcl:282 -msgid "Browse Branch Files" -msgstr "" - -#: lib/browser.tcl:288 lib/choose_repository.tcl:437 -#: lib/choose_repository.tcl:524 lib/choose_repository.tcl:533 -#: lib/choose_repository.tcl:1115 -msgid "Browse" -msgstr "" - -#: lib/browser.tcl:297 lib/branch_checkout.tcl:35 lib/tools_dlg.tcl:321 -msgid "Revision" -msgstr "" - -#: lib/index.tcl:6 -msgid "Unable to unlock the index." -msgstr "" - -#: lib/index.tcl:30 -msgid "Index Error" -msgstr "" - -#: lib/index.tcl:32 -msgid "" -"Updating the Git index failed. A rescan will be automatically started to " -"resynchronize git-gui." -msgstr "" - -#: lib/index.tcl:43 -msgid "Continue" -msgstr "" - -#: lib/index.tcl:46 -msgid "Unlock Index" -msgstr "" - -#: lib/index.tcl:77 lib/index.tcl:146 lib/index.tcl:220 lib/index.tcl:587 -#: lib/choose_repository.tcl:999 -msgid "files" -msgstr "" - -#: lib/index.tcl:326 -msgid "Unstaging selected files from commit" -msgstr "" - -#: lib/index.tcl:330 -#, tcl-format -msgid "Unstaging %s from commit" -msgstr "" - -#: lib/index.tcl:369 -msgid "Ready to commit." -msgstr "" - -#: lib/index.tcl:378 -msgid "Adding selected files" -msgstr "" - -#: lib/index.tcl:382 -#, tcl-format -msgid "Adding %s" -msgstr "" - -#: lib/index.tcl:412 -#, tcl-format -msgid "Stage %d untracked files?" -msgstr "" - -#: lib/index.tcl:420 -msgid "Adding all changed files" -msgstr "" - -#: lib/index.tcl:503 -#, tcl-format -msgid "Revert changes in file %s?" -msgstr "" - -#: lib/index.tcl:508 -#, tcl-format -msgid "Revert changes in these %i files?" -msgstr "" - -#: lib/index.tcl:517 -msgid "Any unstaged changes will be permanently lost by the revert." -msgstr "" - -#: lib/index.tcl:520 lib/index.tcl:563 -msgid "Do Nothing" -msgstr "" - -#: lib/index.tcl:545 -#, tcl-format -msgid "Delete untracked file %s?" -msgstr "" - -#: lib/index.tcl:550 -#, tcl-format -msgid "Delete these %i untracked files?" -msgstr "" - -#: lib/index.tcl:560 -msgid "Files will be permanently deleted." -msgstr "" - -#: lib/index.tcl:564 -msgid "Delete Files" -msgstr "" - -#: lib/index.tcl:586 -msgid "Deleting" -msgstr "" - -#: lib/index.tcl:665 -msgid "Encountered errors deleting files:\n" -msgstr "" - -#: lib/index.tcl:674 -#, tcl-format -msgid "None of the %d selected files could be deleted." -msgstr "" - -#: lib/index.tcl:679 -#, tcl-format -msgid "%d of the %d selected files could not be deleted." -msgstr "" - -#: lib/index.tcl:726 -msgid "Reverting selected files" -msgstr "" - -#: lib/index.tcl:730 -#, tcl-format -msgid "Reverting %s" -msgstr "" - -#: lib/branch_checkout.tcl:16 -#, tcl-format -msgid "%s (%s): Checkout Branch" -msgstr "" - -#: lib/branch_checkout.tcl:21 -msgid "Checkout Branch" -msgstr "" - -#: lib/branch_checkout.tcl:26 -msgid "Checkout" -msgstr "" - -#: lib/branch_checkout.tcl:39 lib/option.tcl:310 lib/branch_create.tcl:69 -msgid "Options" -msgstr "" - -#: lib/branch_checkout.tcl:42 lib/branch_create.tcl:92 -msgid "Fetch Tracking Branch" -msgstr "" - -#: lib/branch_checkout.tcl:47 -msgid "Detach From Local Branch" -msgstr "" - -#: lib/status_bar.tcl:263 -#, tcl-format -msgid "%s ... %*i of %*i %s (%3i%%)" -msgstr "" - -#: lib/remote.tcl:200 -msgid "Push to" -msgstr "" - -#: lib/remote.tcl:218 -msgid "Remove Remote" -msgstr "" - -#: lib/remote.tcl:223 -msgid "Prune from" -msgstr "" - -#: lib/remote.tcl:228 -msgid "Fetch from" -msgstr "" - -#: lib/remote.tcl:249 lib/remote.tcl:253 lib/remote.tcl:258 lib/remote.tcl:264 -msgid "All" -msgstr "" - -#: lib/branch_rename.tcl:15 -#, tcl-format -msgid "%s (%s): Rename Branch" -msgstr "" - -#: lib/branch_rename.tcl:23 -msgid "Rename Branch" -msgstr "" - -#: lib/branch_rename.tcl:28 -msgid "Rename" -msgstr "" - -#: lib/branch_rename.tcl:38 -msgid "Branch:" -msgstr "" - -#: lib/branch_rename.tcl:46 -msgid "New Name:" -msgstr "" - -#: lib/branch_rename.tcl:81 -msgid "Please select a branch to rename." -msgstr "" - -#: lib/branch_rename.tcl:92 lib/branch_create.tcl:154 -msgid "Please supply a branch name." -msgstr "" - -#: lib/branch_rename.tcl:112 lib/branch_create.tcl:165 -#, tcl-format -msgid "'%s' is not an acceptable branch name." -msgstr "" - -#: lib/branch_rename.tcl:123 -#, tcl-format -msgid "Failed to rename '%s'." -msgstr "" - -#: lib/choose_font.tcl:41 -msgid "Select" -msgstr "" - -#: lib/choose_font.tcl:55 -msgid "Font Family" -msgstr "" - -#: lib/choose_font.tcl:76 -msgid "Font Size" -msgstr "" - -#: lib/choose_font.tcl:93 -msgid "Font Example" -msgstr "" - -#: lib/choose_font.tcl:105 -msgid "" -"This is example text.\n" -"If you like this text, it can be your font." -msgstr "" - -#: lib/option.tcl:11 -#, tcl-format -msgid "Invalid global encoding '%s'" -msgstr "" - -#: lib/option.tcl:19 -#, tcl-format -msgid "Invalid repo encoding '%s'" -msgstr "" - -#: lib/option.tcl:119 -msgid "Restore Defaults" -msgstr "" - -#: lib/option.tcl:123 -msgid "Save" -msgstr "" - -#: lib/option.tcl:133 -#, tcl-format -msgid "%s Repository" -msgstr "" - -#: lib/option.tcl:134 -msgid "Global (All Repositories)" -msgstr "" - -#: lib/option.tcl:140 -msgid "User Name" -msgstr "" - -#: lib/option.tcl:141 -msgid "Email Address" -msgstr "" - -#: lib/option.tcl:143 -msgid "Summarize Merge Commits" -msgstr "" - -#: lib/option.tcl:144 -msgid "Merge Verbosity" -msgstr "" - -#: lib/option.tcl:145 -msgid "Show Diffstat After Merge" -msgstr "" - -#: lib/option.tcl:146 -msgid "Use Merge Tool" -msgstr "" - -#: lib/option.tcl:148 -msgid "Trust File Modification Timestamps" -msgstr "" - -#: lib/option.tcl:149 -msgid "Prune Tracking Branches During Fetch" -msgstr "" - -#: lib/option.tcl:150 -msgid "Match Tracking Branches" -msgstr "" - -#: lib/option.tcl:151 -msgid "Use Textconv For Diffs and Blames" -msgstr "" - -#: lib/option.tcl:152 -msgid "Blame Copy Only On Changed Files" -msgstr "" - -#: lib/option.tcl:153 -msgid "Maximum Length of Recent Repositories List" -msgstr "" - -#: lib/option.tcl:154 -msgid "Minimum Letters To Blame Copy On" -msgstr "" - -#: lib/option.tcl:155 -msgid "Blame History Context Radius (days)" -msgstr "" - -#: lib/option.tcl:156 -msgid "Number of Diff Context Lines" -msgstr "" - -#: lib/option.tcl:157 -msgid "Additional Diff Parameters" -msgstr "" - -#: lib/option.tcl:158 -msgid "Commit Message Text Width" -msgstr "" - -#: lib/option.tcl:159 -msgid "New Branch Name Template" -msgstr "" - -#: lib/option.tcl:160 -msgid "Default File Contents Encoding" -msgstr "" - -#: lib/option.tcl:161 -msgid "Warn before committing to a detached head" -msgstr "" - -#: lib/option.tcl:162 -msgid "Staging of untracked files" -msgstr "" - -#: lib/option.tcl:163 -msgid "Show untracked files" -msgstr "" - -#: lib/option.tcl:164 -msgid "Tab spacing" -msgstr "" - -#: lib/option.tcl:182 lib/option.tcl:197 lib/option.tcl:220 lib/option.tcl:282 -#: lib/database.tcl:57 -#, tcl-format -msgid "%s:" -msgstr "" - -#: lib/option.tcl:210 -msgid "Change" -msgstr "" - -#: lib/option.tcl:254 -msgid "Spelling Dictionary:" -msgstr "" - -#: lib/option.tcl:284 -msgid "Change Font" -msgstr "" - -#: lib/option.tcl:288 -#, tcl-format -msgid "Choose %s" -msgstr "" - -#: lib/option.tcl:294 -msgid "pt." -msgstr "" - -#: lib/option.tcl:308 -msgid "Preferences" -msgstr "" - -#: lib/option.tcl:345 -msgid "Failed to completely save options:" -msgstr "" - -#: lib/encoding.tcl:443 -msgid "Default" -msgstr "" - -#: lib/encoding.tcl:448 -#, tcl-format -msgid "System (%s)" -msgstr "" - -#: lib/encoding.tcl:459 lib/encoding.tcl:465 -msgid "Other" -msgstr "" - -#: lib/tools.tcl:76 -#, tcl-format -msgid "Running %s requires a selected file." -msgstr "" - -#: lib/tools.tcl:92 -#, tcl-format -msgid "Are you sure you want to run %1$s on file \"%2$s\"?" -msgstr "" - -#: lib/tools.tcl:96 -#, tcl-format -msgid "Are you sure you want to run %s?" -msgstr "" - -#: lib/tools.tcl:118 -#, tcl-format -msgid "Tool: %s" -msgstr "" - -#: lib/tools.tcl:119 -#, tcl-format -msgid "Running: %s" -msgstr "" - -#: lib/tools.tcl:158 -#, tcl-format -msgid "Tool completed successfully: %s" -msgstr "" - -#: lib/tools.tcl:160 -#, tcl-format -msgid "Tool failed: %s" -msgstr "" - -#: lib/mergetool.tcl:8 -msgid "Force resolution to the base version?" -msgstr "" - -#: lib/mergetool.tcl:9 -msgid "Force resolution to this branch?" -msgstr "" - -#: lib/mergetool.tcl:10 -msgid "Force resolution to the other branch?" -msgstr "" - -#: lib/mergetool.tcl:14 -#, tcl-format -msgid "" -"Note that the diff shows only conflicting changes.\n" -"\n" -"%s will be overwritten.\n" -"\n" -"This operation can be undone only by restarting the merge." -msgstr "" - -#: lib/mergetool.tcl:45 -#, tcl-format -msgid "File %s seems to have unresolved conflicts, still stage?" -msgstr "" - -#: lib/mergetool.tcl:60 -#, tcl-format -msgid "Adding resolution for %s" -msgstr "" - -#: lib/mergetool.tcl:141 -msgid "Cannot resolve deletion or link conflicts using a tool" -msgstr "" - -#: lib/mergetool.tcl:146 -msgid "Conflict file does not exist" -msgstr "" - -#: lib/mergetool.tcl:246 -#, tcl-format -msgid "Not a GUI merge tool: '%s'" -msgstr "" - -#: lib/mergetool.tcl:275 -#, tcl-format -msgid "Unsupported merge tool '%s'" -msgstr "" - -#: lib/mergetool.tcl:310 -msgid "Merge tool is already running, terminate it?" -msgstr "" - -#: lib/mergetool.tcl:330 -#, tcl-format -msgid "" -"Error retrieving versions:\n" -"%s" -msgstr "" - -#: lib/mergetool.tcl:350 -#, tcl-format -msgid "" -"Could not start the merge tool:\n" -"\n" -"%s" -msgstr "" - -#: lib/mergetool.tcl:354 -msgid "Running merge tool..." -msgstr "" - -#: lib/mergetool.tcl:382 lib/mergetool.tcl:390 -msgid "Merge tool failed." -msgstr "" - -#: lib/tools_dlg.tcl:22 -#, tcl-format -msgid "%s (%s): Add Tool" -msgstr "" - -#: lib/tools_dlg.tcl:28 -msgid "Add New Tool Command" -msgstr "" - -#: lib/tools_dlg.tcl:34 -msgid "Add globally" -msgstr "" - -#: lib/tools_dlg.tcl:46 -msgid "Tool Details" -msgstr "" - -#: lib/tools_dlg.tcl:49 -msgid "Use '/' separators to create a submenu tree:" -msgstr "" - -#: lib/tools_dlg.tcl:60 -msgid "Command:" -msgstr "" - -#: lib/tools_dlg.tcl:71 -msgid "Show a dialog before running" -msgstr "" - -#: lib/tools_dlg.tcl:77 -msgid "Ask the user to select a revision (sets $REVISION)" -msgstr "" - -#: lib/tools_dlg.tcl:82 -msgid "Ask the user for additional arguments (sets $ARGS)" -msgstr "" - -#: lib/tools_dlg.tcl:89 -msgid "Don't show the command output window" -msgstr "" - -#: lib/tools_dlg.tcl:94 -msgid "Run only if a diff is selected ($FILENAME not empty)" -msgstr "" - -#: lib/tools_dlg.tcl:118 -msgid "Please supply a name for the tool." -msgstr "" - -#: lib/tools_dlg.tcl:126 -#, tcl-format -msgid "Tool '%s' already exists." -msgstr "" - -#: lib/tools_dlg.tcl:148 -#, tcl-format -msgid "" -"Could not add tool:\n" -"%s" -msgstr "" - -#: lib/tools_dlg.tcl:187 -#, tcl-format -msgid "%s (%s): Remove Tool" -msgstr "" - -#: lib/tools_dlg.tcl:193 -msgid "Remove Tool Commands" -msgstr "" - -#: lib/tools_dlg.tcl:198 -msgid "Remove" -msgstr "" - -#: lib/tools_dlg.tcl:231 -msgid "(Blue denotes repository-local tools)" -msgstr "" - -#: lib/tools_dlg.tcl:283 -#, tcl-format -msgid "%s (%s):" -msgstr "" - -#: lib/tools_dlg.tcl:292 -#, tcl-format -msgid "Run Command: %s" -msgstr "" - -#: lib/tools_dlg.tcl:306 -msgid "Arguments" -msgstr "" - -#: lib/tools_dlg.tcl:341 -msgid "OK" -msgstr "" - -#: lib/search.tcl:48 -msgid "Find:" -msgstr "" - -#: lib/search.tcl:50 -msgid "Next" -msgstr "" - -#: lib/search.tcl:51 -msgid "Prev" -msgstr "" - -#: lib/search.tcl:52 -msgid "RegExp" -msgstr "" - -#: lib/search.tcl:54 -msgid "Case" -msgstr "" - -#: lib/shortcut.tcl:8 lib/shortcut.tcl:43 lib/shortcut.tcl:75 -#, tcl-format -msgid "%s (%s): Create Desktop Icon" -msgstr "" - -#: lib/shortcut.tcl:24 lib/shortcut.tcl:65 -msgid "Cannot write shortcut:" -msgstr "" - -#: lib/shortcut.tcl:140 -msgid "Cannot write icon:" -msgstr "" - -#: lib/remote_branch_delete.tcl:29 -#, tcl-format -msgid "%s (%s): Delete Branch Remotely" -msgstr "" - -#: lib/remote_branch_delete.tcl:34 -msgid "Delete Branch Remotely" -msgstr "" - -#: lib/remote_branch_delete.tcl:48 -msgid "From Repository" -msgstr "" - -#: lib/remote_branch_delete.tcl:88 -msgid "Branches" -msgstr "" - -#: lib/remote_branch_delete.tcl:110 -msgid "Delete Only If" -msgstr "" - -#: lib/remote_branch_delete.tcl:112 -msgid "Merged Into:" -msgstr "" - -#: lib/remote_branch_delete.tcl:120 lib/branch_delete.tcl:53 -msgid "Always (Do not perform merge checks)" -msgstr "" - -#: lib/remote_branch_delete.tcl:153 -msgid "A branch is required for 'Merged Into'." -msgstr "" - -#: lib/remote_branch_delete.tcl:185 -#, tcl-format -msgid "" -"The following branches are not completely merged into %s:\n" -"\n" -" - %s" -msgstr "" - -#: lib/remote_branch_delete.tcl:190 -#, tcl-format -msgid "" -"One or more of the merge tests failed because you have not fetched the " -"necessary commits. Try fetching from %s first." -msgstr "" - -#: lib/remote_branch_delete.tcl:208 -msgid "Please select one or more branches to delete." -msgstr "" - -#: lib/remote_branch_delete.tcl:218 lib/branch_delete.tcl:115 -msgid "" -"Recovering deleted branches is difficult.\n" -"\n" -"Delete the selected branches?" -msgstr "" - -#: lib/remote_branch_delete.tcl:227 -#, tcl-format -msgid "Deleting branches from %s" -msgstr "" - -#: lib/remote_branch_delete.tcl:300 -msgid "No repository selected." -msgstr "" - -#: lib/remote_branch_delete.tcl:305 -#, tcl-format -msgid "Scanning %s..." -msgstr "" - -#: lib/choose_repository.tcl:45 -msgid "Git Gui" -msgstr "" - -#: lib/choose_repository.tcl:104 lib/choose_repository.tcl:427 -msgid "Create New Repository" -msgstr "" - -#: lib/choose_repository.tcl:110 -msgid "New..." -msgstr "" - -#: lib/choose_repository.tcl:117 lib/choose_repository.tcl:511 -msgid "Clone Existing Repository" -msgstr "" - -#: lib/choose_repository.tcl:128 -msgid "Clone..." -msgstr "" - -#: lib/choose_repository.tcl:135 lib/choose_repository.tcl:1105 -msgid "Open Existing Repository" -msgstr "" - -#: lib/choose_repository.tcl:141 -msgid "Open..." -msgstr "" - -#: lib/choose_repository.tcl:154 -msgid "Recent Repositories" -msgstr "" - -#: lib/choose_repository.tcl:164 -msgid "Open Recent Repository:" -msgstr "" - -#: lib/choose_repository.tcl:331 lib/choose_repository.tcl:338 -#: lib/choose_repository.tcl:345 -#, tcl-format -msgid "Failed to create repository %s:" -msgstr "" - -#: lib/choose_repository.tcl:422 lib/branch_create.tcl:33 -msgid "Create" -msgstr "" - -#: lib/choose_repository.tcl:432 -msgid "Directory:" -msgstr "" - -#: lib/choose_repository.tcl:462 lib/choose_repository.tcl:588 -#: lib/choose_repository.tcl:1139 -msgid "Git Repository" -msgstr "" - -#: lib/choose_repository.tcl:487 -#, tcl-format -msgid "Directory %s already exists." -msgstr "" - -#: lib/choose_repository.tcl:491 -#, tcl-format -msgid "File %s already exists." -msgstr "" - -#: lib/choose_repository.tcl:506 -msgid "Clone" -msgstr "" - -#: lib/choose_repository.tcl:519 -msgid "Source Location:" -msgstr "" - -#: lib/choose_repository.tcl:528 -msgid "Target Directory:" -msgstr "" - -#: lib/choose_repository.tcl:538 -msgid "Clone Type:" -msgstr "" - -#: lib/choose_repository.tcl:543 -msgid "Standard (Fast, Semi-Redundant, Hardlinks)" -msgstr "" - -#: lib/choose_repository.tcl:548 -msgid "Full Copy (Slower, Redundant Backup)" -msgstr "" - -#: lib/choose_repository.tcl:553 -msgid "Shared (Fastest, Not Recommended, No Backup)" -msgstr "" - -#: lib/choose_repository.tcl:560 -msgid "Recursively clone submodules too" -msgstr "" - -#: lib/choose_repository.tcl:594 lib/choose_repository.tcl:641 -#: lib/choose_repository.tcl:790 lib/choose_repository.tcl:864 -#: lib/choose_repository.tcl:1145 lib/choose_repository.tcl:1153 -#, tcl-format -msgid "Not a Git repository: %s" -msgstr "" - -#: lib/choose_repository.tcl:630 -msgid "Standard only available for local repository." -msgstr "" - -#: lib/choose_repository.tcl:634 -msgid "Shared only available for local repository." -msgstr "" - -#: lib/choose_repository.tcl:655 -#, tcl-format -msgid "Location %s already exists." -msgstr "" - -#: lib/choose_repository.tcl:666 -msgid "Failed to configure origin" -msgstr "" - -#: lib/choose_repository.tcl:678 -msgid "Counting objects" -msgstr "" - -#: lib/choose_repository.tcl:679 -msgid "buckets" -msgstr "" - -#: lib/choose_repository.tcl:703 -#, tcl-format -msgid "Unable to copy objects/info/alternates: %s" -msgstr "" - -#: lib/choose_repository.tcl:740 -#, tcl-format -msgid "Nothing to clone from %s." -msgstr "" - -#: lib/choose_repository.tcl:742 lib/choose_repository.tcl:962 -#: lib/choose_repository.tcl:974 -msgid "The 'master' branch has not been initialized." -msgstr "" - -#: lib/choose_repository.tcl:755 -msgid "Hardlinks are unavailable. Falling back to copying." -msgstr "" - -#: lib/choose_repository.tcl:769 -#, tcl-format -msgid "Cloning from %s" -msgstr "" - -#: lib/choose_repository.tcl:800 -msgid "Copying objects" -msgstr "" - -#: lib/choose_repository.tcl:801 -msgid "KiB" -msgstr "" - -#: lib/choose_repository.tcl:825 -#, tcl-format -msgid "Unable to copy object: %s" -msgstr "" - -#: lib/choose_repository.tcl:837 -msgid "Linking objects" -msgstr "" - -#: lib/choose_repository.tcl:838 -msgid "objects" -msgstr "" - -#: lib/choose_repository.tcl:846 -#, tcl-format -msgid "Unable to hardlink object: %s" -msgstr "" - -#: lib/choose_repository.tcl:903 -msgid "Cannot fetch branches and objects. See console output for details." -msgstr "" - -#: lib/choose_repository.tcl:914 -msgid "Cannot fetch tags. See console output for details." -msgstr "" - -#: lib/choose_repository.tcl:938 -msgid "Cannot determine HEAD. See console output for details." -msgstr "" - -#: lib/choose_repository.tcl:947 -#, tcl-format -msgid "Unable to cleanup %s" -msgstr "" - -#: lib/choose_repository.tcl:953 -msgid "Clone failed." -msgstr "" - -#: lib/choose_repository.tcl:960 -msgid "No default branch obtained." -msgstr "" - -#: lib/choose_repository.tcl:971 -#, tcl-format -msgid "Cannot resolve %s as a commit." -msgstr "" - -#: lib/choose_repository.tcl:998 -msgid "Creating working directory" -msgstr "" - -#: lib/choose_repository.tcl:1028 -msgid "Initial file checkout failed." -msgstr "" - -#: lib/choose_repository.tcl:1072 -msgid "Cloning submodules" -msgstr "" - -#: lib/choose_repository.tcl:1087 -msgid "Cannot clone submodules." -msgstr "" - -#: lib/choose_repository.tcl:1110 -msgid "Repository:" -msgstr "" - -#: lib/choose_repository.tcl:1159 -#, tcl-format -msgid "Failed to open repository %s:" -msgstr "" - -#: lib/about.tcl:26 -msgid "git-gui - a graphical user interface for Git." -msgstr "" - -#: lib/blame.tcl:74 -#, tcl-format -msgid "%s (%s): File Viewer" -msgstr "" - -#: lib/blame.tcl:80 -msgid "Commit:" -msgstr "" - -#: lib/blame.tcl:282 -msgid "Copy Commit" -msgstr "" - -#: lib/blame.tcl:286 -msgid "Find Text..." -msgstr "" - -#: lib/blame.tcl:290 -msgid "Goto Line..." -msgstr "" - -#: lib/blame.tcl:299 -msgid "Do Full Copy Detection" -msgstr "" - -#: lib/blame.tcl:303 -msgid "Show History Context" -msgstr "" - -#: lib/blame.tcl:306 -msgid "Blame Parent Commit" -msgstr "" - -#: lib/blame.tcl:468 -#, tcl-format -msgid "Reading %s..." -msgstr "" - -#: lib/blame.tcl:596 -msgid "Loading copy/move tracking annotations..." -msgstr "" - -#: lib/blame.tcl:613 -msgid "lines annotated" -msgstr "" - -#: lib/blame.tcl:815 -msgid "Loading original location annotations..." -msgstr "" - -#: lib/blame.tcl:818 -msgid "Annotation complete." -msgstr "" - -#: lib/blame.tcl:849 -msgid "Busy" -msgstr "" - -#: lib/blame.tcl:850 -msgid "Annotation process is already running." -msgstr "" - -#: lib/blame.tcl:889 -msgid "Running thorough copy detection..." -msgstr "" - -#: lib/blame.tcl:957 -msgid "Loading annotation..." -msgstr "" - -#: lib/blame.tcl:1010 -msgid "Author:" -msgstr "" - -#: lib/blame.tcl:1014 -msgid "Committer:" -msgstr "" - -#: lib/blame.tcl:1019 -msgid "Original File:" -msgstr "" - -#: lib/blame.tcl:1067 -msgid "Cannot find HEAD commit:" -msgstr "" - -#: lib/blame.tcl:1122 -msgid "Cannot find parent commit:" -msgstr "" - -#: lib/blame.tcl:1137 -msgid "Unable to display parent" -msgstr "" - -#: lib/blame.tcl:1138 lib/diff.tcl:345 -msgid "Error loading diff:" -msgstr "" - -#: lib/blame.tcl:1279 -msgid "Originally By:" -msgstr "" - -#: lib/blame.tcl:1285 -msgid "In File:" -msgstr "" - -#: lib/blame.tcl:1290 -msgid "Copied Or Moved Here By:" -msgstr "" - -#: lib/diff.tcl:77 -#, tcl-format -msgid "" -"No differences detected.\n" -"\n" -"%s has no changes.\n" -"\n" -"The modification date of this file was updated by another application, but " -"the content within the file was not changed.\n" -"\n" -"A rescan will be automatically started to find other files which may have " -"the same state." -msgstr "" - -#: lib/diff.tcl:117 -#, tcl-format -msgid "Loading diff of %s..." -msgstr "" - -#: lib/diff.tcl:143 -msgid "" -"LOCAL: deleted\n" -"REMOTE:\n" -msgstr "" - -#: lib/diff.tcl:148 -msgid "" -"REMOTE: deleted\n" -"LOCAL:\n" -msgstr "" - -#: lib/diff.tcl:155 -msgid "LOCAL:\n" -msgstr "" - -#: lib/diff.tcl:158 -msgid "REMOTE:\n" -msgstr "" - -#: lib/diff.tcl:220 lib/diff.tcl:344 -#, tcl-format -msgid "Unable to display %s" -msgstr "" - -#: lib/diff.tcl:221 -msgid "Error loading file:" -msgstr "" - -#: lib/diff.tcl:227 -msgid "Git Repository (subproject)" -msgstr "" - -#: lib/diff.tcl:239 -msgid "* Binary file (not showing content)." -msgstr "" - -#: lib/diff.tcl:244 -#, tcl-format -msgid "" -"* Untracked file is %d bytes.\n" -"* Showing only first %d bytes.\n" -msgstr "" - -#: lib/diff.tcl:250 -#, tcl-format -msgid "" -"\n" -"* Untracked file clipped here by %s.\n" -"* To see the entire file, use an external editor.\n" -msgstr "" - -#: lib/diff.tcl:583 -msgid "Failed to unstage selected hunk." -msgstr "" - -#: lib/diff.tcl:591 -msgid "Failed to revert selected hunk." -msgstr "" - -#: lib/diff.tcl:594 -msgid "Failed to stage selected hunk." -msgstr "" - -#: lib/diff.tcl:687 -msgid "Failed to unstage selected line." -msgstr "" - -#: lib/diff.tcl:696 -msgid "Failed to revert selected line." -msgstr "" - -#: lib/diff.tcl:700 -msgid "Failed to stage selected line." -msgstr "" - -#: lib/diff.tcl:889 -msgid "Failed to undo last revert." -msgstr "" - -#: lib/sshkey.tcl:34 -msgid "No keys found." -msgstr "" - -#: lib/sshkey.tcl:37 -#, tcl-format -msgid "Found a public key in: %s" -msgstr "" - -#: lib/sshkey.tcl:43 -msgid "Generate Key" -msgstr "" - -#: lib/sshkey.tcl:61 -msgid "Copy To Clipboard" -msgstr "" - -#: lib/sshkey.tcl:75 -msgid "Your OpenSSH Public Key" -msgstr "" - -#: lib/sshkey.tcl:83 -msgid "Generating..." -msgstr "" - -#: lib/sshkey.tcl:89 -#, tcl-format -msgid "" -"Could not start ssh-keygen:\n" -"\n" -"%s" -msgstr "" - -#: lib/sshkey.tcl:116 -msgid "Generation failed." -msgstr "" - -#: lib/sshkey.tcl:123 -msgid "Generation succeeded, but no keys found." -msgstr "" - -#: lib/sshkey.tcl:126 -#, tcl-format -msgid "Your key is in: %s" -msgstr "" - -#: lib/branch_create.tcl:23 -#, tcl-format -msgid "%s (%s): Create Branch" -msgstr "" - -#: lib/branch_create.tcl:28 -msgid "Create New Branch" -msgstr "" - -#: lib/branch_create.tcl:42 -msgid "Branch Name" -msgstr "" - -#: lib/branch_create.tcl:57 -msgid "Match Tracking Branch Name" -msgstr "" - -#: lib/branch_create.tcl:66 -msgid "Starting Revision" -msgstr "" - -#: lib/branch_create.tcl:72 -msgid "Update Existing Branch:" -msgstr "" - -#: lib/branch_create.tcl:75 -msgid "No" -msgstr "" - -#: lib/branch_create.tcl:80 -msgid "Fast Forward Only" -msgstr "" - -#: lib/branch_create.tcl:97 -msgid "Checkout After Creation" -msgstr "" - -#: lib/branch_create.tcl:132 -msgid "Please select a tracking branch." -msgstr "" - -#: lib/branch_create.tcl:141 -#, tcl-format -msgid "Tracking branch %s is not a branch in the remote repository." -msgstr "" - -#: lib/console.tcl:59 -msgid "Working... please wait..." -msgstr "" - -#: lib/console.tcl:186 -msgid "Success" -msgstr "" - -#: lib/console.tcl:200 -msgid "Error: Command Failed" -msgstr "" - -#: lib/line.tcl:17 -msgid "Goto Line:" -msgstr "" - -#: lib/line.tcl:23 -msgid "Go" -msgstr "" - -#: lib/choose_rev.tcl:52 -msgid "This Detached Checkout" -msgstr "" - -#: lib/choose_rev.tcl:60 -msgid "Revision Expression:" -msgstr "" - -#: lib/choose_rev.tcl:72 -msgid "Local Branch" -msgstr "" - -#: lib/choose_rev.tcl:77 -msgid "Tracking Branch" -msgstr "" - -#: lib/choose_rev.tcl:82 lib/choose_rev.tcl:544 -msgid "Tag" -msgstr "" - -#: lib/choose_rev.tcl:321 -#, tcl-format -msgid "Invalid revision: %s" -msgstr "" - -#: lib/choose_rev.tcl:342 -msgid "No revision selected." -msgstr "" - -#: lib/choose_rev.tcl:350 -msgid "Revision expression is empty." -msgstr "" - -#: lib/choose_rev.tcl:537 -msgid "Updated" -msgstr "" - -#: lib/choose_rev.tcl:565 -msgid "URL" -msgstr "" - -#: lib/commit.tcl:9 -msgid "" -"There is nothing to amend.\n" -"\n" -"You are about to create the initial commit. There is no commit before this " -"to amend.\n" -msgstr "" - -#: lib/commit.tcl:18 -msgid "" -"Cannot amend while merging.\n" -"\n" -"You are currently in the middle of a merge that has not been fully " -"completed. You cannot amend the prior commit unless you first abort the " -"current merge activity.\n" -msgstr "" - -#: lib/commit.tcl:56 -msgid "Error loading commit data for amend:" -msgstr "" - -#: lib/commit.tcl:83 -msgid "Unable to obtain your identity:" -msgstr "" - -#: lib/commit.tcl:88 -msgid "Invalid GIT_COMMITTER_IDENT:" -msgstr "" - -#: lib/commit.tcl:138 -#, tcl-format -msgid "warning: Tcl does not support encoding '%s'." -msgstr "" - -#: lib/commit.tcl:158 -msgid "" -"Last scanned state does not match repository state.\n" -"\n" -"Another Git program has modified this repository since the last scan. A " -"rescan must be performed before another commit can be created.\n" -"\n" -"The rescan will be automatically started now.\n" -msgstr "" - -#: lib/commit.tcl:182 -#, tcl-format -msgid "" -"Unmerged files cannot be committed.\n" -"\n" -"File %s has merge conflicts. You must resolve them and stage the file " -"before committing.\n" -msgstr "" - -#: lib/commit.tcl:190 -#, tcl-format -msgid "" -"Unknown file state %s detected.\n" -"\n" -"File %s cannot be committed by this program.\n" -msgstr "" - -#: lib/commit.tcl:198 -msgid "" -"No changes to commit.\n" -"\n" -"You must stage at least 1 file before you can commit.\n" -msgstr "" - -#: lib/commit.tcl:213 -msgid "" -"Please supply a commit message.\n" -"\n" -"A good commit message has the following format:\n" -"\n" -"- First line: Describe in one sentence what you did.\n" -"- Second line: Blank\n" -"- Remaining lines: Describe why this change is good.\n" -msgstr "" - -#: lib/commit.tcl:244 -msgid "Calling pre-commit hook..." -msgstr "" - -#: lib/commit.tcl:259 -msgid "Commit declined by pre-commit hook." -msgstr "" - -#: lib/commit.tcl:278 -msgid "" -"You are about to commit on a detached head. This is a potentially dangerous " -"thing to do because if you switch to another branch you will lose your " -"changes and it can be difficult to retrieve them later from the reflog. You " -"should probably cancel this commit and create a new branch to continue.\n" -" \n" -" Do you really want to proceed with your Commit?" -msgstr "" - -#: lib/commit.tcl:299 -msgid "Calling commit-msg hook..." -msgstr "" - -#: lib/commit.tcl:314 -msgid "Commit declined by commit-msg hook." -msgstr "" - -#: lib/commit.tcl:327 -msgid "Committing changes..." -msgstr "" - -#: lib/commit.tcl:344 -msgid "write-tree failed:" -msgstr "" - -#: lib/commit.tcl:345 lib/commit.tcl:395 lib/commit.tcl:422 -msgid "Commit failed." -msgstr "" - -#: lib/commit.tcl:362 -#, tcl-format -msgid "Commit %s appears to be corrupt" -msgstr "" - -#: lib/commit.tcl:367 -msgid "" -"No changes to commit.\n" -"\n" -"No files were modified by this commit and it was not a merge commit.\n" -"\n" -"A rescan will be automatically started now.\n" -msgstr "" - -#: lib/commit.tcl:374 -msgid "No changes to commit." -msgstr "" - -#: lib/commit.tcl:394 -msgid "commit-tree failed:" -msgstr "" - -#: lib/commit.tcl:421 -msgid "update-ref failed:" -msgstr "" - -#: lib/commit.tcl:514 -#, tcl-format -msgid "Created commit %s: %s" -msgstr "" - -#: lib/branch_delete.tcl:16 -#, tcl-format -msgid "%s (%s): Delete Branch" -msgstr "" - -#: lib/branch_delete.tcl:21 -msgid "Delete Local Branch" -msgstr "" - -#: lib/branch_delete.tcl:39 -msgid "Local Branches" -msgstr "" - -#: lib/branch_delete.tcl:51 -msgid "Delete Only If Merged Into" -msgstr "" - -#: lib/branch_delete.tcl:103 -#, tcl-format -msgid "The following branches are not completely merged into %s:" -msgstr "" - -#: lib/branch_delete.tcl:131 -#, tcl-format -msgid " - %s:" -msgstr "" - -#: lib/branch_delete.tcl:141 -#, tcl-format -msgid "" -"Failed to delete branches:\n" -"%s" -msgstr "" - -#: lib/date.tcl:25 -#, tcl-format -msgid "Invalid date from Git: %s" -msgstr "" - -#: lib/database.tcl:42 -msgid "Number of loose objects" -msgstr "" - -#: lib/database.tcl:43 -msgid "Disk space used by loose objects" -msgstr "" - -#: lib/database.tcl:44 -msgid "Number of packed objects" -msgstr "" - -#: lib/database.tcl:45 -msgid "Number of packs" -msgstr "" - -#: lib/database.tcl:46 -msgid "Disk space used by packed objects" -msgstr "" - -#: lib/database.tcl:47 -msgid "Packed objects waiting for pruning" -msgstr "" - -#: lib/database.tcl:48 -msgid "Garbage files" -msgstr "" - -#: lib/database.tcl:66 -#, tcl-format -msgid "%s (%s): Database Statistics" -msgstr "" - -#: lib/database.tcl:72 -msgid "Compressing the object database" -msgstr "" - -#: lib/database.tcl:83 -msgid "Verifying the object database with fsck-objects" -msgstr "" - -#: lib/database.tcl:107 -#, tcl-format -msgid "" -"This repository currently has approximately %i loose objects.\n" -"\n" -"To maintain optimal performance it is strongly recommended that you compress " -"the database.\n" -"\n" -"Compress the database now?" -msgstr "" - -#: lib/error.tcl:20 -#, tcl-format -msgid "%s: error" -msgstr "" - -#: lib/error.tcl:36 -#, tcl-format -msgid "%s: warning" -msgstr "" - -#: lib/error.tcl:80 -#, tcl-format -msgid "%s hook failed:" -msgstr "" - -#: lib/error.tcl:96 -msgid "You must correct the above errors before committing." -msgstr "" - -#: lib/error.tcl:116 -#, tcl-format -msgid "%s (%s): error" -msgstr "" - -#: lib/merge.tcl:13 -msgid "" -"Cannot merge while amending.\n" -"\n" -"You must finish amending this commit before starting any type of merge.\n" -msgstr "" - -#: lib/merge.tcl:27 -msgid "" -"Last scanned state does not match repository state.\n" -"\n" -"Another Git program has modified this repository since the last scan. A " -"rescan must be performed before a merge can be performed.\n" -"\n" -"The rescan will be automatically started now.\n" -msgstr "" - -#: lib/merge.tcl:45 -#, tcl-format -msgid "" -"You are in the middle of a conflicted merge.\n" -"\n" -"File %s has merge conflicts.\n" -"\n" -"You must resolve them, stage the file, and commit to complete the current " -"merge. Only then can you begin another merge.\n" -msgstr "" - -#: lib/merge.tcl:55 -#, tcl-format -msgid "" -"You are in the middle of a change.\n" -"\n" -"File %s is modified.\n" -"\n" -"You should complete the current commit before starting a merge. Doing so " -"will help you abort a failed merge, should the need arise.\n" -msgstr "" - -#: lib/merge.tcl:108 -#, tcl-format -msgid "%s of %s" -msgstr "" - -#: lib/merge.tcl:126 -#, tcl-format -msgid "Merging %s and %s..." -msgstr "" - -#: lib/merge.tcl:137 -msgid "Merge completed successfully." -msgstr "" - -#: lib/merge.tcl:139 -msgid "Merge failed. Conflict resolution is required." -msgstr "" - -#: lib/merge.tcl:156 -#, tcl-format -msgid "%s (%s): Merge" -msgstr "" - -#: lib/merge.tcl:164 -#, tcl-format -msgid "Merge Into %s" -msgstr "" - -#: lib/merge.tcl:183 -msgid "Revision To Merge" -msgstr "" - -#: lib/merge.tcl:218 -msgid "" -"Cannot abort while amending.\n" -"\n" -"You must finish amending this commit.\n" -msgstr "" - -#: lib/merge.tcl:228 -msgid "" -"Abort merge?\n" -"\n" -"Aborting the current merge will cause *ALL* uncommitted changes to be lost.\n" -"\n" -"Continue with aborting the current merge?" -msgstr "" - -#: lib/merge.tcl:234 -msgid "" -"Reset changes?\n" -"\n" -"Resetting the changes will cause *ALL* uncommitted changes to be lost.\n" -"\n" -"Continue with resetting the current changes?" -msgstr "" - -#: lib/merge.tcl:246 -msgid "Aborting" -msgstr "" - -#: lib/merge.tcl:247 -msgid "files reset" -msgstr "" - -#: lib/merge.tcl:277 -msgid "Abort failed." -msgstr "" - -#: lib/merge.tcl:279 -msgid "Abort completed. Ready." -msgstr "" diff --git a/git-request-pull.sh b/git-request-pull.sh index 775ba8ea11..6a7b793678 100755 --- a/git-request-pull.sh +++ b/git-request-pull.sh @@ -78,41 +78,47 @@ fi merge_base=$(git merge-base $baserev $headrev) || die "fatal: No commits in common between $base and $head" -# $head is the refname from the command line. -# Find a ref with the same name as $head that exists at the remote +find_matching_ref () { + while read sha1 ref + do + case "$ref" in + *"^"?*) + ref="${ref%"^"*}" + deref=true + ;; + *) + deref= + ;; + esac + + if test "$sha1" = "${remote:-HEAD}" + then + echo "$sha1 $sha1" + break + fi + + case "$ref" in + "${remote:-HEAD}"|*"/${remote:-HEAD}") + if test -z "$deref" + then + # Remember the matching unpeeled object on the + # remote side. + remote_sha1="$sha1" + fi + + if test "$sha1" = "$headrev" + then + echo "${remote_sha1:-$headrev} $ref" + break + fi + ;; + esac + done +} + +# Find a ref with the same name as $remote that exists at the remote # and points to the same commit as the local object. -find_matching_ref=' - my ($head,$headrev) = (@ARGV); - my $pattern = qr{/\Q$head\E$}; - my ($remote_sha1, $found); - - while (<STDIN>) { - chomp; - my ($sha1, $ref, $deref) = /^(\S+)\s+([^^]+)(\S*)$/; - - if ($sha1 eq $head) { - $found = $remote_sha1 = $sha1; - break; - } - - if ($ref eq $head || $ref =~ $pattern) { - if ($deref eq "") { - # Remember the matching object on the remote side - $remote_sha1 = $sha1; - } - if ($sha1 eq $headrev) { - $found = $ref; - break; - } - } - } - if ($found) { - $remote_sha1 = $headrev if ! defined $remote_sha1; - print "$remote_sha1 $found\n"; - } -' - -set fnord $(git ls-remote "$url" | @PERL_PATH@ -e "$find_matching_ref" "${remote:-HEAD}" "$headrev") +set fnord $(git ls-remote "$url" | find_matching_ref) remote_sha1=$2 ref=$3 diff --git a/git-send-email.perl b/git-send-email.perl index 1f613fa979..4215f8f7e9 100755 --- a/git-send-email.perl +++ b/git-send-email.perl @@ -41,6 +41,8 @@ git send-email --translate-aliases --subject <str> * Email "Subject:" --reply-to <str> * Email "Reply-To:" --in-reply-to <str> * Email "In-Reply-To:" + --[no-]outlook-id-fix * The SMTP host is an Outlook server that munges the + Message-ID. Retrieve it from the server. --[no-]xmailer * Add "X-Mailer:" header (default). --[no-]annotate * Review each patch that will be sent in an editor. --compose * Open an editor for introduction. @@ -68,7 +70,7 @@ git send-email --translate-aliases --smtp-auth <str> * Space-separated list of allowed AUTH mechanisms, or "none" to disable authentication. This setting forces to use one of the listed mechanisms. - --no-smtp-auth Disable SMTP authentication. Shorthand for + --no-smtp-auth * Disable SMTP authentication. Shorthand for `--smtp-auth=none` --smtp-debug <0|1> * Disable, enable Net::SMTP debug. @@ -290,6 +292,7 @@ my $validate = 1; my $mailmap = 0; my $target_xfer_encoding = 'auto'; my $forbid_sendmail_variables = 1; +my $outlook_id_fix = 'auto'; my %config_bool_settings = ( "thread" => \$thread, @@ -305,6 +308,7 @@ my %config_bool_settings = ( "xmailer" => \$use_xmailer, "forbidsendmailvariables" => \$forbid_sendmail_variables, "mailmap" => \$mailmap, + "outlookidfix" => \$outlook_id_fix, ); my %config_settings = ( @@ -551,6 +555,7 @@ my %options = ( "relogin-delay=i" => \$relogin_delay, "git-completion-helper" => \$git_completion_helper, "v=s" => \$reroll_count, + "outlook-id-fix!" => \$outlook_id_fix, ); $rc = GetOptions(%options); @@ -1574,6 +1579,16 @@ Message-ID: $message_id return ($recipients_ref, $to, $date, $gitversion, $cc, $ccline, $header); } +sub is_outlook { + my ($host) = @_; + if ($outlook_id_fix eq 'auto') { + $outlook_id_fix = + ($host eq 'smtp.office365.com' || + $host eq 'smtp-mail.outlook.com') ? 1 : 0; + } + return $outlook_id_fix; +} + # Prepares the email, then asks the user what to do. # # If the user chooses to send the email, it's sent and 1 is returned. @@ -1737,6 +1752,22 @@ EOF $smtp->datasend("$line") or die $smtp->message; } $smtp->dataend() or die $smtp->message; + + # Outlook discards the Message-ID header we set while sending the email + # and generates a new random Message-ID. So in order to avoid breaking + # threads, we simply retrieve the Message-ID from the server response + # and assign it to the $message_id variable, which will then be + # assigned to $in_reply_to by the caller when the next message is sent + # as a response to this message. + if (is_outlook($smtp_server)) { + if ($smtp->message =~ /<([^>]+)>/) { + $message_id = "<$1>"; + printf __("Outlook reassigned Message-ID to: %s\n"), $message_id; + } else { + warn __("Warning: Could not retrieve Message-ID from server response.\n"); + } + } + $smtp->code =~ /250|200/ or die sprintf(__("Failed to send %s\n"), $subject).$smtp->message; } if ($quiet) { diff --git a/git-zlib.h b/git-zlib.h index 1e8d9aabcb..0e66fefa8c 100644 --- a/git-zlib.h +++ b/git-zlib.h @@ -4,7 +4,7 @@ #include "compat/zlib-compat.h" typedef struct git_zstream { - z_stream z; + struct z_stream_s z; unsigned long avail_in; unsigned long avail_out; unsigned long total_in; diff --git a/gitk-git/gitk b/gitk-git/gitk index bc9efa1856..11ad639d06 100755 --- a/gitk-git/gitk +++ b/gitk-git/gitk @@ -13,133 +13,102 @@ package require Tk ## ## Enabling platform-specific code paths -proc is_MacOSX {} { - if {[tk windowingsystem] eq {aqua}} { - return 1 - } - return 0 -} - proc is_Windows {} { - if {$::tcl_platform(platform) eq {windows}} { - return 1 - } - return 0 -} - -set _iscygwin {} -proc is_Cygwin {} { - global _iscygwin - if {$_iscygwin eq {}} { - if {[string match "CYGWIN_*" $::tcl_platform(os)]} { - set _iscygwin 1 - } else { - set _iscygwin 0 - } - } - return $_iscygwin + if {$::tcl_platform(platform) eq {windows}} { + return 1 + } + return 0 } ###################################################################### ## ## PATH lookup -set _search_path {} -proc _which {what args} { - global env _search_exe _search_path - - if {$_search_path eq {}} { - if {[is_Cygwin] && [regexp {^(/|\.:)} $env(PATH)]} { - set _search_path [split [exec cygpath \ - --windows \ - --path \ - --absolute \ - $env(PATH)] {;}] - set _search_exe .exe - } elseif {[is_Windows]} { - set gitguidir [file dirname [info script]] - regsub -all ";" $gitguidir "\\;" gitguidir - set env(PATH) "$gitguidir;$env(PATH)" - set _search_path [split $env(PATH) {;}] - # Skip empty `PATH` elements - set _search_path [lsearch -all -inline -not -exact \ - $_search_path ""] - set _search_exe .exe - } else { - set _search_path [split $env(PATH) :] - set _search_exe {} - } - } - - if {[is_Windows] && [lsearch -exact $args -script] >= 0} { - set suffix {} - } else { - set suffix $_search_exe - } - - foreach p $_search_path { - set p [file join $p $what$suffix] - if {[file exists $p]} { - return [file normalize $p] - } - } - return {} -} - -proc sanitize_command_line {command_line from_index} { - set i $from_index - while {$i < [llength $command_line]} { - set cmd [lindex $command_line $i] - if {[file pathtype $cmd] ne "absolute"} { - set fullpath [_which $cmd] - if {$fullpath eq ""} { - throw {NOT-FOUND} "$cmd not found in PATH" - } - lset command_line $i $fullpath - } - - # handle piped commands, e.g. `exec A | B` - for {incr i} {$i < [llength $command_line]} {incr i} { - if {[lindex $command_line $i] eq "|"} { - incr i - break - } - } - } - return $command_line -} - -# Override `exec` to avoid unsafe PATH lookup - -rename exec real_exec - -proc exec {args} { - # skip options - for {set i 0} {$i < [llength $args]} {incr i} { - set arg [lindex $args $i] - if {$arg eq "--"} { - incr i - break - } - if {[string range $arg 0 0] ne "-"} { - break - } - } - set args [sanitize_command_line $args $i] - uplevel 1 real_exec $args -} - -# Override `open` to avoid unsafe PATH lookup - -rename open real_open - -proc open {args} { - set arg0 [lindex $args 0] - if {[string range $arg0 0 0] eq "|"} { - set command_line [string trim [string range $arg0 1 end]] - lset args 0 "| [sanitize_command_line $command_line 0]" - } - uplevel 1 real_open $args +if {[is_Windows]} { + set _search_path {} + proc _which {what args} { + global env _search_path + + if {$_search_path eq {}} { + set gitguidir [file dirname [info script]] + regsub -all ";" $gitguidir "\\;" gitguidir + set env(PATH) "$gitguidir;$env(PATH)" + set _search_path [split $env(PATH) {;}] + # Skip empty `PATH` elements + set _search_path [lsearch -all -inline -not -exact \ + $_search_path ""] + } + + if {[lsearch -exact $args -script] >= 0} { + set suffix {} + } else { + set suffix .exe + } + + foreach p $_search_path { + set p [file join $p $what$suffix] + if {[file exists $p]} { + return [file normalize $p] + } + } + return {} + } + + proc sanitize_command_line {command_line from_index} { + set i $from_index + while {$i < [llength $command_line]} { + set cmd [lindex $command_line $i] + if {[llength [file split $cmd]] < 2} { + set fullpath [_which $cmd] + if {$fullpath eq ""} { + throw {NOT-FOUND} "$cmd not found in PATH" + } + lset command_line $i $fullpath + } + + # handle piped commands, e.g. `exec A | B` + for {incr i} {$i < [llength $command_line]} {incr i} { + if {[lindex $command_line $i] eq "|"} { + incr i + break + } + } + } + return $command_line + } + + # Override `exec` to avoid unsafe PATH lookup + + rename exec real_exec + + proc exec {args} { + # skip options + for {set i 0} {$i < [llength $args]} {incr i} { + set arg [lindex $args $i] + if {$arg eq "--"} { + incr i + break + } + if {[string range $arg 0 0] ne "-"} { + break + } + } + set args [sanitize_command_line $args $i] + uplevel 1 real_exec $args + } + + # Override `open` to avoid unsafe PATH lookup + + rename open real_open + + proc open {args} { + set arg0 [lindex $args 0] + if {[string range $arg0 0 0] eq "|"} { + set command_line [string trim [string range $arg0 1 end]] + lset args 0 "| [sanitize_command_line $command_line 0]" + } + uplevel 1 real_open $args + } } # End of safe PATH lookup stuff @@ -491,11 +460,11 @@ proc parseviewrevs {view revs} { # Escapes a list of filter paths to be passed to git log via stdin. Note that # paths must not be quoted. proc escape_filter_paths {paths} { - set escaped [list] - foreach path $paths { - lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path] - } - return $escaped + set escaped [list] + foreach path $paths { + lappend escaped [string map {\\ \\\\ "\ " "\\\ "} $path] + } + return $escaped } # Start off a git log process and arrange to read its output @@ -4632,7 +4601,7 @@ proc addviewmenu {n} { .bar.view add radiobutton -label $viewname($n) \ -command [list showview $n] -variable selectedview -value $n #$viewhlmenu add radiobutton -label $viewname($n) \ - # -command [list addvhighlight $n] -variable selectedhlview + # -command [list addvhighlight $n] -variable selectedhlview } proc showview {n} { diff --git a/gitk-git/po/meson.build b/gitk-git/po/meson.build index b1ed019828..c00b3d5c8d 100644 --- a/gitk-git/po/meson.build +++ b/gitk-git/po/meson.build @@ -12,6 +12,7 @@ import('i18n').gettext('gitk', 'pt_pt', 'ru', 'sv', + 'ta', 'vi', 'zh_cn', ], diff --git a/gitk-git/po/ta.po b/gitk-git/po/ta.po new file mode 100644 index 0000000000..0e390c5153 --- /dev/null +++ b/gitk-git/po/ta.po @@ -0,0 +1,1457 @@ +# Translation of gitk +# Copyright (C) 2024-2025 தமிழ்நேரம் +# This file is distributed under the same license as the gitk package. +# தமிழ்நேரம் (TamilNeram.github.io), 2025. +# +# +msgid "" +msgstr "" +"Project-Id-Version: gitk\n" +"Report-Msgid-Bugs-To: \n" +"POT-Creation-Date: 2025-05-07 08:01+0530\n" +"PO-Revision-Date: 2025-05-07 09:17\n" +"Last-Translator: தமிழ்நேரம் (TamilNeram.github.io)\n" +"Language-Team: Tamil\n" +"Language: \n" +"MIME-Version: 1.0\n" +"Content-Type: text/plain; charset=UTF-8\n" +"Content-Transfer-Encoding: 8bit\n" + +#: gitk:274 +msgid "Couldn't get list of unmerged files:" +msgstr "ஒருங்கிணைக்கப்படாத கோப்புகளின் பட்டியலைப் பெற முடியவில்லை:" + +#: gitk:346 gitk:2565 +msgid "Color words" +msgstr "வண்ண சொற்கள்" + +#: gitk:351 gitk:2565 gitk:8476 gitk:8509 +msgid "Markup words" +msgstr "குறிக்கப்பட்ட சொற்கள்" + +#: gitk:458 +msgid "Error parsing revisions:" +msgstr "பிழைகளை பாகுபடுத்துதல்:" + +#: gitk:524 +msgid "Error executing --argscmd command:" +msgstr "--argscmd கட்டளையை இயக்குவதில் பிழை:" + +#: gitk:537 +msgid "No files selected: --merge specified but no files are unmerged." +msgstr "" +"கோப்புகள் எதுவும் தேர்ந்தெடுக்கப்படவில்லை: --ஒன்றிணை குறிப்பிடப்பட்டுள்ளது, " +"ஆனால் கோப்புகள் எதுவும் அவிழ்க்கப்படவில்லை." + +#: gitk:540 +msgid "" +"No files selected: --merge specified but no unmerged files are within file " +"limit." +msgstr "" +"கோப்புகள் எதுவும் தேர்ந்தெடுக்கப்படவில்லை: --ஒன்றிணை குறிப்பிடப்பட்டுள்ளது, " +"ஆனால் அவிழ்க்கப்படாத கோப்புகள் எதுவும் கோப்பு வரம்பிற்குள் இல்லை." + +#: gitk:565 gitk:720 +msgid "Error executing git log:" +msgstr "அறிவிலி பதிவை இயக்குவதில் பிழை:" + +#: gitk:583 gitk:736 +msgid "Reading" +msgstr "படித்தல்" + +#: gitk:643 gitk:4736 +msgid "Reading commits..." +msgstr "உறுதிமொழிகளைப் படித்தல்..." + +#: gitk:646 gitk:1795 gitk:4739 +msgid "No commits selected" +msgstr "எந்த உறுதிமொழிகளும் தேர்ந்தெடுக்கப்படவில்லை" + +#: gitk:1603 gitk:4256 gitk:12883 +msgid "Command line" +msgstr "கட்டளை வரி" + +#: gitk:1669 +msgid "Can't parse git log output:" +msgstr "அறிவிலி பதிவு வெளியீட்டை அலச முடியாது:" + +#: gitk:1898 +msgid "No commit information available" +msgstr "உறுதிமொழி செய்தி எதுவும் கிடைக்கவில்லை" + +#: gitk:2065 gitk:2094 gitk:4526 gitk:10016 gitk:11626 gitk:11946 +msgid "OK" +msgstr "சரி" + +#: gitk:2096 gitk:4528 gitk:9452 gitk:9531 gitk:9661 gitk:9747 gitk:10018 +#: gitk:11627 gitk:11947 +msgid "Cancel" +msgstr "நீக்கறல்" + +#: gitk:2249 +msgid "&Update" +msgstr "புதுப்பித்தல்" + +#: gitk:2250 +msgid "&Reload" +msgstr "மீண்டும் ஏற்று" + +#: gitk:2251 +msgid "Reread re&ferences" +msgstr "குறிப்புகளை மீண்டும் படி" + +#: gitk:2252 +msgid "&List references" +msgstr "பட்டியல் குறிப்புகள்" + +#: gitk:2254 +msgid "Start git &gui" +msgstr "அறிவிலி இடைமுகத்தைத் தொடங்கு" + +#: gitk:2256 +msgid "&Quit" +msgstr "வெளியேறு" + +#: gitk:2248 +msgid "&File" +msgstr "கோப்பு" + +#: gitk:2260 +msgid "&Preferences" +msgstr "விருப்பத்தேர்வுகள்" + +#: gitk:2259 +msgid "&Edit" +msgstr "திருத்து" + +#: gitk:2264 +msgid "&New view..." +msgstr "புதிய பார்வை..." + +#: gitk:2265 +msgid "&Edit view..." +msgstr "பார்வையைத் திருத்து..." + +#: gitk:2266 +msgid "&Delete view" +msgstr "பார்வையை நீக்கு" + +#: gitk:2268 +msgid "&All files" +msgstr "அனைத்து கோப்புகளும்" + +#: gitk:2263 +msgid "&View" +msgstr "காண்க" + +#: gitk:2273 gitk:2283 +msgid "&About gitk" +msgstr "அறிவிலிகே பற்றி" + +#: gitk:2274 gitk:2288 +msgid "&Key bindings" +msgstr "முக்கிய பிணைப்புகள்" + +#: gitk:2272 gitk:2287 +msgid "&Help" +msgstr "உதவி" + +#: gitk:2365 gitk:8908 +msgid "Commit ID:" +msgstr "உறுதிமொழி அடையாளம்:" + +#: gitk:2409 +msgid "Row" +msgstr "நிரை" + +#: gitk:2447 +msgid "Find" +msgstr "கண்டுபிடி" + +#: gitk:2475 +msgid "commit" +msgstr "உறுதிமொழி" + +#: gitk:2479 gitk:2481 gitk:4898 gitk:4921 gitk:4945 gitk:6966 gitk:7038 +#: gitk:7123 +msgid "containing:" +msgstr "கொண்டிருக்கிறது:" + +#: gitk:2482 gitk:3737 gitk:3742 gitk:4974 +msgid "touching paths:" +msgstr "தொடும் பாதைகள்:" + +#: gitk:2483 gitk:4988 +msgid "adding/removing string:" +msgstr "சரத்தைச் சேர்ப்பது/அகற்றுவது:" + +#: gitk:2484 gitk:4990 +msgid "changing lines matching:" +msgstr "பொருந்தக்கூடிய வரிகளை மாற்றுதல்:" + +#: gitk:2493 gitk:2495 gitk:4977 +msgid "Exact" +msgstr "சரியான" + +#: gitk:2495 gitk:5065 gitk:6934 +msgid "IgnCase" +msgstr "வழக்குதவிர்" + +#: gitk:2495 gitk:4947 gitk:5063 gitk:6930 +msgid "Regexp" +msgstr "வழக்கவெளி" + +#: gitk:2497 gitk:2498 gitk:5085 gitk:5115 gitk:5122 gitk:7059 gitk:7127 +msgid "All fields" +msgstr "அனைத்து புலங்களும்" + +#: gitk:2498 gitk:5082 gitk:5115 gitk:6997 +msgid "Headline" +msgstr "தலைப்பு" + +#: gitk:2499 gitk:5082 gitk:6997 gitk:7127 gitk:7639 +msgid "Comments" +msgstr "கருத்துகள்" + +#: gitk:2499 gitk:5082 gitk:5087 gitk:5122 gitk:6997 gitk:7574 gitk:9086 +#: gitk:9101 +msgid "Author" +msgstr "நூலாசிரியர்" + +#: gitk:2499 gitk:5082 gitk:6997 gitk:7576 +msgid "Committer" +msgstr "உறுதிமொழிபவர்" + +#: gitk:2533 +msgid "Search" +msgstr "தேடு" + +#: gitk:2541 +msgid "Diff" +msgstr "வேறுபாடு" + +#: gitk:2543 +msgid "Old version" +msgstr "பழைய பதிப்பு" + +#: gitk:2545 +msgid "New version" +msgstr "புதிய பதிப்பு" + +#: gitk:2548 +msgid "Lines of context" +msgstr "சூழலின் வரிகள்" + +#: gitk:2558 +msgid "Ignore space change" +msgstr "இடைவெளி மாற்றத்தை புறக்கணி" + +#: gitk:2562 gitk:2564 gitk:8209 gitk:8462 +msgid "Line diff" +msgstr "வரி வேறுபாடு" + +#: gitk:2637 +msgid "Patch" +msgstr "ஒட்டு" + +#: gitk:2639 +msgid "Tree" +msgstr "மரம்" + +#: gitk:2814 gitk:2835 +msgid "Diff this -> selected" +msgstr "இதை வேறுபடுத்துங்கள் -> தேர்ந்தெடுக்கப்பட்டது" + +#: gitk:2815 gitk:2836 +msgid "Diff selected -> this" +msgstr "வேறுபாடு தேர்ந்தெடுக்கப்பட்டது -> இது" + +#: gitk:2816 gitk:2837 +msgid "Make patch" +msgstr "ஒட்டு செய்" + +#: gitk:2817 gitk:9510 +msgid "Create tag" +msgstr "குறிச்சொல்லை உருவாக்கு" + +#: gitk:2818 +msgid "Copy commit reference" +msgstr "உறுதிமொழி குறிப்பு நகலெடு" + +#: gitk:2819 gitk:9641 +msgid "Write commit to file" +msgstr "கோப்பில் உறவை எழுதுங்கள்" + +#: gitk:2820 +msgid "Create new branch" +msgstr "புதிய கிளையை உருவாக்கு" + +#: gitk:2821 +msgid "Cherry-pick this commit" +msgstr "கனி-எடு இந்த உறுதிமொழி" + +#: gitk:2822 +msgid "Reset HEAD branch to here" +msgstr "தலை கிளையை இங்கே மீட்டமை" + +#: gitk:2823 +msgid "Mark this commit" +msgstr "இந்த உறுதிமொழியைக் குறி" + +#: gitk:2824 +msgid "Return to mark" +msgstr "மார்க்குக்குத் திரும்பு" + +#: gitk:2825 +msgid "Find descendant of this and mark" +msgstr "இதன் வழித்தோன்றலைக் கண்டுபிடித்து குறி" + +#: gitk:2826 +msgid "Compare with marked commit" +msgstr "குறிக்கப்பட்ட உறுதிப்பாட்டுடன் ஒப்பிடுக" + +#: gitk:2827 gitk:2838 +msgid "Diff this -> marked commit" +msgstr "இதை வேறுபடுத்துங்கள் -> குறிக்கப்பட்ட உறுதிமொழி" + +#: gitk:2828 gitk:2839 +msgid "Diff marked commit -> this" +msgstr "வேறுபாடு குறிக்கப்பட்ட உறுதிமொழி -> இது" + +#: gitk:2829 +msgid "Revert this commit" +msgstr "இந்த உறுதிப்பாட்டை மாற்றவும்" + +#: gitk:2845 +msgid "Check out this branch" +msgstr "இந்த கிளையைப் பாருங்கள்" + +#: gitk:2846 +msgid "Rename this branch" +msgstr "இந்த கிளையை மறுபெயரிடு" + +#: gitk:2847 +msgid "Remove this branch" +msgstr "இந்த கிளையை அகற்று" + +#: gitk:2848 +msgid "Copy branch name" +msgstr "கிளை பெயரை நகலெடு" + +#: gitk:2855 +msgid "Highlight this too" +msgstr "இதை முன்னிலைப்படுத்து" + +#: gitk:2856 +msgid "Highlight this only" +msgstr "இதை முன்னிலைப்படுத்து" + +#: gitk:2857 +msgid "External diff" +msgstr "வெளிப்புற வேறுபாடு" + +#: gitk:2858 +msgid "Blame parent commit" +msgstr "பெற்றோரை குற்றம் சாட்டு" + +#: gitk:2859 +msgid "Copy path" +msgstr "நகல் பாதை" + +#: gitk:2866 +msgid "Show origin of this line" +msgstr "இந்த வரியின் தோற்றத்தைக் காட்டு" + +#: gitk:2867 +msgid "Run git gui blame on this line" +msgstr "இந்த வரியில் அறிவிலி இடைமுகம் பழியை இயக்கு" + +#: gitk:3221 +msgid "About gitk" +msgstr "அறிவிலிகே பற்றி" + +#: gitk:3223 +msgid "" +"\n" +"Gitk - a commit viewer for git\n" +"\n" +"Copyright © 2005-2016 Paul Mackerras\n" +"\n" +"Use and redistribute under the terms of the GNU General Public License" +msgstr "" +"\n" +"அறிவிலிகே - அறிவிலி ஒரு உறுதிமொழி பார்வையாளர் \n" +"\n" +"பதிப்புரிமை © 2005-2016 பால் மெக்கெராச் \n" +"\n" +"குனு பொது பொதுமக்கள் உரிமத்தின் விதிமுறைகளின் கீழ் பயன்படுத்தவும் மறுபகிர்வு செய்யவும்" + +#: gitk:3231 gitk:3298 gitk:10231 +msgid "Close" +msgstr "மூடு" + +#: gitk:3252 +msgid "Gitk key bindings" +msgstr "அறிவிலிகே விசை பிணைப்புகள்" + +#: gitk:3255 +msgid "Gitk key bindings:" +msgstr "அறிவிலிகே விசை பிணைப்புகள்:" + +#: gitk:3257 +#, tcl-format +msgid "<%s-Q>\t\tQuit" +msgstr "<%s-Q>\t\tவெளியேறு" + +#: gitk:3258 +#, tcl-format +msgid "<%s-W>\t\tClose window" +msgstr "<%s-w>\t\tசாளரத்தை மூடு" + +#: gitk:3259 +msgid "<Home>\t\tMove to first commit" +msgstr "<வீடு> முதல் உறுதிமொழிக்கு நகர்த்து" + +#: gitk:3260 +msgid "<End>\t\tMove to last commit" +msgstr "<முடி> கடைசி உறுதிமொழிக்கு நகர்த்து" + +#: gitk:3261 +msgid "<Up>, p, k\tMove up one commit" +msgstr "<மேலே>, பி, கே\tஒரு உறுதிமொழியை மேலே நகர்த்து" + +#: gitk:3262 +msgid "<Down>, n, j\tMove down one commit" +msgstr "<கீழ்>, n, j\tஒரு உறுதிமொழியை கீழே நகர்த்து" + +#: gitk:3263 +msgid "<Left>, z, h\tGo back in history list" +msgstr "<இடது>, z, h\tவரலாற்று பட்டியலில் திரும்பிச் செல்" + +#: gitk:3264 +msgid "<Right>, x, l\tGo forward in history list" +msgstr "<வலது>, x, l\tவரலாற்று பட்டியலில் முன்னோக்கி செல்" + +#: gitk:3265 +#, tcl-format +msgid "<%s-n>\tGo to n-th parent of current commit in history list" +msgstr "" +"<%s-n> வரலாற்று பட்டியலில் தற்போதைய உறுதிப்பாட்டின் n- வது பெற்றோரிடம் " +"செல்" + +#: gitk:3266 +msgid "<PageUp>\tMove up one page in commit list" +msgstr "<பக்கம்மேல்>\tஉறுதிமொழி பட்டியலில் ஒரு பக்கத்தை நகர்த்து" + +#: gitk:3267 +msgid "<PageDown>\tMove down one page in commit list" +msgstr "<பக்கம்கீழ்>\tஉறுதிமொழி பட்டியலில் ஒரு பக்கத்தை நகர்த்து" + +#: gitk:3268 +#, tcl-format +msgid "<%s-Home>\tScroll to top of commit list" +msgstr "<%s-வீடு>\tஉறுதிமொழி பட்டியலை மேல் பகுதிக்கு உருட்டவும்" + +#: gitk:3269 +#, tcl-format +msgid "<%s-End>\tScroll to bottom of commit list" +msgstr "<%s-முடி> உறுதிமொழி பட்டியலின் கீழ் பகுதிக்கு உருட்டவும்" + +#: gitk:3270 +#, tcl-format +msgid "<%s-Up>\tScroll commit list up one line" +msgstr "<%s-மேலே>\tஉறுதிமொழி பட்டியலை ஒரு வரி மேலே உருட்டவும்" + +#: gitk:3271 +#, tcl-format +msgid "<%s-Down>\tScroll commit list down one line" +msgstr "<%s-கீழ்>\tஉறுதிமொழி பட்டியலை ஒரு வரி கீழே உருட்டவும்" + +#: gitk:3272 +#, tcl-format +msgid "<%s-PageUp>\tScroll commit list up one page" +msgstr "<%s-பக்கம்மேலே>\tஉறுதிமொழி பட்டியலை ஒரு பக்கம் மேலே உருட்டவும்" + +#: gitk:3273 +#, tcl-format +msgid "<%s-PageDown>\tScroll commit list down one page" +msgstr "<%s-பக்கம்கீழ்>\tஉறுதிமொழி பட்டியலை ஒரு பக்கம் கீழே உருட்டவும்" + +#: gitk:3274 +msgid "<Shift-Up>\tFind backwards (upwards, later commits)" +msgstr "<உயர்த்து-மேலே>\tபின்னோக்கி கண்டுபிடி (மேல்நோக்கி, பின்னர் உறுதிமொழிகள்)" + +#: gitk:3275 +msgid "<Shift-Down>\tFind forwards (downwards, earlier commits)" +msgstr "" +"<உயர்த்து-கீழே>\tமுன்னோக்குகளைக் கண்டறியவும் (கீழ்நோக்கி, முந்தைய " +"உறுதிமொழிகள்)" + +#: gitk:3276 +msgid "<Delete>, b\tScroll diff view up one page" +msgstr "<நீக்கு>, b\tசுருள் வேறுபாடு ஒரு பக்கத்தை மேலே காண்க" + +#: gitk:3277 +msgid "<Backspace>\tScroll diff view up one page" +msgstr "<பின்வெளி>\tசுருள் வேறுபாடு ஒரு பக்கத்தை மேலே காண்க" + +#: gitk:3278 +msgid "<Space>\t\tScroll diff view down one page" +msgstr "<Space>\t\tசுருள் வேறுபாடு ஒரு பக்கத்தைக் கீழே காண்க" + +#: gitk:3279 +msgid "u\t\tScroll diff view up 18 lines" +msgstr "u\t\tசுருள் வேறுபாடு 18 வரிகளை மேலே காண்க" + +#: gitk:3280 +msgid "d\t\tScroll diff view down 18 lines" +msgstr "d\t\tசுருள் வேறுபாடு 18 வரிகளைக் கீழே காண்க" + +#: gitk:3281 +#, tcl-format +msgid "<%s-F>\t\tFind" +msgstr "<%s-F>\t\tகண்டுபிடி" + +#: gitk:3282 +#, tcl-format +msgid "<%s-G>\t\tMove to next find hit" +msgstr "<%s-G>\t\tஅடுத்த கண்டுபிடிப்பு வெற்றிக்கு செல்" + +#: gitk:3283 +msgid "<Return>\tMove to next find hit" +msgstr "<திரும்பு>\tஅடுத்ததைக் கண்டுபிடி" + +#: gitk:3284 +msgid "g\t\tGo to commit" +msgstr "g\t\tஉறுதிமொழிக்கு செல்" + +#: gitk:3285 +msgid "/\t\tFocus the search box" +msgstr "/\t\tதேடல் பெட்டியில் கவனம் செலுத்து" + +#: gitk:3286 +msgid "?\t\tMove to previous find hit" +msgstr "?\t\tமுந்தைய கண்டுபிடிப்பு வெற்றிக்கு செல்" + +#: gitk:3287 +msgid "f\t\tScroll diff view to next file" +msgstr "f\t\tஅடுத்த கோப்பிற்கு உருள் வேறுபாடு பார்வை" + +#: gitk:3288 +#, tcl-format +msgid "<%s-S>\t\tSearch for next hit in diff view" +msgstr "<%s-S>\t\tவேறுபாடு பார்வையில் அடுத்த வெற்றியைத் தேடுங்கள்" + +#: gitk:3289 +#, tcl-format +msgid "<%s-R>\t\tSearch for previous hit in diff view" +msgstr "<%s-r> வேறுபட்ட பார்வையில் முந்தைய வெற்றியைத் தேடுங்கள்" + +#: gitk:3290 +#, tcl-format +msgid "<%s-KP+>\tIncrease font size" +msgstr "<%s-KP+>\tஎழுத்துரு அளவை அதிகரி" + +#: gitk:3291 +#, tcl-format +msgid "<%s-plus>\tIncrease font size" +msgstr "<%s-plus>\tஎழுத்துரு அளவை அதிகரி" + +#: gitk:3292 +#, tcl-format +msgid "<%s-KP->\tDecrease font size" +msgstr "<%s-KP->\tஎழுத்துரு அளவைக் குறை" + +#: gitk:3293 +#, tcl-format +msgid "<%s-minus>\tDecrease font size" +msgstr "<%s-minus>\tஎழுத்துரு அளவைக் குறை" + +#: gitk:3294 +msgid "<F5>\t\tUpdate" +msgstr "<F5>\t\tபுதுப்பிப்பு" + +#: gitk:3761 gitk:3770 +#, tcl-format +msgid "Error creating temporary directory %s:" +msgstr "தற்காலிக அடைவு %s ஐ உருவாக்குவது பிழை:" + +#: gitk:3783 +#, tcl-format +msgid "Error getting \"%s\" from %s:" +msgstr "%s இலிருந்து \" %s\" பெறுவது பிழை:" + +#: gitk:3846 +msgid "command failed:" +msgstr "கட்டளை தோல்வியுற்றது:" + +#: gitk:3995 +msgid "No such commit" +msgstr "அத்தகைய உறுதிமொழி இல்லை" + +#: gitk:4009 +msgid "git gui blame: command failed:" +msgstr "அறிவிலி இடைமுக பழி: கட்டளை தோல்வியுற்றது:" + +#: gitk:4040 +#, tcl-format +msgid "Couldn't read merge head: %s" +msgstr "ஒன்றிணைப்பு தலையைப் படிக்க முடியவில்லை: %s" + +#: gitk:4048 +#, tcl-format +msgid "Error reading index: %s" +msgstr "பிழை வாசிப்பு குறியீடு: %s" + +#: gitk:4073 +#, tcl-format +msgid "Couldn't start git blame: %s" +msgstr "அறிவிலி பழியைத் தொடங்க முடியவில்லை: %s" + +#: gitk:4076 gitk:6965 +msgid "Searching" +msgstr "தேடுகிறது" + +#: gitk:4108 +#, tcl-format +msgid "Error running git blame: %s" +msgstr "பிழை இயங்கும் அறிவிலி பழி: %s" + +#: gitk:4136 +#, tcl-format +msgid "That line comes from commit %s, which is not in this view" +msgstr "" +"அந்த வரி உறுதிமொழி %s என்பதிலிருந்து வருகிறது, இது இந்த பார்வையில் இல்லை" + +#: gitk:4150 +msgid "External diff viewer failed:" +msgstr "வெளிப்புற வேறுபாடு பார்வையாளர் தோல்வியுற்றது:" + +#: gitk:4254 +msgid "All files" +msgstr "அனைத்து கோப்புகளும்" + +#: gitk:4278 +msgid "View" +msgstr "காண்க" + +#: gitk:4281 +msgid "Gitk view definition" +msgstr "அறிவிலிகே பார்வை வரையறை" + +#: gitk:4285 +msgid "Remember this view" +msgstr "இந்த பார்வையை நினைவில் கொள்ளுங்கள்" + +#: gitk:4286 +msgid "References (space separated list):" +msgstr "குறிப்புகள் (இடைவெளி பிரிக்கப்பட்ட பட்டியல்):" + +#: gitk:4287 +msgid "Branches & tags:" +msgstr "கிளைகள் மற்றும் குறிச்சொற்கள்:" + +#: gitk:4288 +msgid "All refs" +msgstr "அனைத்து குறிப்புகள்" + +#: gitk:4289 +msgid "All (local) branches" +msgstr "அனைத்து (உள்ளக) கிளைகளும்" + +#: gitk:4290 +msgid "All tags" +msgstr "அனைத்து குறிச்சொற்களும்" + +#: gitk:4291 +msgid "All remote-tracking branches" +msgstr "அனைத்து தொலை-கண்காணிப்பு கிளைகளும்" + +#: gitk:4292 +msgid "Commit Info (regular expressions):" +msgstr "உறுதிமொழி செய்தி (வழக்கமான வெளிப்பாடுகள்):" + +#: gitk:4293 +msgid "Author:" +msgstr "ஆசிரியர்:" + +#: gitk:4294 +msgid "Committer:" +msgstr "உறுதிமொழிபவர்:" + +#: gitk:4295 +msgid "Commit Message:" +msgstr "உறுதிமொழி செய்தி:" + +#: gitk:4296 +msgid "Matches all Commit Info criteria" +msgstr "அனைத்து உறுதிமொழி செய்தி அளவுகோல்களையும் பொருத்துகிறது" + +#: gitk:4297 +msgid "Matches no Commit Info criteria" +msgstr "உறுதிமொழி செய்தி அளவுகோல்களுடன் பொருந்தவில்லை" + +#: gitk:4298 +msgid "Changes to Files:" +msgstr "கோப்புகளில் மாற்றங்கள்:" + +#: gitk:4299 +msgid "Fixed String" +msgstr "நிலையான சரம்" + +#: gitk:4300 +msgid "Regular Expression" +msgstr "வழக்கமான வெளிப்பாடு" + +#: gitk:4301 +msgid "Search string:" +msgstr "தேடல் சரம்:" + +#: gitk:4302 +msgid "" +"Commit Dates (\"2 weeks ago\", \"2009-03-17 15:27:38\", \"March 17, 2009 " +"15:27:38\"):" +msgstr "" +"உறுதிமொழி தேதிகள் (\"2 வாரங்களுக்கு முன்பு\", \"2009-01-16 15:27:38\", \"மார்ச் 17, " +"2009 15:27:38\"):" + +#: gitk:4303 +msgid "Since:" +msgstr "பின்னர்:" + +#: gitk:4304 +msgid "Until:" +msgstr "வரை:" + +#: gitk:4305 +msgid "Limit and/or skip a number of revisions (positive integer):" +msgstr "" +"பல திருத்தங்களை (நேர்மறை முழு எண்) கட்டுப்படுத்து மற்றும்/அல்லது தவிர்:" + +#: gitk:4306 +msgid "Number to show:" +msgstr "காண்பிக்க எண்:" + +#: gitk:4307 +msgid "Number to skip:" +msgstr "தவிர்க்க எண்:" + +#: gitk:4308 +msgid "Miscellaneous options:" +msgstr "இதர விருப்பங்கள்:" + +#: gitk:4309 +msgid "Strictly sort by date" +msgstr "கண்டிப்பாக தேதியின்படி வரிசைப்படுத்து" + +#: gitk:4310 +msgid "Mark branch sides" +msgstr "கிளை பக்கங்களைக் குறி" + +#: gitk:4311 +msgid "Limit to first parent" +msgstr "முதல் பெற்றோருக்கு வரம்பு" + +#: gitk:4312 +msgid "Simple history" +msgstr "எளிய வரலாறு" + +#: gitk:4313 +msgid "Additional arguments to git log:" +msgstr "அறிவிலி பதிவுக்கு கூடுதல் வாதங்கள்:" + +#: gitk:4314 +msgid "Enter files and directories to include, one per line:" +msgstr "சேர்க்க கோப்புகள் மற்றும் கோப்பகங்களை உள்ளிடவும், ஒரு வரிக்கு ஒன்று:" + +#: gitk:4315 +msgid "Command to generate more commits to include:" +msgstr "சேர்க்க கூடுதல் உறுதிமொழிகளை உருவாக்க கட்டளை:" + +#: gitk:4439 +msgid "Gitk: edit view" +msgstr "அறிவிலிகே: திருத்து பார்வை" + +#: gitk:4447 +msgid "-- criteria for selecting revisions" +msgstr "-- திருத்தங்களைத் தேர்ந்தெடுப்பதற்கான அளவுகோல்கள்" + +#: gitk:4452 +msgid "View Name" +msgstr "பெயரைக் காண்க" + +#: gitk:4527 +msgid "Apply (F5)" +msgstr "இடு (F5)" + +#: gitk:4565 +msgid "Error in commit selection arguments:" +msgstr "உறுதிமொழி தேர்வு வாதங்களில் பிழை:" + +#: gitk:4620 gitk:4673 gitk:5135 gitk:5149 gitk:6419 gitk:12820 gitk:12821 +msgid "None" +msgstr "எதுவுமில்லை" + +#: gitk:5232 gitk:5237 +msgid "Descendant" +msgstr "வழித்தோன்றல்" + +#: gitk:5233 +msgid "Not descendant" +msgstr "வழித்தோன்றல் அல்ல" + +#: gitk:5240 gitk:5245 +msgid "Ancestor" +msgstr "மூதாதையர்" + +#: gitk:5241 +msgid "Not ancestor" +msgstr "மூதாதையர் அல்ல" + +#: gitk:5535 +msgid "Local changes checked in to index but not committed" +msgstr "" +"உள்ளக மாற்றங்கள் குறியீட்டில் சரிபார்க்கப்பட்டன, ஆனால் உறுதிமொழியவில்லை" + +#: gitk:5571 +msgid "Local uncommitted changes, not checked in to index" +msgstr "உள்ளக உறுதிமொழியாத மாற்றங்கள், குறியீட்டில் சரிபார்க்கப்படவில்லை" + +#: gitk:7319 +msgid "Error starting web browser:" +msgstr "வலை உலாவியைத் தொடங்குவதில் பிழை:" + +#: gitk:7380 +msgid "and many more" +msgstr "மற்றும் மேலும் பல" + +#: gitk:7383 +msgid "many" +msgstr "பல" + +#: gitk:7578 +msgid "Tags:" +msgstr "குறிச்சொற்கள்:" + +#: gitk:7595 gitk:7601 gitk:9081 +msgid "Parent" +msgstr "பெற்றோர்" + +#: gitk:7606 +msgid "Child" +msgstr "குழந்தை" + +#: gitk:7615 +msgid "Branch" +msgstr "கிளை" + +#: gitk:7618 +msgid "Follows" +msgstr "பின்வருமாறு" + +#: gitk:7621 +msgid "Precedes" +msgstr "முன்னால்" + +#: gitk:8216 +#, tcl-format +msgid "Error getting diffs: %s" +msgstr "வேறுபாடு பெறுவதில் பிழை: %s" + +#: gitk:8906 +msgid "Goto:" +msgstr "செல்:" + +#: gitk:8927 +#, tcl-format +msgid "Short commit ID %s is ambiguous" +msgstr "குறுகிய உறுதிமொழி அடையாளம் %s தெளிவற்றவை" + +#: gitk:8934 +#, tcl-format +msgid "Revision %s is not known" +msgstr "திருத்தம் %s தெரியவில்லை" + +#: gitk:8944 +#, tcl-format +msgid "Commit ID %s is not known" +msgstr "உறுதிமொழி அடையாளம் %s அறியப்படவில்லை" + +#: gitk:8946 +#, tcl-format +msgid "Revision %s is not in the current view" +msgstr "திருத்தம் %s தற்போதைய பார்வையில் இல்லை" + +#: gitk:9088 gitk:9103 +msgid "Date" +msgstr "திகதி" + +#: gitk:9091 +msgid "Children" +msgstr "குழந்தைகள்" + +#: gitk:9154 +#, tcl-format +msgid "Reset %s branch to here" +msgstr "%s கிளையை இங்கே மீட்டமை" + +#: gitk:9156 +msgid "Detached head: can't reset" +msgstr "பிரிக்கப்பட்ட தலை: மீட்டமைக்க முடியாது" + +#: gitk:9261 gitk:9267 +msgid "Skipping merge commit " +msgstr "ஒன்றிணை உறுதிமொழியை தவர்கிறது " + +#: gitk:9276 gitk:9281 +msgid "Error getting patch ID for " +msgstr "ஒட்டு அடையாளத்தைப் பெறுவதில் பிழை" + +#: gitk:9277 gitk:9282 +msgid " - stopping\n" +msgstr "- நிறுத்துதல்\n" + +#: gitk:9287 gitk:9290 gitk:9298 gitk:9312 gitk:9321 +msgid "Commit " +msgstr "உறுதிமொழி" + +#: gitk:9291 +msgid "" +" is the same patch as\n" +" " +msgstr "அதே ஒட்டு\n" +" " + +#: gitk:9299 +msgid "" +" differs from\n" +" " +msgstr "இருந்து வேறுபடுகிறது\n" +" " + +#: gitk:9301 +msgid "" +"Diff of commits:\n" +"\n" +msgstr "உறுதிமொழியின் வேறுபாடு:\n" +"\n" + +#: gitk:9313 gitk:9322 +#, tcl-format +msgid " has %s children - stopping\n" +msgstr "%s குழந்தைகள் உள்ளனர் - நிறுத்துதல்\n" + +#: gitk:9341 +#, tcl-format +msgid "Error writing commit to file: %s" +msgstr "உறுதிமொழி கோப்பில் எழுதுதல் பிழை: %s" + +#: gitk:9347 +#, tcl-format +msgid "Error diffing commits: %s" +msgstr "உறுதிமொழிகள் வேறுபாடு பிழை: %s" + +#: gitk:9393 +msgid "Top" +msgstr "மேலே" + +#: gitk:9394 +msgid "From" +msgstr "இருந்து" + +#: gitk:9399 +msgid "To" +msgstr "பெறுநர்" + +#: gitk:9423 +msgid "Generate patch" +msgstr "ஒட்டை உருவாக்கு" + +#: gitk:9425 +msgid "From:" +msgstr "இருந்து:" + +#: gitk:9434 +msgid "To:" +msgstr "இதற்கு:" + +#: gitk:9443 +msgid "Reverse" +msgstr "தலைகீழ்" + +#: gitk:9445 gitk:9655 +msgid "Output file:" +msgstr "வெளியீட்டு கோப்பு:" + +#: gitk:9451 +msgid "Generate" +msgstr "உருவாக்கு" + +#: gitk:9489 +msgid "Error creating patch:" +msgstr "ஒட்டை உருவாக்கு பிழை:" + +#: gitk:9512 gitk:9643 gitk:9731 +msgid "ID:" +msgstr "அடையாளம்:" + +#: gitk:9521 +msgid "Tag name:" +msgstr "குறிச்சொல் பெயர்:" + +#: gitk:9524 +msgid "Tag message is optional" +msgstr "குறிச்சொல் செய்தி விருப்பமானது" + +#: gitk:9526 +msgid "Tag message:" +msgstr "குறிச்சொல் செய்தி:" + +#: gitk:9530 gitk:9701 +msgid "Create" +msgstr "உருவாக்கு" + +#: gitk:9548 +msgid "No tag name specified" +msgstr "குறிச்சொல் பெயர் குறிப்பிடப்படவில்லை" + +#: gitk:9552 +#, tcl-format +msgid "Tag \"%s\" already exists" +msgstr "குறிச்சொல் \"%s\" ஏற்கனவே உள்ளது" + +#: gitk:9562 +msgid "Error creating tag:" +msgstr "குறிச்சொல்லை உருவாக்கு பிழை:" + +#: gitk:9652 +msgid "Command:" +msgstr "கட்டளை:" + +#: gitk:9660 +msgid "Write" +msgstr "எழுது" + +#: gitk:9678 +msgid "Error writing commit:" +msgstr "பிழை எழுதுதல் உறுதிமொழி:" + +#: gitk:9700 +msgid "Create branch" +msgstr "கிளையை உருவாக்கு" + +#: gitk:9716 +#, tcl-format +msgid "Rename branch %s" +msgstr "%s கிளையை மறுபெயரிடு" + +#: gitk:9717 +msgid "Rename" +msgstr "மறுபெயரிடு" + +#: gitk:9741 +msgid "Name:" +msgstr "பெயர்:" + +#: gitk:9765 +msgid "Please specify a name for the new branch" +msgstr "புதிய கிளைக்கு ஒரு பெயரைக் குறிப்பிடு" + +#: gitk:9770 +#, tcl-format +msgid "Branch '%s' already exists. Overwrite?" +msgstr "கிளை '%s' ஏற்கனவே உள்ளது. மேலெழுதவா?" + +#: gitk:9814 +msgid "Please specify a new name for the branch" +msgstr "கிளைக்கு ஒரு புதிய பெயரைக் குறிப்பிடு" + +#: gitk:9877 +#, tcl-format +msgid "Commit %s is already included in branch %s -- really re-apply it?" +msgstr "" +"உறுதிமொழி %s ஏற்கனவே கிளை %s சேர்க்கப்பட்டுள்ளன-உண்மையில் அதை மீண்டும் இடவா?" + +#: gitk:9882 +msgid "Cherry-picking" +msgstr "கனி எடுக்கும்" + +#: gitk:9891 +#, tcl-format +msgid "" +"Cherry-pick failed because of local changes to file '%s'.\n" +"Please commit, reset or stash your changes and try again." +msgstr "" +"'%s' கோப்பில் உள்ளக மாற்றங்கள் காரணமாக கனி-எடு தோல்வியடைந்தது. \n" +"தயவுசெய்து உங்கள் மாற்றங்களைச் உறுதிமொழி, மீட்டமை அல்லது சேமி பிறகு மீண்டும் முயற்சி." + +#: gitk:9897 +msgid "" +"Cherry-pick failed because of merge conflict.\n" +"Do you wish to run git citool to resolve it?" +msgstr "" +"ஒன்றிணைக்கும் மோதல் காரணமாக கனி-எடு தோல்வியடைந்தது. \n" +"அதை தீர்க்க அறிவிலி சிஐகருவியை இயக்க விரும்புகிறீர்களா?" + +#: gitk:9913 gitk:9971 +msgid "No changes committed" +msgstr "எந்த மாற்றங்களும் உறுதிமொழியப்படவில்லை" + +#: gitk:9940 +#, tcl-format +msgid "Commit %s is not included in branch %s -- really revert it?" +msgstr "" +"உறுதிமொழி %s கிளை %s சேர்க்கப்படவில்லை - உண்மையில் அதை மீட்டெடுக்கவா?" + +#: gitk:9945 +msgid "Reverting" +msgstr "மீட்டெடுத்தல்" + +#: gitk:9953 +#, tcl-format +msgid "" +"Revert failed because of local changes to the following files:%s Please " +"commit, reset or stash your changes and try again." +msgstr "" +"பின்வரும் கோப்புகளில் உள்ளக மாற்றங்கள் காரணமாக மீட்டெடு தோல்வியுற்றது:%s " +"தயவுசெய்து உங்கள் மாற்றங்களைச் உறுதிமொழி, மீட்டமை அல்லது " +"சேமி மற்றும் மீண்டும் முயற்சி." + +#: gitk:9957 +msgid "" +"Revert failed because of merge conflict.\n" +" Do you wish to run git citool to resolve it?" +msgstr "" +"ஒன்றிணைக்கும் மோதல் காரணமாக மீட்டெடு தோல்வியடைந்தது. \n" +"அதை தீர்க்க அறிவிலி சிஐகருவியை இயக்க விரும்புகிறீர்களா?" + +#: gitk:10000 +msgid "Confirm reset" +msgstr "மீட்டமைப்பை உறுதிப்படுத்து" + +#: gitk:10002 +#, tcl-format +msgid "Reset branch %s to %s?" +msgstr "%s கிளையை %s க்கு மீட்டமைக்கவா?" + +#: gitk:10004 +msgid "Reset type:" +msgstr "மீட்டமை வகை:" + +#: gitk:10007 +msgid "Soft: Leave working tree and index untouched" +msgstr "" +"மென்மை: வேலை செய்யும் மரம் மற்றும் குறியீட்டைத் தீண்டாமல் விடு" + +#: gitk:10010 +msgid "Mixed: Leave working tree untouched, reset index" +msgstr "" +"கலப்பு: வேலை செய்யும் மரத்தை தீண்டாமல் விடு, குறியீட்டை மீட்டமை" + +#: gitk:10013 +msgid "" +"Hard: Reset working tree and index\n" +"(discard ALL local changes)" +msgstr "" +"கடினம்: வேலை செய்யும் மரம் மற்றும் குறியீட்டை மீட்டமை \n" +"(அனைத்து உள்ளக மாற்றங்களையும் நிராகரி)" + +#: gitk:10030 +msgid "Resetting" +msgstr "மீட்டமைத்தல்" + +#: gitk:10103 +#, tcl-format +msgid "A local branch named %s exists already" +msgstr "%s என்ற உள்ளக கிளை ஏற்கனவே உள்ளது" + +#: gitk:10111 +msgid "Checking out" +msgstr "சரிபார்" + +#: gitk:10170 +msgid "Cannot delete the currently checked-out branch" +msgstr "தற்போது சரிபார்க்கப்பட்ட கிளையை நீக்க முடியாது" + +#: gitk:10176 +#, tcl-format +msgid "" +"The commits on branch %s aren't on any other branch.\n" +"Really delete branch %s?" +msgstr "" +"கிளை %s மீதான உறுதிமொழிகள் வேறு எந்த கிளையிலும் இல்லை. \n" +"உண்மையில் கிளை %s நீக்கவா?" + +#: gitk:10207 +#, tcl-format +msgid "Tags and heads: %s" +msgstr "குறிச்சொற்கள் மற்றும் தலைகள்: %s" + +#: gitk:10224 +msgid "Filter" +msgstr "வடிப்பி" + +#: gitk:10531 +msgid "" +"Error reading commit topology information; branch and preceding/following " +"tag information will be incomplete." +msgstr "" +"உறுதிமொழி இடவியல் தகவலை படிப்பதில் பிழை; கிளை மற்றும் அதற்கு " +"முந்தைய/பின்வரும் குறிச்சொல் செய்தி முழுமையடையாது." + +#: gitk:11508 +msgid "Tag" +msgstr "குறிச்சொல்" + +#: gitk:11512 +msgid "Id" +msgstr "அடையாளம்" + +#: gitk:11595 +msgid "Gitk font chooser" +msgstr "அறிவிலிகே எழுத்துரு தேர்வு" + +#: gitk:11612 +msgid "B" +msgstr "பி" + +#: gitk:11615 +msgid "I" +msgstr "ஐ" + +#: gitk:11734 +msgid "Commit list display options" +msgstr "உறுதிமொழி பட்டியல் காட்சி விருப்பங்கள்" + +#: gitk:11737 +msgid "Maximum graph width (lines)" +msgstr "அதிகபட்ச வரைபட அகலம் (கோடுகள்)" + +#: gitk:11741 +#, no-tcl-format +msgid "Maximum graph width (% of pane)" +msgstr "அதிகபட்ச வரைபட அகலம் (பலகத்தின் %)" + +#: gitk:11744 +msgid "Show local changes" +msgstr "உள்ளக மாற்றங்களைக் காட்டு" + +#: gitk:11747 +msgid "Hide remote refs" +msgstr "தொலை குறிகளை மறை" + +#: gitk:11751 +msgid "Copy commit ID to clipboard" +msgstr "இடைநிலைப்பலகைக்கு அடையாளத்தை நகலெடு" + +#: gitk:11755 +msgid "Copy commit ID to X11 selection" +msgstr "உறுதிமொழி அடையாளத்தை ஃ11 பகுதிக்கு நகலெடு" + +#: gitk:11760 +msgid "Length of commit ID to copy" +msgstr "நகலெடுக்க உறுதிமொழி அடையாளத்தின் நீளம்" + +#: gitk:11763 +msgid "Diff display options" +msgstr "வேறுபாடு காட்சி விருப்பங்கள்" + +#: gitk:11765 +msgid "Tab spacing" +msgstr "தாவல் இடைவெளி" + +#: gitk:11769 +msgid "Wrap comment text" +msgstr "கருத்து உரையை மடி" + +#: gitk:11774 +msgid "Wrap other text" +msgstr "மற்ற உரையை மடி" + +#: gitk:11779 +msgid "Display nearby tags/heads" +msgstr "அருகிலுள்ள குறிச்சொற்கள்/தலைகளைக் காண்பி" + +#: gitk:11782 +msgid "Maximum # tags/heads to show" +msgstr "காண்பிக்க அதிகபட்ச # குறிச்சொற்கள்/தலைகள்" + +#: gitk:11785 +msgid "Limit diffs to listed paths" +msgstr "பட்டியலிடப்பட்ட பாதைகளுக்கு வரம்பு வேறுபடுகிறது" + +#: gitk:11788 +msgid "Support per-file encodings" +msgstr "ஒரு கோப்பு குறியீடுகளை ஆதரி" + +#: gitk:11794 gitk:11961 +msgid "External diff tool" +msgstr "வெளிப்புற வேறுபாடு கருவி" + +#: gitk:11795 +msgid "Choose..." +msgstr "தேர்வு..." + +#: gitk:11802 +msgid "Web browser" +msgstr "வலை உலாவி" + +#: gitk:11807 +msgid "General options" +msgstr "பொது விருப்பங்கள்" + +#: gitk:11810 +msgid "Use themed widgets" +msgstr "கருப்பொருள் நிரல்பலகைகளைப் பயன்படுத்து" + +#: gitk:11812 +msgid "(change requires restart)" +msgstr "(மாற்றத்திற்கு மறுதொடக்கம் தேவை)" + +#: gitk:11814 +msgid "(currently unavailable)" +msgstr "(தற்போது கிடைக்கவில்லை)" + +#: gitk:11826 +msgid "Colors: press to choose" +msgstr "நிறங்கள்: தேர்வு செய்ய அழுத்தவும்" + +#: gitk:11829 +msgid "Interface" +msgstr "இடைமுகம்" + +#: gitk:11830 +msgid "interface" +msgstr "இடைமுகம்" + +#: gitk:11833 +msgid "Background" +msgstr "பின்னணி" + +#: gitk:11834 gitk:11876 +msgid "background" +msgstr "பின்னணி" + +#: gitk:11837 +msgid "Foreground" +msgstr "முன்புறம்" + +#: gitk:11838 +msgid "foreground" +msgstr "முன்புறம்" + +#: gitk:11841 +msgid "Diff: old lines" +msgstr "வேறுபாடு: பழைய வரிகள்" + +#: gitk:11842 +msgid "diff old lines" +msgstr "பழைய வரிகள் வேறுபாடு" + +#: gitk:11846 +msgid "Diff: old lines bg" +msgstr "வேறுபாடு: பழைய வரிகள் பின்ணனி" + +#: gitk:11848 +msgid "diff old lines bg" +msgstr "பழைய வரிகள் பின்ணனி வேறுபாடு" + +#: gitk:11852 +msgid "Diff: new lines" +msgstr "வேறுபாடு: புதிய கோடுகள்" + +#: gitk:11853 +msgid "diff new lines" +msgstr "புதிய வரிகள் வேறுபாடு" + +#: gitk:11857 +msgid "Diff: new lines bg" +msgstr "வேறுபாடு: புதிய வரிகள் பின்ணனி" + +#: gitk:11859 +msgid "diff new lines bg" +msgstr "புதிய வரிகளை பின்ணனி வேறுபாடு" + +#: gitk:11863 +msgid "Diff: hunk header" +msgstr "வேறுபாடு: அங்க் தலைப்பு" + +#: gitk:11865 +msgid "diff hunk header" +msgstr "அங்க் தலைப்பு வேறுபாடு" + +#: gitk:11869 +msgid "Marked line bg" +msgstr "குறிக்கப்பட்ட வரி பின்னணி" + +#: gitk:11871 +msgid "marked line background" +msgstr "குறிக்கப்பட்ட வரி பின்னணி" + +#: gitk:11875 +msgid "Select bg" +msgstr "பின்னணி தேர்வு" + +#: gitk:11884 +msgid "Fonts: press to choose" +msgstr "எழுத்துருக்கள்: தேர்வு செய்ய அழுத்து" + +#: gitk:11886 +msgid "Main font" +msgstr "முதன்மையான எழுத்துரு" + +#: gitk:11887 +msgid "Diff display font" +msgstr "காட்சி எழுத்துரு வேறுபாடு" + +#: gitk:11888 +msgid "User interface font" +msgstr "பயனர் இடைமுக எழுத்துரு" + +#: gitk:11910 +msgid "Gitk preferences" +msgstr "அறிவிலிகே விருப்பத்தேர்வுகள்" + +#: gitk:11919 +msgid "General" +msgstr "பொது" + +#: gitk:11920 +msgid "Colors" +msgstr "நிறங்கள்" + +#: gitk:11921 +msgid "Fonts" +msgstr "எழுத்துருக்கள்" + +#: gitk:11971 +#, tcl-format +msgid "Gitk: choose color for %s" +msgstr "அறிவிலிகே: %s க்கு வண்ணத்தைத் தேர்வுசெய்க" + +#: gitk:12490 +msgid "" +"Sorry, gitk cannot run with this version of Tcl/Tk.\n" +" Gitk requires at least Tcl/Tk 8.4." +msgstr "" +"மன்னிக்கவும், டிசிஎல்/டிகேயின் இந்த பதிப்பைக் கொண்டு அறிவிலிகே இயக்க முடியாது. \n" +"அறிவிலிகேவுக்கு குறைந்தபட்சம் டிசிஎல்/டிகே 8.4 தேவைப்படுகிறது." + +#: gitk:12711 +msgid "Cannot find a git repository here." +msgstr "இங்கே ஒரு அறிவிலி களஞ்சியத்தைக் கண்டுபிடிக்க முடியவில்லை." + +#: gitk:12758 +#, tcl-format +msgid "Ambiguous argument '%s': both revision and filename" +msgstr "தெளிவற்ற வாதம் '%s': திருத்தம் மற்றும் கோப்பு பெயர்" + +#: gitk:12770 +msgid "Bad arguments to gitk:" +msgstr "அறிவிலிகேவிற்கு மோசமான வாதங்கள்:" + +#~ msgid "SHA1 ID:" +#~ msgstr "சா1 அடையாளம்:" + +#~ msgid "Auto-select SHA1 (length)" +#~ msgstr "தானாக தேர்ந்தெடுக்கப்பட்ட சா1 (நீளம்)" @@ -205,8 +205,9 @@ void hashmap_clear_(struct hashmap *map, ssize_t entry_offset) return; if (entry_offset >= 0) /* called by hashmap_clear_and_free */ free_individual_entries(map, entry_offset); - free(map->table); - memset(map, 0, sizeof(*map)); + FREE_AND_NULL(map->table); + map->tablesize = 0; + map->private_size = 0; } struct hashmap_entry *hashmap_get(const struct hashmap *map, diff --git a/http-push.c b/http-push.c index 32e37565f4..f9e67cabd4 100644 --- a/http-push.c +++ b/http-push.c @@ -1446,7 +1446,9 @@ static void one_remote_ref(const char *refname) * Fetch a copy of the object if it doesn't exist locally - it * may be required for updating server info later. */ - if (repo->can_update_info_refs && !repo_has_object_file(the_repository, &ref->old_oid)) { + if (repo->can_update_info_refs && + !has_object(the_repository, &ref->old_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { obj = lookup_unknown_object(the_repository, &ref->old_oid); fprintf(stderr, " fetch %s for %s\n", oid_to_hex(&ref->old_oid), refname); @@ -1651,14 +1653,14 @@ static int delete_remote_branch(const char *pattern, int force) return error("Remote HEAD symrefs too deep"); if (is_null_oid(&head_oid)) return error("Unable to resolve remote HEAD"); - if (!repo_has_object_file(the_repository, &head_oid)) + if (!has_object(the_repository, &head_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return error("Remote HEAD resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", oid_to_hex(&head_oid)); /* Remote branch must resolve to a known object */ if (is_null_oid(&remote_ref->old_oid)) return error("Unable to resolve remote branch %s", remote_ref->name); - if (!repo_has_object_file(the_repository, &remote_ref->old_oid)) + if (!has_object(the_repository, &remote_ref->old_oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return error("Remote branch %s resolves to object %s\nwhich does not exist locally, perhaps you need to fetch?", remote_ref->name, oid_to_hex(&remote_ref->old_oid)); /* Remote branch must be an ancestor of remote HEAD */ @@ -1879,7 +1881,8 @@ int cmd_main(int argc, const char **argv) if (!force_all && !is_null_oid(&ref->old_oid) && !ref->force) { - if (!repo_has_object_file(the_repository, &ref->old_oid) || + if (!has_object(the_repository, &ref->old_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) || !ref_newer(&ref->peer_ref->new_oid, &ref->old_oid)) { /* diff --git a/http-walker.c b/http-walker.c index 882cae19c2..463f7b119a 100644 --- a/http-walker.c +++ b/http-walker.c @@ -9,6 +9,7 @@ #include "list.h" #include "transport.h" #include "packfile.h" +#include "object-file.h" #include "object-store.h" struct alt_base { @@ -137,7 +138,8 @@ static int fill_active_slot(void *data UNUSED) list_for_each_safe(pos, tmp, head) { obj_req = list_entry(pos, struct object_request, node); if (obj_req->state == WAITING) { - if (repo_has_object_file(the_repository, &obj_req->oid)) + if (has_object(the_repository, &obj_req->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) obj_req->state = COMPLETE; else { start_object_request(obj_req); @@ -495,7 +497,8 @@ static int fetch_object(struct walker *walker, const struct object_id *oid) if (!obj_req) return error("Couldn't find request for %s in the queue", hex); - if (repo_has_object_file(the_repository, &obj_req->oid)) { + if (has_object(the_repository, &obj_req->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { if (obj_req->req) abort_http_object_request(&obj_req->req); abort_object_request(obj_req); @@ -540,7 +543,7 @@ static int fetch_object(struct walker *walker, const struct object_id *oid) ret = error("File %s has bad hash", hex); } else if (req->rename < 0) { struct strbuf buf = STRBUF_INIT; - loose_object_path(the_repository, &buf, &req->oid); + odb_loose_path(the_repository->objects->odb, &buf, &req->oid); ret = error("unable to write sha1 filename %s", buf.buf); strbuf_release(&buf); } @@ -2662,7 +2662,7 @@ struct http_object_request *new_http_object_request(const char *base_url, oidcpy(&freq->oid, oid); freq->localfile = -1; - loose_object_path(the_repository, &filename, oid); + odb_loose_path(the_repository->objects->odb, &filename, oid); strbuf_addf(&freq->tmpfile, "%s.temp", filename.buf); strbuf_addf(&prevfile, "%s.prev", filename.buf); @@ -2814,7 +2814,7 @@ int finish_http_object_request(struct http_object_request *freq) unlink_or_warn(freq->tmpfile.buf); return -1; } - loose_object_path(the_repository, &filename, &freq->oid); + odb_loose_path(the_repository->objects->odb, &filename, &freq->oid); freq->rename = finalize_object_file(freq->tmpfile.buf, filename.buf); strbuf_release(&filename); diff --git a/list-objects.c b/list-objects.c index 1e5512e131..597114281f 100644 --- a/list-objects.c +++ b/list-objects.c @@ -74,7 +74,8 @@ static void process_blob(struct traversal_context *ctx, * of missing objects. */ if (ctx->revs->exclude_promisor_objects && - !repo_has_object_file(the_repository, &obj->oid) && + !has_object(the_repository, &obj->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) && is_promisor_object(ctx->revs->repo, &obj->oid)) return; diff --git a/log-tree.c b/log-tree.c index a4d4ab59ca..1d05dc1c70 100644 --- a/log-tree.c +++ b/log-tree.c @@ -9,7 +9,7 @@ #include "environment.h" #include "hex.h" #include "object-name.h" -#include "object-store.h" +#include "object-file.h" #include "repository.h" #include "tmp-objdir.h" #include "commit.h" diff --git a/meson.build b/meson.build index 410bbf93da..148ae668eb 100644 --- a/meson.build +++ b/meson.build @@ -70,9 +70,15 @@ # # Execute single test interactively such that features like `debug ()` work. # $ meson test -i --test-args='-ix' t1400-update-ref # -# Test execution is parallelized by default and scales with the number of -# processor cores available. You can change the number of processes by passing -# the `-jN` flag to `meson test`. +# # Execute all benchmarks. +# $ meson test -i --benchmark +# +# # Execute single benchmark. +# $ meson test -i --benchmark p0000-* +# +# Test execution (but not benchmark execution) is parallelized by default and +# scales with the number of processor cores available. You can change the +# number of processes by passing the `-jN` flag to `meson test`. # # 4. Install the Git distribution. Again, this can be done via Meson, Ninja or # Samurai: @@ -235,8 +241,13 @@ git = find_program('git', dirs: program_path, native: true, required: false) sed = find_program('sed', dirs: program_path, native: true) shell = find_program('sh', dirs: program_path, native: true) tar = find_program('tar', dirs: program_path, native: true) +time = find_program('time', dirs: program_path, required: get_option('benchmarks')) -target_shell = find_program('sh', dirs: program_path, native: false) +# Detect the target shell that is used by Git at runtime. Note that we prefer +# "/bin/sh" over a PATH-based lookup, which provides a working shell on most +# supported systems. This path is also the default shell path used by our +# Makefile. This lookup can be overridden via `program_path`. +target_shell = find_program('sh', dirs: program_path + [ '/bin' ], native: false) # Sanity-check that programs required for the build exist. foreach tool : ['cat', 'cut', 'grep', 'sort', 'tr', 'uname'] @@ -446,10 +457,10 @@ libgit_sources = [ 'reftable/iter.c', 'reftable/merged.c', 'reftable/pq.c', - 'reftable/reader.c', 'reftable/record.c', 'reftable/stack.c', 'reftable/system.c', + 'reftable/table.c', 'reftable/tree.c', 'reftable/writer.c', 'remote.c', @@ -668,6 +679,28 @@ builtin_sources = [ 'builtin/write-tree.c', ] +third_party_excludes = [ + ':!contrib', + ':!compat/inet_ntop.c', + ':!compat/inet_pton.c', + ':!compat/nedmalloc', + ':!compat/obstack.*', + ':!compat/poll', + ':!compat/regex', + ':!sha1collisiondetection', + ':!sha1dc', + ':!t/unit-tests/clar', + ':!t/t[0-9][0-9][0-9][0-9]*', + ':!xdiff', +] + +headers_to_check = [] +if git.found() and fs.exists(meson.project_source_root() / '.git') + foreach header : run_command(git, '-C', meson.project_source_root(), 'ls-files', '--deduplicate', '*.h', third_party_excludes, check: true).stdout().split() + headers_to_check += header + endforeach +endif + if not get_option('breaking_changes') builtin_sources += 'builtin/pack-redundant.c' endif @@ -699,11 +732,11 @@ builtin_sources += custom_target( # build options to our tests. build_options_config = configuration_data() build_options_config.set('GIT_INTEROP_MAKE_OPTS', '') -build_options_config.set('GIT_PERF_LARGE_REPO', '') +build_options_config.set_quoted('GIT_PERF_LARGE_REPO', get_option('benchmark_large_repo')) build_options_config.set('GIT_PERF_MAKE_COMMAND', '') build_options_config.set('GIT_PERF_MAKE_OPTS', '') -build_options_config.set('GIT_PERF_REPEAT_COUNT', '') -build_options_config.set('GIT_PERF_REPO', '') +build_options_config.set_quoted('GIT_PERF_REPEAT_COUNT', get_option('benchmark_repeat_count').to_string()) +build_options_config.set_quoted('GIT_PERF_REPO', get_option('benchmark_repo')) build_options_config.set('GIT_TEST_CMP_USE_COPIED_CONTEXT', '') build_options_config.set('GIT_TEST_INDEX_VERSION', '') build_options_config.set('GIT_TEST_OPTS', '') @@ -836,7 +869,7 @@ endif # features. It is optional if you want to neither execute tests nor use any of # these optional features. perl_required = get_option('perl') -if get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') or get_option('docs') != [] +if get_option('benchmarks').enabled() or get_option('gitweb').enabled() or 'netrc' in get_option('credential_helpers') perl_required = true endif @@ -1079,10 +1112,6 @@ if compiler.has_header('alloca.h') libgit_c_args += '-DHAVE_ALLOCA_H' endif -if compiler.has_header('sys/sysinfo.h') - libgit_c_args += '-DHAVE_SYSINFO' -endif - # Windows has libgen.h and a basename implementation, but we still need our own # implementation to threat things like drive prefixes specially. if host_machine.system() == 'windows' or not compiler.has_header('libgen.h') @@ -1105,18 +1134,22 @@ if host_machine.system() == 'windows' networking_dependencies += winsock endif else - libresolv = compiler.find_library('resolv', required: false) - if libresolv.found() - networking_dependencies += libresolv - endif + networking_dependencies += [ + compiler.find_library('nsl', required: false), + compiler.find_library('resolv', required: false), + compiler.find_library('socket', required: false), + ] endif libgit_dependencies += networking_dependencies -foreach symbol : ['inet_ntop', 'inet_pton', 'strerror'] - if not compiler.has_function(symbol, dependencies: networking_dependencies) - libgit_c_args += '-DNO_' + symbol.to_upper() - endif -endforeach +if host_machine.system() != 'windows' + foreach symbol : ['inet_ntop', 'inet_pton', 'hstrerror'] + if not compiler.has_function(symbol, dependencies: networking_dependencies) + libgit_c_args += '-DNO_' + symbol.to_upper() + libgit_sources += 'compat/' + symbol + '.c' + endif + endforeach +endif has_ipv6 = compiler.has_function('getaddrinfo', dependencies: networking_dependencies) if not has_ipv6 @@ -1154,11 +1187,6 @@ else build_options_config.set('NO_UNIX_SOCKETS', '1') endif -if not compiler.has_function('pread') - libgit_c_args += '-DNO_PREAD' - libgit_sources += 'compat/pread.c' -endif - if host_machine.system() == 'darwin' libgit_sources += 'compat/precompose_utf8.c' libgit_c_args += '-DPRECOMPOSE_UNICODE' @@ -1293,6 +1321,10 @@ if host_machine.system() != 'windows' endif endif +if compiler.has_member('struct sysinfo', 'totalram', prefix: '#include <sys/sysinfo.h>') + libgit_c_args += '-DHAVE_SYSINFO' +endif + if compiler.has_member('struct stat', 'st_mtimespec.tv_nsec', prefix: '#include <sys/stat.h>') libgit_c_args += '-DUSE_ST_TIMESPEC' elif not compiler.has_member('struct stat', 'st_mtim.tv_nsec', prefix: '#include <sys/stat.h>') @@ -1311,23 +1343,41 @@ if not compiler.has_member('struct passwd', 'pw_gecos', prefix: '#include <pwd.h libgit_c_args += '-DNO_GECOS_IN_PWENT' endif -if compiler.has_function('sync_file_range') - libgit_c_args += '-DHAVE_SYNC_FILE_RANGE' -endif +checkfuncs = { + 'strcasestr' : ['strcasestr.c'], + 'memmem' : ['memmem.c'], + 'strlcpy' : ['strlcpy.c'], + 'strtoull' : [], + 'setenv' : ['setenv.c'], + 'mkdtemp' : ['mkdtemp.c'], + 'initgroups' : [], + 'strtoumax' : ['strtoumax.c', 'strtoimax.c'], + 'pread' : ['pread.c'], +} -if not compiler.has_function('strcasestr') - libgit_c_args += '-DNO_STRCASESTR' - libgit_sources += 'compat/strcasestr.c' +if host_machine.system() == 'windows' + libgit_c_args += '-DUSE_WIN32_MMAP' +else + checkfuncs += { + 'mmap' : ['mmap.c'], + # provided by compat/mingw.c. + 'unsetenv' : ['unsetenv.c'], + # provided by compat/mingw.c. + 'getpagesize' : [], + } endif -if not compiler.has_function('memmem') - libgit_c_args += '-DNO_MEMMEM' - libgit_sources += 'compat/memmem.c' -endif +foreach func, impls : checkfuncs + if not compiler.has_function(func) + libgit_c_args += '-DNO_' + func.to_upper() + foreach impl : impls + libgit_sources += 'compat/' + impl + endforeach + endif +endforeach -if not compiler.has_function('strlcpy') - libgit_c_args += '-DNO_STRLCPY' - libgit_sources += 'compat/strlcpy.c' +if compiler.has_function('sync_file_range') + libgit_c_args += '-DHAVE_SYNC_FILE_RANGE' endif if not compiler.has_function('strdup') @@ -1335,53 +1385,15 @@ if not compiler.has_function('strdup') libgit_sources += 'compat/strdup.c' endif -if not compiler.has_function('strtoumax') - libgit_c_args += '-DNO_STRTOUMAX' - libgit_sources += [ - 'compat/strtoumax.c', - 'compat/strtoimax.c', - ] -endif - -if not compiler.has_function('strtoull') - libgit_c_args += '-DNO_STRTOULL' -endif - -if not compiler.has_function('setenv') - libgit_c_args += '-DNO_SETENV' - libgit_sources += 'compat/setenv.c' -endif - if not compiler.has_function('qsort') libgit_c_args += '-DINTERNAL_QSORT' endif libgit_sources += 'compat/qsort_s.c' -# unsetenv is provided by compat/mingw.c. -if host_machine.system() != 'windows' and not compiler.has_function('unsetenv') - libgit_c_args += '-DNO_UNSETENV' - libgit_sources += 'compat/unsetenv.c' -endif - -if not compiler.has_function('mkdtemp') - libgit_c_args += '-DNO_MKDTEMP' - libgit_sources += 'compat/mkdtemp.c' -endif - -if not compiler.has_function('initgroups') - libgit_c_args += '-DNO_INITGROUPS' -endif - if compiler.has_function('getdelim') libgit_c_args += '-DHAVE_GETDELIM' endif -if host_machine.system() == 'windows' - libgit_c_args += '-DUSE_WIN32_MMAP' -elif not compiler.has_function('mmap') - libgit_c_args += '-DNO_MMAP' - libgit_sources += 'compat/mmap.c' -endif if compiler.has_function('clock_gettime') libgit_c_args += '-DHAVE_CLOCK_GETTIME' @@ -2033,6 +2045,70 @@ endif subdir('contrib') +exclude_from_check_headers = [ + 'compat/', + 'unicode-width.h', +] + +if sha1_backend != 'openssl' + exclude_from_check_headers += 'sha1/openssl.h' +endif +if sha256_backend != 'openssl' + exclude_from_check_headers += 'sha256/openssl.h' +endif +if sha256_backend != 'nettle' + exclude_from_check_headers += 'sha256/nettle.h' +endif +if sha256_backend != 'gcrypt' + exclude_from_check_headers += 'sha256/gcrypt.h' +endif + +if headers_to_check.length() != 0 and compiler.get_argument_syntax() == 'gcc' + hco_targets = [] + foreach h : headers_to_check + skip_header = false + foreach exclude : exclude_from_check_headers + if h.startswith(exclude) + skip_header = true + break + endif + endforeach + + if skip_header + continue + endif + + hcc = custom_target( + input: h, + output: h.underscorify() + 'cc', + command: [ + shell, + '-c', + 'echo \'#include "git-compat-util.h"\' > @OUTPUT@ && echo \'#include "' + h + '"\' >> @OUTPUT@' + ] + ) + + hco = custom_target( + input: hcc, + output: fs.replace_suffix(h.underscorify(), '.hco'), + command: [ + compiler.cmd_array(), + libgit_c_args, + '-I', meson.project_source_root(), + '-I', meson.project_source_root() / 't/unit-tests', + '-o', '/dev/null', + '-c', '-xc', + '@INPUT@' + ] + ) + hco_targets += hco + endforeach + + # TODO: deprecate 'hdr-check' in lieu of 'check-headers' in Git 2.51+ + hdr_check = alias_target('hdr-check', hco_targets) + alias_target('check-headers', hdr_check) +endif + foreach key, value : { 'DIFF': diff.full_path(), 'GIT_SOURCE_DIR': meson.project_source_root(), @@ -2082,6 +2158,7 @@ meson.add_dist_script( ) summary({ + 'benchmarks': get_option('tests') and perl.found() and time.found(), 'curl': curl.found(), 'expat': expat.found(), 'gettext': intl.found(), @@ -2101,3 +2178,9 @@ summary({ 'sha256': sha256_backend, 'zlib': zlib_backend, }, section: 'Backends') + +summary({ + 'perl': target_perl, + 'python': target_python, + 'shell': target_shell, +}, section: 'Runtime executable paths') diff --git a/meson_options.txt b/meson_options.txt index 8ac30a5223..8547c0eb47 100644 --- a/meson_options.txt +++ b/meson_options.txt @@ -101,6 +101,14 @@ option('docs_backend', type: 'combo', choices: ['asciidoc', 'asciidoctor', 'auto description: 'Which backend to use to generate documentation.') # Testing. +option('benchmarks', type: 'feature', value: 'auto', + description: 'Enable benchmarks. This requires Perl and GNU time.') +option('benchmark_repo', type: 'string', value: '', + description: 'Repository to copy for the performance tests. Should be at least the size of the Git repository.') +option('benchmark_large_repo', type: 'string', value: '', + description: 'Large repository to copy for the performance tests. Should be at least the size of the Linux repository.') +option('benchmark_repeat_count', type: 'integer', value: 3, + description: 'Number of times a test should be repeated for best-of-N measurements.') option('coccinelle', type: 'feature', value: 'auto', description: 'Provide a coccicheck target that generates a Coccinelle patch.') option('tests', type: 'boolean', value: true, @@ -794,7 +794,8 @@ static int prune_notes_helper(const struct object_id *object_oid, struct note_delete_list **l = (struct note_delete_list **) cb_data; struct note_delete_list *n; - if (repo_has_object_file(the_repository, object_oid)) + if (has_object(the_repository, object_oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return 0; /* nothing to do for this note */ /* failed to find object => prune this note */ diff --git a/object-file.c b/object-file.c index 9cc3a24a40..dc56a4766d 100644 --- a/object-file.c +++ b/object-file.c @@ -932,7 +932,7 @@ static int write_loose_object(const struct object_id *oid, char *hdr, if (batch_fsync_enabled(FSYNC_COMPONENT_LOOSE_OBJECT)) prepare_loose_object_bulk_checkin(); - loose_object_path(the_repository, &filename, oid); + odb_loose_path(the_repository->objects->odb, &filename, oid); fd = start_loose_object_common(&tmp_file, filename.buf, flags, &stream, compressed, sizeof(compressed), @@ -1079,7 +1079,7 @@ int stream_loose_object(struct input_stream *in_stream, size_t len, goto cleanup; } - loose_object_path(the_repository, &filename, oid); + odb_loose_path(the_repository->objects->odb, &filename, oid); /* We finally know the object path, and create the missing dir. */ dirlen = directory_size(filename.buf); diff --git a/object-file.h b/object-file.h index c002fbe234..a85b2e5b49 100644 --- a/object-file.h +++ b/object-file.h @@ -3,6 +3,7 @@ #include "git-zlib.h" #include "object.h" +#include "object-store.h" struct index_state; @@ -25,6 +26,20 @@ int index_path(struct index_state *istate, struct object_id *oid, const char *pa struct object_directory; +/* + * Populate and return the loose object cache array corresponding to the + * given object ID. + */ +struct oidtree *odb_loose_cache(struct object_directory *odb, + const struct object_id *oid); + +/* Empty the loose object cache for the specified object directory. */ +void odb_clear_loose_cache(struct object_directory *odb); + +/* + * Put in `buf` the name of the file in the local object database that + * would be used to store a loose object with the specified oid. + */ const char *odb_loose_path(struct object_directory *odb, struct strbuf *buf, const struct object_id *oid); @@ -38,6 +53,68 @@ int has_loose_object_nonlocal(const struct object_id *); int has_loose_object(const struct object_id *); +void *map_loose_object(struct repository *r, const struct object_id *oid, + unsigned long *size); + +/* + * Iterate over the files in the loose-object parts of the object + * directory "path", triggering the following callbacks: + * + * - loose_object is called for each loose object we find. + * + * - loose_cruft is called for any files that do not appear to be + * loose objects. Note that we only look in the loose object + * directories "objects/[0-9a-f]{2}/", so we will not report + * "objects/foobar" as cruft. + * + * - loose_subdir is called for each top-level hashed subdirectory + * of the object directory (e.g., "$OBJDIR/f0"). It is called + * after the objects in the directory are processed. + * + * Any callback that is NULL will be ignored. Callbacks returning non-zero + * will end the iteration. + * + * In the "buf" variant, "path" is a strbuf which will also be used as a + * scratch buffer, but restored to its original contents before + * the function returns. + */ +typedef int each_loose_object_fn(const struct object_id *oid, + const char *path, + void *data); +typedef int each_loose_cruft_fn(const char *basename, + const char *path, + void *data); +typedef int each_loose_subdir_fn(unsigned int nr, + const char *path, + void *data); +int for_each_file_in_obj_subdir(unsigned int subdir_nr, + struct strbuf *path, + each_loose_object_fn obj_cb, + each_loose_cruft_fn cruft_cb, + each_loose_subdir_fn subdir_cb, + void *data); +int for_each_loose_file_in_objdir(const char *path, + each_loose_object_fn obj_cb, + each_loose_cruft_fn cruft_cb, + each_loose_subdir_fn subdir_cb, + void *data); +int for_each_loose_file_in_objdir_buf(struct strbuf *path, + each_loose_object_fn obj_cb, + each_loose_cruft_fn cruft_cb, + each_loose_subdir_fn subdir_cb, + void *data); + +/* + * Iterate over all accessible loose objects without respect to + * reachability. By default, this includes both local and alternate objects. + * The order in which objects are visited is unspecified. + * + * Any flags specific to packs are ignored. + */ +int for_each_loose_object(each_loose_object_fn, void *, + enum for_each_object_flags flags); + + /** * format_object_header() is a thin wrapper around s xsnprintf() that * writes the initial "<type> <obj-len>" part of the loose object @@ -154,6 +231,10 @@ int finalize_object_file(const char *tmpfile, const char *filename); int finalize_object_file_flags(const char *tmpfile, const char *filename, enum finalize_object_file_flags flags); +void hash_object_file(const struct git_hash_algo *algo, const void *buf, + unsigned long len, enum object_type type, + struct object_id *oid); + /* Helper to check and "touch" a file */ int check_and_freshen_file(const char *fn, int freshen); diff --git a/object-name.c b/object-name.c index 2c751a5352..9288b2dd24 100644 --- a/object-name.c +++ b/object-name.c @@ -19,7 +19,7 @@ #include "oidtree.h" #include "packfile.h" #include "pretty.h" -#include "object-store.h" +#include "object-file.h" #include "read-cache-ll.h" #include "repo-settings.h" #include "repository.h" diff --git a/object-store.c b/object-store.c index 6ab50d25d3..2f51d0e3b0 100644 --- a/object-store.c +++ b/object-store.c @@ -83,25 +83,6 @@ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern) return xmkstemp_mode(temp_filename->buf, mode); } -int odb_pack_keep(const char *name) -{ - int fd; - - fd = open(name, O_RDWR|O_CREAT|O_EXCL, 0600); - if (0 <= fd) - return fd; - - /* slow path */ - safe_create_leading_directories_const(the_repository, name); - return open(name, O_RDWR|O_CREAT|O_EXCL, 0600); -} - -const char *loose_object_path(struct repository *r, struct strbuf *buf, - const struct object_id *oid) -{ - return odb_loose_path(r->objects->odb, buf, oid); -} - /* * Return non-zero iff the path is usable as an alternate object database. */ @@ -866,7 +847,7 @@ int pretend_object_file(struct repository *repo, char *co_buf; hash_object_file(repo->hash_algo, buf, len, type, oid); - if (repo_has_object_file_with_flags(repo, oid, OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT) || + if (has_object(repo, oid, 0) || find_cached_object(repo->objects, oid)) return 0; @@ -956,27 +937,16 @@ void *read_object_with_reference(struct repository *r, int has_object(struct repository *r, const struct object_id *oid, unsigned flags) { - int quick = !(flags & HAS_OBJECT_RECHECK_PACKED); - unsigned object_info_flags = OBJECT_INFO_SKIP_FETCH_OBJECT | - (quick ? OBJECT_INFO_QUICK : 0); - - if (!startup_info->have_repository) - return 0; - return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0; -} + unsigned object_info_flags = 0; -int repo_has_object_file_with_flags(struct repository *r, - const struct object_id *oid, int flags) -{ if (!startup_info->have_repository) return 0; - return oid_object_info_extended(r, oid, NULL, flags) >= 0; -} + if (!(flags & HAS_OBJECT_RECHECK_PACKED)) + object_info_flags |= OBJECT_INFO_QUICK; + if (!(flags & HAS_OBJECT_FETCH_PROMISOR)) + object_info_flags |= OBJECT_INFO_SKIP_FETCH_OBJECT; -int repo_has_object_file(struct repository *r, - const struct object_id *oid) -{ - return repo_has_object_file_with_flags(r, oid, 0); + return oid_object_info_extended(r, oid, NULL, object_info_flags) >= 0; } void assert_oid_type(const struct object_id *oid, enum object_type expect) diff --git a/object-store.h b/object-store.h index 46961dc954..c2fe5a1960 100644 --- a/object-store.h +++ b/object-store.h @@ -82,75 +82,8 @@ struct object_directory *set_temporary_primary_odb(const char *dir, int will_des */ void restore_primary_odb(struct object_directory *restore_odb, const char *old_path); -/* - * Populate and return the loose object cache array corresponding to the - * given object ID. - */ -struct oidtree *odb_loose_cache(struct object_directory *odb, - const struct object_id *oid); - -/* Empty the loose object cache for the specified object directory. */ -void odb_clear_loose_cache(struct object_directory *odb); - -struct packed_git { - struct hashmap_entry packmap_ent; - struct packed_git *next; - struct list_head mru; - struct pack_window *windows; - off_t pack_size; - const void *index_data; - size_t index_size; - uint32_t num_objects; - size_t crc_offset; - struct oidset bad_objects; - int index_version; - time_t mtime; - int pack_fd; - int index; /* for builtin/pack-objects.c */ - unsigned pack_local:1, - pack_keep:1, - pack_keep_in_core:1, - freshened:1, - do_not_close:1, - pack_promisor:1, - multi_pack_index:1, - is_cruft:1; - unsigned char hash[GIT_MAX_RAWSZ]; - struct revindex_entry *revindex; - const uint32_t *revindex_data; - const uint32_t *revindex_map; - size_t revindex_size; - /* - * mtimes_map points at the beginning of the memory mapped region of - * this pack's corresponding .mtimes file, and mtimes_size is the size - * of that .mtimes file - */ - const uint32_t *mtimes_map; - size_t mtimes_size; - - /* repo denotes the repository this packfile belongs to */ - struct repository *repo; - - /* something like ".git/objects/pack/xxxxx.pack" */ - char pack_name[FLEX_ARRAY]; /* more */ -}; - +struct packed_git; struct multi_pack_index; - -static inline int pack_map_entry_cmp(const void *cmp_data UNUSED, - const struct hashmap_entry *entry, - const struct hashmap_entry *entry2, - const void *keydata) -{ - const char *key = keydata; - const struct packed_git *pg1, *pg2; - - pg1 = container_of(entry, const struct packed_git, packmap_ent); - pg2 = container_of(entry2, const struct packed_git, packmap_ent); - - return strcmp(pg1->pack_name, key ? key : pg2->pack_name); -} - struct cached_object_entry; struct raw_object_store { @@ -246,23 +179,6 @@ void raw_object_store_clear(struct raw_object_store *o); */ int odb_mkstemp(struct strbuf *temp_filename, const char *pattern); -/* - * Create a pack .keep file named "name" (which should generally be the output - * of odb_pack_name). Returns a file descriptor opened for writing, or -1 on - * error. - */ -int odb_pack_keep(const char *name); - -/* - * Put in `buf` the name of the file in the local object database that - * would be used to store a loose object with the specified oid. - */ -const char *loose_object_path(struct repository *r, struct strbuf *buf, - const struct object_id *oid); - -void *map_loose_object(struct repository *r, const struct object_id *oid, - unsigned long *size); - void *repo_read_object_file(struct repository *r, const struct object_id *oid, enum object_type *type, @@ -271,10 +187,6 @@ void *repo_read_object_file(struct repository *r, /* Read and unpack an object file into memory, write memory to an object file */ int oid_object_info(struct repository *r, const struct object_id *, unsigned long *); -void hash_object_file(const struct git_hash_algo *algo, const void *buf, - unsigned long len, enum object_type type, - struct object_id *oid); - /* * Add an object file to the in-memory object store, without writing it * to disk. @@ -350,33 +262,20 @@ int oid_object_info_extended(struct repository *r, const struct object_id *, struct object_info *, unsigned flags); -/* Retry packed storage after checking packed and loose storage */ -#define HAS_OBJECT_RECHECK_PACKED 1 +enum { + /* Retry packed storage after checking packed and loose storage */ + HAS_OBJECT_RECHECK_PACKED = (1 << 0), + /* Allow fetching the object in case the repository has a promisor remote. */ + HAS_OBJECT_FETCH_PROMISOR = (1 << 1), +}; /* * Returns 1 if the object exists. This function will not lazily fetch objects - * in a partial clone. + * in a partial clone by default. */ int has_object(struct repository *r, const struct object_id *oid, unsigned flags); -/* - * These macros and functions are deprecated. If checking existence for an - * object that is likely to be missing and/or whose absence is relatively - * inconsequential (or is consequential but the caller is prepared to handle - * it), use has_object(), which has better defaults (no lazy fetch in a partial - * clone and no rechecking of packed storage). In the unlikely event that a - * caller needs to assert existence of an object that it fully expects to - * exist, and wants to trigger a lazy fetch in a partial clone, use - * oid_object_info_extended() with a NULL struct object_info. - * - * These functions can be removed once all callers have migrated to - * has_object() and/or oid_object_info_extended(). - */ -int repo_has_object_file(struct repository *r, const struct object_id *oid); -int repo_has_object_file_with_flags(struct repository *r, - const struct object_id *oid, int flags); - void assert_oid_type(const struct object_id *oid, enum object_type expect); /* @@ -411,56 +310,7 @@ static inline void obj_read_unlock(void) if(obj_read_use_lock) pthread_mutex_unlock(&obj_read_mutex); } - -/* - * Iterate over the files in the loose-object parts of the object - * directory "path", triggering the following callbacks: - * - * - loose_object is called for each loose object we find. - * - * - loose_cruft is called for any files that do not appear to be - * loose objects. Note that we only look in the loose object - * directories "objects/[0-9a-f]{2}/", so we will not report - * "objects/foobar" as cruft. - * - * - loose_subdir is called for each top-level hashed subdirectory - * of the object directory (e.g., "$OBJDIR/f0"). It is called - * after the objects in the directory are processed. - * - * Any callback that is NULL will be ignored. Callbacks returning non-zero - * will end the iteration. - * - * In the "buf" variant, "path" is a strbuf which will also be used as a - * scratch buffer, but restored to its original contents before - * the function returns. - */ -typedef int each_loose_object_fn(const struct object_id *oid, - const char *path, - void *data); -typedef int each_loose_cruft_fn(const char *basename, - const char *path, - void *data); -typedef int each_loose_subdir_fn(unsigned int nr, - const char *path, - void *data); -int for_each_file_in_obj_subdir(unsigned int subdir_nr, - struct strbuf *path, - each_loose_object_fn obj_cb, - each_loose_cruft_fn cruft_cb, - each_loose_subdir_fn subdir_cb, - void *data); -int for_each_loose_file_in_objdir(const char *path, - each_loose_object_fn obj_cb, - each_loose_cruft_fn cruft_cb, - each_loose_subdir_fn subdir_cb, - void *data); -int for_each_loose_file_in_objdir_buf(struct strbuf *path, - each_loose_object_fn obj_cb, - each_loose_cruft_fn cruft_cb, - each_loose_subdir_fn subdir_cb, - void *data); - -/* Flags for for_each_*_object() below. */ +/* Flags for for_each_*_object(). */ enum for_each_object_flags { /* Iterate only over local objects, not alternates. */ FOR_EACH_OBJECT_LOCAL_ONLY = (1<<0), @@ -480,33 +330,6 @@ enum for_each_object_flags { FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS = (1<<4), }; -/* - * Iterate over all accessible loose objects without respect to - * reachability. By default, this includes both local and alternate objects. - * The order in which objects are visited is unspecified. - * - * Any flags specific to packs are ignored. - */ -int for_each_loose_object(each_loose_object_fn, void *, - enum for_each_object_flags flags); - -/* - * Iterate over all accessible packed objects without respect to reachability. - * By default, this includes both local and alternate packs. - * - * Note that some objects may appear twice if they are found in multiple packs. - * Each pack is visited in an unspecified order. By default, objects within a - * pack are visited in pack-idx order (i.e., sorted by oid). - */ -typedef int each_packed_object_fn(const struct object_id *oid, - struct packed_git *pack, - uint32_t pos, - void *data); -int for_each_object_in_pack(struct packed_git *p, - each_packed_object_fn, void *data, - enum for_each_object_flags flags); -int for_each_packed_object(struct repository *repo, each_packed_object_fn cb, - void *data, enum for_each_object_flags flags); void *read_object_with_reference(struct repository *r, const struct object_id *oid, diff --git a/pack-objects.h b/pack-objects.h index d1c4ae7f9b..475a2d67ce 100644 --- a/pack-objects.h +++ b/pack-objects.h @@ -4,6 +4,7 @@ #include "object-store.h" #include "thread-utils.h" #include "pack.h" +#include "packfile.h" struct repository; diff --git a/packfile.h b/packfile.h index 25097213d0..3a3c77cf05 100644 --- a/packfile.h +++ b/packfile.h @@ -1,13 +1,71 @@ #ifndef PACKFILE_H #define PACKFILE_H +#include "list.h" #include "object.h" +#include "object-store.h" #include "oidset.h" /* in object-store.h */ -struct packed_git; struct object_info; +struct packed_git { + struct hashmap_entry packmap_ent; + struct packed_git *next; + struct list_head mru; + struct pack_window *windows; + off_t pack_size; + const void *index_data; + size_t index_size; + uint32_t num_objects; + size_t crc_offset; + struct oidset bad_objects; + int index_version; + time_t mtime; + int pack_fd; + int index; /* for builtin/pack-objects.c */ + unsigned pack_local:1, + pack_keep:1, + pack_keep_in_core:1, + freshened:1, + do_not_close:1, + pack_promisor:1, + multi_pack_index:1, + is_cruft:1; + unsigned char hash[GIT_MAX_RAWSZ]; + struct revindex_entry *revindex; + const uint32_t *revindex_data; + const uint32_t *revindex_map; + size_t revindex_size; + /* + * mtimes_map points at the beginning of the memory mapped region of + * this pack's corresponding .mtimes file, and mtimes_size is the size + * of that .mtimes file + */ + const uint32_t *mtimes_map; + size_t mtimes_size; + + /* repo denotes the repository this packfile belongs to */ + struct repository *repo; + + /* something like ".git/objects/pack/xxxxx.pack" */ + char pack_name[FLEX_ARRAY]; /* more */ +}; + +static inline int pack_map_entry_cmp(const void *cmp_data UNUSED, + const struct hashmap_entry *entry, + const struct hashmap_entry *entry2, + const void *keydata) +{ + const char *key = keydata; + const struct packed_git *pg1, *pg2; + + pg1 = container_of(entry, const struct packed_git, packmap_ent); + pg2 = container_of(entry2, const struct packed_git, packmap_ent); + + return strcmp(pg1->pack_name, key ? key : pg2->pack_name); +} + struct pack_window { struct pack_window *next; unsigned char *base; @@ -60,6 +118,24 @@ void for_each_file_in_pack_dir(const char *objdir, each_file_in_pack_dir_fn fn, void *data); +/* + * Iterate over all accessible packed objects without respect to reachability. + * By default, this includes both local and alternate packs. + * + * Note that some objects may appear twice if they are found in multiple packs. + * Each pack is visited in an unspecified order. By default, objects within a + * pack are visited in pack-idx order (i.e., sorted by oid). + */ +typedef int each_packed_object_fn(const struct object_id *oid, + struct packed_git *pack, + uint32_t pos, + void *data); +int for_each_object_in_pack(struct packed_git *p, + each_packed_object_fn, void *data, + enum for_each_object_flags flags); +int for_each_packed_object(struct repository *repo, each_packed_object_fn cb, + void *data, enum for_each_object_flags flags); + /* A hook to report invalid files in pack directory */ #define PACKDIR_FILE_PACK 1 #define PACKDIR_FILE_IDX 2 @@ -1011,6 +1011,20 @@ enum scld_error safe_create_leading_directories_const(struct repository *repo, return result; } +int safe_create_file_with_leading_directories(struct repository *repo, + const char *path) +{ + int fd; + + fd = open(path, O_RDWR|O_CREAT|O_EXCL, 0600); + if (0 <= fd) + return fd; + + /* slow path */ + safe_create_leading_directories_const(repo, path); + return open(path, O_RDWR|O_CREAT|O_EXCL, 0600); +} + static int have_same_root(const char *path1, const char *path2) { int is_abs1, is_abs2; @@ -266,6 +266,13 @@ enum scld_error safe_create_leading_directories_const(struct repository *repo, const char *path); enum scld_error safe_create_leading_directories_no_share(char *path); +/* + * Create a file, potentially creating its leading directories in case they + * don't exist. Returns the return value of the open(3p) call. + */ +int safe_create_file_with_leading_directories(struct repository *repo, + const char *path); + # ifdef USE_THE_REPOSITORY_VARIABLE # include "strbuf.h" # include "repository.h" diff --git a/prune-packed.c b/prune-packed.c index c1d95a519d..92fb4fbb0e 100644 --- a/prune-packed.c +++ b/prune-packed.c @@ -2,7 +2,7 @@ #include "git-compat-util.h" #include "gettext.h" -#include "object-store.h" +#include "object-file.h" #include "packfile.h" #include "progress.h" #include "prune-packed.h" diff --git a/reachable.c b/reachable.c index e5f56f4018..9dc748f0b9 100644 --- a/reachable.c +++ b/reachable.c @@ -14,7 +14,7 @@ #include "list-objects.h" #include "packfile.h" #include "worktree.h" -#include "object-store.h" +#include "object-file.h" #include "pack-bitmap.h" #include "pack-mtimes.h" #include "config.h" @@ -152,7 +152,8 @@ static int tree_is_complete(const struct object_id *oid) init_tree_desc(&desc, &tree->object.oid, tree->buffer, tree->size); complete = 1; while (tree_entry(&desc, &entry)) { - if (!repo_has_object_file(the_repository, &entry.oid) || + if (!has_object(the_repository, &entry.oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR) || (S_ISDIR(entry.mode) && !tree_is_complete(&entry.oid))) { tree->object.flags |= INCOMPLETE; complete = 0; @@ -376,7 +376,7 @@ int ref_resolves_to_object(const char *refname, { if (flags & REF_ISBROKEN) return 0; - if (!repo_has_object_file(repo, oid)) { + if (!has_object(repo, oid, HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { error(_("%s does not point to a valid object!"), refname); return 0; } diff --git a/reftable/basics.c b/reftable/basics.c index 8c4a4433e4..9988ebd635 100644 --- a/reftable/basics.c +++ b/reftable/basics.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #define REFTABLE_ALLOW_BANNED_ALLOCATORS #include "basics.h" diff --git a/reftable/basics.h b/reftable/basics.h index fd59cbb772..d8888c1262 100644 --- a/reftable/basics.h +++ b/reftable/basics.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef BASICS_H #define BASICS_H @@ -18,13 +18,6 @@ https://developers.google.com/open-source/licenses/bsd #define REFTABLE_UNUSED __attribute__((__unused__)) -struct reftable_buf { - size_t alloc; - size_t len; - char *buf; -}; -#define REFTABLE_BUF_INIT { 0 } - /* * Initialize the buffer such that it is ready for use. This is equivalent to * using REFTABLE_BUF_INIT for stack-allocated variables. diff --git a/reftable/block.c b/reftable/block.c index 251a8e9fd3..471faa1642 100644 --- a/reftable/block.c +++ b/reftable/block.c @@ -1,15 +1,16 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "block.h" #include "blocksource.h" #include "constants.h" +#include "iter.h" #include "record.h" #include "reftable-error.h" #include "system.h" @@ -160,7 +161,7 @@ int block_writer_finish(struct block_writer *w) * Log records are stored zlib-compressed. Note that the compression * also spans over the restart points we have just written. */ - if (block_writer_type(w) == BLOCK_TYPE_LOG) { + if (block_writer_type(w) == REFTABLE_BLOCK_TYPE_LOG) { int block_header_skip = 4 + w->header_off; uLongf src_len = w->next - block_header_skip, compressed_len; int ret; @@ -210,61 +211,86 @@ int block_writer_finish(struct block_writer *w) return w->next; } -int block_reader_init(struct block_reader *br, struct reftable_block *block, - uint32_t header_off, uint32_t table_block_size, - uint32_t hash_size) +static int read_block(struct reftable_block_source *source, + struct reftable_block_data *dest, uint64_t off, + uint32_t sz) +{ + size_t size = block_source_size(source); + block_source_release_data(dest); + if (off >= size) + return 0; + if (off + sz > size) + sz = size - off; + return block_source_read_data(source, dest, off, sz); +} + +int reftable_block_init(struct reftable_block *block, + struct reftable_block_source *source, + uint32_t offset, uint32_t header_size, + uint32_t table_block_size, uint32_t hash_size) { + uint32_t guess_block_size = table_block_size ? + table_block_size : DEFAULT_BLOCK_SIZE; uint32_t full_block_size = table_block_size; - uint8_t typ = block->data[header_off]; - uint32_t sz = reftable_get_be24(block->data + header_off + 1); - int err = 0; - uint16_t restart_count = 0; - uint32_t restart_start = 0; - uint8_t *restart_bytes = NULL; + uint16_t restart_count; + uint32_t restart_off; + uint32_t block_size; + uint8_t block_type; + int err; - reftable_block_done(&br->block); + err = read_block(source, &block->block_data, offset, guess_block_size); + if (err < 0) + goto done; - if (!reftable_is_block_type(typ)) { - err = REFTABLE_FORMAT_ERROR; + block_type = block->block_data.data[header_size]; + if (!reftable_is_block_type(block_type)) { + err = REFTABLE_FORMAT_ERROR; goto done; } - if (typ == BLOCK_TYPE_LOG) { - uint32_t block_header_skip = 4 + header_off; - uLong dst_len = sz - block_header_skip; - uLong src_len = block->len - block_header_skip; + block_size = reftable_get_be24(block->block_data.data + header_size + 1); + if (block_size > guess_block_size) { + err = read_block(source, &block->block_data, offset, block_size); + if (err < 0) + goto done; + } + + if (block_type == REFTABLE_BLOCK_TYPE_LOG) { + uint32_t block_header_skip = 4 + header_size; + uLong dst_len = block_size - block_header_skip; + uLong src_len = block->block_data.len - block_header_skip; /* Log blocks specify the *uncompressed* size in their header. */ - REFTABLE_ALLOC_GROW_OR_NULL(br->uncompressed_data, sz, - br->uncompressed_cap); - if (!br->uncompressed_data) { + REFTABLE_ALLOC_GROW_OR_NULL(block->uncompressed_data, block_size, + block->uncompressed_cap); + if (!block->uncompressed_data) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } /* Copy over the block header verbatim. It's not compressed. */ - memcpy(br->uncompressed_data, block->data, block_header_skip); + memcpy(block->uncompressed_data, block->block_data.data, block_header_skip); - if (!br->zstream) { - REFTABLE_CALLOC_ARRAY(br->zstream, 1); - if (!br->zstream) { + if (!block->zstream) { + REFTABLE_CALLOC_ARRAY(block->zstream, 1); + if (!block->zstream) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } - err = inflateInit(br->zstream); + err = inflateInit(block->zstream); } else { - err = inflateReset(br->zstream); + err = inflateReset(block->zstream); } if (err != Z_OK) { err = REFTABLE_ZLIB_ERROR; goto done; } - br->zstream->next_in = block->data + block_header_skip; - br->zstream->avail_in = src_len; - br->zstream->next_out = br->uncompressed_data + block_header_skip; - br->zstream->avail_out = dst_len; + block->zstream->next_in = block->block_data.data + block_header_skip; + block->zstream->avail_in = src_len; + block->zstream->next_out = block->uncompressed_data + block_header_skip; + block->zstream->avail_out = dst_len; /* * We know both input as well as output size, and we know that @@ -273,72 +299,71 @@ int block_reader_init(struct block_reader *br, struct reftable_block *block, * here to instruct zlib to inflate the data in one go, which * is more efficient than using `Z_NO_FLUSH`. */ - err = inflate(br->zstream, Z_FINISH); + err = inflate(block->zstream, Z_FINISH); if (err != Z_STREAM_END) { err = REFTABLE_ZLIB_ERROR; goto done; } err = 0; - if (br->zstream->total_out + block_header_skip != sz) { + if (block->zstream->total_out + block_header_skip != block_size) { err = REFTABLE_FORMAT_ERROR; goto done; } /* We're done with the input data. */ - reftable_block_done(block); - block->data = br->uncompressed_data; - block->len = sz; - full_block_size = src_len + block_header_skip - br->zstream->avail_in; + block_source_release_data(&block->block_data); + block->block_data.data = block->uncompressed_data; + block->block_data.len = block_size; + full_block_size = src_len + block_header_skip - block->zstream->avail_in; } else if (full_block_size == 0) { - full_block_size = sz; - } else if (sz < full_block_size && sz < block->len && - block->data[sz] != 0) { + full_block_size = block_size; + } else if (block_size < full_block_size && block_size < block->block_data.len && + block->block_data.data[block_size] != 0) { /* If the block is smaller than the full block size, it is padded (data followed by '\0') or the next block is unaligned. */ - full_block_size = sz; + full_block_size = block_size; } - restart_count = reftable_get_be16(block->data + sz - 2); - restart_start = sz - 2 - 3 * restart_count; - restart_bytes = block->data + restart_start; + restart_count = reftable_get_be16(block->block_data.data + block_size - 2); + restart_off = block_size - 2 - 3 * restart_count; - /* transfer ownership. */ - br->block = *block; - block->data = NULL; - block->len = 0; + block->block_type = block_type; + block->hash_size = hash_size; + block->restart_off = restart_off; + block->full_block_size = full_block_size; + block->header_off = header_size; + block->restart_count = restart_count; - br->hash_size = hash_size; - br->block_len = restart_start; - br->full_block_size = full_block_size; - br->header_off = header_off; - br->restart_count = restart_count; - br->restart_bytes = restart_bytes; + err = 0; done: + if (err < 0) + reftable_block_release(block); return err; } -void block_reader_release(struct block_reader *br) +void reftable_block_release(struct reftable_block *block) { - inflateEnd(br->zstream); - reftable_free(br->zstream); - reftable_free(br->uncompressed_data); - reftable_block_done(&br->block); + inflateEnd(block->zstream); + reftable_free(block->zstream); + reftable_free(block->uncompressed_data); + block_source_release_data(&block->block_data); + memset(block, 0, sizeof(*block)); } -uint8_t block_reader_type(const struct block_reader *r) +uint8_t reftable_block_type(const struct reftable_block *b) { - return r->block.data[r->header_off]; + return b->block_data.data[b->header_off]; } -int block_reader_first_key(const struct block_reader *br, struct reftable_buf *key) +int reftable_block_first_key(const struct reftable_block *block, struct reftable_buf *key) { - int off = br->header_off + 4, n; + int off = block->header_off + 4, n; struct string_view in = { - .buf = br->block.data + off, - .len = br->block_len - off, + .buf = block->block_data.data + off, + .len = block->restart_off - off, }; uint8_t extra = 0; @@ -353,33 +378,36 @@ int block_reader_first_key(const struct block_reader *br, struct reftable_buf *k return 0; } -static uint32_t block_reader_restart_offset(const struct block_reader *br, size_t idx) +static uint32_t block_restart_offset(const struct reftable_block *b, size_t idx) +{ + return reftable_get_be24(b->block_data.data + b->restart_off + 3 * idx); +} + +void block_iter_init(struct block_iter *it, const struct reftable_block *block) { - return reftable_get_be24(br->restart_bytes + 3 * idx); + it->block = block; + block_iter_seek_start(it); } -void block_iter_seek_start(struct block_iter *it, const struct block_reader *br) +void block_iter_seek_start(struct block_iter *it) { - it->block = br->block.data; - it->block_len = br->block_len; - it->hash_size = br->hash_size; reftable_buf_reset(&it->last_key); - it->next_off = br->header_off + 4; + it->next_off = it->block->header_off + 4; } struct restart_needle_less_args { int error; struct reftable_buf needle; - const struct block_reader *reader; + const struct reftable_block *block; }; static int restart_needle_less(size_t idx, void *_args) { struct restart_needle_less_args *args = _args; - uint32_t off = block_reader_restart_offset(args->reader, idx); + uint32_t off = block_restart_offset(args->block, idx); struct string_view in = { - .buf = args->reader->block.data + off, - .len = args->reader->block_len - off, + .buf = args->block->block_data.data + off, + .len = args->block->restart_off - off, }; uint64_t prefix_len, suffix_len; uint8_t extra; @@ -412,14 +440,14 @@ static int restart_needle_less(size_t idx, void *_args) int block_iter_next(struct block_iter *it, struct reftable_record *rec) { struct string_view in = { - .buf = (unsigned char *) it->block + it->next_off, - .len = it->block_len - it->next_off, + .buf = (unsigned char *) it->block->block_data.data + it->next_off, + .len = it->block->restart_off - it->next_off, }; struct string_view start = in; uint8_t extra = 0; int n = 0; - if (it->next_off >= it->block_len) + if (it->next_off >= it->block->restart_off) return 1; n = reftable_decode_key(&it->last_key, &extra, in); @@ -429,7 +457,7 @@ int block_iter_next(struct block_iter *it, struct reftable_record *rec) return REFTABLE_FORMAT_ERROR; string_view_consume(&in, n); - n = reftable_record_decode(rec, it->last_key, extra, in, it->hash_size, + n = reftable_record_decode(rec, it->last_key, extra, in, it->block->hash_size, &it->scratch); if (n < 0) return -1; @@ -444,8 +472,6 @@ void block_iter_reset(struct block_iter *it) reftable_buf_reset(&it->last_key); it->next_off = 0; it->block = NULL; - it->block_len = 0; - it->hash_size = 0; } void block_iter_close(struct block_iter *it) @@ -454,12 +480,11 @@ void block_iter_close(struct block_iter *it) reftable_buf_release(&it->scratch); } -int block_iter_seek_key(struct block_iter *it, const struct block_reader *br, - struct reftable_buf *want) +int block_iter_seek_key(struct block_iter *it, struct reftable_buf *want) { struct restart_needle_less_args args = { .needle = *want, - .reader = br, + .block = it->block, }; struct reftable_record rec; int err = 0; @@ -477,7 +502,7 @@ int block_iter_seek_key(struct block_iter *it, const struct block_reader *br, * restart point. While that works alright, we would end up scanning * too many record. */ - i = binsearch(br->restart_count, &restart_needle_less, &args); + i = binsearch(it->block->restart_count, &restart_needle_less, &args); if (args.error) { err = REFTABLE_FORMAT_ERROR; goto done; @@ -502,21 +527,18 @@ int block_iter_seek_key(struct block_iter *it, const struct block_reader *br, * starting from the preceding restart point. */ if (i > 0) - it->next_off = block_reader_restart_offset(br, i - 1); + it->next_off = block_restart_offset(it->block, i - 1); else - it->next_off = br->header_off + 4; - it->block = br->block.data; - it->block_len = br->block_len; - it->hash_size = br->hash_size; + it->next_off = it->block->header_off + 4; - err = reftable_record_init(&rec, block_reader_type(br)); + err = reftable_record_init(&rec, reftable_block_type(it->block)); if (err < 0) goto done; /* * We're looking for the last entry less than the wanted key so that * the next call to `block_reader_next()` would yield the wanted - * record. We thus don't want to position our reader at the sought + * record. We thus don't want to position our iterator at the sought * after record, but one before. To do so, we have to go one entry too * far and then back up. */ @@ -561,6 +583,61 @@ done: return err; } +static int block_iter_seek_void(void *it, struct reftable_record *want) +{ + struct reftable_buf buf = REFTABLE_BUF_INIT; + struct block_iter *bi = it; + int err; + + if (bi->block->block_type != want->type) + return REFTABLE_API_ERROR; + + err = reftable_record_key(want, &buf); + if (err < 0) + goto out; + + err = block_iter_seek_key(it, &buf); + if (err < 0) + goto out; + + err = 0; + +out: + reftable_buf_release(&buf); + return err; +} + +static int block_iter_next_void(void *it, struct reftable_record *rec) +{ + return block_iter_next(it, rec); +} + +static void block_iter_close_void(void *it) +{ + block_iter_close(it); +} + +static struct reftable_iterator_vtable block_iter_vtable = { + .seek = &block_iter_seek_void, + .next = &block_iter_next_void, + .close = &block_iter_close_void, +}; + +int reftable_block_init_iterator(const struct reftable_block *b, + struct reftable_iterator *it) +{ + struct block_iter *bi; + + REFTABLE_CALLOC_ARRAY(bi, 1); + block_iter_init(bi, b); + + assert(!it->ops); + it->iter_arg = bi; + it->ops = &block_iter_vtable; + + return 0; +} + void block_writer_release(struct block_writer *bw) { deflateEnd(bw->zstream); @@ -571,14 +648,3 @@ void block_writer_release(struct block_writer *bw) reftable_buf_release(&bw->last_key); /* the block is not owned. */ } - -void reftable_block_done(struct reftable_block *blockp) -{ - struct reftable_block_source source = blockp->source; - if (blockp && source.ops) - source.ops->return_block(source.arg, blockp); - blockp->data = NULL; - blockp->len = 0; - blockp->source.ops = NULL; - blockp->source.arg = NULL; -} diff --git a/reftable/block.h b/reftable/block.h index 64732eba7d..d6dfaae33e 100644 --- a/reftable/block.h +++ b/reftable/block.h @@ -1,16 +1,17 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef BLOCK_H #define BLOCK_H #include "basics.h" #include "record.h" +#include "reftable-block.h" #include "reftable-blocksource.h" /* @@ -18,7 +19,7 @@ https://developers.google.com/open-source/licenses/bsd * allocation overhead. */ struct block_writer { - z_stream *zstream; + struct z_stream_s *zstream; unsigned char *compressed; size_t compressed_cap; @@ -62,53 +63,11 @@ int block_writer_finish(struct block_writer *w); /* clears out internally allocated block_writer members. */ void block_writer_release(struct block_writer *bw); -struct z_stream; - -/* Read a block. */ -struct block_reader { - /* offset of the block header; nonzero for the first block in a - * reftable. */ - uint32_t header_off; - - /* the memory block */ - struct reftable_block block; - uint32_t hash_size; - - /* Uncompressed data for log entries. */ - z_stream *zstream; - unsigned char *uncompressed_data; - size_t uncompressed_cap; - - /* size of the data, excluding restart data. */ - uint32_t block_len; - uint8_t *restart_bytes; - uint16_t restart_count; - - /* size of the data in the file. For log blocks, this is the compressed - * size. */ - uint32_t full_block_size; -}; - -/* initializes a block reader. */ -int block_reader_init(struct block_reader *br, struct reftable_block *bl, - uint32_t header_off, uint32_t table_block_size, - uint32_t hash_size); - -void block_reader_release(struct block_reader *br); - -/* Returns the block type (eg. 'r' for refs) */ -uint8_t block_reader_type(const struct block_reader *r); - -/* Decodes the first key in the block */ -int block_reader_first_key(const struct block_reader *br, struct reftable_buf *key); - -/* Iterate over entries in a block */ +/* Iterator for records contained in a single block. */ struct block_iter { /* offset within the block of the next entry to read. */ uint32_t next_off; - const unsigned char *block; - size_t block_len; - uint32_t hash_size; + const struct reftable_block *block; /* key for last entry we read. */ struct reftable_buf last_key; @@ -120,12 +79,23 @@ struct block_iter { .scratch = REFTABLE_BUF_INIT, \ } -/* Position `it` at start of the block */ -void block_iter_seek_start(struct block_iter *it, const struct block_reader *br); +/* + * Initialize the block iterator with the given block. The iterator will be + * positioned at the first record contained in the block. The block must remain + * valid until the end of the iterator's lifetime. It is valid to re-initialize + * iterators multiple times. + */ +void block_iter_init(struct block_iter *it, const struct reftable_block *block); -/* Position `it` to the `want` key in the block */ -int block_iter_seek_key(struct block_iter *it, const struct block_reader *br, - struct reftable_buf *want); +/* Position the initialized iterator at the first record of its block. */ +void block_iter_seek_start(struct block_iter *it); + +/* + * Position the initialized iterator at the desired record key. It is not an + * error in case the record cannot be found. If so, a subsequent call to + * `block_iter_next()` will indicate that the iterator is exhausted. + */ +int block_iter_seek_key(struct block_iter *it, struct reftable_buf *want); /* return < 0 for error, 0 for OK, > 0 for EOF. */ int block_iter_next(struct block_iter *it, struct reftable_record *rec); @@ -142,7 +112,4 @@ size_t header_size(int version); /* size of file footer, depending on format version */ size_t footer_size(int version); -/* returns a block to its source. */ -void reftable_block_done(struct reftable_block *ret); - #endif diff --git a/reftable/blocksource.c b/reftable/blocksource.c index 78c1be2337..573c81287f 100644 --- a/reftable/blocksource.c +++ b/reftable/blocksource.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "system.h" @@ -13,7 +13,42 @@ https://developers.google.com/open-source/licenses/bsd #include "reftable-blocksource.h" #include "reftable-error.h" -static void reftable_buf_return_block(void *b REFTABLE_UNUSED, struct reftable_block *dest) +void block_source_release_data(struct reftable_block_data *data) +{ + struct reftable_block_source source = data->source; + if (data && source.ops) + source.ops->release_data(source.arg, data); + data->data = NULL; + data->len = 0; + data->source.ops = NULL; + data->source.arg = NULL; +} + +void block_source_close(struct reftable_block_source *source) +{ + if (!source->ops) { + return; + } + + source->ops->close(source->arg); + source->ops = NULL; +} + +ssize_t block_source_read_data(struct reftable_block_source *source, + struct reftable_block_data *dest, uint64_t off, + uint32_t size) +{ + ssize_t result = source->ops->read_data(source->arg, dest, off, size); + dest->source = *source; + return result; +} + +uint64_t block_source_size(struct reftable_block_source *source) +{ + return source->ops->size(source->arg); +} + +static void reftable_buf_release_data(void *b REFTABLE_UNUSED, struct reftable_block_data *dest) { if (dest->len) memset(dest->data, 0xff, dest->len); @@ -24,8 +59,8 @@ static void reftable_buf_close(void *b REFTABLE_UNUSED) { } -static ssize_t reftable_buf_read_block(void *v, struct reftable_block *dest, - uint64_t off, uint32_t size) +static ssize_t reftable_buf_read_data(void *v, struct reftable_block_data *dest, + uint64_t off, uint32_t size) { struct reftable_buf *b = v; assert(off + size <= b->len); @@ -44,8 +79,8 @@ static uint64_t reftable_buf_size(void *b) static struct reftable_block_source_vtable reftable_buf_vtable = { .size = &reftable_buf_size, - .read_block = &reftable_buf_read_block, - .return_block = &reftable_buf_return_block, + .read_data = &reftable_buf_read_data, + .release_data = &reftable_buf_release_data, .close = &reftable_buf_close, }; @@ -67,7 +102,7 @@ static uint64_t file_size(void *b) return ((struct file_block_source *)b)->size; } -static void file_return_block(void *b REFTABLE_UNUSED, struct reftable_block *dest REFTABLE_UNUSED) +static void file_release_data(void *b REFTABLE_UNUSED, struct reftable_block_data *dest REFTABLE_UNUSED) { } @@ -78,8 +113,8 @@ static void file_close(void *v) reftable_free(b); } -static ssize_t file_read_block(void *v, struct reftable_block *dest, uint64_t off, - uint32_t size) +static ssize_t file_read_data(void *v, struct reftable_block_data *dest, uint64_t off, + uint32_t size) { struct file_block_source *b = v; assert(off + size <= b->size); @@ -90,8 +125,8 @@ static ssize_t file_read_block(void *v, struct reftable_block *dest, uint64_t of static struct reftable_block_source_vtable file_vtable = { .size = &file_size, - .read_block = &file_read_block, - .return_block = &file_return_block, + .read_data = &file_read_data, + .release_data = &file_release_data, .close = &file_close, }; diff --git a/reftable/blocksource.h b/reftable/blocksource.h index a84a3ccd89..a110e05958 100644 --- a/reftable/blocksource.h +++ b/reftable/blocksource.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef BLOCKSOURCE_H #define BLOCKSOURCE_H @@ -12,9 +12,34 @@ https://developers.google.com/open-source/licenses/bsd #include "system.h" struct reftable_block_source; +struct reftable_block_data; struct reftable_buf; -/* Create an in-memory block source for reading reftables */ +/* + * Close the block source and the underlying resource. This is a no-op in case + * the block source is zero-initialized. + */ +void block_source_close(struct reftable_block_source *source); + +/* + * Read a block of length `size` from the source at the given `off`. + */ +ssize_t block_source_read_data(struct reftable_block_source *source, + struct reftable_block_data *dest, uint64_t off, + uint32_t size); + +/* + * Return the total length of the underlying resource. + */ +uint64_t block_source_size(struct reftable_block_source *source); + +/* + * Return a block to its original source, releasing any resources associated + * with it. + */ +void block_source_release_data(struct reftable_block_data *data); + +/* Create an in-memory block source for reading reftables. */ void block_source_from_buf(struct reftable_block_source *bs, struct reftable_buf *buf); diff --git a/reftable/constants.h b/reftable/constants.h index f6beb843eb..e3b1aaa516 100644 --- a/reftable/constants.h +++ b/reftable/constants.h @@ -1,19 +1,15 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef CONSTANTS_H #define CONSTANTS_H -#define BLOCK_TYPE_LOG 'g' -#define BLOCK_TYPE_INDEX 'i' -#define BLOCK_TYPE_REF 'r' -#define BLOCK_TYPE_OBJ 'o' -#define BLOCK_TYPE_ANY 0 +#include "reftable-constants.h" #define MAX_RESTARTS ((1 << 16) - 1) #define DEFAULT_BLOCK_SIZE 4096 diff --git a/reftable/error.c b/reftable/error.c index 660d029617..c7cab2dbc4 100644 --- a/reftable/error.c +++ b/reftable/error.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "system.h" #include "reftable-error.h" diff --git a/reftable/iter.c b/reftable/iter.c index f520382e70..2ecc52b336 100644 --- a/reftable/iter.c +++ b/reftable/iter.c @@ -1,19 +1,20 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "iter.h" #include "system.h" #include "block.h" +#include "blocksource.h" #include "constants.h" -#include "reader.h" #include "reftable-error.h" +#include "table.h" int iterator_seek(struct reftable_iterator *it, struct reftable_record *want) { @@ -113,7 +114,7 @@ static void indexed_table_ref_iter_close(void *p) { struct indexed_table_ref_iter *it = p; block_iter_close(&it->cur); - reftable_block_done(&it->block_reader.block); + block_source_release_data(&it->block.block_data); reftable_free(it->offsets); reftable_buf_release(&it->oid); } @@ -127,11 +128,10 @@ static int indexed_table_ref_iter_next_block(struct indexed_table_ref_iter *it) return 1; } - reftable_block_done(&it->block_reader.block); + block_source_release_data(&it->block.block_data); off = it->offsets[it->offset_idx++]; - err = reader_init_block_reader(it->r, &it->block_reader, off, - BLOCK_TYPE_REF); + err = table_init_block(it->table, &it->block, off, REFTABLE_BLOCK_TYPE_REF); if (err < 0) { return err; } @@ -139,7 +139,7 @@ static int indexed_table_ref_iter_next_block(struct indexed_table_ref_iter *it) /* indexed block does not exist. */ return REFTABLE_FORMAT_ERROR; } - block_iter_seek_start(&it->cur, &it->block_reader); + block_iter_init(&it->cur, &it->block); return 0; } @@ -181,7 +181,7 @@ static int indexed_table_ref_iter_next(void *p, struct reftable_record *rec) } int indexed_table_ref_iter_new(struct indexed_table_ref_iter **dest, - struct reftable_reader *r, uint8_t *oid, + struct reftable_table *t, uint8_t *oid, int oid_len, uint64_t *offsets, int offset_len) { struct indexed_table_ref_iter empty = INDEXED_TABLE_REF_ITER_INIT; @@ -195,7 +195,7 @@ int indexed_table_ref_iter_new(struct indexed_table_ref_iter **dest, } *itr = empty; - itr->r = r; + itr->table = t; err = reftable_buf_add(&itr->oid, oid, oid_len); if (err < 0) @@ -246,7 +246,7 @@ int reftable_iterator_seek_ref(struct reftable_iterator *it, const char *name) { struct reftable_record want = { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u.ref = { .refname = (char *)name, }, @@ -258,7 +258,7 @@ int reftable_iterator_next_ref(struct reftable_iterator *it, struct reftable_ref_record *ref) { struct reftable_record rec = { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u = { .ref = *ref }, @@ -272,7 +272,7 @@ int reftable_iterator_seek_log_at(struct reftable_iterator *it, const char *name, uint64_t update_index) { struct reftable_record want = { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u.log = { .refname = (char *)name, .update_index = update_index, @@ -291,7 +291,7 @@ int reftable_iterator_next_log(struct reftable_iterator *it, struct reftable_log_record *log) { struct reftable_record rec = { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u = { .log = *log, }, diff --git a/reftable/iter.h b/reftable/iter.h index 40f98893b8..cc920970a5 100644 --- a/reftable/iter.h +++ b/reftable/iter.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef ITER_H #define ITER_H @@ -59,7 +59,7 @@ void iterator_from_filtering_ref_iterator(struct reftable_iterator *, * but using the object index. */ struct indexed_table_ref_iter { - struct reftable_reader *r; + struct reftable_table *table; struct reftable_buf oid; /* mutable */ @@ -68,7 +68,7 @@ struct indexed_table_ref_iter { /* Points to the next offset to read. */ int offset_idx; int offset_len; - struct block_reader block_reader; + struct reftable_block block; struct block_iter cur; int is_finished; }; @@ -83,7 +83,7 @@ void iterator_from_indexed_table_ref_iter(struct reftable_iterator *it, /* Takes ownership of `offsets` */ int indexed_table_ref_iter_new(struct indexed_table_ref_iter **dest, - struct reftable_reader *r, uint8_t *oid, + struct reftable_table *t, uint8_t *oid, int oid_len, uint64_t *offsets, int offset_len); #endif diff --git a/reftable/merged.c b/reftable/merged.c index 4ff1553772..733de07454 100644 --- a/reftable/merged.c +++ b/reftable/merged.c @@ -1,21 +1,21 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "merged.h" #include "constants.h" #include "iter.h" #include "pq.h" -#include "reader.h" #include "record.h" #include "reftable-merged.h" #include "reftable-error.h" #include "system.h" +#include "table.h" struct merged_subiter { struct reftable_iterator iter; @@ -192,7 +192,7 @@ static void iterator_from_merged_iter(struct reftable_iterator *it, } int reftable_merged_table_new(struct reftable_merged_table **dest, - struct reftable_reader **readers, size_t n, + struct reftable_table **tables, size_t n, enum reftable_hash hash_id) { struct reftable_merged_table *m = NULL; @@ -200,10 +200,10 @@ int reftable_merged_table_new(struct reftable_merged_table **dest, uint64_t first_min = 0; for (size_t i = 0; i < n; i++) { - uint64_t min = reftable_reader_min_update_index(readers[i]); - uint64_t max = reftable_reader_max_update_index(readers[i]); + uint64_t min = reftable_table_min_update_index(tables[i]); + uint64_t max = reftable_table_max_update_index(tables[i]); - if (reftable_reader_hash_id(readers[i]) != hash_id) { + if (reftable_table_hash_id(tables[i]) != hash_id) { return REFTABLE_FORMAT_ERROR; } if (i == 0 || min < first_min) { @@ -218,8 +218,8 @@ int reftable_merged_table_new(struct reftable_merged_table **dest, if (!m) return REFTABLE_OUT_OF_MEMORY_ERROR; - m->readers = readers; - m->readers_len = n; + m->tables = tables; + m->tables_len = n; m->min = first_min; m->max = last_max; m->hash_id = hash_id; @@ -254,20 +254,20 @@ int merged_table_init_iter(struct reftable_merged_table *mt, struct merged_iter *mi = NULL; int ret; - if (mt->readers_len) { - REFTABLE_CALLOC_ARRAY(subiters, mt->readers_len); + if (mt->tables_len) { + REFTABLE_CALLOC_ARRAY(subiters, mt->tables_len); if (!subiters) { ret = REFTABLE_OUT_OF_MEMORY_ERROR; goto out; } } - for (size_t i = 0; i < mt->readers_len; i++) { + for (size_t i = 0; i < mt->tables_len; i++) { ret = reftable_record_init(&subiters[i].rec, typ); if (ret < 0) goto out; - ret = reader_init_iter(mt->readers[i], &subiters[i].iter, typ); + ret = table_init_iter(mt->tables[i], &subiters[i].iter, typ); if (ret < 0) goto out; } @@ -280,14 +280,14 @@ int merged_table_init_iter(struct reftable_merged_table *mt, mi->advance_index = -1; mi->suppress_deletions = mt->suppress_deletions; mi->subiters = subiters; - mi->subiters_len = mt->readers_len; + mi->subiters_len = mt->tables_len; iterator_from_merged_iter(it, mi); ret = 0; out: if (ret < 0) { - for (size_t i = 0; subiters && i < mt->readers_len; i++) { + for (size_t i = 0; subiters && i < mt->tables_len; i++) { reftable_iterator_destroy(&subiters[i].iter); reftable_record_release(&subiters[i].rec); } @@ -301,13 +301,13 @@ out: int reftable_merged_table_init_ref_iterator(struct reftable_merged_table *mt, struct reftable_iterator *it) { - return merged_table_init_iter(mt, it, BLOCK_TYPE_REF); + return merged_table_init_iter(mt, it, REFTABLE_BLOCK_TYPE_REF); } int reftable_merged_table_init_log_iterator(struct reftable_merged_table *mt, struct reftable_iterator *it) { - return merged_table_init_iter(mt, it, BLOCK_TYPE_LOG); + return merged_table_init_iter(mt, it, REFTABLE_BLOCK_TYPE_LOG); } enum reftable_hash reftable_merged_table_hash_id(struct reftable_merged_table *mt) diff --git a/reftable/merged.h b/reftable/merged.h index 0b7d939e92..4317e5f5f6 100644 --- a/reftable/merged.h +++ b/reftable/merged.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef MERGED_H #define MERGED_H @@ -13,8 +13,8 @@ https://developers.google.com/open-source/licenses/bsd #include "reftable-basics.h" struct reftable_merged_table { - struct reftable_reader **readers; - size_t readers_len; + struct reftable_table **tables; + size_t tables_len; enum reftable_hash hash_id; /* If unset, produce deletions. This is useful for compaction. For the diff --git a/reftable/pq.c b/reftable/pq.c index 82394a972d..9a79f5c5ee 100644 --- a/reftable/pq.c +++ b/reftable/pq.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "pq.h" diff --git a/reftable/pq.h b/reftable/pq.h index ff39016445..42310670b0 100644 --- a/reftable/pq.h +++ b/reftable/pq.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef PQ_H #define PQ_H diff --git a/reftable/reader.h b/reftable/reader.h deleted file mode 100644 index bb72108a6f..0000000000 --- a/reftable/reader.h +++ /dev/null @@ -1,67 +0,0 @@ -/* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ - -#ifndef READER_H -#define READER_H - -#include "block.h" -#include "record.h" -#include "reftable-iterator.h" -#include "reftable-reader.h" - -uint64_t block_source_size(struct reftable_block_source *source); - -ssize_t block_source_read_block(struct reftable_block_source *source, - struct reftable_block *dest, uint64_t off, - uint32_t size); -void block_source_close(struct reftable_block_source *source); - -/* metadata for a block type */ -struct reftable_reader_offsets { - int is_present; - uint64_t offset; - uint64_t index_offset; -}; - -/* The state for reading a reftable file. */ -struct reftable_reader { - /* for convenience, associate a name with the instance. */ - char *name; - struct reftable_block_source source; - - /* Size of the file, excluding the footer. */ - uint64_t size; - - /* The hash function used for ref records. */ - enum reftable_hash hash_id; - - uint32_t block_size; - uint64_t min_update_index; - uint64_t max_update_index; - /* Length of the OID keys in the 'o' section */ - int object_id_len; - int version; - - struct reftable_reader_offsets ref_offsets; - struct reftable_reader_offsets obj_offsets; - struct reftable_reader_offsets log_offsets; - - uint64_t refcount; -}; - -const char *reader_name(struct reftable_reader *r); - -int reader_init_iter(struct reftable_reader *r, - struct reftable_iterator *it, - uint8_t typ); - -/* initialize a block reader to read from `r` */ -int reader_init_block_reader(struct reftable_reader *r, struct block_reader *br, - uint64_t next_off, uint8_t want_typ); - -#endif diff --git a/reftable/record.c b/reftable/record.c index c0080024ed..fcd387ba5d 100644 --- a/reftable/record.c +++ b/reftable/record.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ /* record.c - methods for different types of records. */ @@ -69,10 +69,10 @@ int put_var_int(struct string_view *dest, uint64_t value) int reftable_is_block_type(uint8_t typ) { switch (typ) { - case BLOCK_TYPE_REF: - case BLOCK_TYPE_LOG: - case BLOCK_TYPE_OBJ: - case BLOCK_TYPE_INDEX: + case REFTABLE_BLOCK_TYPE_REF: + case REFTABLE_BLOCK_TYPE_LOG: + case REFTABLE_BLOCK_TYPE_OBJ: + case REFTABLE_BLOCK_TYPE_INDEX: return 1; } return 0; @@ -459,7 +459,7 @@ static int reftable_ref_record_cmp_void(const void *_a, const void *_b) static struct reftable_record_vtable reftable_ref_record_vtable = { .key = &reftable_ref_record_key, - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .copy_from = &reftable_ref_record_copy_from, .val_type = &reftable_ref_record_val_type, .encode = &reftable_ref_record_encode, @@ -659,7 +659,7 @@ static int reftable_obj_record_cmp_void(const void *_a, const void *_b) static struct reftable_record_vtable reftable_obj_record_vtable = { .key = &reftable_obj_record_key, - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .copy_from = &reftable_obj_record_copy_from, .val_type = &reftable_obj_record_val_type, .encode = &reftable_obj_record_encode, @@ -1030,7 +1030,7 @@ static int reftable_log_record_is_deletion_void(const void *p) static struct reftable_record_vtable reftable_log_record_vtable = { .key = &reftable_log_record_key, - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .copy_from = &reftable_log_record_copy_from, .val_type = &reftable_log_record_val_type, .encode = &reftable_log_record_encode, @@ -1132,7 +1132,7 @@ static int reftable_index_record_cmp(const void *_a, const void *_b) static struct reftable_record_vtable reftable_index_record_vtable = { .key = &reftable_index_record_key, - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .copy_from = &reftable_index_record_copy_from, .val_type = &reftable_index_record_val_type, .encode = &reftable_index_record_encode, @@ -1275,13 +1275,13 @@ int reftable_log_record_is_deletion(const struct reftable_log_record *log) static void *reftable_record_data(struct reftable_record *rec) { switch (rec->type) { - case BLOCK_TYPE_REF: + case REFTABLE_BLOCK_TYPE_REF: return &rec->u.ref; - case BLOCK_TYPE_LOG: + case REFTABLE_BLOCK_TYPE_LOG: return &rec->u.log; - case BLOCK_TYPE_INDEX: + case REFTABLE_BLOCK_TYPE_INDEX: return &rec->u.idx; - case BLOCK_TYPE_OBJ: + case REFTABLE_BLOCK_TYPE_OBJ: return &rec->u.obj; } abort(); @@ -1291,13 +1291,13 @@ static struct reftable_record_vtable * reftable_record_vtable(struct reftable_record *rec) { switch (rec->type) { - case BLOCK_TYPE_REF: + case REFTABLE_BLOCK_TYPE_REF: return &reftable_ref_record_vtable; - case BLOCK_TYPE_LOG: + case REFTABLE_BLOCK_TYPE_LOG: return &reftable_log_record_vtable; - case BLOCK_TYPE_INDEX: + case REFTABLE_BLOCK_TYPE_INDEX: return &reftable_index_record_vtable; - case BLOCK_TYPE_OBJ: + case REFTABLE_BLOCK_TYPE_OBJ: return &reftable_obj_record_vtable; } abort(); @@ -1309,11 +1309,11 @@ int reftable_record_init(struct reftable_record *rec, uint8_t typ) rec->type = typ; switch (typ) { - case BLOCK_TYPE_REF: - case BLOCK_TYPE_LOG: - case BLOCK_TYPE_OBJ: + case REFTABLE_BLOCK_TYPE_REF: + case REFTABLE_BLOCK_TYPE_LOG: + case REFTABLE_BLOCK_TYPE_OBJ: return 0; - case BLOCK_TYPE_INDEX: + case REFTABLE_BLOCK_TYPE_INDEX: reftable_buf_init(&rec->u.idx.last_key); return 0; default: diff --git a/reftable/record.h b/reftable/record.h index 867810a932..7953f352a3 100644 --- a/reftable/record.h +++ b/reftable/record.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef RECORD_H #define RECORD_H diff --git a/reftable/reftable-basics.h b/reftable/reftable-basics.h index e0397ed583..6d73f19c85 100644 --- a/reftable/reftable-basics.h +++ b/reftable/reftable-basics.h @@ -4,13 +4,21 @@ * Use of this source code is governed by a BSD-style * license that can be found in the LICENSE file or at * https://developers.google.com/open-source/licenses/bsd -*/ + */ #ifndef REFTABLE_BASICS_H #define REFTABLE_BASICS_H #include <stddef.h> +/* A buffer that contains arbitrary byte slices. */ +struct reftable_buf { + size_t alloc; + size_t len; + char *buf; +}; +#define REFTABLE_BUF_INIT { 0 } + /* * Hash functions understood by the reftable library. Note that the values are * arbitrary and somewhat random such that we can easily detect cases where the diff --git a/reftable/reftable-block.h b/reftable/reftable-block.h new file mode 100644 index 0000000000..04c3b518c8 --- /dev/null +++ b/reftable/reftable-block.h @@ -0,0 +1,74 @@ +/* + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ + +#ifndef REFTABLE_BLOCK_H +#define REFTABLE_BLOCK_H + +#include <stdint.h> + +#include "reftable-basics.h" +#include "reftable-blocksource.h" +#include "reftable-iterator.h" + +struct z_stream_s; + +/* + * A block part of a reftable. Contains records as well as some metadata + * describing them. + */ +struct reftable_block { + /* + * Offset of the block header; nonzero for the first block in a + * reftable. + */ + uint32_t header_off; + + /* The memory block. */ + struct reftable_block_data block_data; + uint32_t hash_size; + + /* Uncompressed data for log entries. */ + struct z_stream_s *zstream; + unsigned char *uncompressed_data; + size_t uncompressed_cap; + + /* + * Restart point data. Restart points are located after the block's + * record data. + */ + uint16_t restart_count; + uint32_t restart_off; + + /* + * Size of the data in the file. For log blocks, this is the compressed + * size. + */ + uint32_t full_block_size; + uint8_t block_type; +}; + +/* Initialize a reftable block from the given block source. */ +int reftable_block_init(struct reftable_block *b, + struct reftable_block_source *source, + uint32_t offset, uint32_t header_size, + uint32_t table_block_size, uint32_t hash_size); + +/* Release resources allocated by the block. */ +void reftable_block_release(struct reftable_block *b); + +/* Initialize a generic record iterator from the given block. */ +int reftable_block_init_iterator(const struct reftable_block *b, + struct reftable_iterator *it); + +/* Returns the block type (eg. 'r' for refs). */ +uint8_t reftable_block_type(const struct reftable_block *b); + +/* Decodes the first key in the block. */ +int reftable_block_first_key(const struct reftable_block *b, struct reftable_buf *key); + +#endif /* REFTABLE_BLOCK_H */ diff --git a/reftable/reftable-blocksource.h b/reftable/reftable-blocksource.h index 6b326aa5ea..f5ba867bd6 100644 --- a/reftable/reftable-blocksource.h +++ b/reftable/reftable-blocksource.h @@ -1,17 +1,18 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_BLOCKSOURCE_H #define REFTABLE_BLOCKSOURCE_H #include <stdint.h> -/* block_source is a generic wrapper for a seekable readable file. +/* + * Generic wrapper for a seekable readable file. */ struct reftable_block_source { struct reftable_block_source_vtable *ops; @@ -20,7 +21,7 @@ struct reftable_block_source { /* a contiguous segment of bytes. It keeps track of its generating block_source * so it can return itself into the pool. */ -struct reftable_block { +struct reftable_block_data { uint8_t *data; size_t len; struct reftable_block_source source; @@ -28,20 +29,20 @@ struct reftable_block { /* block_source_vtable are the operations that make up block_source */ struct reftable_block_source_vtable { - /* returns the size of a block source */ + /* Returns the size of a block source. */ uint64_t (*size)(void *source); /* * Reads a segment from the block source. It is an error to read beyond * the end of the block. */ - ssize_t (*read_block)(void *source, struct reftable_block *dest, - uint64_t off, uint32_t size); + ssize_t (*read_data)(void *source, struct reftable_block_data *dest, + uint64_t off, uint32_t size); - /* mark the block as read; may return the data back to malloc */ - void (*return_block)(void *source, struct reftable_block *blockp); + /* Mark the block as read; may release the data. */ + void (*release_data)(void *source, struct reftable_block_data *data); - /* release all resources associated with the block source */ + /* Release all resources associated with the block source. */ void (*close)(void *source); }; diff --git a/reftable/reftable-constants.h b/reftable/reftable-constants.h new file mode 100644 index 0000000000..4ae9ba4bac --- /dev/null +++ b/reftable/reftable-constants.h @@ -0,0 +1,18 @@ +/* + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ + +#ifndef REFTABLE_CONSTANTS_H +#define REFTABLE_CONSTANTS_H + +#define REFTABLE_BLOCK_TYPE_LOG 'g' +#define REFTABLE_BLOCK_TYPE_INDEX 'i' +#define REFTABLE_BLOCK_TYPE_REF 'r' +#define REFTABLE_BLOCK_TYPE_OBJ 'o' +#define REFTABLE_BLOCK_TYPE_ANY 0 + +#endif /* REFTABLE_CONSTANTS_H */ diff --git a/reftable/reftable-error.h b/reftable/reftable-error.h index a7e33d964d..d100e0df92 100644 --- a/reftable/reftable-error.h +++ b/reftable/reftable-error.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_ERROR_H #define REFTABLE_ERROR_H diff --git a/reftable/reftable-iterator.h b/reftable/reftable-iterator.h index e3bf688d53..af582028c2 100644 --- a/reftable/reftable-iterator.h +++ b/reftable/reftable-iterator.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_ITERATOR_H #define REFTABLE_ITERATOR_H diff --git a/reftable/reftable-merged.h b/reftable/reftable-merged.h index f2d01c3ef8..e5af846b32 100644 --- a/reftable/reftable-merged.h +++ b/reftable/reftable-merged.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_MERGED_H #define REFTABLE_MERGED_H @@ -26,14 +26,14 @@ https://developers.google.com/open-source/licenses/bsd /* A merged table is implements seeking/iterating over a stack of tables. */ struct reftable_merged_table; -struct reftable_reader; +struct reftable_table; /* - * reftable_merged_table_new creates a new merged table. The readers must be + * reftable_merged_table_new creates a new merged table. The tables must be * kept alive as long as the merged table is still in use. */ int reftable_merged_table_new(struct reftable_merged_table **dest, - struct reftable_reader **readers, size_t n, + struct reftable_table **tables, size_t n, enum reftable_hash hash_id); /* Initialize a merged table iterator for reading refs. */ diff --git a/reftable/reftable-reader.h b/reftable/reftable-reader.h deleted file mode 100644 index 0085fbb903..0000000000 --- a/reftable/reftable-reader.h +++ /dev/null @@ -1,72 +0,0 @@ -/* - Copyright 2020 Google LLC - - Use of this source code is governed by a BSD-style - license that can be found in the LICENSE file or at - https://developers.google.com/open-source/licenses/bsd -*/ - -#ifndef REFTABLE_READER_H -#define REFTABLE_READER_H - -#include "reftable-iterator.h" -#include "reftable-blocksource.h" - -/* - * Reading single tables - * - * The follow routines are for reading single files. For an - * application-level interface, skip ahead to struct - * reftable_merged_table and struct reftable_stack. - */ - -/* The reader struct is a handle to an open reftable file. */ -struct reftable_reader; - -/* reftable_reader_new opens a reftable for reading. If successful, - * returns 0 code and sets pp. The name is used for creating a - * stack. Typically, it is the basename of the file. The block source - * `src` is owned by the reader, and is closed on calling - * reftable_reader_destroy(). On error, the block source `src` is - * closed as well. - */ -int reftable_reader_new(struct reftable_reader **pp, - struct reftable_block_source *src, const char *name); - -/* - * Manage the reference count of the reftable reader. A newly initialized - * reader starts with a refcount of 1 and will be deleted once the refcount has - * reached 0. - * - * This is required because readers may have longer lifetimes than the stack - * they belong to. The stack may for example be reloaded while the old tables - * are still being accessed by an iterator. - */ -void reftable_reader_incref(struct reftable_reader *reader); -void reftable_reader_decref(struct reftable_reader *reader); - -/* Initialize a reftable iterator for reading refs. */ -int reftable_reader_init_ref_iterator(struct reftable_reader *r, - struct reftable_iterator *it); - -/* Initialize a reftable iterator for reading logs. */ -int reftable_reader_init_log_iterator(struct reftable_reader *r, - struct reftable_iterator *it); - -/* returns the hash ID used in this table. */ -enum reftable_hash reftable_reader_hash_id(struct reftable_reader *r); - -/* return an iterator for the refs pointing to `oid`. */ -int reftable_reader_refs_for(struct reftable_reader *r, - struct reftable_iterator *it, uint8_t *oid); - -/* return the max_update_index for a table */ -uint64_t reftable_reader_max_update_index(struct reftable_reader *r); - -/* return the min_update_index for a table */ -uint64_t reftable_reader_min_update_index(struct reftable_reader *r); - -/* print blocks onto stdout for debugging. */ -int reftable_reader_print_blocks(const char *tablename); - -#endif diff --git a/reftable/reftable-record.h b/reftable/reftable-record.h index 931e594744..385a74cc86 100644 --- a/reftable/reftable-record.h +++ b/reftable/reftable-record.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_RECORD_H #define REFTABLE_RECORD_H diff --git a/reftable/reftable-stack.h b/reftable/reftable-stack.h index ae14270ea7..910ec6ef3a 100644 --- a/reftable/reftable-stack.h +++ b/reftable/reftable-stack.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_STACK_H #define REFTABLE_STACK_H diff --git a/reftable/reftable-table.h b/reftable/reftable-table.h new file mode 100644 index 0000000000..5f935d02e3 --- /dev/null +++ b/reftable/reftable-table.h @@ -0,0 +1,115 @@ +/* + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ + +#ifndef REFTABLE_TABLE_H +#define REFTABLE_TABLE_H + +#include "reftable-iterator.h" +#include "reftable-block.h" +#include "reftable-blocksource.h" + +/* + * Reading single tables + * + * The follow routines are for reading single files. For an + * application-level interface, skip ahead to struct + * reftable_merged_table and struct reftable_stack. + */ + +/* Metadata for a block type. */ +struct reftable_table_offsets { + int is_present; + uint64_t offset; + uint64_t index_offset; +}; + +/* The table struct is a handle to an open reftable file. */ +struct reftable_table { + /* for convenience, associate a name with the instance. */ + char *name; + struct reftable_block_source source; + + /* Size of the file, excluding the footer. */ + uint64_t size; + + /* The hash function used for ref records. */ + enum reftable_hash hash_id; + + uint32_t block_size; + uint64_t min_update_index; + uint64_t max_update_index; + /* Length of the OID keys in the 'o' section */ + int object_id_len; + int version; + + struct reftable_table_offsets ref_offsets; + struct reftable_table_offsets obj_offsets; + struct reftable_table_offsets log_offsets; + + uint64_t refcount; +}; + +/* reftable_table_new opens a reftable for reading. If successful, + * returns 0 code and sets pp. The name is used for creating a + * stack. Typically, it is the basename of the file. The block source + * `src` is owned by the table, and is closed on calling + * reftable_table_destroy(). On error, the block source `src` is + * closed as well. + */ +int reftable_table_new(struct reftable_table **out, + struct reftable_block_source *src, const char *name); + +/* + * Manage the reference count of the reftable table. A newly initialized + * table starts with a refcount of 1 and will be deleted once the refcount has + * reached 0. + * + * This is required because tables may have longer lifetimes than the stack + * they belong to. The stack may for example be reloaded while the old tables + * are still being accessed by an iterator. + */ +void reftable_table_incref(struct reftable_table *table); +void reftable_table_decref(struct reftable_table *table); + +/* Initialize a reftable iterator for reading refs. */ +int reftable_table_init_ref_iterator(struct reftable_table *t, + struct reftable_iterator *it); + +/* Initialize a reftable iterator for reading logs. */ +int reftable_table_init_log_iterator(struct reftable_table *t, + struct reftable_iterator *it); + +/* returns the hash ID used in this table. */ +enum reftable_hash reftable_table_hash_id(struct reftable_table *t); + +/* return an iterator for the refs pointing to `oid`. */ +int reftable_table_refs_for(struct reftable_table *t, + struct reftable_iterator *it, uint8_t *oid); + +/* return the max_update_index for a table */ +uint64_t reftable_table_max_update_index(struct reftable_table *t); + +/* return the min_update_index for a table */ +uint64_t reftable_table_min_update_index(struct reftable_table *t); + +/* + * An iterator that iterates through the blocks contained in a given table. + */ +struct reftable_table_iterator { + void *iter_arg; +}; + +int reftable_table_iterator_init(struct reftable_table_iterator *it, + struct reftable_table *t); + +void reftable_table_iterator_release(struct reftable_table_iterator *it); + +int reftable_table_iterator_next(struct reftable_table_iterator *it, + const struct reftable_block **out); + +#endif diff --git a/reftable/reftable-writer.h b/reftable/reftable-writer.h index 1befe3b07c..0fbeff17f4 100644 --- a/reftable/reftable-writer.h +++ b/reftable/reftable-writer.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef REFTABLE_WRITER_H #define REFTABLE_WRITER_H diff --git a/reftable/stack.c b/reftable/stack.c index 6dac015b47..4caf96aa1d 100644 --- a/reftable/stack.c +++ b/reftable/stack.c @@ -1,20 +1,20 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "stack.h" #include "system.h" #include "constants.h" #include "merged.h" -#include "reader.h" #include "reftable-error.h" #include "reftable-record.h" #include "reftable-merged.h" +#include "table.h" #include "writer.h" static int stack_try_add(struct reftable_stack *st, @@ -203,14 +203,14 @@ int reftable_stack_init_ref_iterator(struct reftable_stack *st, struct reftable_iterator *it) { return merged_table_init_iter(reftable_stack_merged_table(st), - it, BLOCK_TYPE_REF); + it, REFTABLE_BLOCK_TYPE_REF); } int reftable_stack_init_log_iterator(struct reftable_stack *st, struct reftable_iterator *it) { return merged_table_init_iter(reftable_stack_merged_table(st), - it, BLOCK_TYPE_LOG); + it, REFTABLE_BLOCK_TYPE_LOG); } struct reftable_merged_table * @@ -248,11 +248,11 @@ void reftable_stack_destroy(struct reftable_stack *st) REFTABLE_FREE_AND_NULL(names); } - if (st->readers) { + if (st->tables) { struct reftable_buf filename = REFTABLE_BUF_INIT; - for (size_t i = 0; i < st->readers_len; i++) { - const char *name = reader_name(st->readers[i]); + for (size_t i = 0; i < st->tables_len; i++) { + const char *name = reftable_table_name(st->tables[i]); int try_unlinking = 1; reftable_buf_reset(&filename); @@ -260,7 +260,7 @@ void reftable_stack_destroy(struct reftable_stack *st) if (stack_filename(&filename, st, name) < 0) try_unlinking = 0; } - reftable_reader_decref(st->readers[i]); + reftable_table_decref(st->tables[i]); if (try_unlinking && filename.len) { /* On Windows, can only unlink after closing. */ @@ -269,8 +269,8 @@ void reftable_stack_destroy(struct reftable_stack *st) } reftable_buf_release(&filename); - st->readers_len = 0; - REFTABLE_FREE_AND_NULL(st->readers); + st->tables_len = 0; + REFTABLE_FREE_AND_NULL(st->tables); } if (st->list_fd >= 0) { @@ -284,14 +284,14 @@ void reftable_stack_destroy(struct reftable_stack *st) free_names(names); } -static struct reftable_reader **stack_copy_readers(struct reftable_stack *st, - size_t cur_len) +static struct reftable_table **stack_copy_tables(struct reftable_stack *st, + size_t cur_len) { - struct reftable_reader **cur = reftable_calloc(cur_len, sizeof(*cur)); + struct reftable_table **cur = reftable_calloc(cur_len, sizeof(*cur)); if (!cur) return NULL; for (size_t i = 0; i < cur_len; i++) - cur[i] = st->readers[i]; + cur[i] = st->tables[i]; return cur; } @@ -299,19 +299,19 @@ static int reftable_stack_reload_once(struct reftable_stack *st, const char **names, int reuse_open) { - size_t cur_len = !st->merged ? 0 : st->merged->readers_len; - struct reftable_reader **cur = NULL; - struct reftable_reader **reused = NULL; - struct reftable_reader **new_readers = NULL; + size_t cur_len = !st->merged ? 0 : st->merged->tables_len; + struct reftable_table **cur = NULL; + struct reftable_table **reused = NULL; + struct reftable_table **new_tables = NULL; size_t reused_len = 0, reused_alloc = 0, names_len; - size_t new_readers_len = 0; + size_t new_tables_len = 0; struct reftable_merged_table *new_merged = NULL; struct reftable_buf table_path = REFTABLE_BUF_INIT; int err = 0; size_t i; if (cur_len) { - cur = stack_copy_readers(st, cur_len); + cur = stack_copy_tables(st, cur_len); if (!cur) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; @@ -321,28 +321,28 @@ static int reftable_stack_reload_once(struct reftable_stack *st, names_len = names_length(names); if (names_len) { - new_readers = reftable_calloc(names_len, sizeof(*new_readers)); - if (!new_readers) { + new_tables = reftable_calloc(names_len, sizeof(*new_tables)); + if (!new_tables) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } } while (*names) { - struct reftable_reader *rd = NULL; + struct reftable_table *table = NULL; const char *name = *names++; /* this is linear; we assume compaction keeps the number of tables under control so this is not quadratic. */ for (i = 0; reuse_open && i < cur_len; i++) { if (cur[i] && 0 == strcmp(cur[i]->name, name)) { - rd = cur[i]; + table = cur[i]; cur[i] = NULL; /* * When reloading the stack fails, we end up - * releasing all new readers. This also - * includes the reused readers, even though + * releasing all new tables. This also + * includes the reused tables, even though * they are still in used by the old stack. We * thus need to keep them alive here, which we * do by bumping their refcount. @@ -354,13 +354,13 @@ static int reftable_stack_reload_once(struct reftable_stack *st, err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } - reused[reused_len++] = rd; - reftable_reader_incref(rd); + reused[reused_len++] = table; + reftable_table_incref(table); break; } } - if (!rd) { + if (!table) { struct reftable_block_source src = { NULL }; err = stack_filename(&table_path, st, name); @@ -372,36 +372,36 @@ static int reftable_stack_reload_once(struct reftable_stack *st, if (err < 0) goto done; - err = reftable_reader_new(&rd, &src, name); + err = reftable_table_new(&table, &src, name); if (err < 0) goto done; } - new_readers[new_readers_len] = rd; - new_readers_len++; + new_tables[new_tables_len] = table; + new_tables_len++; } /* success! */ - err = reftable_merged_table_new(&new_merged, new_readers, - new_readers_len, st->opts.hash_id); + err = reftable_merged_table_new(&new_merged, new_tables, + new_tables_len, st->opts.hash_id); if (err < 0) goto done; /* - * Close the old, non-reused readers and proactively try to unlink + * Close the old, non-reused tables and proactively try to unlink * them. This is done for systems like Windows, where the underlying - * file of such an open reader wouldn't have been possible to be + * file of such an open table wouldn't have been possible to be * unlinked by the compacting process. */ for (i = 0; i < cur_len; i++) { if (cur[i]) { - const char *name = reader_name(cur[i]); + const char *name = reftable_table_name(cur[i]); err = stack_filename(&table_path, st, name); if (err < 0) goto done; - reftable_reader_decref(cur[i]); + reftable_table_decref(cur[i]); unlink(table_path.buf); } } @@ -412,25 +412,25 @@ static int reftable_stack_reload_once(struct reftable_stack *st, new_merged->suppress_deletions = 1; st->merged = new_merged; - if (st->readers) - reftable_free(st->readers); - st->readers = new_readers; - st->readers_len = new_readers_len; - new_readers = NULL; - new_readers_len = 0; + if (st->tables) + reftable_free(st->tables); + st->tables = new_tables; + st->tables_len = new_tables_len; + new_tables = NULL; + new_tables_len = 0; /* - * Decrement the refcount of reused readers again. This only needs to + * Decrement the refcount of reused tables again. This only needs to * happen on the successful case, because on the unsuccessful one we - * decrement their refcount via `new_readers`. + * decrement their refcount via `new_tables`. */ for (i = 0; i < reused_len; i++) - reftable_reader_decref(reused[i]); + reftable_table_decref(reused[i]); done: - for (i = 0; i < new_readers_len; i++) - reftable_reader_decref(new_readers[i]); - reftable_free(new_readers); + for (i = 0; i < new_tables_len; i++) + reftable_table_decref(new_tables[i]); + reftable_free(new_tables); reftable_free(reused); reftable_free(cur); reftable_buf_release(&table_path); @@ -615,10 +615,10 @@ static int stack_uptodate(struct reftable_stack *st) /* * It's fine for "tables.list" to not exist. In that * case, we have to refresh when the loaded stack has - * any readers. + * any tables. */ if (errno == ENOENT) - return !!st->readers_len; + return !!st->tables_len; return REFTABLE_IO_ERROR; } @@ -637,19 +637,19 @@ static int stack_uptodate(struct reftable_stack *st) if (err < 0) return err; - for (size_t i = 0; i < st->readers_len; i++) { + for (size_t i = 0; i < st->tables_len; i++) { if (!names[i]) { err = 1; goto done; } - if (strcmp(st->readers[i]->name, names[i])) { + if (strcmp(st->tables[i]->name, names[i])) { err = 1; goto done; } } - if (names[st->merged->readers_len]) { + if (names[st->merged->tables_len]) { err = 1; goto done; } @@ -792,8 +792,8 @@ int reftable_addition_commit(struct reftable_addition *add) if (add->new_tables_len == 0) goto done; - for (i = 0; i < add->stack->merged->readers_len; i++) { - if ((err = reftable_buf_addstr(&table_list, add->stack->readers[i]->name)) < 0 || + for (i = 0; i < add->stack->merged->tables_len; i++) { + if ((err = reftable_buf_addstr(&table_list, add->stack->tables[i]->name)) < 0 || (err = reftable_buf_addstr(&table_list, "\n")) < 0) goto done; } @@ -1000,9 +1000,9 @@ done: uint64_t reftable_stack_next_update_index(struct reftable_stack *st) { - int sz = st->merged->readers_len; + int sz = st->merged->tables_len; if (sz > 0) - return reftable_reader_max_update_index(st->readers[sz - 1]) + + return reftable_table_max_update_index(st->tables[sz - 1]) + 1; return 1; } @@ -1021,8 +1021,8 @@ static int stack_compact_locked(struct reftable_stack *st, struct reftable_tmpfile tab_file = REFTABLE_TMPFILE_INIT; int err = 0; - err = format_name(&next_name, reftable_reader_min_update_index(st->readers[first]), - reftable_reader_max_update_index(st->readers[last])); + err = format_name(&next_name, reftable_table_min_update_index(st->tables[first]), + reftable_table_max_update_index(st->tables[last])); if (err < 0) goto done; @@ -1087,18 +1087,18 @@ static int stack_write_compact(struct reftable_stack *st, int err = 0; for (size_t i = first; i <= last; i++) - st->stats.bytes += st->readers[i]->size; - err = reftable_writer_set_limits(wr, st->readers[first]->min_update_index, - st->readers[last]->max_update_index); + st->stats.bytes += st->tables[i]->size; + err = reftable_writer_set_limits(wr, st->tables[first]->min_update_index, + st->tables[last]->max_update_index); if (err < 0) goto done; - err = reftable_merged_table_new(&mt, st->readers + first, subtabs_len, + err = reftable_merged_table_new(&mt, st->tables + first, subtabs_len, st->opts.hash_id); if (err < 0) goto done; - err = merged_table_init_iter(mt, &it, BLOCK_TYPE_REF); + err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF); if (err < 0) goto done; @@ -1126,7 +1126,7 @@ static int stack_write_compact(struct reftable_stack *st, } reftable_iterator_destroy(&it); - err = merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG); + err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_LOG); if (err < 0) goto done; @@ -1250,7 +1250,7 @@ static int stack_compact_range(struct reftable_stack *st, table_locks[i] = REFTABLE_FLOCK_INIT; for (i = last + 1; i > first; i--) { - err = stack_filename(&table_name, st, reader_name(st->readers[i - 1])); + err = stack_filename(&table_name, st, reftable_table_name(st->tables[i - 1])); if (err < 0) goto done; @@ -1376,7 +1376,7 @@ static int stack_compact_range(struct reftable_stack *st, * compacted in the updated "tables.list" file. */ for (size_t i = 0; names[i]; i++) { - if (strcmp(names[i], st->readers[first]->name)) + if (strcmp(names[i], st->tables[first]->name)) continue; /* @@ -1386,8 +1386,8 @@ static int stack_compact_range(struct reftable_stack *st, * have compacted them. */ for (size_t j = 1; j < last - first + 1; j++) { - const char *old = first + j < st->merged->readers_len ? - st->readers[first + j]->name : NULL; + const char *old = first + j < st->merged->tables_len ? + st->tables[first + j]->name : NULL; const char *new = names[i + j]; /* @@ -1427,16 +1427,16 @@ static int stack_compact_range(struct reftable_stack *st, * `fd_read_lines()` uses a `NULL` sentinel to indicate that * the array is at its end. As we use `free_names()` to free * the array, we need to include this sentinel value here and - * thus have to allocate `readers_len + 1` many entries. + * thus have to allocate `tables_len + 1` many entries. */ - REFTABLE_CALLOC_ARRAY(names, st->merged->readers_len + 1); + REFTABLE_CALLOC_ARRAY(names, st->merged->tables_len + 1); if (!names) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } - for (size_t i = 0; i < st->merged->readers_len; i++) { - names[i] = reftable_strdup(st->readers[i]->name); + for (size_t i = 0; i < st->merged->tables_len; i++) { + names[i] = reftable_strdup(st->tables[i]->name); if (!names[i]) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; @@ -1451,8 +1451,8 @@ static int stack_compact_range(struct reftable_stack *st, * it into place now. */ if (!is_empty_table) { - err = format_name(&new_table_name, st->readers[first]->min_update_index, - st->readers[last]->max_update_index); + err = format_name(&new_table_name, st->tables[first]->min_update_index, + st->tables[last]->max_update_index); if (err < 0) goto done; @@ -1559,7 +1559,7 @@ done: int reftable_stack_compact_all(struct reftable_stack *st, struct reftable_log_expiry_config *config) { - size_t last = st->merged->readers_len ? st->merged->readers_len - 1 : 0; + size_t last = st->merged->tables_len ? st->merged->tables_len - 1 : 0; return stack_compact_range(st, 0, last, config, 0); } @@ -1650,12 +1650,12 @@ static uint64_t *stack_table_sizes_for_compaction(struct reftable_stack *st) int overhead = header_size(version) - 1; uint64_t *sizes; - REFTABLE_CALLOC_ARRAY(sizes, st->merged->readers_len); + REFTABLE_CALLOC_ARRAY(sizes, st->merged->tables_len); if (!sizes) return NULL; - for (size_t i = 0; i < st->merged->readers_len; i++) - sizes[i] = st->readers[i]->size - overhead; + for (size_t i = 0; i < st->merged->tables_len; i++) + sizes[i] = st->tables[i]->size - overhead; return sizes; } @@ -1665,14 +1665,14 @@ int reftable_stack_auto_compact(struct reftable_stack *st) struct segment seg; uint64_t *sizes; - if (st->merged->readers_len < 2) + if (st->merged->tables_len < 2) return 0; sizes = stack_table_sizes_for_compaction(st); if (!sizes) return REFTABLE_OUT_OF_MEMORY_ERROR; - seg = suggest_compaction_segment(sizes, st->merged->readers_len, + seg = suggest_compaction_segment(sizes, st->merged->tables_len, st->opts.auto_compaction_factor); reftable_free(sizes); @@ -1763,7 +1763,7 @@ static void remove_maybe_stale_table(struct reftable_stack *st, uint64_t max, int err = 0; uint64_t update_idx = 0; struct reftable_block_source src = { NULL }; - struct reftable_reader *rd = NULL; + struct reftable_table *table = NULL; struct reftable_buf table_path = REFTABLE_BUF_INIT; err = stack_filename(&table_path, st, name); @@ -1774,12 +1774,12 @@ static void remove_maybe_stale_table(struct reftable_stack *st, uint64_t max, if (err < 0) goto done; - err = reftable_reader_new(&rd, &src, name); + err = reftable_table_new(&table, &src, name); if (err < 0) goto done; - update_idx = reftable_reader_max_update_index(rd); - reftable_reader_decref(rd); + update_idx = reftable_table_max_update_index(table); + reftable_table_decref(table); if (update_idx <= max) { unlink(table_path.buf); @@ -1803,8 +1803,8 @@ static int reftable_stack_clean_locked(struct reftable_stack *st) if (!is_table_name(d->d_name)) continue; - for (size_t i = 0; !found && i < st->readers_len; i++) - found = !strcmp(reader_name(st->readers[i]), d->d_name); + for (size_t i = 0; !found && i < st->tables_len; i++) + found = !strcmp(reftable_table_name(st->tables[i]), d->d_name); if (found) continue; diff --git a/reftable/stack.h b/reftable/stack.h index 5b45cff4f7..bc28f2998a 100644 --- a/reftable/stack.h +++ b/reftable/stack.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef STACK_H #define STACK_H @@ -22,8 +22,8 @@ struct reftable_stack { struct reftable_write_options opts; - struct reftable_reader **readers; - size_t readers_len; + struct reftable_table **tables; + size_t tables_len; struct reftable_merged_table *merged; struct reftable_compaction_stats stats; }; diff --git a/reftable/system.h b/reftable/system.h index 072d9daea0..beb9d2431f 100644 --- a/reftable/system.h +++ b/reftable/system.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef SYSTEM_H #define SYSTEM_H diff --git a/reftable/reader.c b/reftable/table.c index 172aff2c10..ee83127615 100644 --- a/reftable/reader.c +++ b/reftable/table.c @@ -1,86 +1,46 @@ /* -Copyright 2020 Google LLC + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ - -#include "reader.h" +#include "table.h" #include "system.h" #include "block.h" +#include "blocksource.h" #include "constants.h" #include "iter.h" #include "record.h" #include "reftable-error.h" -uint64_t block_source_size(struct reftable_block_source *source) -{ - return source->ops->size(source->arg); -} - -ssize_t block_source_read_block(struct reftable_block_source *source, - struct reftable_block *dest, uint64_t off, - uint32_t size) -{ - ssize_t result = source->ops->read_block(source->arg, dest, off, size); - dest->source = *source; - return result; -} - -void block_source_close(struct reftable_block_source *source) -{ - if (!source->ops) { - return; - } - - source->ops->close(source->arg); - source->ops = NULL; -} - -static struct reftable_reader_offsets * -reader_offsets_for(struct reftable_reader *r, uint8_t typ) +static struct reftable_table_offsets * +table_offsets_for(struct reftable_table *t, uint8_t typ) { switch (typ) { - case BLOCK_TYPE_REF: - return &r->ref_offsets; - case BLOCK_TYPE_LOG: - return &r->log_offsets; - case BLOCK_TYPE_OBJ: - return &r->obj_offsets; + case REFTABLE_BLOCK_TYPE_REF: + return &t->ref_offsets; + case REFTABLE_BLOCK_TYPE_LOG: + return &t->log_offsets; + case REFTABLE_BLOCK_TYPE_OBJ: + return &t->obj_offsets; } abort(); } -static int reader_get_block(struct reftable_reader *r, - struct reftable_block *dest, uint64_t off, - uint32_t sz) +enum reftable_hash reftable_table_hash_id(struct reftable_table *t) { - ssize_t bytes_read; - if (off >= r->size) - return 0; - if (off + sz > r->size) - sz = r->size - off; - - bytes_read = block_source_read_block(&r->source, dest, off, sz); - if (bytes_read < 0) - return (int)bytes_read; - - return 0; + return t->hash_id; } -enum reftable_hash reftable_reader_hash_id(struct reftable_reader *r) +const char *reftable_table_name(struct reftable_table *t) { - return r->hash_id; + return t->name; } -const char *reader_name(struct reftable_reader *r) -{ - return r->name; -} - -static int parse_footer(struct reftable_reader *r, uint8_t *footer, +static int parse_footer(struct reftable_table *t, uint8_t *footer, uint8_t *header) { uint8_t *f = footer; @@ -95,29 +55,29 @@ static int parse_footer(struct reftable_reader *r, uint8_t *footer, } f += 4; - if (memcmp(footer, header, header_size(r->version))) { + if (memcmp(footer, header, header_size(t->version))) { err = REFTABLE_FORMAT_ERROR; goto done; } f++; - r->block_size = reftable_get_be24(f); + t->block_size = reftable_get_be24(f); f += 3; - r->min_update_index = reftable_get_be64(f); + t->min_update_index = reftable_get_be64(f); f += 8; - r->max_update_index = reftable_get_be64(f); + t->max_update_index = reftable_get_be64(f); f += 8; - if (r->version == 1) { - r->hash_id = REFTABLE_HASH_SHA1; + if (t->version == 1) { + t->hash_id = REFTABLE_HASH_SHA1; } else { switch (reftable_get_be32(f)) { case REFTABLE_FORMAT_ID_SHA1: - r->hash_id = REFTABLE_HASH_SHA1; + t->hash_id = REFTABLE_HASH_SHA1; break; case REFTABLE_FORMAT_ID_SHA256: - r->hash_id = REFTABLE_HASH_SHA256; + t->hash_id = REFTABLE_HASH_SHA256; break; default: err = REFTABLE_FORMAT_ERROR; @@ -127,20 +87,20 @@ static int parse_footer(struct reftable_reader *r, uint8_t *footer, f += 4; } - r->ref_offsets.index_offset = reftable_get_be64(f); + t->ref_offsets.index_offset = reftable_get_be64(f); f += 8; - r->obj_offsets.offset = reftable_get_be64(f); + t->obj_offsets.offset = reftable_get_be64(f); f += 8; - r->object_id_len = r->obj_offsets.offset & ((1 << 5) - 1); - r->obj_offsets.offset >>= 5; + t->object_id_len = t->obj_offsets.offset & ((1 << 5) - 1); + t->obj_offsets.offset >>= 5; - r->obj_offsets.index_offset = reftable_get_be64(f); + t->obj_offsets.index_offset = reftable_get_be64(f); f += 8; - r->log_offsets.offset = reftable_get_be64(f); + t->log_offsets.offset = reftable_get_be64(f); f += 8; - r->log_offsets.index_offset = reftable_get_be64(f); + t->log_offsets.index_offset = reftable_get_be64(f); f += 8; computed_crc = crc32(0, footer, f - footer); @@ -151,13 +111,13 @@ static int parse_footer(struct reftable_reader *r, uint8_t *footer, goto done; } - first_block_typ = header[header_size(r->version)]; - r->ref_offsets.is_present = (first_block_typ == BLOCK_TYPE_REF); - r->ref_offsets.offset = 0; - r->log_offsets.is_present = (first_block_typ == BLOCK_TYPE_LOG || - r->log_offsets.offset > 0); - r->obj_offsets.is_present = r->obj_offsets.offset > 0; - if (r->obj_offsets.is_present && !r->object_id_len) { + first_block_typ = header[header_size(t->version)]; + t->ref_offsets.is_present = (first_block_typ == REFTABLE_BLOCK_TYPE_REF); + t->ref_offsets.offset = 0; + t->log_offsets.is_present = (first_block_typ == REFTABLE_BLOCK_TYPE_LOG || + t->log_offsets.offset > 0); + t->obj_offsets.is_present = t->obj_offsets.offset > 0; + if (t->obj_offsets.is_present && !t->object_id_len) { err = REFTABLE_FORMAT_ERROR; goto done; } @@ -168,20 +128,20 @@ done: } struct table_iter { - struct reftable_reader *r; + struct reftable_table *table; uint8_t typ; uint64_t block_off; - struct block_reader br; + struct reftable_block block; struct block_iter bi; int is_finished; }; -static int table_iter_init(struct table_iter *ti, struct reftable_reader *r) +static int table_iter_init(struct table_iter *ti, struct reftable_table *t) { struct block_iter bi = BLOCK_ITER_INIT; memset(ti, 0, sizeof(*ti)); - reftable_reader_incref(r); - ti->r = r; + reftable_table_incref(t); + ti->table = t; ti->bi = bi; return 0; } @@ -190,8 +150,8 @@ static int table_iter_next_in_block(struct table_iter *ti, struct reftable_record *rec) { int res = block_iter_next(&ti->bi, rec); - if (res == 0 && reftable_record_type(rec) == BLOCK_TYPE_REF) { - rec->u.ref.update_index += ti->r->min_update_index; + if (res == 0 && reftable_record_type(rec) == REFTABLE_BLOCK_TYPE_REF) { + rec->u.ref.update_index += ti->table->min_update_index; } return res; @@ -199,68 +159,32 @@ static int table_iter_next_in_block(struct table_iter *ti, static void table_iter_block_done(struct table_iter *ti) { - block_reader_release(&ti->br); + reftable_block_release(&ti->block); block_iter_reset(&ti->bi); } -static int32_t extract_block_size(uint8_t *data, uint8_t *typ, uint64_t off, - int version) -{ - int32_t result = 0; - - if (off == 0) { - data += header_size(version); - } - - *typ = data[0]; - if (reftable_is_block_type(*typ)) { - result = reftable_get_be24(data + 1); - } - return result; -} - -int reader_init_block_reader(struct reftable_reader *r, struct block_reader *br, - uint64_t next_off, uint8_t want_typ) +int table_init_block(struct reftable_table *t, struct reftable_block *block, + uint64_t next_off, uint8_t want_typ) { - int32_t guess_block_size = r->block_size ? r->block_size : - DEFAULT_BLOCK_SIZE; - struct reftable_block block = { NULL }; - uint8_t block_typ = 0; - int err = 0; - uint32_t header_off = next_off ? 0 : header_size(r->version); - int32_t block_size = 0; + uint32_t header_off = next_off ? 0 : header_size(t->version); + int err; - if (next_off >= r->size) + if (next_off >= t->size) return 1; - err = reader_get_block(r, &block, next_off, guess_block_size); + err = reftable_block_init(block, &t->source, next_off, header_off, + t->block_size, hash_size(t->hash_id)); if (err < 0) goto done; - block_size = extract_block_size(block.data, &block_typ, next_off, - r->version); - if (block_size < 0) { - err = block_size; - goto done; - } - if (want_typ != BLOCK_TYPE_ANY && block_typ != want_typ) { + if (want_typ != REFTABLE_BLOCK_TYPE_ANY && block->block_type != want_typ) { err = 1; goto done; } - if (block_size > guess_block_size) { - reftable_block_done(&block); - err = reader_get_block(r, &block, next_off, block_size); - if (err < 0) { - goto done; - } - } - - err = block_reader_init(br, &block, header_off, r->block_size, - hash_size(r->hash_id)); done: - reftable_block_done(&block); - + if (err) + reftable_block_release(block); return err; } @@ -268,15 +192,15 @@ static void table_iter_close(struct table_iter *ti) { table_iter_block_done(ti); block_iter_close(&ti->bi); - reftable_reader_decref(ti->r); + reftable_table_decref(ti->table); } static int table_iter_next_block(struct table_iter *ti) { - uint64_t next_block_off = ti->block_off + ti->br.full_block_size; + uint64_t next_block_off = ti->block_off + ti->block.full_block_size; int err; - err = reader_init_block_reader(ti->r, &ti->br, next_block_off, ti->typ); + err = table_init_block(ti->table, &ti->block, next_block_off, ti->typ); if (err > 0) ti->is_finished = 1; if (err) @@ -284,7 +208,7 @@ static int table_iter_next_block(struct table_iter *ti) ti->block_off = next_block_off; ti->is_finished = 0; - block_iter_seek_start(&ti->bi, &ti->br); + block_iter_init(&ti->bi, &ti->block); return 0; } @@ -326,27 +250,27 @@ static int table_iter_seek_to(struct table_iter *ti, uint64_t off, uint8_t typ) { int err; - err = reader_init_block_reader(ti->r, &ti->br, off, typ); + err = table_init_block(ti->table, &ti->block, off, typ); if (err != 0) return err; - ti->typ = block_reader_type(&ti->br); + ti->typ = reftable_block_type(&ti->block); ti->block_off = off; - block_iter_seek_start(&ti->bi, &ti->br); + block_iter_init(&ti->bi, &ti->block); ti->is_finished = 0; return 0; } static int table_iter_seek_start(struct table_iter *ti, uint8_t typ, int index) { - struct reftable_reader_offsets *offs = reader_offsets_for(ti->r, typ); + struct reftable_table_offsets *offs = table_offsets_for(ti->table, typ); uint64_t off = offs->offset; if (index) { off = offs->index_offset; if (off == 0) { return 1; } - typ = BLOCK_TYPE_INDEX; + typ = REFTABLE_BLOCK_TYPE_INDEX; } return table_iter_seek_to(ti, off, typ); @@ -396,10 +320,10 @@ static int table_iter_seek_linear(struct table_iter *ti, * as we have more than three blocks we would have an index, so * we would not do a linear search there anymore. */ - memset(&next.br.block, 0, sizeof(next.br.block)); - next.br.zstream = NULL; - next.br.uncompressed_data = NULL; - next.br.uncompressed_cap = 0; + memset(&next.block.block_data, 0, sizeof(next.block.block_data)); + next.block.zstream = NULL; + next.block.uncompressed_data = NULL; + next.block.uncompressed_cap = 0; err = table_iter_next_block(&next); if (err < 0) @@ -407,7 +331,7 @@ static int table_iter_seek_linear(struct table_iter *ti, if (err > 0) break; - err = block_reader_first_key(&next.br, &got_key); + err = reftable_block_first_key(&next.block, &got_key); if (err < 0) goto done; @@ -425,7 +349,8 @@ static int table_iter_seek_linear(struct table_iter *ti, * the wanted key inside of it. If the block does not contain our key * we know that the corresponding record does not exist. */ - err = block_iter_seek_key(&ti->bi, &ti->br, &want_key); + block_iter_init(&ti->bi, &ti->block); + err = block_iter_seek_key(&ti->bi, &want_key); if (err < 0) goto done; err = 0; @@ -441,10 +366,10 @@ static int table_iter_seek_indexed(struct table_iter *ti, struct reftable_record *rec) { struct reftable_record want_index = { - .type = BLOCK_TYPE_INDEX, .u.idx = { .last_key = REFTABLE_BUF_INIT } + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx = { .last_key = REFTABLE_BUF_INIT } }; struct reftable_record index_result = { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx = { .last_key = REFTABLE_BUF_INIT }, }; int err; @@ -493,7 +418,9 @@ static int table_iter_seek_indexed(struct table_iter *ti, if (err != 0) goto done; - err = block_iter_seek_key(&ti->bi, &ti->br, &want_index.u.idx.last_key); + block_iter_init(&ti->bi, &ti->block); + + err = block_iter_seek_key(&ti->bi, &want_index.u.idx.last_key); if (err < 0) goto done; @@ -502,7 +429,7 @@ static int table_iter_seek_indexed(struct table_iter *ti, break; } - if (ti->typ != BLOCK_TYPE_INDEX) { + if (ti->typ != REFTABLE_BLOCK_TYPE_INDEX) { err = REFTABLE_FORMAT_ERROR; goto done; } @@ -518,7 +445,7 @@ static int table_iter_seek(struct table_iter *ti, struct reftable_record *want) { uint8_t typ = reftable_record_type(want); - struct reftable_reader_offsets *offs = reader_offsets_for(ti->r, typ); + struct reftable_table_offsets *offs = table_offsets_for(ti->table, typ); int err; err = table_iter_seek_start(ti, reftable_record_type(want), @@ -566,11 +493,11 @@ static void iterator_from_table_iter(struct reftable_iterator *it, it->ops = &table_iter_vtable; } -int reader_init_iter(struct reftable_reader *r, - struct reftable_iterator *it, - uint8_t typ) +int table_init_iter(struct reftable_table *t, + struct reftable_iterator *it, + uint8_t typ) { - struct reftable_reader_offsets *offs = reader_offsets_for(r, typ); + struct reftable_table_offsets *offs = table_offsets_for(t, typ); if (offs->is_present) { struct table_iter *ti; @@ -578,7 +505,7 @@ int reader_init_iter(struct reftable_reader *r, if (!ti) return REFTABLE_OUT_OF_MEMORY_ERROR; - table_iter_init(ti, r); + table_iter_init(ti, t); iterator_from_table_iter(it, ti); } else { iterator_set_empty(it); @@ -587,31 +514,31 @@ int reader_init_iter(struct reftable_reader *r, return 0; } -int reftable_reader_init_ref_iterator(struct reftable_reader *r, - struct reftable_iterator *it) +int reftable_table_init_ref_iterator(struct reftable_table *t, + struct reftable_iterator *it) { - return reader_init_iter(r, it, BLOCK_TYPE_REF); + return table_init_iter(t, it, REFTABLE_BLOCK_TYPE_REF); } -int reftable_reader_init_log_iterator(struct reftable_reader *r, - struct reftable_iterator *it) +int reftable_table_init_log_iterator(struct reftable_table *t, + struct reftable_iterator *it) { - return reader_init_iter(r, it, BLOCK_TYPE_LOG); + return table_init_iter(t, it, REFTABLE_BLOCK_TYPE_LOG); } -int reftable_reader_new(struct reftable_reader **out, - struct reftable_block_source *source, char const *name) +int reftable_table_new(struct reftable_table **out, + struct reftable_block_source *source, char const *name) { - struct reftable_block footer = { 0 }; - struct reftable_block header = { 0 }; - struct reftable_reader *r; + struct reftable_block_data footer = { 0 }; + struct reftable_block_data header = { 0 }; + struct reftable_table *t; uint64_t file_size = block_source_size(source); uint32_t read_size; ssize_t bytes_read; int err; - REFTABLE_CALLOC_ARRAY(r, 1); - if (!r) { + REFTABLE_CALLOC_ARRAY(t, 1); + if (!t) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } @@ -626,7 +553,7 @@ int reftable_reader_new(struct reftable_reader **out, goto done; } - bytes_read = block_source_read_block(source, &header, 0, read_size); + bytes_read = block_source_read_data(source, &header, 0, read_size); if (bytes_read < 0 || (size_t)bytes_read != read_size) { err = REFTABLE_IO_ERROR; goto done; @@ -636,84 +563,84 @@ int reftable_reader_new(struct reftable_reader **out, err = REFTABLE_FORMAT_ERROR; goto done; } - r->version = header.data[4]; - if (r->version != 1 && r->version != 2) { + t->version = header.data[4]; + if (t->version != 1 && t->version != 2) { err = REFTABLE_FORMAT_ERROR; goto done; } - r->size = file_size - footer_size(r->version); - r->source = *source; - r->name = reftable_strdup(name); - if (!r->name) { + t->size = file_size - footer_size(t->version); + t->source = *source; + t->name = reftable_strdup(name); + if (!t->name) { err = REFTABLE_OUT_OF_MEMORY_ERROR; goto done; } - r->hash_id = 0; - r->refcount = 1; + t->hash_id = 0; + t->refcount = 1; - bytes_read = block_source_read_block(source, &footer, r->size, - footer_size(r->version)); - if (bytes_read < 0 || (size_t)bytes_read != footer_size(r->version)) { + bytes_read = block_source_read_data(source, &footer, t->size, + footer_size(t->version)); + if (bytes_read < 0 || (size_t)bytes_read != footer_size(t->version)) { err = REFTABLE_IO_ERROR; goto done; } - err = parse_footer(r, footer.data, header.data); + err = parse_footer(t, footer.data, header.data); if (err) goto done; - *out = r; + *out = t; done: - reftable_block_done(&footer); - reftable_block_done(&header); + block_source_release_data(&footer); + block_source_release_data(&header); if (err) { - if (r) - reftable_free(r->name); - reftable_free(r); + if (t) + reftable_free(t->name); + reftable_free(t); block_source_close(source); } return err; } -void reftable_reader_incref(struct reftable_reader *r) +void reftable_table_incref(struct reftable_table *t) { - r->refcount++; + t->refcount++; } -void reftable_reader_decref(struct reftable_reader *r) +void reftable_table_decref(struct reftable_table *t) { - if (!r) + if (!t) return; - if (--r->refcount) + if (--t->refcount) return; - block_source_close(&r->source); - REFTABLE_FREE_AND_NULL(r->name); - reftable_free(r); + block_source_close(&t->source); + REFTABLE_FREE_AND_NULL(t->name); + reftable_free(t); } -static int reftable_reader_refs_for_indexed(struct reftable_reader *r, - struct reftable_iterator *it, - uint8_t *oid) +static int reftable_table_refs_for_indexed(struct reftable_table *t, + struct reftable_iterator *it, + uint8_t *oid) { struct reftable_record want = { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .u.obj = { .hash_prefix = oid, - .hash_prefix_len = r->object_id_len, + .hash_prefix_len = t->object_id_len, }, }; struct reftable_iterator oit = { NULL }; struct reftable_record got = { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .u.obj = { 0 }, }; int err = 0; struct indexed_table_ref_iter *itr = NULL; /* Look through the reverse index. */ - err = reader_init_iter(r, &oit, BLOCK_TYPE_OBJ); + err = table_init_iter(t, &oit, REFTABLE_BLOCK_TYPE_OBJ); if (err < 0) goto done; @@ -727,14 +654,14 @@ static int reftable_reader_refs_for_indexed(struct reftable_reader *r, goto done; if (err > 0 || memcmp(want.u.obj.hash_prefix, got.u.obj.hash_prefix, - r->object_id_len)) { + t->object_id_len)) { /* didn't find it; return empty iterator */ iterator_set_empty(it); err = 0; goto done; } - err = indexed_table_ref_iter_new(&itr, r, oid, hash_size(r->hash_id), + err = indexed_table_ref_iter_new(&itr, t, oid, hash_size(t->hash_id), got.u.obj.offsets, got.u.obj.offset_len); if (err < 0) @@ -748,14 +675,14 @@ done: return err; } -static int reftable_reader_refs_for_unindexed(struct reftable_reader *r, - struct reftable_iterator *it, - uint8_t *oid) +static int reftable_table_refs_for_unindexed(struct reftable_table *t, + struct reftable_iterator *it, + uint8_t *oid) { struct table_iter *ti; struct filtering_ref_iterator *filter = NULL; struct filtering_ref_iterator empty = FILTERING_REF_ITERATOR_INIT; - uint32_t oid_len = hash_size(r->hash_id); + uint32_t oid_len = hash_size(t->hash_id); int err; REFTABLE_ALLOC_ARRAY(ti, 1); @@ -764,8 +691,8 @@ static int reftable_reader_refs_for_unindexed(struct reftable_reader *r, goto out; } - table_iter_init(ti, r); - err = table_iter_seek_start(ti, BLOCK_TYPE_REF, 0); + table_iter_init(ti, t); + err = table_iter_seek_start(ti, REFTABLE_BLOCK_TYPE_REF, 0); if (err < 0) goto out; @@ -795,85 +722,67 @@ out: return err; } -int reftable_reader_refs_for(struct reftable_reader *r, - struct reftable_iterator *it, uint8_t *oid) +int reftable_table_refs_for(struct reftable_table *t, + struct reftable_iterator *it, uint8_t *oid) { - if (r->obj_offsets.is_present) - return reftable_reader_refs_for_indexed(r, it, oid); - return reftable_reader_refs_for_unindexed(r, it, oid); + if (t->obj_offsets.is_present) + return reftable_table_refs_for_indexed(t, it, oid); + return reftable_table_refs_for_unindexed(t, it, oid); } -uint64_t reftable_reader_max_update_index(struct reftable_reader *r) +uint64_t reftable_table_max_update_index(struct reftable_table *t) { - return r->max_update_index; + return t->max_update_index; } -uint64_t reftable_reader_min_update_index(struct reftable_reader *r) +uint64_t reftable_table_min_update_index(struct reftable_table *t) { - return r->min_update_index; + return t->min_update_index; } -int reftable_reader_print_blocks(const char *tablename) +int reftable_table_iterator_init(struct reftable_table_iterator *it, + struct reftable_table *t) { - struct { - const char *name; - int type; - } sections[] = { - { - .name = "ref", - .type = BLOCK_TYPE_REF, - }, - { - .name = "obj", - .type = BLOCK_TYPE_OBJ, - }, - { - .name = "log", - .type = BLOCK_TYPE_LOG, - }, - }; - struct reftable_block_source src = { 0 }; - struct reftable_reader *r = NULL; - struct table_iter ti = { 0 }; - size_t i; + struct table_iter *ti; int err; - err = reftable_block_source_from_file(&src, tablename); - if (err < 0) - goto done; + REFTABLE_ALLOC_ARRAY(ti, 1); + if (!ti) + return REFTABLE_OUT_OF_MEMORY_ERROR; - err = reftable_reader_new(&r, &src, tablename); + err = table_iter_init(ti, t); if (err < 0) - goto done; + goto out; - table_iter_init(&ti, r); + it->iter_arg = ti; + err = 0; - printf("header:\n"); - printf(" block_size: %d\n", r->block_size); +out: + if (err < 0) + reftable_free(ti); + return err; +} - for (i = 0; i < sizeof(sections) / sizeof(*sections); i++) { - err = table_iter_seek_start(&ti, sections[i].type, 0); - if (err < 0) - goto done; - if (err > 0) - continue; +void reftable_table_iterator_release(struct reftable_table_iterator *it) +{ + if (!it->iter_arg) + return; + table_iter_close(it->iter_arg); + reftable_free(it->iter_arg); + it->iter_arg = NULL; +} - printf("%s:\n", sections[i].name); +int reftable_table_iterator_next(struct reftable_table_iterator *it, + const struct reftable_block **out) +{ + struct table_iter *ti = it->iter_arg; + int err; - while (1) { - printf(" - length: %u\n", ti.br.block_len); - printf(" restarts: %u\n", ti.br.restart_count); + err = table_iter_next_block(ti); + if (err) + return err; - err = table_iter_next_block(&ti); - if (err < 0) - goto done; - if (err > 0) - break; - } - } + *out = &ti->block; -done: - reftable_reader_decref(r); - table_iter_close(&ti); - return err; + return 0; } diff --git a/reftable/table.h b/reftable/table.h new file mode 100644 index 0000000000..c54703e621 --- /dev/null +++ b/reftable/table.h @@ -0,0 +1,29 @@ +/* + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ + +#ifndef TABLE_H +#define TABLE_H + +#include "block.h" +#include "record.h" +#include "reftable-iterator.h" +#include "reftable-table.h" + +const char *reftable_table_name(struct reftable_table *t); + +int table_init_iter(struct reftable_table *t, + struct reftable_iterator *it, + uint8_t typ); + +/* + * Initialize a block by reading from the given table and offset. + */ +int table_init_block(struct reftable_table *t, struct reftable_block *block, + uint64_t next_off, uint8_t want_typ); + +#endif diff --git a/reftable/tree.c b/reftable/tree.c index f4dbe72090..a52f7c0c7d 100644 --- a/reftable/tree.c +++ b/reftable/tree.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "system.h" #include "tree.h" diff --git a/reftable/tree.h b/reftable/tree.h index 9604453b6d..2c9c465299 100644 --- a/reftable/tree.h +++ b/reftable/tree.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef TREE_H #define TREE_H diff --git a/reftable/writer.c b/reftable/writer.c index 075ea8661b..cb16f71be4 100644 --- a/reftable/writer.c +++ b/reftable/writer.c @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #include "writer.h" @@ -172,7 +172,7 @@ int reftable_writer_new(struct reftable_writer **out, wp->write_arg = writer_arg; wp->opts = opts; wp->flush = flush_func; - writer_reinit_block_writer(wp, BLOCK_TYPE_REF); + writer_reinit_block_writer(wp, REFTABLE_BLOCK_TYPE_REF); *out = wp; @@ -342,7 +342,7 @@ int reftable_writer_add_ref(struct reftable_writer *w, struct reftable_ref_record *ref) { struct reftable_record rec = { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u = { .ref = *ref }, @@ -406,13 +406,13 @@ static int reftable_writer_add_log_verbatim(struct reftable_writer *w, struct reftable_log_record *log) { struct reftable_record rec = { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u = { .log = *log, }, }; if (w->block_writer && - block_writer_type(w->block_writer) == BLOCK_TYPE_REF) { + block_writer_type(w->block_writer) == REFTABLE_BLOCK_TYPE_REF) { int err = writer_finish_public_section(w); if (err < 0) return err; @@ -532,7 +532,7 @@ static int writer_finish_section(struct reftable_writer *w) max_level++; index_start = w->next; - err = writer_reinit_block_writer(w, BLOCK_TYPE_INDEX); + err = writer_reinit_block_writer(w, REFTABLE_BLOCK_TYPE_INDEX); if (err < 0) return err; @@ -544,7 +544,7 @@ static int writer_finish_section(struct reftable_writer *w) w->index_cap = 0; for (i = 0; i < idx_len; i++) { struct reftable_record rec = { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u = { .idx = idx[i], }, @@ -609,7 +609,7 @@ static void write_object_record(void *void_arg, void *key) struct write_record_arg *arg = void_arg; struct obj_index_tree_node *entry = key; struct reftable_record - rec = { .type = BLOCK_TYPE_OBJ, + rec = { .type = REFTABLE_BLOCK_TYPE_OBJ, .u.obj = { .hash_prefix = (uint8_t *)entry->hash.buf, .hash_prefix_len = arg->w->stats.object_id_len, @@ -639,7 +639,7 @@ static void write_object_record(void *void_arg, void *key) if (arg->err < 0) goto done; - arg->err = writer_reinit_block_writer(arg->w, BLOCK_TYPE_OBJ); + arg->err = writer_reinit_block_writer(arg->w, REFTABLE_BLOCK_TYPE_OBJ); if (arg->err < 0) goto done; @@ -684,7 +684,7 @@ static int writer_dump_object_index(struct reftable_writer *w) infix_walk(w->obj_index_tree, &update_common, &common); w->stats.object_id_len = common.max + 1; - err = writer_reinit_block_writer(w, BLOCK_TYPE_OBJ); + err = writer_reinit_block_writer(w, REFTABLE_BLOCK_TYPE_OBJ); if (err < 0) return err; @@ -708,7 +708,7 @@ static int writer_finish_public_section(struct reftable_writer *w) err = writer_finish_section(w); if (err < 0) return err; - if (typ == BLOCK_TYPE_REF && !w->opts.skip_index_objects && + if (typ == REFTABLE_BLOCK_TYPE_REF && !w->opts.skip_index_objects && w->stats.ref_stats.index_blocks > 0) { err = writer_dump_object_index(w); if (err < 0) @@ -813,7 +813,7 @@ static int writer_flush_nonempty_block(struct reftable_writer *w) * By default, all records except for log records are padded to the * block size. */ - if (!w->opts.unpadded && typ != BLOCK_TYPE_LOG) + if (!w->opts.unpadded && typ != REFTABLE_BLOCK_TYPE_LOG) padding = w->opts.block_size - raw_bytes; bstats = writer_reftable_block_stats(w, typ); diff --git a/reftable/writer.h b/reftable/writer.h index 1f4788a430..9f53610b27 100644 --- a/reftable/writer.h +++ b/reftable/writer.h @@ -1,10 +1,10 @@ /* -Copyright 2020 Google LLC - -Use of this source code is governed by a BSD-style -license that can be found in the LICENSE file or at -https://developers.google.com/open-source/licenses/bsd -*/ + * Copyright 2020 Google LLC + * + * Use of this source code is governed by a BSD-style + * license that can be found in the LICENSE file or at + * https://developers.google.com/open-source/licenses/bsd + */ #ifndef WRITER_H #define WRITER_H @@ -1702,7 +1702,7 @@ void set_ref_status_for_push(struct ref *remote_refs, int send_mirror, if (!reject_reason && !ref->deletion && !is_null_oid(&ref->old_oid)) { if (starts_with(ref->name, "refs/tags/")) reject_reason = REF_STATUS_REJECT_ALREADY_EXISTS; - else if (!repo_has_object_file_with_flags(the_repository, &ref->old_oid, OBJECT_INFO_SKIP_FETCH_OBJECT)) + else if (!has_object(the_repository, &ref->old_oid, HAS_OBJECT_RECHECK_PACKED)) reject_reason = REF_STATUS_REJECT_FETCH_FIRST; else if (!lookup_commit_reference_gently(the_repository, &ref->old_oid, 1) || !lookup_commit_reference_gently(the_repository, &ref->new_oid, 1)) diff --git a/revision.h b/revision.h index 21c6a69899..6d369cdad6 100644 --- a/revision.h +++ b/revision.h @@ -292,7 +292,6 @@ struct rev_info { struct string_list *ref_message_ids; int add_signoff; const char *extra_headers; - const char *log_reencode; const char *subject_prefix; int patch_name_max; int no_inline; diff --git a/send-pack.c b/send-pack.c index 5005689cb5..86592ce526 100644 --- a/send-pack.c +++ b/send-pack.c @@ -45,10 +45,7 @@ int option_parse_push_signed(const struct option *opt, static void feed_object(struct repository *r, const struct object_id *oid, FILE *fh, int negative) { - if (negative && - !repo_has_object_file_with_flags(r, oid, - OBJECT_INFO_SKIP_FETCH_OBJECT | - OBJECT_INFO_QUICK)) + if (negative && !has_object(r, oid, 0)) return; if (negative) @@ -310,7 +310,8 @@ static int write_one_shallow(const struct commit_graft *graft, void *cb_data) if (graft->nr_parent != -1) return 0; if (data->flags & QUICK) { - if (!repo_has_object_file(the_repository, &graft->oid)) + if (!has_object(the_repository, &graft->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) return 0; } else if (data->flags & SEEN_ONLY) { struct commit *c = lookup_commit(the_repository, &graft->oid); @@ -476,7 +477,8 @@ void prepare_shallow_info(struct shallow_info *info, struct oid_array *sa) ALLOC_ARRAY(info->ours, sa->nr); ALLOC_ARRAY(info->theirs, sa->nr); for (size_t i = 0; i < sa->nr; i++) { - if (repo_has_object_file(the_repository, sa->oid + i)) { + if (has_object(the_repository, sa->oid + i, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { struct commit_graft *graft; graft = lookup_commit_graft(the_repository, &sa->oid[i]); @@ -513,7 +515,8 @@ void remove_nonexistent_theirs_shallow(struct shallow_info *info) for (i = dst = 0; i < info->nr_theirs; i++) { if (i != dst) info->theirs[dst] = info->theirs[i]; - if (repo_has_object_file(the_repository, oid + info->theirs[i])) + if (has_object(the_repository, oid + info->theirs[i], + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) dst++; } info->nr_theirs = dst; diff --git a/t/helper/meson.build b/t/helper/meson.build index d2cabaa2bc..d4e8b26df8 100644 --- a/t/helper/meson.build +++ b/t/helper/meson.build @@ -36,6 +36,7 @@ test_tool_sources = [ 'test-mktemp.c', 'test-name-hash.c', 'test-online-cpus.c', + 'test-pack-deltas.c', 'test-pack-mtimes.c', 'test-parse-options.c', 'test-parse-pathspec-file.c', diff --git a/t/helper/test-bloom.c b/t/helper/test-bloom.c index 14e075c1a1..9aa2c5a592 100644 --- a/t/helper/test-bloom.c +++ b/t/helper/test-bloom.c @@ -44,7 +44,7 @@ static void get_bloom_filter_for_commit(const struct object_id *commit_oid) print_bloom_filter(filter); } -static const char *bloom_usage = "\n" +static const char *const bloom_usage = "\n" " test-tool bloom get_murmur3 <string>\n" " test-tool bloom get_murmur3_seven_highbit\n" " test-tool bloom generate_filter <string> [<string>...]\n" diff --git a/t/helper/test-date.c b/t/helper/test-date.c index f25512de9a..87d2ad6fca 100644 --- a/t/helper/test-date.c +++ b/t/helper/test-date.c @@ -2,7 +2,7 @@ #include "date.h" #include "trace.h" -static const char *usage_msg = "\n" +static const char *const usage_msg = "\n" " test-tool date relative [time_t]...\n" " test-tool date human [time_t]...\n" " test-tool date show:<format> [time_t]...\n" diff --git a/t/helper/test-find-pack.c b/t/helper/test-find-pack.c index 85a69a4e55..76c2f4eba8 100644 --- a/t/helper/test-find-pack.c +++ b/t/helper/test-find-pack.c @@ -15,7 +15,7 @@ * packfiles containing the object is not <n>. */ -static const char *find_pack_usage[] = { +static const char *const find_pack_usage[] = { "test-tool find-pack [--check-count <n>] <object>", NULL }; diff --git a/t/helper/test-getcwd.c b/t/helper/test-getcwd.c index d680038a78..cd4d424079 100644 --- a/t/helper/test-getcwd.c +++ b/t/helper/test-getcwd.c @@ -2,7 +2,7 @@ #include "git-compat-util.h" #include "parse-options.h" -static const char *getcwd_usage[] = { +static const char *const getcwd_usage[] = { "test-tool getcwd", NULL }; diff --git a/t/helper/test-pack-deltas.c b/t/helper/test-pack-deltas.c new file mode 100644 index 0000000000..4caa024b1e --- /dev/null +++ b/t/helper/test-pack-deltas.c @@ -0,0 +1,148 @@ +#define USE_THE_REPOSITORY_VARIABLE + +#include "test-tool.h" +#include "git-compat-util.h" +#include "delta.h" +#include "git-zlib.h" +#include "hash.h" +#include "hex.h" +#include "pack.h" +#include "pack-objects.h" +#include "parse-options.h" +#include "setup.h" +#include "strbuf.h" +#include "string-list.h" + +static const char *usage_str[] = { + "test-tool pack-deltas --num-objects <num-objects>", + NULL +}; + +static unsigned long do_compress(void **pptr, unsigned long size) +{ + git_zstream stream; + void *in, *out; + unsigned long maxsize; + + git_deflate_init(&stream, 1); + maxsize = git_deflate_bound(&stream, size); + + in = *pptr; + out = xmalloc(maxsize); + *pptr = out; + + stream.next_in = in; + stream.avail_in = size; + stream.next_out = out; + stream.avail_out = maxsize; + while (git_deflate(&stream, Z_FINISH) == Z_OK) + ; /* nothing */ + git_deflate_end(&stream); + + free(in); + return stream.total_out; +} + +static void write_ref_delta(struct hashfile *f, + struct object_id *oid, + struct object_id *base) +{ + unsigned char header[MAX_PACK_OBJECT_HEADER]; + unsigned long size, base_size, delta_size, compressed_size, hdrlen; + enum object_type type; + void *base_buf, *delta_buf; + void *buf = repo_read_object_file(the_repository, + oid, &type, + &size); + + if (!buf) + die("unable to read %s", oid_to_hex(oid)); + + base_buf = repo_read_object_file(the_repository, + base, &type, + &base_size); + + if (!base_buf) + die("unable to read %s", oid_to_hex(base)); + + delta_buf = diff_delta(base_buf, base_size, + buf, size, &delta_size, 0); + + compressed_size = do_compress(&delta_buf, delta_size); + + hdrlen = encode_in_pack_object_header(header, sizeof(header), + OBJ_REF_DELTA, delta_size); + hashwrite(f, header, hdrlen); + hashwrite(f, base->hash, the_repository->hash_algo->rawsz); + hashwrite(f, delta_buf, compressed_size); + + free(buf); + free(base_buf); + free(delta_buf); +} + +int cmd__pack_deltas(int argc, const char **argv) +{ + int num_objects = -1; + struct hashfile *f; + struct strbuf line = STRBUF_INIT; + struct option options[] = { + OPT_INTEGER('n', "num-objects", &num_objects, N_("the number of objects to write")), + OPT_END() + }; + + argc = parse_options(argc, argv, NULL, + options, usage_str, 0); + + if (argc || num_objects < 0) + usage_with_options(usage_str, options); + + setup_git_directory(); + + f = hashfd(the_repository->hash_algo, 1, "<stdout>"); + write_pack_header(f, num_objects); + + /* Read each line from stdin into 'line' */ + while (strbuf_getline_lf(&line, stdin) != EOF) { + const char *type_str, *content_oid_str, *base_oid_str = NULL; + struct object_id content_oid, base_oid; + struct string_list items = STRING_LIST_INIT_NODUP; + /* + * Tokenize into two or three parts: + * 1. REF_DELTA, OFS_DELTA, or FULL. + * 2. The object ID for the content object. + * 3. The object ID for the base object (optional). + */ + if (string_list_split_in_place(&items, line.buf, " ", 3) < 0) + die("invalid input format: %s", line.buf); + + if (items.nr < 2) + die("invalid input format: %s", line.buf); + + type_str = items.items[0].string; + content_oid_str = items.items[1].string; + + if (get_oid_hex(content_oid_str, &content_oid)) + die("invalid object: %s", content_oid_str); + if (items.nr >= 3) { + base_oid_str = items.items[2].string; + if (get_oid_hex(base_oid_str, &base_oid)) + die("invalid object: %s", base_oid_str); + } + string_list_clear(&items, 0); + + if (!strcmp(type_str, "REF_DELTA")) + write_ref_delta(f, &content_oid, &base_oid); + else if (!strcmp(type_str, "OFS_DELTA")) + die("OFS_DELTA not implemented"); + else if (!strcmp(type_str, "FULL")) + die("FULL not implemented"); + else + die("unknown pack type: %s", type_str); + } + + finalize_hashfile(f, NULL, FSYNC_COMPONENT_PACK, + CSUM_HASH_IN_STREAM | CSUM_FSYNC | CSUM_CLOSE); + strbuf_release(&line); + return 0; +} diff --git a/t/helper/test-pack-mtimes.c b/t/helper/test-pack-mtimes.c index 50f5941bff..fdf1b13437 100644 --- a/t/helper/test-pack-mtimes.c +++ b/t/helper/test-pack-mtimes.c @@ -24,7 +24,7 @@ static void dump_mtimes(struct packed_git *p) } } -static const char *pack_mtimes_usage = "\n" +static const char *const pack_mtimes_usage = "\n" " test-tool pack-mtimes <pack-name.mtimes>"; int cmd__pack_mtimes(int argc, const char **argv) diff --git a/t/helper/test-proc-receive.c b/t/helper/test-proc-receive.c index 3703f734f3..8eccc34216 100644 --- a/t/helper/test-proc-receive.c +++ b/t/helper/test-proc-receive.c @@ -6,7 +6,7 @@ #include "sigchain.h" #include "string-list.h" -static const char *proc_receive_usage[] = { +static const char *const proc_receive_usage[] = { "test-tool proc-receive [<options>]", NULL }; diff --git a/t/helper/test-reftable.c b/t/helper/test-reftable.c index 3c72ed985b..b16c0722c8 100644 --- a/t/helper/test-reftable.c +++ b/t/helper/test-reftable.c @@ -2,10 +2,11 @@ #include "hash.h" #include "hex.h" #include "reftable/system.h" +#include "reftable/reftable-constants.h" #include "reftable/reftable-error.h" #include "reftable/reftable-merged.h" -#include "reftable/reftable-reader.h" #include "reftable/reftable-stack.h" +#include "reftable/reftable-table.h" #include "test-tool.h" static void print_help(void) @@ -20,6 +21,72 @@ static void print_help(void) "\n"); } +static int dump_blocks(const char *tablename) +{ + struct reftable_table_iterator ti = { 0 }; + struct reftable_block_source src = { 0 }; + struct reftable_table *table = NULL; + uint8_t section_type = 0; + int err; + + err = reftable_block_source_from_file(&src, tablename); + if (err < 0) + goto done; + + err = reftable_table_new(&table, &src, tablename); + if (err < 0) + goto done; + + err = reftable_table_iterator_init(&ti, table); + if (err < 0) + goto done; + + printf("header:\n"); + printf(" block_size: %d\n", table->block_size); + + while (1) { + const struct reftable_block *block; + + err = reftable_table_iterator_next(&ti, &block); + if (err < 0) + goto done; + if (err > 0) + break; + + if (block->block_type != section_type) { + const char *section; + switch (block->block_type) { + case REFTABLE_BLOCK_TYPE_LOG: + section = "log"; + break; + case REFTABLE_BLOCK_TYPE_REF: + section = "ref"; + break; + case REFTABLE_BLOCK_TYPE_OBJ: + section = "obj"; + break; + case REFTABLE_BLOCK_TYPE_INDEX: + section = "idx"; + break; + default: + err = -1; + goto done; + } + + section_type = block->block_type; + printf("%s:\n", section); + } + + printf(" - length: %u\n", block->restart_off); + printf(" restarts: %u\n", block->restart_count); + } + +done: + reftable_table_iterator_release(&ti); + reftable_table_decref(table); + return err; +} + static int dump_table(struct reftable_merged_table *mt) { struct reftable_iterator it = { NULL }; @@ -126,19 +193,19 @@ static int dump_reftable(const char *tablename) { struct reftable_block_source src = { 0 }; struct reftable_merged_table *mt = NULL; - struct reftable_reader *r = NULL; + struct reftable_table *table = NULL; int err; err = reftable_block_source_from_file(&src, tablename); if (err < 0) goto done; - err = reftable_reader_new(&r, &src, tablename); + err = reftable_table_new(&table, &src, tablename); if (err < 0) goto done; - err = reftable_merged_table_new(&mt, &r, 1, - reftable_reader_hash_id(r)); + err = reftable_merged_table_new(&mt, &table, 1, + reftable_table_hash_id(table)); if (err < 0) goto done; @@ -146,7 +213,7 @@ static int dump_reftable(const char *tablename) done: reftable_merged_table_free(mt); - reftable_reader_decref(r); + reftable_table_decref(table); return err; } @@ -184,7 +251,7 @@ int cmd__dump_reftable(int argc, const char **argv) arg = argv[1]; if (opt_dump_blocks) { - err = reftable_reader_print_blocks(arg); + err = dump_blocks(arg); } else if (opt_dump_table) { err = dump_reftable(arg); } else if (opt_dump_stack) { diff --git a/t/helper/test-rot13-filter.c b/t/helper/test-rot13-filter.c index 722b1cbe77..ad37e10034 100644 --- a/t/helper/test-rot13-filter.c +++ b/t/helper/test-rot13-filter.c @@ -324,7 +324,7 @@ static void packet_initialize(void) packet_flush(1); } -static const char *rot13_usage[] = { +static const char *const rot13_usage[] = { "test-tool rot13-filter [--always-delay] --log=<path> <capabilities>", NULL }; diff --git a/t/helper/test-submodule.c b/t/helper/test-submodule.c index 22e518d229..0133852e1e 100644 --- a/t/helper/test-submodule.c +++ b/t/helper/test-submodule.c @@ -12,33 +12,33 @@ #define TEST_TOOL_CHECK_NAME_USAGE \ "test-tool submodule check-name" -static const char *submodule_check_name_usage[] = { +static const char *const submodule_check_name_usage[] = { TEST_TOOL_CHECK_NAME_USAGE, NULL }; #define TEST_TOOL_CHECK_URL_USAGE \ "test-tool submodule check-url" -static const char *submodule_check_url_usage[] = { +static const char *const submodule_check_url_usage[] = { TEST_TOOL_CHECK_URL_USAGE, NULL }; #define TEST_TOOL_IS_ACTIVE_USAGE \ "test-tool submodule is-active <name>" -static const char *submodule_is_active_usage[] = { +static const char *const submodule_is_active_usage[] = { TEST_TOOL_IS_ACTIVE_USAGE, NULL }; #define TEST_TOOL_RESOLVE_RELATIVE_URL_USAGE \ "test-tool submodule resolve-relative-url <up_path> <remoteurl> <url>" -static const char *submodule_resolve_relative_url_usage[] = { +static const char *const submodule_resolve_relative_url_usage[] = { TEST_TOOL_RESOLVE_RELATIVE_URL_USAGE, NULL, }; -static const char *submodule_usage[] = { +static const char *const submodule_usage[] = { TEST_TOOL_CHECK_NAME_USAGE, TEST_TOOL_CHECK_URL_USAGE, TEST_TOOL_IS_ACTIVE_USAGE, diff --git a/t/helper/test-tool.c b/t/helper/test-tool.c index 50dc4dac4e..74812ed86d 100644 --- a/t/helper/test-tool.c +++ b/t/helper/test-tool.c @@ -46,6 +46,7 @@ static struct test_cmd cmds[] = { { "mktemp", cmd__mktemp }, { "name-hash", cmd__name_hash }, { "online-cpus", cmd__online_cpus }, + { "pack-deltas", cmd__pack_deltas }, { "pack-mtimes", cmd__pack_mtimes }, { "parse-options", cmd__parse_options }, { "parse-options-flags", cmd__parse_options_flags }, diff --git a/t/helper/test-tool.h b/t/helper/test-tool.h index 6d62a5b53d..2571a3ccfe 100644 --- a/t/helper/test-tool.h +++ b/t/helper/test-tool.h @@ -39,6 +39,7 @@ int cmd__mergesort(int argc, const char **argv); int cmd__mktemp(int argc, const char **argv); int cmd__name_hash(int argc, const char **argv); int cmd__online_cpus(int argc, const char **argv); +int cmd__pack_deltas(int argc, const char **argv); int cmd__pack_mtimes(int argc, const char **argv); int cmd__parse_options(int argc, const char **argv); int cmd__parse_options_flags(int argc, const char **argv); diff --git a/t/helper/test-windows-named-pipe.c b/t/helper/test-windows-named-pipe.c index ae52183e63..bd73784ceb 100644 --- a/t/helper/test-windows-named-pipe.c +++ b/t/helper/test-windows-named-pipe.c @@ -3,7 +3,7 @@ #include "strbuf.h" #ifdef GIT_WINDOWS_NATIVE -static const char *usage_string = "<pipe-filename>"; +static const char *const usage_string = "<pipe-filename>"; #define TEST_BUFSIZE (4096) diff --git a/t/meson.build b/t/meson.build index bfb744e886..fcfc1c2c2b 100644 --- a/t/meson.build +++ b/t/meson.build @@ -58,10 +58,10 @@ unit_test_programs = [ 'unit-tests/t-reftable-block.c', 'unit-tests/t-reftable-merged.c', 'unit-tests/t-reftable-pq.c', - 'unit-tests/t-reftable-reader.c', 'unit-tests/t-reftable-readwrite.c', 'unit-tests/t-reftable-record.c', 'unit-tests/t-reftable-stack.c', + 'unit-tests/t-reftable-table.c', ] foreach unit_test_program : unit_test_programs @@ -501,6 +501,7 @@ integration_tests = [ 't4068-diff-symmetric-merge-base.sh', 't4069-remerge-diff.sh', 't4070-diff-pairs.sh', + 't4071-diff-minimal.sh', 't4100-apply-stat.sh', 't4101-apply-nonl.sh', 't4102-apply-rename.sh', @@ -788,6 +789,7 @@ integration_tests = [ 't6134-pathspec-in-submodule.sh', 't6135-pathspec-with-attrs.sh', 't6136-pathspec-in-bare.sh', + 't6137-pathspec-wildcards-literal.sh', 't6200-fmt-merge-msg.sh', 't6300-for-each-ref.sh', 't6301-for-each-ref-errors.sh', @@ -1097,11 +1099,71 @@ integration_tests = [ 't9903-bash-prompt.sh', ] +benchmarks = [ + 'perf/p0000-perf-lib-sanity.sh', + 'perf/p0001-rev-list.sh', + 'perf/p0002-read-cache.sh', + 'perf/p0003-delta-base-cache.sh', + 'perf/p0004-lazy-init-name-hash.sh', + 'perf/p0005-status.sh', + 'perf/p0006-read-tree-checkout.sh', + 'perf/p0007-write-cache.sh', + 'perf/p0008-odb-fsync.sh', + 'perf/p0071-sort.sh', + 'perf/p0090-cache-tree.sh', + 'perf/p0100-globbing.sh', + 'perf/p1006-cat-file.sh', + 'perf/p1400-update-ref.sh', + 'perf/p1450-fsck.sh', + 'perf/p1451-fsck-skip-list.sh', + 'perf/p1500-graph-walks.sh', + 'perf/p2000-sparse-operations.sh', + 'perf/p3400-rebase.sh', + 'perf/p3404-rebase-interactive.sh', + 'perf/p4000-diff-algorithms.sh', + 'perf/p4001-diff-no-index.sh', + 'perf/p4002-diff-color-moved.sh', + 'perf/p4205-log-pretty-formats.sh', + 'perf/p4209-pickaxe.sh', + 'perf/p4211-line-log.sh', + 'perf/p4220-log-grep-engines.sh', + 'perf/p4221-log-grep-engines-fixed.sh', + 'perf/p5302-pack-index.sh', + 'perf/p5303-many-packs.sh', + 'perf/p5304-prune.sh', + 'perf/p5310-pack-bitmaps.sh', + 'perf/p5311-pack-bitmaps-fetch.sh', + 'perf/p5312-pack-bitmaps-revs.sh', + 'perf/p5313-pack-objects.sh', + 'perf/p5314-name-hash.sh', + 'perf/p5326-multi-pack-bitmaps.sh', + 'perf/p5332-multi-pack-reuse.sh', + 'perf/p5333-pseudo-merge-bitmaps.sh', + 'perf/p5550-fetch-tags.sh', + 'perf/p5551-fetch-rescan.sh', + 'perf/p5600-partial-clone.sh', + 'perf/p5601-clone-reference.sh', + 'perf/p6100-describe.sh', + 'perf/p6300-for-each-ref.sh', + 'perf/p7000-filter-branch.sh', + 'perf/p7102-reset.sh', + 'perf/p7300-clean.sh', + 'perf/p7519-fsmonitor.sh', + 'perf/p7527-builtin-fsmonitor.sh', + 'perf/p7810-grep.sh', + 'perf/p7820-grep-engines.sh', + 'perf/p7821-grep-engines-fixed.sh', + 'perf/p7822-grep-perl-character.sh', + 'perf/p9210-scalar.sh', + 'perf/p9300-fast-import-export.sh', +] + # Sanity check that we are not missing any tests present in 't/'. This check # only runs once at configure time and is thus best-effort, only. It is # sufficient to catch missing test suites in our CI though. foreach glob, tests : { 't[0-9][0-9][0-9][0-9]-*.sh': integration_tests, + 'perf/p[0-9][0-9][0-9][0-9]-*.sh': benchmarks, 'unit-tests/t-*.c': unit_test_programs, 'unit-tests/u-*.c': clar_test_suites, } @@ -1153,3 +1215,20 @@ foreach integration_test : integration_tests timeout: 0, ) endforeach + +if perl.found() and time.found() + benchmark_environment = test_environment + benchmark_environment.set('GTIME', time.full_path()) + + foreach benchmark : benchmarks + benchmark(fs.stem(benchmark), shell, + args: [ + fs.name(benchmark), + ], + workdir: meson.current_source_dir() / 'perf', + env: benchmark_environment, + depends: test_dependencies + bin_wrappers, + timeout: 0, + ) + endforeach +endif diff --git a/t/perf/aggregate.perl b/t/perf/aggregate.perl index 575d2000cc..1791c7528a 100755 --- a/t/perf/aggregate.perl +++ b/t/perf/aggregate.perl @@ -1,4 +1,4 @@ -#!/usr/bin/perl +#!/usr/bin/env perl use lib '../../perl/build/lib'; use strict; diff --git a/t/perf/p5332-multi-pack-reuse.sh b/t/perf/p5332-multi-pack-reuse.sh index d1c89a8b7d..0a2525db44 100755 --- a/t/perf/p5332-multi-pack-reuse.sh +++ b/t/perf/p5332-multi-pack-reuse.sh @@ -58,7 +58,7 @@ do ' test_expect_success "setup bitmaps for $nr_packs-pack scenario" ' - find $packdir -type f -name "*.idx" | sed -e "s/.*\/\(.*\)$/+\1/g" | + find $packdir -type f -name "*.idx" | sed -e "s/.*\///" | git multi-pack-index write --stdin-packs --bitmap \ --preferred-pack="$(find_pack $(git rev-parse HEAD))" ' diff --git a/t/perf/perf-lib.sh b/t/perf/perf-lib.sh index 8ab6d9c469..b15c74d6f1 100644 --- a/t/perf/perf-lib.sh +++ b/t/perf/perf-lib.sh @@ -25,7 +25,43 @@ TEST_OUTPUT_DIRECTORY=$(pwd) TEST_NO_CREATE_REPO=t TEST_NO_MALLOC_CHECK=t -. ../test-lib.sh +# GIT-BUILD-OPTIONS, sourced by test-lib.sh, overwrites the `GIT_PERF_*` +# values that are set by the user (if any). Let's stash them away as +# `eval`-able assignments. +git_perf_settings="$(env | + sed -n "/^GIT_PERF_/{ + # escape all single-quotes in the value + s/'/'\\\\''/g + # turn this into an eval-able assignment + s/^\\([^=]*=\\)\\(.*\\)/\\1'\\2'/p + }")" + +# While test-lib.sh computes the build directory for us, we also have to do the +# same thing in order to locate the script via GIT-BUILD-OPTIONS in the first +# place. +GIT_BUILD_DIR="${GIT_BUILD_DIR:-$TEST_DIRECTORY/..}" +if test -f "$GIT_BUILD_DIR/GIT-BUILD-DIR" +then + GIT_BUILD_DIR="$(cat "$GIT_BUILD_DIR/GIT-BUILD-DIR")" || exit 1 + # On Windows, we must convert Windows paths lest they contain a colon + case "$(uname -s)" in + *MINGW*) + GIT_BUILD_DIR="$(cygpath -au "$GIT_BUILD_DIR")" + ;; + esac +fi + +if test ! -f "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS +then + echo >&2 'error: GIT-BUILD-OPTIONS missing (has Git been built?).' + exit 1 +fi + +. "$GIT_BUILD_DIR"/GIT-BUILD-OPTIONS +. "$GIT_SOURCE_DIR"/t/test-lib.sh + +# Then restore GIT_PERF_* settings. +eval "$git_perf_settings" unset GIT_CONFIG_NOSYSTEM GIT_CONFIG_SYSTEM="$TEST_DIRECTORY/perf/config" @@ -98,6 +134,8 @@ test_perf_create_repo_from () { source_git="$("$MODERN_GIT" -C "$source" rev-parse --git-dir)" objects_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-path objects)" common_dir="$("$MODERN_GIT" -C "$source" rev-parse --git-common-dir)" + refformat="$("$MODERN_GIT" -C "$source" rev-parse --show-ref-format)" + objectformat="$("$MODERN_GIT" -C "$source" rev-parse --show-object-format)" mkdir -p "$repo/.git" ( cd "$source" && @@ -114,7 +152,7 @@ test_perf_create_repo_from () { ) && ( cd "$repo" && - "$MODERN_GIT" init -q && + "$MODERN_GIT" init -q --ref-format="$refformat" --object-format="$objectformat" && test_perf_do_repo_symlink_config_ && mv .git/hooks .git/hooks-disabled 2>/dev/null && if test -f .git/index.lock @@ -274,7 +312,7 @@ test_perf_ () { else test_ok_ "$1" fi - "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result + "$PERL_PATH" "$TEST_DIRECTORY"/perf/min_time.perl test_time.* >"$base".result rm test_time.* } @@ -322,7 +360,7 @@ test_at_end_hook_ () { if test -z "$GIT_PERF_AGGREGATING_LATER"; then ( cd "$TEST_DIRECTORY"/perf && - ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0") + "$PERL_PATH" "$GIT_SOURCE_DIR"/t/perf/aggregate.perl --results-dir="$TEST_RESULTS_DIR" $(basename "$0") ) fi } diff --git a/t/perf/run b/t/perf/run index 486ead2198..073bcb2aff 100755 --- a/t/perf/run +++ b/t/perf/run @@ -192,10 +192,10 @@ run_subsection () { if test -z "$GIT_PERF_SEND_TO_CODESPEED" then - ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $codespeed_opt "$@" + "$PERL_PATH" ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" $codespeed_opt "$@" else json_res_file=""$TEST_RESULTS_DIR"/$GIT_PERF_SUBSECTION/aggregate.json" - ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" --codespeed "$@" | tee "$json_res_file" + "$PERL_PATH" ./aggregate.perl --results-dir="$TEST_RESULTS_DIR" --codespeed "$@" | tee "$json_res_file" send_data_url="$GIT_PERF_SEND_TO_CODESPEED/result/add/json/" curl -v --request POST --data-urlencode "json=$(cat "$json_res_file")" "$send_data_url" fi diff --git a/t/t0613-reftable-write-options.sh b/t/t0613-reftable-write-options.sh index 42aa1592f8..6447920c9b 100755 --- a/t/t0613-reftable-write-options.sh +++ b/t/t0613-reftable-write-options.sh @@ -93,6 +93,9 @@ test_expect_success 'many refs results in multiple blocks' ' restarts: 3 - length: 3289 restarts: 3 + idx: + - length: 103 + restarts: 1 EOF test-tool dump-reftable -b .git/reftable/*.ref >actual && test_cmp expect actual @@ -241,6 +244,9 @@ test_expect_success 'object index gets written by default with ref index' ' restarts: 1 - length: 80 restarts: 1 + idx: + - length: 55 + restarts: 2 obj: - length: 11 restarts: 1 @@ -277,6 +283,9 @@ test_expect_success 'object index can be disabled' ' restarts: 1 - length: 80 restarts: 1 + idx: + - length: 55 + restarts: 2 EOF test-tool dump-reftable -b .git/reftable/*.ref >actual && test_cmp expect actual diff --git a/t/t4071-diff-minimal.sh b/t/t4071-diff-minimal.sh new file mode 100755 index 0000000000..4c484dadfb --- /dev/null +++ b/t/t4071-diff-minimal.sh @@ -0,0 +1,14 @@ +#!/bin/sh + +test_description='minimal diff algorithm' + +. ./test-lib.sh + +test_expect_success 'minimal diff should not mark changes between changed lines' ' + test_write_lines x x x x >pre && + test_write_lines x x x A B C D x E F G >post && + test_expect_code 1 git diff --no-index --minimal pre post >diff && + test_grep ! ^[+-]x diff +' + +test_done diff --git a/t/t5150-request-pull.sh b/t/t5150-request-pull.sh index cb67bac1c4..270ce6ea48 100755 --- a/t/t5150-request-pull.sh +++ b/t/t5150-request-pull.sh @@ -7,12 +7,6 @@ export GIT_TEST_DEFAULT_INITIAL_BRANCH_NAME . ./test-lib.sh -if ! test_have_prereq PERL -then - skip_all='skipping request-pull tests, perl not available' - test_done -fi - test_expect_success 'setup' ' git init --bare upstream.git && diff --git a/t/t5309-pack-delta-cycles.sh b/t/t5309-pack-delta-cycles.sh index 60fc710bac..6b03675d91 100755 --- a/t/t5309-pack-delta-cycles.sh +++ b/t/t5309-pack-delta-cycles.sh @@ -60,7 +60,10 @@ test_expect_success 'index-pack detects REF_DELTA cycles' ' test_expect_success 'failover to an object in another pack' ' clear_packs && git index-pack --stdin <ab.pack && - test_must_fail git index-pack --stdin --fix-thin <cycle.pack + + # This cycle does not fail since the existence of A & B in + # the repo allows us to resolve the cycle. + git index-pack --stdin --fix-thin <cycle.pack ' test_expect_success 'failover to a duplicate object in the same pack' ' @@ -72,7 +75,34 @@ test_expect_success 'failover to a duplicate object in the same pack' ' pack_obj $A } >recoverable.pack && pack_trailer recoverable.pack && - test_must_fail git index-pack --fix-thin --stdin <recoverable.pack + + # This cycle does not fail since the existence of a full copy + # of A in the pack allows us to resolve the cycle. + git index-pack --fix-thin --stdin <recoverable.pack +' + +test_expect_success 'index-pack works with thin pack A->B->C with B on disk' ' + git init server && + ( + cd server && + test_commit_bulk 4 + ) && + + A=$(git -C server rev-parse HEAD^{tree}) && + B=$(git -C server rev-parse HEAD~1^{tree}) && + C=$(git -C server rev-parse HEAD~2^{tree}) && + git -C server reset --hard HEAD~1 && + + test-tool -C server pack-deltas --num-objects=2 >thin.pack <<-EOF && + REF_DELTA $A $B + REF_DELTA $B $C + EOF + + git clone "file://$(pwd)/server" client && + ( + cd client && + git index-pack --fix-thin --stdin <../thin.pack + ) ' test_done diff --git a/t/t6137-pathspec-wildcards-literal.sh b/t/t6137-pathspec-wildcards-literal.sh new file mode 100755 index 0000000000..20abad5667 --- /dev/null +++ b/t/t6137-pathspec-wildcards-literal.sh @@ -0,0 +1,429 @@ +#!/bin/sh +test_description='test wildcards and literals with git add/commit (subshell style)' + +. ./test-lib.sh + +test_have_prereq FUNNYNAMES || { + skip_all='skipping: needs FUNNYNAMES (non-Windows only)' + test_done +} + +prepare_test_files () { + for f in "*" "**" "?" "[abc]" "a" "f*" "f**" "f?z" "foo*bar" "hello?world" "hello_world" + do + >"$f" || return + done +} + +test_expect_success 'add wildcard *' ' + git init test-asterisk && + ( + cd test-asterisk && + prepare_test_files && + git add "*" && + cat >expect <<-EOF && + * + ** + ? + [abc] + a + f* + f** + f?z + foo*bar + hello?world + hello_world + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add literal \*' ' + git init test-asterisk-literal && + ( + cd test-asterisk-literal && + prepare_test_files && + git add "\*" && + cat >expect <<-EOF && + * + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard **' ' + git init test-dstar && + ( + cd test-dstar && + prepare_test_files && + git add "**" && + cat >expect <<-EOF && + * + ** + ? + [abc] + a + f* + f** + f?z + foo*bar + hello?world + hello_world + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard ?' ' + git init test-qmark && + ( + cd test-qmark && + prepare_test_files && + git add "?" && + cat >expect <<-\EOF | sort && + * + ? + a + EOF + git ls-files | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard [abc]' ' + git init test-brackets && + ( + cd test-brackets && + prepare_test_files && + git add "[abc]" && + cat >expect <<-\EOF | sort && + [abc] + a + EOF + git ls-files | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard f*' ' + git init test-f-wild && + ( + cd test-f-wild && + prepare_test_files && + git add "f*" && + cat >expect <<-\EOF | sort && + f* + f** + f?z + foo*bar + EOF + git ls-files | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add literal f\*' ' + git init test-f-lit && + ( + cd test-f-lit && + prepare_test_files && + git add "f\*" && + cat >expect <<-\EOF && + f* + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard f**' ' + git init test-fdstar && + ( + cd test-fdstar && + prepare_test_files && + git add "f**" && + cat >expect <<-\EOF | sort && + f* + f** + f?z + foo*bar + EOF + git ls-files | sort >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add literal f\*\*' ' + git init test-fdstar-lit && + ( + cd test-fdstar-lit && + prepare_test_files && + git add "f\*\*" && + cat >expect <<-\EOF && + f** + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard f?z' ' + git init test-fqz && + ( + cd test-fqz && + prepare_test_files && + git add "f?z" && + cat >expect <<-\EOF && + f?z + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add literal \? literal' ' + git init test-q-lit && + ( + cd test-q-lit && + prepare_test_files && + git add "\?" && + cat >expect <<-\EOF && + ? + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard foo*bar' ' + git init test-foobar && + ( + cd test-foobar && + prepare_test_files && + git add "foo*bar" && + cat >expect <<-\EOF && + foo*bar + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add wildcard hello?world' ' + git init test-hellowild && + ( + cd test-hellowild && + prepare_test_files && + git add "hello?world" && + cat >expect <<-\EOF && + hello?world + hello_world + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add literal hello\?world' ' + git init test-hellolit && + ( + cd test-hellolit && + prepare_test_files && + git add "hello\?world" && + cat >expect <<-\EOF && + hello?world + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'add literal [abc]' ' + git init test-brackets-lit && + ( + cd test-brackets-lit && + prepare_test_files && + git add "\[abc\]" && + cat >expect <<-\EOF && + [abc] + EOF + git ls-files >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: wildcard *' ' + git init test-c-asterisk && + ( + cd test-c-asterisk && + prepare_test_files && + git add . && + git commit -m "c1" -- "*" && + cat >expect <<-EOF && + * + ** + ? + [abc] + a + f* + f** + f?z + foo*bar + hello?world + hello_world + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: literal *' ' + git init test-c-asterisk-lit && + ( + cd test-c-asterisk-lit && + prepare_test_files && + git add . && + git commit -m "c2" -- "\*" && + cat >expect <<-EOF && + * + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: wildcard f*' ' + git init test-c-fwild && + ( + cd test-c-fwild && + prepare_test_files && + git add . && + git commit -m "c3" -- "f*" && + cat >expect <<-EOF && + f* + f** + f?z + foo*bar + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: literal f\*' ' + git init test-c-flit && + ( + cd test-c-flit && + prepare_test_files && + git add . && + git commit -m "c4" -- "f\*" && + cat >expect <<-EOF && + f* + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: wildcard pathspec limits commit' ' + git init test-c-pathlimit && + ( + cd test-c-pathlimit && + prepare_test_files && + git add . && + git commit -m "c5" -- "f**" && + cat >expect <<-EOF && + f* + f** + f?z + foo*bar + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: literal f\*\*' ' + git init test-c-fdstar-lit && + ( + cd test-c-fdstar-lit && + prepare_test_files && + git add . && + git commit -m "c6" -- "f\*\*" && + cat >expect <<-EOF && + f** + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: wildcard ?' ' + git init test-c-qwild && + ( + cd test-c-qwild && + prepare_test_files && + git add . && + git commit -m "c7" -- "?" && + cat >expect <<-EOF && + * + ? + a + EOF + git ls-tree -r --name-only HEAD | sort >actual && + sort expect >expect.sorted && + test_cmp expect.sorted actual + ) +' + +test_expect_success 'commit: literal \?' ' + git init test-c-qlit && + ( + cd test-c-qlit && + prepare_test_files && + git add . && + git commit -m "c8" -- "\?" && + cat >expect <<-EOF && + ? + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_expect_success 'commit: wildcard hello?world' ' + git init test-c-hellowild && + ( + cd test-c-hellowild && + prepare_test_files && + git add . && + git commit -m "c9" -- "hello?world" && + cat >expect <<-EOF && + hello?world + hello_world + EOF + git ls-tree -r --name-only HEAD | sort >actual && + sort expect >expect.sorted && + test_cmp expect.sorted actual + ) +' + +test_expect_success 'commit: literal hello\?world' ' + git init test-c-hellolit && + ( + cd test-c-hellolit && + prepare_test_files && + git add . && + git commit -m "c10" -- "hello\?world" && + cat >expect <<-EOF && + hello?world + EOF + git ls-tree -r --name-only HEAD >actual && + test_cmp expect actual + ) +' + +test_done diff --git a/t/t7001-mv.sh b/t/t7001-mv.sh index 25334b5062..920479e925 100755 --- a/t/t7001-mv.sh +++ b/t/t7001-mv.sh @@ -550,16 +550,32 @@ test_expect_success 'moving nested submodules' ' git status ' -test_expect_failure 'nonsense mv triggers assertion failure and partially updated index' ' +test_expect_success 'moving file and its parent directory at the same time fails' ' test_when_finished git reset --hard HEAD && git reset --hard HEAD && mkdir -p a && mkdir -p b && >a/a.txt && git add a/a.txt && - test_must_fail git mv a/a.txt a b && - git status --porcelain >actual && - grep "^A[ ]*a/a.txt$" actual + cat >expect <<-EOF && + fatal: cannot move both ${SQ}a/a.txt${SQ} and its parent directory ${SQ}a${SQ} + EOF + test_must_fail git mv a/a.txt a b 2>err && + test_cmp expect err +' + +test_expect_success 'moving nested directory and its parent directory at the same time fails' ' + test_when_finished git reset --hard HEAD && + git reset --hard HEAD && + mkdir -p a/b/c && + >a/b/c/file.txt && + git add a && + mkdir target && + cat >expect <<-EOF && + fatal: cannot move both ${SQ}a/b/c${SQ} and its parent directory ${SQ}a${SQ} + EOF + test_must_fail git mv a/b/c a target 2>err && + test_cmp expect err ' test_done diff --git a/t/unit-tests/t-reftable-block.c b/t/unit-tests/t-reftable-block.c index 22040aeefa..7dbd93601c 100644 --- a/t/unit-tests/t-reftable-block.c +++ b/t/unit-tests/t-reftable-block.c @@ -19,24 +19,25 @@ static void t_ref_block_read_write(void) struct reftable_record recs[30]; const size_t N = ARRAY_SIZE(recs); const size_t block_size = 1024; - struct reftable_block block = { 0 }; + struct reftable_block_source source = { 0 }; struct block_writer bw = { .last_key = REFTABLE_BUF_INIT, }; struct reftable_record rec = { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, }; size_t i = 0; int ret; - struct block_reader br = { 0 }; + struct reftable_block block = { 0 }; struct block_iter it = BLOCK_ITER_INIT; - struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT; + struct reftable_buf want = REFTABLE_BUF_INIT; + struct reftable_buf block_data = REFTABLE_BUF_INIT; - REFTABLE_CALLOC_ARRAY(block.data, block_size); - check(block.data != NULL); - block.len = block_size; - block_source_from_buf(&block.source ,&buf); - ret = block_writer_init(&bw, BLOCK_TYPE_REF, block.data, block_size, + REFTABLE_CALLOC_ARRAY(block_data.buf, block_size); + check(block_data.buf != NULL); + block_data.len = block_size; + + ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_REF, (uint8_t *) block_data.buf, block_size, header_off, hash_size(REFTABLE_HASH_SHA1)); check(!ret); @@ -62,9 +63,10 @@ static void t_ref_block_read_write(void) block_writer_release(&bw); - block_reader_init(&br, &block, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + block_source_from_buf(&source ,&block_data); + reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); - block_iter_seek_start(&it, &br); + block_iter_init(&it, &block); for (i = 0; ; i++) { ret = block_iter_next(&it, &rec); @@ -77,10 +79,9 @@ static void t_ref_block_read_write(void) } for (i = 0; i < N; i++) { - block_iter_reset(&it); reftable_record_key(&recs[i], &want); - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -89,7 +90,7 @@ static void t_ref_block_read_write(void) check(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1)); want.len--; - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -97,12 +98,11 @@ static void t_ref_block_read_write(void) check(reftable_record_equal(&recs[10 * (i / 10)], &rec, REFTABLE_HASH_SIZE_SHA1)); } - block_reader_release(&br); + reftable_block_release(&block); block_iter_close(&it); reftable_record_release(&rec); - reftable_block_done(&br.block); reftable_buf_release(&want); - reftable_buf_release(&buf); + reftable_buf_release(&block_data); for (i = 0; i < N; i++) reftable_record_release(&recs[i]); } @@ -113,24 +113,25 @@ static void t_log_block_read_write(void) struct reftable_record recs[30]; const size_t N = ARRAY_SIZE(recs); const size_t block_size = 2048; - struct reftable_block block = { 0 }; + struct reftable_block_source source = { 0 }; struct block_writer bw = { .last_key = REFTABLE_BUF_INIT, }; struct reftable_record rec = { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, }; size_t i = 0; int ret; - struct block_reader br = { 0 }; + struct reftable_block block = { 0 }; struct block_iter it = BLOCK_ITER_INIT; - struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT; + struct reftable_buf want = REFTABLE_BUF_INIT; + struct reftable_buf block_data = REFTABLE_BUF_INIT; + + REFTABLE_CALLOC_ARRAY(block_data.buf, block_size); + check(block_data.buf != NULL); + block_data.len = block_size; - REFTABLE_CALLOC_ARRAY(block.data, block_size); - check(block.data != NULL); - block.len = block_size; - block_source_from_buf(&block.source ,&buf); - ret = block_writer_init(&bw, BLOCK_TYPE_LOG, block.data, block_size, + ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_LOG, (uint8_t *) block_data.buf, block_size, header_off, hash_size(REFTABLE_HASH_SHA1)); check(!ret); @@ -151,9 +152,10 @@ static void t_log_block_read_write(void) block_writer_release(&bw); - block_reader_init(&br, &block, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + block_source_from_buf(&source, &block_data); + reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); - block_iter_seek_start(&it, &br); + block_iter_init(&it, &block); for (i = 0; ; i++) { ret = block_iter_next(&it, &rec); @@ -166,11 +168,10 @@ static void t_log_block_read_write(void) } for (i = 0; i < N; i++) { - block_iter_reset(&it); reftable_buf_reset(&want); check(!reftable_buf_addstr(&want, recs[i].u.log.refname)); - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -179,7 +180,7 @@ static void t_log_block_read_write(void) check(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1)); want.len--; - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -187,12 +188,11 @@ static void t_log_block_read_write(void) check(reftable_record_equal(&recs[10 * (i / 10)], &rec, REFTABLE_HASH_SIZE_SHA1)); } - block_reader_release(&br); + reftable_block_release(&block); block_iter_close(&it); reftable_record_release(&rec); - reftable_block_done(&br.block); reftable_buf_release(&want); - reftable_buf_release(&buf); + reftable_buf_release(&block_data); for (i = 0; i < N; i++) reftable_record_release(&recs[i]); } @@ -203,24 +203,25 @@ static void t_obj_block_read_write(void) struct reftable_record recs[30]; const size_t N = ARRAY_SIZE(recs); const size_t block_size = 1024; - struct reftable_block block = { 0 }; + struct reftable_block_source source = { 0 }; struct block_writer bw = { .last_key = REFTABLE_BUF_INIT, }; struct reftable_record rec = { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, }; size_t i = 0; int ret; - struct block_reader br = { 0 }; + struct reftable_block block = { 0 }; struct block_iter it = BLOCK_ITER_INIT; - struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT; + struct reftable_buf want = REFTABLE_BUF_INIT; + struct reftable_buf block_data = REFTABLE_BUF_INIT; + + REFTABLE_CALLOC_ARRAY(block_data.buf, block_size); + check(block_data.buf != NULL); + block_data.len = block_size; - REFTABLE_CALLOC_ARRAY(block.data, block_size); - check(block.data != NULL); - block.len = block_size; - block_source_from_buf(&block.source, &buf); - ret = block_writer_init(&bw, BLOCK_TYPE_OBJ, block.data, block_size, + ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_OBJ, (uint8_t *) block_data.buf, block_size, header_off, hash_size(REFTABLE_HASH_SHA1)); check(!ret); @@ -243,9 +244,10 @@ static void t_obj_block_read_write(void) block_writer_release(&bw); - block_reader_init(&br, &block, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + block_source_from_buf(&source, &block_data); + reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); - block_iter_seek_start(&it, &br); + block_iter_init(&it, &block); for (i = 0; ; i++) { ret = block_iter_next(&it, &rec); @@ -258,10 +260,9 @@ static void t_obj_block_read_write(void) } for (i = 0; i < N; i++) { - block_iter_reset(&it); reftable_record_key(&recs[i], &want); - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -270,12 +271,11 @@ static void t_obj_block_read_write(void) check(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1)); } - block_reader_release(&br); + reftable_block_release(&block); block_iter_close(&it); reftable_record_release(&rec); - reftable_block_done(&br.block); reftable_buf_release(&want); - reftable_buf_release(&buf); + reftable_buf_release(&block_data); for (i = 0; i < N; i++) reftable_record_release(&recs[i]); } @@ -286,25 +286,26 @@ static void t_index_block_read_write(void) struct reftable_record recs[30]; const size_t N = ARRAY_SIZE(recs); const size_t block_size = 1024; - struct reftable_block block = { 0 }; + struct reftable_block_source source = { 0 }; struct block_writer bw = { .last_key = REFTABLE_BUF_INIT, }; struct reftable_record rec = { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx.last_key = REFTABLE_BUF_INIT, }; size_t i = 0; int ret; - struct block_reader br = { 0 }; + struct reftable_block block = { 0 }; struct block_iter it = BLOCK_ITER_INIT; - struct reftable_buf want = REFTABLE_BUF_INIT, buf = REFTABLE_BUF_INIT; + struct reftable_buf want = REFTABLE_BUF_INIT; + struct reftable_buf block_data = REFTABLE_BUF_INIT; - REFTABLE_CALLOC_ARRAY(block.data, block_size); - check(block.data != NULL); - block.len = block_size; - block_source_from_buf(&block.source, &buf); - ret = block_writer_init(&bw, BLOCK_TYPE_INDEX, block.data, block_size, + REFTABLE_CALLOC_ARRAY(block_data.buf, block_size); + check(block_data.buf != NULL); + block_data.len = block_size; + + ret = block_writer_init(&bw, REFTABLE_BLOCK_TYPE_INDEX, (uint8_t *) block_data.buf, block_size, header_off, hash_size(REFTABLE_HASH_SHA1)); check(!ret); @@ -314,7 +315,7 @@ static void t_index_block_read_write(void) snprintf(buf, sizeof(buf), "branch%02"PRIuMAX, (uintmax_t)i); reftable_buf_init(&recs[i].u.idx.last_key); - recs[i].type = BLOCK_TYPE_INDEX; + recs[i].type = REFTABLE_BLOCK_TYPE_INDEX; check(!reftable_buf_addstr(&recs[i].u.idx.last_key, buf)); recs[i].u.idx.offset = i; @@ -327,9 +328,10 @@ static void t_index_block_read_write(void) block_writer_release(&bw); - block_reader_init(&br, &block, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); + block_source_from_buf(&source, &block_data); + reftable_block_init(&block, &source, 0, header_off, block_size, REFTABLE_HASH_SIZE_SHA1); - block_iter_seek_start(&it, &br); + block_iter_init(&it, &block); for (i = 0; ; i++) { ret = block_iter_next(&it, &rec); @@ -342,10 +344,9 @@ static void t_index_block_read_write(void) } for (i = 0; i < N; i++) { - block_iter_reset(&it); reftable_record_key(&recs[i], &want); - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -354,7 +355,7 @@ static void t_index_block_read_write(void) check(reftable_record_equal(&recs[i], &rec, REFTABLE_HASH_SIZE_SHA1)); want.len--; - ret = block_iter_seek_key(&it, &br, &want); + ret = block_iter_seek_key(&it, &want); check_int(ret, ==, 0); ret = block_iter_next(&it, &rec); @@ -362,22 +363,99 @@ static void t_index_block_read_write(void) check(reftable_record_equal(&recs[10 * (i / 10)], &rec, REFTABLE_HASH_SIZE_SHA1)); } - block_reader_release(&br); + reftable_block_release(&block); block_iter_close(&it); reftable_record_release(&rec); - reftable_block_done(&br.block); reftable_buf_release(&want); - reftable_buf_release(&buf); + reftable_buf_release(&block_data); for (i = 0; i < N; i++) reftable_record_release(&recs[i]); } +static void t_block_iterator(void) +{ + struct reftable_block_source source = { 0 }; + struct block_writer writer = { + .last_key = REFTABLE_BUF_INIT, + }; + struct reftable_record expected_refs[20]; + struct reftable_ref_record ref = { 0 }; + struct reftable_iterator it = { 0 }; + struct reftable_block block = { 0 }; + struct reftable_buf data; + int err; + + data.len = 1024; + REFTABLE_CALLOC_ARRAY(data.buf, data.len); + check(data.buf != NULL); + + err = block_writer_init(&writer, REFTABLE_BLOCK_TYPE_REF, (uint8_t *) data.buf, data.len, + 0, hash_size(REFTABLE_HASH_SHA1)); + check(!err); + + for (size_t i = 0; i < ARRAY_SIZE(expected_refs); i++) { + expected_refs[i] = (struct reftable_record) { + .type = REFTABLE_BLOCK_TYPE_REF, + .u.ref = { + .value_type = REFTABLE_REF_VAL1, + .refname = xstrfmt("refs/heads/branch-%02"PRIuMAX, (uintmax_t)i), + }, + }; + memset(expected_refs[i].u.ref.value.val1, i, REFTABLE_HASH_SIZE_SHA1); + + err = block_writer_add(&writer, &expected_refs[i]); + check_int(err, ==, 0); + } + + err = block_writer_finish(&writer); + check_int(err, >, 0); + + block_source_from_buf(&source, &data); + reftable_block_init(&block, &source, 0, 0, data.len, REFTABLE_HASH_SIZE_SHA1); + + err = reftable_block_init_iterator(&block, &it); + check_int(err, ==, 0); + + for (size_t i = 0; ; i++) { + err = reftable_iterator_next_ref(&it, &ref); + if (err > 0) { + check_int(i, ==, ARRAY_SIZE(expected_refs)); + break; + } + check_int(err, ==, 0); + + check(reftable_ref_record_equal(&ref, &expected_refs[i].u.ref, + REFTABLE_HASH_SIZE_SHA1)); + } + + err = reftable_iterator_seek_ref(&it, "refs/heads/does-not-exist"); + check_int(err, ==, 0); + err = reftable_iterator_next_ref(&it, &ref); + check_int(err, ==, 1); + + err = reftable_iterator_seek_ref(&it, "refs/heads/branch-13"); + check_int(err, ==, 0); + err = reftable_iterator_next_ref(&it, &ref); + check_int(err, ==, 0); + check(reftable_ref_record_equal(&ref, &expected_refs[13].u.ref, + REFTABLE_HASH_SIZE_SHA1)); + + for (size_t i = 0; i < ARRAY_SIZE(expected_refs); i++) + reftable_free(expected_refs[i].u.ref.refname); + reftable_ref_record_release(&ref); + reftable_iterator_destroy(&it); + reftable_block_release(&block); + block_writer_release(&writer); + reftable_buf_release(&data); +} + int cmd_main(int argc UNUSED, const char *argv[] UNUSED) { TEST(t_index_block_read_write(), "read-write operations on index blocks work"); TEST(t_log_block_read_write(), "read-write operations on log blocks work"); TEST(t_obj_block_read_write(), "read-write operations on obj blocks work"); TEST(t_ref_block_read_write(), "read-write operations on ref blocks work"); + TEST(t_block_iterator(), "block iterator works"); return test_done(); } diff --git a/t/unit-tests/t-reftable-merged.c b/t/unit-tests/t-reftable-merged.c index 60836f80d6..18c3251a56 100644 --- a/t/unit-tests/t-reftable-merged.c +++ b/t/unit-tests/t-reftable-merged.c @@ -11,7 +11,7 @@ https://developers.google.com/open-source/licenses/bsd #include "reftable/blocksource.h" #include "reftable/constants.h" #include "reftable/merged.h" -#include "reftable/reader.h" +#include "reftable/table.h" #include "reftable/reftable-error.h" #include "reftable/reftable-merged.h" #include "reftable/reftable-writer.h" @@ -19,7 +19,7 @@ https://developers.google.com/open-source/licenses/bsd static struct reftable_merged_table * merged_table_from_records(struct reftable_ref_record **refs, struct reftable_block_source **source, - struct reftable_reader ***readers, const size_t *sizes, + struct reftable_table ***tables, const size_t *sizes, struct reftable_buf *buf, const size_t n) { struct reftable_merged_table *mt = NULL; @@ -28,8 +28,8 @@ merged_table_from_records(struct reftable_ref_record **refs, }; int err; - REFTABLE_CALLOC_ARRAY(*readers, n); - check(*readers != NULL); + REFTABLE_CALLOC_ARRAY(*tables, n); + check(*tables != NULL); REFTABLE_CALLOC_ARRAY(*source, n); check(*source != NULL); @@ -37,21 +37,21 @@ merged_table_from_records(struct reftable_ref_record **refs, t_reftable_write_to_buf(&buf[i], refs[i], sizes[i], NULL, 0, &opts); block_source_from_buf(&(*source)[i], &buf[i]); - err = reftable_reader_new(&(*readers)[i], &(*source)[i], - "name"); + err = reftable_table_new(&(*tables)[i], &(*source)[i], + "name"); check(!err); } - err = reftable_merged_table_new(&mt, *readers, n, REFTABLE_HASH_SHA1); + err = reftable_merged_table_new(&mt, *tables, n, REFTABLE_HASH_SHA1); check(!err); return mt; } -static void readers_destroy(struct reftable_reader **readers, const size_t n) +static void tables_destroy(struct reftable_table **tables, const size_t n) { for (size_t i = 0; i < n; i++) - reftable_reader_decref(readers[i]); - reftable_free(readers); + reftable_table_decref(tables[i]); + reftable_free(tables); } static void t_merged_single_record(void) @@ -77,14 +77,14 @@ static void t_merged_single_record(void) size_t sizes[] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) }; struct reftable_buf bufs[3] = { REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, REFTABLE_BUF_INIT }; struct reftable_block_source *bs = NULL; - struct reftable_reader **readers = NULL; + struct reftable_table **tables = NULL; struct reftable_merged_table *mt = - merged_table_from_records(refs, &bs, &readers, sizes, bufs, 3); + merged_table_from_records(refs, &bs, &tables, sizes, bufs, 3); struct reftable_ref_record ref = { 0 }; struct reftable_iterator it = { 0 }; int err; - err = merged_table_init_iter(mt, &it, BLOCK_TYPE_REF); + err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF); check(!err); err = reftable_iterator_seek_ref(&it, "a"); check(!err); @@ -94,7 +94,7 @@ static void t_merged_single_record(void) check(reftable_ref_record_equal(&r2[0], &ref, REFTABLE_HASH_SIZE_SHA1)); reftable_ref_record_release(&ref); reftable_iterator_destroy(&it); - readers_destroy(readers, 3); + tables_destroy(tables, 3); reftable_merged_table_free(mt); for (size_t i = 0; i < ARRAY_SIZE(bufs); i++) reftable_buf_release(&bufs[i]); @@ -154,9 +154,9 @@ static void t_merged_refs(void) size_t sizes[3] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) }; struct reftable_buf bufs[3] = { REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, REFTABLE_BUF_INIT }; struct reftable_block_source *bs = NULL; - struct reftable_reader **readers = NULL; + struct reftable_table **tables = NULL; struct reftable_merged_table *mt = - merged_table_from_records(refs, &bs, &readers, sizes, bufs, 3); + merged_table_from_records(refs, &bs, &tables, sizes, bufs, 3); struct reftable_iterator it = { 0 }; int err; struct reftable_ref_record *out = NULL; @@ -164,7 +164,7 @@ static void t_merged_refs(void) size_t cap = 0; size_t i; - err = merged_table_init_iter(mt, &it, BLOCK_TYPE_REF); + err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF); check(!err); err = reftable_iterator_seek_ref(&it, "a"); check(!err); @@ -193,7 +193,7 @@ static void t_merged_refs(void) for (i = 0; i < 3; i++) reftable_buf_release(&bufs[i]); - readers_destroy(readers, 3); + tables_destroy(tables, 3); reftable_merged_table_free(mt); reftable_free(bs); } @@ -238,13 +238,13 @@ static void t_merged_seek_multiple_times(void) REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, }; struct reftable_block_source *sources = NULL; - struct reftable_reader **readers = NULL; + struct reftable_table **tables = NULL; struct reftable_ref_record rec = { 0 }; struct reftable_iterator it = { 0 }; struct reftable_merged_table *mt; - mt = merged_table_from_records(refs, &sources, &readers, sizes, bufs, 2); - merged_table_init_iter(mt, &it, BLOCK_TYPE_REF); + mt = merged_table_from_records(refs, &sources, &tables, sizes, bufs, 2); + merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF); for (size_t i = 0; i < 5; i++) { int err = reftable_iterator_seek_ref(&it, "c"); @@ -266,7 +266,7 @@ static void t_merged_seek_multiple_times(void) for (size_t i = 0; i < ARRAY_SIZE(bufs); i++) reftable_buf_release(&bufs[i]); - readers_destroy(readers, ARRAY_SIZE(refs)); + tables_destroy(tables, ARRAY_SIZE(refs)); reftable_ref_record_release(&rec); reftable_iterator_destroy(&it); reftable_merged_table_free(mt); @@ -313,14 +313,14 @@ static void t_merged_seek_multiple_times_without_draining(void) REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, }; struct reftable_block_source *sources = NULL; - struct reftable_reader **readers = NULL; + struct reftable_table **tables = NULL; struct reftable_ref_record rec = { 0 }; struct reftable_iterator it = { 0 }; struct reftable_merged_table *mt; int err; - mt = merged_table_from_records(refs, &sources, &readers, sizes, bufs, 2); - merged_table_init_iter(mt, &it, BLOCK_TYPE_REF); + mt = merged_table_from_records(refs, &sources, &tables, sizes, bufs, 2); + merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_REF); err = reftable_iterator_seek_ref(&it, "b"); check(!err); @@ -338,7 +338,7 @@ static void t_merged_seek_multiple_times_without_draining(void) for (size_t i = 0; i < ARRAY_SIZE(bufs); i++) reftable_buf_release(&bufs[i]); - readers_destroy(readers, ARRAY_SIZE(refs)); + tables_destroy(tables, ARRAY_SIZE(refs)); reftable_ref_record_release(&rec); reftable_iterator_destroy(&it); reftable_merged_table_free(mt); @@ -348,7 +348,7 @@ static void t_merged_seek_multiple_times_without_draining(void) static struct reftable_merged_table * merged_table_from_log_records(struct reftable_log_record **logs, struct reftable_block_source **source, - struct reftable_reader ***readers, const size_t *sizes, + struct reftable_table ***tables, const size_t *sizes, struct reftable_buf *buf, const size_t n) { struct reftable_merged_table *mt = NULL; @@ -358,8 +358,8 @@ merged_table_from_log_records(struct reftable_log_record **logs, }; int err; - REFTABLE_CALLOC_ARRAY(*readers, n); - check(*readers != NULL); + REFTABLE_CALLOC_ARRAY(*tables, n); + check(*tables != NULL); REFTABLE_CALLOC_ARRAY(*source, n); check(*source != NULL); @@ -367,12 +367,12 @@ merged_table_from_log_records(struct reftable_log_record **logs, t_reftable_write_to_buf(&buf[i], NULL, 0, logs[i], sizes[i], &opts); block_source_from_buf(&(*source)[i], &buf[i]); - err = reftable_reader_new(&(*readers)[i], &(*source)[i], - "name"); + err = reftable_table_new(&(*tables)[i], &(*source)[i], + "name"); check(!err); } - err = reftable_merged_table_new(&mt, *readers, n, REFTABLE_HASH_SHA1); + err = reftable_merged_table_new(&mt, *tables, n, REFTABLE_HASH_SHA1); check(!err); return mt; } @@ -435,9 +435,9 @@ static void t_merged_logs(void) size_t sizes[3] = { ARRAY_SIZE(r1), ARRAY_SIZE(r2), ARRAY_SIZE(r3) }; struct reftable_buf bufs[3] = { REFTABLE_BUF_INIT, REFTABLE_BUF_INIT, REFTABLE_BUF_INIT }; struct reftable_block_source *bs = NULL; - struct reftable_reader **readers = NULL; + struct reftable_table **tables = NULL; struct reftable_merged_table *mt = merged_table_from_log_records( - logs, &bs, &readers, sizes, bufs, 3); + logs, &bs, &tables, sizes, bufs, 3); struct reftable_iterator it = { 0 }; int err; struct reftable_log_record *out = NULL; @@ -445,7 +445,7 @@ static void t_merged_logs(void) size_t cap = 0; size_t i; - err = merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG); + err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_LOG); check(!err); err = reftable_iterator_seek_log(&it, "a"); check(!err); @@ -469,7 +469,7 @@ static void t_merged_logs(void) check(reftable_log_record_equal(want[i], &out[i], REFTABLE_HASH_SIZE_SHA1)); - err = merged_table_init_iter(mt, &it, BLOCK_TYPE_LOG); + err = merged_table_init_iter(mt, &it, REFTABLE_BLOCK_TYPE_LOG); check(!err); err = reftable_iterator_seek_log_at(&it, "a", 2); check(!err); @@ -485,7 +485,7 @@ static void t_merged_logs(void) for (i = 0; i < 3; i++) reftable_buf_release(&bufs[i]); - readers_destroy(readers, 3); + tables_destroy(tables, 3); reftable_merged_table_free(mt); reftable_free(bs); } @@ -502,7 +502,7 @@ static void t_default_write_opts(void) int err; struct reftable_block_source source = { 0 }; uint32_t hash_id; - struct reftable_reader *rd = NULL; + struct reftable_table *table = NULL; struct reftable_merged_table *merged = NULL; reftable_writer_set_limits(w, 1, 1); @@ -516,18 +516,18 @@ static void t_default_write_opts(void) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&rd, &source, "filename"); + err = reftable_table_new(&table, &source, "filename"); check(!err); - hash_id = reftable_reader_hash_id(rd); + hash_id = reftable_table_hash_id(table); check_int(hash_id, ==, REFTABLE_HASH_SHA1); - err = reftable_merged_table_new(&merged, &rd, 1, REFTABLE_HASH_SHA256); + err = reftable_merged_table_new(&merged, &table, 1, REFTABLE_HASH_SHA256); check_int(err, ==, REFTABLE_FORMAT_ERROR); - err = reftable_merged_table_new(&merged, &rd, 1, REFTABLE_HASH_SHA1); + err = reftable_merged_table_new(&merged, &table, 1, REFTABLE_HASH_SHA1); check(!err); - reftable_reader_decref(rd); + reftable_table_decref(table); reftable_merged_table_free(merged); reftable_buf_release(&buf); } diff --git a/t/unit-tests/t-reftable-pq.c b/t/unit-tests/t-reftable-pq.c index c128fe8616..fb5a4eb187 100644 --- a/t/unit-tests/t-reftable-pq.c +++ b/t/unit-tests/t-reftable-pq.c @@ -34,7 +34,7 @@ static void t_pq_record(void) char *last = NULL; for (i = 0; i < N; i++) { - check(!reftable_record_init(&recs[i], BLOCK_TYPE_REF)); + check(!reftable_record_init(&recs[i], REFTABLE_BLOCK_TYPE_REF)); recs[i].u.ref.refname = xstrfmt("%02"PRIuMAX, (uintmax_t)i); } @@ -57,7 +57,7 @@ static void t_pq_record(void) merged_iter_pqueue_check(&pq); check(pq_entry_equal(&top, &e)); - check(reftable_record_type(e.rec) == BLOCK_TYPE_REF); + check(reftable_record_type(e.rec) == REFTABLE_BLOCK_TYPE_REF); if (last) check_int(strcmp(last, e.rec->u.ref.refname), <, 0); last = e.rec->u.ref.refname; @@ -76,7 +76,7 @@ static void t_pq_index(void) size_t N = ARRAY_SIZE(recs), i; for (i = 0; i < N; i++) { - check(!reftable_record_init(&recs[i], BLOCK_TYPE_REF)); + check(!reftable_record_init(&recs[i], REFTABLE_BLOCK_TYPE_REF)); recs[i].u.ref.refname = (char *) "refs/heads/master"; } @@ -100,7 +100,7 @@ static void t_pq_index(void) merged_iter_pqueue_check(&pq); check(pq_entry_equal(&top, &e)); - check(reftable_record_type(e.rec) == BLOCK_TYPE_REF); + check(reftable_record_type(e.rec) == REFTABLE_BLOCK_TYPE_REF); check_int(e.index, ==, i); if (last) check_str(last, e.rec->u.ref.refname); @@ -117,7 +117,7 @@ static void t_merged_iter_pqueue_top(void) size_t N = ARRAY_SIZE(recs), i; for (i = 0; i < N; i++) { - check(!reftable_record_init(&recs[i], BLOCK_TYPE_REF)); + check(!reftable_record_init(&recs[i], REFTABLE_BLOCK_TYPE_REF)); recs[i].u.ref.refname = (char *) "refs/heads/master"; } diff --git a/t/unit-tests/t-reftable-reader.c b/t/unit-tests/t-reftable-reader.c deleted file mode 100644 index 546df6005e..0000000000 --- a/t/unit-tests/t-reftable-reader.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "test-lib.h" -#include "lib-reftable.h" -#include "reftable/blocksource.h" -#include "reftable/reader.h" - -static int t_reader_seek_once(void) -{ - struct reftable_ref_record records[] = { - { - .refname = (char *) "refs/heads/main", - .value_type = REFTABLE_REF_VAL1, - .value.val1 = { 42 }, - }, - }; - struct reftable_block_source source = { 0 }; - struct reftable_ref_record ref = { 0 }; - struct reftable_iterator it = { 0 }; - struct reftable_reader *reader; - struct reftable_buf buf = REFTABLE_BUF_INIT; - int ret; - - t_reftable_write_to_buf(&buf, records, ARRAY_SIZE(records), NULL, 0, NULL); - block_source_from_buf(&source, &buf); - - ret = reftable_reader_new(&reader, &source, "name"); - check(!ret); - - reftable_reader_init_ref_iterator(reader, &it); - ret = reftable_iterator_seek_ref(&it, ""); - check(!ret); - ret = reftable_iterator_next_ref(&it, &ref); - check(!ret); - - ret = reftable_ref_record_equal(&ref, &records[0], REFTABLE_HASH_SIZE_SHA1); - check_int(ret, ==, 1); - - ret = reftable_iterator_next_ref(&it, &ref); - check_int(ret, ==, 1); - - reftable_ref_record_release(&ref); - reftable_iterator_destroy(&it); - reftable_reader_decref(reader); - reftable_buf_release(&buf); - return 0; -} - -static int t_reader_reseek(void) -{ - struct reftable_ref_record records[] = { - { - .refname = (char *) "refs/heads/main", - .value_type = REFTABLE_REF_VAL1, - .value.val1 = { 42 }, - }, - }; - struct reftable_block_source source = { 0 }; - struct reftable_ref_record ref = { 0 }; - struct reftable_iterator it = { 0 }; - struct reftable_reader *reader; - struct reftable_buf buf = REFTABLE_BUF_INIT; - int ret; - - t_reftable_write_to_buf(&buf, records, ARRAY_SIZE(records), NULL, 0, NULL); - block_source_from_buf(&source, &buf); - - ret = reftable_reader_new(&reader, &source, "name"); - check(!ret); - - reftable_reader_init_ref_iterator(reader, &it); - - for (size_t i = 0; i < 5; i++) { - ret = reftable_iterator_seek_ref(&it, ""); - check(!ret); - ret = reftable_iterator_next_ref(&it, &ref); - check(!ret); - - ret = reftable_ref_record_equal(&ref, &records[0], REFTABLE_HASH_SIZE_SHA1); - check_int(ret, ==, 1); - - ret = reftable_iterator_next_ref(&it, &ref); - check_int(ret, ==, 1); - } - - reftable_ref_record_release(&ref); - reftable_iterator_destroy(&it); - reftable_reader_decref(reader); - reftable_buf_release(&buf); - return 0; -} - -int cmd_main(int argc UNUSED, const char *argv[] UNUSED) -{ - TEST(t_reader_seek_once(), "reader can seek once"); - TEST(t_reader_reseek(), "reader can reseek multiple times"); - return test_done(); -} diff --git a/t/unit-tests/t-reftable-readwrite.c b/t/unit-tests/t-reftable-readwrite.c index c9626831da..4c49129439 100644 --- a/t/unit-tests/t-reftable-readwrite.c +++ b/t/unit-tests/t-reftable-readwrite.c @@ -12,9 +12,9 @@ https://developers.google.com/open-source/licenses/bsd #include "lib-reftable.h" #include "reftable/basics.h" #include "reftable/blocksource.h" -#include "reftable/reader.h" #include "reftable/reftable-error.h" #include "reftable/reftable-writer.h" +#include "reftable/table.h" #include "strbuf.h" static const int update_index = 5; @@ -23,22 +23,22 @@ static void t_buffer(void) { struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_block_source source = { 0 }; - struct reftable_block out = { 0 }; + struct reftable_block_data out = { 0 }; int n; uint8_t in[] = "hello"; check(!reftable_buf_add(&buf, in, sizeof(in))); block_source_from_buf(&source, &buf); check_int(block_source_size(&source), ==, 6); - n = block_source_read_block(&source, &out, 0, sizeof(in)); + n = block_source_read_data(&source, &out, 0, sizeof(in)); check_int(n, ==, sizeof(in)); check(!memcmp(in, out.data, n)); - reftable_block_done(&out); + block_source_release_data(&out); - n = block_source_read_block(&source, &out, 1, 2); + n = block_source_read_data(&source, &out, 1, 2); check_int(n, ==, 2); check(!memcmp(out.data, "el", 2)); - reftable_block_done(&out); + block_source_release_data(&out); block_source_close(&source); reftable_buf_release(&buf); } @@ -204,7 +204,7 @@ static void t_log_write_read(void) struct reftable_ref_record ref = { 0 }; struct reftable_log_record log = { 0 }; struct reftable_iterator it = { 0 }; - struct reftable_reader *reader; + struct reftable_table *table; struct reftable_block_source source = { 0 }; struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts); @@ -254,10 +254,10 @@ static void t_log_write_read(void) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.log"); + err = reftable_table_new(&table, &source, "file.log"); check(!err); - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, names[N - 1]); @@ -273,7 +273,7 @@ static void t_log_write_read(void) reftable_iterator_destroy(&it); reftable_ref_record_release(&ref); - err = reftable_reader_init_log_iterator(reader, &it); + err = reftable_table_init_log_iterator(table, &it); check(!err); err = reftable_iterator_seek_log(&it, ""); check(!err); @@ -294,7 +294,7 @@ static void t_log_write_read(void) /* cleanup. */ reftable_buf_release(&buf); free_names(names); - reftable_reader_decref(reader); + reftable_table_decref(table); } static void t_log_zlib_corruption(void) @@ -303,7 +303,7 @@ static void t_log_zlib_corruption(void) .block_size = 256, }; struct reftable_iterator it = { 0 }; - struct reftable_reader *reader; + struct reftable_table *table; struct reftable_block_source source = { 0 }; struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts); @@ -345,10 +345,10 @@ static void t_log_zlib_corruption(void) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.log"); + err = reftable_table_new(&table, &source, "file.log"); check(!err); - err = reftable_reader_init_log_iterator(reader, &it); + err = reftable_table_init_log_iterator(table, &it); check(!err); err = reftable_iterator_seek_log(&it, "refname"); check_int(err, ==, REFTABLE_ZLIB_ERROR); @@ -356,7 +356,7 @@ static void t_log_zlib_corruption(void) reftable_iterator_destroy(&it); /* cleanup. */ - reftable_reader_decref(reader); + reftable_table_decref(table); reftable_buf_release(&buf); } @@ -367,7 +367,7 @@ static void t_table_read_write_sequential(void) int N = 50; struct reftable_iterator it = { 0 }; struct reftable_block_source source = { 0 }; - struct reftable_reader *reader; + struct reftable_table *table; int err = 0; int j = 0; @@ -375,10 +375,10 @@ static void t_table_read_write_sequential(void) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.ref"); + err = reftable_table_new(&table, &source, "file.ref"); check(!err); - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, ""); check(!err); @@ -396,7 +396,7 @@ static void t_table_read_write_sequential(void) check_int(j, ==, N); reftable_iterator_destroy(&it); - reftable_reader_decref(reader); + reftable_table_decref(table); reftable_buf_release(&buf); free_names(names); } @@ -417,7 +417,7 @@ static void t_table_read_api(void) char **names; struct reftable_buf buf = REFTABLE_BUF_INIT; int N = 50; - struct reftable_reader *reader; + struct reftable_table *table; struct reftable_block_source source = { 0 }; int err; struct reftable_log_record log = { 0 }; @@ -427,10 +427,10 @@ static void t_table_read_api(void) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.ref"); + err = reftable_table_new(&table, &source, "file.ref"); check(!err); - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, names[0]); check(!err); @@ -441,7 +441,7 @@ static void t_table_read_api(void) reftable_buf_release(&buf); free_names(names); reftable_iterator_destroy(&it); - reftable_reader_decref(reader); + reftable_table_decref(table); reftable_buf_release(&buf); } @@ -450,7 +450,7 @@ static void t_table_read_write_seek(int index, enum reftable_hash hash_id) char **names; struct reftable_buf buf = REFTABLE_BUF_INIT; int N = 50; - struct reftable_reader *reader; + struct reftable_table *table; struct reftable_block_source source = { 0 }; int err; int i = 0; @@ -463,18 +463,18 @@ static void t_table_read_write_seek(int index, enum reftable_hash hash_id) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.ref"); + err = reftable_table_new(&table, &source, "file.ref"); check(!err); - check_int(hash_id, ==, reftable_reader_hash_id(reader)); + check_int(hash_id, ==, reftable_table_hash_id(table)); if (!index) { - reader->ref_offsets.index_offset = 0; + table->ref_offsets.index_offset = 0; } else { - check_int(reader->ref_offsets.index_offset, >, 0); + check_int(table->ref_offsets.index_offset, >, 0); } for (i = 1; i < N; i++) { - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, names[i]); check(!err); @@ -491,7 +491,7 @@ static void t_table_read_write_seek(int index, enum reftable_hash hash_id) check(!reftable_buf_addstr(&pastLast, names[N - 1])); check(!reftable_buf_addstr(&pastLast, "/")); - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, pastLast.buf); if (err == 0) { @@ -507,7 +507,7 @@ static void t_table_read_write_seek(int index, enum reftable_hash hash_id) reftable_buf_release(&buf); free_names(names); - reftable_reader_decref(reader); + reftable_table_decref(table); } static void t_table_read_write_seek_linear(void) @@ -535,7 +535,7 @@ static void t_table_refs_for(int indexed) .block_size = 256, }; struct reftable_ref_record ref = { 0 }; - struct reftable_reader *reader; + struct reftable_table *table; struct reftable_block_source source = { 0 }; struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts); @@ -585,18 +585,18 @@ static void t_table_refs_for(int indexed) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.ref"); + err = reftable_table_new(&table, &source, "file.ref"); check(!err); if (!indexed) - reader->obj_offsets.is_present = 0; + table->obj_offsets.is_present = 0; - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, ""); check(!err); reftable_iterator_destroy(&it); - err = reftable_reader_refs_for(reader, &it, want_hash); + err = reftable_table_refs_for(table, &it, want_hash); check(!err); for (j = 0; ; j++) { @@ -613,7 +613,7 @@ static void t_table_refs_for(int indexed) reftable_buf_release(&buf); free_names(want_names); reftable_iterator_destroy(&it); - reftable_reader_decref(reader); + reftable_table_decref(table); } static void t_table_refs_for_no_index(void) @@ -632,7 +632,7 @@ static void t_write_empty_table(void) struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_writer *w = t_reftable_strbuf_writer(&buf, &opts); struct reftable_block_source source = { 0 }; - struct reftable_reader *rd = NULL; + struct reftable_table *table = NULL; struct reftable_ref_record rec = { 0 }; struct reftable_iterator it = { 0 }; int err; @@ -647,10 +647,10 @@ static void t_write_empty_table(void) block_source_from_buf(&source, &buf); - err = reftable_reader_new(&rd, &source, "filename"); + err = reftable_table_new(&table, &source, "filename"); check(!err); - err = reftable_reader_init_ref_iterator(rd, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, ""); check(!err); @@ -659,7 +659,7 @@ static void t_write_empty_table(void) check_int(err, >, 0); reftable_iterator_destroy(&it); - reftable_reader_decref(rd); + reftable_table_decref(table); reftable_buf_release(&buf); } @@ -803,7 +803,7 @@ static void t_write_multiple_indices(void) struct reftable_iterator it = { 0 }; const struct reftable_stats *stats; struct reftable_writer *writer; - struct reftable_reader *reader; + struct reftable_table *table; char buf[128]; int err, i; @@ -852,21 +852,21 @@ static void t_write_multiple_indices(void) check_int(stats->log_stats.index_offset, >, 0); block_source_from_buf(&source, &writer_buf); - err = reftable_reader_new(&reader, &source, "filename"); + err = reftable_table_new(&table, &source, "filename"); check(!err); /* * Seeking the log uses the log index now. In case there is any * confusion regarding indices we would notice here. */ - err = reftable_reader_init_log_iterator(reader, &it); + err = reftable_table_init_log_iterator(table, &it); check(!err); err = reftable_iterator_seek_log(&it, ""); check(!err); reftable_iterator_destroy(&it); reftable_writer_free(writer); - reftable_reader_decref(reader); + reftable_table_decref(table); reftable_buf_release(&writer_buf); } @@ -880,7 +880,7 @@ static void t_write_multi_level_index(void) struct reftable_iterator it = { 0 }; const struct reftable_stats *stats; struct reftable_writer *writer; - struct reftable_reader *reader; + struct reftable_table *table; int err; writer = t_reftable_strbuf_writer(&writer_buf, &opts); @@ -909,20 +909,20 @@ static void t_write_multi_level_index(void) check_int(stats->ref_stats.max_index_level, ==, 2); block_source_from_buf(&source, &writer_buf); - err = reftable_reader_new(&reader, &source, "filename"); + err = reftable_table_new(&table, &source, "filename"); check(!err); /* * Seeking the last ref should work as expected. */ - err = reftable_reader_init_ref_iterator(reader, &it); + err = reftable_table_init_ref_iterator(table, &it); check(!err); err = reftable_iterator_seek_ref(&it, "refs/heads/199"); check(!err); reftable_iterator_destroy(&it); reftable_writer_free(writer); - reftable_reader_decref(reader); + reftable_table_decref(table); reftable_buf_release(&writer_buf); reftable_buf_release(&buf); } @@ -931,11 +931,11 @@ static void t_corrupt_table_empty(void) { struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_block_source source = { 0 }; - struct reftable_reader *reader; + struct reftable_table *table; int err; block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.log"); + err = reftable_table_new(&table, &source, "file.log"); check_int(err, ==, REFTABLE_FORMAT_ERROR); } @@ -944,12 +944,12 @@ static void t_corrupt_table(void) uint8_t zeros[1024] = { 0 }; struct reftable_buf buf = REFTABLE_BUF_INIT; struct reftable_block_source source = { 0 }; - struct reftable_reader *reader; + struct reftable_table *table; int err; check(!reftable_buf_add(&buf, zeros, sizeof(zeros))); block_source_from_buf(&source, &buf); - err = reftable_reader_new(&reader, &source, "file.log"); + err = reftable_table_new(&table, &source, "file.log"); check_int(err, ==, REFTABLE_FORMAT_ERROR); reftable_buf_release(&buf); diff --git a/t/unit-tests/t-reftable-record.c b/t/unit-tests/t-reftable-record.c index 5954966373..553a007664 100644 --- a/t/unit-tests/t-reftable-record.c +++ b/t/unit-tests/t-reftable-record.c @@ -84,17 +84,17 @@ static void t_reftable_ref_record_comparison(void) { struct reftable_record in[3] = { { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u.ref.refname = (char *) "refs/heads/master", .u.ref.value_type = REFTABLE_REF_VAL1, }, { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u.ref.refname = (char *) "refs/heads/master", .u.ref.value_type = REFTABLE_REF_DELETION, }, { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u.ref.refname = (char *) "HEAD", .u.ref.value_type = REFTABLE_REF_SYMREF, .u.ref.value.symref = (char *) "refs/heads/master", @@ -141,10 +141,10 @@ static void t_reftable_ref_record_roundtrip(void) for (int i = REFTABLE_REF_DELETION; i < REFTABLE_NR_REF_VALUETYPES; i++) { struct reftable_record in = { - .type = BLOCK_TYPE_REF, + .type = REFTABLE_BLOCK_TYPE_REF, .u.ref.value_type = i, }; - struct reftable_record out = { .type = BLOCK_TYPE_REF }; + struct reftable_record out = { .type = REFTABLE_BLOCK_TYPE_REF }; struct reftable_buf key = REFTABLE_BUF_INIT; uint8_t buffer[1024] = { 0 }; struct string_view dest = { @@ -198,17 +198,17 @@ static void t_reftable_log_record_comparison(void) { struct reftable_record in[3] = { { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u.log.refname = (char *) "refs/heads/master", .u.log.update_index = 42, }, { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u.log.refname = (char *) "refs/heads/master", .u.log.update_index = 22, }, { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u.log.refname = (char *) "refs/heads/main", .u.log.update_index = 22, }, @@ -297,7 +297,7 @@ static void t_reftable_log_record_roundtrip(void) check(!reftable_log_record_is_deletion(&in[2])); for (size_t i = 0; i < ARRAY_SIZE(in); i++) { - struct reftable_record rec = { .type = BLOCK_TYPE_LOG }; + struct reftable_record rec = { .type = REFTABLE_BLOCK_TYPE_LOG }; struct reftable_buf key = REFTABLE_BUF_INIT; uint8_t buffer[1024] = { 0 }; struct string_view dest = { @@ -306,7 +306,7 @@ static void t_reftable_log_record_roundtrip(void) }; /* populate out, to check for leaks. */ struct reftable_record out = { - .type = BLOCK_TYPE_LOG, + .type = REFTABLE_BLOCK_TYPE_LOG, .u.log = { .refname = xstrdup("old name"), .value_type = REFTABLE_LOG_UPDATE, @@ -384,21 +384,21 @@ static void t_reftable_obj_record_comparison(void) uint64_t offsets[] = { 0, 16, 32, 48, 64, 80, 96, 112}; struct reftable_record in[3] = { { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .u.obj.hash_prefix = id_bytes, .u.obj.hash_prefix_len = 7, .u.obj.offsets = offsets, .u.obj.offset_len = 8, }, { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .u.obj.hash_prefix = id_bytes, .u.obj.hash_prefix_len = 7, .u.obj.offsets = offsets, .u.obj.offset_len = 5, }, { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .u.obj.hash_prefix = id_bytes, .u.obj.hash_prefix_len = 5, }, @@ -450,13 +450,13 @@ static void t_reftable_obj_record_roundtrip(void) .len = sizeof(buffer), }; struct reftable_record in = { - .type = BLOCK_TYPE_OBJ, + .type = REFTABLE_BLOCK_TYPE_OBJ, .u = { .obj = recs[i], }, }; struct reftable_buf key = REFTABLE_BUF_INIT; - struct reftable_record out = { .type = BLOCK_TYPE_OBJ }; + struct reftable_record out = { .type = REFTABLE_BLOCK_TYPE_OBJ }; int n, m; uint8_t extra; @@ -482,17 +482,17 @@ static void t_reftable_index_record_comparison(void) { struct reftable_record in[3] = { { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx.offset = 22, .u.idx.last_key = REFTABLE_BUF_INIT, }, { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx.offset = 32, .u.idx.last_key = REFTABLE_BUF_INIT, }, { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx.offset = 32, .u.idx.last_key = REFTABLE_BUF_INIT, }, @@ -523,7 +523,7 @@ static void t_reftable_index_record_comparison(void) static void t_reftable_index_record_roundtrip(void) { struct reftable_record in = { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx = { .offset = 42, .last_key = REFTABLE_BUF_INIT, @@ -537,7 +537,7 @@ static void t_reftable_index_record_roundtrip(void) struct reftable_buf scratch = REFTABLE_BUF_INIT; struct reftable_buf key = REFTABLE_BUF_INIT; struct reftable_record out = { - .type = BLOCK_TYPE_INDEX, + .type = REFTABLE_BLOCK_TYPE_INDEX, .u.idx = { .last_key = REFTABLE_BUF_INIT }, }; int n, m; diff --git a/t/unit-tests/t-reftable-stack.c b/t/unit-tests/t-reftable-stack.c index c3f0059c34..2f49c97519 100644 --- a/t/unit-tests/t-reftable-stack.c +++ b/t/unit-tests/t-reftable-stack.c @@ -12,9 +12,9 @@ https://developers.google.com/open-source/licenses/bsd #include "lib-reftable.h" #include "dir.h" #include "reftable/merged.h" -#include "reftable/reader.h" #include "reftable/reftable-error.h" #include "reftable/stack.h" +#include "reftable/table.h" #include "strbuf.h" #include "tempfile.h" #include <dirent.h> @@ -176,7 +176,7 @@ static void t_reftable_stack_add_one(void) err = reftable_stack_read_ref(st, ref.refname, &dest); check(!err); check(reftable_ref_record_equal(&ref, &dest, REFTABLE_HASH_SIZE_SHA1)); - check_int(st->readers_len, >, 0); + check_int(st->tables_len, >, 0); #ifndef GIT_WINDOWS_NATIVE check(!reftable_buf_addstr(&scratch, dir)); @@ -189,7 +189,7 @@ static void t_reftable_stack_add_one(void) check(!reftable_buf_addstr(&scratch, dir)); check(!reftable_buf_addstr(&scratch, "/")); /* do not try at home; not an external API for reftable. */ - check(!reftable_buf_addstr(&scratch, st->readers[0]->name)); + check(!reftable_buf_addstr(&scratch, st->tables[0]->name)); err = stat(scratch.buf, &stat_result); check(!err); check_int((stat_result.st_mode & 0777), ==, opts.default_permissions); @@ -402,9 +402,9 @@ static void t_reftable_stack_transaction_api_performs_auto_compaction(void) * all tables in the stack. */ if (i != n) - check_int(st->merged->readers_len, ==, i + 1); + check_int(st->merged->tables_len, ==, i + 1); else - check_int(st->merged->readers_len, ==, 1); + check_int(st->merged->tables_len, ==, 1); } reftable_stack_destroy(st); @@ -430,7 +430,7 @@ static void t_reftable_stack_auto_compaction_fails_gracefully(void) err = reftable_stack_add(st, write_test_ref, &ref); check(!err); - check_int(st->merged->readers_len, ==, 1); + check_int(st->merged->tables_len, ==, 1); check_int(st->stats.attempts, ==, 0); check_int(st->stats.failures, ==, 0); @@ -441,14 +441,14 @@ static void t_reftable_stack_auto_compaction_fails_gracefully(void) */ check(!reftable_buf_addstr(&table_path, dir)); check(!reftable_buf_addstr(&table_path, "/")); - check(!reftable_buf_addstr(&table_path, st->readers[0]->name)); + check(!reftable_buf_addstr(&table_path, st->tables[0]->name)); check(!reftable_buf_addstr(&table_path, ".lock")); write_file_buf(table_path.buf, "", 0); ref.update_index = 2; err = reftable_stack_add(st, write_test_ref, &ref); check(!err); - check_int(st->merged->readers_len, ==, 2); + check_int(st->merged->tables_len, ==, 2); check_int(st->stats.attempts, ==, 1); check_int(st->stats.failures, ==, 1); @@ -592,7 +592,7 @@ static void t_reftable_stack_add(void) check(!reftable_buf_addstr(&path, dir)); check(!reftable_buf_addstr(&path, "/")); /* do not try at home; not an external API for reftable. */ - check(!reftable_buf_addstr(&path, st->readers[0]->name)); + check(!reftable_buf_addstr(&path, st->tables[0]->name)); err = stat(path.buf, &stat_result); check(!err); check_int((stat_result.st_mode & 0777), ==, opts.default_permissions); @@ -1026,7 +1026,7 @@ static void t_reftable_stack_auto_compaction(void) err = reftable_stack_auto_compact(st); check(!err); - check(i < 2 || st->merged->readers_len < 2 * fastlogN(i, 2)); + check(i < 2 || st->merged->tables_len < 2 * fastlogN(i, 2)); } check_int(reftable_stack_compaction_stats(st)->entries_written, <, @@ -1061,7 +1061,7 @@ static void t_reftable_stack_auto_compaction_factor(void) err = reftable_stack_add(st, &write_test_ref, &ref); check(!err); - check(i < 5 || st->merged->readers_len < 5 * fastlogN(i, 5)); + check(i < 5 || st->merged->tables_len < 5 * fastlogN(i, 5)); } reftable_stack_destroy(st); @@ -1082,7 +1082,7 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void) check(!err); write_n_ref_tables(st, 5); - check_int(st->merged->readers_len, ==, 5); + check_int(st->merged->tables_len, ==, 5); /* * Given that all tables we have written should be roughly the same @@ -1091,7 +1091,7 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void) */ check(!reftable_buf_addstr(&buf, dir)); check(!reftable_buf_addstr(&buf, "/")); - check(!reftable_buf_addstr(&buf, st->readers[2]->name)); + check(!reftable_buf_addstr(&buf, st->tables[2]->name)); check(!reftable_buf_addstr(&buf, ".lock")); write_file_buf(buf.buf, "", 0); @@ -1104,7 +1104,7 @@ static void t_reftable_stack_auto_compaction_with_locked_tables(void) err = reftable_stack_auto_compact(st); check(!err); check_int(st->stats.failures, ==, 0); - check_int(st->merged->readers_len, ==, 4); + check_int(st->merged->tables_len, ==, 4); reftable_stack_destroy(st); reftable_buf_release(&buf); @@ -1149,9 +1149,9 @@ static void t_reftable_stack_add_performs_auto_compaction(void) * all tables in the stack. */ if (i != n) - check_int(st->merged->readers_len, ==, i + 1); + check_int(st->merged->tables_len, ==, i + 1); else - check_int(st->merged->readers_len, ==, 1); + check_int(st->merged->tables_len, ==, 1); } reftable_stack_destroy(st); @@ -1172,12 +1172,12 @@ static void t_reftable_stack_compaction_with_locked_tables(void) check(!err); write_n_ref_tables(st, 3); - check_int(st->merged->readers_len, ==, 3); + check_int(st->merged->tables_len, ==, 3); /* Lock one of the tables that we're about to compact. */ check(!reftable_buf_addstr(&buf, dir)); check(!reftable_buf_addstr(&buf, "/")); - check(!reftable_buf_addstr(&buf, st->readers[1]->name)); + check(!reftable_buf_addstr(&buf, st->tables[1]->name)); check(!reftable_buf_addstr(&buf, ".lock")); write_file_buf(buf.buf, "", 0); @@ -1188,7 +1188,7 @@ static void t_reftable_stack_compaction_with_locked_tables(void) err = reftable_stack_compact_all(st, NULL); check_int(err, ==, REFTABLE_LOCK_ERROR); check_int(st->stats.failures, ==, 1); - check_int(st->merged->readers_len, ==, 3); + check_int(st->merged->tables_len, ==, 3); reftable_stack_destroy(st); reftable_buf_release(&buf); @@ -1222,10 +1222,10 @@ static void t_reftable_stack_compaction_concurrent(void) static void unclean_stack_close(struct reftable_stack *st) { /* break abstraction boundary to simulate unclean shutdown. */ - for (size_t i = 0; i < st->readers_len; i++) - reftable_reader_decref(st->readers[i]); - st->readers_len = 0; - REFTABLE_FREE_AND_NULL(st->readers); + for (size_t i = 0; i < st->tables_len; i++) + reftable_table_decref(st->tables[i]); + st->tables_len = 0; + REFTABLE_FREE_AND_NULL(st->tables); } static void t_reftable_stack_compaction_concurrent_clean(void) @@ -1275,7 +1275,7 @@ static void t_reftable_stack_read_across_reload(void) err = reftable_new_stack(&st1, dir, &opts); check(!err); write_n_ref_tables(st1, 2); - check_int(st1->merged->readers_len, ==, 2); + check_int(st1->merged->tables_len, ==, 2); reftable_stack_init_ref_iterator(st1, &it); err = reftable_iterator_seek_ref(&it, ""); check(!err); @@ -1283,10 +1283,10 @@ static void t_reftable_stack_read_across_reload(void) /* Set up a second stack for the same directory and compact it. */ err = reftable_new_stack(&st2, dir, &opts); check(!err); - check_int(st2->merged->readers_len, ==, 2); + check_int(st2->merged->tables_len, ==, 2); err = reftable_stack_compact_all(st2, NULL); check(!err); - check_int(st2->merged->readers_len, ==, 1); + check_int(st2->merged->tables_len, ==, 1); /* * Verify that we can continue to use the old iterator even after we @@ -1294,7 +1294,7 @@ static void t_reftable_stack_read_across_reload(void) */ err = reftable_stack_reload(st1); check(!err); - check_int(st1->merged->readers_len, ==, 1); + check_int(st1->merged->tables_len, ==, 1); err = reftable_iterator_next_ref(&it, &rec); check(!err); check_str(rec.refname, "refs/heads/branch-0000"); @@ -1325,19 +1325,19 @@ static void t_reftable_stack_reload_with_missing_table(void) err = reftable_new_stack(&st, dir, &opts); check(!err); write_n_ref_tables(st, 2); - check_int(st->merged->readers_len, ==, 2); + check_int(st->merged->tables_len, ==, 2); reftable_stack_init_ref_iterator(st, &it); err = reftable_iterator_seek_ref(&it, ""); check(!err); /* * Update the tables.list file with some garbage data, while reusing - * our old readers. This should trigger a partial reload of the stack, - * where we try to reuse our old readers. + * our old tables. This should trigger a partial reload of the stack, + * where we try to reuse our old tables. */ - check(!reftable_buf_addstr(&content, st->readers[0]->name)); + check(!reftable_buf_addstr(&content, st->tables[0]->name)); check(!reftable_buf_addstr(&content, "\n")); - check(!reftable_buf_addstr(&content, st->readers[1]->name)); + check(!reftable_buf_addstr(&content, st->tables[1]->name)); check(!reftable_buf_addstr(&content, "\n")); check(!reftable_buf_addstr(&content, "garbage\n")); check(!reftable_buf_addstr(&table_path, st->list_file)); @@ -1348,7 +1348,7 @@ static void t_reftable_stack_reload_with_missing_table(void) err = reftable_stack_reload(st); check_int(err, ==, -4); - check_int(st->merged->readers_len, ==, 2); + check_int(st->merged->tables_len, ==, 2); /* * Even though the reload has failed, we should be able to continue diff --git a/t/unit-tests/t-reftable-table.c b/t/unit-tests/t-reftable-table.c new file mode 100644 index 0000000000..7e1eb533d0 --- /dev/null +++ b/t/unit-tests/t-reftable-table.c @@ -0,0 +1,206 @@ +#include "test-lib.h" +#include "lib-reftable.h" +#include "reftable/blocksource.h" +#include "reftable/constants.h" +#include "reftable/iter.h" +#include "reftable/table.h" +#include "strbuf.h" + +static int t_table_seek_once(void) +{ + struct reftable_ref_record records[] = { + { + .refname = (char *) "refs/heads/main", + .value_type = REFTABLE_REF_VAL1, + .value.val1 = { 42 }, + }, + }; + struct reftable_block_source source = { 0 }; + struct reftable_ref_record ref = { 0 }; + struct reftable_iterator it = { 0 }; + struct reftable_table *table; + struct reftable_buf buf = REFTABLE_BUF_INIT; + int ret; + + t_reftable_write_to_buf(&buf, records, ARRAY_SIZE(records), NULL, 0, NULL); + block_source_from_buf(&source, &buf); + + ret = reftable_table_new(&table, &source, "name"); + check(!ret); + + reftable_table_init_ref_iterator(table, &it); + ret = reftable_iterator_seek_ref(&it, ""); + check(!ret); + ret = reftable_iterator_next_ref(&it, &ref); + check(!ret); + + ret = reftable_ref_record_equal(&ref, &records[0], REFTABLE_HASH_SIZE_SHA1); + check_int(ret, ==, 1); + + ret = reftable_iterator_next_ref(&it, &ref); + check_int(ret, ==, 1); + + reftable_ref_record_release(&ref); + reftable_iterator_destroy(&it); + reftable_table_decref(table); + reftable_buf_release(&buf); + return 0; +} + +static int t_table_reseek(void) +{ + struct reftable_ref_record records[] = { + { + .refname = (char *) "refs/heads/main", + .value_type = REFTABLE_REF_VAL1, + .value.val1 = { 42 }, + }, + }; + struct reftable_block_source source = { 0 }; + struct reftable_ref_record ref = { 0 }; + struct reftable_iterator it = { 0 }; + struct reftable_table *table; + struct reftable_buf buf = REFTABLE_BUF_INIT; + int ret; + + t_reftable_write_to_buf(&buf, records, ARRAY_SIZE(records), NULL, 0, NULL); + block_source_from_buf(&source, &buf); + + ret = reftable_table_new(&table, &source, "name"); + check(!ret); + + reftable_table_init_ref_iterator(table, &it); + + for (size_t i = 0; i < 5; i++) { + ret = reftable_iterator_seek_ref(&it, ""); + check(!ret); + ret = reftable_iterator_next_ref(&it, &ref); + check(!ret); + + ret = reftable_ref_record_equal(&ref, &records[0], REFTABLE_HASH_SIZE_SHA1); + check_int(ret, ==, 1); + + ret = reftable_iterator_next_ref(&it, &ref); + check_int(ret, ==, 1); + } + + reftable_ref_record_release(&ref); + reftable_iterator_destroy(&it); + reftable_table_decref(table); + reftable_buf_release(&buf); + return 0; +} + +static int t_table_block_iterator(void) +{ + struct reftable_block_source source = { 0 }; + struct reftable_table_iterator it = { 0 }; + struct reftable_ref_record *records; + const struct reftable_block *block; + struct reftable_table *table; + struct reftable_buf buf = REFTABLE_BUF_INIT; + struct { + uint8_t block_type; + uint16_t header_off; + uint16_t restart_count; + uint16_t record_count; + } expected_blocks[] = { + { + .block_type = REFTABLE_BLOCK_TYPE_REF, + .header_off = 24, + .restart_count = 10, + .record_count = 158, + }, + { + .block_type = REFTABLE_BLOCK_TYPE_REF, + .restart_count = 10, + .record_count = 159, + }, + { + .block_type = REFTABLE_BLOCK_TYPE_REF, + .restart_count = 10, + .record_count = 159, + }, + { + .block_type = REFTABLE_BLOCK_TYPE_REF, + .restart_count = 2, + .record_count = 24, + }, + { + .block_type = REFTABLE_BLOCK_TYPE_INDEX, + .restart_count = 1, + .record_count = 4, + }, + { + .block_type = REFTABLE_BLOCK_TYPE_OBJ, + .restart_count = 1, + .record_count = 1, + }, + }; + const size_t nrecords = 500; + int ret; + + REFTABLE_CALLOC_ARRAY(records, nrecords); + for (size_t i = 0; i < nrecords; i++) { + records[i].value_type = REFTABLE_REF_VAL1; + records[i].refname = xstrfmt("refs/heads/branch-%03"PRIuMAX, + (uintmax_t) i); + } + + t_reftable_write_to_buf(&buf, records, nrecords, NULL, 0, NULL); + block_source_from_buf(&source, &buf); + + ret = reftable_table_new(&table, &source, "name"); + check(!ret); + + ret = reftable_table_iterator_init(&it, table); + check(!ret); + + for (size_t i = 0; i < ARRAY_SIZE(expected_blocks); i++) { + struct reftable_iterator record_it = { 0 }; + struct reftable_record record = { + .type = expected_blocks[i].block_type, + }; + + ret = reftable_table_iterator_next(&it, &block); + check(!ret); + + check_int(block->block_type, ==, expected_blocks[i].block_type); + check_int(block->header_off, ==, expected_blocks[i].header_off); + check_int(block->restart_count, ==, expected_blocks[i].restart_count); + + ret = reftable_block_init_iterator(block, &record_it); + check(!ret); + + for (size_t j = 0; ; j++) { + ret = iterator_next(&record_it, &record); + if (ret > 0) { + check_int(j, ==, expected_blocks[i].record_count); + break; + } + check(!ret); + } + + reftable_iterator_destroy(&record_it); + reftable_record_release(&record); + } + + ret = reftable_table_iterator_next(&it, &block); + check_int(ret, ==, 1); + + for (size_t i = 0; i < nrecords; i++) + reftable_free(records[i].refname); + reftable_table_iterator_release(&it); + reftable_table_decref(table); + reftable_buf_release(&buf); + reftable_free(records); + return 0; +} + +int cmd_main(int argc UNUSED, const char *argv[] UNUSED) +{ + TEST(t_table_seek_once(), "table can seek once"); + TEST(t_table_reseek(), "table can reseek multiple times"); + TEST(t_table_block_iterator(), "table can iterate through blocks"); + return test_done(); +} diff --git a/tree-walk.h b/tree-walk.h index aaea689f9a..29a55328bd 100644 --- a/tree-walk.h +++ b/tree-walk.h @@ -176,11 +176,14 @@ struct traverse_info { }; /** - * Find an entry in a tree given a pathname and the sha1 of a tree to - * search. Returns 0 if the entry is found and -1 otherwise. The third - * and fourth parameters are set to the entry's sha1 and mode respectively. - */ -int get_tree_entry(struct repository *, const struct object_id *, const char *, struct object_id *, unsigned short *); + * Walk trees starting with "tree_oid" to find the entry for "name", and + * return the the object name and the mode of the found entry via the + * "oid" and "mode" parameters. Return 0 if the entry is found, and -1 + * otherwise. + */ +int get_tree_entry(struct repository *repo, const struct object_id *tree_oid, + const char *name, struct object_id *oid, + unsigned short *mode); /** * Generate the full pathname of a tree entry based from the root of the diff --git a/upload-pack.c b/upload-pack.c index 30e4630f3a..956da5b061 100644 --- a/upload-pack.c +++ b/upload-pack.c @@ -509,8 +509,7 @@ static int got_oid(struct upload_pack_data *data, { if (get_oid_hex(hex, oid)) die("git upload-pack: expected SHA1 object, got '%s'", hex); - if (!repo_has_object_file_with_flags(the_repository, oid, - OBJECT_INFO_QUICK | OBJECT_INFO_SKIP_FETCH_OBJECT)) + if (!has_object(the_repository, oid, 0)) return -1; return do_got_oid(data, oid); } @@ -150,7 +150,8 @@ static int process(struct walker *walker, struct object *obj) return 0; obj->flags |= SEEN; - if (repo_has_object_file(the_repository, &obj->oid)) { + if (has_object(the_repository, &obj->oid, + HAS_OBJECT_RECHECK_PACKED | HAS_OBJECT_FETCH_PROMISOR)) { /* We already have it, so we should scan it now. */ obj->flags |= TO_SCAN; } @@ -737,7 +737,26 @@ int is_empty_or_missing_file(const char *filename) int open_nofollow(const char *path, int flags) { #ifdef O_NOFOLLOW - return open(path, flags | O_NOFOLLOW); + int ret = open(path, flags | O_NOFOLLOW); + /* + * NetBSD sets errno to EFTYPE when path is a symlink. The only other + * time this errno occurs when O_REGULAR is used. Since we don't use + * it anywhere we can avoid an lstat here. FreeBSD does the same with + * EMLINK. + */ +# ifdef __NetBSD__ +# define SYMLINK_ERRNO EFTYPE +# elif defined(__FreeBSD__) +# define SYMLINK_ERRNO EMLINK +# endif +# if SYMLINK_ERRNO + if (ret < 0 && errno == SYMLINK_ERRNO) { + errno = ELOOP; + return -1; + } +# undef SYMLINK_ERRNO +# endif + return ret; #else struct stat st; if (lstat(path, &st) < 0) diff --git a/xdiff/xprepare.c b/xdiff/xprepare.c index c84549f6c5..e1d4017b2d 100644 --- a/xdiff/xprepare.c +++ b/xdiff/xprepare.c @@ -368,6 +368,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd xrecord_t **recs; xdlclass_t *rcrec; char *dis, *dis1, *dis2; + int need_min = !!(cf->flags & XDF_NEED_MINIMAL); if (!XDL_CALLOC_ARRAY(dis, xdf1->nrec + xdf2->nrec + 2)) return -1; @@ -379,7 +380,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd for (i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; i <= xdf1->dend; i++, recs++) { rcrec = cf->rcrecs[(*recs)->ha]; nm = rcrec ? rcrec->len2 : 0; - dis1[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; + dis1[i] = (nm == 0) ? 0: (nm >= mlim && !need_min) ? 2: 1; } if ((mlim = xdl_bogosqrt(xdf2->nrec)) > XDL_MAX_EQLIMIT) @@ -387,7 +388,7 @@ static int xdl_cleanup_records(xdlclassifier_t *cf, xdfile_t *xdf1, xdfile_t *xd for (i = xdf2->dstart, recs = &xdf2->recs[xdf2->dstart]; i <= xdf2->dend; i++, recs++) { rcrec = cf->rcrecs[(*recs)->ha]; nm = rcrec ? rcrec->len1 : 0; - dis2[i] = (nm == 0) ? 0: (nm >= mlim) ? 2: 1; + dis2[i] = (nm == 0) ? 0: (nm >= mlim && !need_min) ? 2: 1; } for (nreff = 0, i = xdf1->dstart, recs = &xdf1->recs[xdf1->dstart]; |
