Compare

52e324c8d60c30b8ea3bac654f183bfb3467dfae..88d06b1c911e8491029ef24e96e3f412ce24c2ae

pathspec: match and original in pathspec_item are const

No existing code modifies these two strings in pathspec elements
after they are created via these two pointers.  Declare them as
"const char *" to stress on this fact and cast away constness from
the code that frees these two strings.

Signed-off-by: Junio C Hamano <gitster@pobox.com>

Junio C Hamano <gitster@pobox.com> ยท 2026-09-03 18:13 UTC

Browse files
253 files changed, +3875 โˆ’11930
deleted .b4-config mode 100644
@@ -1,6 +0,0 @@
1 - # Note that these are default values that you can tweak via the typical
2 - # git-config(1) machinery. You thus shouldn't ever have to change this file.
3 - # See also https://b4.docs.kernel.org/en/latest/config.html.
4 - [b4]
5 - send-same-thread = shallow
6 - prep-cover-template = ./.b4-cover-template
deleted .b4-cover-template mode 100644
@@ -1,12 +0,0 @@
1 - ${cover}
2 -
3 - ---
4 - ${shortlog}
5 -
6 - ${diffstat}
7 -
8 - ${range_diff}
9 - ---
10 - base-commit: ${base_commit}
11 - change-id: ${change_id}
12 - ${prerequisites}
modified .gitattributes
@@ -2,7 +2,7 @@
2 2 *.[ch] whitespace=indent,trail,space,incomplete diff=cpp
3 3 *.sh whitespace=indent,trail,space,incomplete text eol=lf
4 4 *.perl text eol=lf diff=perl
5 - *.pl text eol=lf diff=perl
5 + *.pl text eof=lf diff=perl
6 6 *.pm text eol=lf diff=perl
7 7 *.py text eol=lf diff=python
8 8 *.bat text eol=crlf
modified .github/workflows/main.yml
@@ -5,20 +5,18 @@ on: [push, pull_request]
5 5 env:
6 6 DEVELOPER: 1
7 7
8 - # For pull requests, only the latest workflow run is allowed to proceed.
9 - # Older runs are canceled when a new revision is pushed.
8 + # If more than one workflow run is triggered for the very same commit hash
9 + # (which happens when multiple branches pointing to the same commit), only
10 + # the first one is allowed to run, the second will be kept in the "queued"
11 + # state. This allows a successful completion of the first run to be reused
12 + # in the second run via the `skip-if-redundant` logic in the `config` job.
10 13 #
11 - # For pushes, if more than one workflow run is triggered for the very same
12 - # commit hash (which happens when multiple branches point to the same commit),
13 - # only the first one is allowed to run. This allows a successful completion of
14 - # the first run to be reused in the second run via the `skip-if-redundant`
15 - # logic in the `config` job.
16 - #
17 - # For more details about the `concurrency` attribute, see:
14 + # The only caveat is that if a workflow run is triggered for the same commit
15 + # hash that another run is already being held, that latter run will be
16 + # canceled. For more details about the `concurrency` attribute, see:
18 17 # https://docs.github.com/en/actions/using-workflows/workflow-syntax-for-github-actions#concurrency
19 18 concurrency:
20 - group: ${{ github.workflow }}-${{ github.event.pull_request.number || github.sha }}
21 - cancel-in-progress: ${{ github.event_name == 'pull_request' }}
19 + group: ${{ github.sha }}
22 20
23 21 jobs:
24 22 ci-config:
@@ -409,7 +407,7 @@ jobs:
409 407 image: alpine:latest
410 408 # Supported until 2025-04-02.
411 409 - jobname: linux32
412 - image: i386/ubuntu:20.04
410 + image: i386/ubuntu:focal
413 411 # A RHEL 8 compatible distro. Supported until 2029-05-31.
414 412 - jobname: almalinux-8
415 413 image: almalinux:8
@@ -422,9 +420,7 @@ jobs:
422 420 CI_JOB_IMAGE: ${{matrix.vector.image}}
423 421 CUSTOM_PATH: /custom
424 422 runs-on: ubuntu-latest
425 - container:
426 - image: ${{ matrix.vector.image }}
427 - options: ${{ github.repository_visibility == 'private' && '--pids-limit 16384 --ulimit nproc=16384:16384 --ulimit nofile=32768:32768' || '' }}
423 + container: ${{matrix.vector.image}}
428 424 steps:
429 425 - name: prepare libc6 for actions
430 426 if: matrix.vector.jobname == 'linux32'
@@ -462,8 +458,8 @@ jobs:
462 458 if: needs.ci-config.outputs.enabled == 'yes'
463 459 env:
464 460 jobname: StaticAnalysis
465 - CI_JOB_IMAGE: ubuntu-latest
466 - runs-on: ubuntu-latest
461 + CI_JOB_IMAGE: ubuntu-22.04
462 + runs-on: ubuntu-22.04
467 463 concurrency:
468 464 group: static-analysis-${{ github.ref }}
469 465 cancel-in-progress: ${{ needs.ci-config.outputs.skip_concurrent == 'yes' }}
modified .gitignore
@@ -71,7 +71,6 @@
71 71 /git-for-each-ref
72 72 /git-for-each-repo
73 73 /git-format-patch
74 - /git-format-rev
75 74 /git-fsck
76 75 /git-fsck-objects
77 76 /git-fsmonitor--daemon
@@ -183,7 +182,6 @@
183 182 /git-update-server-info
184 183 /git-upload-archive
185 184 /git-upload-pack
186 - /git-url-parse
187 185 /git-var
188 186 /git-verify-commit
189 187 /git-verify-pack
modified .gitlab-ci.yml
@@ -42,15 +42,15 @@ test:linux:
42 42 - jobname: linux-reftable
43 43 image: ubuntu:rolling
44 44 CC: clang
45 - - jobname: linux-TEST-vars
46 - image: ubuntu:20.04
47 - CC: gcc
48 - CC_PACKAGE: gcc-8
49 45 - jobname: linux-breaking-changes
50 - image: ubuntu:rolling
46 + image: ubuntu:20.04
51 47 CC: gcc
52 48 - jobname: fedora-breaking-changes-meson
53 49 image: fedora:latest
50 + - jobname: linux-TEST-vars
51 + image: ubuntu:20.04
52 + CC: gcc
53 + CC_PACKAGE: gcc-8
54 54 - jobname: linux-leaks
55 55 image: ubuntu:rolling
56 56 CC: gcc
@@ -60,20 +60,13 @@ test:linux:
60 60 - jobname: linux-asan-ubsan
61 61 image: ubuntu:rolling
62 62 CC: clang
63 - - jobname: linux-meson
64 - image: ubuntu:rolling
65 - CC: gcc
66 63 - jobname: linux-musl-meson
67 64 image: alpine:latest
68 - # Supported until 2025-04-02.
69 65 - jobname: linux32
70 66 image: i386/ubuntu:20.04
71 - # A RHEL 8 compatible distro. Supported until 2029-05-31.
72 - - jobname: almalinux-8
73 - image: almalinux:8
74 - # Supported until 2026-08-31.
75 - - jobname: debian-11
76 - image: debian:11
67 + - jobname: linux-meson
68 + image: ubuntu:rolling
69 + CC: gcc
77 70 artifacts:
78 71 paths:
79 72 - t/failed-test-artifacts
@@ -86,10 +79,15 @@ test:osx:
86 79 stage: test
87 80 needs: [ ]
88 81 tags:
89 - - saas-macos-large-m2pro
82 + - saas-macos-medium-m1
90 83 variables:
91 - TEST_OUTPUT_DIRECTORY: "/tmp/test-output"
84 + TEST_OUTPUT_DIRECTORY: "/Volumes/RAMDisk"
92 85 before_script:
86 + # Create a 4GB RAM disk that we use to store test output on. This small hack
87 + # significantly speeds up tests by more than a factor of 2 because the
88 + # macOS runners use network-attached storage as disks, which is _really_
89 + # slow with the many small writes that our tests do.
90 + - sudo diskutil apfs create $(hdiutil attach -nomount ram://8192000) RAMDisk
93 91 - ./ci/install-dependencies.sh
94 92 script:
95 93 - ./ci/run-build-and-tests.sh
@@ -106,10 +104,10 @@ test:osx:
106 104 image: macos-15-xcode-16
107 105 CC: clang
108 106 - jobname: osx-reftable
109 - image: macos-26-xcode-26
107 + image: macos-15-xcode-16
110 108 CC: clang
111 109 - jobname: osx-meson
112 - image: macos-26-xcode-26
110 + image: macos-15-xcode-16
113 111 CC: clang
114 112 artifacts:
115 113 paths:
@@ -147,9 +145,6 @@ test:mingw64:
147 145 needs:
148 146 - job: "build:mingw64"
149 147 artifacts: true
150 - variables:
151 - # Windows runners don't have enough RAM to run EXPENSIVE tests.
152 - GIT_TEST_LONG: false
153 148 before_script:
154 149 - *windows_before_script
155 150 - git-sdk/usr/bin/bash.exe -l -c 'tar xf artifacts/artifacts.tar.gz'
@@ -166,16 +161,11 @@ test:mingw64:
166 161 TEST_OUTPUT_DIRECTORY: "C:/Git-Test"
167 162 tags:
168 163 - saas-windows-medium-amd64
169 - cache:
170 - key:
171 - files:
172 - - ci/install-dependencies.ps1
173 - paths:
174 - - .dependencies
175 164 before_script:
176 165 - *windows_before_script
177 - - ./ci/install-dependencies.ps1
178 - - $env:Path = "C:\Meson;C:\Rust\bin;$env:Path"
166 + - choco install -y git meson ninja rust-ms
167 + - Import-Module $env:ChocolateyInstall\helpers\chocolateyProfile.psm1
168 + - refreshenv
179 169 - New-Item -Path $env:TEST_OUTPUT_DIRECTORY -ItemType Directory
180 170
181 171 build:msvc-meson:
@@ -198,9 +188,6 @@ test:msvc-meson:
198 188 script:
199 189 - |
200 190 & "C:/Program Files/Git/usr/bin/bash.exe" -l -c 'ci/run-test-slice-meson.sh build $CI_NODE_INDEX $CI_NODE_TOTAL'
201 - variables:
202 - # Windows runners don't have enough RAM to run EXPENSIVE tests.
203 - GIT_TEST_LONG: false
204 191 after_script:
205 192 - |
206 193 if ($env:CI_JOB_STATUS -ne "success") {
@@ -227,7 +214,7 @@ test:fuzz-smoke-tests:
227 214 - ./ci/run-build-and-minimal-fuzzers.sh
228 215
229 216 static-analysis:
230 - image: ubuntu:latest
217 + image: ubuntu:22.04
231 218 stage: analyze
232 219 needs: [ ]
233 220 variables:
modified .mailmap
@@ -39,13 +39,12 @@ Chris Shoemaker <c.shoemaker@cox.net>
39 39 Chris Wright <chrisw@sous-sol.org> <chrisw@osdl.org>
40 40 Christian Ludwig <chrissicool@gmail.com> <chrissicool@googlemail.com>
41 41 Cord Seele <cowose@gmail.com> <cowose@googlemail.com>
42 - Christian Couder <christian.couder@gmail.com> <chriscool@tuxfamily.org>
42 + Christian Couder <chriscool@tuxfamily.org> <christian.couder@gmail.com>
43 43 Christian Stimming <stimming@tuhh.de> <chs@ckiste.goetheallee>
44 44 Christopher Dรญaz Riveros <chrisadr@gentoo.org> Christopher Diaz Riveros
45 45 Clemens Buchacher <drizzd@gmx.net> <drizzd@aon.at>
46 46 Clemens Buchacher <drizzd@gmx.net> <clemens.buchacher@intel.com>
47 47 Csaba Henk <csaba@gluster.com> <csaba@lowlife.hu>
48 - D. Ben Knoble <ben.knoble@gmail.com> <ben.knoble+github@gmail.com>
49 48 Dan Johnson <computerdruid@gmail.com>
50 49 Dana L. How <danahow@gmail.com> <how@deathvalley.cswitch.com>
51 50 Dana L. How <danahow@gmail.com> Dana How
@@ -66,8 +65,6 @@ Derrick Stolee <stolee@gmail.com> <dstolee@microsoft.com>
66 65 Deskin Miller <deskinm@umich.edu>
67 66 ฤoร n Trแบงn Cรดng Danh <congdanhqx@gmail.com> Doan Tran Cong Danh
68 67 Dirk Sรผsserott <newsletter@dirk.my1.cc>
69 - Elijah Newren <newren@gmail.com> <newren@palantir.com>
70 - Elijah Newren <newren@gmail.com> <newren@github.com>
71 68 Emily Shaffer <nasamuffin@google.com> <emilyshaffer@google.com>
72 69 Eric Blake <eblake@redhat.com> <ebb9@byu.net>
73 70 Eric Hanchrow <eric.hanchrow@gmail.com> <offby1@blarg.net>
@@ -280,7 +277,6 @@ Sven Verdoolaege <skimo@kotnet.org> <skimo@liacs.nl>
280 277 SZEDER Gรกbor <szeder.dev@gmail.com> <szeder@ira.uka.de>
281 278 Tao Qingyun <taoqy@ls-a.me> <845767657@qq.com>
282 279 Tay Ray Chuan <rctay89@gmail.com>
283 - Taylor Blau <me@ttaylorr.com> <ttaylorr@openai.com>
284 280 Ted Percival <ted@midg3t.net> <ted.percival@quest.com>
285 281 Theodore Ts'o <tytso@mit.edu>
286 282 Thomas Ackermann <th.acker@arcor.de> <th.acker66@arcor.de>
modified .tsan-suppressions
@@ -7,6 +7,7 @@
7 7 # A static variable is written to racily, but we always write the same value, so
8 8 # in practice it (hopefully!) doesn't matter.
9 9 race:^want_color$
10 + race:^transfer_debug$
10 11
11 12 # A boolean value, which tells whether the replace_map has been initialized or
12 13 # not, is read racily with an update. As this variable is written to only once,
modified Documentation/BreakingChanges.adoc
@@ -216,30 +216,6 @@ would be significant, we may decide to defer this change to a subsequent minor
216 216 release. This evaluation will also take into account our own experience with
217 217 how painful it is to keep Rust an optional component.
218 218
219 - * The default value of `safe.bareRepository` will change from `all` to
220 - `explicit`. It is all too easy for an attacker to trick a user into cloning a
221 - repository that contains an embedded bare repository with malicious hooks
222 - configured. If the user enters that subdirectory and runs any Git command, Git
223 - discovers the bare repository and the hooks fire. The user does not even need
224 - to run a Git command explicitly: many shell prompts run `git status` in the
225 - background to display branch and dirty state information, and `git status` in
226 - turn may invoke the fsmonitor hook if so configured, making the user
227 - vulnerable the moment they `cd` into the directory. The `safe.bareRepository`
228 - configuration variable was introduced in 8959555cee (setup_git_directory():
229 - add an owner check for the top-level directory, 2022-03-02) with a default of
230 - `all` to preserve backwards compatibility.
231 - +
232 - Changing the default to `explicit` means that Git will refuse to work with bare
233 - repositories that are discovered implicitly by walking up the directory tree.
234 - Bare repositories specified explicitly via the `--git-dir` command-line option
235 - or the `GIT_DIR` environment variable continue to work regardless of this
236 - setting. Repositories that look like a `.git` directory, a worktree, or a
237 - submodule directory are also unaffected.
238 - +
239 - Users who rely on implicit discovery of bare repositories can restore the
240 - previous behavior by setting `safe.bareRepository=all` in their global or
241 - system configuration.
242 -
243 219 === Removals
244 220
245 221 * Support for grafting commits has long been superseded by git-replace(1).
modified Documentation/CodingGuidelines
@@ -693,12 +693,6 @@ For C programs:
693 693 char *dogs[] = ...;
694 694 walk_all_dogs(dogs);
695 695
696 - - For file timestamps, do not use "st_mtim" (and other timestamp
697 - members in "struct stat") unconditionally; not everybody is POSIX
698 - (grep for USE_ST_TIMESPEC). If you only need a timestamp in whole
699 - second resolution, "st_mtime" should work fine everywhere.
700 -
701 -
702 696 For Perl programs:
703 697
704 698 - Most of the C guidelines above apply.
modified Documentation/Makefile
@@ -129,7 +129,6 @@ TECH_DOCS += technical/long-running-process-protocol
129 129 TECH_DOCS += technical/multi-pack-index
130 130 TECH_DOCS += technical/packfile-uri
131 131 TECH_DOCS += technical/pack-heuristics
132 - TECH_DOCS += technical/paint-down-to-common
133 132 TECH_DOCS += technical/parallel-checkout
134 133 TECH_DOCS += technical/partial-clone
135 134 TECH_DOCS += technical/platform-support
modified Documentation/MyFirstContribution.adoc
@@ -790,7 +790,7 @@ We can note a few things:
790 790 v3", etc. in place of "PATCH". For example, "[PATCH v2 1/3]" would be the first of
791 791 three patches in the second iteration. Each iteration is sent with a new cover
792 792 letter (like "[PATCH v2 0/3]" above), itself a reply to the cover letter of the
793 - first iteration (more on that below).
793 + previous iteration (more on that below).
794 794
795 795 NOTE: A single-patch topic is sent with "[PATCH]", "[PATCH v2]", etc. without
796 796 _i_/_n_ numbering (in the above thread overview, no single-patch topic appears,
@@ -833,7 +833,7 @@ This patchset is part of the MyFirstContribution tutorial and should not
833 833 be merged.
834 834 ----
835 835
836 - At this point the tutorial diverges, in order to demonstrate three
836 + At this point the tutorial diverges, in order to demonstrate two
837 837 different methods of formatting your patchset and getting it reviewed.
838 838
839 839 The first method to be covered is GitGitGadget, which is useful for those
@@ -845,14 +845,9 @@ more fine-grained control over the emails to be sent. This method requires some
845 845 setup which can change depending on your system and will not be covered in this
846 846 tutorial.
847 847
848 - The third method to be covered is `b4`, which builds on top of `git
849 - format-patch` and `git send-email`. This method is the recommended way to
850 - submit patches via mail as it automates a lot of the bookkeeping required by
851 - `git send-email`.
852 -
853 848 Regardless of which method you choose, your engagement with reviewers will be
854 - the same; the review process will be covered after the sections on GitGitGadget,
855 - `git send-email` and `b4`.
849 + the same; the review process will be covered after the sections on GitGitGadget
850 + and `git send-email`.
856 851
857 852 [[howto-ggg]]
858 853 == Sending Patches via GitGitGadget
@@ -1219,7 +1214,7 @@ between your last version and now, if it's something significant. You do not
1219 1214 need the exact same body in your second cover letter; focus on explaining to
1220 1215 reviewers the changes you've made that may not be as visible.
1221 1216
1222 - You will also need to go and find the Message-ID of your first cover letter.
1217 + You will also need to go and find the Message-ID of your previous cover letter.
1223 1218 You can either note it when you send the first series, from the output of `git
1224 1219 send-email`, or you can look it up on the
1225 1220 https://lore.kernel.org/git[mailing list]. Find your cover letter in the
@@ -1232,8 +1227,8 @@ Message-ID: <foo.12345.author@example.com>
1232 1227
1233 1228 Your Message-ID is `<foo.12345.author@example.com>`. This example will be used
1234 1229 below as well; make sure to replace it with the correct Message-ID for your
1235 - **first cover letter** - that is, for any subsequent version that you send,
1236 - always use the Message-ID from v1.
1230 + **previous cover letter** - that is, if you're sending v2, use the Message-ID
1231 + from v1; if you're sending v3, use the Message-ID from v2.
1237 1232
1238 1233 While you're looking at the email, you should also note who is CC'd, as it's
1239 1234 common practice in the mailing list to keep all CCs on a thread. You can add
@@ -1301,87 +1296,6 @@ index 88f126184c..38da593a60 100644
1301 1296 2.21.0.392.gf8f6787159e-goog
1302 1297 ----
1303 1298
1304 - [[howto-b4]]
1305 - == Sending Patches with `b4`
1306 -
1307 - `b4` is a tool that builds on top of `git format-patch` and `git send-email`.
1308 - It automates much of the bookkeeping involved in sending a patch series to a
1309 - mailing-list-based project.
1310 -
1311 - Refer to the https://b4.docs.kernel.org/[b4 documentation] for a full reference.
1312 -
1313 - [[prep-b4]]
1314 - === Preparing a Patch Series
1315 -
1316 - `b4` tracks your patch series as a branch. To start tracking the `psuh` branch
1317 - you have been working on, run:
1318 -
1319 - ----
1320 - $ b4 prep --enroll master
1321 - ----
1322 -
1323 - This enrolls the current branch, using `master` as the base of the topic. `b4`
1324 - manages the cover letter as part of the branch, so you can edit it at any time
1325 - with:
1326 -
1327 - ----
1328 - $ b4 prep --edit-cover
1329 - ----
1330 -
1331 - The cover letter not only tracks the content of the top-level mail, but also
1332 - the set of recipients. You can add recipients by adding `To:` and `Cc:`
1333 - trailer lines.
1334 -
1335 - [[send-b4]]
1336 - === Sending the Patches
1337 -
1338 - Before sending the series out for real, you can inspect what `b4` would send by
1339 - passing `--dry-run`:
1340 -
1341 - ----
1342 - $ b4 send --dry-run
1343 - ----
1344 -
1345 - Once you are happy with the result, send the series with:
1346 -
1347 - ----
1348 - $ b4 send
1349 - ----
1350 -
1351 - [[v2-b4]]
1352 - === Sending v2
1353 -
1354 - When you are ready to send a new iteration of your series, refine your
1355 - patches as usual using linkgit:git-rebase[1]. Note that you typically want to
1356 - rebase on top of the cover letter. You can configure an alias to enable easy
1357 - rebases going forward:
1358 -
1359 - ---
1360 - $ git config set alias.b4-rebase 'rebase "HEAD^{/--- b4-submit-tracking ---}"'
1361 - $ git b4-rebase -i
1362 - ---
1363 -
1364 - Before sending out the new version you should also update the cover letter with
1365 - `b4 prep --edit-cover` to note the relevant changes compared to the previous
1366 - version. You can inspect the changes between the two versions with `b4 prep
1367 - --compare-to=v1`.
1368 -
1369 - Same as with the first version, you can use `b4 send` to send out the second
1370 - version. `b4` automatically bumps the version to `v2`, generates the range-diff
1371 - against the previous iteration, and threads the new series as a reply to the
1372 - cover letter of the first version.
1373 -
1374 - [[configure-b4]]
1375 - === Configure b4
1376 -
1377 - `b4` can be configured via linkgit:git-config[1]. In addition to that, projects
1378 - can have their own set of defaults in `.b4-config` in the root tree, which also
1379 - uses Git's config format. The user's configuration always takes precedence over
1380 - the per-project defaults.
1381 -
1382 - Refer to the https://b4.docs.kernel.org/en/latest/config.html[b4 config documentation]
1383 - for more information on the available options.
1384 -
1385 1299 [[now-what]]
1386 1300 == My Patch Got Emailed - Now What?
1387 1301
@@ -1416,28 +1330,6 @@ previous one" patches over 2 days), reviewers would strongly prefer if a
1416 1330 single polished version came 2 days later instead, and that version with
1417 1331 fewer mistakes were the only one they would need to review.
1418 1332
1419 - This consideration applies not only when going from the initial patch to v2,
1420 - but also to later iterations of the same series. There is no fixed rule for how
1421 - long to wait before sending a new version. A useful default is to send at most
1422 - one new version of the same patch series per day. This gives multiple reviewers
1423 - time to comment, gives reviewers across time zones a fair chance to
1424 - participate, lets you batch feedback together, and gives you time to think
1425 - through the comments you received. Knowing that you should not immediately send
1426 - another version also encourages you to review the patches more carefully before
1427 - sending them, catch small mistakes such as typos and off-by-one errors
1428 - yourself, and let reviewers spend more of their attention on design,
1429 - algorithms, and other substantial issues.
1430 -
1431 - The right timing depends on the topic and the feedback. Larger series usually
1432 - need more review time. If the only comments so far are minor, such as typo
1433 - fixes, it often makes sense to wait a little longer in case deeper reviews are
1434 - still coming. If the comments call for substantial rework, do not rush out an
1435 - updated version before you have reviewed the larger changes carefully. Instead,
1436 - reply to the review that prompted the rewrite, say that you are preparing a
1437 - substantial rework, and mention which parts of the current series will become
1438 - obsolete so reviewers can avoid spending time on them until the updated series
1439 - is ready.
1440 -
1441 1333
1442 1334 [[reviewing]]
1443 1335 === Responding to Reviews
@@ -1445,13 +1337,11 @@ is ready.
1445 1337 After a few days, you will hopefully receive a reply to your patchset with some
1446 1338 comments. Woohoo! Now you can get back to work.
1447 1339
1448 - It's good manners to reply to each comment in the mailing list discussion
1449 - instead of letting the next version of your patch be your only response. Tell
1450 - the reviewer whether you plan to make the suggested change, keep the original,
1451 - or pursue a different approach. This way reviewers can respond to your reasoning
1452 - before you spend time preparing a version they may not agree with, and later do
1453 - not need to inspect your v2 to figure out whether you implemented their comment
1454 - or not.
1340 + It's good manners to reply to each comment, notifying the reviewer that you have
1341 + made the change suggested, feel the original is better, or that the comment
1342 + inspired you to do something a new way which is superior to both the original
1343 + and the suggested change. This way reviewers don't need to inspect your v2 to
1344 + figure out whether you implemented their comment or not.
1455 1345
1456 1346 Reviewers may ask you about what you wrote in the patchset, either in
1457 1347 the proposed commit log message or in the changes themselves. You
@@ -1477,11 +1367,6 @@ effect which had not occurred to you. It is always okay to ask for clarification
1477 1367 if you aren't sure why a change was suggested, or what the reviewer is asking
1478 1368 you to do.
1479 1369
1480 - When replying to review comments, quote only the parts of the message that are
1481 - relevant to your response. It is usually helpful to trim away unrelated context,
1482 - such as large portions of the patch that are not being discussed, while keeping
1483 - enough quoted text for readers to understand what you are responding to.
1484 -
1485 1370 Make sure your email client has a plaintext email mode and it is turned on; the
1486 1371 Git list rejects HTML email. Please also follow the mailing list etiquette
1487 1372 outlined in the
deleted Documentation/RelNotes/2.55.0.adoc mode 100644
@@ -1,460 +0,0 @@
1 - Git v2.55 Release Notes
2 - =======================
3 -
4 - UI, Workflows & Features
5 - ------------------------
6 -
7 - * Hook scripts defined via the configuration system can now be
8 - configured to run in parallel.
9 -
10 - * The userdiff driver for the Scheme language has been extended to
11 - cover other Lisp dialects.
12 -
13 - * Terminal control sequences coming over the sideband while talking
14 - to a remote repository are mostly disabled by default, except for
15 - ANSI color escape sequences.
16 -
17 - * "ort" merge backend improvements.
18 -
19 - * "git checkout -m another-branch" was invented to deal with local
20 - changes to paths that are different between the current and the new
21 - branch, but it gave only one chance to resolve conflicts. The command
22 - was taught to create a stash to save the local changes.
23 -
24 - * A new builtin "git format-rev" is introduced for pretty formatting
25 - one revision expression per line or commit object names found in
26 - running text.
27 -
28 - * "git history" learned "fixup" command.
29 -
30 - * The internal URL parsing logic has been made accessible via a new
31 - subcommand "git url-parse".
32 -
33 - * Misspelt proxy URL (e.g., httt://...) did not trigger any warning
34 - or failure, which has been corrected. We had a regression in this
35 - update that broke https:// proxies, but that has been caught and
36 - corrected.
37 -
38 - * Document the fact that .git/info/exclude is shared across worktrees
39 - linked to the same repository.
40 -
41 - * The command line parser for "git diff" learned a few options take
42 - only non-negative integers.
43 -
44 - * The graph output from commands like "git log --graph" can now be
45 - limited to a specified number of lanes, preventing overly wide output
46 - in repositories with many branches.
47 -
48 - * The fsmonitor daemon has been implemented for Linux.
49 -
50 - * "git cat-file --batch" learns an in-line command "mailmap"
51 - that lets the user toggle use of mailmap.
52 -
53 - * The "git pack-objects --path-walk" traversal has been integrated
54 - with several object filters, including blobless and sparse filters.
55 -
56 - * "git push" learned to take a "remote group" name to push to, which
57 - causes pushes to multiple places, just like "git fetch" would do.
58 -
59 - * The 'git-jump' command (in contrib/) has been taught to automatically
60 - pick a mode (merge, diff, or ws) when invoked without arguments.
61 -
62 - * The documentation for `push.default = simple` has been clarified to
63 - better explain its behavior, making it clear that it pushes the
64 - current branch to a same-named branch on the remote, and detailing
65 - the upstream requirements for centralized workflows.
66 -
67 - * The documentation for "--word-diff" has been extended with a bit of
68 - implementation detail of where these different words come from.
69 -
70 - * "git config foo.bar=baz" is not likely to be a request to read the
71 - value of such a variable with '=' in its name; rather it is plausible
72 - that the user meant "git config set foo.bar baz". Give advice when
73 - giving an error message.
74 -
75 - * "git rev-list" (and "git log" family of commands) learned a new "--max-count-oldest"
76 - that picks oldest N commits in the range instead of the usual newest.
77 -
78 - * Various AsciiDoc markup fixes in 'git config' documentation and
79 - related files to ensure lists and formatting are rendered correctly.
80 -
81 -
82 - Performance, Internal Implementation, Development Support etc.
83 - --------------------------------------------------------------
84 -
85 - * Promisor remote handling has been refactored and fixed in
86 - preparation for auto-configuration of advertised remotes.
87 -
88 - * Rust support is enabled by default (but still allows opting out);
89 - in Git version 3.0, Rust will become mandatory.
90 -
91 - * Preparation of the xdiff/ codebase to work with Rust.
92 -
93 - * Use a larger buffer size in the code paths to ingest pack stream.
94 -
95 - * Refactor service routines in the ref subsystem backends.
96 -
97 - * Shrink wasted memory in Myers diff that does not account for common
98 - prefix and suffix removal.
99 -
100 - * Enable expensive tests to catch topics that may cause breakages on
101 - integration branches closer to their origin in the contributor PR
102 - builds.
103 -
104 - * "git merge-base" optimization.
105 -
106 - * The limit_list() function that is one of the core part of the
107 - revision traversal infrastructure has been optimized by replacing
108 - its use of linear list with priority queue.
109 -
110 - * In a lazy clone, "git cherry" and "git grep" often fetch necessary
111 - blob objects one by one from promisor remotes. It has been corrected
112 - to collect necessary object names and fetch them in bulk to gain
113 - reasonable performance.
114 -
115 - * The logic to determine that branches in an octopus merge are
116 - independent has been optimized.
117 -
118 - * The consistency checks for the files reference backend have been updated
119 - to skip lock files earlier, avoiding unnecessary parsing of
120 - intermediate files.
121 -
122 - * The negotiation tip options in "git fetch" have been reworked to
123 - allow requiring certain refs to be sent as "have" lines, and to
124 - restrict negotiation to a specific set of refs.
125 -
126 - * The repacking code has been refactored and compaction of MIDX layers
127 - have been implemented, and incremental strategy that does not require
128 - all-into-one repacking has been introduced.
129 -
130 - * ODB transaction interface is being reworked to explicitly handle
131 - object writes.
132 -
133 - * Add a new odb "in-memory" source that is meant to only hold
134 - tentative objects (like the virtual blob object that represents the
135 - working tree file used by "git blame").
136 -
137 - * Many uses of the_repository has been updated to use a more
138 - appropriate struct repository instance in setup.c codepath.
139 -
140 - * Revision traversal optimization.
141 -
142 - * Build update.
143 -
144 - * The logic to lazy-load trees from the commit-graph has been made
145 - more robust by falling back to reading the commit object when
146 - the commit-graph is no longer available.
147 -
148 - * The "name" argument in git_connect() and related functions has been
149 - converted to a "service" enum to improve type safety and clarify its
150 - purpose.
151 -
152 - * 'git restore --staged' has been optimized to avoid unnecessarily expanding
153 - the sparse index when operating on paths within the sparse checkout
154 - definition, by handling sparse directory entries at the tree level.
155 -
156 - * "git stash -p" has been optimized by reusing cached index
157 - entries in its temporary index, avoiding unnecessary lstat()
158 - calls on unchanged files.
159 -
160 - * The check for non-stale commits in the priority queue used by
161 - `paint_down_to_common` and `ahead_behind` has been optimized by
162 - replacing an O(N) scan with an O(1) counter, yielding performance
163 - improvements in repositories with wide histories.
164 -
165 - * Reachability bitmap generation has been significantly optimized. By
166 - reordering tree traversal, caching object positions, and refining how
167 - pseudo-merge bitmaps are constructed, the performance of "git repack
168 - --write-midx-bitmaps" is improved, especially for large repositories
169 - and when using pseudo-merges.
170 -
171 - * Adding a decimal integer with strbuf_addf("%u") appears commonly;
172 - they have been optimized by using a custom formatter.
173 -
174 - * Formatting object name in full hexadecimal form has been optimized
175 - by using a new strbuf_add_oid_hex() helper function.
176 -
177 - * Encourage original authors to monitor the CI status.
178 -
179 - * The `git log -L` implementation has been refactored to use the
180 - standard diff output pipeline, enabling pickaxe and diff-filter to
181 - work as expected. Additionally, metadata-only diff formats like
182 - --raw and --name-only are now supported with -L.
183 -
184 - * The loose object source has been refactored into a proper `struct
185 - odb_source`.
186 -
187 - * Guidelines on how to write a cover letter for a multi-patch series
188 - have been added to SubmittingPatches, which also got a new marker
189 - to separate the section for typofixes.
190 -
191 - * The setup logic to discover and configure repositories has been
192 - refactored, and the initialization of the object database has been
193 - centralized.
194 -
195 - * Many core configuration variables have been migrated from global
196 - variables into 'repo_config_values' to tie them to a specific
197 - repository instance, avoiding cross-repository state leakage.
198 -
199 - * Streaming revision walks have been optimized by using a priority queue
200 - for date-sorting commits, speeding up walks repositories with many
201 - merges.
202 -
203 - * A recent regression in t7527 that broke TAP output has been fixed,
204 - some other test noise that also broke TAP output has been silenced,
205 - and 'prove' is now configured to fail on invalid TAP output to
206 - prevent future regressions.
207 -
208 - * A handful of inappropriate uses of the_repository have been
209 - rewritten to use the right repository structure instance in the
210 - unpack-trees.c codepath.
211 -
212 - * "git index-pack" has been optimized by retaining child bases in the
213 - delta cache instead of immediately freeing them, letting the existing
214 - cache limit policy decide eviction.
215 -
216 - * `git ls-files --modified` and `git ls-files --deleted` have been
217 - optimized to filter with pathspec before calling lstat() when there is
218 - only a single pathspec item, avoiding unnecessary filesystem access
219 - for entries that will not be shown.
220 -
221 - * The UNUSED macro in 'compat/posix.h' has been updated to use a
222 - newly introduced GIT_CLANG_PREREQ macro for compiler version
223 - checks, and the existing GIT_GNUC_PREREQ macro has been modernized
224 - to use explicit major/minor comparisons rather than bit-shifting.
225 -
226 - * Wean the Windows builds in GitLab CI procedure away from
227 - (unfortunately unreliable) Chocolatey to install dependencies.
228 - (merge 0e7b51fed2 ps/gitlab-ci-windows later to maint).
229 -
230 - * Build-fix for 32-bit Windows.
231 -
232 - * Xcode 15 and later has a linker set to complain when the same library
233 - archive is listed twice on the command line. Squelch the annoyance.
234 -
235 -
236 - Fixes since v2.54
237 - -----------------
238 -
239 - * Code clean-up to use the right instance of a repository instance in
240 - calls inside refs subsystem.
241 - (merge 57c590feb9 sp/refs-reduce-the-repository later to maint).
242 -
243 - * The check that implements the logic to see if an in-core cache-tree
244 - is fully ready to write out a tree object was broken, which has
245 - been corrected.
246 - (merge 521731213c dl/cache-tree-fully-valid-fix later to maint).
247 -
248 - * The test suite harness and many individual test scripts have been
249 - updated to work correctly when 'set -e' is in effect, which helps
250 - detect misspelled test commands.
251 - (merge ffe8005b9d ps/test-set-e-clean later to maint).
252 -
253 - * Revert a recent change that introduced a regression to help mksh users.
254 -
255 - * Update various GitHub Actions versions.
256 -
257 - * Avoid hitting the pathname limit for socks proxy socket during the
258 - test..
259 -
260 - * To help Windows 10 installations, avoid removing files whose
261 - contents are still mmap()'ed.
262 -
263 - * The 'git backfill' command now rejects revision-limiting options that
264 - are incompatible with its operation, uses standard documentation for
265 - revision ranges, and includes blobs from boundary commits by default
266 - to improve performance of subsequent operations.
267 - (merge a1ad4a0fca en/backfill-fixes-and-edges later to maint).
268 -
269 - * "git grep" update.
270 - (merge 9ff4b5ab1b rs/grep-column-only-match-fix later to maint).
271 -
272 - * Headers from glibc 2.43 when used with clang does not allow
273 - disabling C11 language features, causing build failures..
274 -
275 - * The 'http.emptyAuth=auto' configuration now correctly attempts
276 - Negotiate authentication before falling back to manual credentials.
277 - This allows seamless Kerberos ticket-based authentication without
278 - requiring users to explicitly set 'http.emptyAuth=true'.
279 - (merge 4919938d28 mc/http-emptyauth-negotiate-fix later to maint).
280 -
281 - * Ramifications of turning off commit-graph has been documented a bit
282 - more clearly.
283 - (merge 48c855bb8f kh/doc-commit-graph later to maint).
284 -
285 - * "git rebase --update-refs", when used with an rebase.instructionFormat
286 - with "%d" (describe) in it, tried to update local branch HEAD by
287 - mistake, which has been corrected.
288 - (merge 106b6885c7 ag/rebase-update-refs-limit-to-branches later to maint).
289 -
290 - * Tweak the way how sideband messages from remote are printed while
291 - we talk with a remote repository to avoid tickling terminal
292 - emulator glitches.
293 - (merge 31e8fcabd8 rs/sideband-clear-line-before-print later to maint).
294 -
295 - * The configuration variable submodule.fetchJobs was not read correctly,
296 - which has been corrected.
297 - (merge aa45a5902f sj/submodule-update-clone-config-fix later to maint).
298 -
299 - * Update code paths that assumed "unsigned long" was long enough for
300 - "size_t".
301 - (merge 7a094d68a2 js/objects-larger-than-4gb-on-windows later to maint).
302 -
303 - * Stop using unmaintained custom allocator in Windows build which was
304 - the last user of the code.
305 -
306 - * The computation to shorten the filenames shown in diffstat measured
307 - width of individual UTF-8 characters to add up, but forgot to take
308 - into account error cases (e.g., an invalid UTF-8 sequence, or a
309 - control character).
310 - (merge 09d86a3b98 en/diffstat-utf8-truncation-fix later to maint).
311 -
312 - * Some tests assume that bare repository accesses are by default
313 - allowed; rewrite some of them to avoid the assumption, rewrite
314 - others to explicitly set safe.bareRepository to allow them.
315 - (merge 985b38ca6c js/adjust-tests-to-explicitly-access-bare-repo later to maint).
316 -
317 - * Signing commit with custom encoding was passing the data to be
318 - signed at a wrong stage in the pipeline, which has been corrected.
319 - (merge 7735d7eee3 bc/sign-commit-with-custom-encoding later to maint).
320 -
321 - * Further update to the i18n alias support to avoid regressions.
322 -
323 - * "git fetch --deepen=<n>" in a full clone truncated the history to <n>
324 - commits deep, which has been corrected to be a no-op instead.
325 - (merge 2431f5e0e5 sp/shallow-deepen-on-non-shallow-repo-fix later to maint).
326 -
327 - * "git maintenance" that goes background did not use the lockfile to
328 - prevent multiple maintenance processes from running at the same
329 - time, which has been corrected.
330 - (merge 29364f1624 ps/maintenance-daemonize-lockfix later to maint).
331 -
332 - * Remove ineffective strbuf presizing that would have computed an
333 - allocation that would not have fit in the available memory anyway,
334 - or too small due to integer wraparound to cause immediate automatic
335 - growing.
336 - (merge a9ce8526dc jk/pretty-no-strbuf-presizing later to maint).
337 -
338 - * The HTTP walker misinterpreted the alternates file that gives an
339 - absolute path when the server URL does not have the final slash
340 - (i.e., "https://example.com" not "https://example.com/").
341 - (merge b92387cd55 jk/dumb-http-alternate-fix later to maint).
342 -
343 - * "git bisect" now uses the selected terms (e.g., old/new) more
344 - consistently in its output.
345 - (merge cb55991825 jr/bisect-custom-terms-in-output later to maint).
346 -
347 - * Update GitLab CI jobs that exercise macOS.
348 - (merge 62319b49bb ps/gitlab-ci-macOS-improvements later to maint).
349 -
350 - * "Friday noon" asked in the morning on Sunday was parsed to be one
351 - day before the specified time, which has been corrected.
352 - (merge b809304101 ta/approxidate-noon-fix later to maint).
353 -
354 - * The GIT_WORK_TREE variable prepared to invoke the push-to-checkout
355 - hook was leaking into the environment even when there was no hook
356 - used and broke the default push-to-deploy (i.e., let "git checkout"
357 - update the working tree only when the working tree is clean).
358 - (merge 44d04e4426 ar/receive-pack-worktree-env later to maint).
359 -
360 - * A batch of documentation pages has been updated to use the modern
361 - synopsis style.
362 - (merge 2ef248ae45 ja/doc-synopsis-style-again later to maint).
363 -
364 - * The "promisor.quiet" configuration variable was not used from
365 - relevant submodules when commands like "grep --recurse-submodules"
366 - triggered a lazy fetch, which has been corrected.
367 - (merge fa1468a1f7 th/promisor-quiet-per-repo later to maint).
368 -
369 - * Correct use of sockaddr API in "git daemon".
370 - (merge 422a5bf575 st/daemon-sockaddr-fixes later to maint).
371 -
372 - * A memory leak in `fetch_and_setup_pack_index()` when verification of
373 - the downloaded pack index fails has been plugged. Also an obsolete
374 - `unlink()` call on parse failure has been cleaned up.
375 -
376 - * In t3070-wildmatch, "via ls-files" test variants with patterns
377 - containing backslash escapes are now skipped on Windows, avoiding 36
378 - test failures caused by pathspec separator conversion.
379 - (merge 8c84e6802c kk/wildmatch-windows-ls-files-prereq later to maint).
380 -
381 - * A linker warning on macOS when building with Xcode 16.3 or newer has
382 - been avoided by passing -fno-common to the compiler when a
383 - sufficiently new linker is detected.
384 - (merge 5cd4d0d850 hn/macos-linker-warning later to maint).
385 -
386 - * Documentation and tests have been added to clarify that Git's internal
387 - raw timestamp format requires a `@` prefix for values less than
388 - 100,000,000 to prevent ambiguity with other formats like YYYYMMDD.
389 - (merge 4018dc29ee ls/doc-raw-timestamp-prefix later to maint).
390 -
391 - * Wording used in "format-patch --subject-prefix" documentation
392 - has been improved.
393 - (merge 4a1eb9304a lo/doc-format-patch-subject-prefix later to maint).
394 -
395 - * Advanced emulation of kill() used on Windows in GfW has been
396 - upstreamed to improve the symptoms like left-behind .lock files and
397 - that fails to let the child clean-up itself when it gets killed.
398 - (merge 363f1d8b3a js/win-kill-child-more-gently later to maint).
399 -
400 - * The 'git describe --contains --all' command has been fixed to
401 - properly honor the '--match' and '--exclude' options by passing
402 - them down to 'git name-rev' with the appropriate reference
403 - prefixes.
404 - (merge 1891707d1b jk/describe-contains-all-match-fix later to maint).
405 -
406 - * Various typos, grammatical errors, and duplicated words in both
407 - documentation and code comments have been corrected.
408 - (merge dc6068df67 wy/docs-typofixes later to maint).
409 -
410 - * The subprocess handshake during startup has been made gentler by using
411 - packet_read_line_gently() instead of packet_read_line() to prevent the
412 - parent Git process from dying abruptly when a configured subprocess
413 - (e.g., a clean/smudge filter) fails to start.
414 - (merge 061a68e443 mm/subprocess-handshake-fix later to maint).
415 -
416 - * The TSAN race in transfer_debug() within transport-helper.c has been
417 - resolved by initializing the debug flag early in
418 - bidirectional_transfer_loop() before spawning worker threads, allowing
419 - the removal of a TSAN suppression.
420 - (merge 85704eda18 ps/transport-helper-tsan-fix later to maint).
421 -
422 - * 'git describe' has been taught to pass the 'refs/tags/' prefix down to
423 - the ref iterator when '--all' is not requested, avoiding unnecessary
424 - iteration over non-tag refs.
425 - (merge 55088ac8a4 td/describe-tag-iteration later to maint).
426 -
427 - * compute_reachable_generation_numbers() in commit-graph used a 32-bit
428 - integer to accumulate parent generations, which is OK for generation
429 - number v1 (topological levels), but with generation number v2
430 - (adjusted committer timestamps), it truncated timestamps beyond
431 - 2106. Fixed by widening the accumulator to timestamp_t.
432 - (merge fbcc5408fc en/commit-graph-timestamp-fix later to maint).
433 -
434 - * Other code cleanup, docfix, build fix, etc.
435 - (merge 80f4b802e9 ja/doc-difftool-synopsis-style later to maint).
436 - (merge b96490241e jc/doc-timestamps-in-stat later to maint).
437 - (merge ef85286e51 ss/t7004-unhide-git-failures later to maint).
438 - (merge 7584d10bc2 mf/format-patch-cover-letter-format-docfix later to maint).
439 - (merge 8547908eb3 pw/rename-to-get-current-worktree later to maint).
440 - (merge 890229b3f3 sg/t6112-unwanted-tilde-expansion-fix later to maint).
441 - (merge ab9753e7bc kh/doc-restore-double-underscores-fix later to maint).
442 - (merge 4a9e097228 za/t2000-modernise-more later to maint).
443 - (merge b635fd0725 kh/doc-log-decorate-list later to maint).
444 - (merge 65ea197dca jk/commit-sign-overflow-fix later to maint).
445 - (merge 3ccb16052a jk/apply-leakfix later to maint).
446 - (merge 5e6e8dc786 tb/pseudo-merge-bugfixes later to maint).
447 - (merge 6d09e798bc pb/doc-diff-format-updates later to maint).
448 - (merge 34a891a2d3 rs/trailer-fold-optim later to maint).
449 - (merge 499f9048e0 ps/t3903-cover-stash-include-untracked later to maint).
450 - (merge b56ab270aa jk/sq-dequote-cleanup later to maint).
451 - (merge 29d9fdcf10 rs/use-builtin-add-overflow-explicitly-on-clang later to maint).
452 - (merge d9982e8290 ed/check-connected-close-err-fd-2.53 later to maint).
453 - (merge 1740cc35d0 ed/check-connected-close-err-fd later to maint).
454 - (merge f4d7eb3d1c sp/doc-range-diff-takes-notes later to maint).
455 - (merge 83e7f3bd2b kh/free-commit-list later to maint).
456 - (merge d1b72b29e9 am/doc-tech-hash-typofix later to maint).
457 - (merge 014c454799 ak/typofixes later to maint).
458 - (merge 522ea8ef7d js/osxkeychain-build-wo-rust later to maint).
459 - (merge e8f12e0e95 jc/t1400-fifo-cleanup later to maint).
460 - (merge 0bf506efd4 kw/gitattributes-typofix later to maint).
deleted Documentation/RelNotes/2.56.0.adoc mode 100644
@@ -1,784 +0,0 @@
1 - Git v2.56 Release Notes
2 - =======================
3 -
4 - UI, Workflows & Features
5 - ------------------------
6 -
7 - * Advice shown by "git status" when the local branch is behind or has
8 - diverged from its push branch has been updated to suggest "git pull
9 - <remote> <branch>".
10 -
11 - * The handling of promisor-remote protocol capability has been updated
12 - to allow the other side to add to the list of promisor remotes via the
13 - 'promisor.acceptFromServerURL' configuration variable.
14 -
15 - * The 'ort' merge backend has been hardened against corrupt trees by
16 - ensuring it aborts under appropriate error conditions.
17 -
18 - * The `fetch.followRemoteHEAD` configuration variable has been added to
19 - provide a default for the per-remote `remote.<name>.followRemoteHEAD`
20 - setting.
21 -
22 - * "git log --follow" has been updated to better handle non-linear
23 - history, in which the path being tracked gets renamed differently in
24 - multiple history lines.
25 -
26 - * The "git repo info" command has been taught new keys to output both
27 - absolute and relative paths for "gitdir" and "commondir", supported by
28 - a new path-formatting helper extracted from "git rev-parse".
29 -
30 - * When 'git push origin/main' or 'git branch origin main' is run, the
31 - command is now recognized as a potential typo, and advice has been
32 - added to offer a typo fix.
33 -
34 - * The 'git refs' toolbox has been extended with new 'create', 'delete',
35 - 'update', and 'rename' subcommands to create, delete, update, and
36 - rename references, respectively.
37 -
38 - * The experimental 'git history' command has been taught a new 'drop'
39 - subcommand to remove a commit, with its descendants replayed onto its
40 - parent.
41 -
42 - * The alignment of commit object name abbreviations in 'git blame'
43 - output has been optimized to reserve a column for marks (caret,
44 - question mark, or asterisk) only when such marks are actually shown.
45 -
46 - * Option parsing with 'git rev-parse --parseopt' and in most 'git'
47 - subcommands has been updated to exit with 0 (instead of 129) when the
48 - help option ('-h' or '--help') is requested directly by the user,
49 - aligning with standard Unix convention.
50 -
51 - * The '[includeIf "condition"]' conditional inclusion facility for
52 - configuration files has been taught to use the location of the
53 - worktree in its condition.
54 -
55 - * The usage string and SYNOPSIS for 'git fast-export' have been
56 - standardized to make them consistent with each other and with other
57 - commands.
58 -
59 - * 'git log --graph' has been modified to visually distinguish parentless
60 - 'root' commits (and commits that become roots due to history
61 - simplification) by indenting them, preventing them from appearing
62 - falsely related to unrelated commits rendered immediately above them.
63 -
64 - * Userdiff patterns for Swift have been added, with support for
65 - Swift-specific constructs such as attributes, modifiers, failable
66 - initializers, and generics.
67 -
68 - * Configuration file locking has been updated to retry for a short
69 - period, avoiding failures when multiple processes attempt to update
70 - the configuration simultaneously.
71 -
72 - * The 'remote-object-info' command has been added to 'git cat-file
73 - --batch-command', allowing clients to request object metadata
74 - (currently size) from a remote server via protocol v2 without
75 - downloading the entire object. Format placeholders are dynamically
76 - filtered on the client based on server-advertised capabilities,
77 - returning empty strings for inapplicable or unsupported fields.
78 -
79 - * 'git branch -d' has been taught to report when a branch cannot be
80 - deleted because it is being used in an active bisect run.
81 -
82 - * 'git mv' has been updated to check for a missing destination
83 - leading directory during the checking phase, allowing 'git mv -n'
84 - to report the failure. The error message when the rename(2)
85 - syscall fails has also been improved to name both the source and
86 - the destination.
87 -
88 - * 'git add' has been taught a new '--resolved' option to stage
89 - conflict-resolved paths, while leaving unrelated local changes
90 - unstaged. It scans the unmerged paths for leftover conflict
91 - markers and aborts if any are found.
92 -
93 - * The known limitations of the ref format migration in 'git refs' have
94 - been moved to be displayed as a warning admonition directly under the
95 - description of the 'migrate' subcommand, improving visibility. A
96 - reference to 'git-maintenance' has also been corrected to use the
97 - 'linkgit' macro.
98 -
99 - * The 'git bisect' command has been taught a
100 - '--reset-when-found[=<where>]' option that tells the command to
101 - automatically run 'git bisect reset' to jump back to the original
102 - state or to the found culprit.
103 -
104 - * The 'git branch' command has been taught the '--delete-merged' option
105 - to remove local branches that are already merged into their tracked
106 - remote-tracking branches.
107 -
108 - * The 'remote-object-info' command for 'git cat-file --batch-command'
109 - has been extended to support the '%(objecttype)' placeholder.
110 -
111 - * The usage string of 'git fast-import' has been updated to use the
112 - parse_options() API for displaying help, and its SYNOPSIS in the
113 - documentation has been standardized to match.
114 -
115 - * The error message given by 'git send-email' when a message file is
116 - missing a 'Subject:' header has been clarified, and the error string
117 - is now terminated with a newline so that Perl avoids appending its
118 - internal source location data.
119 -
120 - * The '--shallow-file' option of 'git' command requires a value, but the
121 - code did not check the presence of a value and instead segfaulted
122 - without one, which has been corrected.
123 -
124 - * 'git repack' has been taught '--drop-filtered' to delete local
125 - promisor blobs exceeding a limit (currently 'blob:limit=') in partial
126 - clones, reclaiming space. Guards prevent running during other
127 - operations or if referenced by the index.
128 -
129 - * The documentation for 'git format-rev' has been updated to use the
130 - [synopsis] block definition on code blocks to properly highlight
131 - placeholders, and a quoting inconsistency in the running text has
132 - been fixed.
133 -
134 - * The DWIM logic in 'git worktree add' sometimes tried to infer a
135 - remote-tracking branch when an explicit '-b' or '-B' option was
136 - given to create a new branch, causing the explicit branch name to
137 - be ignored, which has been corrected.
138 -
139 - * The command line completion (in contrib/) has been taught to handle
140 - the experimental 'git history' command.
141 -
142 - * 'git checkout' and 'git worktree add' makes guesses based on a name
143 - of a remote-tracking branch, but does not give an error when such a
144 - remote-tracking branch cannot be uniquely identified, which has
145 - been corrected.
146 -
147 -
148 - Performance, Internal Implementation, Development Support etc.
149 - --------------------------------------------------------------
150 -
151 - * The refactoring of 'setup.c' has been continued to drop remaining
152 - global state (`git_work_tree_cfg`, `is_bare_repository_cfg`), updating
153 - `is_bare_repository()` to no longer implicitly rely on
154 - `the_repository`.
155 -
156 - * Project-specific configuration for b4 has been introduced, and the
157 - documentation has been updated to recommend using it as a
158 - streamlined method for submitting patches.
159 -
160 - * The default format path of git cat-file --batch has been optimized
161 - to use strbuf_add_oid_hex() and strbuf_add_uint() instead of
162 - strbuf_addf(), yielding a noticeable speedup.
163 -
164 - * Commands that list branches and tags (like git branch and git tag)
165 - have been optimized to pass the namespace prefix when initializing
166 - their ref iterator, avoiding a loose-ref scaling regression in
167 - repositories with many unrelated loose references.
168 -
169 - * The packed object source has been refactored into a proper struct
170 - odb_source.
171 -
172 - * The global configuration variables protect_hfs and protect_ntfs have
173 - been migrated into struct repo_config_values to tie them to
174 - per-repository configuration state.
175 -
176 - * The trailer sections in SubmittingPatches have been updated to
177 - encourage use of standard trailers.
178 -
179 - * The documentation in SubmittingPatches has been updated to clarify how
180 - patch contributors should respond to design and viability critiques,
181 - and how the resolution of such critiques should be recorded in the
182 - final commit messages.
183 -
184 - * The pack-objects command has been updated to support reachability
185 - bitmaps and delta-islands concurrently with the `--path-walk` option,
186 - allowing faster packaging by falling back to path-walk when bitmaps
187 - cannot fully satisfy the request.
188 -
189 - * Documentation on community contribution guidelines has been updated to
190 - encourage replying to review comments before rerolling, and to advise
191 - a default limit of at most one reroll per day to give reviewers across
192 - different time zones enough time to participate.
193 -
194 - * The lazy priority queue optimization pattern (deferring actual removal
195 - in 'prio_queue_get()' to allow get+put fusion) has been folded
196 - directly into 'prio_queue' itself, speeding up commit traversal
197 - workflows and simplifying callers.
198 -
199 - * The 'reprepare()' callback for object database sources has been
200 - generalized into a 'prepare()' callback with an optional flush cache
201 - flag, and a new 'odb_prepare()' wrapper has been introduced to allow
202 - pre-opening object database sources.
203 -
204 - * The 'whence' field in 'struct object_info' has been removed. The
205 - backend-specific object information retrieval has been refactored into
206 - an opt-in 'struct object_info_source' structure.
207 -
208 - * A racy build failure under Meson has been corrected by ensuring that
209 - the generated header file 'hook-list.h' is built before compiling
210 - files in 'builtin_sources' that depend on it.
211 -
212 - * The repository discovery and repository configuration phases, which
213 - were previously intertwined in 'setup.c', have been split. Repository
214 - discovery has been updated to populate a 'struct repo_discovery'
215 - without modifying the repository state, which is then taken by
216 - repository configuration to initialize the repository, paving the way
217 - for clean unification of repository configuration.
218 -
219 - * The 'SubmittingPatches' document has been updated to explicitly
220 - describe the expectation for contributors to retract or abandon their
221 - patch series when they are no longer pursuing it.
222 -
223 - * The contributor guide has been updated to advise new contributors to
224 - trim irrelevant quoted text when replying to review comments, matching
225 - the existing advice given to reviewers.
226 -
227 - * The build system has been updated to support building universal macOS
228 - binaries when 'Rust' is enabled, by compiling separate static archives
229 - for each target triple listed in 'RUST_TARGETS' and combining them
230 - using the macOS 'lipo' tool. The 'git-credential-osxkeychain' helper
231 - has been updated to link against '$(RUST_LIB)' when 'Rust' is enabled.
232 -
233 - * The test suite has been updated to use the 'test_grep' helper instead
234 - of bare 'grep' for test assertions, allowing file contents to be
235 - printed on failure for easier debugging. A new 'greplint' linter has
236 - been introduced to detect and prevent new bare 'grep' assertions from
237 - being added to the test suite.
238 -
239 - * The pipelines in 't1410-reflog.sh' have been replaced with the
240 - 'test_stdout_line_count' helper to avoid suppressing the exit code of
241 - 'git' commands, ensuring failures are not hidden from the test suite.
242 -
243 - * The cache-scanning loop in 'next_cache_entry()' has been optimized
244 - to avoid rescanning already-unpacked index entries, preventing a
245 - quadratic performance slow-down when diffing the working tree
246 - against a commit with a pathspec matching early index entries.
247 -
248 - * The global configuration variable 'ignore_case' (representing the
249 - 'core.ignorecase' configuration) has been migrated into 'struct
250 - repo_config_values' to tie it to a specific repository instance.
251 -
252 - * The performance of ref updates and reads using the 'reftable' backend
253 - in the presence of many deletion tombstone records has been optimized
254 - by removing the tombstone suppression flag from the merged iterator
255 - and instead skipping tombstones at higher-level call sites where
256 - iteration bounds are known.
257 -
258 - * Various code paths have been hardened against potential NULL-pointer
259 - dereferences and invalid file descriptor accesses flagged by
260 - Coverity.
261 -
262 - * The in-tree 'b4' cover letter template has been updated to include the
263 - 'change-id' trailer, ensuring that sent tags generated by 'b4' contain
264 - the required tracking information for subsequent runs.
265 -
266 - * 'git receive-pack' has been refactored to use ODB transaction
267 - interfaces instead of directly managing 'tmp_objdir' for staging
268 - incoming objects, bringing it closer to being ODB backend agnostic.
269 -
270 - * The test script 't/t9811-git-p4-label-import.sh' has been
271 - modernized to use 'test_path_is_file' and 'test_path_is_missing'
272 - instead of raw 'test -f' and '! test -f' calls.
273 -
274 - * A redundant strbuf_reset() call in the 'HAVE_GETDELIM' path of
275 - strbuf_getwholeline() has been removed, as getdelim() overwrites the
276 - buffer and the length is updated afterward.
277 -
278 - * The object database enumeration interface odb_for_each_object() has
279 - been taught to accept object filters, allowing the underlying backends
280 - to optimize the traversal by using reachability bitmaps when
281 - available. 'git cat-file --batch-all-objects' has been updated to use
282 - this generic interface, simplifying its code and avoiding direct
283 - access to ODB backend internals.
284 -
285 - * The test script 't/t1100-commit-tree-options.sh' has been modernized
286 - by converting test cases to the modern style (using single quotes and
287 - tab indentation) and moving the creation of the expected file inside
288 - the setup test so it runs under the protection of the test harness.
289 -
290 - * The test script 't/t7614-merge-signoff.sh' has been updated to avoid
291 - suppressing the exit code of 'git' commands in a pipe.
292 -
293 - * The 'git rev-list --no-walk' command has been corrected to restore
294 - pathspec filtering, which was lost when the streaming walk was
295 - refactored.
296 -
297 - * The ref subsystem and the worktree API have been refactored to pass a
298 - repository pointer down the call chain, allowing them to drop
299 - references to the global 'the_repository' variable. As part of this,
300 - the handling of the 'core.packedRefsTimeout' configuration has been
301 - moved into the per-repository ref store structure.
302 -
303 - * 'git branch --contains' and 'git for-each-ref --contains' have been
304 - optimized to use the memoized commit traversal previously used only by
305 - 'git tag --contains', significantly speeding up connectivity checks
306 - across many candidate refs with shared history.
307 -
308 - * The passing of push destination specifications in the 'remote-curl'
309 - helper has been simplified by removing the explicit 'count' parameter
310 - and relying on the NULL-termination of the array.
311 -
312 - * The dependency on the global 'the_repository' variable in the
313 - 'refspec.c' API has been removed by passing the hash algorithm
314 - explicitly to refspec-parsing functions and storing it in 'struct
315 - refspec'.
316 -
317 - * The enumeration of untracked and ignored files in 'git status' has
318 - been optimized by avoiding quadratic complexity when inserting into
319 - string lists, reducing the construction cost from O(n^2) to O(n log
320 - n).
321 -
322 - * The copy_file() and copy_file_with_time() functions have been
323 - refactored to take a repository parameter, allowing the removal of the
324 - implicit dependency on the global 'the_repository' variable in
325 - 'copy.c'.
326 -
327 - * The tempfile and lockfile APIs have been refactored to stop depending
328 - on the 'the_repository' global variable, and their callers have been
329 - updated to use the repository-aware variants.
330 -
331 - * The 'trust_executable_bit' (coming from the 'core.filemode'
332 - configuration) has been migrated into 'struct repo_config_values' to
333 - tie it to a specific repository instance.
334 -
335 - * The 'excludes_file' and various other global configuration variables
336 - (including 'editor_program', 'pager_program', 'askpass_program', and
337 - 'push_default') have been migrated into the per-repository structure.
338 -
339 - * The 'git stash push' command has been optimized to avoid unnecessary
340 - sparse index expansion when pathspecs are wholly inside the
341 - sparse-checkout cone. Also, a potential out-of-bounds read in the
342 - sparse-index expansion check helper pathspec_needs_expanded_index()
343 - has been fixed by consistently using the parsed, prefixed path.
344 -
345 - * The logic to write loose objects has been refactored and moved from
346 - 'object-file.c' to the loose backend source file 'odb/source-loose.c',
347 - making the loose backend more self-contained. This is achieved by
348 - first refactoring force_object_loose() to use generic ODB write
349 - interfaces instead of loose-backend internals.
350 -
351 - * Object database housekeeping in 'git gc' and 'git maintenance' has
352 - been refactored to be pluggable. The files-backend-specific logic,
353 - including incremental and geometric repacking as well as object
354 - pruning, has been moved out of the command implementation and into the
355 - files object database source, enabling future alternative object
356 - database backends to implement their own housekeeping services.
357 -
358 - * The image version used by the static-analysis CI job has been bumped
359 - to ubuntu-latest (Ubuntu 24.04), which brings in a newer Coccinelle
360 - version that resolves a severe performance regression. A false
361 - positive warning from the 'CHECK_ASSERTION_SIDE_EFFECTS' build with
362 - GCC 15 in the Bloom filter code has also been silenced to facilitate
363 - the image upgrade.
364 -
365 - * The alias tests in 't/t0014-alias.sh' have been updated to dynamically
366 - query the list of deprecated commands using 'git
367 - --list-cmds=deprecated' to avoid test failures when running with
368 - 'WITH_BREAKING_CHANGES' in a build directory that contains stale
369 - executables of formerly deprecated commands.
370 -
371 - * The code path that deals with relative paths in the diff-lib has
372 - been cleaned up.
373 -
374 - * The get_commit_action() function has been refactored to be a pure
375 - predicate by moving the side-effecting line-level log range folding to
376 - simplify_commit(). This ensures that evaluating a commit's action
377 - before the walk reaches it does not prematurely mutate its tracked
378 - line ranges, making it safer for potential lookahead evaluations.
379 -
380 - * Synopsis and options in the documentation for 'git format-patch',
381 - 'git imap-send', 'git send-email', and 'git request-pull' have been
382 - updated to the modern style.
383 -
384 - * A new test helper commit_body() has been introduced to print the
385 - message body of a commit, and various tests have been updated to use
386 - it instead of spelling out the command pipeline manually and losing
387 - the exit status of the 'git cat-file' command on the upstream of the
388 - pipe.
389 -
390 - * Tests for 'git merge-base --is-ancestor' have been added to cover
391 - exit codes (0 for success, 1 for non-ancestor, 128 for errors) and
392 - to ensure it cannot be combined with '--all'.
393 -
394 - * The 'TRACE2_ANCESTRY' prerequisite in the 't0213' test script has been
395 - refined to avoid failures under user-mode emulation by verifying that
396 - the ancestry collector reports the expected process names rather than
397 - the emulator binary name.
398 -
399 - * Concurrent downloads of packfiles via packfile URIs and dumb HTTP are
400 - safer by avoiding concurrent appends to the staging file. Opening in
401 - read-write mode with separate file offsets prevents corruption and
402 - preserves resumability. 'fetch-pack' now tolerates pre-existing
403 - '.keep' files.
404 -
405 - * The 'ssh-agent' tests in 't7528' have been fixed to work when the
406 - user's login shell is csh-like, by explicitly passing '-s' to
407 - 'ssh-agent' to force Bourne shell syntax.
408 -
409 - * A compatibility wrapper for writev(3p) has been reintroduced,
410 - including fixes for CMake build and 'MAX_IO_SIZE' limits on NonStop.
411 - Calls to write(3p) in send_sideband() and cat_blob() have been
412 - refactored to use writev(3p) wrappers to reduce syscall overhead.
413 -
414 - * The creation of the on-disk data structures for the object database
415 - has been made pluggable, allowing future backends to customize their
416 - setup. As part of this, the initialization of the object database
417 - has been deferred, and the loading of the loose-object map has been
418 - detangled from repository initialization.
419 -
420 - * The 'struct odb_read_stream' and 'struct odb_write_stream'
421 - structures have been consolidated into a single unified 'struct
422 - odb_stream' structure, simplifying object database streaming APIs
423 - and enabling streaming of arbitrary object types.
424 -
425 - * The sequencer has been updated to release the object database before
426 - spawning 'git commit'. This prevents open file handles from
427 - blocking auto-maintenance tasks, such as repacking, on systems like
428 - Windows where open files cannot be easily unlinked.
429 -
430 - * The merge-base computation has been optimized by stopping the walk
431 - early when one side's exclusive commits in the queue are exhausted,
432 - yielding significant speedups for queries with one-sided histories.
433 -
434 - * A handful of code paths have been corrected to check return values
435 - from functions like curl_easy_duphandle(), deflateInit(), lseek(),
436 - dup(), and strbuf_getline_lf(), resolving several Coverity warnings
437 - about unchecked returns.
438 -
439 - * The setting of a now-unused member '.pretty_given' in the sequencer
440 - machinery has been removed.
441 -
442 - * The performance of adding numerous new packfiles has been improved
443 - by introducing a fast path for known-new packfiles to skip an
444 - unnecessary traversal in packfile_list_append(), avoiding a
445 - quadratic complexity regression on load.
446 -
447 - * The unused name parameter in 'struct chdir_notify_entry' has been
448 - removed from chdir_notify_register(), chdir_notify_unregister(), and
449 - related callback signatures across several subsystems, simplifying the
450 - API now that trace output no longer uses it.
451 -
452 - * A heap-use-after-free bug in the object name parsing code when
453 - reporting failures with a relative path to a sparse directory has
454 - been corrected.
455 -
456 - * The object database (odb) API has been refactored to distinguish
457 - between missing objects and corrupt ones by returning more
458 - descriptive error statuses. Both the packed and loose backends now
459 - faithfully propagate error details using a generic strbuf error
460 - mechanism, removing backend-specific leakage from central lookup
461 - paths.
462 -
463 - * The object database layer has been simplified by eagerly loading
464 - alternate object directories upon initialization, instead of
465 - deferring it to the first object lookup. This eliminates the need
466 - for scattered lazy-loading calls throughout the codebase and paves
467 - the way for integrating alternates with the pluggable backends.
468 -
469 - * The threshold for geometric repacking to trigger based on loose
470 - object count has been adjusted to match that of 'git gc --auto',
471 - preventing over-aggressive repacking during concurrent writes.
472 -
473 - * The 'git receive-pack' command has been updated to use a new ODB
474 - transaction interface for writing incoming packfiles, making it more
475 - backend-agnostic.
476 -
477 - * The mechanism to generate a packfile corresponding to the result of
478 - a fetch/push has been made pluggable through a set of object
479 - database callback functions, removing hardcoded references to
480 - 'pack-objects' and enabling alternative ODBs to serve packfiles
481 - themselves.
482 -
483 - * The pack-objects command has been updated to record the total bytes
484 - written to pack files in trace2 output, allowing performance
485 - analysis of different compression settings by comparing the
486 - resulting pack sizes.
487 -
488 - * The global variable 'fetch_if_missing' has been moved to a member in
489 - 'struct repository', continuing the libification process and
490 - allowing per-repository control (such as for submodules).
491 -
492 - * The reftable code has been optimized to avoid an unnecessary
493 - stat/reload of the stack when an addition already holds the
494 - list_file lock, reducing the number of newfstatat syscalls from
495 - linear to constant when writing refs.
496 -
497 - * The application of the edited patch in 'git add -e' has been
498 - refactored to use the internal apply API directly, avoiding the need
499 - to spawn a 'git apply' subprocess.
500 -
501 -
502 - Fixes since v2.55
503 - -----------------
504 -
505 - * A regression in the error diagnosis code for invalid .git files has
506 - been fixed, avoiding a potential NULL-pointer crash when reporting
507 - that a .git file does not point to a valid repository.
508 - (merge 54a441bcea jk/setup-gitfile-diag-fix later to maint).
509 -
510 - * Support for hashing loose or packed objects larger than 4GB on Windows
511 - and other LLP64 platforms has been improved by converting object header
512 - buffers and data-handling functions from 'unsigned long' to 'size_t'.
513 - (merge d99e13d0be po/hash-object-size-t later to maint).
514 -
515 - * The display of the rebase todo list in "git status" has been
516 - improved to correctly abbreviate object IDs for more commands and
517 - avoid misinterpreting refs as object IDs.
518 - (merge 6f34e5f9e3 pw/status-rebase-todo later to maint).
519 -
520 - * Reference backend configuration has been updated to load lazily to
521 - avoid recursive calls during repository initialization when 'onbranch'
522 - configuration conditions are evaluated. This has also fixed a memory
523 - leak and allowed the unused `chdir_notify_reparent()` machinery to be
524 - dropped.
525 - (merge d6522d01df ps/refs-onbranch-fixes later to maint).
526 -
527 - * The connectivity check has been refactored to search for promisor
528 - objects in a generic way using the object database interface,
529 - rather than iterating packfiles directly. This allows connectivity
530 - checks to work properly in repositories that do not use packfiles.
531 - (merge 66ee9cb930 ps/connected-generic-promisor-checks later to maint).
532 -
533 - * A test checking interactions between git rebase --quit and
534 - autostash in t3420-rebase-autostash.sh has been corrected to use
535 - test_path_is_missing instead of ! grep on a file that shouldn't
536 - exist in the conflicted state.
537 - (merge eaad121fef sg/t3420-do-not-grep-in-missing-file later to maint).
538 -
539 - * The GPG and SSH signature parsing code has been corrected to strip
540 - carriage return characters only when they immediately precede line
541 - feeds, instead of unconditionally stripping all carriage returns.
542 - (merge 5dea8b690b ad/gpg-strip-cr-before-lf later to maint).
543 -
544 - * A memory leak in the 'reftable_writer_new()' initialization function
545 - has been fixed by delaying the allocation of 'struct reftable_writer'
546 - until after input options are validated.
547 - (merge c6fb3b9c3e jk/reftable-leakfix later to maint).
548 -
549 - * A memory leak in the '--base' handling of 'git format-patch' has been
550 - plugged, and the leak reporting of the test suite when running under a
551 - TAP harness has been improved.
552 - (merge 973a0373ff jk/format-patch-leakfix later to maint).
553 -
554 - * A write file stream resource leak has been fixed as part of a code
555 - cleanup.
556 - (merge ebb4d2ffa3 jc/history-message-prep-fix later to maint).
557 -
558 - * Various memory leaks in the Bloom-filter code paths that are exposed
559 - when running tests with the 'GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS=1'
560 - environment variable have been plugged.
561 - (merge 459088ec2e jk/bloom-leak-fixes later to maint).
562 -
563 - * The wincred credential helper has been updated to avoid memory
564 - corruption when erasing credentials and to prevent silent
565 - credential loss when storing OAuth tokens, by correcting buffer
566 - allocations and arguments passed to safe-CRT APIs.
567 - (merge f635ab9ab4 js/wincred-fixes later to maint).
568 -
569 - * Various code paths that initialize a cryptographic hash context but
570 - bail out or finish without calling 'git_hash_final()' have been taught
571 - to call 'git_hash_discard()' to release allocated resources, fixing
572 - memory leaks when Git is built with non-default backends like
573 - 'OpenSSL' or 'libgcrypt'.
574 - (merge 600588d2aa jk/hash-algo-leak-fixes later to maint).
575 -
576 - * Various resource leaks, invalid file descriptor closures, and process
577 - handle ownership issues flagged by Coverity have been fixed.
578 - (merge 9184231173 js/coverity-fixes later to maint).
579 -
580 - * Dockerized CI jobs running in private GitHub repositories have been
581 - adjusted to use explicit process and file limits, preventing resource
582 - exhaustion errors on private runners.
583 - (merge bad766fbac js/ci-dockerized-pid-limit later to maint).
584 -
585 - * Various test scripts have been updated to clean up large temporary
586 - files and repositories, reducing peak disk usage during testing.
587 - Also, expensive tests have been disabled on platforms that lack
588 - sufficient resources (like 32-bit platforms and Windows CI runners),
589 - and the long test suite has been enabled in GitLab CI.
590 - (merge 84248444ad ps/t-fixes-for-git-test-long later to maint).
591 -
592 - * The UTF-8 precomposition wrapper on macOS has been updated to use a
593 - flexible array member to represent the name of a directory entry,
594 - preventing fortified libc checks from failing when the name is
595 - reallocated to be larger than 'NAME_MAX' bytes.
596 - (merge 1eb281159f ih/precompose-flex-array later to maint).
597 -
598 - * The 'git_hash_*()' wrappers have been updated to be used consistently
599 - across the codebase instead of direct calls to members of 'struct
600 - git_hash_algo', and 'git_hash_discard()' has been made idempotent to
601 - simplify cleanups.
602 - (merge 9e396aa553 jk/git-hash-cleanups later to maint).
603 -
604 - * The sideband demultiplexer has been updated to recognize ANSI SGR
605 - escape sequences that use colon-separated subfields (e.g., for
606 - 256-color or true-color codes).
607 - (merge 3792b2aea4 mm/sideband-ansi-sgr-colon-fix later to maint).
608 -
609 - * The 'reftable' code has been hardened against corrupted tables by
610 - fixing out-of-bounds writes, out-of-bounds reads, and abort calls
611 - during parsing.
612 - (merge ca93c27328 ps/reftable-hardening later to maint).
613 -
614 - * A description in the release notes for Git 2.55.0 has been
615 - retroactively updated to clarify that Rust support is enabled by
616 - default, but still optional, and will become mandatory in Git 3.0.
617 - (merge 18b2009d14 jc/relnotes-2.55-rust-fix later to maint).
618 -
619 - * The early-exit optimization in 'paint_down_to_common()' has been
620 - gated on the queue being generation-ordered, fixing a bug where
621 - 'git merge-base' (without '--all') could return incorrect results
622 - on repositories with v1 commit graphs and clock skew.
623 - (merge ae68032a8d kk/commit-reach-find-all-fix later to maint).
624 -
625 - * The client-side parser of the server-advertised bundle-URI list has
626 - been updated to drain the remaining response in order to avoid
627 - protocol desynchronization when the server sends a misconfigured list.
628 - Also, the server-side has been taught to omit empty configuration
629 - values instead of sending invalid key-value lines.
630 - (merge 50de1169e4 tc/bundle-uri-empty-fix later to maint).
631 -
632 - * The 'topo_levels' slab was propagated only to the topmost layer of a
633 - split commit-graph chain, causing topological levels for commits in
634 - base layers to be recomputed during incremental writes. This has been
635 - corrected.
636 -
637 - * The stream-based object signature verification path has been
638 - corrected to avoid double-closing the stream on read errors.
639 - (merge cfd52a74a0 ps/odb-stream-double-close-fix later to maint).
640 -
641 - * The '-i' shorthand for the '--init' option, which was accepted by the
642 - 'git submodule update' command until it was broken in a modernization
643 - of the option-parsing code, has been restored.
644 - (merge ff1da37f58 dm/submodule-update-i-shorthand later to maint).
645 -
646 - * An accidental use of the '%zu' format specifier in 'git
647 - submodule--helper' has been corrected to use 'PRIuMAX' and cast the
648 - value to 'uintmax_t' to avoid portability issues.
649 - (merge 3279c13c00 jc/submodule-helper-avoid-zu later to maint).
650 -
651 - * The rebase post-rewrite notes-copying logic has been corrected. When
652 - a commit is dropped during rebase (e.g., because its changes are
653 - already upstream), it is no longer recorded as rewritten, preventing
654 - its notes from being copied to an unrelated commit.
655 - (merge 42554b78fd pw/rebase-drop-notes-with-commit later to maint).
656 -
657 - * A few memory problems in the Rust interface to C hash functions have
658 - been corrected. The 'Clone' implementation of 'CryptoHasher' now
659 - properly initializes the context before cloning, and its 'Drop'
660 - implementation now discards the context to prevent leaks.
661 -
662 - * The object ID shortening and linking in the 'commitdiff' view of
663 - 'gitweb' has been corrected to work even when the index line carries
664 - a trailing file mode.
665 - (merge fda513d6fe tl/gitweb-shorten-hashes-with-modes later to maint).
666 -
667 - * When the push remote is specified as a URL, the fetch refspec of a
668 - uniquely matching configured remote is now used to find and update
669 - the remote-tracking branch (e.g., '@{push}').
670 -
671 - * Traversals with '--exclude-first-parent-only' have been corrected
672 - to properly stop after the first parent even when it has already
673 - been marked as 'SEEN'.
674 - (merge 47382f7398 jc/exclude-first-parent-seen later to maint).
675 -
676 - * A segfault when 'git clone --revision' talks to a server that does not
677 - support protocol v2 (falling back to protocol v0) has been corrected.
678 - (merge 1034ad383f af/clone-revision-v0-segfault-fix later to maint).
679 -
680 - * rewrites_release() in 'remote.c' has been updated to free 'struct
681 - rewrite' instances, their '.instead_of' arrays, and their contents.
682 - (merge dcef3bf041 jc/remote-insteadof-leakfix later to maint).
683 -
684 - * The remote-matching logic for submodules has been corrected to resolve
685 - 'url.*.insteadOf' aliases before comparing the inventoried URL from
686 - '.gitmodules' with the URLs of configured remotes.
687 -
688 - * 'git diff --relative' running with '--cached' has been corrected to
689 - avoid a segfault when encountering unmerged paths outside the
690 - prefix.
691 - (merge 447126ed7d jk/diff-relative-cached-unmerged later to maint).
692 -
693 - * Two bugs in how 'git rebase' handles skipped 'fixup' and 'squash'
694 - commands have been fixed. One bug caused an incorrect commit count to
695 - be shown in the template message when multiple commands were skipped,
696 - and another prevented the editor from opening when the final command
697 - in a chain containing 'fixup -c' was skipped.
698 -
699 - * Git for Windows has been updated to avoid auto-detecting the symlink
700 - type if the target path starts with a slash, preventing NTLM
701 - credential leaks when checking out repositories with crafted
702 - symbolic links pointing to network shares.
703 -
704 - * 'git cat-file --batch-command' that asked for 'contents' without
705 - 'type' segfaults, which has been corrected.
706 - (merge 2abc7f0304 jk/cat-file-batch-wo-type-fix later to maint).
707 -
708 - * A memory leak in 'git merge' when run without arguments (which
709 - triggers the default-to-upstream path) has been fixed. A test has
710 - been added to cover this case.
711 - (merge 68cce04a02 tc/merge-default-to-upstream-leakfix later to maint).
712 -
713 - * A boundary case check in reachability bitmap traversal has been
714 - corrected to properly handle the object at position zero, which was
715 - previously skipped, leading to redundant bitmap loading.
716 - (merge b56b48301e dl/pack-bitmap-position-zero later to maint).
717 -
718 - * A crash in the 'sparse-index' collapse code when encountering an
719 - invalidated cache-tree node (due to an intent-to-add path) has been
720 - fixed by avoiding collapsing such subtrees.
721 - (merge eede1e69fe ds/sparse-index-ita-crash later to maint).
722 -
723 - * Documentation for 'git replay' has been updated to refer to its
724 - configuration variables.
725 - (merge 48c0549f5c kh/doc-replay-config later to maint).
726 -
727 - * Documentation for 'git interpret-trailers' has been updated to explain
728 - the format of trailer keys (alphanumeric characters and hyphens),
729 - replace outdated terminology, define key terms upfront, and document
730 - how comment lines in the input are treated.
731 - (merge 4515c86fd9 kh/doc-trailers later to maint).
732 -
733 - * The 'pack-objects' and delta-encoding code paths have been updated to
734 - use 'size_t' instead of 'unsigned long' for object sizes and offset
735 - limits, avoiding potential truncation issues on 64-bit Windows.
736 - (merge d50ac11724 js/pack-objects-delta-size-t later to maint).
737 -
738 - * A client requesting the promisor-remote capability without a value
739 - caused a null pointer dereference, which has been corrected by
740 - rejecting a request without an argument.
741 - (merge dd6b35ff71 en/serve-promisor-remote-fix later to maint).
742 -
743 - * Various tests in 't7900-maintenance.sh' have been updated to use a
744 - throwaway repository, and auto-detaching of maintenance tasks is now
745 - disabled for these tests to fix flaky races with concurrent background
746 - maintenance jobs.
747 - (merge 2775d8bcd1 ps/t7900-deflake-maintenance later to maint).
748 -
749 - * The help text for the '-l' option of 'git diff' has been updated.
750 - (merge 764243bdf4 en/diff-l-opt-help later to maint).
751 -
752 - * 'git -C <dir> diff fi<TAB>' did not complete 'file', which has
753 - been corrected.
754 - (merge 354d1bf3a0 jc/complete-diff-tracked-paths later to maint).
755 -
756 - * 'git -C <dir> checkout fi<TAB>' did not complete 'file', which has
757 - been corrected.
758 - (merge 05e2ab1f31 jc/complete-checkout later to maint).
759 -
760 - * The trailer parsing machinery has been updated to avoid mistaking
761 - lines that begin with a URL (e.g., 'https://...') as trailer lines.
762 - This prevents intended textual URLs from being mangled or mistakenly
763 - treated as metadata keys.
764 -
765 - * The instructions for deprecated commands emitted by
766 - you_still_use_that() have been reworded to clarify that the removal
767 - decision is final and to provide more assertive guidance on finding
768 - a replacement.
769 - (merge 8ace32221c jc/you-still-use-that later to maint).
770 -
771 - * The zsh completion script (in 'contrib/') has been updated to
772 - correctly locate the Git command after global options like '-C' by
773 - properly skipping them, similar to how the bash completion does.
774 -
775 - * The git worktree repair command failed to rewrite the .git file of
776 - a working tree from a relative path to an absolute path when the
777 - command was run in the working tree itself. The
778 - read_gitfile_gently() function was modified to also return whether
779 - the path originally recorded in the file was absolute, and this new
780 - capability is used to correctly detect such mismatches.
781 -
782 - * Other code cleanup, docfix, build fix, etc.
783 - (merge 026636128f ss/submittingpatches-typofix later to maint).
784 - (merge d2af22cc21 jc/rerere-doc-typofix later to maint).
modified Documentation/SubmittingPatches
@@ -48,41 +48,13 @@ area.
48 48
49 49 . You get comments and suggestions for improvements. You may even get
50 50 them in an "on top of your change" patch form. You are expected to
51 - respond to them with "Reply-All" on the mailing list, instead of
52 - letting an updated patch series be your only response. Tell
53 - reviewers which suggestions you plan to use, which ones you disagree
54 - with, and when a comment leads you to consider a different approach.
55 - Use these replies and any follow-up discussion as input when
56 - preparing an updated set of patches.
57 - +
58 - Be particularly mindful of critiques regarding the high-level design
59 - or viability of your proposal (e.g., questioning if the feature is
60 - worth implementing, or if the chosen approach is appropriate). Defend
61 - your design decisions on the list first and work with reviewers and
62 - other members to improve the design before revising the implementation.
63 - This will avoid wasting effort on an implementation before its design is
64 - solid.
65 - +
66 - Make sure that any new version explains and justifies those design
67 - decisions more clearly, in the cover letter and in the revised commit
68 - messages. Aim to make the reviewers say "it is now clear why we may
69 - want to do this with the updated version".
70 - +
71 - Topics with unresolved fundamental design critiques will not be
72 - considered ready for merging.
51 + respond to them with "Reply-All" on the mailing list, while taking
52 + them into account while preparing an updated set of patches.
73 53 +
74 54 It is often beneficial to allow some time for reviewers to provide
75 55 feedback before sending a new version, rather than sending an updated
76 56 series immediately after receiving a review. This helps collect broader
77 - input, gives reviewers in different time zones a fair chance to comment,
78 - and avoids unnecessary churn from many rapid iterations. Waiting also
79 - encourages you to polish each version before sending it, so reviewers
80 - can focus on substantial issues rather than typos or other small
81 - mistakes.
82 - +
83 - As a rough default, avoid sending more than one new version of the same
84 - series per day, while considering the size of the series and the depth
85 - of review.
57 + input and avoids unnecessary churn from many rapid iterations.
86 58
87 59 . These early update iterations are expected to be full replacements,
88 60 not incremental updates on top of what you posted already. If you
@@ -117,26 +89,12 @@ of review.
117 89 can still continue to further improve them by adding more patches on
118 90 top, but by the time a topic gets merged to 'next', it is expected
119 91 that everybody agrees that the scope and the basic direction of the
120 - topic are appropriate, so such incremental updates are limited to
92 + topic are appropriate, so such an incremental updates are limited to
121 93 small corrections and polishing. After a topic cooks for some time
122 94 (like 7 calendar days) in 'next' without needing further tweaks on
123 - top, it gets merged to the 'master' branch and waits to become part
95 + top, it gets merged to the 'master' branch and wait to become part
124 96 of the next major release.
125 97
126 - But sometimes things do not work as planned:
127 -
128 - . If a mailing list discussion convinces you that your changes aren't
129 - ideal, please explicitly retract the topic to save the maintainer
130 - time and effort.
131 -
132 - . If you must drop a topic due to shifting priorities, lack of time,
133 - or other commitments, notify the list as a courtesy so others can
134 - take over. Anyone can resurrect the topic later when they have the
135 - capacity to do so.
136 -
137 - . Topics with unaddressed review comments that remain inactive for
138 - four weeks may be discarded by the maintainer.
139 -
140 98 In the following sections, many techniques and conventions are listed
141 99 to help your patches get reviewed effectively in such a life cycle.
142 100
@@ -279,7 +237,6 @@ Do not forget to update the documentation to describe the updated
279 237 behavior and make sure that the resulting documentation set formats
280 238 well (try the Documentation/doc-diff script).
281 239
282 - [[typofixes]]
283 240 We currently have a liberal mixture of US and UK English norms for
284 241 spelling and grammar, which is somewhat unfortunate. A huge patch that
285 242 touches the files all over the place only to correct the inconsistency
@@ -365,10 +322,6 @@ The body should provide a meaningful commit message, which:
365 322
366 323 . alternate solutions considered but discarded, if any.
367 324
368 - . records the resolution of design or viability concerns raised by the
369 - community during the review, if any, ensuring the historical record
370 - explains why the chosen approach was accepted over alternatives.
371 -
372 325 [[present-tense]]
373 326 The problem statement that describes the status quo is written in the
374 327 present tense. Write "The code does X when it is given input Y",
@@ -421,7 +374,7 @@ or, on an older version of Git without support for --pretty=reference:
421 374 ....
422 375
423 376 [[sign-off]]
424 - === Certify your work by adding your `Signed-off-by:` trailer
377 + === Certify your work by adding your `Signed-off-by` trailer
425 378
426 379 To improve tracking of who did what, we ask you to certify that you
427 380 wrote the patch or have the right to pass it on under the same license
@@ -458,7 +411,7 @@ d. I understand and agree that this project and the contribution
458 411 this project or the open source license(s) involved.
459 412 ____
460 413
461 - you add a `Signed-off-by:` trailer to your commit, that looks like
414 + you add a "Signed-off-by" trailer to your commit, that looks like
462 415 this:
463 416
464 417 ....
@@ -468,23 +421,19 @@ this:
468 421 This line can be added by Git if you run the git-commit command with
469 422 the -s option.
470 423
471 - Notice that you can place your own `Signed-off-by:` trailer when
424 + Notice that you can place your own `Signed-off-by` trailer when
472 425 forwarding somebody else's patch with the above rules for
473 426 D-C-O. Indeed you are encouraged to do so. Do not forget to
474 427 place an in-body "From: " line at the beginning to properly attribute
475 428 the change to its true author (see (2) above).
476 429
477 - Place this `Signed-off-by:` trailer at the end, after trailers added by
478 - others and after other trailers added by you; see
479 - <<commit-trailers,Commit trailers>> below ("chronological order").
480 -
481 430 This procedure originally came from the Linux kernel project, so our
482 431 rule is quite similar to theirs, but what exactly it means to sign-off
483 432 your patch differs from project to project, so it may be different
484 433 from that of the project you are accustomed to.
485 434
486 435 [[real-name]]
487 - Please use a known identity in the `Signed-off-by:` trailer, since we cannot
436 + Please use a known identity in the `Signed-off-by` trailer, since we cannot
488 437 accept anonymous contributions. It is common, but not required, to use some form
489 438 of your real name. We realize that some contributors are not comfortable doing
490 439 so or prefer to contribute under a pseudonym or preferred name and we can accept
@@ -495,15 +444,7 @@ The goal of this policy is to allow us to have sufficient information to contact
495 444 you if questions arise about your contribution.
496 445
497 446 [[commit-trailers]]
498 - === Commit trailers
499 - It is polite to credit people who have helped with your work to a
500 - substantial enough degree. This project uses commit trailers for that,
501 - where the credited person is written out like a Git author, i.e. with
502 - both their name and their email address. Note that the threshold to
503 - credit someone is a judgement call, and crediting someone for simple
504 - review work is certainly not necessary.
505 -
506 - These are the common trailers in use:
447 + If you like, you can put extra trailers at the end:
507 448
508 449 . `Reported-by:` is used to credit someone who found the bug that
509 450 the patch attempts to fix.
@@ -516,10 +457,6 @@ These are the common trailers in use:
516 457 and found it to have the desired effect.
517 458 . `Co-authored-by:` is used to indicate that people exchanged drafts
518 459 of a patch before submitting it.
519 - . `Based-on-patch-by:` is used when someone else authored parts of the
520 - patch that you are submitting. This might be relevant if someone sent
521 - a patch to the mailing list with their sign-off. (Be mindful and ask
522 - them to sign off on it if they did not.)
523 460 . `Helped-by:` is used to credit someone who suggested ideas for
524 461 changes without providing the precise changes in patch form.
525 462 . `Mentored-by:` is used to credit someone with helping develop a
@@ -531,42 +468,8 @@ While you can also create your own trailer if the situation warrants it, we
531 468 encourage you to instead use one of the common trailers in this project
532 469 highlighted above.
533 470
534 - Other projects might regularly refer to other kinds of data, like
535 - `Fixes:` and `Link:` in the Linux Kernel project, but these ones in
536 - particular are not used in this project.
537 -
538 471 Only capitalize the very first letter of the trailer, i.e. favor
539 - `Signed-off-by:` over `Signed-Off-By:` and `Acked-by:` over `Acked-By:`.
540 -
541 - As mentioned under <<dco,DCO>> above, trailers are added in
542 - chronological order; one person might sign-off on a patch and send it to
543 - someone else, who then in turn adds her own sign-off. Further, any
544 - trailers that you add beyond your sign-off should come before that
545 - sign-off. That makes it clear what trailers which person added.
546 -
547 - [[cover-letter]]
548 - === Cover Letter
549 -
550 - The purpose of your cover letter is to sell your changes, explain what
551 - they are about, and get your target audience interested enough to read
552 - the patches.
553 -
554 - . Every code change comes with risk of regression and maintenance cost.
555 - The cover letter should clearly communicate why the value of your
556 - proposed change is worth applying. You can also describe how the risk
557 - is reduced by the design choices you made while writing the patches.
558 -
559 - . Make sure your target audience can understand what the patches are
560 - about and why they are needed without prior context.
561 -
562 - . For a second or subsequent iteration of the same topic, make sure
563 - people who missed the earlier discussion can still understand what
564 - the patches are about, so they can judge if the topic is worth their
565 - time to read and comment on.
566 -
567 - . To help those who are familiar with earlier iterations, give a
568 - summary of changes since the previous rounds.
569 -
472 + "Signed-off-by" over "Signed-Off-By" and "Acked-by:" over "Acked-By".
570 473
571 474 [[ai]]
572 475 === Use of Artificial Intelligence (AI)
@@ -659,8 +562,8 @@ when the maintainer did not heavily participate in the discussion and
659 562 instead left the review to trusted others.
660 563
661 564 Do not forget to add trailers such as `Acked-by:`, `Reviewed-by:` and
662 - `Tested-by:` (see <<commit-trailers,Commit trailers>>), and "cc:" them
663 - when sending such a final version for inclusion.
565 + `Tested-by:` lines as necessary to credit people who helped your
566 + patch, and "cc:" them when sending such a final version for inclusion.
664 567
665 568 ==== `format-patch` and `send-email`
666 569
@@ -670,10 +573,8 @@ your existing e-mail client (often optimized for "multipart/*" MIME
670 573 type e-mails) might render your patches unusable.
671 574
672 575 NOTE: Here we outline the procedure using `format-patch` and
673 - `send-email`, but you can instead use GitGitGadget or `b4` to send in
674 - your patches (see link:MyFirstContribution.html[MyFirstContribution]).
675 - Contributors are encouraged to use `b4`, which automates much of the
676 - bookkeeping that is otherwise done by hand.
576 + `send-email`, but you can instead use GitGitGadget to send in your
577 + patches (see link:MyFirstContribution.html[MyFirstContribution]).
677 578
678 579 People on the Git mailing list need to be able to read and
679 580 comment on the changes you are submitting. It is important for
@@ -687,13 +588,10 @@ grouped into their own e-mail thread to help readers find all parts of the
687 588 series. To that end, send them as replies to either an additional "cover
688 589 letter" message (see below), the first patch, or the respective preceding patch.
689 590 Here is a link:MyFirstContribution.html#v2-git-send-email[step-by-step guide] on
690 - how to submit updated versions of a patch series. Before sending another
691 - version, make sure you have answered meaningful review comments in the existing
692 - discussion. Also give reviewers enough time to comment before sending another
693 - version.
591 + how to submit updated versions of a patch series.
694 592
695 593 If your log message (including your name on the
696 - `Signed-off-by:` trailer) is not writable in ASCII, make sure that
594 + `Signed-off-by` trailer) is not writable in ASCII, make sure that
697 595 you send off a message in the correct encoding.
698 596
699 597 WARNING: Be wary of your MUAs word-wrap
@@ -713,7 +611,7 @@ previously sent.
713 611 The `git format-patch` command follows the best current practice to
714 612 format the body of an e-mail message. At the beginning of the
715 613 patch should come your commit message, ending with the
716 - `Signed-off-by:` trailers, and a line that consists of three dashes,
614 + `Signed-off-by` trailers, and a line that consists of three dashes,
717 615 followed by the diffstat information and the patch itself. If
718 616 you are forwarding a patch from somebody else, optionally, at
719 617 the beginning of the e-mail message just before the commit
@@ -919,17 +817,6 @@ relevant for debugging.
919 817 Then fix the problem and push your fix to your GitHub fork. This will
920 818 trigger a new CI build to ensure all tests pass.
921 819
922 - Even if you do not use GitHub CI to test your changes, pay close
923 - attention to new failures on the branches when the maintainer pushes
924 - out after your topic gets merged to the 'seen' branch to make sure
925 - that your topic is not breaking the CI, and retract your breaking
926 - topic quickly while you fix the breakage you caused.
927 -
928 - To see maintainer's push, keep an eye on this page:
929 -
930 - `https://github.com/git/git/actions/workflows/main.yml?query=event%3Apush+actor%3Agitster`
931 -
932 -
933 820 [[mua]]
934 821 == MUA specific hints
935 822
modified Documentation/asciidoc.conf.in
@@ -84,9 +84,6 @@ ifdef::doctype-manpage[]
84 84 [blockdef-open]
85 85 synopsis-style=template="verseparagraph",filter="sed 's!&#8230;\\(\\]\\|$\\)!<phrase>\\0</phrase>!g;s!\\([\\[ |()]\\|^\\|\\]\\|&gt;\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|&#8230;\\)!\\1<literal>\\2</literal>!g;s!&lt;[-a-zA-Z0-9.]\\+&gt;!<emphasis>\\0</emphasis>!g'"
86 86
87 - [blockdef-listing]
88 - synopsis-style=template="verseparagraph",filter="sed 's!&#8230;\\(\\]\\|$\\)!<phrase>\\0</phrase>!g;s!\\([\\[ |()]\\|^\\|\\]\\|&gt;\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|&#8230;\\)!\\1<literal>\\2</literal>!g;s!&lt;[-a-zA-Z0-9.]\\+&gt;!<emphasis>\\0</emphasis>!g'"
89 -
90 87 [paradef-default]
91 88 synopsis-style=template="verseparagraph",filter="sed 's!&#8230;\\(\\]\\|$\\)!<phrase>\\0</phrase>!g;s!\\([\\[ |()]\\|^\\|\\]\\|&gt;\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|&#8230;\\)!\\1<literal>\\2</literal>!g;s!&lt;[-a-zA-Z0-9.]\\+&gt;!<emphasis>\\0</emphasis>!g'"
92 89 endif::doctype-manpage[]
@@ -96,9 +93,6 @@ ifdef::backend-xhtml11[]
96 93 [blockdef-open]
97 94 synopsis-style=template="verseparagraph",filter="sed 's!&#8230;\\(\\]\\|$\\)!<span>\\0</span>!g;s!\\([\\[ |()]\\|^\\|\\]\\|&gt;\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|&#8230;\\)!\\1<code>\\2</code>!g;s!&lt;[-a-zA-Z0-9.]\\+&gt;!<em>\\0</em>!g'"
98 95
99 - [blockdef-listing]
100 - synopsis-style=template="verseparagraph",filter="sed 's!&#8230;\\(\\]\\|$\\)!<span>\\0</span>!g;s!\\([\\[ |()]\\|^\\|\\]\\|&gt;\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|&#8230;\\)!\\1<code>\\2</code>!g;s!&lt;[-a-zA-Z0-9.]\\+&gt;!<em>\\0</em>!g'"
101 -
102 96 [paradef-default]
103 97 synopsis-style=template="verseparagraph",filter="sed 's!&#8230;\\(\\]\\|$\\)!<span>\\0</span>!g;s!\\([\\[ |()]\\|^\\|\\]\\|&gt;\\)\\([-=a-zA-Z0-9:+@,\\/_^\\$.\\\\\\*]\\+\\|&#8230;\\)!\\1<code>\\2</code>!g;s!&lt;[-a-zA-Z0-9.]\\+&gt;!<em>\\0</em>!g'"
104 98 endif::backend-xhtml11[]
modified Documentation/config.adoc
@@ -146,51 +146,6 @@ refer to linkgit:gitignore[5] for details. For convenience:
146 146 This is the same as `gitdir` except that matching is done
147 147 case-insensitively (e.g. on case-insensitive file systems)
148 148
149 - `worktree`::
150 - The data that follows the keyword `worktree` and a colon is used as a
151 - glob pattern. If the working directory of the current worktree matches
152 - the pattern, the include condition is met.
153 - +
154 - The worktree location is the path where files are checked out (as returned
155 - by `git rev-parse --show-toplevel`). This is different from `gitdir`, which
156 - matches the `.git` directory path. In a linked worktree, the worktree path
157 - is the directory where that worktree's files are located, not the main
158 - repository's `.git` directory.
159 - +
160 - The pattern uses the same glob syntax as `gitdir` (including `~/`, `./`,
161 - `**/`, and trailing-`/` prefix matching). This condition will never match
162 - in a bare repository (which has no worktree).
163 - +
164 - Unlike `gitdir`, the `worktree` condition currently matches only the
165 - realpath-resolved worktree location. If the working tree was entered via a
166 - symbolic link, a pattern that uses the symbolic-link spelling may not match;
167 - use the real path instead.
168 - +
169 - This is useful when you want to apply configuration based on where the
170 - working tree is located on the filesystem. For example, a contributor who
171 - works on the same project both personally and as an employee can use
172 - different `user.name` and `user.email` values depending on which directory
173 - the worktree is checked out under:
174 - +
175 - ----
176 - [includeIf "worktree:/home/user/work/"]
177 - path = ~/.config/git/work.inc
178 - [includeIf "worktree:/home/user/personal/"]
179 - path = ~/.config/git/personal.inc
180 - ----
181 - +
182 - While `extensions.worktreeConfig` (see linkgit:git-worktree[1]) also supports
183 - per-worktree configuration, it stores the config inside each repository's
184 - `.git/config.worktree` file and requires running `git config --worktree`
185 - inside each worktree individually. In contrast, `includeIf "worktree:..."`
186 - can be set once in a global or system-level configuration file (e.g.
187 - `~/.config/git/config`) and applies to all repositories at once based on
188 - their worktree location.
189 -
190 - `worktree/i`::
191 - This is the same as `worktree` except that matching is done
192 - case-insensitively (e.g. on case-insensitive file systems)
193 -
194 149 `onbranch`::
195 150 The data that follows the keyword `onbranch` and a colon is taken to be a
196 151 pattern with standard globbing wildcards and two additional
@@ -289,14 +244,6 @@ Example
289 244 [includeIf "gitdir:~/to/group/"]
290 245 path = /path/to/foo.inc
291 246
292 - ; include if the worktree is at /path/to/project-build
293 - [includeIf "worktree:/path/to/project-build"]
294 - path = build-config.inc
295 -
296 - ; include for all worktrees inside /path/to/group
297 - [includeIf "worktree:/path/to/group/"]
298 - path = group-config.inc
299 -
300 247 ; relative paths are always relative to the including
301 248 ; file (if the condition is true); their location is not
302 249 ; affected by the condition
@@ -329,15 +276,13 @@ boolean::
329 276 When a variable is said to take a boolean value, many
330 277 synonyms are accepted for 'true' and 'false'; these are all
331 278 case-insensitive.
332 - +
333 - --
279 +
334 280 true;; Boolean true literals are `yes`, `on`, `true`,
335 281 and `1`. Also, a variable defined without `= <value>`
336 282 is taken as true.
337 283
338 284 false;; Boolean false literals are `no`, `off`, `false`,
339 285 `0` and the empty string.
340 - --
341 286 +
342 287 When converting a value to its canonical form using the `--type=bool` type
343 288 specifier, 'git config' will ensure that the output is "true" or
@@ -506,8 +451,6 @@ include::config/guitool.adoc[]
506 451
507 452 include::config/help.adoc[]
508 453
509 - include::config/hook.adoc[]
510 -
511 454 include::config/http.adoc[]
512 455
513 456 include::config/i18n.adoc[]
@@ -568,8 +511,6 @@ include::config/remotes.adoc[]
568 511
569 512 include::config/repack.adoc[]
570 513
571 - include::config/replay.adoc[]
572 -
573 514 include::config/rerere.adoc[]
574 515
575 516 include::config/revert.adoc[]
@@ -582,8 +523,6 @@ include::config/sequencer.adoc[]
582 523
583 524 include::config/showbranch.adoc[]
584 525
585 - include::config/sideband.adoc[]
586 -
587 526 include::config/sparse.adoc[]
588 527
589 528 include::config/splitindex.adoc[]
modified Documentation/config/advice.adoc
@@ -48,10 +48,6 @@ all advice messages.
48 48 to create a local branch after the fact.
49 49 diverging::
50 50 Shown when a fast-forward is not possible.
51 - fetchRemoteHEADWarn::
52 - Shown when linkgit:git-fetch[1] reveals that a remote `HEAD`
53 - differs from what is set locally and the user has opted into
54 - receiving a warning in this situation.
55 51 fetchShowForcedUpdates::
56 52 Shown when linkgit:git-fetch[1] takes a long time
57 53 to calculate forced updates after ref updates, or to warn
@@ -94,11 +90,6 @@ all advice messages.
94 90 Shown when linkgit:git-push[1] rejects a forced update of
95 91 a branch when its remote-tracking ref has updates that we
96 92 do not have locally.
97 - pushRepoLooksLikeRef::
98 - Shown when the repository given to linkgit:git-push[1] is not
99 - a configured remote but looks like a `<remote>/<branch>` ref,
100 - suggesting that the remote and branch be given as separate
101 - arguments.
102 93 pushUnqualifiedRefname::
103 94 Shown when linkgit:git-push[1] gives up trying to
104 95 guess based on the source and destination refs what
modified Documentation/config/am.adoc
@@ -1,11 +1,11 @@
1 - `am.keepcr`::
1 + am.keepcr::
2 2 If true, linkgit:git-am[1] will call linkgit:git-mailsplit[1]
3 3 for patches in mbox format with parameter `--keep-cr`. In this
4 4 case linkgit:git-mailsplit[1] will
5 5 not remove `\r` from lines ending with `\r\n`. Can be overridden
6 6 by giving `--no-keep-cr` from the command line.
7 7
8 - `am.threeWay`::
8 + am.threeWay::
9 9 By default, linkgit:git-am[1] will fail if the patch does not
10 10 apply cleanly. When set to true, this setting tells
11 11 linkgit:git-am[1] to fall back on 3-way merge if the patch
@@ -13,7 +13,7 @@
13 13 have those blobs available locally (equivalent to giving the
14 14 `--3way` option from the command line). Defaults to `false`.
15 15
16 - `am.messageId`::
16 + am.messageId::
17 17 Add a `Message-ID` trailer based on the email header to the
18 18 commit when using linkgit:git-am[1] (see
19 19 linkgit:git-interpret-trailers[1]). See also the `--message-id`
modified Documentation/config/apply.adoc
@@ -1,16 +1,11 @@
1 - `apply.ignoreWhitespace`::
2 - When set to `change`, tells `git apply` to ignore changes in
1 + apply.ignoreWhitespace::
2 + When set to 'change', tells 'git apply' to ignore changes in
3 3 whitespace, in the same way as the `--ignore-space-change`
4 4 option.
5 - When set to one of: `no`, `none`, `never`, `false`, it tells `git apply` to
5 + When set to one of: no, none, never, false, it tells 'git apply' to
6 6 respect all whitespace differences.
7 - ifndef::git-apply[]
8 7 See linkgit:git-apply[1].
9 - endif::git-apply[]
10 8
11 - `apply.whitespace`::
12 - Tells `git apply` how to handle whitespace, in the same way
13 - as the `--whitespace` option.
14 - ifndef::git-apply[]
15 - See linkgit:git-apply[1].
16 - endif::git-apply[]
9 + apply.whitespace::
10 + Tells 'git apply' how to handle whitespace, in the same way
11 + as the `--whitespace` option. See linkgit:git-apply[1].
modified Documentation/config/bitmap-pseudo-merge.adoc
@@ -47,8 +47,8 @@ will be updated more often than a reference pointing at an old commit.
47 47 bitmapPseudoMerge.<name>.sampleRate::
48 48 Determines the proportion of non-bitmapped commits (among
49 49 reference tips) which are selected for inclusion in an
50 - unstable pseudo-merge bitmap. Must be greater than `0` and
51 - less than or equal to `1`. The default is `1`.
50 + unstable pseudo-merge bitmap. Must be between `0` and `1`
51 + (inclusive). The default is `1`.
52 52
53 53 bitmapPseudoMerge.<name>.threshold::
54 54 Determines the minimum age of non-bitmapped commits (among
modified Documentation/config/branch.adoc
@@ -55,7 +55,6 @@ This option defaults to `never`.
55 55 repository), you would want to set `remote.pushDefault` to
56 56 specify the remote to push to for all branches, and use this
57 57 option to override it for a specific branch.
58 - The value may be the name of a configured remote or a repository URL.
59 58
60 59 `branch.<name>.merge`::
61 60 Defines, together with `branch.<name>.remote`, the upstream branch
@@ -103,10 +102,3 @@ for details).
103 102 `git branch --edit-description`. Branch description is
104 103 automatically added to the `format-patch` cover letter or
105 104 `request-pull` summary.
106 -
107 - `branch.<name>.deleteMerged`::
108 - If set to `false`, branch _<name>_ is exempt from
109 - `git branch --delete-merged`. Useful for a topic branch you
110 - intend to develop further after an initial round has been
111 - merged upstream. Defaults to true. Explicit deletion via
112 - `git branch -d` is unaffected.
modified Documentation/config/core.adoc
@@ -589,14 +589,6 @@ core.packedRefsTimeout::
589 589 all; -1 means to try indefinitely. Default is 1000 (i.e.,
590 590 retry for 1 second).
591 591
592 - core.configLockTimeout::
593 - The length of time, in milliseconds, to retry when trying to
594 - lock a configuration file for writing. Value 0 means not to
595 - retry at all; -1 means to try indefinitely. Default is 1000
596 - (i.e., retry for 1 second). This is read from the configuration
597 - that is already on disk before the lock is taken, so it can be
598 - set persistently like any other option.
599 -
600 592 core.pager::
601 593 Text viewer for use by Git commands (e.g., 'less'). The value
602 594 is meant to be interpreted by the shell. The order of preference
modified Documentation/config/difftool.adoc
@@ -1,43 +1,43 @@
1 - `diff.tool`::
1 + diff.tool::
2 2 Controls which diff tool is used by linkgit:git-difftool[1].
3 3 This variable overrides the value configured in `merge.tool`.
4 4 The list below shows the valid built-in values.
5 5 Any other value is treated as a custom diff tool and requires
6 - that a corresponding `difftool.<tool>.cmd` variable is defined.
6 + that a corresponding difftool.<tool>.cmd variable is defined.
7 7
8 - `diff.guitool`::
8 + diff.guitool::
9 9 Controls which diff tool is used by linkgit:git-difftool[1] when
10 - the `-g`/`--gui` flag is specified. This variable overrides the value
10 + the -g/--gui flag is specified. This variable overrides the value
11 11 configured in `merge.guitool`. The list below shows the valid
12 12 built-in values. Any other value is treated as a custom diff tool
13 - and requires that a corresponding `difftool.<guitool>.cmd` variable
13 + and requires that a corresponding difftool.<guitool>.cmd variable
14 14 is defined.
15 15
16 16 include::{build_dir}/mergetools-diff.adoc[]
17 17
18 - `difftool.<tool>.cmd`::
18 + difftool.<tool>.cmd::
19 19 Specify the command to invoke the specified diff tool.
20 20 The specified command is evaluated in shell with the following
21 - variables available: `LOCAL` is set to the name of the temporary
22 - file containing the contents of the diff pre-image and `REMOTE`
21 + variables available: 'LOCAL' is set to the name of the temporary
22 + file containing the contents of the diff pre-image and 'REMOTE'
23 23 is set to the name of the temporary file containing the contents
24 24 of the diff post-image.
25 25 +
26 26 See the `--tool=<tool>` option in linkgit:git-difftool[1] for more details.
27 27
28 - `difftool.<tool>.path`::
28 + difftool.<tool>.path::
29 29 Override the path for the given tool. This is useful in case
30 30 your tool is not in the PATH.
31 31
32 - `difftool.trustExitCode`::
32 + difftool.trustExitCode::
33 33 Exit difftool if the invoked diff tool returns a non-zero exit status.
34 34 +
35 35 See the `--trust-exit-code` option in linkgit:git-difftool[1] for more details.
36 36
37 - `difftool.prompt`::
37 + difftool.prompt::
38 38 Prompt before each invocation of the diff tool.
39 39
40 - `difftool.guiDefault`::
40 + difftool.guiDefault::
41 41 Set `true` to use the `diff.guitool` by default (equivalent to specifying
42 42 the `--gui` argument), or `auto` to select `diff.guitool` or `diff.tool`
43 43 depending on the presence of a `DISPLAY` environment variable value. The
modified Documentation/config/fetch.adoc
@@ -76,7 +76,7 @@
76 76 default is `skipping`. Unknown values will cause `git fetch` to
77 77 error out.
78 78 +
79 - See also the `--negotiate-only` and `--negotiation-restrict` options to
79 + See also the `--negotiate-only` and `--negotiation-tip` options to
80 80 linkgit:git-fetch[1].
81 81
82 82 `fetch.showForcedUpdates`::
@@ -126,22 +126,3 @@ the new bundle URI.
126 126 The creation token values are chosen by the provider serving the specific
127 127 bundle URI. If you modify the URI at `fetch.bundleURI`, then be sure to
128 128 remove the value for the `fetch.bundleCreationToken` value before fetching.
129 -
130 - `fetch.followRemoteHEAD`::
131 - When fetching using a default refspec, this setting determines how to handle
132 - differences between a fetched remote's `HEAD` and the local
133 - `remotes/<name>/HEAD` symbolic-ref. Its value is one of
134 - +
135 - --
136 - `create`;;
137 - Create `remotes/<name>/HEAD` if a ref exists on the remote, but not locally.
138 - An existing symbolic-ref will not be touched. This is the default value.
139 - `warn`;;
140 - Display a warning if the remote advertises a different `HEAD` than what is
141 - set locally. Behaves like "create" if the local symbolic-ref doesn't exist.
142 - `always`;;
143 - Silently update `remotes/<name>/HEAD` whenever the remote advertises a new
144 - value.
145 - `never`;;
146 - Never create or modify the `remotes/<name>/HEAD` symbolic-ref.
147 - --
modified Documentation/config/format.adoc
@@ -102,7 +102,7 @@ format.coverLetter::
102 102 Default is false.
103 103
104 104 format.commitListFormat::
105 - When the `--commit-list-format` option is not given, `format-patch`
105 + When the `--cover-letter-format` option is not given, `format-patch`
106 106 uses the value of this variable to decide how to format the entry of
107 107 each commit. Defaults to `shortlog`.
108 108
modified Documentation/config/fsmonitor--daemon.adoc
@@ -4,8 +4,8 @@ fsmonitor.allowRemote::
4 4 behavior. Only respected when `core.fsmonitor` is set to `true`.
5 5
6 6 fsmonitor.socketDir::
7 - This Mac OS and Linux-specific option, if set, specifies the directory in
7 + This Mac OS-specific option, if set, specifies the directory in
8 8 which to create the Unix domain socket used for communication
9 9 between the fsmonitor daemon and various Git commands. The directory must
10 - reside on a native filesystem. Only respected when `core.fsmonitor`
10 + reside on a native Mac OS filesystem. Only respected when `core.fsmonitor`
11 11 is set to `true`.
modified Documentation/config/grep.adoc
@@ -1,28 +1,28 @@
1 - `grep.lineNumber`::
2 - If set to `true`, enable `-n` option by default.
1 + grep.lineNumber::
2 + If set to true, enable `-n` option by default.
3 3
4 - `grep.column`::
5 - If set to `true`, enable the `--column` option by default.
4 + grep.column::
5 + If set to true, enable the `--column` option by default.
6 6
7 - `grep.patternType`::
8 - Set the default matching behavior. Using a value of `basic`, `extended`,
9 - `fixed`, or `perl` will enable the `--basic-regexp`, `--extended-regexp`,
7 + grep.patternType::
8 + Set the default matching behavior. Using a value of 'basic', 'extended',
9 + 'fixed', or 'perl' will enable the `--basic-regexp`, `--extended-regexp`,
10 10 `--fixed-strings`, or `--perl-regexp` option accordingly, while the
11 - value `default` will use the `grep.extendedRegexp` option to choose
12 - between `basic` and `extended`.
11 + value 'default' will use the `grep.extendedRegexp` option to choose
12 + between 'basic' and 'extended'.
13 13
14 - `grep.extendedRegexp`::
15 - If set to `true`, enable `--extended-regexp` option by default. This
14 + grep.extendedRegexp::
15 + If set to true, enable `--extended-regexp` option by default. This
16 16 option is ignored when the `grep.patternType` option is set to a value
17 - other than `default`.
17 + other than 'default'.
18 18
19 - `grep.threads`::
19 + grep.threads::
20 20 Number of grep worker threads to use. If unset (or set to 0), Git will
21 21 use as many threads as the number of logical cores available.
22 22
23 - `grep.fullName`::
24 - If set to `true`, enable `--full-name` option by default.
23 + grep.fullName::
24 + If set to true, enable `--full-name` option by default.
25 25
26 - `grep.fallbackToNoIndex`::
27 - If set to `true`, fall back to `git grep --no-index` if `git grep`
28 - is executed outside of a git repository. Defaults to `false`.
26 + grep.fallbackToNoIndex::
27 + If set to true, fall back to `git grep --no-index` if `git grep`
28 + is executed outside of a git repository. Defaults to false.
modified Documentation/config/hook.adoc
@@ -1,17 +1,10 @@
1 - ifdef::git-hook[]
2 - :see-git-hook:
3 - endif::git-hook[]
4 - ifndef::git-hook[]
5 - :see-git-hook: See linkgit:git-hook[1].
6 - endif::git-hook[]
7 -
8 1 hook.<friendly-name>.command::
9 2 The command to execute for `hook.<friendly-name>`. `<friendly-name>`
10 3 is a unique name that identifies this hook. The hook events that
11 4 trigger the command are configured with `hook.<friendly-name>.event`.
12 5 The value can be an executable path or a shell oneliner. If more than
13 6 one value is specified for the same `<friendly-name>`, only the last
14 - value parsed is used. {see-git-hook}
7 + value parsed is used. See linkgit:git-hook[1].
15 8
16 9 hook.<friendly-name>.event::
17 10 The hook events that trigger `hook.<friendly-name>`. The value is the
@@ -21,87 +14,11 @@ hook.<friendly-name>.event::
21 14 This is a multi-valued key. To run `hook.<friendly-name>` on multiple
22 15 events, specify the key more than once. An empty value resets
23 16 the list of events, clearing any previously defined events for
24 - `hook.<friendly-name>`. {see-git-hook}
25 - +
26 - The `<friendly-name>` must not be the same as a known hook event name
27 - (e.g. do not use `hook.pre-commit.event`). Using a known event name as
28 - a friendly-name is a fatal error because it creates an ambiguity with
29 - `hook.<event>.enabled` and `hook.<event>.jobs`. For unknown event names,
30 - a warning is issued when `<friendly-name>` matches the event value.
17 + `hook.<friendly-name>`. See linkgit:git-hook[1].
31 18
32 19 hook.<friendly-name>.enabled::
33 20 Whether the hook `hook.<friendly-name>` is enabled. Defaults to `true`.
34 21 Set to `false` to disable the hook without removing its
35 22 configuration. This is particularly useful when a hook is defined
36 23 in a system or global config file and needs to be disabled for a
37 - specific repository. {see-git-hook}
38 -
39 - hook.<friendly-name>.parallel::
40 - Whether the hook `hook.<friendly-name>` may run in parallel with other hooks
41 - for the same event. Defaults to `false`. Set to `true` only when the
42 - hook script is safe to run concurrently with other hooks for the same
43 - event. If any hook for an event does not have this set to `true`,
44 - all hooks for that event run sequentially regardless of `hook.jobs`.
45 - Only configured (named) hooks need to declare this. Traditional hooks
46 - found in the hooks directory do not need to, and run in parallel when
47 - the effective job count is greater than 1. {see-git-hook}
48 -
49 - hook.<event>.enabled::
50 - Switch to enable or disable all hooks for the `<event>` hook event.
51 - When set to `false`, no hooks fire for that event, regardless of any
52 - per-hook `hook.<friendly-name>.enabled` settings. Defaults to `true`.
53 - {see-git-hook}
54 - +
55 - Note on naming: `<event>` must be the event name (e.g. `pre-commit`),
56 - not a hook friendly-name. Since using a known event name as a
57 - friendly-name is disallowed (see `hook.<friendly-name>.event` above),
58 - there is no ambiguity between event-level and per-hook `.enabled`
59 - settings for known events. For unknown events, if a friendly-name
60 - matches the event name despite the warning, `.enabled` is treated
61 - as per-hook only.
62 -
63 - hook.<event>.jobs::
64 - Specifies how many hooks can be run simultaneously for the `<event>`
65 - hook event (e.g. `hook.post-receive.jobs = 4`). Overrides `hook.jobs`
66 - for this specific event. The same parallelism restrictions apply: this
67 - setting has no effect unless all configured hooks for the event have
68 - `hook.<friendly-name>.parallel` set to `true`. Set to `-1` to use the
69 - number of available CPU cores. Must be a positive integer or `-1`;
70 - zero is rejected with a warning. {see-git-hook}
71 - +
72 - Note on naming: although this key resembles `hook.<friendly-name>.*`
73 - (a per-hook setting), `<event>` must be the event name, not a hook
74 - friendly name. The key component is stored literally and looked up by
75 - event name at runtime with no translation between the two namespaces.
76 - A key like `hook.my-hook.jobs` is stored under `"my-hook"` but the
77 - lookup at runtime uses the event name (e.g. `"post-receive"`), so
78 - `hook.my-hook.jobs` is silently ignored even when `my-hook` is
79 - registered for that event. Use `hook.post-receive.jobs` or any other
80 - valid event name when setting `hook.<event>.jobs`.
81 -
82 - hook.jobs::
83 - Specifies how many hooks can be run simultaneously during parallelized
84 - hook execution. If unspecified, defaults to 1 (serial execution).
85 - Set to `-1` to use the number of available CPU cores.
86 - Can be overridden on a per-event basis with `hook.<event>.jobs`.
87 - Some hooks always run sequentially regardless of this setting because
88 - they operate on shared data and cannot safely be parallelized:
89 - +
90 - --
91 - `applypatch-msg`;;
92 - `prepare-commit-msg`;;
93 - `commit-msg`;;
94 - Receive a commit message file and may rewrite it in place.
95 - `pre-commit`;;
96 - `post-checkout`;;
97 - `push-to-checkout`;;
98 - `post-commit`;;
99 - Access the working tree, index, or repository state.
100 - --
101 - +
102 - This setting has no effect unless all configured hooks for the event have
103 - `hook.<friendly-name>.parallel` set to `true`.
104 - +
105 - For `pre-push` hooks, which normally keep stdout and stderr separate,
106 - setting this to a value greater than 1 (or passing `-j`) will merge stdout
107 - into stderr to allow correct de-interleaving of parallel output.
24 + specific repository. See linkgit:git-hook[1].
modified Documentation/config/http.adoc
@@ -59,18 +59,7 @@ http.emptyAuth::
59 59 Attempt authentication without seeking a username or password. This
60 60 can be used to attempt GSS-Negotiate authentication without specifying
61 61 a username in the URL, as libcurl normally requires a username for
62 - authentication. Possible values are:
63 - +
64 - --
65 - * `auto` (default) - Send empty credentials only if the server's 401 response
66 - advertises an authentication mechanism that requires them (such as
67 - GSS-Negotiate); otherwise fall back to prompting via the credential helper.
68 - * `true` - Always send empty credentials on the very first request, before
69 - receiving any 401 response from the server.
70 - * `false` - Never send empty credentials. Mechanisms that require
71 - empty credentials or an explicit username, such as GSS-Negotiate, will not
72 - work.
73 - --
62 + authentication.
74 63
75 64 http.proactiveAuth::
76 65 Attempt authentication without first making an unauthenticated attempt and
modified Documentation/config/imap.adoc
@@ -1,47 +1,47 @@
1 - `imap.folder`::
1 + imap.folder::
2 2 The folder to drop the mails into, which is typically the Drafts
3 3 folder. For example: `INBOX.Drafts`, `INBOX/Drafts` or
4 4 `[Gmail]/Drafts`. The IMAP folder to interact with MUST be specified;
5 5 the value of this configuration variable is used as the fallback
6 6 default value when the `--folder` option is not given.
7 7
8 - `imap.tunnel`::
8 + imap.tunnel::
9 9 Command used to set up a tunnel to the IMAP server through which
10 10 commands will be piped instead of using a direct network connection
11 - to the server. Required when `imap.host` is not set.
11 + to the server. Required when imap.host is not set.
12 12
13 - `imap.host`::
13 + imap.host::
14 14 A URL identifying the server. Use an `imap://` prefix for non-secure
15 15 connections and an `imaps://` prefix for secure connections.
16 - Ignored when `imap.tunnel` is set, but required otherwise.
16 + Ignored when imap.tunnel is set, but required otherwise.
17 17
18 - `imap.user`::
18 + imap.user::
19 19 The username to use when logging in to the server.
20 20
21 - `imap.pass`::
21 + imap.pass::
22 22 The password to use when logging in to the server.
23 23
24 - `imap.port`::
24 + imap.port::
25 25 An integer port number to connect to on the server.
26 - Defaults to 143 for `imap://` hosts and 993 for `imaps://` hosts.
27 - Ignored when `imap.tunnel` is set.
26 + Defaults to 143 for imap:// hosts and 993 for imaps:// hosts.
27 + Ignored when imap.tunnel is set.
28 28
29 - `imap.sslverify`::
29 + imap.sslverify::
30 30 A boolean to enable/disable verification of the server certificate
31 31 used by the SSL/TLS connection. Default is `true`. Ignored when
32 - `imap.tunnel` is set.
32 + imap.tunnel is set.
33 33
34 - `imap.preformattedHTML`::
34 + imap.preformattedHTML::
35 35 A boolean to enable/disable the use of html encoding when sending
36 - a patch. An html encoded patch will be bracketed with `<pre>`
36 + a patch. An html encoded patch will be bracketed with <pre>
37 37 and have a content type of text/html. Ironically, enabling this
38 38 option causes Thunderbird to send the patch as a plain/text,
39 39 format=fixed email. Default is `false`.
40 40
41 - `imap.authMethod`::
41 + imap.authMethod::
42 42 Specify the authentication method for authenticating with the IMAP server.
43 43 If Git was built with the NO_CURL option, or if your curl version is older
44 - than 7.34.0, or if you're running `git-imap-send` with the `--no-curl`
44 + than 7.34.0, or if you're running git-imap-send with the `--no-curl`
45 45 option, the only supported methods are `PLAIN`, `CRAM-MD5`, `OAUTHBEARER`
46 46 and `XOAUTH2`. If this is not set then `git imap-send` uses the basic IMAP
47 47 plaintext `LOGIN` command.
modified Documentation/config/log.adoc
@@ -53,16 +53,13 @@ This is the same as the `--decorate` option of the `git log`.
53 53 `log.follow`::
54 54 If `true`, `git log` will act as if the `--follow` option was used when
55 55 a single <path> is given. This has the same limitations as `--follow`,
56 - i.e. it cannot be used to follow multiple files.
56 + i.e. it cannot be used to follow multiple files and does not work well
57 + on non-linear history.
57 58
58 59 `log.graphColors`::
59 60 A list of colors, separated by commas, that can be used to draw
60 61 history lines in `git log --graph`.
61 62
62 - `log.graphIndent`::
63 - If `true`, indent visual roots when rendering the graphs with `--graph`.
64 - Set true by default. It can be overriden with `--[no-]graph-indent`.
65 -
66 63 `log.showRoot`::
67 64 If true, the initial commit will be shown as a big creation event.
68 65 This is equivalent to a diff against an empty tree.
modified Documentation/config/maintenance.adoc
@@ -101,7 +101,7 @@ maintenance.geometric-repack.auto::
101 101 there are packfiles that need to be merged together to retain the
102 102 geometric progression, or when there are at least this many loose
103 103 objects that would be written into a new packfile. The default value is
104 - 6700.
104 + 100.
105 105
106 106 maintenance.geometric-repack.splitFactor::
107 107 This integer config option controls the factor used for the geometric
modified Documentation/config/mergetool.adoc
@@ -52,13 +52,13 @@
52 52 if `merge.tool` is configured as _<variant>_), Git will consult
53 53 `mergetool.<variant>.layout` to determine the tool's layout. If the
54 54 variant-specific configuration is not available, `vimdiff` ' s is used as
55 - fallback. If that too is not available, a default layout with 4 windows
56 - will be used.
55 + fallback. If that too is not available, a default layout with 4 windows
56 + will be used. To configure the layout, see the 'BACKEND SPECIFIC HINTS'
57 57 ifdef::git-mergetool[]
58 - To configure the layout, see the 'BACKEND SPECIFIC HINTS' section.
58 + section.
59 59 endif::[]
60 60 ifndef::git-mergetool[]
61 - To configure the layout, see the 'BACKEND SPECIFIC HINTS' section in linkgit:git-mergetool[1].
61 + section in linkgit:git-mergetool[1].
62 62 endif::[]
63 63
64 64 `mergetool.hideResolved`::
modified Documentation/config/promisor.adoc
@@ -32,136 +32,24 @@ variable is set to "true", and the "name" and "url" fields are always
32 32 advertised regardless of this setting.
33 33
34 34 promisor.acceptFromServer::
35 - Controls which promisor remotes advertised by a server (using the
36 - "promisor-remote" protocol capability) a client will accept. By
37 - accepting a promisor remote, the client agrees that the server
38 - might omit objects that are lazily fetchable from this promisor
39 - remote from its responses to "fetch" and "clone" requests.
40 - +
41 - Note that this option does not cause new remotes to be automatically
42 - created in the client's configuration. It only allows remotes which
43 - are somehow already configured to be trusted for the current
44 - operation, or their fields to be updated (if `promisor.storeFields` is
45 - set and the remote already exists locally). To allow Git to
46 - automatically create and persist new remotes from server
47 - advertisements, use `promisor.acceptFromServerUrl`.
48 - +
49 - The available options are:
50 - +
51 - * `none` (default): No promisor remote advertised by a server will be
52 - accepted.
53 - +
54 - * `knownUrl`: The client will accept promisor remotes that are already
55 - configured on the client and have both the same name and the same URL
56 - as advertised by the server. This is more secure than `all` or
57 - `knownName`, and should be used if possible instead of those options.
58 - +
59 - * `knownName`: The client will accept promisor remotes that are already
60 - configured on the client and have the same name as those advertised
61 - by the server. This is not very secure, but could be used in a corporate
62 - setup where servers and clients are trusted to not switch names and URLs.
63 - +
64 - * `all`: The client will accept all the promisor remotes a server might
65 - advertise. This is the least secure option and should only be used in
66 - fully trusted environments.
67 - +
68 - Name and URL comparisons are case-sensitive. See linkgit:gitprotocol-v2[5]
69 - for protocol details.
70 -
71 - promisor.acceptFromServerUrl::
72 - A glob pattern to specify which server-advertised URLs a
73 - client is allowed to act on. When a URL matches, the client
74 - will accept the advertised remote as a promisor remote, may
75 - automatically create a new remote configuration for it and may
76 - automatically accept field updates (such as authentication
77 - tokens) from the server, even if `promisor.acceptFromServer`
78 - is set to `none` (the default).
79 - +
80 - This option can appear multiple times in config files. An advertised
81 - URL will be accepted if it matches _ANY_ glob pattern specified by
82 - this option in _ANY_ config file read by Git.
83 - +
84 - When both `promisor.acceptFromServer` and `promisor.acceptFromServerUrl`
85 - are set, `promisor.acceptFromServerUrl` is consulted first and takes
86 - precedence: if a matching pattern leads to acceptance (either by
87 - auto-configuring an unknown remote or by accepting field updates for
88 - a known remote whose URL matches both the local configuration and the
89 - allowlist), the advertised remote is accepted regardless of the
90 - `promisor.acceptFromServer` setting. If no pattern in
91 - `promisor.acceptFromServerUrl` triggers acceptance, the decision is
92 - left to `promisor.acceptFromServer`.
93 - +
94 - Note however that, even when an advertised URL matches a pattern in
95 - `promisor.acceptFromServerUrl`, an already-existing remote on the
96 - client whose name matches the advertised name but whose configured URL
97 - differs from the advertised one will _NOT_ be accepted through
98 - `promisor.acceptFromServerUrl`. This prevents a server from silently
99 - re-pointing an existing client-side remote at a different URL. (Such a
100 - remote may still be accepted through `promisor.acceptFromServer=all`
101 - or `=knownName`, which have their own, looser semantics; see the
102 - documentation of that option.)
103 - +
104 - Be _VERY_ careful with these patterns: `*` matches any sequence of
105 - characters within the 'host' and 'path' parts of a URL (but cannot
106 - cross part boundaries). An overly broad pattern is a major security
107 - risk, as a matching URL allows a server to auto-configure new remotes
108 - and to update fields (such as authentication tokens) on known remotes
109 - without further confirmation. To minimize security risks, follow these
110 - guidelines:
111 - +
112 - --
113 - 1. Start with a secure protocol scheme, like `https://` or `ssh://`.
114 - +
115 - 2. Only allow domain names or paths where you control and trust _ALL_
116 - the content. Be especially careful with shared hosting platforms
117 - like `github.com` or `gitlab.com`. A broad pattern like
118 - `https://gitlab.com/*` is dangerous because it trusts every
119 - repository on the entire platform. Always restrict such patterns to
120 - your specific organization or namespace (e.g.,
121 - `https://gitlab.com/your-org/*`).
122 - +
123 - 3. Never use globs at the end of domain names. For example,
124 - `https://cdn.your-org.com/*` might be safe, but
125 - `https://cdn.your-org.com*/*` is a major security risk because
126 - the latter matches `https://cdn.your-org.com.hacker.net/repo`.
127 - +
128 - 4. Be careful using globs at the beginning of domain names. While the
129 - code ensures a `*` in the host cannot cross into the path, a
130 - pattern like `https://*.example.com/*` will still match any
131 - subdomain. This is extremely dangerous on shared hosting platforms
132 - (e.g., `https://*.github.io/*` trusts every user's site on the
133 - entire platform).
134 - --
135 - +
136 - Before matching, both the advertised URL and the pattern are
137 - normalized: the scheme and host are lowercased, percent-encoded
138 - characters are decoded where possible, and path segments like `..`
139 - are resolved. The port must also match exactly (e.g.,
140 - `https://example.com:8080/*` will not match a URL advertised on
141 - port 9999). The username and password components of the URL are
142 - ignored during matching. Note that embedding credentials in URLs is
143 - discouraged. Passing authentication tokens via the `token` field of
144 - the `promisor-remote` capability is strongly preferred.
145 - +
146 - The glob pattern can optionally be prefixed with a remote name and an
147 - equals sign (e.g., `cdn=https://cdn.example.com/*`). If such a prefix
148 - is provided, accepted remotes will be saved under that name. If no
149 - such prefix is provided, a safe remote name will be automatically
150 - generated by sanitizing the URL and prefixing it with
151 - `promisor-auto-`.
152 - +
153 - If a remote with the chosen name already exists but points to a
154 - different URL, Git will append a numeric suffix (e.g., `-1`, `-2`) to
155 - the name to prevent overwriting existing configurations. You should
156 - make sure that this doesn't happen often though, as remotes will be
157 - rejected if the numeric suffix increases too much. In all cases, the
158 - original name advertised by the server is recorded in the
159 - `remote.<name>.advertisedAs` configuration variable for tracing and
160 - debugging purposes.
161 - +
162 - For the security implications of accepting a promisor remote, see the
163 - documentation of `promisor.acceptFromServer`. For details on the
164 - protocol, see linkgit:gitprotocol-v2[5].
35 + If set to "all", a client will accept all the promisor remotes
36 + a server might advertise using the "promisor-remote"
37 + capability. If set to "knownName" the client will accept
38 + promisor remotes which are already configured on the client
39 + and have the same name as those advertised by the client. This
40 + is not very secure, but could be used in a corporate setup
41 + where servers and clients are trusted to not switch name and
42 + URLs. If set to "knownUrl", the client will accept promisor
43 + remotes which have both the same name and the same URL
44 + configured on the client as the name and URL advertised by the
45 + server. This is more secure than "all" or "knownName", so it
46 + should be used if possible instead of those options. Default
47 + is "none", which means no promisor remote advertised by a
48 + server will be accepted. By accepting a promisor remote, the
49 + client agrees that the server might omit objects that are
50 + lazily fetchable from this promisor remote from its responses
51 + to "fetch" and "clone" requests from the client. Name and URL
52 + comparisons are case sensitive. See linkgit:gitprotocol-v2[5].
165 53
166 54 promisor.checkFields::
167 55 A comma or space separated list of additional remote related
@@ -175,13 +63,11 @@ If one of these field names (e.g., "token") is being checked for an
175 63 advertised promisor remote (e.g., "foo"), three conditions must be met
176 64 for the check of this specific field to pass:
177 65 +
178 - --
179 66 1. The corresponding local configuration (e.g., `remote.foo.token`)
180 67 must be set.
181 68 2. The server must advertise the "token" field for remote "foo".
182 69 3. The value of the locally configured `remote.foo.token` must exactly
183 70 match the value advertised by the server for the "token" field.
184 - --
185 71 +
186 72 If any of these conditions is not met for any field name listed in
187 73 `promisor.checkFields`, the advertised remote "foo" is rejected.
modified Documentation/config/push.adoc
@@ -41,10 +41,9 @@ this is a deprecated synonym for `upstream`.
41 41 `simple`;;
42 42 push the current branch with the same name on the remote.
43 43 +
44 - This mode requires that the remote repository to be pushed to is
45 - known. When pushing back to the same remote you pull from, the
46 - current branch must also have an upstream tracking branch with the
47 - same name.
44 + If you are working on a centralized workflow (pushing to the same repository you
45 + pull from, which is typically `origin`), then you need to configure an upstream
46 + branch with the same name.
48 47 +
49 48 This mode is the default since Git 2.0, and is the safest option suited for
50 49 beginners.
modified Documentation/config/remote.adoc
@@ -91,15 +91,6 @@ remote.<name>.promisor::
91 91 When set to true, this remote will be used to fetch promisor
92 92 objects.
93 93
94 - remote.<name>.advertisedAs::
95 - When a promisor remote is automatically configured using
96 - information advertised by a server through the
97 - `promisor-remote` protocol capability (see
98 - `promisor.acceptFromServerUrl`), the server's originally
99 - advertised name is saved in this variable. This is for
100 - information, tracing and debugging purposes. Users should not
101 - typically modify or create such configuration entries.
102 -
103 94 remote.<name>.partialclonefilter::
104 95 The filter that will be applied when fetching from this promisor remote.
105 96 Changing or clearing this value will only affect fetches for new commits.
@@ -116,62 +107,16 @@ priority configuration file (e.g. `.git/config` in a repository) to clear
116 107 the values inherited from a lower priority configuration files (e.g.
117 108 `$HOME/.gitconfig`).
118 109
119 - remote.<name>.negotiationRestrict::
120 - When negotiating with this remote during `git fetch`, restrict the
121 - commits advertised as "have" lines to only those reachable from refs
122 - matching the given patterns. This multi-valued config option behaves
123 - like `--negotiation-restrict` on the command line.
124 - +
125 - Each value is either an exact ref name (e.g. `refs/heads/release`) or a
126 - glob pattern (e.g. `refs/heads/release/*`). The pattern syntax is the
127 - same as for `--negotiation-restrict`.
128 - +
129 - These config values are used as defaults for the `--negotiation-restrict`
130 - command-line option. If `--negotiation-restrict` (or its synonym
131 - `--negotiation-tip`) is specified on the command line, then the config
132 - values are not used.
133 - +
134 - These values also influence negotiation during `git push` if
135 - `push.negotiate` is enabled.
136 - +
137 - Blank values signal to ignore all previous values, allowing a reset of
138 - the list from broader config scenarios.
139 -
140 - remote.<name>.negotiationInclude::
141 - When negotiating with this remote during `git fetch`, the client
142 - advertises a list of commits that exist locally. In repos with
143 - many references, this list of "haves" can be truncated. Depending
144 - on data shape, dropping certain references may be expensive. This
145 - multi-valued config option specifies references, commit hashes,
146 - or ref pattern globs whose tips should always be sent as "have"
147 - commits during fetch negotiation with this remote.
148 - +
149 - Each value is either an exact ref name (e.g. `refs/heads/release`), a
150 - commit hash, or a glob pattern (e.g. `refs/heads/release/*`). The
151 - pattern syntax is the same as for `--negotiation-include`.
152 - +
153 - These config values are used as defaults for the `--negotiation-include`
154 - command-line option. If `--negotiation-include` is specified on the
155 - command line, then the config values are not used.
156 - +
157 - This option is additive with the normal negotiation process: the
158 - negotiation algorithm still runs and advertises its own selected commits,
159 - but the refs matching `remote.<name>.negotiationInclude` are sent
160 - unconditionally on top of those heuristically selected commits.
161 - +
162 - These values also influence negotiation during `git push` if
163 - `push.negotiate` is enabled.
164 - +
165 - Blank values signal to ignore all previous values, allowing a reset of
166 - the list from broader config scenarios.
167 -
168 110 remote.<name>.followRemoteHEAD::
169 - When fetching this remote using its default refspec, this setting determines
170 - how to handle differences between the remote's `HEAD` and the local
171 - `remotes/<name>/HEAD` symbolic-ref. Overrides the value of
172 - `fetch.followRemoteHEAD`. See `fetch.followRemoteHEAD` for a description of
173 - accepted values.
174 - +
175 - In addition to the values supported by `fetch.followRemoteHEAD`, this setting
176 - may also take on the value "warn-if-not-`$branch`", which behaves like "warn",
177 - but ignores the warning if the remote's `HEAD` is `remotes/<name>/$branch`.
111 + How linkgit:git-fetch[1] should handle updates to `remotes/<name>/HEAD`
112 + when fetching using the configured refspecs of a remote.
113 + The default value is "create", which will create `remotes/<name>/HEAD`
114 + if it exists on the remote, but not locally; this will not touch an
115 + already existing local reference. Setting it to "warn" will print
116 + a message if the remote has a different value than the local one;
117 + in case there is no local reference, it behaves like "create".
118 + A variant on "warn" is "warn-if-not-$branch", which behaves like
119 + "warn", but if `HEAD` on the remote is `$branch` it will be silent.
120 + Setting it to "always" will silently update `remotes/<name>/HEAD` to
121 + the value on the remote. Finally, setting it to "never" will never
122 + change or create the local reference.
modified Documentation/config/repack.adoc
@@ -46,21 +46,3 @@ repack.midxMustContainCruft::
46 46 `--write-midx`. When false, cruft packs are only included in the MIDX
47 47 when necessary (e.g., because they might be required to form a
48 48 reachability closure with MIDX bitmaps). Defaults to true.
49 -
50 - repack.midxSplitFactor::
51 - The factor used in the geometric merging condition when
52 - compacting incremental MIDX layers during `git repack` when
53 - invoked with the `--write-midx=incremental` option.
54 - +
55 - Adjacent layers are merged when the accumulated object count of the
56 - newer layer exceeds `1/<N>` of the object count of the next deeper
57 - layer. Must be at least 2. Defaults to 2.
58 -
59 - repack.midxNewLayerThreshold::
60 - The minimum number of packs in the tip MIDX layer before those
61 - packs are considered as candidates for geometric repacking
62 - during `git repack --write-midx=incremental`.
63 - +
64 - When the tip layer has fewer packs than this threshold, those packs are
65 - excluded from the geometric repack entirely, and are thus left
66 - unmodified. Must be at least 1. Defaults to 8.
modified Documentation/config/replay.adoc
@@ -1,18 +1,11 @@
1 1 replay.refAction::
2 - Specifies the default mode for handling reference updates.
3 - The value can be:
2 + Specifies the default mode for handling reference updates in
3 + `git replay`. The value can be:
4 4 +
5 5 --
6 - ////
7 - These use the first sentences from the description list in git-replay(1).
8 - ////
9 - `update`;; (default) Update refs directly using an atomic transaction.
10 - `print`;; Output update-ref commands for pipeline use.
6 + * `update`: Update refs directly using an atomic transaction (default behavior).
7 + * `print`: Output update-ref commands for pipeline use.
11 8 --
12 9 +
13 - ifdef::git-replay[]
14 - See `--ref-action`.
15 - endif::git-replay[]
16 - ifndef::git-replay[]
17 - See `--ref-action` in linkgit:git-replay[1] for details.
18 - endif::git-replay[]
10 + This setting can be overridden with the `--ref-action` command-line option.
11 + When not configured, `git replay` defaults to `update` mode.
modified Documentation/config/safe.adoc
@@ -2,14 +2,10 @@ safe.bareRepository::
2 2 Specifies which bare repositories Git will work with. The currently
3 3 supported values are:
4 4 +
5 - --
6 - * `all`: Git works with all bare repositories. This is the default in
7 - Git 2.x.
5 + * `all`: Git works with all bare repositories. This is the default.
8 6 * `explicit`: Git only works with bare repositories specified via
9 7 the top-level `--git-dir` command-line option, or the `GIT_DIR`
10 - environment variable (see linkgit:git[1]). This will be the default
11 - in Git 3.0.
12 - --
8 + environment variable (see linkgit:git[1]).
13 9 +
14 10 If you do not use bare repositories in your workflow, then it may be
15 11 beneficial to set `safe.bareRepository` to `explicit` in your global
@@ -17,10 +13,6 @@ config. This will protect you from attacks that involve cloning a
17 13 repository that contains a bare repository and running a Git command
18 14 within that directory.
19 15 +
20 - If you use bare repositories regularly and want to preserve the current
21 - behavior after upgrading to Git 3.0, set `safe.bareRepository` to `all`
22 - in your global or system config.
23 - +
24 16 This config setting is only respected in protected configuration (see
25 17 <<SCOPES>>). This prevents untrusted repositories from tampering with
26 18 this value.
modified Documentation/config/sendemail.adoc
@@ -1,25 +1,25 @@
1 - `sendemail.identity`::
1 + sendemail.identity::
2 2 A configuration identity. When given, causes values in the
3 3 `sendemail.<identity>` subsection to take precedence over
4 4 values in the `sendemail` section. The default identity is
5 5 the value of `sendemail.identity`.
6 6
7 - `sendemail.smtpEncryption`::
7 + sendemail.smtpEncryption::
8 8 See linkgit:git-send-email[1] for description. Note that this
9 9 setting is not subject to the `identity` mechanism.
10 10
11 - `sendemail.smtpSSLCertPath`::
11 + sendemail.smtpSSLCertPath::
12 12 Path to ca-certificates (either a directory or a single file).
13 13 Set it to an empty string to disable certificate verification.
14 14
15 - `sendemail.smtpSSLClientCert`::
15 + sendemail.smtpSSLClientCert::
16 16 Path to the client certificate file to present if requested by the
17 17 server. This is required when the server is set up to verify client
18 18 certificates. If the corresponding private key is not included in the
19 19 file, it must be supplied using `sendemail.smtpSSLClientKey` or the
20 20 `--smtp-ssl-client-key` option.
21 21
22 - `sendemail.smtpSSLClientKey`::
22 + sendemail.smtpSSLClientKey::
23 23 Path to the client private key file that corresponds to the client
24 24 certificate. To avoid misconfiguration, this configuration must be used
25 25 in conjunction with `sendemail.smtpSSLClientCert` or the
@@ -28,45 +28,45 @@
28 28 the certificate. Visit https://metacpan.org/pod/IO::Socket::SSL for more
29 29 details.
30 30
31 - `sendemail.<identity>.<config>`::
32 - Identity-specific versions of the `sendemail.<config>` parameters
31 + sendemail.<identity>.*::
32 + Identity-specific versions of the `sendemail.*` parameters
33 33 found below, taking precedence over those when this
34 34 identity is selected, through either the command-line or
35 35 `sendemail.identity`.
36 36
37 - `sendemail.multiEdit`::
37 + sendemail.multiEdit::
38 38 If `true` (default), a single editor instance will be spawned to edit
39 39 files you have to edit (patches when `--annotate` is used, and the
40 40 summary when `--compose` is used). If `false`, files will be edited one
41 41 after the other, spawning a new editor each time.
42 42
43 - `sendemail.confirm`::
43 + sendemail.confirm::
44 44 Sets the default for whether to confirm before sending. Must be
45 45 one of `always`, `never`, `cc`, `compose`, or `auto`. See `--confirm`
46 46 in the linkgit:git-send-email[1] documentation for the meaning of these
47 47 values.
48 48
49 - `sendemail.mailmap`::
49 + sendemail.mailmap::
50 50 If `true`, makes linkgit:git-send-email[1] assume `--mailmap`,
51 51 otherwise assume `--no-mailmap`. `False` by default.
52 52
53 - `sendemail.mailmap.file`::
53 + sendemail.mailmap.file::
54 54 The location of a linkgit:git-send-email[1] specific augmenting
55 55 mailmap file. The default mailmap and `mailmap.file` are loaded
56 56 first. Thus, entries in this file take precedence over entries in
57 57 the default mailmap locations. See linkgit:gitmailmap[5].
58 58
59 - `sendemail.mailmap.blob`::
59 + sendemail.mailmap.blob::
60 60 Like `sendemail.mailmap.file`, but consider the value as a reference
61 61 to a blob in the repository. Entries in `sendemail.mailmap.file`
62 62 take precedence over entries here. See linkgit:gitmailmap[5].
63 63
64 - `sendemail.aliasesFile`::
64 + sendemail.aliasesFile::
65 65 To avoid typing long email addresses, point this to one or more
66 66 email aliases files. You must also supply `sendemail.aliasFileType`.
67 67
68 - `sendemail.aliasFileType`::
69 - Format of the file(s) specified in `sendemail.aliasesFile`. Must be
68 + sendemail.aliasFileType::
69 + Format of the file(s) specified in sendemail.aliasesFile. Must be
70 70 one of `mutt`, `mailrc`, `pine`, `elm`, `gnus`, or `sendmail`.
71 71 +
72 72 What an alias file in each format looks like can be found in
@@ -75,7 +75,7 @@ differences and limitations from the standard formats are
75 75 described below:
76 76 +
77 77 --
78 - `sendmail`;;
78 + sendmail;;
79 79 * Quoted aliases and quoted addresses are not supported: lines that
80 80 contain a `"` symbol are ignored.
81 81 * Redirection to a file (`/path/name`) or pipe (`|command`) is not
@@ -85,54 +85,54 @@ described below:
85 85 explicitly unsupported constructs, and any other lines that are not
86 86 recognized by the parser.
87 87 --
88 - `sendemail.annotate`::
89 - `sendemail.bcc`::
90 - `sendemail.cc`::
91 - `sendemail.ccCmd`::
92 - `sendemail.chainReplyTo`::
93 - `sendemail.envelopeSender`::
94 - `sendemail.from`::
95 - `sendemail.headerCmd`::
96 - `sendemail.signedOffByCc`::
97 - `sendemail.smtpPass`::
98 - `sendemail.suppressCc`::
99 - `sendemail.suppressFrom`::
100 - `sendemail.to`::
101 - `sendemail.toCmd`::
102 - `sendemail.smtpDomain`::
103 - `sendemail.smtpServer`::
104 - `sendemail.smtpServerPort`::
105 - `sendemail.smtpServerOption`::
106 - `sendemail.smtpUser`::
107 - `sendemail.imapSentFolder`::
108 - `sendemail.useImapOnly`::
109 - `sendemail.thread`::
110 - `sendemail.transferEncoding`::
111 - `sendemail.validate`::
112 - `sendemail.xmailer`::
88 + sendemail.annotate::
89 + sendemail.bcc::
90 + sendemail.cc::
91 + sendemail.ccCmd::
92 + sendemail.chainReplyTo::
93 + sendemail.envelopeSender::
94 + sendemail.from::
95 + sendemail.headerCmd::
96 + sendemail.signedOffByCc::
97 + sendemail.smtpPass::
98 + sendemail.suppressCc::
99 + sendemail.suppressFrom::
100 + sendemail.to::
101 + sendemail.toCmd::
102 + sendemail.smtpDomain::
103 + sendemail.smtpServer::
104 + sendemail.smtpServerPort::
105 + sendemail.smtpServerOption::
106 + sendemail.smtpUser::
107 + sendemail.imapSentFolder::
108 + sendemail.useImapOnly::
109 + sendemail.thread::
110 + sendemail.transferEncoding::
111 + sendemail.validate::
112 + sendemail.xmailer::
113 113 These configuration variables all provide a default for
114 114 linkgit:git-send-email[1] command-line options. See its
115 115 documentation for details.
116 116
117 - `sendemail.outlookidfix`::
117 + sendemail.outlookidfix::
118 118 If `true`, makes linkgit:git-send-email[1] assume `--outlook-id-fix`,
119 119 and if `false` assume `--no-outlook-id-fix`. If not specified, it will
120 120 behave the same way as if `--outlook-id-fix` is not specified.
121 121
122 - `sendemail.signedOffCc` (deprecated)::
122 + sendemail.signedOffCc (deprecated)::
123 123 Deprecated alias for `sendemail.signedOffByCc`.
124 124
125 - `sendemail.smtpBatchSize`::
125 + sendemail.smtpBatchSize::
126 126 Number of messages to be sent per connection, after that a relogin
127 127 will happen. If the value is `0` or undefined, send all messages in
128 128 one connection.
129 129 See also the `--batch-size` option of linkgit:git-send-email[1].
130 130
131 - `sendemail.smtpReloginDelay`::
131 + sendemail.smtpReloginDelay::
132 132 Seconds to wait before reconnecting to the smtp server.
133 133 See also the `--relogin-delay` option of linkgit:git-send-email[1].
134 134
135 - `sendemail.forbidSendmailVariables`::
135 + sendemail.forbidSendmailVariables::
136 136 To avoid common misconfiguration mistakes, linkgit:git-send-email[1]
137 137 will abort with a warning if any configuration options for `sendmail`
138 138 exist. Set this variable to bypass the check.
deleted Documentation/config/sideband.adoc mode 100644
@@ -1,27 +0,0 @@
1 - sideband.allowControlCharacters::
2 - By default, control characters that are delivered via the sideband
3 - are masked, except ANSI color sequences. This prevents potentially
4 - unwanted ANSI escape sequences from being sent to the terminal. Use
5 - this config setting to override this behavior (the value can be
6 - a comma-separated list of the following keywords):
7 - +
8 - --
9 - `color`::
10 - Allow ANSI color sequences, line feeds and horizontal tabs,
11 - but mask all other control characters. This is the default.
12 - `cursor`::
13 - Allow control sequences that move the cursor. This is
14 - disabled by default.
15 - `erase`::
16 - Allow control sequences that erase characters. This is
17 - disabled by default.
18 - `false`::
19 - Mask all control characters other than line feeds and
20 - horizontal tabs.
21 - `true`::
22 - Allow all control characters to be sent to the terminal.
23 - --
24 -
25 - sideband.<url>.*::
26 - Apply the `sideband.*` option selectively to specific URLs. The
27 - same URL matching logic applies as for `http.<url>.*` settings.
modified Documentation/config/worktree.adoc
@@ -5,9 +5,8 @@
5 5 set to true, `worktree add` tries to find a remote-tracking
6 6 branch whose name uniquely matches the new branch name. If
7 7 such a branch exists, it is checked out and set as "upstream"
8 - for the new branch. If multiple matches are found, the command
9 - fails. If no such match can be found, it falls back to
10 - creating a new branch from the current `HEAD`.
8 + for the new branch. If no such match can be found, it falls
9 + back to creating a new branch from the current `HEAD`.
11 10
12 11 `worktree.useRelativePaths`::
13 12 Link worktrees using relative paths (when "`true`") or absolute
modified Documentation/date-formats.adoc
@@ -9,11 +9,6 @@ Git internal format::
9 9 `<unix-timestamp>` is the number of seconds since the UNIX epoch.
10 10 `<time-zone-offset>` is a positive or negative offset from UTC.
11 11 For example CET (which is 1 hour ahead of UTC) is `+0100`.
12 - +
13 - It is safer to prepend the `<unix-timestamp>` with `@` (e.g.,
14 - `@0 +0000`), which forces Git to interpret it as a raw timestamp. This
15 - is required for values less than 100,000,000 (which have fewer than 9
16 - digits) to avoid confusion with other date formats like `YYYYMMDD`.
17 12
18 13 RFC 2822::
19 14 The standard date format as described by RFC 2822, for example
modified Documentation/diff-format.adoc
@@ -19,9 +19,9 @@ compared differs:
19 19 `git-diff-files [<pattern>...]`::
20 20 compares the index and the files on the filesystem.
21 21
22 - All the commands print one output line per changed file,
23 - except `git diff-files` in the case of an unmerged file, which prints
24 - both an "unmerged" and an "in-place edit" line.
22 + The `git-diff-tree` command begins its output by printing the hash of
23 + what is being compared. After that, all the commands print one output
24 + line per changed file.
25 25
26 26 An output line is formatted this way:
27 27
@@ -37,13 +37,13 @@ unmerged :000000 000000 0000000 0000000 U file6
37 37 That is, from the left to the right:
38 38
39 39 . a colon.
40 - . mode for "src"; 000000 if creation, or if "src" is from the index and is unmerged.
40 + . mode for "src"; 000000 if creation or unmerged.
41 41 . a space.
42 - . mode for "dst"; 000000 if deletion, or if "dst" is from the index and is unmerged.
42 + . mode for "dst"; 000000 if deletion or unmerged.
43 43 . a space.
44 - . sha1 for "src"; 0\{40\} if creation, or if "src" is from the index and is unmerged.
44 + . sha1 for "src"; 0\{40\} if creation or unmerged.
45 45 . a space.
46 - . sha1 for "dst"; 0\{40\} if deletion, if "dst" is from the index and is unmerged, or if "dst" is from the work tree and is out of sync with the index.
46 + . sha1 for "dst"; 0\{40\} if deletion, unmerged or "work tree out of sync with the index".
47 47 . a space.
48 48 . status, followed by optional "score" number.
49 49 . a tab or a NUL when `-z` option is used.
modified Documentation/diff-options.adoc
@@ -13,8 +13,8 @@ endif::git-diff[]
13 13 endif::git-format-patch[]
14 14
15 15 ifdef::git-format-patch[]
16 - `-p`::
17 - `--no-stat`::
16 + -p::
17 + --no-stat::
18 18 Generate plain patches without any diffstats.
19 19 endif::git-format-patch[]
20 20
@@ -457,14 +457,6 @@ endif::git-diff[]
457 457 +
458 458 Note that despite the name of the first mode, color is used to
459 459 highlight the changed parts in all modes if enabled.
460 - +
461 - The `--word-diff` option operates by taking the same line-by-line
462 - diff that is produced without the option and computing
463 - word-by-word changes within each hunk. This may produce a
464 - larger diff than a dedicated word-diff tool would. If Git
465 - acquires a different implementation in the future, the output
466 - may change. Note that this is similar to the `--diff-algorithm`
467 - option, which may also change the output.
468 460
469 461 `--word-diff-regex=<regex>`::
470 462 Use _<regex>_ to decide what a word is, instead of considering
@@ -893,8 +885,8 @@ endif::git-format-patch[]
893 885 reverted with `--ita-visible-in-index`. Both options are
894 886 experimental and could be removed in future.
895 887
896 - `--max-depth=<depth>`::
897 - For each pathspec given on command line, descend at most _<depth>_
888 + --max-depth=<depth>::
889 + For each pathspec given on command line, descend at most `<depth>`
898 890 levels of directories. A value of `-1` means no limit.
899 891 Cannot be combined with wildcards in the pathspec.
900 892 Given a tree containing `foo/bar/baz`, the following list shows the
modified Documentation/fetch-options.adoc
@@ -1,6 +1,6 @@
1 1 `--all`::
2 2 `--no-all`::
3 - Fetch all remotes, except for the ones that have the
3 + Fetch all remotes, except for the ones that has the
4 4 `remote.<name>.skipFetchAll` configuration variable set.
5 5 This overrides the configuration variable `fetch.all`.
6 6
@@ -49,7 +49,6 @@ the current repository has the same history as the source repository.
49 49 `.git/shallow`. This option updates `.git/shallow` and accepts such
50 50 refs.
51 51
52 - `--negotiation-restrict=(<commit>|<glob>)`::
53 52 `--negotiation-tip=(<commit>|<glob>)`::
54 53 By default, Git will report, to the server, commits reachable
55 54 from all local refs to find common commits in an attempt to
@@ -59,9 +58,6 @@ the current repository has the same history as the source repository.
59 58 local ref is likely to have commits in common with the
60 59 upstream ref being fetched.
61 60 +
62 - `--negotiation-restrict` is the preferred name for this option;
63 - `--negotiation-tip` is accepted as a synonym.
64 - +
65 61 This option may be specified more than once; if so, Git will report
66 62 commits reachable from any of the given commits.
67 63 +
@@ -73,32 +69,9 @@ See also the `fetch.negotiationAlgorithm` and `push.negotiate`
73 69 configuration variables documented in linkgit:git-config[1], and the
74 70 `--negotiate-only` option below.
75 71
76 - `--negotiation-include=(<commit>|<glob>)`::
77 - Ensure that the commits at the given tips are always sent as "have"
78 - lines during fetch negotiation, regardless of what the negotiation
79 - algorithm selects. This is useful to guarantee that common
80 - history reachable from specific refs is always considered, even
81 - when `--negotiation-restrict` restricts the set of tips or when
82 - the negotiation algorithm would otherwise skip them.
83 - +
84 - This option may be specified more than once; if so, each commit is sent
85 - unconditionally.
86 - +
87 - The argument may be an exact ref name (e.g. `refs/heads/release`), an
88 - object hash, or a glob pattern (e.g. `refs/heads/release/{asterisk}`).
89 - The pattern syntax is the same as for `--negotiation-restrict`.
90 - +
91 - If `--negotiation-restrict` is used, the have set is first restricted by
92 - that option and then increased to include the tips specified by
93 - `--negotiation-include`.
94 - +
95 - If this option is not specified on the command line, then any
96 - `remote.<name>.negotiationInclude` config values for the current remote
97 - are used instead.
98 -
99 72 `--negotiate-only`::
100 73 Do not fetch anything from the server, and instead print the
101 - ancestors of the provided `--negotiation-restrict=` arguments,
74 + ancestors of the provided `--negotiation-tip=` arguments,
102 75 which we have in common with the server.
103 76 +
104 77 This is incompatible with `--recurse-submodules=(yes|on-demand)`.
modified Documentation/format-patch-caveats.adoc
@@ -28,6 +28,6 @@ repositories. This goes to show that this behavior does not only impact
28 28 email workflows.
29 29
30 30 Given these limitations, one might be tempted to use a general-purpose
31 - utility like `patch`(1) instead. However, `patch`(1) will not only look for
31 + utility like patch(1) instead. However, patch(1) will not only look for
32 32 unindented diffs (like linkgit:git-am[1]) but will try to apply indented
33 33 diffs as well.
modified Documentation/format-patch-end-of-commit-message.adoc
@@ -1,8 +1,8 @@
1 1 Any line that is of the form:
2 2
3 3 * three-dashes and end-of-line, or
4 - * a line that begins with `diff -`, or
5 - * a line that begins with `Index: `
4 + * a line that begins with "diff -", or
5 + * a line that begins with "Index: "
6 6
7 7 is taken as the beginning of a patch, and the commit log message
8 8 is terminated before the first occurrence of such a line.
modified Documentation/git-add.adoc
@@ -11,7 +11,7 @@ SYNOPSIS
11 11 git add [--verbose | -v] [--dry-run | -n] [--force | -f] [--interactive | -i] [--patch | -p]
12 12 [--edit | -e] [--[no-]all | -A | --[no-]ignore-removal | [--update | -u]] [--sparse]
13 13 [--intent-to-add | -N] [--refresh] [--ignore-errors] [--ignore-missing] [--renormalize]
14 - [--resolved] [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]]
14 + [--chmod=(+|-)x] [--pathspec-from-file=<file> [--pathspec-file-nul]]
15 15 [--] [<pathspec>...]
16 16
17 17 DESCRIPTION
@@ -195,14 +195,6 @@ for `git add --no-all <pathspec>...`, i.e. ignored removed files.
195 195 while a _CRLF_ cleans to _LF_, a _CRCRLF_ sequence is only partially
196 196 cleaned to _CRLF_.
197 197
198 - `--resolved`::
199 - Update the index for unmerged paths matching _<pathspec>_ where
200 - no conflict markers remain in the working tree. Unmerged paths
201 - without conflict markers (including binary files and file
202 - deletions) are staged as resolved, while any path with leftover
203 - conflict markers causes the command to refuse to stage any files.
204 - Cannot be combined with `-u` or `-A`.
205 -
206 198 `--chmod=(+|-)x`::
207 199 Override the executable bit of the added files. The executable
208 200 bit is only changed in the index, the files on disk are left
modified Documentation/git-am.adoc
@@ -8,17 +8,17 @@ git-am - Apply a series of patches from a mailbox
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git am [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--[no-]verify]
11 + [verse]
12 + 'git am' [--signoff] [--keep] [--[no-]keep-cr] [--[no-]utf8] [--[no-]verify]
13 13 [--[no-]3way] [--interactive] [--committer-date-is-author-date]
14 14 [--ignore-date] [--ignore-space-change | --ignore-whitespace]
15 15 [--whitespace=<action>] [-C<n>] [-p<n>] [--directory=<dir>]
16 16 [--exclude=<path>] [--include=<path>] [--reject] [-q | --quiet]
17 - [--[no-]scissors] [-S[<key-id>]] [--patch-format=<format>]
17 + [--[no-]scissors] [-S[<keyid>]] [--patch-format=<format>]
18 18 [--quoted-cr=<action>]
19 19 [--empty=(stop|drop|keep)]
20 20 [(<mbox> | <Maildir>)...]
21 - git am (--continue | --skip | --abort | --quit | --retry | --show-current-patch[=(diff|raw)] | --allow-empty)
21 + 'git am' (--continue | --skip | --abort | --quit | --retry | --show-current-patch[=(diff|raw)] | --allow-empty)
22 22
23 23 DESCRIPTION
24 24 -----------
@@ -30,45 +30,45 @@ history without merges.
30 30
31 31 OPTIONS
32 32 -------
33 - `(<mbox>|<Maildir>)...`::
33 + (<mbox>|<Maildir>)...::
34 34 The list of mailbox files to read patches from. If you do not
35 35 supply this argument, the command reads from the standard input.
36 36 If you supply directories, they will be treated as Maildirs.
37 37
38 - `-s`::
39 - `--signoff`::
38 + -s::
39 + --signoff::
40 40 Add a `Signed-off-by` trailer to the commit message (see
41 41 linkgit:git-interpret-trailers[1]), using the committer identity
42 42 of yourself. See the signoff option in linkgit:git-commit[1]
43 43 for more information.
44 44
45 - `-k`::
46 - `--keep`::
45 + -k::
46 + --keep::
47 47 Pass `-k` flag to linkgit:git-mailinfo[1].
48 48
49 - `--keep-non-patch`::
49 + --keep-non-patch::
50 50 Pass `-b` flag to linkgit:git-mailinfo[1].
51 51
52 - `--keep-cr`::
53 - `--no-keep-cr`::
52 + --keep-cr::
53 + --no-keep-cr::
54 54 With `--keep-cr`, call linkgit:git-mailsplit[1]
55 55 with the same option, to prevent it from stripping CR at the end of
56 56 lines. `am.keepcr` configuration variable can be used to specify the
57 57 default behaviour. `--no-keep-cr` is useful to override `am.keepcr`.
58 58
59 - `-c`::
60 - `--scissors`::
59 + -c::
60 + --scissors::
61 61 Remove everything in body before a scissors line (see
62 62 linkgit:git-mailinfo[1]). Can be activated by default using
63 63 the `mailinfo.scissors` configuration variable.
64 64
65 - `--no-scissors`::
65 + --no-scissors::
66 66 Ignore scissors lines (see linkgit:git-mailinfo[1]).
67 67
68 - `--quoted-cr=<action>`::
68 + --quoted-cr=<action>::
69 69 This flag will be passed down to linkgit:git-mailinfo[1].
70 70
71 - `--empty=(drop|keep|stop)`::
71 + --empty=(drop|keep|stop)::
72 72 How to handle an e-mail message lacking a patch:
73 73 +
74 74 --
@@ -82,23 +82,23 @@ OPTIONS
82 82 session. This is the default behavior.
83 83 --
84 84
85 - `-m`::
86 - `--message-id`::
85 + -m::
86 + --message-id::
87 87 Pass the `-m` flag to linkgit:git-mailinfo[1],
88 88 so that the `Message-ID` header is added to the commit message.
89 89 The `am.messageid` configuration variable can be used to specify
90 90 the default behaviour.
91 91
92 - `--no-message-id`::
92 + --no-message-id::
93 93 Do not add the Message-ID header to the commit message.
94 94 `--no-message-id` is useful to override `am.messageid`.
95 95
96 - `-q`::
97 - `--quiet`::
96 + -q::
97 + --quiet::
98 98 Be quiet. Only print error messages.
99 99
100 - `-u`::
101 - `--utf8`::
100 + -u::
101 + --utf8::
102 102 Pass `-u` flag to linkgit:git-mailinfo[1].
103 103 The proposed commit log message taken from the e-mail
104 104 is re-coded into UTF-8 encoding (configuration variable
@@ -108,57 +108,57 @@ OPTIONS
108 108 This was optional in prior versions of git, but now it is the
109 109 default. You can use `--no-utf8` to override this.
110 110
111 - `--no-utf8`::
111 + --no-utf8::
112 112 Pass `-n` flag to linkgit:git-mailinfo[1].
113 113
114 - `-3`::
115 - `--3way`::
116 - `--no-3way`::
114 + -3::
115 + --3way::
116 + --no-3way::
117 117 When the patch does not apply cleanly, fall back on
118 118 3-way merge if the patch records the identity of blobs
119 119 it is supposed to apply to and we have those blobs
120 120 available locally. `--no-3way` can be used to override
121 - `am.threeWay` configuration variable. For more information,
122 - see `am.threeWay` in linkgit:git-config[1].
121 + am.threeWay configuration variable. For more information,
122 + see am.threeWay in linkgit:git-config[1].
123 123
124 124 include::rerere-options.adoc[]
125 125
126 - `--ignore-space-change`::
127 - `--ignore-whitespace`::
128 - `--whitespace=<action>`::
129 - `-C<n>`::
130 - `-p<n>`::
131 - `--directory=<dir>`::
132 - `--exclude=<path>`::
133 - `--include=<path>`::
134 - `--reject`::
126 + --ignore-space-change::
127 + --ignore-whitespace::
128 + --whitespace=<action>::
129 + -C<n>::
130 + -p<n>::
131 + --directory=<dir>::
132 + --exclude=<path>::
133 + --include=<path>::
134 + --reject::
135 135 These flags are passed to the linkgit:git-apply[1] program that
136 136 applies the patch.
137 137 +
138 - Valid _<action>_ for the `--whitespace` option are:
138 + Valid <action> for the `--whitespace` option are:
139 139 `nowarn`, `warn`, `fix`, `error`, and `error-all`.
140 140
141 - `--patch-format`::
141 + --patch-format::
142 142 By default the command will try to detect the patch format
143 143 automatically. This option allows the user to bypass the automatic
144 144 detection and specify the patch format that the patch(es) should be
145 145 interpreted as. Valid formats are mbox, mboxrd,
146 146 stgit, stgit-series, and hg.
147 147
148 - `-i`::
149 - `--interactive`::
148 + -i::
149 + --interactive::
150 150 Run interactively.
151 151
152 - `--verify`::
153 - `-n`::
154 - `--no-verify`::
152 + --verify::
153 + -n::
154 + --no-verify::
155 155 Run the `pre-applypatch` and `applypatch-msg` hooks. This is the
156 156 default. Skip these hooks with `-n` or `--no-verify`. See also
157 157 linkgit:githooks[5].
158 158 +
159 159 Note that `post-applypatch` cannot be skipped.
160 160
161 - `--committer-date-is-author-date`::
161 + --committer-date-is-author-date::
162 162 By default the command records the date from the e-mail
163 163 message as the commit author date, and uses the time of
164 164 commit creation as the committer date. This allows the
@@ -172,29 +172,29 @@ committer date when applying commits on top of a base which commit is
172 172 older (in terms of the commit date) than the oldest patch you are
173 173 applying.
174 174
175 - `--ignore-date`::
175 + --ignore-date::
176 176 By default the command records the date from the e-mail
177 177 message as the commit author date, and uses the time of
178 178 commit creation as the committer date. This allows the
179 179 user to lie about the author date by using the same
180 180 value as the committer date.
181 181
182 - `--skip`::
182 + --skip::
183 183 Skip the current patch. This is only meaningful when
184 184 restarting an aborted patch.
185 185
186 - `-S[<key-id>]`::
187 - `--gpg-sign[=<key-id>]`::
188 - `--no-gpg-sign`::
189 - GPG-sign commits. The _<key-id>_ is optional and
186 + -S[<keyid>]::
187 + --gpg-sign[=<keyid>]::
188 + --no-gpg-sign::
189 + GPG-sign commits. The `keyid` argument is optional and
190 190 defaults to the committer identity; if specified, it must be
191 191 stuck to the option without a space. `--no-gpg-sign` is useful to
192 192 countermand both `commit.gpgSign` configuration variable, and
193 193 earlier `--gpg-sign`.
194 194
195 - `--continue`::
196 - `-r`::
197 - `--resolved`::
195 + --continue::
196 + -r::
197 + --resolved::
198 198 After a patch failure (e.g. attempting to apply
199 199 conflicting patch), the user has applied it by hand and
200 200 the index file stores the result of the application.
@@ -202,36 +202,36 @@ applying.
202 202 extracted from the e-mail message and the current index
203 203 file, and continue.
204 204
205 - `--resolvemsg=<msg>`::
206 - When a patch failure occurs, _<msg>_ will be printed
205 + --resolvemsg=<msg>::
206 + When a patch failure occurs, <msg> will be printed
207 207 to the screen before exiting. This overrides the
208 208 standard message informing you to use `--continue`
209 209 or `--skip` to handle the failure. This is solely
210 210 for internal use between linkgit:git-rebase[1] and
211 211 linkgit:git-am[1].
212 212
213 - `--abort`::
213 + --abort::
214 214 Restore the original branch and abort the patching operation.
215 215 Revert the contents of files involved in the am operation to their
216 216 pre-am state.
217 217
218 - `--quit`::
219 - Abort the patching operation but keep `HEAD` and the index
218 + --quit::
219 + Abort the patching operation but keep HEAD and the index
220 220 untouched.
221 221
222 - `--retry`::
222 + --retry::
223 223 Try to apply the last conflicting patch again. This is generally
224 224 only useful for passing extra options to the retry attempt
225 225 (e.g., `--3way`), since otherwise you'll just see the same
226 226 failure again.
227 227
228 - `--show-current-patch[=(diff|raw)]`::
228 + --show-current-patch[=(diff|raw)]::
229 229 Show the message at which linkgit:git-am[1] has stopped due to
230 230 conflicts. If `raw` is specified, show the raw contents of
231 231 the e-mail message; if `diff`, show the diff portion only.
232 232 Defaults to `raw`.
233 233
234 - `--allow-empty`::
234 + --allow-empty::
235 235 After a patch failure on an input e-mail message lacking a patch,
236 236 create an empty commit with the contents of the e-mail message
237 237 as its log message.
@@ -278,11 +278,11 @@ operation is finished, so if you decide to start over from scratch,
278 278 run `git am --abort` before running the command with mailbox
279 279 names.
280 280
281 - Before any patches are applied, `ORIG_HEAD` is set to the tip of the
281 + Before any patches are applied, ORIG_HEAD is set to the tip of the
282 282 current branch. This is useful if you have problems with multiple
283 283 commits, like running linkgit:git-am[1] on the wrong branch or an error
284 284 in the commits that is more easily fixed by changing the mailbox (e.g.
285 - errors in the `From:` lines).
285 + errors in the "From:" lines).
286 286
287 287 [[caveats]]
288 288 CAVEATS
modified Documentation/git-apply.adoc
@@ -8,8 +8,8 @@ git-apply - Apply a patch to files and/or to the index
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git apply [--stat] [--numstat] [--summary] [--check]
11 + [verse]
12 + 'git apply' [--stat] [--numstat] [--summary] [--check]
13 13 [--index | --intent-to-add] [--3way] [--ours | --theirs | --union]
14 14 [--apply] [--no-add] [--build-fake-ancestor=<file>] [-R | --reverse]
15 15 [--allow-binary-replacement | --binary] [--reject] [-z]
@@ -35,33 +35,33 @@ linkgit:git-format-patch[1] and/or received by email.
35 35
36 36 OPTIONS
37 37 -------
38 - `<patch>...`::
39 - The files to read the patch from. `-` can be used to read
38 + <patch>...::
39 + The files to read the patch from. '-' can be used to read
40 40 from the standard input.
41 41
42 - `--stat`::
42 + --stat::
43 43 Instead of applying the patch, output diffstat for the
44 44 input. Turns off "apply".
45 45
46 - `--numstat`::
46 + --numstat::
47 47 Similar to `--stat`, but shows the number of added and
48 48 deleted lines in decimal notation and the pathname without
49 49 abbreviation, to make it more machine friendly. For
50 50 binary files, outputs two `-` instead of saying
51 51 `0 0`. Turns off "apply".
52 52
53 - `--summary`::
53 + --summary::
54 54 Instead of applying the patch, output a condensed
55 55 summary of information obtained from git diff extended
56 56 headers, such as creations, renames, and mode changes.
57 57 Turns off "apply".
58 58
59 - `--check`::
59 + --check::
60 60 Instead of applying the patch, see if the patch is
61 61 applicable to the current working tree and/or the index
62 62 file and detects errors. Turns off "apply".
63 63
64 - `--index`::
64 + --index::
65 65 Apply the patch to both the index and the working tree (or
66 66 merely check that it would apply cleanly to both if `--check` is
67 67 in effect). Note that `--index` expects index entries and
@@ -70,13 +70,13 @@ OPTIONS
70 70 raise an error if they are not, even if the patch would apply
71 71 cleanly to both the index and the working tree in isolation.
72 72
73 - `--cached`::
73 + --cached::
74 74 Apply the patch to just the index, without touching the working
75 75 tree. If `--check` is in effect, merely check that it would
76 76 apply cleanly to the index entry.
77 77
78 - `-N`::
79 - `--intent-to-add`::
78 + -N::
79 + --intent-to-add::
80 80 When applying the patch only to the working tree, mark new
81 81 files to be added to the index later (see `--intent-to-add`
82 82 option in linkgit:git-add[1]). This option is ignored if
@@ -84,8 +84,8 @@ OPTIONS
84 84 repository. Note that `--index` could be implied by other options
85 85 such as `--3way`.
86 86
87 - `-3`::
88 - `--3way`::
87 + -3::
88 + --3way::
89 89 Attempt 3-way merge if the patch records the identity of blobs it is supposed
90 90 to apply to and we have those blobs available locally, possibly leaving the
91 91 conflict markers in the files in the working tree for the user to
@@ -94,14 +94,14 @@ OPTIONS
94 94 When used with the `--cached` option, any conflicts are left at higher stages
95 95 in the cache.
96 96
97 - `--ours`::
98 - `--theirs`::
99 - `--union`::
97 + --ours::
98 + --theirs::
99 + --union::
100 100 Instead of leaving conflicts in the file, resolve conflicts favouring
101 - our (or their or both) side of the lines. Requires `--3way`.
101 + our (or their or both) side of the lines. Requires --3way.
102 102
103 - `--build-fake-ancestor=<file>`::
104 - Newer `git diff` output has embedded 'index information'
103 + --build-fake-ancestor=<file>::
104 + Newer 'git diff' output has embedded 'index information'
105 105 for each blob to help identify the original version that
106 106 the patch applies to. When this flag is given, and if
107 107 the original versions of the blobs are available locally,
@@ -110,18 +110,18 @@ OPTIONS
110 110 When a pure mode change is encountered (which has no index information),
111 111 the information is read from the current index instead.
112 112
113 - `-R`::
114 - `--reverse`::
113 + -R::
114 + --reverse::
115 115 Apply the patch in reverse.
116 116
117 - `--reject`::
118 - For atomicity, `git apply` by default fails the whole patch and
117 + --reject::
118 + For atomicity, 'git apply' by default fails the whole patch and
119 119 does not touch the working tree when some of the hunks
120 120 do not apply. This option makes it apply
121 121 the parts of the patch that are applicable, and leave the
122 - rejected hunks in corresponding `*.rej` files.
122 + rejected hunks in corresponding *.rej files.
123 123
124 - `-z`::
124 + -z::
125 125 When `--numstat` has been given, do not munge pathnames,
126 126 but use a NUL-terminated machine-readable format.
127 127 +
@@ -129,20 +129,20 @@ Without this option, pathnames with "unusual" characters are quoted as
129 129 explained for the configuration variable `core.quotePath` (see
130 130 linkgit:git-config[1]).
131 131
132 - `-p<n>`::
133 - Remove _<n>_ leading path components (separated by slashes) from
132 + -p<n>::
133 + Remove <n> leading path components (separated by slashes) from
134 134 traditional diff paths. E.g., with `-p2`, a patch against
135 135 `a/dir/file` will be applied directly to `file`. The default is
136 136 1.
137 137
138 - `-C<n>`::
139 - Ensure at least _<n>_ lines of surrounding context match before
138 + -C<n>::
139 + Ensure at least <n> lines of surrounding context match before
140 140 and after each change. When fewer lines of surrounding
141 141 context exist they all must match. By default no context is
142 142 ever ignored.
143 143
144 - `--unidiff-zero`::
145 - By default, `git apply` expects that the patch being
144 + --unidiff-zero::
145 + By default, 'git apply' expects that the patch being
146 146 applied is a unified diff with at least one line of context.
147 147 This provides good safety measures, but breaks down when
148 148 applying a diff generated with `--unified=0`. To bypass these
@@ -151,34 +151,34 @@ linkgit:git-config[1]).
151 151 Note, for the reasons stated above, the usage of context-free patches is
152 152 discouraged.
153 153
154 - `--apply`::
154 + --apply::
155 155 If you use any of the options marked "Turns off
156 - 'apply'" above, `git apply` reads and outputs the
156 + 'apply'" above, 'git apply' reads and outputs the
157 157 requested information without actually applying the
158 158 patch. Give this flag after those flags to also apply
159 159 the patch.
160 160
161 - `--no-add`::
161 + --no-add::
162 162 When applying a patch, ignore additions made by the
163 163 patch. This can be used to extract the common part between
164 - two files by first running `diff` on them and applying
164 + two files by first running 'diff' on them and applying
165 165 the result with this option, which would apply the
166 166 deletion part but not the addition part.
167 167
168 - `--allow-binary-replacement`::
169 - `--binary`::
168 + --allow-binary-replacement::
169 + --binary::
170 170 Historically we did not allow binary patch application
171 171 without an explicit permission from the user, and this
172 172 flag was the way to do so. Currently, we always allow binary
173 173 patch application, so this is a no-op.
174 174
175 - `--exclude=<path-pattern>`::
176 - Don't apply changes to files matching _<path-pattern>_. This can
175 + --exclude=<path-pattern>::
176 + Don't apply changes to files matching the given path pattern. This can
177 177 be useful when importing patchsets, where you want to exclude certain
178 178 files or directories.
179 179
180 - `--include=<path-pattern>`::
181 - Apply changes to files matching the _<path-pattern>_. This can
180 + --include=<path-pattern>::
181 + Apply changes to files matching the given path pattern. This can
182 182 be useful when importing patchsets, where you want to include certain
183 183 files or directories.
184 184 +
@@ -188,15 +188,15 @@ patch to each path is used. A patch to a path that does not match any
188 188 include/exclude pattern is used by default if there is no include pattern
189 189 on the command line, and ignored if there is any include pattern.
190 190
191 - `--ignore-space-change`::
192 - `--ignore-whitespace`::
191 + --ignore-space-change::
192 + --ignore-whitespace::
193 193 When applying a patch, ignore changes in whitespace in context
194 194 lines if necessary.
195 195 Context lines will preserve their whitespace, and they will not
196 196 undergo whitespace fixing regardless of the value of the
197 197 `--whitespace` option. New lines will still be fixed, though.
198 198
199 - `--whitespace=<action>`::
199 + --whitespace=<action>::
200 200 When applying a patch, detect a new or modified line that has
201 201 whitespace errors. What are considered whitespace errors is
202 202 controlled by `core.whitespace` configuration. By default,
@@ -209,7 +209,7 @@ By default, the command outputs warning messages but applies the patch.
209 209 When `git-apply` is used for statistics and not applying a
210 210 patch, it defaults to `nowarn`.
211 211 +
212 - You can use different _<action>_ values to control this
212 + You can use different `<action>` values to control this
213 213 behavior:
214 214 +
215 215 * `nowarn` turns off the trailing whitespace warning.
@@ -223,48 +223,48 @@ behavior:
223 223 to apply the patch.
224 224 * `error-all` is similar to `error` but shows all errors.
225 225
226 - `--inaccurate-eof`::
227 - Under certain circumstances, some versions of `diff` do not correctly
226 + --inaccurate-eof::
227 + Under certain circumstances, some versions of 'diff' do not correctly
228 228 detect a missing new-line at the end of the file. As a result, patches
229 - created by such `diff` programs do not record incomplete lines
229 + created by such 'diff' programs do not record incomplete lines
230 230 correctly. This option adds support for applying such patches by
231 231 working around this bug.
232 232
233 - `-v`::
234 - `--verbose`::
233 + -v::
234 + --verbose::
235 235 Report progress to stderr. By default, only a message about the
236 236 current patch being applied will be printed. This option will cause
237 237 additional information to be reported.
238 238
239 - `-q`::
240 - `--quiet`::
239 + -q::
240 + --quiet::
241 241 Suppress stderr output. Messages about patch status and progress
242 242 will not be printed.
243 243
244 - `--recount`::
244 + --recount::
245 245 Do not trust the line counts in the hunk headers, but infer them
246 246 by inspecting the patch (e.g. after editing the patch without
247 247 adjusting the hunk headers appropriately).
248 248
249 - `--directory=<root>`::
250 - Prepend _<root>_ to all filenames. If a `-p` argument was also passed,
249 + --directory=<root>::
250 + Prepend <root> to all filenames. If a "-p" argument was also passed,
251 251 it is applied before prepending the new root.
252 252 +
253 253 For example, a patch that talks about updating `a/git-gui.sh` to `b/git-gui.sh`
254 254 can be applied to the file in the working tree `modules/git-gui/git-gui.sh` by
255 255 running `git apply --directory=modules/git-gui`.
256 256
257 - `--unsafe-paths`::
257 + --unsafe-paths::
258 258 By default, a patch that affects outside the working area
259 259 (either a Git controlled working tree, or the current working
260 - directory when `git apply` is used as a replacement of GNU
261 - `patch`) is rejected as a mistake (or a mischief).
260 + directory when "git apply" is used as a replacement of GNU
261 + patch) is rejected as a mistake (or a mischief).
262 262 +
263 - When `git apply` is used as a "better GNU `patch`", the user can pass
263 + When `git apply` is used as a "better GNU patch", the user can pass
264 264 the `--unsafe-paths` option to override this safety check. This option
265 265 has no effect when `--index` or `--cached` is in use.
266 266
267 - `--allow-empty`::
267 + --allow-empty::
268 268 Don't return an error for patches containing no diff. This includes
269 269 empty patches and patches with commit text only.
270 270
@@ -273,12 +273,11 @@ CONFIGURATION
273 273
274 274 include::includes/cmd-config-section-all.adoc[]
275 275
276 - :git-apply: 1
277 276 include::config/apply.adoc[]
278 277
279 278 SUBMODULES
280 279 ----------
281 - If the patch contains any changes to submodules then `git apply`
280 + If the patch contains any changes to submodules then 'git apply'
282 281 treats these changes as follows.
283 282
284 283 If `--index` is specified (explicitly or implicitly), then the submodule
modified Documentation/git-backfill.adoc
@@ -9,7 +9,7 @@ git-backfill - Download missing objects in a partial clone
9 9 SYNOPSIS
10 10 --------
11 11 [synopsis]
12 - git backfill [--min-batch-size=<n>] [--[no-]sparse] [--[no-]include-edges] [<revision-range>]
12 + git backfill [--min-batch-size=<n>] [--[no-]sparse]
13 13
14 14 DESCRIPTION
15 15 -----------
@@ -43,7 +43,7 @@ smaller network calls than downloading the entire repository at clone
43 43 time.
44 44
45 45 By default, `git backfill` downloads all blobs reachable from the `HEAD`
46 - commit. This set can be restricted or expanded using various options below.
46 + commit. This set can be restricted or expanded using various options.
47 47
48 48 THIS COMMAND IS EXPERIMENTAL. ITS BEHAVIOR MAY CHANGE IN THE FUTURE.
49 49
@@ -63,27 +63,7 @@ OPTIONS
63 63 current sparse-checkout. If the sparse-checkout feature is enabled,
64 64 then `--sparse` is assumed and can be disabled with `--no-sparse`.
65 65
66 - `--include-edges`::
67 - `--no-include-edges`::
68 - Include blobs from boundary commits in the backfill. Useful in
69 - preparation for commands like `git log -p A..B` or `git replay
70 - --onto TARGET A..B`, where A..B normally excludes A but you need
71 - the blobs from A as well. `--include-edges` is the default.
72 -
73 - `<revision-range>`::
74 - Backfill only blobs reachable from commits in the specified
75 - revision range. When no _<revision-range>_ is specified, it
76 - defaults to `HEAD` (i.e. the whole history leading to the
77 - current commit). For a complete list of ways to spell
78 - _<revision-range>_, see the "Specifying Ranges" section of
79 - linkgit:gitrevisions[7].
80 - +
81 - You may also use commit-limiting options understood by
82 - linkgit:git-rev-list[1] such as `--first-parent`, `--since`, or pathspecs.
83 - +
84 - Most `--filter=<spec>` options don't work with the purpose of
85 - `git backfill`, but the `sparse:<oid>` filter is integrated to provide a
86 - focused set of paths to download, distinct from the `--sparse` option.
66 + You may also specify the commit limiting options from linkgit:git-rev-list[1].
87 67
88 68 SEE ALSO
89 69 --------
modified Documentation/git-bisect.adoc
@@ -8,20 +8,20 @@ git-bisect - Use binary search to find the commit that introduced a bug
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]
13 - [--no-checkout] [--first-parent] [--reset-when-found[=<where>]] [<bad> [<good>...]] [--] [<pathspec>...]
14 - git bisect (bad|new|<term-new>) [<rev>]
15 - git bisect (good|old|<term-old>) [<rev>...]
16 - git bisect terms [--term-(good|old) | --term-(bad|new)]
17 - git bisect skip [(<rev>|<range>)...]
18 - git bisect next
19 - git bisect reset [<commit>]
20 - git bisect (visualize|view)
21 - git bisect replay <logfile>
22 - git bisect log
23 - git bisect run [--reset-when-found[=<where>]] <cmd> [<arg>...]
24 - git bisect help
11 + [verse]
12 + 'git bisect' start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]
13 + [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]
14 + 'git bisect' (bad|new|<term-new>) [<rev>]
15 + 'git bisect' (good|old|<term-old>) [<rev>...]
16 + 'git bisect' terms [--term-(good|old) | --term-(bad|new)]
17 + 'git bisect' skip [(<rev>|<range>)...]
18 + 'git bisect' next
19 + 'git bisect' reset [<commit>]
20 + 'git bisect' (visualize|view)
21 + 'git bisect' replay <logfile>
22 + 'git bisect' log
23 + 'git bisect' run <cmd> [<arg>...]
24 + 'git bisect' help
25 25
26 26 DESCRIPTION
27 27 -----------
@@ -94,10 +94,11 @@ Bisect reset
94 94 ~~~~~~~~~~~~
95 95
96 96 After a bisect session, to clean up the bisection state and return to
97 - the original `HEAD`, issue the following command:
97 + the original HEAD, issue the following command:
98 98
99 - [synopsis]
100 - git bisect reset
99 + ------------------------------------------------
100 + $ git bisect reset
101 + ------------------------------------------------
101 102
102 103 By default, this will return your tree to the commit that was checked
103 104 out before `git bisect start`. (A new `git bisect start` will also do
@@ -106,9 +107,9 @@ that, as it cleans up the old bisection state.)
106 107 With an optional argument, you can return to a different commit
107 108 instead:
108 109
109 - [synopsis]
110 - git bisect reset <commit>
111 -
110 + ------------------------------------------------
111 + $ git bisect reset <commit>
112 + ------------------------------------------------
112 113
113 114 For example, `git bisect reset bisect/bad` will check out the first
114 115 bad revision, while `git bisect reset HEAD` will leave you on the
@@ -142,20 +143,23 @@ To use "old" and "new" instead of "good" and bad, you must run `git
142 143 bisect start` without commits as argument and then run the following
143 144 commands to add the commits:
144 145
145 - [synopsis]
146 + ------------------------------------------------
146 147 git bisect old [<rev>]
148 + ------------------------------------------------
147 149
148 150 to indicate that a commit was before the sought change, or
149 151
150 - [synopsis]
152 + ------------------------------------------------
151 153 git bisect new [<rev>...]
154 + ------------------------------------------------
152 155
153 156 to indicate that it was after.
154 157
155 158 To get a reminder of the currently used terms, use
156 159
157 - [synopsis]
160 + ------------------------------------------------
158 161 git bisect terms
162 + ------------------------------------------------
159 163
160 164 You can get just the old term with `git bisect terms --term-old`
161 165 or `git bisect terms --term-good`; `git bisect terms --term-new`
@@ -167,20 +171,21 @@ If you would like to use your own terms instead of "bad"/"good" or
167 171 subcommands like `reset`, `start`, ...) by starting the
168 172 bisection using
169 173
170 - [synopsis]
174 + ------------------------------------------------
171 175 git bisect start --term-old <term-old> --term-new <term-new>
176 + ------------------------------------------------
172 177
173 178 For example, if you are looking for a commit that introduced a
174 179 performance regression, you might use
175 180
176 181 ------------------------------------------------
177 - $ git bisect start --term-old fast --term-new slow
182 + git bisect start --term-old fast --term-new slow
178 183 ------------------------------------------------
179 184
180 185 Or if you are looking for the commit that fixed a bug, you might use
181 186
182 187 ------------------------------------------------
183 - $ git bisect start --term-new fixed --term-old broken
188 + git bisect start --term-new fixed --term-old broken
184 189 ------------------------------------------------
185 190
186 191 Then, use `git bisect <term-old>` and `git bisect <term-new>` instead
@@ -189,7 +194,7 @@ of `git bisect good` and `git bisect bad` to mark commits.
189 194 Bisect visualize/view
190 195 ~~~~~~~~~~~~~~~~~~~~~
191 196
192 - To see the currently remaining suspects in `gitk`, issue the following
197 + To see the currently remaining suspects in 'gitk', issue the following
193 198 command during the bisection process (the subcommand `view` can be used
194 199 as an alternative to `visualize`):
195 200
@@ -198,13 +203,12 @@ $ git bisect visualize
198 203 ------------
199 204
200 205 Git detects a graphical environment through various environment variables:
206 + `DISPLAY`, which is set in X Window System environments on Unix systems.
207 + `SESSIONNAME`, which is set under Cygwin in interactive desktop sessions.
208 + `MSYSTEM`, which is set under Msys2 and Git for Windows.
209 + `SECURITYSESSIONID`, which may be set on macOS in interactive desktop sessions.
201 210
202 - `DISPLAY`:: which is set in X Window System environments on Unix systems.
203 - `SESSIONNAME`:: which is set under Cygwin in interactive desktop sessions.
204 - `MSYSTEM`:: which is set under Msys2 and Git for Windows.
205 - `SECURITYSESSIONID`:: which may be set on macOS in interactive desktop sessions.
206 -
207 - If none of these environment variables is set, `git log` is used instead.
211 + If none of these environment variables is set, 'git log' is used instead.
208 212 You can also give command-line options such as `-p` and `--stat`.
209 213
210 214 ------------
@@ -328,17 +332,18 @@ Bisect run
328 332 If you have a script that can tell if the current source code is good
329 333 or bad, you can bisect by issuing the command:
330 334
331 - [synopsis]
332 - git bisect run <cmd> [<arg>...]
335 + ------------
336 + $ git bisect run my_script arguments
337 + ------------
333 338
334 - Note that _<cmd>_ run with _<arg>_ should exit
339 + Note that the script (`my_script` in the above example) should exit
335 340 with code 0 if the current source code is good/old, and exit with a
336 341 code between 1 and 127 (inclusive), except 125, if the current source
337 342 code is bad/new.
338 343
339 344 Any other exit code will abort the bisect process. It should be noted
340 - that a program that terminates via `exit(-1)` leaves `$?` = 255, (see the
341 - `exit`(3) manual page), as the value is chopped with `& 0377`.
345 + that a program that terminates via `exit(-1)` leaves $? = 255, (see the
346 + exit(3) manual page), as the value is chopped with `& 0377`.
342 347
343 348 The special exit code 125 should be used when the current source code
344 349 cannot be tested. If the script exits with this code, the current
@@ -350,12 +355,12 @@ details do not matter, as they are normal errors in the script, as far as
350 355 `bisect run` is concerned).
351 356
352 357 You may often find that during a bisect session you want to have
353 - temporary modifications (e.g. `s/#define DEBUG 0/#define DEBUG 1/` in a
358 + temporary modifications (e.g. s/#define DEBUG 0/#define DEBUG 1/ in a
354 359 header file, or "revision that does not have this commit needs this
355 360 patch applied to work around another problem this bisection is not
356 361 interested in") applied to the revision being tested.
357 362
358 - To cope with such a situation, after the inner `git bisect` finds the
363 + To cope with such a situation, after the inner 'git bisect' finds the
359 364 next revision to test, the script can apply the patch
360 365 before compiling, run the real test, and afterwards decide if the
361 366 revision (possibly with the needed patch) passed the test and then
@@ -365,18 +370,20 @@ determine the eventual outcome of the bisect session.
365 370
366 371 OPTIONS
367 372 -------
368 - `--no-checkout`::
369 - Do not checkout the new working tree at each iteration of the bisection
370 - process. Instead just update the reference named `BISECT_HEAD` to make
371 - it point to the commit that should be tested.
373 + --no-checkout::
374 + +
375 + Do not checkout the new working tree at each iteration of the bisection
376 + process. Instead just update the reference named `BISECT_HEAD` to make
377 + it point to the commit that should be tested.
372 378 +
373 379 This option may be useful when the test you would perform in each step
374 380 does not require a checked out tree.
375 381 +
376 382 If the repository is bare, `--no-checkout` is assumed.
377 383
378 - `--first-parent`::
379 - Follow only the first parent commit upon seeing a merge commit.
384 + --first-parent::
385 + +
386 + Follow only the first parent commit upon seeing a merge commit.
380 387 +
381 388 In detecting regressions introduced through the merging of a branch, the merge
382 389 commit will be identified as introduction of the bug and its ancestors will be
@@ -385,20 +392,10 @@ ignored.
385 392 This option is particularly useful in avoiding false positives when a merged
386 393 branch contained broken or non-buildable commits, but the merge itself was OK.
387 394
388 - `--reset-when-found[=<where>]`::
389 - Once the first bad commit is found, report it and clean up the
390 - bisection state. `<where>` may be `original` to return to the commit
391 - checked out before `git bisect start`, or `found` to leave the first
392 - bad commit checked out. If `<where>` is omitted, it defaults to
393 - `original`.
394 - +
395 - This option may be given to `git bisect start` or to `git bisect run`. It
396 - cannot be used for a bisection started with `--no-checkout`.
397 -
398 395 EXAMPLES
399 396 --------
400 397
401 - * Automatically bisect a broken build between v1.2 and `HEAD`:
398 + * Automatically bisect a broken build between v1.2 and HEAD:
402 399 +
403 400 ------------
404 401 $ git bisect start HEAD v1.2 -- # HEAD is bad, v1.2 is good
@@ -406,7 +403,7 @@ $ git bisect run make # "make" builds the app
406 403 $ git bisect reset # quit the bisect session
407 404 ------------
408 405
409 - * Automatically bisect a test failure between origin and `HEAD`:
406 + * Automatically bisect a test failure between origin and HEAD:
410 407 +
411 408 ------------
412 409 $ git bisect start HEAD origin -- # HEAD is bad, origin is good
@@ -433,7 +430,7 @@ and `exit 1` otherwise.
433 430 +
434 431 It is safer if both `test.sh` and `check_test_case.sh` are
435 432 outside the repository to prevent interactions between the bisect,
436 - `make` and test processes and the scripts.
433 + make and test processes and the scripts.
437 434
438 435 * Automatically bisect with temporary modifications (hot-fix):
439 436 +
@@ -494,9 +491,9 @@ $ git bisect run sh -c '
494 491 $ git bisect reset # quit the bisect session
495 492 ------------
496 493 +
497 - In this case, when `git bisect run` finishes, `bisect/bad` will refer to a commit that
494 + In this case, when 'git bisect run' finishes, bisect/bad will refer to a commit that
498 495 has at least one parent whose reachable graph is fully traversable in the sense
499 - required by `git pack-objects`.
496 + required by 'git pack objects'.
500 497
501 498 * Look for a fix instead of a regression in the code
502 499 +
modified Documentation/git-blame.adoc
@@ -88,12 +88,11 @@ include::blame-options.adoc[]
88 88 include::diff-algorithm-option.adoc[]
89 89
90 90 `--abbrev=<n>`::
91 - Instead of using the default _7_ hexadecimal digits as the
92 - abbreviated object name, use at least _<n>_ digits, but ensure
93 - the commit object names are unique.
94 - If commits marked with caret (boundary), question mark (ignored)
95 - or asterisk (unblamable) are shown, extend unmarked object names
96 - to align them.
91 + Instead of using the default _7+1_ hexadecimal digits as the
92 + abbreviated object name, use _<m>+1_ digits, where _<m>_ is at
93 + least _<n>_ but ensures the commit object names are unique.
94 + Note that 1 column
95 + is used for a caret to mark the boundary commit.
97 96
98 97
99 98 THE DEFAULT FORMAT
modified Documentation/git-branch.adoc
@@ -13,7 +13,6 @@ git branch [--color[=<when>] | --no-color] [--show-current]
13 13 [--column[=<options>] | --no-column] [--sort=<key>]
14 14 [--merged [<commit>]] [--no-merged [<commit>]]
15 15 [--contains [<commit>]] [--no-contains [<commit>]]
16 - [(--forked <branch>)...]
17 16 [--points-at <object>] [--format=<format>]
18 17 [(-r|--remotes) | (-a|--all)]
19 18 [--list] [<pattern>...]
@@ -25,7 +24,6 @@ git branch (-m|-M) [<old-branch>] <new-branch>
25 24 git branch (-c|-C) [<old-branch>] <new-branch>
26 25 git branch (-d|-D) [-r] <branch-name>...
27 26 git branch --edit-description [<branch-name>]
28 - git branch [--dry-run] (--delete-merged <pattern>)... [<branch-pattern>...]
29 27
30 28 DESCRIPTION
31 29 -----------
@@ -53,8 +51,7 @@ merged into the named commit (i.e. the branches whose tip commits are
53 51 reachable from the named commit) will be listed. With `--no-merged` only
54 52 branches not merged into the named commit will be listed. If the _<commit>_
55 53 argument is missing it defaults to `HEAD` (i.e. the tip of the current
56 - branch). With `--forked`, only branches whose configured upstream matches
57 - the given branch or pattern will be listed.
54 + branch).
58 55
59 56 The command's second form creates a new branch head named _<branch-name>_
60 57 which points to the current `HEAD`, or _<start-point>_ if given. As a
@@ -202,45 +199,6 @@ This option is only applicable in non-verbose mode.
202 199 Print the name of the current branch. In detached `HEAD` state,
203 200 nothing is printed.
204 201
205 - `--delete-merged <pattern>`::
206 - Delete local branches whose configured upstream matches
207 - _<pattern>_, but only when their tip is reachable from that
208 - upstream. In other words, the work on the branch has already
209 - landed on the upstream it tracks, so the local copy is no longer
210 - needed. _<pattern>_ may name a ref, a remote (using the branch its
211 - `HEAD` points at), or a shell-style glob. The option can be
212 - repeated to widen the upstream match.
213 - Optional _<branch-pattern>_ arguments limit which local branches
214 - are considered, e.g. `git branch --delete-merged 'origin/*'
215 - 'topic-*'`.
216 - +
217 - A branch is not deleted when:
218 - +
219 - --
220 - * its configured upstream ref no longer exists,
221 - * it is checked out in any worktree,
222 - * pushing it to the remote configured by
223 - `branch.<name>.remote` would update its upstream, so it cannot be
224 - distinguished from a branch that just looks fully merged right
225 - after a pull; this is determined by the remote's configured push and
226 - fetch refspecs,
227 - * it is the local upstream of a branch that is not being deleted, or
228 - * `branch.<name>.deleteMerged` is set to `false`.
229 - --
230 - +
231 - When such a local upstream branch has its own upstream deleted by the
232 - same operation, its upstream configuration is cleared.
233 - +
234 - A branch whose work has not yet been merged into its upstream is
235 - silently skipped. Delete it with `git branch -D` if you want to
236 - remove it anyway.
237 -
238 - `--dry-run`::
239 - With `--delete-merged`, print which branches would be
240 - deleted and exit without touching any ref. Useful for
241 - sanity-checking a wide pattern like `'origin/*'` before
242 - committing to the deletion.
243 -
244 202 `-v`::
245 203 `-vv`::
246 204 `--verbose`::
@@ -353,14 +311,6 @@ superproject's "origin/main", but tracks the submodule's "origin/main".
353 311 Only list branches whose tips are not reachable from
354 312 _<commit>_ (`HEAD` if not specified). Implies `--list`.
355 313
356 - `--forked <branch>`::
357 - Only list branches whose configured upstream matches
358 - _<branch>_. The argument can be a ref (e.g. `origin/main`,
359 - `master`), a remote name like `origin` for the branch its
360 - `origin/HEAD` points at, or a shell-style glob (e.g.
361 - `'origin/*'`). The option can be repeated to widen the
362 - filter. Implies `--list`.
363 -
364 314 `--points-at <object>`::
365 315 Only list branches of _<object>_.
366 316
modified Documentation/git-cat-file.adoc
@@ -169,23 +169,11 @@ info <object>::
169 169 Print object info for object reference `<object>`. This corresponds to the
170 170 output of `--batch-check`.
171 171
172 - remote-object-info <remote> <object>...::
173 - Print object info for object references `<object>` at specified
174 - `<remote>` without downloading objects from the remote.
175 - Raise an error when the `object-info` capability is not supported by the remote.
176 - Raise an error when no object references are provided.
177 - This command may be combined with `--buffer`.
178 -
179 172 flush::
180 173 Used with `--buffer` to execute all preceding commands that were issued
181 174 since the beginning or since the last flush was issued. When `--buffer`
182 175 is used, no output will come until a `flush` is issued. When `--buffer`
183 176 is not used, commands are flushed each time without issuing `flush`.
184 -
185 - `mailmap (<bool>)`::
186 - Enable or disable mailmap for subsequent commands. The `<bool>`
187 - argument accepts the same boolean values as linkgit:git-config[1].
188 - The mailmap data is read upon the first use and only once.
189 177 --
190 178 +
191 179
@@ -308,8 +296,7 @@ one per line, and print information based on the command given. With
308 296 `--batch-command`, the `info` command followed by an object will print
309 297 information about the object the same way `--batch-check` would, and the
310 298 `contents` command followed by an object prints contents in the same way
311 - `--batch` would. The `remote-object-info` command followed by a remote and
312 - object IDs prints object info from the remote without downloading the objects.
299 + `--batch` would.
313 300
314 301 You can specify the information shown for each object by using a custom
315 302 `<format>`. The `<format>` is copied literally to stdout for each
@@ -348,10 +335,6 @@ newline. The available atoms are:
348 335 after that first run of whitespace (i.e., the "rest" of the
349 336 line) are output in place of the `%(rest)` atom.
350 337
351 - The command `remote-object-info` only supports the `%(objectname)`,
352 - `%(objectsize)` and `%(objecttype)` placeholders. See `CAVEATS` below for more
353 - information.
354 -
355 338 If no format is specified, the default format is `%(objectname)
356 339 %(objecttype) %(objectsize)`.
357 340
@@ -450,10 +433,6 @@ scripting purposes.
450 433 CAVEATS
451 434 -------
452 435
453 - Note that only `%(objectname)`, `%(objectsize)` and `%(objecttype)` are
454 - currently supported by the `remote-object-info` command. Using any other
455 - placeholder in the format string will return an empty string in its position.
456 -
457 436 Note that the sizes of objects on disk are reported accurately, but care
458 437 should be taken in drawing conclusions about which refs or objects are
459 438 responsible for disk usage. The size of a packed non-delta object may be
modified Documentation/git-checkout.adoc
@@ -251,19 +251,20 @@ working tree, by copying them from elsewhere, extracting a tarball, etc.
251 251 are different between the current branch and the branch to
252 252 which you are switching, the command refuses to switch
253 253 branches in order to preserve your modifications in context.
254 - With this option, the conflicting local changes are
255 - automatically stashed before the switch and reapplied
256 - afterwards. If the local changes do not overlap with the
257 - differences between branches, the switch proceeds without
258 - stashing. If reapplying the stash results in conflicts, the
259 - entry is saved to the stash list. Resolve the conflicts
260 - and run `git stash drop` when done, or clear the working
261 - tree (e.g. with `git reset --hard`) before running `git stash
262 - pop` later to re-apply your changes.
254 + However, with this option, a three-way merge between the current
255 + branch, your working tree contents, and the new branch
256 + is done, and you will be on the new branch.
257 + +
258 + When a merge conflict happens, the index entries for conflicting
259 + paths are left unmerged, and you need to resolve the conflicts
260 + and mark the resolved paths with `git add` (or `git rm` if the merge
261 + should result in deletion of the path).
263 262 +
264 263 When checking out paths from the index, this option lets you recreate
265 264 the conflicted merge in the specified paths. This option cannot be
266 265 used when checking out paths from a tree-ish.
266 + +
267 + When switching branches with `--merge`, staged changes may be lost.
267 268
268 269 `--conflict=<style>`::
269 270 The same as `--merge` option above, but changes the way the
@@ -577,36 +578,38 @@ $ git checkout mytopic
577 578 error: You have local changes to 'frotz'; not switching branches.
578 579 ------------
579 580
580 - You can give the `-m` flag to the command, which will carry your local
581 - changes to the new branch:
581 + You can give the `-m` flag to the command, which would try a
582 + three-way merge:
582 583
583 584 ------------
584 585 $ git checkout -m mytopic
585 - Applied autostash.
586 - Switched to branch 'mytopic'
587 - The following paths have local changes:
588 - M frotz
586 + Auto-merging frotz
589 587 ------------
590 588
591 - After the switch, the local modifications are reapplied and are _not_
589 + After this three-way merge, the local modifications are _not_
592 590 registered in your index file, so `git diff` would show you what
593 591 changes you made since the tip of the new branch.
594 592
595 593 === 3. Merge conflict
596 594
597 - When the `--merge` (`-m`) option is given and the local changes
598 - overlap with the changes in the branch we're switching to, the
599 - changes are stashed and reapplied after the switch. If this
600 - process results in conflicts, the stash entry is saved and a
601 - message is printed:
595 + When a merge conflict happens during switching branches with
596 + the `-m` option, you would see something like this:
602 597
603 598 ------------
604 599 $ git checkout -m mytopic
605 - Your local changes are stashed, however applying them
606 - resulted in conflicts. You can either resolve the conflicts
607 - and then discard the stash with "git stash drop", or, if you
608 - do not want to resolve them now, run "git reset --hard" and
609 - apply the local changes later by running "git stash pop".
600 + Auto-merging frotz
601 + ERROR: Merge conflict in frotz
602 + fatal: merge program failed
603 + ------------
604 +
605 + At this point, `git diff` shows the changes cleanly merged as in
606 + the previous example, as well as the changes in the conflicted
607 + files. Edit and resolve the conflict and mark it resolved with
608 + `git add` as usual:
609 +
610 + ------------
611 + $ edit frotz
612 + $ git add frotz
610 613 ------------
611 614
612 615 CONFIGURATION
modified Documentation/git-commit-graph.adoc
@@ -146,12 +146,6 @@ $ git show-ref -s | git commit-graph write --stdin-commits
146 146 $ git rev-parse HEAD | git commit-graph write --stdin-commits --append
147 147 ------------------------------------------------
148 148
149 - CAVEATS
150 - -------
151 -
152 - The existence of replace objects or commit grafts turns off reading or
153 - writing to the commit-graph. See linkgit:git-replace[1].
154 -
155 149 CONFIGURATION
156 150 -------------
157 151
modified Documentation/git-config.adoc
@@ -119,10 +119,10 @@ OPTIONS
119 119 Append a comment at the end of new or modified lines.
120 120 +
121 121 If _<message>_ begins with one or more whitespaces followed
122 - by `#`, it is used as-is. If it begins with `#`, a space is
123 - prepended before it is used. Otherwise, a string `" # "` (a
122 + by "#", it is used as-is. If it begins with "#", a space is
123 + prepended before it is used. Otherwise, a string " # " (a
124 124 space followed by a hash followed by a space) is prepended
125 - to it. The resulting string is placed immediately after
125 + to it. And the resulting string is placed immediately after
126 126 the value defined for the variable. The _<message>_ must
127 127 not contain linefeed characters (no multi-line comments are
128 128 permitted).
@@ -221,7 +221,6 @@ Use `--no-value` to unset _<pattern>_.
221 221 +
222 222 Valid `<type>`'s include:
223 223 +
224 - --
225 224 - 'bool': canonicalize values `true`, `yes`, `on`, and positive
226 225 numbers as "true", and values `false`, `no`, `off` and `0` as
227 226 "false".
@@ -240,7 +239,6 @@ Valid `<type>`'s include:
240 239 escape sequence. When setting a value, a sanity-check is performed to ensure
241 240 that the given value is canonicalize-able as an ANSI color, but it is written
242 241 as-is.
243 - --
244 242 +
245 243 If the command is in `list` mode, then the `--type <type>` argument will apply
246 244 to each listed config value. If the value does not successfully parse in that
modified Documentation/git-describe.adoc
@@ -7,10 +7,10 @@ git-describe - Give an object a human readable name based on an available ref
7 7
8 8 SYNOPSIS
9 9 --------
10 - [synopsis]
11 - git describe [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
12 - git describe [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
13 - git describe <blob>
10 + [verse]
11 + 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] [<commit-ish>...]
12 + 'git describe' [--all] [--tags] [--contains] [--abbrev=<n>] --dirty[=<mark>]
13 + 'git describe' <blob>
14 14
15 15 DESCRIPTION
16 16 -----------
@@ -22,70 +22,70 @@ abbreviated object name of the most recent commit. The result
22 22 is a "human-readable" object name which can also be used to
23 23 identify the commit to other git commands.
24 24
25 - By default (without `--all` or `--tags`) `git describe` only shows
25 + By default (without --all or --tags) `git describe` only shows
26 26 annotated tags. For more information about creating annotated tags
27 - see the `-a` and `-s` options to linkgit:git-tag[1].
27 + see the -a and -s options to linkgit:git-tag[1].
28 28
29 29 If the given object refers to a blob, it will be described
30 30 as `<commit-ish>:<path>`, such that the blob can be found
31 - at _<path>_ in the _<commit-ish>_, which itself describes the
31 + at `<path>` in the `<commit-ish>`, which itself describes the
32 32 first commit in which this blob occurs in a reverse revision walk
33 - from `HEAD`.
33 + from HEAD.
34 34
35 35 OPTIONS
36 36 -------
37 - `<commit-ish>...`::
38 - Commit-ish object names to describe. Defaults to `HEAD` if omitted.
37 + <commit-ish>...::
38 + Commit-ish object names to describe. Defaults to HEAD if omitted.
39 39
40 - `--dirty[=<mark>]`::
41 - `--broken[=<mark>]`::
40 + --dirty[=<mark>]::
41 + --broken[=<mark>]::
42 42 Describe the state of the working tree. When the working
43 - tree matches `HEAD`, the output is the same as `git describe HEAD`.
44 - If the working tree has local modification, `-dirty`
43 + tree matches HEAD, the output is the same as "git describe
44 + HEAD". If the working tree has local modification "-dirty"
45 45 is appended to it. If a repository is corrupt and Git
46 46 cannot determine if there is local modification, Git will
47 - error out, unless `--broken` is given, which appends
48 - the suffix `-broken` instead.
47 + error out, unless `--broken' is given, which appends
48 + the suffix "-broken" instead.
49 49
50 - `--all`::
50 + --all::
51 51 Instead of using only the annotated tags, use any ref
52 52 found in `refs/` namespace. This option enables matching
53 53 any known branch, remote-tracking branch, or lightweight tag.
54 54
55 - `--tags`::
55 + --tags::
56 56 Instead of using only the annotated tags, use any tag
57 57 found in `refs/tags` namespace. This option enables matching
58 58 a lightweight (non-annotated) tag.
59 59
60 - `--contains`::
60 + --contains::
61 61 Instead of finding the tag that predates the commit, find
62 62 the tag that comes after the commit, and thus contains it.
63 - Automatically implies `--tags`.
63 + Automatically implies --tags.
64 64
65 - `--abbrev=<n>`::
65 + --abbrev=<n>::
66 66 Instead of using the default number of hexadecimal digits (which
67 67 will vary according to the number of objects in the repository with
68 - a default of 7) of the abbreviated object name, use _<n>_ digits, or
69 - as many digits as needed to form a unique object name. An _<n>_ of 0
68 + a default of 7) of the abbreviated object name, use <n> digits, or
69 + as many digits as needed to form a unique object name. An <n> of 0
70 70 will suppress long format, only showing the closest tag.
71 71
72 - `--candidates=<n>`::
72 + --candidates=<n>::
73 73 Instead of considering only the 10 most recent tags as
74 74 candidates to describe the input commit-ish consider
75 - up to _<n>_ candidates. Increasing _<n>_ above 10 will take
75 + up to <n> candidates. Increasing <n> above 10 will take
76 76 slightly longer but may produce a more accurate result.
77 - An _<n>_ of 0 will cause only exact matches to be output.
77 + An <n> of 0 will cause only exact matches to be output.
78 78
79 - `--exact-match`::
79 + --exact-match::
80 80 Only output exact matches (a tag directly references the
81 - supplied commit). This is a synonym for `--candidates=0`.
81 + supplied commit). This is a synonym for --candidates=0.
82 82
83 - `--debug`::
83 + --debug::
84 84 Verbosely display information about the searching strategy
85 85 being employed to standard error. The tag name will still
86 86 be printed to standard out.
87 87
88 - `--long`::
88 + --long::
89 89 Always output the long format (the tag, the number of commits
90 90 and the abbreviated commit name) even when it matches a tag.
91 91 This is useful when you want to see parts of the commit object name
@@ -94,8 +94,8 @@ OPTIONS
94 94 describe such a commit as v1.2-0-gdeadbee (0th commit since tag v1.2
95 95 that points at object deadbee....).
96 96
97 - `--match <pattern>`::
98 - Only consider tags matching the given `glob`(7) pattern,
97 + --match <pattern>::
98 + Only consider tags matching the given `glob(7)` pattern,
99 99 excluding the "refs/tags/" prefix. If used with `--all`, it also
100 100 considers local branches and remote-tracking references matching the
101 101 pattern, excluding respectively "refs/heads/" and "refs/remotes/"
@@ -104,22 +104,22 @@ OPTIONS
104 104 matching any of the patterns will be considered. Use `--no-match` to
105 105 clear and reset the list of patterns.
106 106
107 - `--exclude <pattern>`::
108 - Do not consider tags matching the given `glob`(7) pattern, excluding
107 + --exclude <pattern>::
108 + Do not consider tags matching the given `glob(7)` pattern, excluding
109 109 the "refs/tags/" prefix. If used with `--all`, it also does not consider
110 110 local branches and remote-tracking references matching the pattern,
111 - excluding respectively "`refs/heads/`" and "`refs/remotes/`" prefix;
111 + excluding respectively "refs/heads/" and "refs/remotes/" prefix;
112 112 references of other types are never considered. If given multiple times,
113 113 a list of patterns will be accumulated and tags matching any of the
114 - patterns will be excluded. When combined with `--match` a tag will be
115 - considered when it matches at least one `--match` pattern and does not
116 - match any of the `--exclude` patterns. Use `--no-exclude` to clear and
114 + patterns will be excluded. When combined with --match a tag will be
115 + considered when it matches at least one --match pattern and does not
116 + match any of the --exclude patterns. Use `--no-exclude` to clear and
117 117 reset the list of patterns.
118 118
119 - `--always`::
119 + --always::
120 120 Show uniquely abbreviated commit object as fallback.
121 121
122 - `--first-parent`::
122 + --first-parent::
123 123 Follow only the first parent commit upon seeing a merge commit.
124 124 This is useful when you wish to not match tags on branches merged
125 125 in the history of the target commit.
@@ -139,8 +139,8 @@ an abbreviated object name for the commit itself ("2414721")
139 139 at the end.
140 140
141 141 The number of additional commits is the number
142 - of commits which would be displayed by `git log v1.0.4..parent`.
143 - The hash suffix is "`-g`" + an unambiguous abbreviation for the tip commit
142 + of commits which would be displayed by "git log v1.0.4..parent".
143 + The hash suffix is "-g" + an unambiguous abbreviation for the tip commit
144 144 of parent (which was `2414721b194453f058079d897d13c4e377f92dc6`). The
145 145 length of the abbreviation scales as the repository grows, using the
146 146 approximate number of objects in the repository and a bit of math
@@ -149,12 +149,12 @@ The "g" prefix stands for "git" and is used to allow describing the version of
149 149 a software depending on the SCM the software is managed with. This is useful
150 150 in an environment where people may use different SCMs.
151 151
152 - Doing a `git describe` on a tag-name will just show the tag name:
152 + Doing a 'git describe' on a tag-name will just show the tag name:
153 153
154 154 [torvalds@g5 git]$ git describe v1.0.4
155 155 v1.0.4
156 156
157 - With `--all`, the command can use branch heads as references, so
157 + With --all, the command can use branch heads as references, so
158 158 the output shows the reference path as well:
159 159
160 160 [torvalds@g5 git]$ git describe --all --abbrev=4 v1.0.5^2
@@ -163,7 +163,7 @@ the output shows the reference path as well:
163 163 [torvalds@g5 git]$ git describe --all --abbrev=4 HEAD^
164 164 heads/lt/describe-7-g975b
165 165
166 - With `--abbrev` set to 0, the command can be used to find the
166 + With --abbrev set to 0, the command can be used to find the
167 167 closest tagname without any suffix:
168 168
169 169 [torvalds@g5 git]$ git describe --abbrev=0 v1.0.5^2
@@ -179,13 +179,13 @@ be sufficient to disambiguate these commits.
179 179 SEARCH STRATEGY
180 180 ---------------
181 181
182 - For each commit-ish supplied, `git describe` will first look for
182 + For each commit-ish supplied, 'git describe' will first look for
183 183 a tag which tags exactly that commit. Annotated tags will always
184 184 be preferred over lightweight tags, and tags with newer dates will
185 185 always be preferred over tags with older dates. If an exact match
186 186 is found, its name will be output and searching will stop.
187 187
188 - If an exact match was not found, `git describe` will walk back
188 + If an exact match was not found, 'git describe' will walk back
189 189 through the commit history to locate an ancestor commit which
190 190 has been tagged. The ancestor's tag will be output along with an
191 191 abbreviation of the input commit-ish's SHA-1. If `--first-parent` was
@@ -203,7 +203,7 @@ BUGS
203 203
204 204 Tree objects as well as tag objects not pointing at commits, cannot be described.
205 205 When describing blobs, the lightweight tags pointing at blobs are ignored,
206 - but the blob is still described as `<commit-ish>:<path>` despite the lightweight
206 + but the blob is still described as <commit-ish>:<path> despite the lightweight
207 207 tag being favorable.
208 208
209 209 GIT
modified Documentation/git-difftool.adoc
@@ -7,64 +7,64 @@ git-difftool - Show changes using common diff tools
7 7
8 8 SYNOPSIS
9 9 --------
10 - [synopsis]
11 - git difftool [<options>] [<commit> [<commit>]] [--] [<path>...]
10 + [verse]
11 + 'git difftool' [<options>] [<commit> [<commit>]] [--] [<path>...]
12 12
13 13 DESCRIPTION
14 14 -----------
15 - `git difftool` is a Git command that allows you to compare and edit files
16 - between revisions using common diff tools. `git difftool` is a frontend
17 - to `git diff` and accepts the same options and arguments. See
15 + 'git difftool' is a Git command that allows you to compare and edit files
16 + between revisions using common diff tools. 'git difftool' is a frontend
17 + to 'git diff' and accepts the same options and arguments. See
18 18 linkgit:git-diff[1].
19 19
20 20 OPTIONS
21 21 -------
22 - `-d`::
23 - `--dir-diff`::
22 + -d::
23 + --dir-diff::
24 24 Copy the modified files to a temporary location and perform
25 25 a directory diff on them. This mode never prompts before
26 26 launching the diff tool.
27 27
28 - `-y`::
29 - `--no-prompt`::
28 + -y::
29 + --no-prompt::
30 30 Do not prompt before launching a diff tool.
31 31
32 - `--prompt`::
32 + --prompt::
33 33 Prompt before each invocation of the diff tool.
34 34 This is the default behaviour; the option is provided to
35 35 override any configuration settings.
36 36
37 - `--rotate-to=<file>`::
38 - Start showing the diff for _<file>_,
37 + --rotate-to=<file>::
38 + Start showing the diff for the given path,
39 39 the paths before it will move to the end and output.
40 40
41 - `--skip-to=<file>`::
42 - Start showing the diff for _<file>_, skipping all
41 + --skip-to=<file>::
42 + Start showing the diff for the given path, skipping all
43 43 the paths before it.
44 44
45 - `-t <tool>`::
46 - `--tool=<tool>`::
47 - Use the diff tool specified by _<tool>_. Valid values include
45 + -t <tool>::
46 + --tool=<tool>::
47 + Use the diff tool specified by <tool>. Valid values include
48 48 emerge, kompare, meld, and vimdiff. Run `git difftool --tool-help`
49 - for the list of valid _<tool>_ settings.
49 + for the list of valid <tool> settings.
50 50 +
51 - If a diff tool is not specified, `git difftool`
51 + If a diff tool is not specified, 'git difftool'
52 52 will use the configuration variable `diff.tool`. If the
53 - configuration variable `diff.tool` is not set, `git difftool`
53 + configuration variable `diff.tool` is not set, 'git difftool'
54 54 will pick a suitable default.
55 55 +
56 56 You can explicitly provide a full path to the tool by setting the
57 57 configuration variable `difftool.<tool>.path`. For example, you
58 58 can configure the absolute path to kdiff3 by setting
59 - `difftool.kdiff3.path`. Otherwise, `git difftool` assumes the
59 + `difftool.kdiff3.path`. Otherwise, 'git difftool' assumes the
60 60 tool is available in PATH.
61 61 +
62 62 Instead of running one of the known diff tools,
63 - `git difftool` can be customized to run an alternative program
63 + 'git difftool' can be customized to run an alternative program
64 64 by specifying the command line to invoke in a configuration
65 65 variable `difftool.<tool>.cmd`.
66 66 +
67 - When `git difftool` is invoked with this tool (either through the
67 + When 'git difftool' is invoked with this tool (either through the
68 68 `-t` or `--tool` option or the `diff.tool` configuration variable)
69 69 the configured command line will be invoked with the following
70 70 variables available: `$LOCAL` is set to the name of the temporary
@@ -74,30 +74,30 @@ of the diff post-image. `$MERGED` is the name of the file which is
74 74 being compared. `$BASE` is provided for compatibility
75 75 with custom merge tool commands and has the same value as `$MERGED`.
76 76
77 - `--tool-help`::
77 + --tool-help::
78 78 Print a list of diff tools that may be used with `--tool`.
79 79
80 - `--symlinks`::
81 - `--no-symlinks`::
82 - `git difftool`'s default behavior is to create symlinks to the
80 + --symlinks::
81 + --no-symlinks::
82 + 'git difftool''s default behavior is to create symlinks to the
83 83 working tree when run in `--dir-diff` mode and the right-hand
84 84 side of the comparison yields the same content as the file in
85 85 the working tree.
86 86 +
87 - Specifying `--no-symlinks` instructs `git difftool` to create copies
87 + Specifying `--no-symlinks` instructs 'git difftool' to create copies
88 88 instead. `--no-symlinks` is the default on Windows.
89 89
90 - `-x <command>`::
91 - `--extcmd=<command>`::
90 + -x <command>::
91 + --extcmd=<command>::
92 92 Specify a custom command for viewing diffs.
93 - `git-difftool` ignores the configured defaults and runs
93 + 'git-difftool' ignores the configured defaults and runs
94 94 `<command> $LOCAL $REMOTE` when this option is specified.
95 95 Additionally, `$BASE` is set in the environment.
96 96
97 - `-g`::
98 - `--gui`::
99 - `--no-gui`::
100 - When `git-difftool` is invoked with the `-g` or `--gui` option
97 + -g::
98 + --gui::
99 + --no-gui::
100 + When 'git-difftool' is invoked with the `-g` or `--gui` option
101 101 the default diff tool will be read from the configured
102 102 `diff.guitool` variable instead of `diff.tool`. This may be
103 103 selected automatically using the configuration variable
@@ -106,20 +106,20 @@ instead. `--no-symlinks` is the default on Windows.
106 106 fallback in the order of `merge.guitool`, `diff.tool`,
107 107 `merge.tool` until a tool is found.
108 108
109 - `--trust-exit-code`::
110 - `--no-trust-exit-code`::
109 + --trust-exit-code::
110 + --no-trust-exit-code::
111 111 Errors reported by the diff tool are ignored by default.
112 - Use `--trust-exit-code` to make `git-difftool` exit when an
112 + Use `--trust-exit-code` to make 'git-difftool' exit when an
113 113 invoked diff tool returns a non-zero exit code.
114 114 +
115 - `git-difftool` will forward the exit code of the invoked tool when
115 + 'git-difftool' will forward the exit code of the invoked tool when
116 116 `--trust-exit-code` is used.
117 117
118 118 See linkgit:git-diff[1] for the full list of supported options.
119 119
120 120 CONFIGURATION
121 121 -------------
122 - `git difftool` falls back to `git mergetool` config variables when the
122 + 'git difftool' falls back to 'git mergetool' config variables when the
123 123 difftool equivalents have not been defined.
124 124
125 125 include::includes/cmd-config-section-rest.adoc[]
modified Documentation/git-fast-export.adoc
@@ -9,7 +9,7 @@ git-fast-export - Git data exporter
9 9 SYNOPSIS
10 10 --------
11 11 [verse]
12 - 'git fast-export' [<options>] [<revision-range>] [[--] <path>...]
12 + 'git fast-export' [<options>] | 'git fast-import'
13 13
14 14 DESCRIPTION
15 15 -----------
modified Documentation/git-fast-import.adoc
@@ -9,7 +9,7 @@ git-fast-import - Backend for fast Git data importers
9 9 SYNOPSIS
10 10 --------
11 11 [verse]
12 - 'git fast-import' [<options>]
12 + frontend | 'git fast-import' [<options>]
13 13
14 14 DESCRIPTION
15 15 -----------
@@ -65,13 +65,6 @@ Only enable this option if you trust the program generating the
65 65 fast-import stream! This option is enabled automatically for
66 66 remote-helpers that use the `import` capability, as they are
67 67 already trusted to run their own code.
68 - +
69 - Note that this option has to be spelled in full, and has to appear
70 - before any option whose value is separated from it by a space, for
71 - the unsafe `feature` commands in the stream to be allowed. So
72 - `--allow-unsafe` or `--depth 5 --allow-unsafe-features` still refuse
73 - them, while `--allow-unsafe-features --depth 5` and
74 - `--depth=5 --allow-unsafe-features` allow them.
75 68
76 69 `--signed-tags=<mode>`::
77 70 Specify how to handle signed tags. Behaves in the same way as
modified Documentation/git-format-patch.adoc
@@ -8,8 +8,8 @@ git-format-patch - Prepare patches for e-mail submission
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git format-patch [-k] [(-o|--output-directory) <dir> | --stdout]
11 + [verse]
12 + 'git format-patch' [-k] [(-o|--output-directory) <dir> | --stdout]
13 13 [--no-thread | --thread[=<style>]]
14 14 [(--attach|--inline)[=<boundary>] | --no-attach]
15 15 [-s | --signoff]
@@ -40,20 +40,20 @@ DESCRIPTION
40 40 Prepare each non-merge commit with its "patch" in
41 41 one "message" per commit, formatted to resemble a UNIX mailbox.
42 42 The output of this command is convenient for e-mail submission or
43 - for use with `git am`.
43 + for use with 'git am'.
44 44
45 45 A "message" generated by the command consists of three parts:
46 46
47 47 * A brief metadata header that begins with `From <commit>`
48 48 with a fixed `Mon Sep 17 00:00:00 2001` datestamp to help programs
49 - like `file`(1) to recognize that the file is an output from this
49 + like "file(1)" to recognize that the file is an output from this
50 50 command, fields that record the author identity, the author date,
51 51 and the title of the change (taken from the first paragraph of the
52 52 commit log message).
53 53
54 54 * The second and subsequent paragraphs of the commit log message.
55 55
56 - * The "patch", which is the `diff -p --stat` output (see
56 + * The "patch", which is the "diff -p --stat" output (see
57 57 linkgit:git-diff[1]) between the commit and its parent.
58 58
59 59 The log message and the patch are separated by a line with a
@@ -61,18 +61,18 @@ three-dash line.
61 61
62 62 There are two ways to specify which commits to operate on.
63 63
64 - 1. A single commit, _<since>_, specifies that the commits leading
64 + 1. A single commit, <since>, specifies that the commits leading
65 65 to the tip of the current branch that are not in the history
66 - that leads to the _<since>_ to be output.
66 + that leads to the <since> to be output.
67 67
68 - 2. Generic _<revision-range>_ expression (see 'SPECIFYING
69 - REVISIONS' section in linkgit:gitrevisions[7]) means the
68 + 2. Generic <revision-range> expression (see "SPECIFYING
69 + REVISIONS" section in linkgit:gitrevisions[7]) means the
70 70 commits in the specified range.
71 71
72 - The first rule takes precedence in the case of a single _<commit>_. To
72 + The first rule takes precedence in the case of a single <commit>. To
73 73 apply the second rule, i.e., format everything since the beginning of
74 - history up until _<commit>_, use the `--root` option: `git format-patch
75 - --root <commit>`. If you want to format only _<commit>_ itself, you
74 + history up until <commit>, use the `--root` option: `git format-patch
75 + --root <commit>`. If you want to format only <commit> itself, you
76 76 can do this with `git format-patch -1 <commit>`.
77 77
78 78 By default, each output file is numbered sequentially from 1, and uses the
@@ -82,7 +82,7 @@ will only be numbers, without the first line of the commit appended.
82 82 The names of the output files are printed to standard
83 83 output, unless the `--stdout` option is specified.
84 84
85 - If `-o` is specified, output files are created in _<dir>_. Otherwise
85 + If `-o` is specified, output files are created in <dir>. Otherwise
86 86 they are created in the current working directory. The default path
87 87 can be set with the `format.outputDirectory` configuration option.
88 88 The `-o` option takes precedence over `format.outputDirectory`.
@@ -108,122 +108,123 @@ OPTIONS
108 108 :git-format-patch: 1
109 109 include::diff-options.adoc[]
110 110
111 - `-<n>`::
112 - Prepare patches from the topmost _<n>_ commits.
111 + -<n>::
112 + Prepare patches from the topmost <n> commits.
113 113
114 - `-o <dir>`::
115 - `--output-directory=<dir>`::
116 - Use _<dir>_ to store the resulting files, instead of the
114 + -o <dir>::
115 + --output-directory <dir>::
116 + Use <dir> to store the resulting files, instead of the
117 117 current working directory.
118 118
119 - `-n`::
120 - `--numbered`::
119 + -n::
120 + --numbered::
121 121 Name output in '[PATCH n/m]' format, even with a single patch.
122 122
123 - `-N`::
124 - `--no-numbered`::
123 + -N::
124 + --no-numbered::
125 125 Name output in '[PATCH]' format.
126 126
127 - `--start-number <n>`::
128 - Start numbering the patches at _<n>_ instead of 1.
127 + --start-number <n>::
128 + Start numbering the patches at <n> instead of 1.
129 129
130 - `--numbered-files`::
130 + --numbered-files::
131 131 Output file names will be a simple number sequence
132 132 without the default first line of the commit appended.
133 133
134 - `-k`::
135 - `--keep-subject`::
134 + -k::
135 + --keep-subject::
136 136 Do not strip/add '[PATCH]' from the first line of the
137 137 commit log message.
138 138
139 - `-s`::
140 - `--signoff`::
139 + -s::
140 + --signoff::
141 141 Add a `Signed-off-by` trailer to the commit message, using
142 142 the committer identity of yourself.
143 143 See the signoff option in linkgit:git-commit[1] for more information.
144 144
145 - `--stdout`::
145 + --stdout::
146 146 Print all commits to the standard output in mbox format,
147 147 instead of creating a file for each one.
148 148
149 - `--attach[=<boundary>]`::
149 + --attach[=<boundary>]::
150 150 Create multipart/mixed attachment, the first part of
151 151 which is the commit message and the patch itself in the
152 152 second part, with `Content-Disposition: attachment`.
153 153
154 - `--no-attach`::
154 + --no-attach::
155 155 Disable the creation of an attachment, overriding the
156 156 configuration setting.
157 157
158 - `--inline[=<boundary>]`::
158 + --inline[=<boundary>]::
159 159 Create multipart/mixed attachment, the first part of
160 160 which is the commit message and the patch itself in the
161 161 second part, with `Content-Disposition: inline`.
162 162
163 - `--thread[=<style>]`::
164 - `--no-thread`::
165 - Control addition of `In-Reply-To` and `References` headers to
163 + --thread[=<style>]::
164 + --no-thread::
165 + Controls addition of `In-Reply-To` and `References` headers to
166 166 make the second and subsequent mails appear as replies to the
167 167 first. Also controls generation of the `Message-ID` header to
168 168 reference.
169 169 +
170 - The optional _<style>_ argument can be either `shallow` or `deep`.
171 - `shallow` threading makes every mail a reply to the head of the
170 + The optional <style> argument can be either `shallow` or `deep`.
171 + 'shallow' threading makes every mail a reply to the head of the
172 172 series, where the head is chosen from the cover letter, the
173 - `--in-reply-to`, and the first patch mail, in this order. `deep`
173 + `--in-reply-to`, and the first patch mail, in this order. 'deep'
174 174 threading makes every mail a reply to the previous one.
175 175 +
176 176 The default is `--no-thread`, unless the `format.thread` configuration
177 177 is set. `--thread` without an argument is equivalent to `--thread=shallow`.
178 178 +
179 - Beware that the default for `git send-email` is to thread emails
179 + Beware that the default for 'git send-email' is to thread emails
180 180 itself. If you want `git format-patch` to take care of threading, you
181 181 will want to ensure that threading is disabled for `git send-email`.
182 182
183 - `--in-reply-to=<message-id>`::
183 + --in-reply-to=<message-id>::
184 184 Make the first mail (or all the mails with `--no-thread`) appear as a
185 - reply to the given _<message-id>_, which avoids breaking threads to
185 + reply to the given <message-id>, which avoids breaking threads to
186 186 provide a new patch series.
187 187
188 - `--ignore-if-in-upstream`::
188 + --ignore-if-in-upstream::
189 189 Do not include a patch that matches a commit in
190 - _<until>_.._<since>_. This will examine all patches reachable
191 - from _<since>_ but not from _<until>_ and compare them with the
190 + <until>..<since>. This will examine all patches reachable
191 + from <since> but not from <until> and compare them with the
192 192 patches being generated, and any patch that matches is
193 193 ignored.
194 194
195 - `--always`::
195 + --always::
196 196 Include patches for commits that do not introduce any change,
197 197 which are omitted by default.
198 198
199 - `--cover-from-description=<mode>`::
200 - Control which parts of the cover letter will be automatically
199 + --cover-from-description=<mode>::
200 + Controls which parts of the cover letter will be automatically
201 201 populated using the branch's description.
202 202 +
203 - _<mode>_ can have the following values:
204 -
205 - `message`;;
206 - `default`;; the cover letter subject will be
203 + If `<mode>` is `message` or `default`, the cover letter subject will be
207 204 populated with placeholder text. The body of the cover letter will be
208 205 populated with the branch's description. This is the default mode when
209 206 no configuration nor command line option is specified.
210 - `subject`;; the first paragraph of the branch description will
207 + +
208 + If `<mode>` is `subject`, the first paragraph of the branch description will
211 209 populate the cover letter subject. The remainder of the description will
212 210 populate the body of the cover letter.
213 - `auto`;; if the first paragraph of the branch description
211 + +
212 + If `<mode>` is `auto`, if the first paragraph of the branch description
214 213 is greater than 100 bytes, then the mode will be `message`, otherwise
215 214 `subject` will be used.
216 - `none`;; both the cover letter subject and body will be
215 + +
216 + If `<mode>` is `none`, both the cover letter subject and body will be
217 217 populated with placeholder text.
218 218
219 - `--description-file=<file>`::
220 - Use the contents of _<file>_ instead of the branch's description
219 + --description-file=<file>::
220 + Use the contents of <file> instead of the branch's description
221 221 for generating the cover letter.
222 222
223 - `--subject-prefix=<subject-prefix>`::
224 - Use '[<subject-prefix>]' instead of the standard '[PATCH]'
225 - prefix in the subject line. This can be used to name a patch
226 - series, and can be combined with the `--numbered` option.
223 + --subject-prefix=<subject-prefix>::
224 + Instead of the standard '[PATCH]' prefix in the subject
225 + line, instead use '[<subject-prefix>]'. This can be used
226 + to name a patch series, and can be combined with the
227 + `--numbered` option.
227 228 +
228 229 The configuration variable `format.subjectPrefix` may also be used
229 230 to configure a subject prefix to apply to a given repository for
@@ -231,14 +232,14 @@ all patches. This is often useful on mailing lists which receive
231 232 patches for several repositories and can be used to disambiguate
232 233 the patches (with a value of e.g. "PATCH my-project").
233 234
234 - `--filename-max-length=<n>`::
235 + --filename-max-length=<n>::
235 236 Instead of the standard 64 bytes, chomp the generated output
236 - filenames at around _<n>_ bytes (too short a value will be
237 + filenames at around '<n>' bytes (too short a value will be
237 238 silently raised to a reasonable length). Defaults to the
238 239 value of the `format.filenameMaxLength` configuration
239 240 variable, or 64 if unconfigured.
240 241
241 - `--rfc[=<rfc>]`::
242 + --rfc[=<rfc>]::
242 243 Prepends the string _<rfc>_ (defaults to "RFC") to
243 244 the subject prefix. As the subject prefix defaults to
244 245 "PATCH", you'll get "RFC PATCH" by default.
@@ -254,38 +255,38 @@ can be prefixed with a dash ("`-`") to signal that the rest of
254 255 the _<rfc>_ string should be appended to the subject prefix instead,
255 256 e.g., `--rfc='-(WIP)'` results in "PATCH (WIP)".
256 257
257 - `-v <n>`::
258 - `--reroll-count=<n>`::
259 - Mark the series as the _<n>_-th iteration of the topic. The
258 + -v <n>::
259 + --reroll-count=<n>::
260 + Mark the series as the <n>-th iteration of the topic. The
260 261 output filenames have `v<n>` prepended to them, and the
261 262 subject prefix ("PATCH" by default, but configurable via the
262 - `--subject-prefix` option) has `v<n>` appended to it. E.g.
263 + `--subject-prefix` option) has ` v<n>` appended to it. E.g.
263 264 `--reroll-count=4` may produce `v4-0001-add-makefile.patch`
264 265 file that has "Subject: [PATCH v4 1/20] Add makefile" in it.
265 - _<n>_ does not have to be an integer (e.g. `--reroll-count=4.4`,
266 - or `--reroll-count=4rev2` are allowed), but the downside of
266 + `<n>` does not have to be an integer (e.g. "--reroll-count=4.4",
267 + or "--reroll-count=4rev2" are allowed), but the downside of
267 268 using such a reroll-count is that the range-diff/interdiff
268 269 with the previous version does not state exactly which
269 270 version the new iteration is compared against.
270 271
271 - `--to=<email>`::
272 + --to=<email>::
272 273 Add a `To:` header to the email headers. This is in addition
273 274 to any configured headers, and may be used multiple times.
274 275 The negated form `--no-to` discards all `To:` headers added so
275 276 far (from config or command line).
276 277
277 - `--cc=<email>`::
278 + --cc=<email>::
278 279 Add a `Cc:` header to the email headers. This is in addition
279 280 to any configured headers, and may be used multiple times.
280 281 The negated form `--no-cc` discards all `Cc:` headers added so
281 282 far (from config or command line).
282 283
283 - `--from`::
284 - `--from=<ident>`::
285 - Use _<ident>_ in the `From:` header of each email. In case of a
284 + --from::
285 + --from=<ident>::
286 + Use `ident` in the `From:` header of each email. In case of a
286 287 commit email, if the author ident of the commit is not textually
287 - identical to the provided _<ident>_, place a `From:` header in the
288 - body of the message with the original author. If no _<ident>_ is
288 + identical to the provided `ident`, place a `From:` header in the
289 + body of the message with the original author. If no `ident` is
289 290 given, or if the option is not passed at all, use the ident of
290 291 the current committer.
291 292 +
@@ -296,8 +297,8 @@ header). Note also that `git send-email` already handles this
296 297 transformation for you, and this option should not be used if you are
297 298 feeding the result to `git send-email`.
298 299
299 - `--force-in-body-from`::
300 - `--no-force-in-body-from`::
300 + --force-in-body-from::
301 + --no-force-in-body-from::
301 302 With the e-mail sender specified via the `--from` option, by
302 303 default, an in-body "From:" to identify the real author of
303 304 the commit is added at the top of the commit log message if
@@ -308,7 +309,7 @@ feeding the result to `git send-email`.
308 309 Defaults to the value of the `format.forceInBodyFrom`
309 310 configuration variable.
310 311
311 - `--add-header=<header>`::
312 + --add-header=<header>::
312 313 Add an arbitrary header to the email headers. This is in addition
313 314 to any configured headers, and may be used multiple times.
314 315 For example, `--add-header="Organization: git-foo"`.
@@ -316,13 +317,13 @@ feeding the result to `git send-email`.
316 317 `Cc:`, and custom) headers added so far from config or command
317 318 line.
318 319
319 - `--cover-letter`::
320 - `--no-cover-letter`::
320 + --cover-letter::
321 + --no-cover-letter::
321 322 In addition to the patches, generate a cover letter file containing the
322 323 branch description, commit list and the overall diffstat. You can fill
323 324 in a description in the file before sending it out.
324 325
325 - `--commit-list-format=<format-spec>`::
326 + --commit-list-format=<format-spec>::
326 327 Specify the format in which to generate the commit list of the patch
327 328 series. The accepted values for format-spec are `shortlog`, `modern` or
328 329 a format-string prefixed with `log:`. E.g. `log: %s (%an)`.
@@ -334,28 +335,28 @@ feeding the result to `git send-email`.
334 335 This option given from the command-line implies the use of
335 336 `--cover-letter` unless `--no-cover-letter` is given.
336 337
337 - `--encode-email-headers`::
338 - `--no-encode-email-headers`::
338 + --encode-email-headers::
339 + --no-encode-email-headers::
339 340 Encode email headers that have non-ASCII characters with
340 341 "Q-encoding" (described in RFC 2047), instead of outputting the
341 342 headers verbatim. Defaults to the value of the
342 343 `format.encodeEmailHeaders` configuration variable.
343 344
344 - `--interdiff=<previous>`::
345 + --interdiff=<previous>::
345 346 As a reviewer aid, insert an interdiff into the cover letter,
346 347 or as commentary of the lone patch of a 1-patch series, showing
347 348 the differences between the previous version of the patch series and
348 - the series currently being formatted. _<previous>_ is a single revision
349 + the series currently being formatted. `previous` is a single revision
349 350 naming the tip of the previous series which shares a common base with
350 351 the series being formatted (for example `git format-patch
351 352 --cover-letter --interdiff=feature/v1 -3 feature/v2`).
352 353
353 - `--range-diff=<previous>`::
354 + --range-diff=<previous>::
354 355 As a reviewer aid, insert a range-diff (see linkgit:git-range-diff[1])
355 356 into the cover letter, or as commentary of the lone patch of a
356 357 1-patch series, showing the differences between the previous
357 358 version of the patch series and the series currently being formatted.
358 - _<previous>_ can be a single revision naming the tip of the previous
359 + `previous` can be a single revision naming the tip of the previous
359 360 series if it shares a common base with the series being formatted (for
360 361 example `git format-patch --cover-letter --range-diff=feature/v1 -3
361 362 feature/v2`), or a revision range if the two versions of the series are
@@ -367,7 +368,7 @@ product of `format-patch` is generated, and they are not passed to
367 368 the underlying `range-diff` machinery used to generate the cover-letter
368 369 material (this may change in the future).
369 370
370 - `--creation-factor=<percent>`::
371 + --creation-factor=<percent>::
371 372 Used with `--range-diff`, tweak the heuristic which matches up commits
372 373 between the previous and current series of patches by adjusting the
373 374 creation/deletion cost fudge factor. See linkgit:git-range-diff[1])
@@ -378,8 +379,8 @@ case is to show comparison with an older iteration of the same
378 379 topic and the tool should find more correspondence between the two
379 380 sets of patches.
380 381
381 - `--notes[=<ref>]`::
382 - `--no-notes`::
382 + --notes[=<ref>]::
383 + --no-notes::
383 384 Append the notes (see linkgit:git-notes[1]) for the commit
384 385 after the three-dash line.
385 386 +
@@ -394,17 +395,17 @@ configuration options in linkgit:git-notes[1] to use this workflow).
394 395 The default is `--no-notes`, unless the `format.notes` configuration is
395 396 set.
396 397
397 - `--signature=<signature>`::
398 - `--no-signature`::
398 + --signature=<signature>::
399 + --no-signature::
399 400 Add a signature to each message produced. Per RFC 3676 the signature
400 - is separated from the body by a line with "-- " on it. If the
401 + is separated from the body by a line with '-- ' on it. If the
401 402 signature option is omitted the signature defaults to the Git version
402 403 number.
403 404
404 - `--signature-file=<file>`::
405 - Works just like `--signature` except the signature is read from a file.
405 + --signature-file=<file>::
406 + Works just like --signature except the signature is read from a file.
406 407
407 - `--suffix=.<sfx>`::
408 + --suffix=.<sfx>::
408 409 Instead of using `.patch` as the suffix for generated
409 410 filenames, use specified suffix. A common alternative is
410 411 `--suffix=.txt`. Leaving this empty will remove the `.patch`
@@ -413,36 +414,36 @@ set.
413 414 Note that the leading character does not have to be a dot; for example,
414 415 you can use `--suffix=-patch` to get `0001-description-of-my-change-patch`.
415 416
416 - `-q`::
417 - `--quiet`::
417 + -q::
418 + --quiet::
418 419 Do not print the names of the generated files to standard output.
419 420
420 - `--no-binary`::
421 + --no-binary::
421 422 Do not output contents of changes in binary files, instead
422 423 display a notice that those files changed. Patches generated
423 424 using this option cannot be applied properly, but they are
424 425 still useful for code review.
425 426
426 - `--zero-commit`::
427 + --zero-commit::
427 428 Output an all-zero hash in each patch's From header instead
428 429 of the hash of the commit.
429 430
430 - `--no-base`::
431 - `--base[=<commit>]`::
431 + --no-base::
432 + --base[=<commit>]::
432 433 Record the base tree information to identify the state the
433 434 patch series applies to. See the BASE TREE INFORMATION section
434 - below for details. If _<commit>_ is `auto`, a base commit is
435 + below for details. If <commit> is "auto", a base commit is
435 436 automatically chosen. The `--no-base` option overrides a
436 437 `format.useAutoBase` configuration.
437 438
438 - `--root`::
439 - Treat the revision argument as a _<revision-range>_, even if it
439 + --root::
440 + Treat the revision argument as a <revision-range>, even if it
440 441 is just a single commit (that would normally be treated as a
441 - _<since>_). Note that root commits included in the specified
442 + <since>). Note that root commits included in the specified
442 443 range are always formatted as creation patches, independently
443 444 of this flag.
444 445
445 - `--progress`::
446 + --progress::
446 447 Show progress reports on stderr as patches are generated.
447 448
448 449 CONFIGURATION
@@ -453,7 +454,7 @@ outputting more than one patch, add "To:" or "Cc:" headers, configure
453 454 attachments, change the patch output directory, and sign off patches
454 455 with configuration variables.
455 456
456 - ----
457 + ------------
457 458 [format]
458 459 headers = "Organization: git-foo\n"
459 460 subjectPrefix = CHANGE
@@ -467,16 +468,17 @@ with configuration variables.
467 468 coverLetter = auto
468 469 commitListFormat = shortlog
469 470 coverFromDescription = auto
470 - ----
471 + ------------
472 +
471 473
472 474 DISCUSSION
473 475 ----------
474 476
475 - The patch produced by `git format-patch` is in UNIX mailbox format,
477 + The patch produced by 'git format-patch' is in UNIX mailbox format,
476 478 with a fixed "magic" time stamp to indicate that the file is output
477 479 from format-patch rather than a real mailbox, like so:
478 480
479 - ----
481 + ------------
480 482 From 8f72bad1baf19a53459661343e21d6491c3908d3 Mon Sep 17 00:00:00 2001
481 483 From: Tony Luck <tony.luck@intel.com>
482 484 Date: Tue, 13 Jul 2010 11:42:54 -0700
@@ -491,7 +493,7 @@ arch/arm config files were slimmed down using a python script
491 493
492 494 Do the same for ia64 so we can have sleek & trim looking
493 495 ...
494 - ----
496 + ------------
495 497
496 498 Typically it will be placed in a MUA's drafts folder, edited to add
497 499 timely commentary that should not go in the changelog after the three
@@ -501,12 +503,12 @@ can save interesting patches in a UNIX mailbox and apply them with
501 503 linkgit:git-am[1].
502 504
503 505 When a patch is part of an ongoing discussion, the patch generated by
504 - `git format-patch` can be tweaked to take advantage of the `git am
505 - --scissors` feature. After your response to the discussion comes a
506 + 'git format-patch' can be tweaked to take advantage of the 'git am
507 + --scissors' feature. After your response to the discussion comes a
506 508 line that consists solely of "`-- >8 --`" (scissors and perforation),
507 509 followed by the patch with unnecessary header fields removed:
508 510
509 - ----
511 + ------------
510 512 ...
511 513 > So we should do such-and-such.
512 514
@@ -517,7 +519,7 @@ Subject: [IA64] Put ia64 config files on the Uwe Kleine-Kรถnig diet
517 519
518 520 arch/arm config files were slimmed down using a python script
519 521 ...
520 - ----
522 + ------------
521 523
522 524 When sending a patch this way, most often you are sending your own
523 525 patch, so in addition to the "`From $SHA1 $magic_timestamp`" marker you
@@ -539,7 +541,7 @@ two common types of corruption:
539 541 One way to test if your MUA is set up correctly is:
540 542
541 543 * Send the patch to yourself, exactly the way you would, except
542 - with `To:` and `Cc:` lines that do not contain the list and
544 + with To: and Cc: lines that do not contain the list and
543 545 maintainer address.
544 546
545 547 * Save that patch to a file in UNIX mailbox format. Call it a.patch,
@@ -560,12 +562,12 @@ If it does not apply correctly, there can be various reasons.
560 562 this case.
561 563
562 564 * The MUA corrupted your patch; "am" would complain that
563 - the patch does not apply. Look in the `.git/rebase-apply/` subdirectory and
564 - see what `patch` file contains and check for the common
565 - corruption patterns mentioned above.
565 + the patch does not apply. Look in the .git/rebase-apply/ subdirectory and
566 + see what 'patch' file contains and check for the common
567 + corruption patterns mentioned above.
566 568
567 - * While at it, check the `info` and `final-commit` files as well.
568 - If what is in `final-commit` is not exactly what you would want to
569 + * While at it, check the 'info' and 'final-commit' files as well.
570 + If what is in 'final-commit' is not exactly what you would want to
569 571 see in the commit log message, it is very likely that the
570 572 receiver would end up hand editing the log message when applying
571 573 your patch. Things like "Hi, this is my first patch.\n" in the
@@ -581,11 +583,11 @@ GMail
581 583 ~~~~~
582 584 GMail does not have any way to turn off line wrapping in the web
583 585 interface, so it will mangle any emails that you send. You can however
584 - use `git send-email` and send your patches through the GMail SMTP server, or
586 + use "git send-email" and send your patches through the GMail SMTP server, or
585 587 use any IMAP email client to connect to the google IMAP server and forward
586 588 the emails through that.
587 589
588 - For hints on using `git send-email` to send your patches through the
590 + For hints on using 'git send-email' to send your patches through the
589 591 GMail SMTP server, see the EXAMPLE section of linkgit:git-send-email[1].
590 592
591 593 For hints on submission using the IMAP interface, see the EXAMPLE
@@ -594,7 +596,7 @@ section of linkgit:git-imap-send[1].
594 596 Thunderbird
595 597 ~~~~~~~~~~~
596 598 By default, Thunderbird will both wrap emails as well as flag
597 - them as being `format=flowed`, both of which will make the
599 + them as being 'format=flowed', both of which will make the
598 600 resulting email unusable by Git.
599 601
600 602 There are three different approaches: use an add-on to turn off line wraps,
@@ -608,14 +610,14 @@ Install the Toggle Line Wrap add-on that is available from
608 610 https://addons.thunderbird.net/thunderbird/addon/toggle-line-wrap
609 611 It adds a button "Line Wrap" to the composer's toolbar
610 612 that you can tick off. Now you can compose the message as you otherwise do
611 - (cut + paste, `git format-patch` | `git imap-send`, etc), but you have to
613 + (cut + paste, 'git format-patch' | 'git imap-send', etc), but you have to
612 614 insert line breaks manually in any text that you type.
613 615
614 616 As a bonus feature, the add-on can detect patch text in the composer
615 617 and warns when line wrapping has not yet been turned off.
616 618
617 619 The add-on requires a few tweaks of the advanced configuration
618 - (`about:config`). These are listed on the download page.
620 + (about:config). These are listed on the download page.
619 621
620 622 Approach #2 (configuration)
621 623 ^^^^^^^^^^^^^^^^^^^^^^^^^^^
@@ -642,7 +644,7 @@ Toggle it to make sure it is set to `false`. Also, search for
642 644 Toggle it to make sure it is set to `false`.
643 645
644 646 After that is done, you should be able to compose email as you
645 - otherwise would (cut + paste, `git format-patch` | `git imap-send`, etc),
647 + otherwise would (cut + paste, 'git format-patch' | 'git imap-send', etc),
646 648 and the patches will not be mangled.
647 649
648 650 Approach #3 (external editor)
@@ -659,14 +661,14 @@ External Editor from https://globs.org/articles.php?lng=en&pg=8
659 661 "Composition & Addressing" panel of the account to be used to
660 662 send the patch.
661 663
662 - 3. In the main Thunderbird window, _before_ you open the compose
664 + 3. In the main Thunderbird window, 'before' you open the compose
663 665 window for the patch, use Tools->about:config to set the
664 666 following to the indicated values:
665 667 +
666 - ----
668 + ----------
667 669 mailnews.send_plaintext_flowed => false
668 670 mailnews.wraplength => 0
669 - ----
671 + ----------
670 672
671 673 4. Open a compose window and click the external editor icon.
672 674
@@ -676,11 +678,11 @@ External Editor from https://globs.org/articles.php?lng=en&pg=8
676 678 Side note: it may be possible to do step 2 with
677 679 about:config and the following settings but no one's tried yet.
678 680
679 - ----
681 + ----------
680 682 mail.html_compose => false
681 683 mail.identity.default.compose_html => false
682 684 mail.identity.id?.compose_html => false
683 - ----
685 + ----------
684 686
685 687 There is a script in contrib/thunderbird-patch-inline which can help
686 688 you include patches with Thunderbird in an easy way. To use it, do the
@@ -707,15 +709,15 @@ BASE TREE INFORMATION
707 709
708 710 The base tree information block is used for maintainers or third party
709 711 testers to know the exact state the patch series applies to. It consists
710 - of the "base commit", which is a well-known commit that is part of the
712 + of the 'base commit', which is a well-known commit that is part of the
711 713 stable part of the project history everybody else works off of, and zero
712 - or more "prerequisite patches", which are well-known patches in flight
713 - that is not yet part of the "base commit" that need to be applied on top
714 - of "base commit" in topological order before the patches can be applied.
714 + or more 'prerequisite patches', which are well-known patches in flight
715 + that is not yet part of the 'base commit' that need to be applied on top
716 + of 'base commit' in topological order before the patches can be applied.
715 717
716 - The "base commit" is shown as "`base-commit:` " followed by the 40-hex of
717 - the commit object name. A "prerequisite patch" is shown as
718 - "`prerequisite-patch-id:` " followed by the 40-hex "patch id", which can
718 + The 'base commit' is shown as "base-commit: " followed by the 40-hex of
719 + the commit object name. A 'prerequisite patch' is shown as
720 + "prerequisite-patch-id: " followed by the 40-hex 'patch id', which can
719 721 be obtained by passing the patch through the `git patch-id --stable`
720 722 command.
721 723
@@ -733,12 +735,12 @@ range), the base tree information block is shown at the end of the
733 735 first message the command outputs (either the first patch, or the
734 736 cover letter), like this:
735 737
736 - ----
738 + ------------
737 739 base-commit: P
738 740 prerequisite-patch-id: X
739 741 prerequisite-patch-id: Y
740 742 prerequisite-patch-id: Z
741 - ----
743 + ------------
742 744
743 745 For non-linear topology, such as
744 746
@@ -762,7 +764,7 @@ EXAMPLES
762 764 --------
763 765
764 766 * Extract commits between revisions R1 and R2, and apply them on top of
765 - the current branch using `git am` to cherry-pick them:
767 + the current branch using 'git am' to cherry-pick them:
766 768 +
767 769 ------------
768 770 $ git format-patch -k --stdout R1..R2 | git am -3 -k
@@ -777,7 +779,7 @@ $ git format-patch origin
777 779 +
778 780 For each commit a separate file is created in the current directory.
779 781
780 - * Extract all commits that lead to `origin` since the inception of the
782 + * Extract all commits that lead to 'origin' since the inception of the
781 783 project:
782 784 +
783 785 ------------
@@ -793,7 +795,7 @@ $ git format-patch -M -B origin
793 795 Additionally, it detects and handles renames and complete rewrites
794 796 intelligently to produce a renaming patch. A renaming patch reduces
795 797 the amount of text output, and generally makes it easier to review.
796 - Note that non-Git `patch` programs won't understand renaming patches, so
798 + Note that non-Git "patch" programs won't understand renaming patches, so
797 799 use it only when you know the recipient uses Git to apply your patch.
798 800
799 801 * Extract three topmost commits from the current branch and format them
deleted Documentation/git-format-rev.adoc mode 100644
@@ -1,216 +0,0 @@
1 - git-format-rev(1)
2 - =================
3 -
4 - NAME
5 - ----
6 - git-format-rev - EXPERIMENTAL: Pretty format revisions on demand
7 -
8 -
9 - SYNOPSIS
10 - --------
11 - [synopsis]
12 - (EXPERIMENTAL!) git format-rev --stdin-mode=<mode> --format=<pretty> [--[no-]notes=<ref>] [-z] [--[no-]null-output] [--[no-]null-input]
13 -
14 - DESCRIPTION
15 - -----------
16 -
17 - Pretty format revisions from standard input.
18 -
19 - THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
20 -
21 - OPTIONS
22 - -------
23 -
24 - `--stdin-mode=<mode>`::
25 - How to interpret standard input data:
26 - +
27 - --
28 - `revs`;; Each line or record (see the <<io,INPUT AND OUTPUT FORMATS>>
29 - section) is interpreted as a commit. Any kind of revision
30 - expression can be used (see linkgit:gitrevisions[7]). Annotated
31 - tags are peeled (see linkgit:gitglossary[7]).
32 - +
33 - The argument `rev` is also accepted.
34 -
35 - `text`;; Formats all commit object names found in freeform text. These
36 - must be full object names, i.e. abbreviated hexadecimal object
37 - names will not be interpreted.
38 - +
39 - Anything that is parsed as an object name but that is not found to be a
40 - commit object name is left alone (echoed).
41 - --
42 -
43 - `--format=<pretty>`::
44 - Pretty format string.
45 -
46 - `--notes=<ref>`::
47 - `--no-notes`::
48 - Custom notes ref. Notes are displayed when using the `%N`
49 - atom. See linkgit:git-notes[1].
50 -
51 - `-z`::
52 - `--null`::
53 - Use _NUL_ character to terminate both input and output instead
54 - of newline. This option cannot be negated.
55 - +
56 - This is useful if both the input and output could contain newlines or if
57 - the input to this command also uses _NUL_ character termination; see the
58 - <<io,INPUT AND OUTPUT FORMATS>> section below.
59 - +
60 - The mode `--stdin-mode=text` can have use for this option when it needs
61 - to process input like for example `git last-modified -z`; see the
62 - <<examples,EXAMPLES>> section below.
63 -
64 - `--null-output`::
65 - `--no-null-output`::
66 - Use _NUL_ character to terminate output instead of newline. The
67 - default is `--no-null-output`.
68 - +
69 - This is useful if the output could contain newlines, for example if the
70 - `%n` (newline) atom is used.
71 -
72 - `--null-input`::
73 - `--no-null-input`::
74 - Use _NUL_ character to terminate input instead of newline. The
75 - default is `--no-null-input`.
76 - +
77 - This is useful if the input revision expressions could contain newlines.
78 -
79 - [[io]]
80 - INPUT AND OUTPUT FORMAT
81 - -----------------------
82 -
83 - The command uses newlines for both input and output termination by
84 - default. See the `-z`, `--null-output`, and `--null-input` options for
85 - using _NUL_ character as the terminator.
86 -
87 - The mode `--stdin-mode=revs` outputs one formatted commit followed by
88 - the terminator. This could either be called a _line_ or a _record_ in
89 - case "line" is too suggestive of newline termination.
90 -
91 - Note that this means that the terminator character (newline or _NUL_)
92 - acts as a _terminator_, not a _separator_. In other words, the final
93 - line or record is also terminated by the terminator character.
94 -
95 - The mode `--stdin-mode=text` replaces each object name with the
96 - formatted commit, i.e. the format `"%s"` would transform some commit
97 - object name to `"<subject>"` without any termination. Like this:
98 -
99 - [synopsis]
100 - --
101 - Did we not fix this in "<subject>"?
102 - --
103 -
104 - It is safe to interactively read and write from this command since each
105 - record is immediately flushed.
106 -
107 - [[examples]]
108 - EXAMPLES
109 - --------
110 -
111 - The command linkgit:git-last-modified[1] shows the commit that each file
112 - was last modified in.
113 -
114 - ----
115 - $ git last-modified -- README.md Makefile
116 - 7798034171030be0909c56377a4e0e10e6d2df93 Makefile
117 - c50fbb2dd225e7e82abba4380423ae105089f4d7 README.md
118 - ----
119 -
120 - We can pipe the result to this command in order to replace the object
121 - name with the commit author.
122 -
123 - ----
124 - $ git last-modified -- README.md Makefile |
125 - git format-rev --stdin-mode=text --format=%an
126 - Junio C Hamano Makefile
127 - Todd Zullinger README.md
128 - ----
129 -
130 - Another example is _formatting commits in commit messages_. Given this commit message:
131 -
132 - ----
133 - Fix off-by-one error
134 -
135 - Fix off-by-one error introduced in
136 - e83c5163316f89bfbde7d9ab23ca2e25604af290.
137 -
138 - We thought we fixed this in 5569bf9bbedd63a00780fc5c110e0cfab3aa97b9 but
139 - that only covered 1/3 of the faulty cases.
140 - ----
141 -
142 - We can format the commits and use par(1) to reflow the text, say in a
143 - `commit-msg` hook:
144 -
145 - ----
146 - $ git config set hook.reference-commits.event commit-msg
147 - $ git config set hook.reference-commits.command reference-commits
148 - $ cat $(which reference-commits)
149 - #/bin/sh
150 -
151 - msg="$1"
152 - rewritten=$(mktemp)
153 - git format-rev --stdin-mode=text --format=reference <"$msg" |
154 - par >"$rewritten"
155 - mv "$rewritten" "$msg"
156 - ----
157 -
158 - Which will produce something like this:
159 -
160 - ----
161 - Fix off-by-one error
162 -
163 - Fix off-by-one error introduced in e83c5163316 (Implement better memory
164 - allocator, 2005-04-07).
165 -
166 - We thought we fixed this in 5569bf9bbed (Fix memory allocator,
167 - 2005-06-22) but that only covered 1/3 of the faulty cases.
168 - ----
169 -
170 - DISCUSSION
171 - ----------
172 -
173 - This command lets you format any number of revisions in any order
174 - through one command invocation. Consider the
175 - linkgit:git-last-modified[1] case from the <<examples,EXAMPLES>> section
176 - above:
177 -
178 - 1. There might be hundreds of files
179 - 2. Commits can be repeated, i.e. two or more files were last modified in
180 - the same commit
181 -
182 - Two widely-used commands which pretty formats commits are
183 - linkgit:git-log[1] and linkgit:git-show[1]. It turns out that they are
184 - not a good fit for the above use case.
185 -
186 - - The output of linkgit:git-last-modified[1] would have to be processed
187 - in stages since you need to transform the first column separately and
188 - then link the author to the filename. But this is surmountable.
189 - - You can feed each commit to `git show` or `git log --no-walk -1`. But
190 - that means that you need to create a process for each line.
191 - - Letโ€™s say that you want to use one process, not one per line. So you
192 - want to feed all the commits to the command. Now you face the problem
193 - that you have to feed all the commits to the commands before you get
194 - any output (this is also the case for the `--stdin` modes). In other
195 - words, you cannot loop through each line, get the author for the
196 - commit, and output the author and the filename. You need to feed all
197 - the commits, get back all the output, and match the output with the
198 - filename.
199 - - But the next problem is that commands will deduplicate the input and
200 - only output one commit one single time only. Thus you cannot make the
201 - output order match the input order, since a commit could have been
202 - repeated in the original input.
203 -
204 - In short, it is straightforward to use these two commands if you use one
205 - process per line. It is much more work if you just want to use one
206 - process, but still doable. In contrast, this problem is solved with just
207 - another shell pipeline with this command.
208 -
209 - SEE ALSO
210 - --------
211 - linkgit:git-name-rev[1],
212 - linkgit:git-log[1].
213 -
214 - GIT
215 - ---
216 - Part of the linkgit:git[1] suite
modified Documentation/git-fsmonitor--daemon.adoc
@@ -76,9 +76,9 @@ repositories; this may be overridden by setting `fsmonitor.allowRemote` to
76 76 correctly with all network-mounted repositories, so such use is considered
77 77 experimental.
78 78
79 - On Mac OS and Linux, the inter-process communication (IPC) between various Git
79 + On Mac OS, the inter-process communication (IPC) between various Git
80 80 commands and the fsmonitor daemon is done via a Unix domain socket (UDS) -- a
81 - special type of file -- which is supported by native Mac OS and Linux filesystems,
81 + special type of file -- which is supported by native Mac OS filesystems,
82 82 but not on network-mounted filesystems, NTFS, or FAT32. Other filesystems
83 83 may or may not have the needed support; the fsmonitor daemon is not guaranteed
84 84 to work with these filesystems and such use is considered experimental.
@@ -87,33 +87,13 @@ By default, the socket is created in the `.git` directory. However, if the
87 87 `.git` directory is on a network-mounted filesystem, it will instead be
88 88 created at `$HOME/.git-fsmonitor-*` unless `$HOME` itself is on a
89 89 network-mounted filesystem, in which case you must set the configuration
90 - variable `fsmonitor.socketDir` to the path of a directory on a native
90 + variable `fsmonitor.socketDir` to the path of a directory on a Mac OS native
91 91 filesystem in which to create the socket file.
92 92
93 93 If none of the above directories (`.git`, `$HOME`, or `fsmonitor.socketDir`)
94 - is on a native filesystem the fsmonitor daemon will report an
94 + is on a native Mac OS file filesystem the fsmonitor daemon will report an
95 95 error that will cause the daemon and the currently running command to exit.
96 96
97 - LINUX CAVEATS
98 - ~~~~~~~~~~~~~
99 -
100 - On Linux, the fsmonitor daemon uses inotify to monitor filesystem events.
101 - The inotify system has per-user limits on the number of watches that can
102 - be created. The default limit is typically 8192 watches per user.
103 -
104 - For large repositories with many directories, you may need to increase
105 - this limit. Check the current limit with:
106 -
107 - cat /proc/sys/fs/inotify/max_user_watches
108 -
109 - To temporarily increase the limit:
110 -
111 - sudo sysctl fs.inotify.max_user_watches=65536
112 -
113 - To make the change permanent, add to `/etc/sysctl.conf`:
114 -
115 - fs.inotify.max_user_watches=65536
116 -
117 97 CONFIGURATION
118 98 -------------
119 99
modified Documentation/git-grep.adoc
@@ -8,8 +8,8 @@ git-grep - Print lines matching a pattern
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git grep [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp]
11 + [verse]
12 + 'git grep' [-a | --text] [-I] [--textconv] [-i | --ignore-case] [-w | --word-regexp]
13 13 [-v | --invert-match] [-h|-H] [--full-name]
14 14 [-E | --extended-regexp] [-G | --basic-regexp]
15 15 [-P | --perl-regexp]
@@ -41,139 +41,139 @@ characters. An empty string as search expression matches all lines.
41 41
42 42 OPTIONS
43 43 -------
44 - `--cached`::
44 + --cached::
45 45 Instead of searching tracked files in the working tree, search
46 46 blobs registered in the index file.
47 47
48 - `--untracked`::
48 + --untracked::
49 49 In addition to searching in the tracked files in the working
50 50 tree, search also in untracked files.
51 51
52 - `--no-index`::
52 + --no-index::
53 53 Search files in the current directory that is not managed by Git,
54 54 or by ignoring that the current directory is managed by Git. This
55 - is rather similar to running the regular `grep`(1) utility with its
55 + is rather similar to running the regular `grep(1)` utility with its
56 56 `-r` option specified, but with some additional benefits, such as
57 - using pathspec patterns to limit paths; see the `pathspec` entry
57 + using pathspec patterns to limit paths; see the 'pathspec' entry
58 58 in linkgit:gitglossary[7] for more information.
59 59 +
60 60 This option cannot be used together with `--cached` or `--untracked`.
61 61 See also `grep.fallbackToNoIndex` in 'CONFIGURATION' below.
62 62
63 - `--no-exclude-standard`::
63 + --no-exclude-standard::
64 64 Also search in ignored files by not honoring the `.gitignore`
65 65 mechanism. Only useful with `--untracked`.
66 66
67 - `--exclude-standard`::
67 + --exclude-standard::
68 68 Do not pay attention to ignored files specified via the `.gitignore`
69 69 mechanism. Only useful when searching files in the current directory
70 70 with `--no-index`.
71 71
72 - `--recurse-submodules`::
72 + --recurse-submodules::
73 73 Recursively search in each submodule that is active and
74 74 checked out in the repository. When used in combination with the
75 75 _<tree>_ option the prefix of all submodule output will be the name of
76 76 the parent project's _<tree>_ object. This option cannot be used together
77 77 with `--untracked`, and it has no effect if `--no-index` is specified.
78 78
79 - `-a`::
80 - `--text`::
79 + -a::
80 + --text::
81 81 Process binary files as if they were text.
82 82
83 - `--textconv`::
83 + --textconv::
84 84 Honor textconv filter settings.
85 85
86 - `--no-textconv`::
86 + --no-textconv::
87 87 Do not honor textconv filter settings.
88 88 This is the default.
89 89
90 - `-i`::
91 - `--ignore-case`::
90 + -i::
91 + --ignore-case::
92 92 Ignore case differences between the patterns and the
93 93 files.
94 94
95 - `-I`::
95 + -I::
96 96 Don't match the pattern in binary files.
97 97
98 - `--max-depth <depth>`::
99 - For each _<pathspec>_ given on command line, descend at most _<depth>_
98 + --max-depth <depth>::
99 + For each <pathspec> given on command line, descend at most <depth>
100 100 levels of directories. A value of -1 means no limit.
101 - This option is ignored if _<pathspec>_ contains active wildcards.
101 + This option is ignored if <pathspec> contains active wildcards.
102 102 In other words if "a*" matches a directory named "a*",
103 - "*" is matched literally so `--max-depth` is still effective.
103 + "*" is matched literally so --max-depth is still effective.
104 104
105 - `-r`::
106 - `--recursive`::
105 + -r::
106 + --recursive::
107 107 Same as `--max-depth=-1`; this is the default.
108 108
109 - `--no-recursive`::
109 + --no-recursive::
110 110 Same as `--max-depth=0`.
111 111
112 - `-w`::
113 - `--word-regexp`::
112 + -w::
113 + --word-regexp::
114 114 Match the pattern only at word boundary (either begin at the
115 115 beginning of a line, or preceded by a non-word character; end at
116 116 the end of a line or followed by a non-word character).
117 117
118 - `-v`::
119 - `--invert-match`::
118 + -v::
119 + --invert-match::
120 120 Select non-matching lines.
121 121
122 - `-h`::
123 - `-H`::
122 + -h::
123 + -H::
124 124 By default, the command shows the filename for each
125 125 match. `-h` option is used to suppress this output.
126 126 `-H` is there for completeness and does not do anything
127 127 except it overrides `-h` given earlier on the command
128 128 line.
129 129
130 - `--full-name`::
130 + --full-name::
131 131 When run from a subdirectory, the command usually
132 132 outputs paths relative to the current directory. This
133 133 option forces paths to be output relative to the project
134 134 top directory.
135 135
136 - `-E`::
137 - `--extended-regexp`::
138 - `-G`::
139 - `--basic-regexp`::
136 + -E::
137 + --extended-regexp::
138 + -G::
139 + --basic-regexp::
140 140 Use POSIX extended/basic regexp for patterns. Default
141 141 is to use basic regexp.
142 142
143 - `-P`::
144 - `--perl-regexp`::
143 + -P::
144 + --perl-regexp::
145 145 Use Perl-compatible regular expressions for patterns.
146 146 +
147 147 Support for these types of regular expressions is an optional
148 148 compile-time dependency. If Git wasn't compiled with support for them
149 149 providing this option will cause it to die.
150 150
151 - `-F`::
152 - `--fixed-strings`::
151 + -F::
152 + --fixed-strings::
153 153 Use fixed strings for patterns (don't interpret pattern
154 154 as a regex).
155 155
156 - `-n`::
157 - `--line-number`::
156 + -n::
157 + --line-number::
158 158 Prefix the line number to matching lines.
159 159
160 - `--column`::
160 + --column::
161 161 Prefix the 1-indexed byte-offset of the first match from the start of the
162 162 matching line.
163 163
164 - `-l`::
165 - `--files-with-matches`::
166 - `--name-only`::
167 - `-L`::
168 - `--files-without-match`::
164 + -l::
165 + --files-with-matches::
166 + --name-only::
167 + -L::
168 + --files-without-match::
169 169 Instead of showing every matched line, show only the
170 170 names of files that contain (or do not contain) matches.
171 - For better compatibility with `git diff`, `--name-only` is a
171 + For better compatibility with 'git diff', `--name-only` is a
172 172 synonym for `--files-with-matches`.
173 173
174 - `-O[<pager>]`::
175 - `--open-files-in-pager[=<pager>]`::
176 - Open the matching files in the pager (not the output of `grep`).
174 + -O[<pager>]::
175 + --open-files-in-pager[=<pager>]::
176 + Open the matching files in the pager (not the output of 'grep').
177 177 If the pager happens to be "less" or "vi", and the user
178 178 specified only one pattern, the first file is positioned at
179 179 the first match automatically. The `pager` argument is
@@ -181,65 +181,65 @@ providing this option will cause it to die.
181 181 without a space. If `pager` is unspecified, the default pager
182 182 will be used (see `core.pager` in linkgit:git-config[1]).
183 183
184 - `-z`::
185 - `--null`::
184 + -z::
185 + --null::
186 186 Use \0 as the delimiter for pathnames in the output, and print
187 187 them verbatim. Without this option, pathnames with "unusual"
188 188 characters are quoted as explained for the configuration
189 189 variable `core.quotePath` (see linkgit:git-config[1]).
190 190
191 - `-o`::
192 - `--only-matching`::
191 + -o::
192 + --only-matching::
193 193 Print only the matched (non-empty) parts of a matching line, with each such
194 194 part on a separate output line.
195 195
196 - `-c`::
197 - `--count`::
196 + -c::
197 + --count::
198 198 Instead of showing every matched line, show the number of
199 199 lines that match.
200 200
201 - `--color[=<when>]`::
201 + --color[=<when>]::
202 202 Show colored matches.
203 - The value must be `always` (the default), `never`, or `auto`.
203 + The value must be always (the default), never, or auto.
204 204
205 - `--no-color`::
205 + --no-color::
206 206 Turn off match highlighting, even when the configuration file
207 207 gives the default to color output.
208 208 Same as `--color=never`.
209 209
210 - `--break`::
210 + --break::
211 211 Print an empty line between matches from different files.
212 212
213 - `--heading`::
213 + --heading::
214 214 Show the filename above the matches in that file instead of
215 215 at the start of each shown line.
216 216
217 - `-p`::
218 - `--show-function`::
217 + -p::
218 + --show-function::
219 219 Show the preceding line that contains the function name of
220 220 the match, unless the matching line is a function name itself.
221 221 The name is determined in the same way as `git diff` works out
222 222 patch hunk headers (see 'Defining a custom hunk-header' in
223 223 linkgit:gitattributes[5]).
224 224
225 - `-<num>`::
226 - `-C <num>`::
227 - `--context <num>`::
228 - Show _<num>_ leading and trailing lines, and place a line
225 + -<num>::
226 + -C <num>::
227 + --context <num>::
228 + Show <num> leading and trailing lines, and place a line
229 229 containing `--` between contiguous groups of matches.
230 230
231 - `-A <num>`::
232 - `--after-context <num>`::
233 - Show _<num>_ trailing lines, and place a line containing
231 + -A <num>::
232 + --after-context <num>::
233 + Show <num> trailing lines, and place a line containing
234 234 `--` between contiguous groups of matches.
235 235
236 - `-B <num>`::
237 - `--before-context <num>`::
238 - Show _<num>_ leading lines, and place a line containing
236 + -B <num>::
237 + --before-context <num>::
238 + Show <num> leading lines, and place a line containing
239 239 `--` between contiguous groups of matches.
240 240
241 - `-W`::
242 - `--function-context`::
241 + -W::
242 + --function-context::
243 243 Show the surrounding text from the previous line containing a
244 244 function name up to the one before the next function name,
245 245 effectively showing the whole function in which the match was
@@ -247,22 +247,22 @@ providing this option will cause it to die.
247 247 `git diff` works out patch hunk headers (see 'Defining a
248 248 custom hunk-header' in linkgit:gitattributes[5]).
249 249
250 - `-m <num>`::
251 - `--max-count <num>`::
250 + -m <num>::
251 + --max-count <num>::
252 252 Limit the amount of matches per file. When using the `-v` or
253 253 `--invert-match` option, the search stops after the specified
254 254 number of non-matches. A value of -1 will return unlimited
255 255 results (the default). A value of 0 will exit immediately with
256 256 a non-zero status.
257 257
258 - `--threads <num>`::
259 - Number of `grep` worker threads to use. See `NOTES ON THREADS`
258 + --threads <num>::
259 + Number of `grep` worker threads to use. See 'NOTES ON THREADS'
260 260 and `grep.threads` in 'CONFIGURATION' for more information.
261 261
262 - `-f <file>`::
263 - Read patterns from _<file>_, one per line.
262 + -f <file>::
263 + Read patterns from <file>, one per line.
264 264 +
265 - Passing the pattern via _<file>_ allows for providing a search pattern
265 + Passing the pattern via <file> allows for providing a search pattern
266 266 containing a \0.
267 267 +
268 268 Not all pattern types support patterns containing \0. Git will error
@@ -279,44 +279,44 @@ In future versions we may learn to support patterns containing \0 for
279 279 more search backends, until then we'll die when the pattern type in
280 280 question doesn't support them.
281 281
282 - `-e`::
282 + -e::
283 283 The next parameter is the pattern. This option has to be
284 284 used for patterns starting with `-` and should be used in
285 285 scripts passing user input to grep. Multiple patterns are
286 - combined by `or`.
286 + combined by 'or'.
287 287
288 - `--and`::
289 - `--or`::
290 - `--not`::
291 - `( ... )`::
288 + --and::
289 + --or::
290 + --not::
291 + ( ... )::
292 292 Specify how multiple patterns are combined using Boolean
293 293 expressions. `--or` is the default operator. `--and` has
294 294 higher precedence than `--or`. `-e` has to be used for all
295 295 patterns.
296 296
297 - `--all-match`::
297 + --all-match::
298 298 When giving multiple pattern expressions combined with `--or`,
299 299 this flag is specified to limit the match to files that
300 300 have lines to match all of them.
301 301
302 - `-q`::
303 - `--quiet`::
302 + -q::
303 + --quiet::
304 304 Do not output matched lines; instead, exit with status 0 when
305 305 there is a match and with non-zero status when there isn't.
306 306
307 - `<tree>...`::
307 + <tree>...::
308 308 Instead of searching tracked files in the working tree, search
309 309 blobs in the given trees.
310 310
311 - `--`::
311 + \--::
312 312 Signals the end of options; the rest of the parameters
313 - are _<pathspec>_ limiters.
313 + are <pathspec> limiters.
314 314
315 - `<pathspec>...`::
315 + <pathspec>...::
316 316 If given, limit the search to paths matching at least one pattern.
317 - Both leading paths match and `glob`(7) patterns are supported.
317 + Both leading paths match and glob(7) patterns are supported.
318 318 +
319 - For more details about the _<pathspec>_ syntax, see the `pathspec` entry
319 + For more details about the <pathspec> syntax, see the 'pathspec' entry
320 320 in linkgit:gitglossary[7].
321 321
322 322 EXAMPLES
modified Documentation/git-history.adoc
@@ -8,8 +8,6 @@ git-history - EXPERIMENTAL: Rewrite history
8 8 SYNOPSIS
9 9 --------
10 10 [synopsis]
11 - git history drop <commit> [--dry-run] [--update-refs=(branches|head)] [--empty=(drop|keep|abort)]
12 - git history fixup <commit> [--dry-run] [--update-refs=(branches|head)] [--reedit-message] [--empty=(drop|keep|abort)]
13 11 git history reword <commit> [--dry-run] [--update-refs=(branches|head)]
14 12 git history split <commit> [--dry-run] [--update-refs=(branches|head)] [--] [<pathspec>...]
15 13
@@ -24,9 +22,8 @@ THIS COMMAND IS EXPERIMENTAL. THE BEHAVIOR MAY CHANGE.
24 22 This command is related to linkgit:git-rebase[1] in that both commands can be
25 23 used to rewrite history. There are a couple of major differences though:
26 24
27 - * Most subcommands of linkgit:git-history[1] can work in a bare repository as
28 - they do not need to touch either the index or the worktree. The `fixup`
29 - subcommand is an exception to this, as it reads staged changes from the index.
25 + * linkgit:git-history[1] can work in a bare repository as it does not need to
26 + touch either the index or the worktree.
30 27 * linkgit:git-history[1] does not execute any linkgit:githooks[5] at the
31 28 current point in time. This may change in the future.
32 29 * linkgit:git-history[1] by default updates all branches that are descendants
@@ -51,43 +48,11 @@ conflicts. This limitation is by design as history rewrites are not intended to
51 48 be stateful operations. The limitation can be lifted once (if) Git learns about
52 49 first-class conflicts.
53 50
54 - When using `fixup` with `--empty=drop`, dropping the root commit is not yet
55 - supported. Likewise, `drop` cannot remove the root commit or a merge commit.
56 -
57 51 COMMANDS
58 52 --------
59 53
60 54 The following commands are available to rewrite history in different ways:
61 55
62 - `drop <commit>`::
63 - Remove the specified commit from the history. All descendants of the
64 - commit are replayed directly onto its parent.
65 - +
66 - The root commit cannot be dropped as that may lead to edge cases where refs
67 - end up with no commits anymore. Merge commits cannot be dropped either; see
68 - LIMITATIONS.
69 - +
70 - If `HEAD` points at a commit that is to be rewritten, the index and working
71 - tree are updated to match the new `HEAD`. The command aborts before any
72 - references are updated in case local modifications would be overwritten.
73 - +
74 - If replaying any descendant would result in a conflict, the command aborts
75 - with an error.
76 -
77 - `fixup <commit>`::
78 - Apply the currently staged changes to the specified commit. This is
79 - similar in nature to `git commit --fixup=<commit>` followed by `git
80 - rebase --autosquash <commit>~`. Changes are applied to the target
81 - commit by performing a three-way merge between the HEAD commit, the
82 - target commit and the tree generated from staged changes.
83 - +
84 - The commit message and authorship of the target commit are preserved by
85 - default, unless you specify `--reedit-message`.
86 - +
87 - If applying the staged changes would result in a conflict, the command
88 - aborts with an error. All branches that are descendants of the original
89 - commit are updated to point to the rewritten history.
90 -
91 56 `reword <commit>`::
92 57 Rewrite the commit message of the specified commit. All the other
93 58 details of this commit remain unchanged. This command will spawn an
@@ -122,31 +87,6 @@ OPTIONS
122 87 objects will be written into the repository, so applying these printed
123 88 ref updates is generally safe.
124 89
125 - `--reedit-message`::
126 - Open an editor to modify the target commit's message.
127 -
128 - `--empty=(drop|keep|abort)`::
129 - Control what happens when a commit becomes empty as a result of the
130 - fixup. This can happen in two situations:
131 - +
132 - --
133 - * The fixup target itself becomes empty because the staged changes exactly
134 - cancel out all changes introduced by that commit.
135 -
136 - * A descendant commit becomes empty during replay because it introduced the
137 - same change that was just fixed up into an ancestor.
138 - --
139 - +
140 - With `drop` (the default), empty commits are removed from the rewritten
141 - history. Descendants of a dropped target commit are replayed directly onto
142 - the target's parent. Note that dropping the root commit is not supported;
143 - see LIMITATIONS.
144 - +
145 - With `keep`, empty commits are retained in the rewritten history as-is.
146 - +
147 - With `abort`, the command stops with an error if any commit would become
148 - empty.
149 -
150 90 `--update-refs=(branches|head)`::
151 91 Control which references will be updated by the command, if any. With
152 92 `branches`, all local branches that point to commits which are
@@ -156,56 +96,6 @@ empty.
156 96 EXAMPLES
157 97 --------
158 98
159 - Fixup a commit
160 - ~~~~~~~~~~~~~~
161 -
162 - ----------
163 - $ git log --oneline --stat
164 - abc1234 (HEAD -> main) third
165 - third.txt | 1 +
166 - def5678 second
167 - second.txt | 1 +
168 - ghi9012 first
169 - first.txt | 1 +
170 -
171 - $ echo "change" >>unrelated.txt
172 - $ git add unrelated.txt
173 - $ git history fixup ghi9012
174 -
175 - $ git log --oneline --stat
176 - jkl3456 (HEAD -> main) third
177 - third.txt | 1 +
178 - mno7890 second
179 - second.txt | 1 +
180 - pqr1234 first
181 - first.txt | 1 +
182 - unrelated.txt | 1 +
183 - ----------
184 -
185 - The staged addition of `unrelated.txt` has been incorporated into the `first`
186 - commit. All descendant commits have been replayed on top of the rewritten
187 - history.
188 -
189 - Drop a commit
190 - ~~~~~~~~~~~~~
191 -
192 - ----------
193 - $ git log --oneline
194 - abc1234 (HEAD -> main) third
195 - def5678 second
196 - ghi9012 first
197 -
198 - $ git history drop 'main^{/second}'
199 -
200 - $ git log --oneline
201 - jkl3456 (HEAD -> main) third
202 - ghi9012 first
203 - ----------
204 -
205 - The `second` commit has been removed from the history, and `third` has been
206 - replayed directly on top of `first`. All branches that pointed at the dropped
207 - commit have been moved to its parent.
208 -
209 99 Split a commit
210 100 ~~~~~~~~~~~~~~
211 101
modified Documentation/git-hook.adoc
@@ -3,20 +3,19 @@ git-hook(1)
3 3
4 4 NAME
5 5 ----
6 - git-hook - Run Git hooks
6 + git-hook - Run git hooks
7 7
8 8 SYNOPSIS
9 9 --------
10 10 [verse]
11 - 'git hook' run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] [(-j|--jobs) <n>]
12 - <hook-name> [-- <hook-args>]
11 + 'git hook' run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]
13 12 'git hook' list [--allow-unknown-hook-name] [-z] [--show-scope] <hook-name>
14 13
15 14 DESCRIPTION
16 15 -----------
17 16
18 - A command interface for running Git hooks (see linkgit:githooks[5]),
19 - for use by other scripted Git commands.
17 + A command interface for running git hooks (see linkgit:githooks[5]),
18 + for use by other scripted git commands.
20 19
21 20 This command parses the default configuration files for sets of configs like
22 21 so:
@@ -41,7 +40,7 @@ spell-checker for your commit messages, you would write a configuration like so:
41 40
42 41 With this config, when you run 'git commit', first `~/bin/linter --cpp20` will
43 42 have a chance to check your files to be committed (during the `pre-commit` hook
44 - event), and then `~/bin/spellchecker` will have a chance to check your commit
43 + event`), and then `~/bin/spellchecker` will have a chance to check your commit
45 44 message (during the `commit-msg` hook event).
46 45
47 46 Commands are run in the order Git encounters their associated
@@ -148,23 +147,6 @@ OPTIONS
148 147 mirroring the output style of `git config --show-scope`. Traditional
149 148 hooks from the hookdir are unaffected.
150 149
151 - -j::
152 - --jobs::
153 - Only valid for `run`.
154 - +
155 - Specify how many hooks to run simultaneously. If this flag is not specified,
156 - the value of the `hook.jobs` config is used, see linkgit:git-config[1]. If
157 - neither is specified, defaults to 1 (serial execution).
158 - +
159 - When greater than 1, it overrides the per-hook `hook.<friendly-name>.parallel`
160 - setting, allowing all hooks for the event to run concurrently, even if they
161 - are not individually marked as parallel.
162 - +
163 - Some hooks always run sequentially regardless of this flag or the
164 - `hook.jobs` config, because Git knows they cannot safely run in parallel:
165 - `applypatch-msg`, `pre-commit`, `prepare-commit-msg`, `commit-msg`,
166 - `post-commit`, `post-checkout`, and `push-to-checkout`.
167 -
168 150 WRAPPERS
169 151 --------
170 152
@@ -187,8 +169,7 @@ running:
187 169 git hook run --allow-unknown-hook-name mywrapper-start-tests \
188 170 # providing something to stdin
189 171 --stdin some-tempfile-123 \
190 - # execute multiple hooks in parallel
191 - --jobs 3 \
172 + # execute hooks in serial
192 173 # plus some arguments of your own...
193 174 -- \
194 175 --testname bar \
@@ -204,7 +185,6 @@ unintended and unsupported ways.
204 185
205 186 CONFIGURATION
206 187 -------------
207 - :git-hook: 1
208 188 include::config/hook.adoc[]
209 189
210 190 SEE ALSO
modified Documentation/git-http-fetch.adoc
@@ -48,15 +48,13 @@ commit-id::
48 48 line (which is not expected in
49 49 this case), 'git http-fetch' fetches the packfile directly at the given
50 50 URL and uses index-pack to generate corresponding .idx and .keep files.
51 - The hash is used to determine the name of the temporary file. It need
52 - not be the pack hash, but it must uniquely identify the pack contents
53 - for resumption. The output of index-pack is printed to stdout. Requires
54 - one or more --index-pack-arg options.
51 + The hash is used to determine the name of the temporary file and is
52 + arbitrary. The output of index-pack is printed to stdout. Requires
53 + --index-pack-args.
55 54
56 - --index-pack-arg=<arg>::
57 - For internal use only. The first instance specifies the command run on
58 - the contents of the downloaded pack. Subsequent instances specify its
59 - arguments.
55 + --index-pack-args=<args>::
56 + For internal use only. The command to run on the contents of the
57 + downloaded pack. Arguments are URL-encoded separated by spaces.
60 58
61 59 --recover::
62 60 Verify that everything reachable from target is fetched. Used after
modified Documentation/git-imap-send.adoc
@@ -8,9 +8,9 @@ git-imap-send - Send a collection of patches from stdin to an IMAP folder
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git imap-send [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]
13 - git imap-send --list
11 + [verse]
12 + 'git imap-send' [-v] [-q] [--[no-]curl] [(--folder|-f) <folder>]
13 + 'git imap-send' --list
14 14
15 15
16 16 DESCRIPTION
@@ -24,38 +24,38 @@ that order.
24 24
25 25 Typical usage is something like:
26 26
27 - ----
27 + ------
28 28 $ git format-patch --signoff --stdout --attach origin | git imap-send
29 - ----
29 + ------
30 30
31 31
32 32 OPTIONS
33 33 -------
34 34
35 - `-v`::
36 - `--verbose`::
35 + -v::
36 + --verbose::
37 37 Be verbose.
38 38
39 - `-q`::
40 - `--quiet`::
39 + -q::
40 + --quiet::
41 41 Be quiet.
42 42
43 - `-f <folder>`::
44 - `--folder=<folder>`::
43 + -f <folder>::
44 + --folder=<folder>::
45 45 Specify the folder in which the emails have to saved.
46 46 For example: `--folder=[Gmail]/Drafts` or `-f INBOX/Drafts`.
47 47
48 - `--curl`::
48 + --curl::
49 49 Use libcurl to communicate with the IMAP server, unless tunneling
50 50 into it. Ignored if Git was built without the USE_CURL_FOR_IMAP_SEND
51 51 option set.
52 52
53 - `--no-curl`::
53 + --no-curl::
54 54 Talk to the IMAP server using git's own IMAP routines instead of
55 55 using libcurl. Ignored if Git was built with the NO_OPENSSL option
56 56 set.
57 57
58 - `--list`::
58 + --list::
59 59 Run the IMAP LIST command to output a list of all the folders present.
60 60
61 61 CONFIGURATION
@@ -138,13 +138,13 @@ have set up) may not be verified correctly.
138 138
139 139 Using Gmail's IMAP interface:
140 140
141 - ----
141 + ---------
142 142 [imap]
143 143 folder = "[Gmail]/Drafts"
144 144 host = imaps://imap.gmail.com
145 145 user = user@gmail.com
146 146 port = 993
147 - ----
147 + ---------
148 148
149 149 Gmail does not allow using your regular password for `git imap-send`.
150 150 If you have multi-factor authentication set up on your Gmail account, you
@@ -167,34 +167,32 @@ than using app-specific passwords, and also does not enforce the need of
167 167 having multi-factor authentication. You will have to use an OAuth2.0
168 168 access token in place of your password when using this authentication.
169 169
170 - ----
170 + ---------
171 171 [imap]
172 172 folder = "[Gmail]/Drafts"
173 173 host = imaps://imap.gmail.com
174 174 user = user@gmail.com
175 175 port = 993
176 176 authmethod = OAUTHBEARER
177 - ----
177 + ---------
178 178
179 179 Using Outlook's IMAP interface:
180 180
181 181 Unlike Gmail, Outlook only supports OAuth2.0 based authentication. Also, it
182 182 supports only `XOAUTH2` as the mechanism.
183 183
184 - ----
184 + ---------
185 185 [imap]
186 186 folder = "Drafts"
187 187 host = imaps://outlook.office365.com
188 188 user = user@outlook.com
189 189 port = 993
190 190 authmethod = XOAUTH2
191 - ----
191 + ---------
192 192
193 193 Once the commits are ready to be sent, run the following command:
194 194
195 - ----
196 - $ git format-patch --cover-letter -M --stdout origin/master | git imap-send
197 - ----
195 + $ git format-patch --cover-letter -M --stdout origin/master | git imap-send
198 196
199 197 Just make sure to disable line wrapping in the email client (Gmail's web
200 198 interface will wrap lines no matter what, so you need to use a real
@@ -219,7 +217,7 @@ users may wish to visit this web page for more information:
219 217
220 218 SEE ALSO
221 219 --------
222 - linkgit:git-format-patch[1], linkgit:git-send-email[1], `mbox`(5)
220 + linkgit:git-format-patch[1], linkgit:git-send-email[1], mbox(5)
223 221
224 222 GIT
225 223 ---
modified Documentation/git-interpret-trailers.adoc
@@ -3,7 +3,7 @@ git-interpret-trailers(1)
3 3
4 4 NAME
5 5 ----
6 - git-interpret-trailers - Add or parse metadata in commit messages
6 + git-interpret-trailers - Add or parse structured information in commit messages
7 7
8 8 SYNOPSIS
9 9 --------
@@ -14,15 +14,9 @@ git interpret-trailers [--in-place] [--trim-empty]
14 14
15 15 DESCRIPTION
16 16 -----------
17 - Add or parse trailer metadata at the end of the otherwise
18 - free-form part of a commit message, or any other kind of text.
19 -
20 - A _trailer_ in its simplest form is a key-value pair with a colon as a
21 - separator. The _key_ consists of ASCII alphanumeric characters and
22 - hyphens (`-`). A _trailer block_ consists of one or more trailers. The
23 - trailer block needs to be preceded by a blank line, where a _blank line_
24 - is either an empty or a whitespace-only line. For example, in the
25 - following commit message
17 + Add or parse _trailer_ lines that look similar to RFC 822 e-mail
18 + headers, at the end of the otherwise free-form part of a commit
19 + message. For example, in the following commit message
26 20
27 21 ------------------------------------------------
28 22 subject
@@ -60,18 +54,10 @@ are applied to each input and the way any existing trailer in
60 54 the input is changed. They also make it possible to
61 55 automatically add some trailers.
62 56
63 - Let's consider new trailers added with `--trailer`.
64 - By default, the new trailer will appear at the end of the trailer block.
65 - Also by default, this new trailer will only be added
66 - if the last trailer is different to it.
67 - A trailer block will be created with only that trailer if a trailer
68 - block does not already exist. Recall that a trailer block needs to be
69 - preceded by a blank line, so a blank line will be inserted before the
70 - new trailer block in that case.
71 -
72 - This is how the new trailer is added: a `<key>=<value>` or
73 - `<key>:<value>` argument given using `--trailer` will be appended after
74 - the existing trailers. The _<key>_ and _<value>_ parts will be trimmed
57 + By default, a `<key>=<value>` or `<key>:<value>` argument given
58 + using `--trailer` will be appended after the existing trailers only if
59 + the last trailer has a different (_<key>_, _<value>_) pair (or if there
60 + is no existing trailer). The _<key>_ and _<value>_ parts will be trimmed
75 61 to remove starting and trailing whitespace, and the resulting trimmed
76 62 _<key>_ and _<value>_ will appear in the output like this:
77 63
@@ -82,16 +68,6 @@ key: value
82 68 This means that the trimmed _<key>_ and _<value>_ will be separated by
83 69 "`:`{nbsp}" (one colon followed by one space).
84 70
85 - Existing trailers are extracted from the input by looking for the
86 - trailer block. A trailer block is a group of one or more lines that (i)
87 - is all trailers, or (ii) contains at least one Git-generated or
88 - user-configured trailer and consists of at
89 - least 25% trailers.
90 - The trailer block is by definition at the end of the commit message.
91 - The message in turn is either (i) at the end of the input, or (ii) the
92 - last non-whitespace lines before a line that starts with `---` (followed
93 - by a space or the end of the line).
94 -
95 71 For convenience, a _<key-alias>_ can be configured to make using `--trailer`
96 72 shorter to type on the command line. This can be configured using the
97 73 `trailer.<key-alias>.key` configuration variable. The _<key-alias>_ must be a prefix
@@ -105,6 +81,20 @@ trailer.sign.key "Signed-off-by: "
105 81 in your configuration, you only need to specify `--trailer="sign: foo"`
106 82 on the command line instead of `--trailer="Signed-off-by: foo"`.
107 83
84 + By default the new trailer will appear at the end of all the existing
85 + trailers. If there is no existing trailer, the new trailer will appear
86 + at the end of the input. A blank line will be added before the new
87 + trailer if there isn't one already.
88 +
89 + Existing trailers are extracted from the input by looking for
90 + a group of one or more lines that (i) is all trailers, or (ii) contains at
91 + least one Git-generated or user-configured trailer and consists of at
92 + least 25% trailers.
93 + The group must be preceded by one or more empty (or whitespace-only) lines.
94 + The group must either be at the end of the input or be the last
95 + non-whitespace lines before a line that starts with `---` (followed by a
96 + space or the end of the line).
97 +
108 98 When reading trailers, there can be no whitespace before or inside the
109 99 _<key>_, but any number of regular space and tab characters are allowed
110 100 between the _<key>_ and the separator. There can be whitespaces before,
@@ -117,22 +107,8 @@ key: This is a very long value, with spaces and
117 107 newlines in it.
118 108 ------------------------------------------------
119 109
120 - OTHER RULES
121 - -----------
122 -
123 - What was covered in the previous section are the rules that are relevant
124 - for regular use. The following points are included for completeness.
125 -
126 - --
127 - * This command ignores comment lines (see `core.commentString` in
128 - linkgit:git-config[1]). This is for use with the `prepare-commit-msg`
129 - and `commit-msg` hooks.
130 -
131 - * Candidate trailer lines that have `:` as the separator, that have no
132 - whitespace before the value part, and that start with `//` are not
133 - recognized as trailers. This is to avoid accidentally interpreting
134 - URLs as trailers (e.g. lines that start with `https://`).
135 - --
110 + Note that trailers do not follow (nor are they intended to follow) many of the
111 + rules for RFC 822 headers. For example they do not follow the encoding rule.
136 112
137 113 OPTIONS
138 114 -------
@@ -426,29 +402,6 @@ mv "\$1.new" "\$1"
426 402 $ chmod +x .git/hooks/commit-msg
427 403 ------------
428 404
429 - * Here we try to use three different trailer keys. But it fails because
430 - two of them are not recognized as trailer keys.
431 - +
432 - ----
433 - $ cat msg.txt
434 - subject
435 -
436 - Skapad-pรฅ: some-branch
437 - Hash-in-v6.11: 45c12d3269fe48f22834320c782ffe86c3560f2c
438 - Reviewed-by: Alice <alice@example.com>
439 - $ git interpret-trailers --only-trailers <msg.txt
440 - $
441 - ----
442 - +
443 - Recall that a trailer key has to consist of only ASCII alphanumeric
444 - characters and hyphens, and this does not hold for the two first
445 - supposed trailer keys. And now none are recognized as trailers because
446 - the candidate trailer block has at least one non-trailer line, even
447 - though `Reviewed-by` is a valid trailer key. Recall that a trailer block
448 - has to either (i) be all trailers, or (ii) consist of at least one
449 - Git-generated or user-configured trailer (and some other conditions).
450 - And (ii) is not satisfied since we have not configured any trailer keys.
451 -
452 405 SEE ALSO
453 406 --------
454 407 linkgit:git-commit[1], linkgit:git-format-patch[1], linkgit:git-config[1]
modified Documentation/git-log.adoc
@@ -36,14 +36,14 @@ OPTIONS
36 36 Print out the ref names of any commits that are shown. Possible values
37 37 are:
38 38 +
39 - --
39 + ----
40 40 `short`;; the ref name prefixes `refs/heads/`, `refs/tags/` and
41 41 `refs/remotes/` are not printed.
42 42 `full`;; the full ref name (including prefix) is printed.
43 - `auto`;; if the output is going to a terminal, the ref names
43 + `auto`:: if the output is going to a terminal, the ref names
44 44 are shown as if `short` were given, otherwise no ref names are
45 45 shown.
46 - --
46 + ----
47 47 +
48 48 The option `--decorate` is short-hand for `--decorate=short`. Default to
49 49 configuration value of `log.decorate` if configured, otherwise, `auto`.
modified Documentation/git-ls-files.adoc
@@ -331,7 +331,7 @@ can give `--exclude-per-directory=.gitignore`, and then specify:
331 331 1. The file specified by the `core.excludesfile` configuration
332 332 variable, if exists, or the `$XDG_CONFIG_HOME/git/ignore` file.
333 333
334 - 2. The `$GIT_COMMON_DIR/info/exclude` file.
334 + 2. The `$GIT_DIR/info/exclude` file.
335 335
336 336 via the `--exclude-from=` option.
337 337
modified Documentation/git-multi-pack-index.adoc
@@ -11,11 +11,9 @@ SYNOPSIS
11 11 [verse]
12 12 'git multi-pack-index' [<options>] write [--preferred-pack=<pack>]
13 13 [--[no-]bitmap] [--[no-]incremental] [--[no-]stdin-packs]
14 - [--refs-snapshot=<path>] [--[no-]write-chain-file]
15 - [--base=<checksum>]
14 + [--refs-snapshot=<path>]
16 15 'git multi-pack-index' [<options>] compact [--[no-]incremental]
17 - [--[no-]bitmap] [--base=<checksum>] [--[no-]write-chain-file]
18 - <from> <to>
16 + [--[no-]bitmap] <from> <to>
19 17 'git multi-pack-index' [<options>] verify
20 18 'git multi-pack-index' [<options>] expire
21 19 'git multi-pack-index' [<options>] repack [--batch-size=<size>]
@@ -85,20 +83,6 @@ marker).
85 83 and packs not present in an existing MIDX layer.
86 84 Migrates non-incremental MIDXs to incremental ones when
87 85 necessary.
88 -
89 - --[no-]write-chain-file::
90 - When used with `--incremental`, write a new MIDX layer
91 - but do not update the multi-pack-index-chain file.
92 - The checksum of the new layer is printed to standard
93 - output, allowing the caller to assemble and write the
94 - chain itself. Requires `--incremental`.
95 -
96 - --base=<checksum>::
97 - Specify the checksum of an existing MIDX layer to use
98 - as the base when writing a new incremental layer.
99 - The special value `none` indicates that the new layer
100 - should have no base (i.e., it becomes a root layer).
101 - Requires `--no-write-chain-file`.
102 86 --
103 87
104 88 compact::
@@ -113,18 +97,6 @@ compact::
113 97
114 98 --[no-]bitmap::
115 99 Control whether or not a multi-pack bitmap is written.
116 -
117 - --[no-]write-chain-file::
118 - When used with `--incremental`, write a new compacted
119 - MIDX layer but do not update the multi-pack-index-chain
120 - file. The checksum of the new layer is printed to
121 - standard output. Requires `--incremental`.
122 -
123 - --base=<checksum>::
124 - Specify the checksum of an existing MIDX layer to use
125 - as the base for the compacted result, instead of using
126 - the immediate parent of `<from>`. The special value
127 - `none` indicates that the result should have no base.
128 100 --
129 101 +
130 102 Note that the compact command requires writing a version-2 midx that
modified Documentation/git-pack-objects.adoc
@@ -402,13 +402,9 @@ will be automatically changed to version `1`.
402 402 of filenames that cause collisions in Git's default name-hash
403 403 algorithm.
404 404 +
405 - When `--use-bitmap-index` is specified with `--path-walk`, a successful
406 - bitmap traversal is used for object enumeration, with path-walk
407 - remaining as the fallback traversal when the bitmap cannot satisfy the
408 - request. The `--path-walk` option supports the `--filter=<spec>` forms
409 - `blob:none`, `blob:limit=<n>`, `tree:0`, `object:type=<type>`, and
410 - `sparse:<oid>`. These supported filter types can be combined with the
411 - `combine:<spec>+<spec>` form.
405 + Incompatible with `--delta-islands`, `--shallow`, or `--filter`. The
406 + `--use-bitmap-index` option will be ignored in the presence of
407 + `--path-walk.`
412 408
413 409
414 410 DELTA ISLANDS
modified Documentation/git-push.adoc
@@ -18,28 +18,17 @@ git push [--all | --branches | --mirror | --tags] [--follow-tags] [--atomic] [-n
18 18
19 19 DESCRIPTION
20 20 -----------
21 - Updates one or more branches, tags, or other references in one or more
22 - remote repositories from your local repository, and sends all necessary
23 - data that isn't already on the remote.
21 +
22 + Updates one or more branches, tags, or other references in a remote
23 + repository from your local repository, and sends all necessary data
24 + that isn't already on the remote.
24 25
25 26 The simplest way to push is `git push <remote> <branch>`.
26 27 `git push origin main` will push the local `main` branch to the `main`
27 28 branch on the remote named `origin`.
28 29
29 - You can also push to multiple remotes at once by using a remote group.
30 - A remote group is a named list of remotes configured via `remotes.<name>`
31 - in your git config:
32 -
33 - $ git config remotes.all-remotes "origin gitlab backup"
34 -
35 - Then `git push all-remotes` will push to `origin`, `gitlab`, and
36 - `backup` in turn, as if you had run `git push` against each one
37 - individually. Each remote is pushed independently using its own
38 - push mapping configuration. There is a `remotes.<group>` entry in
39 - the configuration file. (See linkgit:git-config[1]).
40 -
41 - The `<repository>` argument defaults to the upstream for the current
42 - branch, or `origin` if there's no configured upstream.
30 + The `<repository>` argument defaults to the upstream for the current branch,
31 + or `origin` if there's no configured upstream.
43 32
44 33 To decide which branches, tags, or other refs to push, Git uses
45 34 (in order of precedence):
@@ -66,10 +55,8 @@ OPTIONS
66 55 _<repository>_::
67 56 The "remote" repository that is the destination of a push
68 57 operation. This parameter can be either a URL
69 - (see the section <<URLS,GIT URLS>> below), the name
70 - of a remote (see the section <<REMOTES,REMOTES>> below),
71 - or the name of a remote group
72 - (see the section <<REMOTE-GROUPS,REMOTE GROUPS>> below).
58 + (see the section <<URLS,GIT URLS>> below) or the name
59 + of a remote (see the section <<REMOTES,REMOTES>> below).
73 60
74 61 `<refspec>...`::
75 62 Specify what destination ref to update with what source object.
@@ -443,57 +430,6 @@ further recursion will occur. In this case, `only` is treated as `on-demand`.
443 430
444 431 include::urls-remotes.adoc[]
445 432
446 - [[REMOTE-GROUPS]]
447 - REMOTE GROUPS
448 - -------------
449 -
450 - A remote group is a named list of remotes configured via `remotes.<name>`
451 - in your git config:
452 -
453 - $ git config remotes.all-remotes "r1 r2 r3"
454 -
455 - When a group name is given as the `<repository>` argument, the push is
456 - performed to each member remote in turn. The defining principle is:
457 -
458 - git push <options> all-remotes <args>
459 -
460 - is exactly equivalent to:
461 -
462 - git push <options> r1 <args>
463 - git push <options> r2 <args>
464 - ...
465 - git push <options> rN <args>
466 -
467 - where r1, r2, ..., rN are the members of `all-remotes`. No special
468 - behaviour is added or removed โ€” the group is purely a shorthand for
469 - running the same push command against each member remote individually.
470 -
471 - When pushing to a group of more than one remote, Git spawns a separate
472 - `git push` subprocess for each member remote in sequence. Each subprocess
473 - receives the same flags and refspecs as the original invocation. This
474 - means that per-remote push mappings configured via `remote.<name>.push`
475 - and mirror mode (`remote.<name>.mirror`) are evaluated independently for
476 - each remote, and a mirror remote in the group cannot affect the push
477 - behaviour of other non-mirror remotes in the same group.
478 -
479 - The `--atomic` option is not supported for group pushes, because atomicity
480 - can only be guaranteed within a single transport connection to a single
481 - remote. Git will refuse the invocation with an error if `--atomic` is
482 - combined with a group name.
483 -
484 - If any member remote fails whether due to a push rejection (e.g. a
485 - non-fast-forward update, a server-side hook refusing a ref) or a connection
486 - error (e.g. the repository does not exist, authentication fails, or the
487 - network is unreachable), Git reports the error and continues pushing to
488 - the remaining remotes in the group. The overall exit code is non-zero if
489 - any member push fails.
490 -
491 - This means the user is responsible for ensuring that the sequence of
492 - individual pushes makes sense. If `git push r1`` would fail for a given
493 - set of options and arguments, then `git push all-remotes` will fail in
494 - the same way when it reaches r1. The group push does not do anything
495 - special to make a failing individual push succeed.
496 -
497 433 OUTPUT
498 434 ------
499 435
modified Documentation/git-range-diff.adoc
@@ -7,11 +7,11 @@ git-range-diff - Compare two commit ranges (e.g. two versions of a branch)
7 7
8 8 SYNOPSIS
9 9 --------
10 - [synopsis]
11 - git range-diff [--color=[<when>]] [--no-color] [<diff-options>]
10 + [verse]
11 + 'git range-diff' [--color=[<when>]] [--no-color] [<diff-options>]
12 12 [--no-dual-color] [--creation-factor=<factor>]
13 13 [--left-only | --right-only] [--diff-merges=<format>]
14 - [--remerge-diff] [--no-notes | --notes[=<ref>]]
14 + [--remerge-diff]
15 15 ( <range1> <range2> | <rev1>...<rev2> | <base> <rev1> <rev2> )
16 16 [[--] <path>...]
17 17
@@ -21,14 +21,14 @@ DESCRIPTION
21 21 This command shows the differences between two versions of a patch
22 22 series, or more generally, two commit ranges (ignoring merge commits).
23 23
24 - In the presence of _<path>_ arguments, these commit ranges are limited
24 + In the presence of `<path>` arguments, these commit ranges are limited
25 25 accordingly.
26 26
27 27 To that end, it first finds pairs of commits from both commit ranges
28 28 that correspond with each other. Two commits are said to correspond when
29 29 the diff between their patches (i.e. the author information, the commit
30 30 message and the commit diff) is reasonably small compared to the
31 - patches' size. See 'Algorithm' below for details.
31 + patches' size. See ``Algorithm`` below for details.
32 32
33 33 Finally, the list of matching commits is shown in the order of the
34 34 second commit range, with unmatched commits being inserted just after
@@ -37,7 +37,7 @@ all of their ancestors have been shown.
37 37 There are three ways to specify the commit ranges:
38 38
39 39 - `<range1> <range2>`: Either commit range can be of the form
40 - `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See 'SPECIFYING RANGES'
40 + `<base>..<rev>`, `<rev>^!` or `<rev>^-<n>`. See `SPECIFYING RANGES`
41 41 in linkgit:gitrevisions[7] for more details.
42 42
43 43 - `<rev1>...<rev2>`. This is equivalent to
@@ -48,7 +48,7 @@ There are three ways to specify the commit ranges:
48 48
49 49 OPTIONS
50 50 -------
51 - `--no-dual-color`::
51 + --no-dual-color::
52 52 When the commit diffs differ, `git range-diff` recreates the
53 53 original diffs' coloring, and adds outer -/+ diff markers with
54 54 the *background* being red/green to make it easier to see e.g.
@@ -56,33 +56,33 @@ OPTIONS
56 56 +
57 57 Additionally, the commit diff lines that are only present in the first commit
58 58 range are shown "dimmed" (this can be overridden using the `color.diff.<slot>`
59 - config setting where _<slot>_ is one of `contextDimmed`, `oldDimmed` and
59 + config setting where `<slot>` is one of `contextDimmed`, `oldDimmed` and
60 60 `newDimmed`), and the commit diff lines that are only present in the second
61 61 commit range are shown in bold (which can be overridden using the config
62 - settings `color.diff.<slot>` with _<slot>_ being one of `contextBold`,
62 + settings `color.diff.<slot>` with `<slot>` being one of `contextBold`,
63 63 `oldBold` or `newBold`).
64 64 +
65 65 This is known to `range-diff` as "dual coloring". Use `--no-dual-color`
66 66 to revert to color all lines according to the outer diff markers
67 67 (and completely ignore the inner diff when it comes to color).
68 68
69 - `--creation-factor=<percent>`::
70 - Set the creation/deletion cost fudge factor to _<percent>_.
69 + --creation-factor=<percent>::
70 + Set the creation/deletion cost fudge factor to `<percent>`.
71 71 Defaults to 60. Try a larger value if `git range-diff` erroneously
72 72 considers a large change a total rewrite (deletion of one commit
73 73 and addition of another), and a smaller one in the reverse case.
74 - See the 'Algorithm' section below for an explanation of why this is
74 + See the ``Algorithm`` section below for an explanation of why this is
75 75 needed.
76 76
77 - `--left-only`::
77 + --left-only::
78 78 Suppress commits that are missing from the first specified range
79 - (or the "left range" when using the `<rev1>...<rev2>` form).
79 + (or the "left range" when using the `<rev1>...<rev2>` format).
80 80
81 - `--right-only`::
81 + --right-only::
82 82 Suppress commits that are missing from the second specified range
83 - (or the "right range" when using the `<rev1>...<rev2>` form).
83 + (or the "right range" when using the `<rev1>...<rev2>` format).
84 84
85 - `--diff-merges=<format>`::
85 + --diff-merges=<format>::
86 86 Instead of ignoring merge commits, generate diffs for them using the
87 87 corresponding `--diff-merges=<format>` option of linkgit:git-log[1],
88 88 and include them in the comparison.
@@ -93,30 +93,30 @@ have produced. In other words, if a merge commit is the result of a
93 93 non-conflicting `git merge`, the `remerge` mode will represent it with an empty
94 94 diff.
95 95
96 - `--remerge-diff`::
96 + --remerge-diff::
97 97 Convenience option, equivalent to `--diff-merges=remerge`.
98 98
99 - `--notes[=<ref>]`::
100 - `--no-notes`::
99 + --notes[=<ref>]::
100 + --no-notes::
101 101 This flag is passed to the `git log` program
102 102 (see linkgit:git-log[1]) that generates the patches.
103 103
104 - `<range1> <range2>`::
104 + <range1> <range2>::
105 105 Compare the commits specified by the two ranges, where
106 - _<range1>_ is considered an older version of _<range2>_.
106 + `<range1>` is considered an older version of `<range2>`.
107 107
108 - `<rev1>...<rev2>`::
108 + <rev1>...<rev2>::
109 109 Equivalent to passing `<rev2>..<rev1>` and `<rev1>..<rev2>`.
110 110
111 - `<base> <rev1> <rev2>`::
111 + <base> <rev1> <rev2>::
112 112 Equivalent to passing `<base>..<rev1>` and `<base>..<rev2>`.
113 - Note that _<base>_ does not need to be the exact branch point
113 + Note that `<base>` does not need to be the exact branch point
114 114 of the branches. Example: after rebasing a branch `my-topic`,
115 115 `git range-diff my-topic@{u} my-topic@{1} my-topic` would
116 116 show the differences introduced by the rebase.
117 117
118 118 `git range-diff` also accepts the regular diff options (see
119 - linkgit:git-diff[1]), most notably the `--color[=<when>]` and
119 + linkgit:git-diff[1]), most notably the `--color=[<when>]` and
120 120 `--no-color` options. These options are used when generating the "diff
121 121 between patches", i.e. to compare the author, commit message and diff of
122 122 corresponding old/new commits. There is currently no means to tweak most of the
modified Documentation/git-refs.adoc
@@ -20,10 +20,6 @@ git refs list [--count=<count>] [--shell|--perl|--python|--tcl]
20 20 [ --stdin | (<pattern>...)]
21 21 git refs exists <ref>
22 22 git refs optimize [--all] [--no-prune] [--auto] [--include <pattern>] [--exclude <pattern>]
23 - git refs create [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value>
24 - git refs delete [--message=<reason>] [--no-deref] <ref> [<old-value>]
25 - git refs update [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value> [<old-value>]
26 - git refs rename [--message=<reason>] <old-ref> <new-ref>
27 23
28 24 DESCRIPTION
29 25 -----------
@@ -35,21 +31,6 @@ COMMANDS
35 31
36 32 `migrate`::
37 33 Migrate ref store between different formats.
38 - +
39 - [WARNING]
40 - --
41 - The ref format migration has several known limitations in its current form:
42 -
43 - * It is not possible to migrate repositories that have worktrees.
44 -
45 - * There is no way to block concurrent writes to the repository during an
46 - ongoing migration. Concurrent writes can lead to an inconsistent migrated
47 - state. Users are expected to block writes on a higher level. If your
48 - repository is registered for scheduled maintenance, it is recommended to
49 - unregister it first with linkgit:git-maintenance[1].
50 -
51 - These limitations may eventually be lifted.
52 - --
53 34
54 35 `verify`::
55 36 Verify reference database consistency.
@@ -70,28 +51,6 @@ optimize::
70 51 usage. This subcommand is an alias for linkgit:git-pack-refs[1] and
71 52 offers identical functionality.
72 53
73 - create::
74 - Create the given reference, which must not already exist, pointing at
75 - `<new-value>`.
76 -
77 - delete::
78 - Delete the given reference. This subcommand mirrors `git update-ref -d`
79 - (see linkgit:git-update-ref[1]). When `<old-value>` is given, the
80 - reference is only deleted after verifying that it currently contains
81 - `<old-value>`.
82 -
83 - update::
84 - Update the given reference to point at `<new-value>`. If `<old-value>`
85 - is given, the reference is only updated after verifying that it
86 - currently contains `<old-value>`. As a special case, an all-zeroes
87 - `<new-value>` deletes the branch, whereas an all-zeroes `<old-value>`
88 - ensures that the branch does not yet exist.
89 -
90 - rename::
91 - Rename the reference `<oldref>` to `<newref>`. The old reference must
92 - exist and the new reference must not yet exist, and both must have a
93 - well-formed name (see linkgit:git-check-ref-format[1]).
94 -
95 54 OPTIONS
96 55 -------
97 56
@@ -131,19 +90,20 @@ The following options are specific to 'git refs optimize':
131 90
132 91 include::pack-refs-options.adoc[]
133 92
134 - The following options are specific to commands which write references:
93 + KNOWN LIMITATIONS
94 + -----------------
135 95
136 - `--create-reflog`::
137 - Create a reflog for the reference even if one would not ordinarily be
138 - created.
96 + The ref format migration has several known limitations in its current form:
139 97
140 - `--message=<reason>`::
141 - Use the given <reason> string for the reflog entry associated with the
142 - update. An empty message is rejected.
98 + * It is not possible to migrate repositories that have worktrees.
143 99
144 - `--no-deref`::
145 - Operate on <ref> itself rather than the reference it points to via a
146 - symbolic ref.
100 + * There is no way to block concurrent writes to the repository during an
101 + ongoing migration. Concurrent writes can lead to an inconsistent migrated
102 + state. Users are expected to block writes on a higher level. If your
103 + repository is registered for scheduled maintenance, it is recommended to
104 + unregister it first with git-maintenance(1).
105 +
106 + These limitations may eventually be lifted.
147 107
148 108 GIT
149 109 ---
modified Documentation/git-repack.adoc
@@ -11,8 +11,7 @@ SYNOPSIS
11 11 [verse]
12 12 'git repack' [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]
13 13 [--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]
14 - [--write-midx[=<mode>]] [--name-hash-version=<n>] [--path-walk]
15 - [--filter=<filter-spec>] [--drop-filtered [--dry-run]]
14 + [--write-midx] [--name-hash-version=<n>] [--path-walk]
16 15
17 16 DESCRIPTION
18 17 -----------
@@ -183,42 +182,6 @@ depth is 4095.
183 182 `objects` and `objects/info/alternates` sections of
184 183 linkgit:gitrepository-layout[5].
185 184
186 - --drop-filtered::
187 - Delete the local objects that match the `--filter` specification
188 - instead of keeping them in a separate packfile, reclaiming the
189 - disk space they occupy. This is intended for partial clones,
190 - where the filtered objects are promisor objects that remain
191 - recoverable from the promisor remote and are lazily re-fetched
192 - on demand when they are next needed.
193 - +
194 - Only large blobs are supported for now, so `--filter=blob:limit=<n>`
195 - is currently the only accepted filter. Because dropped objects must be
196 - recoverable, this option requires a promisor remote to be configured
197 - and refuses to run otherwise.
198 - +
199 - This option requires `-a`, and implies `-d`: the objects are dropped by
200 - rebuilding the promisor pack without them and then removing the now
201 - redundant old packs, so the redundant packs must be deleted for the
202 - space to actually be reclaimed. It is incompatible with `--filter-to`
203 - and with bitmap writing (`-b`/`--write-bitmap-index`), since filtering
204 - breaks the single-pack closure that bitmaps require. A bitmap setting
205 - coming from configuration is silently disabled for the duration of the
206 - command.
207 - +
208 - As a convenience, since dropped objects remain recoverable by lazy fetch,
209 - `--drop-filtered` refuses to run while another operation
210 - (merge, rebase, am, cherry-pick, revert, or bisect) is in progress, to
211 - avoid a surprising network fetch mid-operation, and refuses to drop any
212 - blob that the current index references, since such a blob would only be
213 - lazily re-fetched by the next command that inspects the working tree.
214 - These checks are skipped in bare repositories, which have neither a
215 - working tree nor an index.
216 -
217 - --dry-run::
218 - Only meaningful with `--drop-filtered`. List the objects that
219 - would be dropped, one object ID per line, without rebuilding any
220 - pack or deleting anything.
221 -
222 185 -b::
223 186 --write-bitmap-index::
224 187 Write a reachability bitmap index as part of the repack. This
@@ -287,47 +250,9 @@ pack as the preferred pack for object selection by the MIDX (see
287 250 linkgit:git-multi-pack-index[1]).
288 251
289 252 -m::
290 - --write-midx[=<mode>]::
253 + --write-midx::
291 254 Write a multi-pack index (see linkgit:git-multi-pack-index[1])
292 - containing the non-redundant packs. The following modes are
293 - available:
294 - +
295 - --
296 - `default`;;
297 - Write a single MIDX covering all packs. This is the
298 - default when `--write-midx` is given without an
299 - explicit mode.
300 -
301 - `incremental`;;
302 - Write an incremental MIDX chain instead of a single
303 - flat MIDX.
304 - +
305 - Without `--geometric`, a new MIDX layer is appended to the existing
306 - chain (or a new chain is started) containing whatever packs were written
307 - by the repack. Existing layers are preserved as-is.
308 - +
309 - When combined with `--geometric`, the incremental mode maintains a chain
310 - of MIDX layers that is compacted over time using a geometric merging
311 - strategy. Each repack creates a new tip layer containing the newly
312 - written pack(s). Adjacent layers are then merged whenever the newer
313 - layer's object count exceeds `1/repack.midxSplitFactor` of the next
314 - deeper layer's count. Layers that do not meet this condition are
315 - retained as-is.
316 - +
317 - The result is that newer (tip) layers tend to contain many small packs
318 - with relatively few objects, while older (deeper) layers contain fewer,
319 - larger packs covering more objects. Because compaction is driven by the
320 - tip of the chain, newer layers are also rewritten more frequently than
321 - older ones, which are only touched when enough objects have accumulated
322 - to justify merging into them. This keeps the total number of layers
323 - logarithmic relative to the total number of objects.
324 - +
325 - Only packs in the tip MIDX layer are considered as candidates for the
326 - geometric repack; packs in deeper layers are left untouched. If the tip
327 - layer contains fewer packs than `repack.midxNewLayerThreshold`, those
328 - packs are excluded from the geometry entirely, and a new layer is
329 - created for any new pack(s) without disturbing the existing chain.
330 - --
255 + containing the non-redundant packs.
331 256
332 257 --name-hash-version=<n>::
333 258 Provide this argument to the underlying `git pack-objects` process.
modified Documentation/git-replace.adoc
@@ -145,13 +145,6 @@ commit instead of the replaced commit.
145 145 There may be other problems when using 'git rev-list' related to
146 146 pending objects.
147 147
148 - CAVEATS
149 - -------
150 -
151 - The existence of replace objects or commit grafts turns off reading or
152 - writing to the commit-graph, which can cause performance issues. See
153 - linkgit:git-commit-graph[1].
154 -
155 148 SEE ALSO
156 149 --------
157 150 linkgit:git-hash-object[1]
modified Documentation/git-replay.adoc
@@ -80,13 +80,10 @@ incompatible with `--contained` (which is a modifier for `--onto` only).
80 80 Control how references are updated. The mode can be:
81 81 +
82 82 --
83 - ////
84 - Expanded description list compared to 'replay.refAction'.
85 - ////
86 - `update`;; (default) Update refs directly using an atomic transaction.
87 - All refs are updated or none are (all-or-nothing behavior).
88 - `print`;; Output update-ref commands for pipeline use. This is the
89 - traditional behavior where output can be piped to `git update-ref --stdin`.
83 + * `update` (default): Update refs directly using an atomic transaction.
84 + All refs are updated or none are (all-or-nothing behavior).
85 + * `print`: Output update-ref commands for pipeline use. This is the
86 + traditional behavior where output can be piped to `git update-ref --stdin`.
90 87 --
91 88 +
92 89 The default mode can be configured via the `replay.refAction` configuration variable.
@@ -212,11 +209,6 @@ This replays the range `aabbcc..ddeeff` onto commit `112233` and updates
212 209 `refs/heads/mybranch` to point at the result. This can be useful when you want
213 210 to use bare commit IDs instead of branch names.
214 211
215 - CONFIGURATION
216 - -------------
217 - :git-replay: 1
218 - include::config/replay.adoc[]
219 -
220 212 GIT
221 213 ---
222 214 Part of the linkgit:git[1] suite
modified Documentation/git-repo.adoc
@@ -104,21 +104,6 @@ values that they return:
104 104 `object.format`::
105 105 The object format (hash algorithm) used in the repository.
106 106
107 - `path.commondir.absolute`::
108 - The canonical absolute path to the Git repository's common
109 - directory (the shared `.git` directory containing objects,
110 - refs, and global configuration).
111 -
112 - `path.commondir.relative`::
113 - The path to the Git repository's common directory relative to
114 - the current working directory.
115 -
116 - `path.gitdir.absolute`::
117 - The canonical absolute path to the Git repository directory (the `.git` directory).
118 -
119 - `path.gitdir.relative`::
120 - The path to the Git repository directory relative to the current working directory.
121 -
122 107 `references.format`::
123 108 The reference storage format. The valid values are:
124 109 +
modified Documentation/git-request-pull.adoc
@@ -7,8 +7,8 @@ git-request-pull - Generates a summary of pending changes
7 7
8 8 SYNOPSIS
9 9 --------
10 - [synopsis]
11 - git request-pull [-p] <start> <URL> [<end>]
10 + [verse]
11 + 'git request-pull' [-p] <start> <URL> [<end>]
12 12
13 13 DESCRIPTION
14 14 -----------
@@ -19,28 +19,28 @@ begins with the branch description, summarizes
19 19 the changes, and indicates from where they can be pulled.
20 20
21 21 The upstream project is expected to have the commit named by
22 - _<start>_ and the output asks it to integrate the changes you made
23 - since that commit, up to the commit named by _<end>_, by visiting
24 - the repository named by _<URL>_.
22 + `<start>` and the output asks it to integrate the changes you made
23 + since that commit, up to the commit named by `<end>`, by visiting
24 + the repository named by `<URL>`.
25 25
26 26
27 27 OPTIONS
28 28 -------
29 - `-p`::
29 + -p::
30 30 Include patch text in the output.
31 31
32 - _<start>_::
32 + <start>::
33 33 Commit to start at. This names a commit that is already in
34 34 the upstream history.
35 35
36 - _<URL>_::
36 + <URL>::
37 37 The repository URL to be pulled from.
38 38
39 - _<end>_::
40 - Commit to end at (defaults to `HEAD`). This names the commit
39 + <end>::
40 + Commit to end at (defaults to HEAD). This names the commit
41 41 at the tip of the history you are asking to be pulled.
42 42 +
43 - When the repository named by _<URL>_ has the commit at a tip of a
43 + When the repository named by `<URL>` has the commit at a tip of a
44 44 ref that is different from the ref you have locally, you can use the
45 45 `<local>:<remote>` syntax, to have its local name, a colon `:`, and
46 46 its remote name.
@@ -54,15 +54,11 @@ the `v1.0` release, and want it to be integrated into the project.
54 54 First you push that change to your public repository for others to
55 55 see:
56 56
57 - ----
58 - git push https://git.ko.xz/project master
59 - ----
57 + git push https://git.ko.xz/project master
60 58
61 59 Then, you run this command:
62 60
63 - ----
64 - git request-pull v1.0 https://git.ko.xz/project master
65 - ----
61 + git request-pull v1.0 https://git.ko.xz/project master
66 62
67 63 which will produce a request to the upstream, summarizing the
68 64 changes between the `v1.0` release and your `master`, to pull it
@@ -71,15 +67,11 @@ from your public repository.
71 67 If you pushed your change to a branch whose name is different from
72 68 the one you have locally, e.g.
73 69
74 - ----
75 - git push https://git.ko.xz/project master:for-linus
76 - ----
70 + git push https://git.ko.xz/project master:for-linus
77 71
78 72 then you can ask that to be pulled with
79 73
80 - ----
81 - git request-pull v1.0 https://git.ko.xz/project master:for-linus
82 - ----
74 + git request-pull v1.0 https://git.ko.xz/project master:for-linus
83 75
84 76
85 77 GIT
modified Documentation/git-restore.adoc
@@ -41,7 +41,7 @@ given, otherwise from the index.
41 41 +
42 42 As a special case, you may use `"<rev-A>...<rev-B>"` as a shortcut for the
43 43 merge base of _<rev-A>_ and _<rev-B>_ if there is exactly one merge base. You can
44 - leave out at most one of _<rev-A>_ and _<rev-B>_, in which case it defaults to `HEAD`.
44 + leave out at most one of _<rev-A>__ and _<rev-B>_, in which case it defaults to `HEAD`.
45 45
46 46 `-p`::
47 47 `--patch`::
modified Documentation/git-send-email.adoc
@@ -8,11 +8,11 @@ git-send-email - Send a collection of patches as emails
8 8
9 9 SYNOPSIS
10 10 --------
11 - [synopsis]
12 - git send-email [<options>] (<file>|<directory>)...
13 - git send-email [<options>] <format-patch-options>
14 - git send-email --dump-aliases
15 - git send-email --translate-aliases
11 + [verse]
12 + 'git send-email' [<options>] (<file>|<directory>)...
13 + 'git send-email' [<options>] <format-patch-options>
14 + 'git send-email' --dump-aliases
15 + 'git send-email' --translate-aliases
16 16
17 17
18 18 DESCRIPTION
@@ -48,24 +48,24 @@ OPTIONS
48 48 Composing
49 49 ~~~~~~~~~
50 50
51 - `--annotate`::
51 + --annotate::
52 52 Review and edit each patch you're about to send. Default is the value
53 53 of `sendemail.annotate`. See the CONFIGURATION section for
54 54 `sendemail.multiEdit`.
55 55
56 - `--bcc=<address>,...`::
56 + --bcc=<address>,...::
57 57 Specify a `Bcc:` value for each email. Default is the value of
58 58 `sendemail.bcc`.
59 59 +
60 60 This option may be specified multiple times.
61 61
62 - `--cc=<address>,...`::
62 + --cc=<address>,...::
63 63 Specify a starting `Cc:` value for each email.
64 64 Default is the value of `sendemail.cc`.
65 65 +
66 66 This option may be specified multiple times.
67 67
68 - `--compose`::
68 + --compose::
69 69 Invoke a text editor (see GIT_EDITOR in linkgit:git-var[1])
70 70 to edit an introductory message for the patch series.
71 71 +
@@ -80,7 +80,7 @@ Missing `From` or `In-Reply-To` headers will be prompted for.
80 80 +
81 81 See the CONFIGURATION section for `sendemail.multiEdit`.
82 82
83 - `--from=<address>`::
83 + --from=<address>::
84 84 Specify the sender of the emails. If not specified on the command line,
85 85 the value of the `sendemail.from` configuration option is used. If
86 86 neither the command-line option nor `sendemail.from` are set, then the
@@ -88,12 +88,12 @@ See the CONFIGURATION section for `sendemail.multiEdit`.
88 88 the value of `GIT_AUTHOR_IDENT`, or `GIT_COMMITTER_IDENT` if that is not
89 89 set, as returned by `git var -l`.
90 90
91 - `--reply-to=<address>`::
91 + --reply-to=<address>::
92 92 Specify the address where replies from recipients should go to.
93 93 Use this if replies to messages should go to another address than what
94 94 is specified with the `--from` parameter.
95 95
96 - `--in-reply-to=<identifier>`::
96 + --in-reply-to=<identifier>::
97 97 Make the first mail (or all the mails with `--no-thread`) appear as a
98 98 reply to the given Message-ID, which avoids breaking threads to
99 99 provide a new patch series.
@@ -115,8 +115,8 @@ illustration below where `[PATCH v2 0/3]` is in reply to `[PATCH 0/2]`:
115 115 Only necessary if `--compose` is also set. If `--compose`
116 116 is not set, this will be prompted for.
117 117
118 - `--outlook-id-fix`::
119 - `--no-outlook-id-fix`::
118 + --outlook-id-fix::
119 + --no-outlook-id-fix::
120 120 Microsoft Outlook SMTP servers discard the Message-ID sent via email and
121 121 assign a new random Message-ID, thus breaking threads.
122 122 +
@@ -126,15 +126,15 @@ threading. Use it only when you know that the server reports the
126 126 rewritten Message-ID the same way as Outlook servers do.
127 127 +
128 128 Without this option specified, the fix is done by default when talking
129 - to `smtp.office365.com` or `smtp-mail.outlook.com`. Use
129 + to 'smtp.office365.com' or 'smtp-mail.outlook.com'. Use
130 130 `--no-outlook-id-fix` to disable even when talking to these two servers.
131 131
132 - `--subject=<string>`::
132 + --subject=<string>::
133 133 Specify the initial subject of the email thread.
134 134 Only necessary if `--compose` is also set. If `--compose`
135 135 is not set, this will be prompted for.
136 136
137 - `--to=<address>,...`::
137 + --to=<address>,...::
138 138 Specify the primary recipient of the emails generated. Generally, this
139 139 will be the upstream maintainer of the project involved. Default is the
140 140 value of the `sendemail.to` configuration value; if that is unspecified,
@@ -142,20 +142,20 @@ to `smtp.office365.com` or `smtp-mail.outlook.com`. Use
142 142 +
143 143 This option may be specified multiple times.
144 144
145 - `--8bit-encoding=<encoding>`::
145 + --8bit-encoding=<encoding>::
146 146 When encountering a non-ASCII message or subject that does not
147 147 declare its encoding, add headers/quoting to indicate it is
148 - encoded in _<encoding>_. Default is the value of the
148 + encoded in <encoding>. Default is the value of the
149 149 `sendemail.assume8bitEncoding`; if that is unspecified, this
150 150 will be prompted for if any non-ASCII files are encountered.
151 151 +
152 152 Note that no attempts whatsoever are made to validate the encoding.
153 153
154 - `--compose-encoding=<encoding>`::
154 + --compose-encoding=<encoding>::
155 155 Specify encoding of compose message. Default is the value of the
156 156 `sendemail.composeEncoding`; if that is unspecified, UTF-8 is assumed.
157 157
158 - `--transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)`::
158 + --transfer-encoding=(7bit|8bit|quoted-printable|base64|auto)::
159 159 Specify the transfer encoding to be used to send the message over SMTP.
160 160 `7bit` will fail upon encountering a non-ASCII message. `quoted-printable`
161 161 can be useful when the repository contains files that contain carriage
@@ -167,8 +167,8 @@ Note that no attempts whatsoever are made to validate the encoding.
167 167 Default is the value of the `sendemail.transferEncoding` configuration
168 168 value; if that is unspecified, default to `auto`.
169 169
170 - `--xmailer`::
171 - `--no-xmailer`::
170 + --xmailer::
171 + --no-xmailer::
172 172 Add (or prevent adding) the `X-Mailer:` header. By default,
173 173 the header is added, but it can be turned off by setting the
174 174 `sendemail.xmailer` configuration variable to `false`.
@@ -176,7 +176,7 @@ value; if that is unspecified, default to `auto`.
176 176 Sending
177 177 ~~~~~~~
178 178
179 - `--envelope-sender=<address>`::
179 + --envelope-sender=<address>::
180 180 Specify the envelope sender used to send the emails.
181 181 This is useful if your default address is not the address that is
182 182 subscribed to a list. In order to use the `From` address, set the
@@ -185,7 +185,7 @@ Sending
185 185 `sendemail.envelopeSender` configuration variable; if that is
186 186 unspecified, choosing the envelope sender is left to your MTA.
187 187
188 - `--sendmail-cmd=<command>`::
188 + --sendmail-cmd=<command>::
189 189 Specify a command to run to send the email. The command should
190 190 be sendmail-like; specifically, it must support the `-i` option.
191 191 The command will be executed in the shell if necessary. Default
@@ -193,7 +193,7 @@ Sending
193 193 `--smtp-server` is also unspecified, `git send-email` will search
194 194 for `sendmail` in `/usr/sbin`, `/usr/lib` and `$PATH`.
195 195
196 - `--smtp-encryption=<encryption>`::
196 + --smtp-encryption=<encryption>::
197 197 Specify in what way encrypting begins for the SMTP connection.
198 198 Valid values are `ssl` and `tls`. Any other value reverts to plain
199 199 (unencrypted) SMTP, which defaults to port 25.
@@ -207,14 +207,14 @@ Sending
207 207 documentation or your server configuration to make sure
208 208 for your own case. Default is the value of `sendemail.smtpEncryption`.
209 209
210 - `--smtp-domain=<FQDN>`::
210 + --smtp-domain=<FQDN>::
211 211 Specify the Fully Qualified Domain Name (FQDN) used in the
212 212 HELO/EHLO command to the SMTP server. Some servers require the
213 213 FQDN to match your IP address. If not set, `git send-email` attempts
214 214 to determine your FQDN automatically. Default is the value of
215 215 `sendemail.smtpDomain`.
216 216
217 - `--smtp-auth=<mechanisms>`::
217 + --smtp-auth=<mechanisms>::
218 218 Whitespace-separated list of allowed SMTP-AUTH mechanisms. This setting
219 219 forces using only the listed mechanisms. Example:
220 220 +
@@ -229,7 +229,7 @@ is specified, all mechanisms supported by the SASL library can be used. The
229 229 special value `none` maybe specified to completely disable authentication
230 230 independently of `--smtp-user`.
231 231
232 - `--smtp-pass[=<password>]`::
232 + --smtp-pass[=<password>]::
233 233 Password for SMTP-AUTH. The argument is optional: If no
234 234 argument is specified, then the empty string is used as
235 235 the password. Default is the value of `sendemail.smtpPass`,
@@ -241,10 +241,10 @@ or on the command line. If a username has been specified (with
241 241 specified (with `--smtp-pass` or `sendemail.smtpPass`), then
242 242 a password is obtained using linkgit:git-credential[1].
243 243
244 - `--no-smtp-auth`::
244 + --no-smtp-auth::
245 245 Disable SMTP authentication. Short hand for `--smtp-auth=none`.
246 246
247 - `--smtp-server=<host>`::
247 + --smtp-server=<host>::
248 248 Specify the outgoing SMTP server to use (e.g.
249 249 `smtp.example.com` or a raw IP address). If unspecified, and if
250 250 `--sendmail-cmd` is also unspecified, the default is to search
@@ -257,7 +257,7 @@ option. This method does not support passing arguments or using plain
257 257 command names. For those use cases, consider using `--sendmail-cmd`
258 258 instead.
259 259
260 - `--smtp-server-port=<port>`::
260 + --smtp-server-port=<port>::
261 261 Specify a port different from the default port (SMTP
262 262 servers typically listen to smtp port 25, but may also listen to
263 263 submission port 587, or the common SSL smtp port 465);
@@ -265,7 +265,7 @@ instead.
265 265 are also accepted. The port can also be set with the
266 266 `sendemail.smtpServerPort` configuration variable.
267 267
268 - `--smtp-server-option=<option>`::
268 + --smtp-server-option=<option>::
269 269 Specify the outgoing SMTP server option to use.
270 270 Default value can be specified by the `sendemail.smtpServerOption`
271 271 configuration option.
@@ -274,15 +274,15 @@ The `--smtp-server-option` option must be repeated for each option you want
274 274 to pass to the server. Likewise, different lines in the configuration files
275 275 must be used for each option.
276 276
277 - `--smtp-ssl`::
277 + --smtp-ssl::
278 278 Legacy alias for `--smtp-encryption ssl`.
279 279
280 - `--smtp-ssl-cert-path <path>`::
280 + --smtp-ssl-cert-path <path>::
281 281 Path to a store of trusted CA certificates for SMTP SSL/TLS
282 282 certificate validation (either a directory that has been processed
283 283 by `c_rehash`, or a single file containing one or more PEM format
284 284 certificates concatenated together: see the description of the
285 - `-CAfile <file>` and the `-CApath <dir>` options of
285 + `-CAfile` _<file>_ and the `-CApath` _<dir>_ options of
286 286 https://docs.openssl.org/master/man1/openssl-verify/
287 287 [OpenSSL's verify(1) manual page] for more information on these).
288 288 Set it to an empty string to disable certificate verification.
@@ -290,7 +290,7 @@ must be used for each option.
290 290 variable, if set, or the backing SSL library's compiled-in default
291 291 otherwise (which should be the best choice on most platforms).
292 292
293 - `--smtp-ssl-client-cert <path>`::
293 + --smtp-ssl-client-cert <path>::
294 294 Path to the client certificate file to present if requested by the
295 295 server. This option is required when the server is set up to verify
296 296 client certificates. If the corresponding private key is not included in
@@ -299,7 +299,7 @@ must be used for each option.
299 299 to the value of the `sendemail.smtpSSLClientCert` configuration
300 300 variable, if set.
301 301
302 - `--smtp-ssl-client-key <path>`::
302 + --smtp-ssl-client-key <path>::
303 303 Path to the client private key file that corresponds to the client
304 304 certificate. To avoid misconfiguration, this option must be used in
305 305 conjunction with the `sendemail.smtpSSLClientKey` configuration variable
@@ -309,17 +309,17 @@ must be used for each option.
309 309 more details. Defaults to the value of the `sendemail.smtpSSLClientKey`
310 310 configuration variable, if set.
311 311
312 - `--smtp-user=<user>`::
312 + --smtp-user=<user>::
313 313 Username for SMTP-AUTH. Default is the value of `sendemail.smtpUser`;
314 314 if a username is not specified (with `--smtp-user` or `sendemail.smtpUser`),
315 315 then authentication is not attempted.
316 316
317 - `--smtp-debug=(0|1)`::
317 + --smtp-debug=(0|1)::
318 318 Enable (1) or disable (0) debug output. If enabled, SMTP
319 319 commands and replies will be printed. Useful to debug TLS
320 320 connection and authentication problems.
321 321
322 - `--imap-sent-folder=<folder>`::
322 + --imap-sent-folder=<folder>::
323 323 Some email providers (e.g. iCloud) do not send a copy of the emails sent
324 324 using SMTP to the `Sent` folder or similar in your mailbox. Use this option
325 325 to use `git imap-send` to send a copy of the emails to the folder specified
@@ -331,8 +331,8 @@ must be used for each option.
331 331 This feature requires setting up `git imap-send`. See linkgit:git-imap-send[1]
332 332 for instructions.
333 333
334 - `--use-imap-only`::
335 - `--no-use-imap-only`::
334 + --use-imap-only::
335 + --no-use-imap-only::
336 336 If this is set, all emails will only be copied to the IMAP folder specified
337 337 with `--imap-sent-folder` or `sendemail.imapSentFolder` and will not be sent
338 338 to the recipients. Useful if you just want to create a draft of the emails
@@ -344,8 +344,8 @@ for instructions.
344 344 This feature requires setting up `git imap-send`. See linkgit:git-imap-send[1]
345 345 for instructions.
346 346
347 - `--batch-size=<num>`::
348 - Some email servers (e.g. `smtp.163.com`) limit the number of emails to be
347 + --batch-size=<num>::
348 + Some email servers (e.g. 'smtp.163.com') limit the number of emails to be
349 349 sent per session (connection) and this will lead to a failure when
350 350 sending many messages. With this option, send-email will disconnect after
351 351 sending _<num>_ messages and wait for a few seconds
@@ -354,7 +354,7 @@ for instructions.
354 354 retype your password every time this happens. Defaults to the
355 355 `sendemail.smtpBatchSize` configuration variable.
356 356
357 - `--relogin-delay=<int>`::
357 + --relogin-delay=<int>::
358 358 Waiting _<int>_ seconds before reconnecting to SMTP server. Used together
359 359 with `--batch-size` option. Defaults to the `sendemail.smtpReloginDelay`
360 360 configuration variable.
@@ -362,29 +362,29 @@ for instructions.
362 362 Automating
363 363 ~~~~~~~~~~
364 364
365 - `--no-to`::
366 - `--no-cc`::
367 - `--no-bcc`::
365 + --no-to::
366 + --no-cc::
367 + --no-bcc::
368 368 Clear any list of `To:`, `Cc:`, `Bcc:` addresses previously
369 369 set via config.
370 370
371 - `--no-identity`::
371 + --no-identity::
372 372 Clear the previously read value of `sendemail.identity` set
373 373 via config, if any.
374 374
375 - `--to-cmd=<command>`::
375 + --to-cmd=<command>::
376 376 Specify a command to execute once per patch file which
377 377 should generate patch file specific `To:` entries.
378 378 Output of this command must be single email address per line.
379 379 Default is the value of `sendemail.toCmd` configuration value.
380 380
381 - `--cc-cmd=<command>`::
381 + --cc-cmd=<command>::
382 382 Specify a command to execute once per patch file which
383 383 should generate patch file specific `Cc:` entries.
384 384 Output of this command must be single email address per line.
385 385 Default is the value of `sendemail.ccCmd` configuration value.
386 386
387 - `--header-cmd=<command>`::
387 + --header-cmd=<command>::
388 388 Specify a command that is executed once per outgoing message
389 389 and output RFC 2822 style header lines to be inserted into
390 390 them. When the `sendemail.headerCmd` configuration variable is
@@ -392,11 +392,11 @@ Automating
392 392 at the command line, its value takes precedence over the
393 393 `sendemail.headerCmd` configuration variable.
394 394
395 - `--no-header-cmd`::
395 + --no-header-cmd::
396 396 Disable any header command in use.
397 397
398 - `--chain-reply-to`::
399 - `--no-chain-reply-to`::
398 + --chain-reply-to::
399 + --no-chain-reply-to::
400 400 If this is set, each email will be sent as a reply to the previous
401 401 email sent. If disabled with `--no-chain-reply-to`, all emails after
402 402 the first will be sent as replies to the first email sent. When using
@@ -404,34 +404,34 @@ Automating
404 404 entire patch series. Disabled by default, but the `sendemail.chainReplyTo`
405 405 configuration variable can be used to enable it.
406 406
407 - `--identity=<identity>`::
407 + --identity=<identity>::
408 408 A configuration identity. When given, causes values in the
409 409 `sendemail.<identity>` subsection to take precedence over
410 410 values in the `sendemail` section. The default identity is
411 411 the value of `sendemail.identity`.
412 412
413 - `--signed-off-by-cc`::
414 - `--no-signed-off-by-cc`::
413 + --signed-off-by-cc::
414 + --no-signed-off-by-cc::
415 415 If this is set, add emails found in the `Signed-off-by` trailer or `Cc:`
416 416 lines to the cc list. Default is the value of `sendemail.signedOffByCc`
417 417 configuration value; if that is unspecified, default to
418 418 `--signed-off-by-cc`.
419 419
420 - `--cc-cover`::
421 - `--no-cc-cover`::
420 + --cc-cover::
421 + --no-cc-cover::
422 422 If this is set, emails found in `Cc:` headers in the first patch of
423 423 the series (typically the cover letter) are added to the cc list
424 424 for each email set. Default is the value of `sendemail.ccCover`
425 425 configuration value; if that is unspecified, default to `--no-cc-cover`.
426 426
427 - `--to-cover`::
428 - `--no-to-cover`::
427 + --to-cover::
428 + --no-to-cover::
429 429 If this is set, emails found in `To:` headers in the first patch of
430 430 the series (typically the cover letter) are added to the to list
431 431 for each email set. Default is the value of `sendemail.toCover`
432 432 configuration value; if that is unspecified, default to `--no-to-cover`.
433 433
434 - `--suppress-cc=<category>`::
434 + --suppress-cc=<category>::
435 435 Specify an additional category of recipients to suppress the
436 436 auto-cc of:
437 437 +
@@ -456,14 +456,14 @@ Default is the value of `sendemail.suppressCc` configuration value; if
456 456 that is unspecified, default to `self` if `--suppress-from` is
457 457 specified, as well as `body` if `--no-signed-off-by-cc` is specified.
458 458
459 - `--suppress-from`::
460 - `--no-suppress-from`::
459 + --suppress-from::
460 + --no-suppress-from::
461 461 If this is set, do not add the `From:` address to the `Cc:` list.
462 462 Default is the value of `sendemail.suppressFrom` configuration
463 463 value; if that is unspecified, default to `--no-suppress-from`.
464 464
465 - `--thread`::
466 - `--no-thread`::
465 + --thread::
466 + --no-thread::
467 467 If this is set, the `In-Reply-To` and `References` headers will be
468 468 added to each email sent. Whether each mail refers to the
469 469 previous email (`deep` threading per `git format-patch`
@@ -481,8 +481,8 @@ exists when `git send-email` is asked to add it (especially note that
481 481 Failure to do so may not produce the expected result in the
482 482 recipient's MUA.
483 483
484 - `--mailmap`::
485 - `--no-mailmap`::
484 + --mailmap::
485 + --no-mailmap::
486 486 Use the mailmap file (see linkgit:gitmailmap[5]) to map all
487 487 addresses to their canonical real name and email address. Additional
488 488 mailmap data specific to `git send-email` may be provided using the
@@ -492,7 +492,7 @@ recipient's MUA.
492 492 Administering
493 493 ~~~~~~~~~~~~~
494 494
495 - `--confirm=<mode>`::
495 + --confirm=<mode>::
496 496 Confirm just before sending:
497 497 +
498 498 --
@@ -508,22 +508,22 @@ Default is the value of `sendemail.confirm` configuration value; if that
508 508 is unspecified, default to `auto` unless any of the suppress options
509 509 have been specified, in which case default to `compose`.
510 510
511 - `--dry-run`::
511 + --dry-run::
512 512 Do everything except actually send the emails.
513 513
514 - `--format-patch`::
515 - `--no-format-patch`::
514 + --format-patch::
515 + --no-format-patch::
516 516 When an argument may be understood either as a reference or as a file name,
517 517 choose to understand it as a format-patch argument (`--format-patch`)
518 518 or as a file name (`--no-format-patch`). By default, when such a conflict
519 519 occurs, `git send-email` will fail.
520 520
521 - `--quiet`::
521 + --quiet::
522 522 Make `git send-email` less verbose. One line per email should be
523 523 all that is output.
524 524
525 - `--validate`::
526 - `--no-validate`::
525 + --validate::
526 + --no-validate::
527 527 Perform sanity checks on patches.
528 528 Currently, validation means the following:
529 529 +
@@ -539,20 +539,20 @@ have been specified, in which case default to `compose`.
539 539 Default is the value of `sendemail.validate`; if this is not set,
540 540 default to `--validate`.
541 541
542 - `--force`::
542 + --force::
543 543 Send emails even if safety checks would prevent it.
544 544
545 545
546 546 Information
547 547 ~~~~~~~~~~~
548 548
549 - `--dump-aliases`::
549 + --dump-aliases::
550 550 Instead of the normal operation, dump the shorthand alias names from
551 551 the configured alias file(s), one per line in alphabetical order. Note
552 552 that this only includes the alias name and not its expanded email addresses.
553 553 See `sendemail.aliasesFile` for more information about aliases.
554 554
555 - `--translate-aliases`::
555 + --translate-aliases::
556 556 Instead of the normal operation, read from standard input and
557 557 interpret each line as an email alias. Translate it according to the
558 558 configured alias file(s). Output each translated name and email
@@ -718,7 +718,7 @@ include::format-patch-caveats.adoc[]
718 718
719 719 SEE ALSO
720 720 --------
721 - linkgit:git-format-patch[1], linkgit:git-imap-send[1], `mbox`(5)
721 + linkgit:git-format-patch[1], linkgit:git-imap-send[1], mbox(5)
722 722
723 723 GIT
724 724 ---
modified Documentation/git-shortlog.adoc
@@ -3,63 +3,63 @@ git-shortlog(1)
3 3
4 4 NAME
5 5 ----
6 - git-shortlog - Summarize `git log` output
6 + git-shortlog - Summarize 'git log' output
7 7
8 8 SYNOPSIS
9 9 --------
10 - [synopsis]
11 - git shortlog [<options>] [<revision-range>] [[--] <path>...]
12 - git log --pretty=short | git shortlog [<options>]
10 + [verse]
11 + 'git shortlog' [<options>] [<revision-range>] [[--] <path>...]
12 + git log --pretty=short | 'git shortlog' [<options>]
13 13
14 14 DESCRIPTION
15 15 -----------
16 - Summarizes `git log` output in a format suitable for inclusion
16 + Summarizes 'git log' output in a format suitable for inclusion
17 17 in release announcements. Each commit will be grouped by author and title.
18 18
19 19 Additionally, "[PATCH]" will be stripped from the commit description.
20 20
21 21 If no revisions are passed on the command line and either standard input
22 - is not a terminal or there is no current branch, `git shortlog` will
22 + is not a terminal or there is no current branch, 'git shortlog' will
23 23 output a summary of the log read from standard input, without
24 24 reference to the current repository.
25 25
26 26 OPTIONS
27 27 -------
28 28
29 - `-n`::
30 - `--numbered`::
29 + -n::
30 + --numbered::
31 31 Sort output according to the number of commits per author instead
32 32 of author alphabetic order.
33 33
34 - `-s`::
35 - `--summary`::
34 + -s::
35 + --summary::
36 36 Suppress commit description and provide a commit count summary only.
37 37
38 - `-e`::
39 - `--email`::
38 + -e::
39 + --email::
40 40 Show the email address of each author.
41 41
42 - `--format[=<format>]`::
42 + --format[=<format>]::
43 43 Instead of the commit subject, use some other information to
44 - describe each commit. _<format>_ can be any string accepted
45 - by the `--format` option of `git log`, such as '* [%h] %s'.
46 - (See the 'PRETTY FORMATS' section of linkgit:git-log[1].)
44 + describe each commit. '<format>' can be any string accepted
45 + by the `--format` option of 'git log', such as '* [%h] %s'.
46 + (See the "PRETTY FORMATS" section of linkgit:git-log[1].)
47 47 +
48 48 Each pretty-printed commit will be rewrapped before it is shown.
49 49
50 - `--date=<format>`::
50 + --date=<format>::
51 51 Show dates formatted according to the given date string. (See
52 - the `--date` option in the 'Commit Formatting' section of
52 + the `--date` option in the "Commit Formatting" section of
53 53 linkgit:git-log[1]). Useful with `--group=format:<format>`.
54 54
55 - `--group=<type>`::
56 - Group commits based on _<type>_. If no `--group` option is
57 - specified, the default is `author`. _<type>_ is one of:
55 + --group=<type>::
56 + Group commits based on `<type>`. If no `--group` option is
57 + specified, the default is `author`. `<type>` is one of:
58 58 +
59 59 --
60 60 - `author`, commits are grouped by author
61 61 - `committer`, commits are grouped by committer (the same as `-c`)
62 - - `trailer:<field>`, the _<field>_ is interpreted as a case-insensitive
62 + - `trailer:<field>`, the `<field>` is interpreted as a case-insensitive
63 63 commit message trailer (see linkgit:git-interpret-trailers[1]). For
64 64 example, if your project uses `Reviewed-by` trailers, you might want
65 65 to see who has been reviewing with
@@ -76,7 +76,7 @@ unless the `--email` option is specified. If the value cannot be parsed
76 76 as an identity, it will be taken literally and completely.
77 77
78 78 - `format:<format>`, any string accepted by the `--format` option of
79 - `git log`. (See the 'PRETTY FORMATS' section of
79 + 'git log'. (See the "PRETTY FORMATS" section of
80 80 linkgit:git-log[1].)
81 81 --
82 82 +
@@ -85,11 +85,11 @@ value (but again, only once per unique value in that commit). For
85 85 example, `git shortlog --group=author --group=trailer:co-authored-by`
86 86 counts both authors and co-authors.
87 87
88 - `-c`::
89 - `--committer`::
88 + -c::
89 + --committer::
90 90 This is an alias for `--group=committer`.
91 91
92 - `-w[<width>[,<indent1>[,<indent2>]]]`::
92 + -w[<width>[,<indent1>[,<indent2>]]]::
93 93 Linewrap the output by wrapping each line at `width`. The first
94 94 line of each entry is indented by `indent1` spaces, and the second
95 95 and subsequent lines are indented by `indent2` spaces. `width`,
@@ -98,16 +98,16 @@ counts both authors and co-authors.
98 98 If width is `0` (zero) then indent the lines of the output without wrapping
99 99 them.
100 100
101 - `<revision-range>`::
101 + <revision-range>::
102 102 Show only commits in the specified revision range. When no
103 - _<revision-range>_ is specified, it defaults to `HEAD` (i.e. the
103 + <revision-range> is specified, it defaults to `HEAD` (i.e. the
104 104 whole history leading to the current commit). `origin..HEAD`
105 105 specifies all the commits reachable from the current commit
106 106 (i.e. `HEAD`), but not from `origin`. For a complete list of
107 - ways to spell _<revision-range>_, see the 'Specifying Ranges'
107 + ways to spell <revision-range>, see the "Specifying Ranges"
108 108 section of linkgit:gitrevisions[7].
109 109
110 - `[--] <path>...`::
110 + [--] <path>...::
111 111 Consider only commits that are enough to explain how the files
112 112 that match the specified paths came to be.
113 113 +
modified Documentation/git-sparse-checkout.adoc
@@ -134,7 +134,7 @@ the `clean.requireForce` config option is set to `false`.
134 134 +
135 135 The `--dry-run` option will list the directories that would be removed
136 136 without deleting them. Running in this mode can be helpful to predict the
137 - behavior of the clean command or to determine which kinds of files are left
137 + behavior of the clean comand or to determine which kinds of files are left
138 138 in the sparse directories.
139 139 +
140 140 The `--verbose` option will list every file within the directories that
modified Documentation/git-stash.adoc
@@ -12,7 +12,7 @@ git stash list [<log-options>]
12 12 git stash show [-u | --include-untracked | --only-untracked] [<diff-options>] [<stash>]
13 13 git stash drop [-q | --quiet] [<stash>]
14 14 git stash pop [--index] [-q | --quiet] [<stash>]
15 - git stash apply [--index] [-q | --quiet] [--label-ours=<label>] [--label-theirs=<label>] [--label-base=<label>] [<stash>]
15 + git stash apply [--index] [-q | --quiet] [<stash>]
16 16 git stash branch <branchname> [<stash>]
17 17 git stash [push] [-p | --patch] [-S | --staged] [-k | --[no-]keep-index] [-q | --quiet]
18 18 [-u | --include-untracked] [-a | --all] [(-m | --message) <message>]
@@ -195,15 +195,6 @@ the index's ones. However, this can fail, when you have conflicts
195 195 (which are stored in the index, where you therefore can no longer
196 196 apply the changes as they were originally).
197 197
198 - `--label-ours=<label>`::
199 - `--label-theirs=<label>`::
200 - `--label-base=<label>`::
201 - These options are only valid for the `apply` command.
202 - +
203 - Use the given labels in conflict markers instead of the default
204 - "Updated upstream", "Stashed changes", and "Stash base".
205 - `--label-base` only has an effect with merge.conflictStyle=diff3.
206 -
207 198 `-k`::
208 199 `--keep-index`::
209 200 `--no-keep-index`::
modified Documentation/git-svn.adoc
@@ -439,7 +439,7 @@ Any other arguments are passed directly to 'git log'
439 439 'show-ignore'::
440 440 Recursively finds and lists the svn:ignore and svn:global-ignores
441 441 properties on directories. The output is suitable for appending to
442 - the $GIT_COMMON_DIR/info/exclude file.
442 + the $GIT_DIR/info/exclude file.
443 443
444 444 'mkdirs'::
445 445 Attempts to recreate empty directories that core Git cannot track
modified Documentation/git-switch.adoc
@@ -123,19 +123,18 @@ variable.
123 123
124 124 `-m`::
125 125 `--merge`::
126 - If you have local modifications to one or more files that
127 - are different between the current branch and the branch to
128 - which you are switching, the command normally refuses to
129 - switch branches in order to preserve your modifications in
130 - context. However, with this option, the conflicting local
131 - changes are automatically stashed before the switch and
132 - reapplied afterwards. If the local changes do not overlap
133 - with the differences between branches, the switch proceeds
134 - without stashing. If reapplying the stash results in
135 - conflicts, the entry is saved to the stash list. Resolve
136 - the conflicts and run `git stash drop` when done, or clear
137 - the working tree (e.g. with `git reset --hard`) before
138 - running `git stash pop` later to re-apply your changes.
126 + If you have local modifications to one or more files that are
127 + different between the current branch and the branch to which
128 + you are switching, the command refuses to switch branches in
129 + order to preserve your modifications in context. However,
130 + with this option, a three-way merge between the current
131 + branch, your working tree contents, and the new branch is
132 + done, and you will be on the new branch.
133 + +
134 + When a merge conflict happens, the index entries for conflicting
135 + paths are left unmerged, and you need to resolve the conflicts
136 + and mark the resolved paths with `git add` (or `git rm` if the merge
137 + should result in deletion of the path).
139 138
140 139 `--conflict=<style>`::
141 140 The same as `--merge` option above, but changes the way the
@@ -218,18 +217,15 @@ $ git switch mytopic
218 217 error: You have local changes to 'frotz'; not switching branches.
219 218 ------------
220 219
221 - You can give the `-m` flag to the command, which will carry your local
222 - changes to the new branch:
220 + You can give the `-m` flag to the command, which would try a three-way
221 + merge:
223 222
224 223 ------------
225 224 $ git switch -m mytopic
226 - Applied autostash.
227 - Switched to branch 'mytopic'
228 - The following paths have local changes:
229 - M frotz
225 + Auto-merging frotz
230 226 ------------
231 227
232 - After the switch, the local modifications are reapplied and are _not_
228 + After this three-way merge, the local modifications are _not_
233 229 registered in your index file, so `git diff` would show you what
234 230 changes you made since the tip of the new branch.
235 231
deleted Documentation/git-url-parse.adoc mode 100644
@@ -1,80 +0,0 @@
1 - git-url-parse(1)
2 - ================
3 -
4 - NAME
5 - ----
6 - git-url-parse - Parse and extract git URL components
7 -
8 - SYNOPSIS
9 - --------
10 - [synopsis]
11 - git url-parse [-c <component>] [--] <url>...
12 -
13 - DESCRIPTION
14 - -----------
15 -
16 - Git supports many ways to specify URLs, some of them non-standard.
17 - For example, git supports the scp style [user@]host:[path] format.
18 - This command eases interoperability with git URLs by enabling the
19 - parsing and extraction of the components of all git URLs.
20 -
21 - Any syntactically valid URL is parsed, even if the scheme is not one
22 - git supports for fetching or pushing.
23 -
24 - OPTIONS
25 - -------
26 -
27 - `-c <component>`::
28 - `--component <component>`::
29 - Extract the _<component>_ component from the given Git URLs.
30 - _<component>_ can be one of:
31 - `scheme`, `user`, `password`, `host`, `port`, `path`.
32 -
33 - OUTPUT
34 - ------
35 -
36 - When `--component` is given, the requested component of each URL
37 - is printed on its own line, in the order the URLs were given. If
38 - the URL has no such component (for example, a port in a URL that
39 - does not specify one), an empty line is printed in its place.
40 -
41 - When `--component` is not given, no output is produced. The exit
42 - status is zero if every URL parses successfully and non-zero
43 - otherwise, allowing the command to be used purely as a validator.
44 -
45 - EXAMPLES
46 - --------
47 -
48 - * Print the host name:
49 - +
50 - ------------
51 - $ git url-parse --component host https://example.com/user/repo
52 - example.com
53 - ------------
54 -
55 - * Print the path:
56 - +
57 - ------------
58 - $ git url-parse --component path https://example.com/user/repo
59 - /user/repo
60 - $ git url-parse --component path example.com:~user/repo
61 - ~user/repo
62 - $ git url-parse --component path example.com:user/repo
63 - /user/repo
64 - ------------
65 -
66 - * Validate URLs without outputting anything:
67 - +
68 - ------------
69 - $ git url-parse https://example.com/user/repo example.com:~user/repo
70 - ------------
71 -
72 - SEE ALSO
73 - --------
74 - linkgit:git-clone[1],
75 - linkgit:git-fetch[1],
76 - linkgit:git-config[1]
77 -
78 - GIT
79 - ---
80 - Part of the linkgit:git[1] suite
modified Documentation/git-worktree.adoc
@@ -219,9 +219,7 @@ To remove a locked worktree, specify `--force` twice.
219 219 of creating a new branch from `HEAD`, if there exists a tracking
220 220 branch in exactly one remote matching the basename of _<path>_,
221 221 base the new branch on the remote-tracking branch, and mark
222 - the remote-tracking branch as "upstream" from the new branch. If
223 - there are multiple matches, the command fails. If there is no
224 - match, the command falls back to creating a new branch from `HEAD`.
222 + the remote-tracking branch as "upstream" from the new branch.
225 223 +
226 224 This can also be set up as the default behaviour by using the
227 225 `worktree.guessRemote` config option.
modified Documentation/gitattributes.adoc
@@ -911,10 +911,7 @@ patterns are available:
911 911
912 912 - `rust` suitable for source code in the Rust language.
913 913
914 - - `scheme` suitable for source code in most Lisp dialects,
915 - including Scheme, Emacs Lisp, Common Lisp, and Clojure.
916 -
917 - - `swift` suitable for source code in the Swift language.
914 + - `scheme` suitable for source code in the Scheme language.
918 915
919 916 - `tex` suitable for source code for LaTeX documents.
920 917
modified Documentation/gitformat-index.adoc
@@ -291,14 +291,14 @@ Git index format
291 291 sequence in variable width encoding. Each string describes the
292 292 environment where the cache can be used.
293 293
294 - - Stat data of $GIT_COMMON_DIR/info/exclude. See "Index entry" section from
294 + - Stat data of $GIT_DIR/info/exclude. See "Index entry" section from
295 295 ctime field until "file size".
296 296
297 297 - Stat data of core.excludesFile
298 298
299 299 - 32-bit dir_flags (see struct dir_struct)
300 300
301 - - Hash of $GIT_COMMON_DIR/info/exclude. A null hash means the file
301 + - Hash of $GIT_DIR/info/exclude. A null hash means the file
302 302 does not exist.
303 303
304 304 - Hash of core.excludesFile. A null hash means the file does
modified Documentation/gitignore.adoc
@@ -7,7 +7,7 @@ gitignore - Specifies intentionally untracked files to ignore
7 7
8 8 SYNOPSIS
9 9 --------
10 - $XDG_CONFIG_HOME/git/ignore, $GIT_COMMON_DIR/info/exclude, .gitignore
10 + $XDG_CONFIG_HOME/git/ignore, $GIT_DIR/info/exclude, .gitignore
11 11
12 12 DESCRIPTION
13 13 -----------
@@ -34,7 +34,7 @@ precedence, the last matching pattern decides the outcome):
34 34 includes such `.gitignore` files in its repository, containing patterns for
35 35 files generated as part of the project build.
36 36
37 - * Patterns read from `$GIT_COMMON_DIR/info/exclude`.
37 + * Patterns read from `$GIT_DIR/info/exclude`.
38 38
39 39 * Patterns read from the file specified by the configuration
40 40 variable `core.excludesFile`.
@@ -50,7 +50,7 @@ be used.
50 50 specific to a particular repository but which do not need to be shared
51 51 with other related repositories (e.g., auxiliary files that live inside
52 52 the repository but are specific to one user's workflow) should go into
53 - the `$GIT_COMMON_DIR/info/exclude` file.
53 + the `$GIT_DIR/info/exclude` file.
54 54
55 55 * Patterns which a user wants Git to
56 56 ignore in all situations (e.g., backup or temporary files generated by
@@ -97,7 +97,7 @@ PATTERN FORMAT
97 97 match at any level below the `.gitignore` level.
98 98
99 99 - Patterns read from exclude sources that are outside the working tree,
100 - such as $GIT_COMMON_DIR/info/exclude and core.excludesFile, are treated as if
100 + such as $GIT_DIR/info/exclude and core.excludesFile, are treated as if
101 101 they are specified at the root of the working tree, i.e. a leading "/"
102 102 in such patterns anchors the match at the root of the repository.
103 103
@@ -146,8 +146,8 @@ CONFIGURATION
146 146
147 147 The optional configuration variable `core.excludesFile` indicates a path to a
148 148 file containing patterns of file names to exclude, similar to
149 - `$GIT_COMMON_DIR/info/exclude`. Patterns in the exclude file are used in
150 - addition to those in `$GIT_COMMON_DIR/info/exclude`.
149 + `$GIT_DIR/info/exclude`. Patterns in the exclude file are used in addition to
150 + those in `$GIT_DIR/info/exclude`.
151 151
152 152 NOTES
153 153 -----
modified Documentation/gitpacking.adoc
@@ -150,7 +150,7 @@ with a configuration like so:
150 150 pattern = "refs/"
151 151 threshold = now
152 152 stableThreshold = never
153 - sampleRate = 1
153 + sampleRate = 100
154 154 maxMerges = 64
155 155 ----
156 156
@@ -177,7 +177,7 @@ like:
177 177 pattern = "refs/virtual/([0-9]+)/(heads|tags)/"
178 178 threshold = now
179 179 stableThreshold = never
180 - sampleRate = 1
180 + sampleRate = 100
181 181 maxMerges = 64
182 182 ----
183 183
modified Documentation/gitprotocol-v2.adoc
@@ -558,46 +558,31 @@ object-info
558 558
559 559 `object-info` is the command to retrieve information about one or more objects.
560 560 Its main purpose is to allow a client to make decisions based on this
561 - information without having to fully fetch objects. Currently only object size
562 - and type are supported.
561 + information without having to fully fetch objects. Object size is the only
562 + information that is currently supported.
563 563
564 564 An `object-info` request takes the following arguments:
565 565
566 566 size
567 567 Requests size information to be returned for each listed object id.
568 568
569 - type
570 - Requests type information to be returned for each listed object id.
571 -
572 569 oid <oid>
573 570 Indicates to the server an object which the client wants to obtain
574 - information for. They must be full OIDs.
571 + information for.
575 572
576 - The response of `object-info` consists of one pkt-line per requested attribute,
577 - echoing the attributes the server will report, followed by one pkt-line per
578 - requested object id with its information, each field separated by a single
579 - space.
573 + The response of `object-info` is a list of the requested object ids
574 + and associated requested information, each separated by a single space.
580 575
581 576 output = info flush-pkt
582 577
583 - info = *PKT-LINE(attr LF)
584 - *PKT-LINE(obj-info LF)
585 -
586 - attr = "size" | "type"
587 -
588 - obj-size = 1*DIGIT
578 + info = PKT-LINE(attrs) LF)
579 + *PKT-LINE(obj-info LF)
589 580
590 - obj-type = "blob" | "tree" | "commit" | "tag"
581 + attrs = attr | attrs SP attrs
591 582
592 - obj-val = obj-size | obj-type
583 + attr = "size"
593 584
594 - obj-info = obj-id [SP [obj-val *(SP obj-val)]]
595 -
596 - The values in `obj-info` appear in the same order as the corresponding `attr`
597 - lines, with exactly one value per requested attribute.
598 -
599 - If the server does not recognize the OID, the response will be `<oid> SP`
600 - regardless of the number of attributes requested.
585 + obj-info = obj-id SP obj-size
601 586
602 587 bundle-uri
603 588 ~~~~~~~~~~
@@ -863,10 +848,6 @@ advertised, it can reply with "promisor-remote=<pr-names>" where
863 848 where `pr-name` is the urlencoded name of a promisor remote the server
864 849 advertised and the client accepts.
865 850
866 - The promisor remotes that the client accepted will be tried before the
867 - other configured promisor remotes when the client attempts to fetch
868 - missing objects.
869 -
870 851 Note that, everywhere in this document, the ';' and ',' characters
871 852 MUST be encoded if they appear in `pr-name` or `field-value`.
872 853
@@ -881,11 +862,10 @@ the server advertised, the client shouldn't advertise the
881 862
882 863 On the server side, the "promisor.advertise" and "promisor.sendFields"
883 864 configuration options can be used to control what it advertises. On
884 - the client side, the "promisor.acceptFromServer" and
885 - "promisor.acceptFromServerUrl" configuration options can be used to
886 - control what it accepts, and the "promisor.storeFields" option, to
887 - control what it stores. See the documentation of these configuration
888 - options in linkgit:git-config[1] for more information.
865 + the client side, the "promisor.acceptFromServer" configuration option
866 + can be used to control what it accepts, and the "promisor.storeFields"
867 + option, to control what it stores. See the documentation of these
868 + configuration options in linkgit:git-config[1] for more information.
889 869
890 870 Note that in the future it would be nice if the "promisor-remote"
891 871 protocol capability could be used by the server, when responding to
modified Documentation/line-range-options.adoc
@@ -8,14 +8,12 @@
8 8 give zero or one positive revision arguments, and
9 9 _<start>_ and _<end>_ (or _<funcname>_) must exist in the starting revision.
10 10 You can specify this option more than once. Implies `--patch`.
11 - Patch output can be suppressed using `--no-patch`.
12 - Non-patch diff formats `--raw`, `--name-only`, `--name-status`,
13 - and `--summary` are supported. Diff stat formats
14 - (`--stat`, `--numstat`, `--shortstat`, `--dirstat`) are not
15 - currently implemented.
11 + Patch output can be suppressed using `--no-patch`, but other diff formats
12 + (namely `--raw`, `--numstat`, `--shortstat`, `--dirstat`, `--summary`,
13 + `--name-only`, `--name-status`, `--check`) are not currently implemented.
16 14 +
17 15 Patch formatting options such as `--word-diff`, `--color-moved`,
18 16 `--no-prefix`, and whitespace options (`-w`, `-b`) are supported,
19 - as are pickaxe options (`-S`, `-G`) and `--diff-filter`.
17 + as are pickaxe options (`-S`, `-G`).
20 18 +
21 19 include::line-range-format.adoc[]
modified Documentation/meson.build
@@ -55,7 +55,6 @@ manpages = {
55 55 'git-for-each-ref.adoc' : 1,
56 56 'git-for-each-repo.adoc' : 1,
57 57 'git-format-patch.adoc' : 1,
58 - 'git-format-rev.adoc' : 1,
59 58 'git-fsck-objects.adoc' : 1,
60 59 'git-fsck.adoc' : 1,
61 60 'git-fsmonitor--daemon.adoc' : 1,
@@ -156,7 +155,6 @@ manpages = {
156 155 'git-update-server-info.adoc' : 1,
157 156 'git-upload-archive.adoc' : 1,
158 157 'git-upload-pack.adoc' : 1,
159 - 'git-url-parse.adoc' : 1,
160 158 'git-var.adoc' : 1,
161 159 'git-verify-commit.adoc' : 1,
162 160 'git-verify-pack.adoc' : 1,
modified Documentation/rev-list-options.adoc
@@ -16,18 +16,14 @@ ordering and formatting options, such as `--reverse`.
16 16 `-<number>`::
17 17 `-n <number>`::
18 18 `--max-count=<number>`::
19 - Limit the output to the first _<number>_ commits that would be shown.
20 -
21 - `--max-count-oldest=<number>`::
22 - Limit the output to the last _<number>_ commits that would be shown.
19 + Limit the output to _<number>_ commits.
23 20
24 21 `--skip=<number>`::
25 22 Skip _<number>_ commits before starting to show the commit output.
26 23
27 24 `--since=<date>`::
28 25 `--after=<date>`::
29 - Show commits more recent than _<date>_. As a special case,
30 - 'today' means the last midnight.
26 + Show commits more recent than _<date>_.
31 27
32 28 `--since-as-filter=<date>`::
33 29 Show all commits more recent than _<date>_. This visits
@@ -1263,20 +1259,6 @@ This implies the `--topo-order` option by default, but the
1263 1259 in between them in that case. If _<barrier>_ is specified, it
1264 1260 is the string that will be shown instead of the default one.
1265 1261
1266 - `--graph-lane-limit=<n>`::
1267 - When `--graph` is used, limit the number of graph lanes to be shown.
1268 - Lanes over the limit are replaced with a truncation mark '~'.
1269 - By default it is set to 0 (no limit), zero and negative values
1270 - are ignored and treated as no limit.
1271 -
1272 - `--no-graph-indent`::
1273 - `--graph-indent`::
1274 - When used with `--graph`, indent visual roots (commits with no parents
1275 - or whose parents are not shown) to differentiate them from commits that
1276 - are vertically adjacent but unrelated. Enabled by default. Use
1277 - `--no-graph-indent` to disable or set `log.graphIndent` to set a
1278 - default preference.
1279 -
1280 1262 ifdef::git-rev-list[]
1281 1263 `--count`::
1282 1264 Print a number stating how many commits would have been
modified Documentation/revisions.adoc
@@ -127,9 +127,6 @@ some output processing may assume ref names in UTF-8.
127 127 `git push` were run while `branchname` was checked out (or the current
128 128 `HEAD` if no branchname is specified). Like for '@\{upstream\}', we report
129 129 the remote-tracking branch that corresponds to that branch at the remote.
130 - If the push destination is a URL and exactly one configured remote uses
131 - that URL for pushing, '@\{push}' reports that remote's remote-tracking
132 - branch.
133 130 +
134 131 Here's an example to make it more clear:
135 132 +
modified Documentation/technical/api-parse-options.adoc
@@ -150,77 +150,8 @@ Data Structure
150 150
151 151 The main data structure is an array of the `option` struct,
152 152 say `static struct option builtin_add_options[]`.
153 -
154 - Option flags
155 - ~~~~~~~~~~~~
156 -
157 - Each option can carry flags in the `flags` field of its `option`
158 - struct. These are per-option flags and are distinct from the
159 - `parse_options()` flags described above; they are usually set through
160 - the `OPT_*_F()` macro variants (see below) rather than by hand. They
161 - are the bitwise-or of:
162 -
163 - `PARSE_OPT_OPTARG`::
164 - The option's argument is optional, i.e. both `--option` and
165 - `--option=<value>` are accepted.
166 -
167 - `PARSE_OPT_NOARG`::
168 - The option takes no argument at all. Using `--option=<value>`
169 - is rejected.
170 -
171 - `PARSE_OPT_NONEG`::
172 - Disable the automatically generated negated `--no-option`
173 - form.
174 -
175 - `PARSE_OPT_HIDDEN`::
176 - Hide the option: it is omitted from the usage shown by
177 - `git <cmd> -h`, but is still shown by `git <cmd> --help-all`.
178 - The option is parsed as usual either way. This is meant for
179 - deprecated, advanced or otherwise uncommon options.
180 -
181 - `PARSE_OPT_LASTARG_DEFAULT`::
182 - The no-argument form is only accepted when the option is the
183 - last token on the command line; used earlier, it still
184 - requires an argument. Should not be combined with
185 - `PARSE_OPT_OPTARG`.
186 -
187 - `PARSE_OPT_NODASH`::
188 - The option is a single character without a leading dash, such
189 - as the `+` used by some commands.
190 -
191 - `PARSE_OPT_LITERAL_ARGHELP`::
192 - Use the argument help string (`argh`) verbatim in the usage
193 - output instead of surrounding it with `<>` or `[]`. Useful when
194 - `argh` already contains a hand-formatted description.
195 -
196 - `PARSE_OPT_FROM_ALIAS`::
197 - Internal flag, set on options that were expanded from a
198 - configured alias. It should not be set by callers.
199 -
200 - `PARSE_OPT_NOCOMPLETE`::
201 - Do not offer this option for completion.
202 -
203 - `PARSE_OPT_COMP_ARG`::
204 - The option's argument, rather than the option itself, is what
205 - should be completed.
206 -
207 - `PARSE_OPT_CMDMODE`::
208 - The option is one of several mutually exclusive "command mode"
209 - options that share the same variable. Using more than one of
210 - them at once is rejected.
211 -
212 - Macros
213 - ~~~~~~
214 -
215 153 There are some macros to easily define options:
216 154
217 - Many of the macros below have an `_F` variant (for example `OPT_BOOL_F`,
218 - `OPT_STRING_F`, `OPT_INTEGER_F`, `OPT_SET_INT_F`, `OPT_BIT_F` and
219 - `OPT_CALLBACK_F`) that takes an additional trailing `flags` argument.
220 - That argument is the bitwise-or of the per-option flags described in the
221 - "Option flags" section above; the non-`_F` macros are simply defined
222 - with `flags` set to `0`.
223 -
224 155 `OPT__ABBREV(&int_var)`::
225 156 Add `--abbrev[=<n>]`.
226 157
@@ -244,21 +175,10 @@ with `flags` set to `0`.
244 175 describes the group or an empty string.
245 176 Start the description with an upper-case letter.
246 177
247 - `OPT_HIDDEN_GROUP(description)`::
248 - Like `OPT_GROUP()`, but the group header carries
249 - `PARSE_OPT_HIDDEN`, so it is only shown by `--help-all` and not
250 - by `-h`. Use it to label a group that contains only hidden
251 - options, which would otherwise show an empty header under `-h`.
252 -
253 178 `OPT_BOOL(short, long, &int_var, description)`::
254 179 Introduce a boolean option. `int_var` is set to one with
255 180 `--option` and set to zero with `--no-option`.
256 181
257 - `OPT_HIDDEN_BOOL(short, long, &int_var, description)`::
258 - Like `OPT_BOOL()`, but the option carries `PARSE_OPT_HIDDEN`,
259 - so it is hidden from `-h` while still being shown by
260 - `--help-all`.
261 -
262 182 `OPT_COUNTUP(short, long, &int_var, description)`::
263 183 Introduce a count-up option.
264 184 Each use of `--option` increments `int_var`, starting from zero
modified Documentation/technical/api-path-walk.adoc
@@ -48,13 +48,6 @@ commits.
48 48 applications could disable some options to make it simpler to walk
49 49 the objects or to have fewer calls to `path_fn`.
50 50 +
51 - Note that objects directly requested as pending objects (such as targets
52 - of lightweight tags or other ref tips) are always emitted to `path_fn`,
53 - even when the corresponding type flag is disabled. Only objects
54 - discovered during the tree walk are subject to these type filters. This
55 - ensures that objects specifically requested through the revision input
56 - are never silently dropped.
57 - +
58 51 While it is possible to walk only commits in this way, consumers would be
59 52 better off using the revision walk API instead.
60 53
modified Documentation/technical/build-systems.adoc
@@ -47,7 +47,7 @@ Auto-detection of the following items is considered to be important:
47 47
48 48 - Check for the existence of headers.
49 49 - Check for the existence of libraries.
50 - - Check for the existence of executables.
50 + - Check for the existence of exectuables.
51 51 - Check for the runtime behavior of specific functions.
52 52 - Check for specific link order requirements when multiple libraries are
53 53 involved.
@@ -106,7 +106,7 @@ by the build system:
106 106
107 107 - C: the primary compiled language used by Git, must be supported. Relevant
108 108 toolchains are GCC, Clang and MSVC.
109 - - Rust: candidate as a second compiled language, should be supported. Relevant
109 + - Rust: candidate as a second compiled lanugage, should be supported. Relevant
110 110 toolchains is the LLVM-based rustc.
111 111
112 112 Built-in support for the respective languages is preferred over support that
@@ -142,7 +142,7 @@ The following list of build systems are considered:
142 142
143 143 === GNU Make
144 144
145 - - Platform support: ubiquitous on all platforms, but not well-integrated into Windows.
145 + - Platform support: ubitquitous on all platforms, but not well-integrated into Windows.
146 146 - Auto-detection: no built-in support for auto-detection of features.
147 147 - Ease of use: easy to use, but discovering available options is hard. Makefile
148 148 rules can quickly get out of hand once reaching a certain scope.
modified Documentation/technical/hash-function-transition.adoc
@@ -545,7 +545,7 @@ Alternates
545 545 ~~~~~~~~~~
546 546 For the same reason, a SHA-256 repository cannot borrow objects from a
547 547 SHA-1 repository using objects/info/alternates or
548 - $GIT_ALTERNATE_OBJECT_DIRECTORIES.
548 + $GIT_ALTERNATE_OBJECT_REPOSITORIES.
549 549
550 550 git notes
551 551 ~~~~~~~~~
modified Documentation/technical/meson.build
@@ -18,7 +18,6 @@ articles = [
18 18 'multi-pack-index.adoc',
19 19 'packfile-uri.adoc',
20 20 'pack-heuristics.adoc',
21 - 'paint-down-to-common.adoc',
22 21 'parallel-checkout.adoc',
23 22 'partial-clone.adoc',
24 23 'platform-support.adoc',
deleted Documentation/technical/paint-down-to-common.adoc mode 100644
@@ -1,155 +0,0 @@
1 - Merge-Base Computation and paint_down_to_common()
2 - ==================================================
3 -
4 - The function `paint_down_to_common()` in `commit-reach.c` computes merge
5 - bases by walking the commit graph backwards from two sets of tips and
6 - finding where their ancestry meets.
7 -
8 - Use cases
9 - ---------
10 -
11 - Computing merge bases is used in two different ways:
12 -
13 - 1. *Finding all merge bases* (`merge-base --all`, `merge-tree`,
14 - `merge`, `rebase`). A merge base is a common ancestor that is
15 - not itself an ancestor of another common ancestor.
16 -
17 - 2. *Ancestry checks* (`in_merge_bases`, used by `merge-base
18 - --is-ancestor`, `branch -d`, `fetch`). These ask: "is commit A
19 - an ancestor of commit B?" If a common ancestor equals one of the
20 - inputs, that input is necessarily the only merge base -- no other
21 - common ancestor can be both as recent and not an ancestor of it.
22 -
23 - Both use cases share the same algorithm and implementation.
24 -
25 - Algorithm
26 - ---------
27 -
28 - Given a commit `one` and a set of commits `twos[]`, the walk paints
29 - commits with two colors:
30 -
31 - - PARENT1: reachable from `one`
32 - - PARENT2: reachable from any commit in `twos[]`
33 -
34 - The walk uses a priority queue ordered by generation number
35 - (highest first), breaking ties by commit date. Each step dequeues
36 - the highest-priority commit and propagates its paint flags to its
37 - parents, enqueuing any parent that gained new flags. When a
38 - commit receives both PARENT1 and PARENT2, it is a merge-base
39 - candidate. A candidate gains the STALE flag so its ancestors
40 - propagate staleness -- any deeper common ancestor is necessarily
41 - redundant.
42 -
43 - [[generation-regions]]
44 - Topologically ordered and unordered generation regions
45 - ------------------------------------------------------
46 -
47 - Commits fall into two regions based on whether their generation
48 - numbers provide a topological ordering guarantee:
49 -
50 - ....
51 - +------------------------------------------+
52 - | Unordered region |
53 - | generation = INFINITY or V1_MAX |
54 - | queue order: heuristic (commit date) |
55 - +------------------------------------------+
56 - |
57 - v
58 - +------------------------------------------+
59 - | Ordered region |
60 - | generation = finite, unsaturated |
61 - | queue order: topological |
62 - +------------------------------------------+
63 - ....
64 -
65 - In the ordered region, a child's generation is strictly greater
66 - than its parent's. Same-generation commits are necessarily
67 - independent, so the queue always processes children before
68 - their parents.
69 -
70 - In the unordered region, parent-child pairs can share the same
71 - generation number, so topological order is not guaranteed. The
72 - queue uses commit-date as a heuristic, which typically produces
73 - a reasonable traversal order but may process a parent before
74 - its child.
75 -
76 - Commits not in the commit-graph have generation INFINITY; v1
77 - commit-graphs saturate at V1_MAX. Both place commits in the
78 - unordered region. Any optimization that depends on generation
79 - ordering must account for this saturation boundary. The early
80 - exit gates compare against a topological ceiling --
81 - `GENERATION_NUMBER_V1_MAX` for v1 graphs and
82 - `GENERATION_NUMBER_INFINITY` for v2 graphs -- so that saturated
83 - commits are treated as unordered.
84 -
85 - With generation ordering, values in the unordered region exceed
86 - those in the ordered region. The walk may therefore transition
87 - from the unordered region into the ordered region, but never in
88 - the reverse direction. Without a commit-graph, every commit has INFINITY
89 - and the walk operates entirely in the unordered region.
90 -
91 - In the ordered region, paint on a dequeued commit is final --
92 - no future step can add flags to it. In the unordered region,
93 - a dequeued commit may later gain additional paint. Paint flags
94 - are only added, never removed, bounding the number of
95 - re-enqueues per commit.
96 -
97 - Termination
98 - -----------
99 -
100 - The walk tracks the number of commits of each type in the queue
101 - (PARENT1-only, PARENT2-only, pending merge-base). The main loop
102 - ends when one of the following conditions holds:
103 -
104 - 1. The queue is empty.
105 - 2. The queue contains only stale entries.
106 - 3. Generation cutoff: the dequeued commit's generation is below
107 - a caller-supplied `min_generation` threshold.
108 - 4. Single result: the caller only needs one merge base, one has
109 - been found, and the walk has entered the ordered region.
110 - 5. Side exhaustion: no pure PARENT1 or pure PARENT2 commits
111 - remain in the queue, no pending merge-base candidates exist,
112 - and the walk has entered the ordered region.
113 -
114 - Stale entry condition
115 - ~~~~~~~~~~~~~~~~~~~~~
116 - Once all queued entries are stale, no new merge-base candidates can
117 - be discovered -- that requires at least one non-stale commit from
118 - each side meeting. Continuing the walk could still invalidate
119 - existing candidates by proving one is an ancestor of another, but
120 - `remove_redundant()` handles that as a post-processing step, so it
121 - is safe to exit early.
122 -
123 - Side-exhaustion condition
124 - ~~~~~~~~~~~~~~~~~~~~~~~~~
125 - A new merge-base requires commits from both sides to meet. When one
126 - side's exclusive counter reaches zero and there are no pending
127 - merge-base candidates, no future traversal step can produce a new
128 - candidate. This optimization only activates in the ordered region,
129 - where paint flags are final at visit time; in the unordered region,
130 - a side that appears exhausted could reappear through late paint
131 - propagation.
132 -
133 - Generation cutoff
134 - ~~~~~~~~~~~~~~~~~
135 - Some callers (notably `remove_redundant()`) supply a `min_generation`
136 - threshold equal to the minimum generation of the input commits.
137 - These callers only need to determine reachability among the inputs,
138 - not find deep merge bases, so the walk can safely terminate when it
139 - dequeues a commit below this threshold.
140 -
141 - Single result
142 - ~~~~~~~~~~~~~
143 - When only one merge base is needed and the walk is in the
144 - ordered region with generation ordering, the first candidate
145 - found is necessarily the highest-generation common ancestor.
146 - No remaining commit in the queue can be a descendant of this
147 - candidate (generation ordering guarantees children are visited
148 - first), so it cannot be redundant and the walk can stop
149 - immediately.
150 -
151 - Related documentation
152 - ---------------------
153 -
154 - - `Documentation/technical/commit-graph.adoc` -- generation numbers
155 - and the reachability closure property.
modified Documentation/technical/partial-clone.adoc
@@ -159,7 +159,7 @@ and prefetch those objects in bulk.
159 159 - `repack` in GC has been updated to not touch promisor packfiles at all,
160 160 and to only repack other objects.
161 161
162 - - The per-repository flag "fetch_if_missing" is used to control whether an
162 + - The global variable "fetch_if_missing" is used to control whether an
163 163 object lookup will attempt to dynamically fetch a missing object or
164 164 report an error.
165 165 +
modified Documentation/technical/rerere.adoc
@@ -77,7 +77,7 @@ Sorting hunks
77 77 ~~~~~~~~~~~~~
78 78
79 79 As before, let's imagine that a common ancestor had a file with line A
80 - in its early part, and line X in its late part. And then four branches
80 + its early part, and line X in its late part. And then four branches
81 81 are forked that do these things:
82 82
83 83 - AB: changes A to B
modified GIT-VERSION-GEN
@@ -1,6 +1,6 @@
1 1 #!/bin/sh
2 2
3 - DEF_VER=v2.55.GIT
3 + DEF_VER=v2.54.0
4 4
5 5 LF='
6 6 '
modified Makefile
@@ -416,7 +416,7 @@ include shared.mak
416 416 # If your platform has OS-specific ways to tell if a repo is incompatible with
417 417 # fsmonitor (whether the hook or IPC daemon version), set FSMONITOR_OS_SETTINGS
418 418 # to the "<name>" of the corresponding `compat/fsmonitor/fsm-settings-<name>.c`
419 - # and `compat/fsmonitor/fsm-ipc-<name>.c` files.
419 + # that implements the `fsm_os_settings__*()` routines.
420 420 #
421 421 # Define LINK_FUZZ_PROGRAMS if you want `make all` to also build the fuzz test
422 422 # programs in oss-fuzz/.
@@ -494,20 +494,12 @@ include shared.mak
494 494 #
495 495 # == Optional Rust support ==
496 496 #
497 - # Define NO_RUST if you want to disable features and subsystems written in Rust
498 - # from being compiled into Git. For now, Rust is still an optional feature of
499 - # the build process. With Git 3.0 though, Rust will always be enabled.
497 + # Define WITH_RUST if you want to include features and subsystems written in
498 + # Rust into Git. For now, Rust is still an optional feature of the build
499 + # process. With Git 3.0 though, Rust will always be enabled.
500 500 #
501 501 # Building Rust code requires Cargo.
502 502 #
503 - # Define RUST_TARGETS if you want to cross-compile. If left unspecified, it uses
504 - # the default Rust target on the system.
505 - #
506 - # On macOS, this supports specifying multiple targets, separated by a space.
507 - # This will produce a Universal static library using `lipo`.
508 - #
509 - # Example: RUST_TARGETS="aarch64-apple-darwin x86_64-apple-darwin"
510 - #
511 503 # == SHA-1 and SHA-256 defines ==
512 504 #
513 505 # === SHA-1 backend ===
@@ -876,7 +868,6 @@ TEST_BUILTINS_OBJS += test-submodule-config.o
876 868 TEST_BUILTINS_OBJS += test-submodule-nested-repo-config.o
877 869 TEST_BUILTINS_OBJS += test-submodule.o
878 870 TEST_BUILTINS_OBJS += test-subprocess.o
879 - TEST_BUILTINS_OBJS += test-synthesize.o
880 871 TEST_BUILTINS_OBJS += test-trace2.o
881 872 TEST_BUILTINS_OBJS += test-truncate.o
882 873 TEST_BUILTINS_OBJS += test-userdiff.o
@@ -900,7 +891,6 @@ BUILT_INS += $(patsubst builtin/%.o,git-%$X,$(BUILTIN_OBJS))
900 891 BUILT_INS += git-cherry$X
901 892 BUILT_INS += git-cherry-pick$X
902 893 BUILT_INS += git-format-patch$X
903 - BUILT_INS += git-format-rev$X
904 894 BUILT_INS += git-fsck-objects$X
905 895 BUILT_INS += git-init$X
906 896 BUILT_INS += git-maintenance$X
@@ -947,19 +937,16 @@ TEST_SHELL_PATH = $(SHELL_PATH)
947 937
948 938 LIB_FILE = libgit.a
949 939
950 - ifndef NO_RUST
951 940 ifdef DEBUG
952 - RUST_BUILD_CONFIG = debug
941 + RUST_TARGET_DIR = target/debug
953 942 else
954 - RUST_BUILD_CONFIG = release
943 + RUST_TARGET_DIR = target/release
955 944 endif
956 945
957 946 ifeq ($(uname_S),Windows)
958 - RUST_LIB_NAME = gitcore.lib
947 + RUST_LIB = $(RUST_TARGET_DIR)/gitcore.lib
959 948 else
960 - RUST_LIB_NAME = libgitcore.a
961 - endif
962 - RUST_LIB = target/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME)
949 + RUST_LIB = $(RUST_TARGET_DIR)/libgitcore.a
963 950 endif
964 951
965 952 GITLIBS = common-main.o $(LIB_FILE)
@@ -1169,7 +1156,6 @@ LIB_OBJS += ewah/ewah_io.o
1169 1156 LIB_OBJS += ewah/ewah_rlw.o
1170 1157 LIB_OBJS += exec-cmd.o
1171 1158 LIB_OBJS += fetch-negotiator.o
1172 - LIB_OBJS += fetch-object-info.o
1173 1159 LIB_OBJS += fetch-pack.o
1174 1160 LIB_OBJS += fmt-merge-msg.o
1175 1161 LIB_OBJS += fsck.o
@@ -1228,11 +1214,7 @@ LIB_OBJS += object.o
1228 1214 LIB_OBJS += odb.o
1229 1215 LIB_OBJS += odb/source.o
1230 1216 LIB_OBJS += odb/source-files.o
1231 - LIB_OBJS += odb/source-inmemory.o
1232 - LIB_OBJS += odb/source-loose.o
1233 - LIB_OBJS += odb/source-packed.o
1234 1217 LIB_OBJS += odb/streaming.o
1235 - LIB_OBJS += odb/transaction.o
1236 1218 LIB_OBJS += oid-array.o
1237 1219 LIB_OBJS += oidmap.o
1238 1220 LIB_OBJS += oidset.o
@@ -1246,7 +1228,6 @@ LIB_OBJS += pack-refs.o
1246 1228 LIB_OBJS += pack-revindex.o
1247 1229 LIB_OBJS += pack-write.o
1248 1230 LIB_OBJS += packfile.o
1249 - LIB_OBJS += packfile-list.o
1250 1231 LIB_OBJS += pager.o
1251 1232 LIB_OBJS += parallel-checkout.o
1252 1233 LIB_OBJS += parse.o
@@ -1366,7 +1347,7 @@ LIB_OBJS += urlmatch.o
1366 1347 LIB_OBJS += usage.o
1367 1348 LIB_OBJS += userdiff.o
1368 1349 LIB_OBJS += utf8.o
1369 - ifdef NO_RUST
1350 + ifndef WITH_RUST
1370 1351 LIB_OBJS += varint.o
1371 1352 endif
1372 1353 LIB_OBJS += version.o
@@ -1512,7 +1493,6 @@ BUILTIN_OBJS += builtin/update-ref.o
1512 1493 BUILTIN_OBJS += builtin/update-server-info.o
1513 1494 BUILTIN_OBJS += builtin/upload-archive.o
1514 1495 BUILTIN_OBJS += builtin/upload-pack.o
1515 - BUILTIN_OBJS += builtin/url-parse.o
1516 1496 BUILTIN_OBJS += builtin/var.o
1517 1497 BUILTIN_OBJS += builtin/verify-commit.o
1518 1498 BUILTIN_OBJS += builtin/verify-pack.o
@@ -1542,7 +1522,6 @@ CLAR_TEST_SUITES += u-hash
1542 1522 CLAR_TEST_SUITES += u-hashmap
1543 1523 CLAR_TEST_SUITES += u-list-objects-filter-options
1544 1524 CLAR_TEST_SUITES += u-mem-pool
1545 - CLAR_TEST_SUITES += u-odb-inmemory
1546 1525 CLAR_TEST_SUITES += u-oid-array
1547 1526 CLAR_TEST_SUITES += u-oidmap
1548 1527 CLAR_TEST_SUITES += u-oidtree
@@ -1606,7 +1585,7 @@ endif
1606 1585 ALL_CFLAGS = $(DEVELOPER_CFLAGS) $(CPPFLAGS) $(CFLAGS) $(CFLAGS_APPEND)
1607 1586 ALL_LDFLAGS = $(LDFLAGS) $(LDFLAGS_APPEND)
1608 1587
1609 - ifndef NO_RUST
1588 + ifdef WITH_RUST
1610 1589 BASIC_CFLAGS += -DWITH_RUST
1611 1590 GITLIBS += $(RUST_LIB)
1612 1591 ifeq ($(uname_S),Windows)
@@ -2045,10 +2024,6 @@ ifdef NO_PREAD
2045 2024 COMPAT_CFLAGS += -DNO_PREAD
2046 2025 COMPAT_OBJS += compat/pread.o
2047 2026 endif
2048 - ifdef NO_WRITEV
2049 - COMPAT_CFLAGS += -DNO_WRITEV
2050 - COMPAT_OBJS += compat/writev.o
2051 - endif
2052 2027 ifdef NO_FAST_WORKING_DIRECTORY
2053 2028 BASIC_CFLAGS += -DNO_FAST_WORKING_DIRECTORY
2054 2029 endif
@@ -2393,13 +2368,13 @@ ifdef FSMONITOR_DAEMON_BACKEND
2393 2368 COMPAT_CFLAGS += -DHAVE_FSMONITOR_DAEMON_BACKEND
2394 2369 COMPAT_OBJS += compat/fsmonitor/fsm-listen-$(FSMONITOR_DAEMON_BACKEND).o
2395 2370 COMPAT_OBJS += compat/fsmonitor/fsm-health-$(FSMONITOR_DAEMON_BACKEND).o
2371 + COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_DAEMON_BACKEND).o
2396 2372 endif
2397 2373
2398 2374 ifdef FSMONITOR_OS_SETTINGS
2399 2375 COMPAT_CFLAGS += -DHAVE_FSMONITOR_OS_SETTINGS
2400 - COMPAT_OBJS += compat/fsmonitor/fsm-ipc-$(FSMONITOR_OS_SETTINGS).o
2401 2376 COMPAT_OBJS += compat/fsmonitor/fsm-settings-$(FSMONITOR_OS_SETTINGS).o
2402 - COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_DAEMON_BACKEND).o
2377 + COMPAT_OBJS += compat/fsmonitor/fsm-path-utils-$(FSMONITOR_OS_SETTINGS).o
2403 2378 endif
2404 2379
2405 2380 ifdef WITH_BREAKING_CHANGES
@@ -2617,7 +2592,6 @@ FUZZ_OBJS += oss-fuzz/fuzz-date.o
2617 2592 FUZZ_OBJS += oss-fuzz/fuzz-pack-headers.o
2618 2593 FUZZ_OBJS += oss-fuzz/fuzz-pack-idx.o
2619 2594 FUZZ_OBJS += oss-fuzz/fuzz-parse-attr-line.o
2620 - FUZZ_OBJS += oss-fuzz/fuzz-reftable.o
2621 2595 FUZZ_OBJS += oss-fuzz/fuzz-url-decode-mem.o
2622 2596 .PHONY: fuzz-objs
2623 2597 fuzz-objs: $(FUZZ_OBJS)
@@ -2686,7 +2660,7 @@ git$X: git.o GIT-LDFLAGS $(BUILTIN_OBJS) $(GITLIBS)
2686 2660
2687 2661 help.sp help.s help.o: command-list.h
2688 2662 builtin/bugreport.sp builtin/bugreport.s builtin/bugreport.o: hook-list.h
2689 - hook.sp hook.s hook.o: hook-list.h
2663 + builtin/hook.sp builtin/hook.s builtin/hook.o: hook-list.h
2690 2664
2691 2665 builtin/help.sp builtin/help.s builtin/help.o: config-list.h GIT-PREFIX
2692 2666 builtin/help.sp builtin/help.s builtin/help.o: EXTRA_CPPFLAGS = \
@@ -3036,35 +3010,11 @@ scalar$X: scalar.o GIT-LDFLAGS $(GITLIBS)
3036 3010 $(LIB_FILE): $(LIB_OBJS)
3037 3011 $(QUIET_AR)$(RM) $@ && $(AR) $(ARFLAGS) $@ $^
3038 3012
3039 - ifndef NO_RUST
3040 - ifeq ($(RUST_TARGETS),)
3041 3013 $(RUST_LIB): Cargo.toml $(RUST_SOURCES) $(LIB_FILE)
3042 3014 $(QUIET_CARGO)cargo build $(CARGO_ARGS)
3043 - else
3044 - ifneq ($(words $(RUST_TARGETS)),1)
3045 - ifneq ($(uname_S),Darwin)
3046 - $(error Building universal Rust libraries requires macOS (lipo is not available on $(uname_S)))
3047 - endif
3048 - endif
3049 -
3050 - RUST_MEMBER_LIBS = $(foreach target,$(RUST_TARGETS),target/$(target)/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME))
3051 - $(RUST_MEMBER_LIBS): target/%/$(RUST_BUILD_CONFIG)/$(RUST_LIB_NAME): Cargo.toml $(RUST_SOURCES) $(LIB_FILE)
3052 - $(QUIET_CARGO)cargo build $(CARGO_ARGS) --target $*
3053 -
3054 - $(RUST_LIB): $(RUST_MEMBER_LIBS)
3055 - $(call mkdir_p_parent_template)
3056 - $(QUIET_GEN)\
3057 - if test $(words $(RUST_TARGETS)) -gt 1; \
3058 - then \
3059 - lipo -create $^ -output $@; \
3060 - else \
3061 - cp $< $@; \
3062 - fi
3063 - endif
3064 3015
3065 3016 .PHONY: rust
3066 3017 rust: $(RUST_LIB)
3067 - endif
3068 3018
3069 3019 export DEFAULT_EDITOR DEFAULT_PAGER
3070 3020
@@ -4115,10 +4065,9 @@ $(LIBGIT_HIDDEN_EXPORT): $(LIBGIT_PARTIAL_EXPORT)
4115 4065 contrib/libgit-sys/libgitpub.a: $(LIBGIT_HIDDEN_EXPORT)
4116 4066 $(AR) $(ARFLAGS) $@ $^
4117 4067
4118 - # When Rust is enabled, git-credential-osxkeychain depends on Rust symbols in $(RUST_LIB)
4119 - contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) $(RUST_LIB) GIT-LDFLAGS
4068 + contrib/credential/osxkeychain/git-credential-osxkeychain: contrib/credential/osxkeychain/git-credential-osxkeychain.o $(LIB_FILE) GIT-LDFLAGS
4120 4069 $(QUIET_LINK)$(CC) $(ALL_CFLAGS) -o $@ $(ALL_LDFLAGS) \
4121 - $(filter %.o,$^) $(LIBS) -framework Security -framework CoreFoundation
4070 + $(filter %.o,$^) $(LIB_FILE) $(EXTLIBS) -framework Security -framework CoreFoundation
4122 4071
4123 4072 contrib/credential/osxkeychain/git-credential-osxkeychain.o: contrib/credential/osxkeychain/git-credential-osxkeychain.c GIT-CFLAGS
4124 4073 $(QUIET_LINK)$(CC) -o $@ -c $(dep_args) $(compdb_args) $(ALL_CFLAGS) $(EXTRA_CPPFLAGS) $<
modified README.md
@@ -1,5 +1,4 @@
1 - [![GitHub build status](https://github.com/git/git/workflows/CI/badge.svg)](https://github.com/git/git/actions?query=branch%3Amaster+event%3Apush)
2 - [![GitLab build status](https://gitlab.com/git-scm/git/badges/master/pipeline.svg)](https://gitlab.com/git-scm/git/-/pipelines?ref=master)
1 + [![Build status](https://github.com/git/git/workflows/CI/badge.svg)](https://github.com/git/git/actions?query=branch%3Amaster+event%3Apush)
3 2
4 3 Git - fast, scalable, distributed revision control system
5 4 =========================================================
modified RelNotes
@@ -1 +1 @@
1 - Documentation/RelNotes/2.56.0.adocโŠ˜
1 + Documentation/RelNotes/2.54.1.adocโŠ˜
modified advice.c
@@ -69,7 +69,6 @@ static struct {
69 69 [ADVICE_PUSH_NON_FF_CURRENT] = { "pushNonFFCurrent" },
70 70 [ADVICE_PUSH_NON_FF_MATCHING] = { "pushNonFFMatching" },
71 71 [ADVICE_PUSH_REF_NEEDS_UPDATE] = { "pushRefNeedsUpdate" },
72 - [ADVICE_PUSH_REPO_LOOKS_LIKE_REF] = { "pushRepoLooksLikeRef" },
73 72 [ADVICE_PUSH_UNQUALIFIED_REF_NAME] = { "pushUnqualifiedRefName" },
74 73 [ADVICE_PUSH_UPDATE_REJECTED] = { "pushUpdateRejected" },
75 74 [ADVICE_PUSH_UPDATE_REJECTED_ALIAS] = { "pushNonFastForward" }, /* backwards compatibility */
modified advice.h
@@ -36,7 +36,6 @@ enum advice_type {
36 36 ADVICE_PUSH_NON_FF_CURRENT,
37 37 ADVICE_PUSH_NON_FF_MATCHING,
38 38 ADVICE_PUSH_REF_NEEDS_UPDATE,
39 - ADVICE_PUSH_REPO_LOOKS_LIKE_REF,
40 39 ADVICE_PUSH_UNQUALIFIED_REF_NAME,
41 40 ADVICE_PUSH_UPDATE_REJECTED,
42 41 ADVICE_PUSH_UPDATE_REJECTED_ALIAS,
modified apply.c
@@ -47,17 +47,11 @@ struct gitdiff_data {
47 47 int p_value;
48 48 };
49 49
50 - static void git_apply_config(struct repository *repo)
50 + static void git_apply_config(void)
51 51 {
52 - struct repo_config_values *cfg = repo_config_values(repo);
53 -
54 - FREE_AND_NULL(cfg->apply_default_whitespace);
55 - repo_config_get_string(repo, "apply.whitespace",
56 - &cfg->apply_default_whitespace);
57 - FREE_AND_NULL(cfg->apply_default_ignorewhitespace);
58 - repo_config_get_string(repo, "apply.ignorewhitespace",
59 - &cfg->apply_default_ignorewhitespace);
60 - repo_config(repo, git_xmerge_config, NULL);
52 + repo_config_get_string(the_repository, "apply.whitespace", &apply_default_whitespace);
53 + repo_config_get_string(the_repository, "apply.ignorewhitespace", &apply_default_ignorewhitespace);
54 + repo_config(the_repository, git_xmerge_config, NULL);
61 55 }
62 56
63 57 static int parse_whitespace_option(struct apply_state *state, const char *option)
@@ -115,8 +109,6 @@ int init_apply_state(struct apply_state *state,
115 109 struct repository *repo,
116 110 const char *prefix)
117 111 {
118 - struct repo_config_values *cfg = repo_config_values(repo);
119 -
120 112 memset(state, 0, sizeof(*state));
121 113 state->prefix = prefix;
122 114 state->repo = repo;
@@ -134,13 +126,10 @@ int init_apply_state(struct apply_state *state,
134 126 strset_init(&state->kept_symlinks);
135 127 strbuf_init(&state->root, 0);
136 128
137 - git_apply_config(repo);
138 -
139 - if (cfg->apply_default_whitespace &&
140 - parse_whitespace_option(state, cfg->apply_default_whitespace))
129 + git_apply_config();
130 + if (apply_default_whitespace && parse_whitespace_option(state, apply_default_whitespace))
141 131 return -1;
142 - if (cfg->apply_default_ignorewhitespace &&
143 - parse_ignorewhitespace_option(state, cfg->apply_default_ignorewhitespace))
132 + if (apply_default_ignorewhitespace && parse_ignorewhitespace_option(state, apply_default_ignorewhitespace))
144 133 return -1;
145 134 return 0;
146 135 }
@@ -203,8 +192,7 @@ int check_apply_state(struct apply_state *state, int force_apply)
203 192
204 193 static void set_default_whitespace_mode(struct apply_state *state)
205 194 {
206 - if (!state->whitespace_option &&
207 - !repo_config_values(state->repo)->apply_default_whitespace)
195 + if (!state->whitespace_option && !apply_default_whitespace)
208 196 state->ws_error_action = (state->apply ? warn_on_ws_error : nowarn_ws_error);
209 197 }
210 198
@@ -3244,7 +3232,7 @@ static int apply_binary_fragment(struct apply_state *state,
3244 3232 struct patch *patch)
3245 3233 {
3246 3234 struct fragment *fragment = patch->fragments;
3247 - size_t len;
3235 + unsigned long len;
3248 3236 void *dst;
3249 3237
3250 3238 if (!fragment)
@@ -3333,7 +3321,7 @@ static int apply_binary(struct apply_state *state,
3333 3321 if (odb_has_object(the_repository->objects, &oid, 0)) {
3334 3322 /* We already have the postimage */
3335 3323 enum object_type type;
3336 - size_t size;
3324 + unsigned long size;
3337 3325 char *result;
3338 3326
3339 3327 result = odb_read_object(the_repository->objects, &oid,
@@ -3396,7 +3384,7 @@ static int read_blob_object(struct strbuf *buf, const struct object_id *oid, uns
3396 3384 strbuf_addf(buf, "Subproject commit %s\n", oid_to_hex(oid));
3397 3385 } else {
3398 3386 enum object_type type;
3399 - size_t sz;
3387 + unsigned long sz;
3400 3388 char *result;
3401 3389
3402 3390 result = odb_read_object(the_repository->objects, oid,
@@ -3623,7 +3611,7 @@ static int load_preimage(struct apply_state *state,
3623 3611
3624 3612 static int resolve_to(struct image *image, const struct object_id *result_id)
3625 3613 {
3626 - size_t size;
3614 + unsigned long size;
3627 3615 enum object_type type;
3628 3616 char *data;
3629 3617
@@ -3905,8 +3893,8 @@ static int check_preimage(struct apply_state *state,
3905 3893 if (*ce && !(*ce)->ce_mode)
3906 3894 BUG("ce_mode == 0 for path '%s'", old_name);
3907 3895
3908 - if (repo_trust_executable_bit(state->repo) || !S_ISREG(st->st_mode))
3909 - st_mode = ce_mode_from_stat(state->repo, *ce, st->st_mode);
3896 + if (trust_executable_bit || !S_ISREG(st->st_mode))
3897 + st_mode = ce_mode_from_stat(*ce, st->st_mode);
3910 3898 else if (*ce)
3911 3899 st_mode = (*ce)->ce_mode;
3912 3900 else
@@ -4020,7 +4008,7 @@ static int path_is_beyond_symlink_1(struct apply_state *state, struct strbuf *na
4020 4008 struct cache_entry *ce;
4021 4009
4022 4010 ce = index_file_exists(state->repo->index, name->buf,
4023 - name->len, repo_ignore_case(the_repository));
4011 + name->len, ignore_case);
4024 4012 if (ce && S_ISLNK(ce->ce_mode))
4025 4013 return 1;
4026 4014 } else {
@@ -4299,8 +4287,7 @@ static int build_fake_ancestor(struct apply_state *state, struct patch *list)
4299 4287 }
4300 4288 }
4301 4289
4302 - repo_hold_lock_file_for_update(state->repo, &lock, state->fake_ancestor,
4303 - LOCK_DIE_ON_ERROR);
4290 + hold_lock_file_for_update(&lock, state->fake_ancestor, LOCK_DIE_ON_ERROR);
4304 4291 res = write_locked_index(&result, &lock, COMMIT_LOCK);
4305 4292 discard_index(&result);
4306 4293
@@ -4524,7 +4511,7 @@ static int try_create_file(struct apply_state *state, const char *path,
4524 4511 return !!mkdir(path, 0777);
4525 4512 }
4526 4513
4527 - if (repo_has_symlinks(state->repo) && S_ISLNK(mode))
4514 + if (has_symlinks && S_ISLNK(mode))
4528 4515 /* Although buf:size is counted string, it also is NUL
4529 4516 * terminated.
4530 4517 */
@@ -4894,10 +4881,8 @@ static int apply_patch(struct apply_state *state,
4894 4881
4895 4882 state->patch_input_file = filename;
4896 4883 state->linenr = 1;
4897 - if (read_patch_file(&buf, fd) < 0) {
4898 - res = -128;
4899 - goto end;
4900 - }
4884 + if (read_patch_file(&buf, fd) < 0)
4885 + return -128;
4901 4886 offset = 0;
4902 4887 while (offset < buf.len) {
4903 4888 struct patch *patch;
@@ -4958,10 +4943,9 @@ static int apply_patch(struct apply_state *state,
4958 4943 state->update_index = (state->check_index || state->ita_only) && state->apply;
4959 4944 if (state->update_index && !is_lock_file_locked(&state->lock_file)) {
4960 4945 if (state->index_file)
4961 - repo_hold_lock_file_for_update(state->repo,
4962 - &state->lock_file,
4963 - state->index_file,
4964 - LOCK_DIE_ON_ERROR);
4946 + hold_lock_file_for_update(&state->lock_file,
4947 + state->index_file,
4948 + LOCK_DIE_ON_ERROR);
4965 4949 else
4966 4950 repo_hold_locked_index(state->repo, &state->lock_file,
4967 4951 LOCK_DIE_ON_ERROR);
modified archive-tar.c
@@ -129,20 +129,20 @@ static void write_trailer(void)
129 129 */
130 130 static int stream_blocked(struct repository *r, const struct object_id *oid)
131 131 {
132 - struct odb_stream *st;
132 + struct odb_read_stream *st;
133 133 char buf[BLOCKSIZE];
134 134 ssize_t readlen;
135 135
136 - st = odb_stream_from_object(r->objects, oid, NULL);
136 + st = odb_read_stream_open(r->objects, oid, NULL);
137 137 if (!st)
138 138 return error(_("cannot stream blob %s"), oid_to_hex(oid));
139 139 for (;;) {
140 - readlen = odb_stream_read(st, buf, sizeof(buf));
140 + readlen = odb_read_stream_read(st, buf, sizeof(buf));
141 141 if (readlen <= 0)
142 142 break;
143 143 do_write_blocked(buf, readlen);
144 144 }
145 - odb_stream_close(st);
145 + odb_read_stream_close(st);
146 146 if (!readlen)
147 147 finish_record();
148 148 return readlen;
modified archive-zip.c
@@ -206,7 +206,7 @@ static void *zlib_deflate_raw(void *data, unsigned long size,
206 206 unsigned long *compressed_size)
207 207 {
208 208 git_zstream stream;
209 - size_t maxsize;
209 + unsigned long maxsize;
210 210 void *buffer;
211 211 int result;
212 212
@@ -309,7 +309,7 @@ static int write_zip_entry(struct archiver_args *args,
309 309 enum zip_method method;
310 310 unsigned char *out;
311 311 void *deflated = NULL;
312 - struct odb_stream *stream = NULL;
312 + struct odb_read_stream *stream = NULL;
313 313 unsigned long flags = 0;
314 314 int is_binary = -1;
315 315 const char *path_without_prefix = path + args->baselen;
@@ -347,7 +347,7 @@ static int write_zip_entry(struct archiver_args *args,
347 347 method = ZIP_METHOD_DEFLATE;
348 348
349 349 if (!buffer) {
350 - stream = odb_stream_from_object(args->repo->objects, oid, NULL);
350 + stream = odb_read_stream_open(args->repo->objects, oid, NULL);
351 351 if (!stream)
352 352 return error(_("cannot stream blob %s"),
353 353 oid_to_hex(oid));
@@ -428,7 +428,7 @@ static int write_zip_entry(struct archiver_args *args,
428 428 ssize_t readlen;
429 429
430 430 for (;;) {
431 - readlen = odb_stream_read(stream, buf, sizeof(buf));
431 + readlen = odb_read_stream_read(stream, buf, sizeof(buf));
432 432 if (readlen <= 0)
433 433 break;
434 434 crc = crc32(crc, buf, readlen);
@@ -438,7 +438,7 @@ static int write_zip_entry(struct archiver_args *args,
438 438 buf, readlen);
439 439 write_or_die(1, buf, readlen);
440 440 }
441 - odb_stream_close(stream);
441 + odb_read_stream_close(stream);
442 442 if (readlen)
443 443 return readlen;
444 444
@@ -461,7 +461,7 @@ static int write_zip_entry(struct archiver_args *args,
461 461 zstream.avail_out = sizeof(compressed);
462 462
463 463 for (;;) {
464 - readlen = odb_stream_read(stream, buf, sizeof(buf));
464 + readlen = odb_read_stream_read(stream, buf, sizeof(buf));
465 465 if (readlen <= 0)
466 466 break;
467 467 crc = crc32(crc, buf, readlen);
@@ -485,7 +485,7 @@ static int write_zip_entry(struct archiver_args *args,
485 485 }
486 486
487 487 }
488 - odb_stream_close(stream);
488 + odb_read_stream_close(stream);
489 489 if (readlen)
490 490 return readlen;
491 491
modified archive.c
@@ -87,7 +87,7 @@ static void *object_file_to_archive(const struct archiver_args *args,
87 87 const struct object_id *oid,
88 88 unsigned int mode,
89 89 enum object_type *type,
90 - size_t *sizep)
90 + unsigned long *sizep)
91 91 {
92 92 void *buffer;
93 93 const struct commit *commit = args->convert ? args->commit : NULL;
@@ -158,7 +158,7 @@ static int write_archive_entry(const struct object_id *oid, const char *base,
158 158 write_archive_entry_fn_t write_entry = c->write_entry;
159 159 int err;
160 160 const char *path_without_prefix;
161 - size_t size;
161 + unsigned long size;
162 162 void *buffer;
163 163 enum object_type type;
164 164
@@ -786,7 +786,7 @@ int write_archive(int argc, const char **argv, const char *prefix,
786 786 * die ourselves; but its error message will be more specific
787 787 * than what we could write here.
788 788 */
789 - setup_git_directory(the_repository);
789 + setup_git_directory();
790 790 }
791 791
792 792 parse_treeish_arg(argv, &args, remote);
modified attr.c
@@ -681,7 +681,7 @@ static enum git_attr_direction direction;
681 681
682 682 void git_attr_set_direction(enum git_attr_direction new_direction)
683 683 {
684 - if (is_bare_repository(the_repository) && new_direction != GIT_ATTR_INDEX)
684 + if (is_bare_repository() && new_direction != GIT_ATTR_INDEX)
685 685 BUG("non-INDEX attr direction in a bare repo");
686 686
687 687 if (new_direction != direction)
@@ -768,7 +768,7 @@ static struct attr_stack *read_attr_from_blob(struct index_state *istate,
768 768 const char *path, unsigned flags)
769 769 {
770 770 struct object_id oid;
771 - size_t sz;
771 + unsigned long sz;
772 772 enum object_type type;
773 773 void *buf;
774 774 unsigned short mode;
@@ -848,7 +848,7 @@ static struct attr_stack *read_attr(struct index_state *istate,
848 848 res = read_attr_from_index(istate, path, flags);
849 849 } else if (tree_oid) {
850 850 res = read_attr_from_blob(istate, tree_oid, path, flags);
851 - } else if (!is_bare_repository(the_repository)) {
851 + } else if (!is_bare_repository()) {
852 852 if (direction == GIT_ATTR_CHECKOUT) {
853 853 res = read_attr_from_index(istate, path, flags);
854 854 if (!res)
modified bisect.c
@@ -154,7 +154,7 @@ static void show_list(const char *debug, int counted, int nr,
154 154 struct commit *commit = p->item;
155 155 unsigned commit_flags = commit->object.flags;
156 156 enum object_type type;
157 - size_t size;
157 + unsigned long size;
158 158 char *buf = odb_read_object(the_repository->objects,
159 159 &commit->object.oid, &type,
160 160 &size);
@@ -488,7 +488,6 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START")
488 488 static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
489 489 static GIT_PATH_FUNC(git_path_bisect_terms, "BISECT_TERMS")
490 490 static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
491 - static GIT_PATH_FUNC(git_path_bisect_reset_when_found, "BISECT_RESET_WHEN_FOUND")
492 491
493 492 static void read_bisect_paths(struct strvec *array)
494 493 {
@@ -513,7 +512,7 @@ static char *join_oid_array_hex(struct oid_array *array, char delim)
513 512 int i;
514 513
515 514 for (i = 0; i < array->nr; i++) {
516 - strbuf_add_oid_hex(&joined_hexs, array->oid + i);
515 + strbuf_addstr(&joined_hexs, oid_to_hex(array->oid + i));
517 516 if (i + 1 < array->nr)
518 517 strbuf_addch(&joined_hexs, delim);
519 518 }
@@ -712,7 +711,7 @@ static enum bisect_error error_if_skipped_commits(struct commit_list *tried,
712 711 return BISECT_OK;
713 712
714 713 printf("There are only 'skip'ped commits left to test.\n"
715 - "The first '%s' commit could be any of:\n", term_bad);
714 + "The first %s commit could be any of:\n", term_bad);
716 715
717 716 for ( ; tried; tried = tried->next)
718 717 printf("%s\n", oid_to_hex(&tried->item->object.oid));
@@ -811,7 +810,7 @@ static enum bisect_error handle_bad_merge_base(void)
811 810 "between %s and [%s].\n"),
812 811 bad_hex, bad_hex, good_hex);
813 812 } else {
814 - fprintf(stderr, _("The merge base %s is '%s'.\n"
813 + fprintf(stderr, _("The merge base %s is %s.\n"
815 814 "This means the first '%s' commit is "
816 815 "between %s and [%s].\n"),
817 816 bad_hex, term_bad, term_good, bad_hex, good_hex);
@@ -821,9 +820,9 @@ static enum bisect_error handle_bad_merge_base(void)
821 820 return BISECT_MERGE_BASE_CHECK;
822 821 }
823 822
824 - fprintf(stderr, _("Some '%s' revs are not ancestors of the '%s' rev.\n"
823 + fprintf(stderr, _("Some %s revs are not ancestors of the %s rev.\n"
825 824 "git bisect cannot work properly in this case.\n"
826 - "Maybe you mistook '%s' and '%s' revs?\n"),
825 + "Maybe you mistook %s and %s revs?\n"),
827 826 term_good, term_bad, term_good, term_bad);
828 827 return BISECT_FAILED;
829 828 }
@@ -836,7 +835,7 @@ static void handle_skipped_merge_base(const struct object_id *mb)
836 835
837 836 warning(_("the merge base between %s and [%s] "
838 837 "must be skipped.\n"
839 - "So we cannot be sure the first '%s' commit is "
838 + "So we cannot be sure the first %s commit is "
840 839 "between %s and %s.\n"
841 840 "We continue anyway."),
842 841 bad_hex, good_hex, term_bad, mb_hex, bad_hex);
@@ -929,7 +928,7 @@ static enum bisect_error check_good_are_ancestors_of_bad(struct repository *r,
929 928 struct commit **rev;
930 929
931 930 if (!current_bad_oid)
932 - return error(_("a '%s' revision is needed"), term_bad);
931 + return error(_("a %s revision is needed"), term_bad);
933 932
934 933 filename = repo_git_path(the_repository, "BISECT_ANCESTORS_OK");
935 934
@@ -1020,12 +1019,10 @@ void read_bisect_terms(char **read_bad, char **read_good)
1020 1019 die_errno(_("could not read file '%s'"), filename);
1021 1020 }
1022 1021 } else {
1023 - if (strbuf_getline_lf(&str, fp) == EOF)
1024 - die(_("could not read bad term from file '%s'"), filename);
1022 + strbuf_getline_lf(&str, fp);
1025 1023 free(*read_bad);
1026 1024 *read_bad = strbuf_detach(&str, NULL);
1027 - if (strbuf_getline_lf(&str, fp) == EOF)
1028 - die(_("could not read good term from file '%s'"), filename);
1025 + strbuf_getline_lf(&str, fp);
1029 1026 free(*read_good);
1030 1027 *read_good = strbuf_detach(&str, NULL);
1031 1028 }
@@ -1093,7 +1090,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
1093 1090 res = error_if_skipped_commits(tried, NULL);
1094 1091 if (res < 0)
1095 1092 goto cleanup;
1096 - printf(_("%s was both '%s' and '%s'\n"),
1093 + printf(_("%s was both %s and %s\n"),
1097 1094 oid_to_hex(current_bad_oid),
1098 1095 term_good,
1099 1096 term_bad);
@@ -1116,7 +1113,7 @@ enum bisect_error bisect_next_all(struct repository *r, const char *prefix)
1116 1113 res = error_if_skipped_commits(tried, current_bad_oid);
1117 1114 if (res)
1118 1115 goto cleanup;
1119 - printf("%s is the first '%s' commit\n", oid_to_hex(bisect_rev),
1116 + printf("%s is the first %s commit\n", oid_to_hex(bisect_rev),
1120 1117 term_bad);
1121 1118
1122 1119 show_commit(revs.commits->item);
@@ -1214,7 +1211,6 @@ int bisect_clean_state(void)
1214 1211 unlink_or_warn(git_path_bisect_run());
1215 1212 unlink_or_warn(git_path_bisect_terms());
1216 1213 unlink_or_warn(git_path_bisect_first_parent());
1217 - unlink_or_warn(git_path_bisect_reset_when_found());
1218 1214 /*
1219 1215 * Cleanup BISECT_START last to support the --no-checkout option
1220 1216 * introduced in the commit 4796e823a.
modified blame.c
@@ -1041,13 +1041,10 @@ static void fill_origin_blob(struct diff_options *opt,
1041 1041 textconv_object(opt->repo, o->path, o->mode,
1042 1042 &o->blob_oid, 1, &file->ptr, &file_size))
1043 1043 ;
1044 - else {
1045 - size_t file_size_st = 0;
1044 + else
1046 1045 file->ptr = odb_read_object(the_repository->objects,
1047 1046 &o->blob_oid, &type,
1048 - &file_size_st);
1049 - file_size = cast_size_t_to_ulong(file_size_st);
1050 - }
1047 + &file_size);
1051 1048 file->size = file_size;
1052 1049
1053 1050 if (!file->ptr)
@@ -2816,7 +2813,7 @@ void setup_scoreboard(struct blame_scoreboard *sb,
2816 2813 }
2817 2814
2818 2815 if (!sb->contents_from)
2819 - setup_work_tree(the_repository);
2816 + setup_work_tree();
2820 2817
2821 2818 sb->final = fake_working_tree_commit(sb->repo,
2822 2819 &sb->revs->diffopt,
@@ -2872,14 +2869,10 @@ void setup_scoreboard(struct blame_scoreboard *sb,
2872 2869 textconv_object(sb->repo, sb->path, o->mode, &o->blob_oid, 1, (char **) &sb->final_buf,
2873 2870 &sb->final_buf_size))
2874 2871 ;
2875 - else {
2876 - size_t final_buf_size_st = 0;
2872 + else
2877 2873 sb->final_buf = odb_read_object(the_repository->objects,
2878 2874 &o->blob_oid, &type,
2879 - &final_buf_size_st);
2880 - sb->final_buf_size =
2881 - cast_size_t_to_ulong(final_buf_size_st);
2882 - }
2875 + &sb->final_buf_size);
2883 2876
2884 2877 if (!sb->final_buf)
2885 2878 die(_("cannot read blob %s for path %s"),
modified bloom.c
@@ -16,7 +16,6 @@
16 16 define_commit_slab(bloom_filter_slab, struct bloom_filter);
17 17
18 18 static struct bloom_filter_slab bloom_filters;
19 - static int bloom_filter_slab_initialized;
20 19
21 20 struct pathmap_hash_entry {
22 21 struct hashmap_entry entry;
@@ -264,10 +263,7 @@ void add_key_to_filter(const struct bloom_key *key,
264 263
265 264 void init_bloom_filters(void)
266 265 {
267 - if (bloom_filter_slab_initialized)
268 - return;
269 266 init_bloom_filter_slab(&bloom_filters);
270 - bloom_filter_slab_initialized = 1;
271 267 }
272 268
273 269 static void free_one_bloom_filter(struct bloom_filter *filter)
@@ -280,7 +276,6 @@ static void free_one_bloom_filter(struct bloom_filter *filter)
280 276 void deinit_bloom_filters(void)
281 277 {
282 278 deep_clear_bloom_filter_slab(&bloom_filters, free_one_bloom_filter);
283 - bloom_filter_slab_initialized = 0;
284 279 }
285 280
286 281 struct bloom_keyvec *bloom_keyvec_new(const char *path, size_t len,
@@ -610,10 +605,10 @@ int bloom_filter_contains_vec(const struct bloom_filter *filter,
610 605 uint32_t test_bloom_murmur3_seeded(uint32_t seed, const char *data, size_t len,
611 606 int version)
612 607 {
608 + assert(version == 1 || version == 2);
609 +
613 610 if (version == 2)
614 611 return murmur3_seeded_v2(seed, data, len);
615 - else if (version == 1)
616 - return murmur3_seeded_v1(seed, data, len);
617 612 else
618 - BUG("unexpected bloom version: %d", version);
613 + return murmur3_seeded_v1(seed, data, len);
619 614 }
modified branch.c
@@ -61,7 +61,7 @@ static int find_tracked_branch(struct remote *remote, void *priv)
61 61
62 62 static int should_setup_rebase(const char *origin)
63 63 {
64 - switch (repo_config_values(the_repository)->autorebase) {
64 + switch (autorebase) {
65 65 case AUTOREBASE_NEVER:
66 66 return 0;
67 67 case AUTOREBASE_LOCAL:
@@ -372,7 +372,7 @@ int read_branch_desc(struct strbuf *buf, const char *branch_name)
372 372 */
373 373 int validate_branchname(const char *name, struct strbuf *ref)
374 374 {
375 - if (check_branch_ref(the_repository, ref, name)) {
375 + if (check_branch_ref(ref, name)) {
376 376 int code = die_message(_("'%s' is not a valid branch name"), name);
377 377 advise_if_enabled(ADVICE_REF_SYNTAX,
378 378 _("See 'git help check-ref-format'"));
@@ -385,39 +385,6 @@ int validate_branchname(const char *name, struct strbuf *ref)
385 385 static int initialized_checked_out_branches;
386 386 static struct strmap current_checked_out_branches = STRMAP_INIT;
387 387
388 - enum branch_checkout_kind {
389 - BRANCH_CHECKOUT_KIND_CHECKOUT,
390 - BRANCH_CHECKOUT_KIND_REBASE,
391 - BRANCH_CHECKOUT_KIND_BISECT,
392 - BRANCH_CHECKOUT_KIND_UPDATE_REF,
393 - };
394 -
395 - struct checked_out_branch {
396 - char *refname;
397 - char *path;
398 - enum branch_checkout_kind kind;
399 - };
400 -
401 - static struct checked_out_branch *checked_out_branches;
402 - static size_t checked_out_branches_alloc, checked_out_branches_nr;
403 -
404 - static void register_checked_out_branch(const char *prefix, const char *name,
405 - const char *path,
406 - enum branch_checkout_kind kind)
407 - {
408 - char *refname = xstrfmt("%s%s", prefix, name);
409 - char *path_copy = xstrdup(path);
410 -
411 - ALLOC_GROW(checked_out_branches, checked_out_branches_nr + 1,
412 - checked_out_branches_alloc);
413 - checked_out_branches[checked_out_branches_nr].refname = refname;
414 - checked_out_branches[checked_out_branches_nr].path = path_copy;
415 - checked_out_branches[checked_out_branches_nr].kind = kind;
416 - checked_out_branches_nr++;
417 -
418 - strmap_put(&current_checked_out_branches, refname, path_copy);
419 - }
420 -
421 388 static void prepare_checked_out_branches(void)
422 389 {
423 390 int i = 0;
@@ -427,10 +394,10 @@ static void prepare_checked_out_branches(void)
427 394 return;
428 395 initialized_checked_out_branches = 1;
429 396
430 - worktrees = get_worktrees(the_repository);
397 + worktrees = get_worktrees();
431 398
432 399 while (worktrees[i]) {
433 - char *wt_gitdir;
400 + char *old, *wt_gitdir;
434 401 struct wt_status_state state = { 0 };
435 402 struct worktree *wt = worktrees[i++];
436 403 struct string_list update_refs = STRING_LIST_INIT_DUP;
@@ -439,25 +406,34 @@ static void prepare_checked_out_branches(void)
439 406 continue;
440 407
441 408 if (wt->head_ref) {
442 - register_checked_out_branch("", wt->head_ref, wt->path,
443 - BRANCH_CHECKOUT_KIND_CHECKOUT);
409 + old = strmap_put(&current_checked_out_branches,
410 + wt->head_ref,
411 + xstrdup(wt->path));
412 + free(old);
444 413 }
445 414
446 415 if (wt_status_check_rebase(wt, &state) &&
447 416 (state.rebase_in_progress || state.rebase_interactive_in_progress) &&
448 417 state.branch) {
449 - register_checked_out_branch("refs/heads/", state.branch,
450 - wt->path,
451 - BRANCH_CHECKOUT_KIND_REBASE);
418 + struct strbuf ref = STRBUF_INIT;
419 + strbuf_addf(&ref, "refs/heads/%s", state.branch);
420 + old = strmap_put(&current_checked_out_branches,
421 + ref.buf,
422 + xstrdup(wt->path));
423 + free(old);
424 + strbuf_release(&ref);
452 425 }
453 426 wt_status_state_free_buffers(&state);
454 427
455 428 if (wt_status_check_bisect(wt, &state) &&
456 429 state.bisecting_from) {
457 - register_checked_out_branch("refs/heads/",
458 - state.bisecting_from,
459 - wt->path,
460 - BRANCH_CHECKOUT_KIND_BISECT);
430 + struct strbuf ref = STRBUF_INIT;
431 + strbuf_addf(&ref, "refs/heads/%s", state.bisecting_from);
432 + old = strmap_put(&current_checked_out_branches,
433 + ref.buf,
434 + xstrdup(wt->path));
435 + free(old);
436 + strbuf_release(&ref);
461 437 }
462 438 wt_status_state_free_buffers(&state);
463 439
@@ -466,9 +442,10 @@ static void prepare_checked_out_branches(void)
466 442 &update_refs)) {
467 443 struct string_list_item *item;
468 444 for_each_string_list_item(item, &update_refs) {
469 - register_checked_out_branch("", item->string,
470 - wt->path,
471 - BRANCH_CHECKOUT_KIND_UPDATE_REF);
445 + old = strmap_put(&current_checked_out_branches,
446 + item->string,
447 + xstrdup(wt->path));
448 + free(old);
472 449 }
473 450 string_list_clear(&update_refs, 1);
474 451 }
@@ -485,17 +462,6 @@ const char *branch_checked_out(const char *refname)
485 462 return strmap_get(&current_checked_out_branches, refname);
486 463 }
487 464
488 - const char *branch_bisecting(const char *refname)
489 - {
490 - prepare_checked_out_branches();
491 - for (size_t i = 0; i < checked_out_branches_nr; i++) {
492 - if (!strcmp(refname, checked_out_branches[i].refname) &&
493 - checked_out_branches[i].kind == BRANCH_CHECKOUT_KIND_BISECT)
494 - return checked_out_branches[i].path;
495 - }
496 - return NULL;
497 - }
498 -
499 465 /*
500 466 * Check if a branch 'name' can be created as a new branch; die otherwise.
501 467 * 'force' can be used when it is OK for the named branch already exists.
@@ -880,7 +846,7 @@ void remove_branch_state(struct repository *r, int verbose)
880 846
881 847 void die_if_checked_out(const char *branch, int ignore_current_worktree)
882 848 {
883 - struct worktree **worktrees = get_worktrees(the_repository);
849 + struct worktree **worktrees = get_worktrees();
884 850
885 851 for (int i = 0; worktrees[i]; i++) {
886 852 if (worktrees[i]->is_current && ignore_current_worktree)
modified branch.h
@@ -106,12 +106,6 @@ void create_branches_recursively(struct repository *r, const char *name,
106 106 */
107 107 const char *branch_checked_out(const char *refname);
108 108
109 - /*
110 - * If the branch at 'refname' is currently used for bisecting in a
111 - * worktree, then return the path to that worktree.
112 - */
113 - const char *branch_bisecting(const char *refname);
114 -
115 109 /*
116 110 * Check if 'name' can be a valid name for a branch; die otherwise.
117 111 * Return 1 if the named branch already exists; return 0 otherwise.
modified builtin.h
@@ -189,7 +189,6 @@ int cmd_fmt_merge_msg(int argc, const char **argv, const char *prefix, struct re
189 189 int cmd_for_each_ref(int argc, const char **argv, const char *prefix, struct repository *repo);
190 190 int cmd_for_each_repo(int argc, const char **argv, const char *prefix, struct repository *repo);
191 191 int cmd_format_patch(int argc, const char **argv, const char *prefix, struct repository *repo);
192 - int cmd_format_rev(int argc, const char **argv, const char *prefix, struct repository *repo);
193 192 int cmd_fsck(int argc, const char **argv, const char *prefix, struct repository *repo);
194 193 int cmd_fsmonitor__daemon(int argc, const char **argv, const char *prefix, struct repository *repo);
195 194 int cmd_gc(int argc, const char **argv, const char *prefix, struct repository *repo);
@@ -272,7 +271,6 @@ int cmd_update_server_info(int argc, const char **argv, const char *prefix, stru
272 271 int cmd_upload_archive(int argc, const char **argv, const char *prefix, struct repository *repo);
273 272 int cmd_upload_archive_writer(int argc, const char **argv, const char *prefix, struct repository *repo);
274 273 int cmd_upload_pack(int argc, const char **argv, const char *prefix, struct repository *repo);
275 - int cmd_url_parse(int argc, const char **argv, const char *prefix, struct repository *repo);
276 274 int cmd_var(int argc, const char **argv, const char *prefix, struct repository *repo);
277 275 int cmd_verify_commit(int argc, const char **argv, const char *prefix, struct repository *repo);
278 276 int cmd_verify_tag(int argc, const char **argv, const char *prefix, struct repository *repo);
modified builtin/add.c
@@ -13,19 +13,18 @@
13 13 #include "dir.h"
14 14 #include "gettext.h"
15 15 #include "pathspec.h"
16 + #include "run-command.h"
16 17 #include "object-file.h"
17 18 #include "odb.h"
18 - #include "odb/transaction.h"
19 19 #include "parse-options.h"
20 20 #include "path.h"
21 21 #include "preload-index.h"
22 22 #include "diff.h"
23 23 #include "read-cache.h"
24 24 #include "revision.h"
25 + #include "strvec.h"
25 26 #include "submodule.h"
26 27 #include "add-interactive.h"
27 - #include "merge-ll.h"
28 - #include "apply.h"
29 28
30 29 static const char * const builtin_add_usage[] = {
31 30 N_("git add [<options>] [--] <pathspec>..."),
@@ -35,7 +34,6 @@ static int patch_interactive, add_interactive, edit_interactive;
35 34 static struct interactive_options interactive_opts = INTERACTIVE_OPTIONS_INIT;
36 35 static int take_worktree_changes;
37 36 static int add_renormalize;
38 - static int add_resolved;
39 37 static int pathspec_file_nul;
40 38 static int include_sparse;
41 39 static const char *pathspec_from_file;
@@ -188,8 +186,7 @@ static int edit_patch(struct repository *repo,
188 186 const char *prefix)
189 187 {
190 188 char *file = repo_git_path(repo, "ADD_EDIT.patch");
191 - struct apply_state state;
192 - const char *apply_argv[2];
189 + struct child_process child = CHILD_PROCESS_INIT;
193 190 struct rev_info rev;
194 191 int out;
195 192 struct stat st;
@@ -219,16 +216,11 @@ static int edit_patch(struct repository *repo,
219 216 if (!st.st_size)
220 217 die(_("empty patch. aborted"));
221 218
222 - apply_argv[0] = file;
223 - apply_argv[1] = NULL;
224 - if (init_apply_state(&state, repo, NULL))
225 - die(_("could not initialize apply state"));
226 - state.cached = 1;
227 - if (check_apply_state(&state, 0))
228 - die(_("could not check apply state"));
229 - if (apply_all_patches(&state, 1, apply_argv, APPLY_OPT_RECOUNT))
219 + child.git_cmd = 1;
220 + strvec_pushl(&child.args, "apply", "--recount", "--cached", file,
221 + NULL);
222 + if (run_command(&child))
230 223 die(_("could not apply '%s'"), file);
231 - clear_apply_state(&state);
232 224
233 225 unlink(file);
234 226 free(file);
@@ -272,7 +264,6 @@ static struct option builtin_add_options[] = {
272 264 OPT__FORCE(&ignored_too, N_("allow adding otherwise ignored files"), 0),
273 265 OPT_BOOL('u', "update", &take_worktree_changes, N_("update tracked files")),
274 266 OPT_BOOL(0, "renormalize", &add_renormalize, N_("renormalize EOL of tracked files (implies -u)")),
275 - OPT_BOOL(0, "resolved", &add_resolved, N_("add conflict-resolved tracked files")),
276 267 OPT_BOOL('N', "intent-to-add", &intent_to_add, N_("record only the fact that the path will be added later")),
277 268 OPT_BOOL('A', "all", &addremove_explicit, N_("add changes from all tracked and untracked files")),
278 269 OPT_CALLBACK_F(0, "ignore-removal", &addremove_explicit,
@@ -387,76 +378,6 @@ static int add_files(struct repository *repo, struct dir_struct *dir, int flags)
387 378 return exit_status;
388 379 }
389 380
390 - static int failed_to_add(int flags, const char *path)
391 - {
392 - if (!(flags & ADD_CACHE_IGNORE_ERRORS))
393 - die(_("updating file '%s' failed"), path);
394 - return 1;
395 - }
396 -
397 - static int add_resolved_files(struct repository *repo,
398 - const struct pathspec *pathspec,
399 - int flags)
400 - {
401 - struct index_state *istate = repo->index;
402 - struct string_list unmerged_paths = STRING_LIST_INIT_DUP;
403 - struct string_list unresolved_paths = STRING_LIST_INIT_DUP;
404 - int exit_status = 0;
405 - size_t i;
406 -
407 - for (i = 0; i < istate->cache_nr; i++) {
408 - struct cache_entry *ce = istate->cache[i];
409 - if (!ce_stage(ce))
410 - continue;
411 - if (pathspec->nr && !ce_path_match(istate, ce, pathspec, NULL))
412 - continue;
413 - if (!unmerged_paths.nr ||
414 - strcmp(unmerged_paths.items[unmerged_paths.nr - 1].string, ce->name))
415 - string_list_append(&unmerged_paths, ce->name);
416 - }
417 -
418 - if (!unmerged_paths.nr) {
419 - string_list_clear(&unmerged_paths, 0);
420 - return 0;
421 - }
422 -
423 - for (i = 0; i < unmerged_paths.nr; i++) {
424 - const char *path = unmerged_paths.items[i].string;
425 - struct stat st;
426 -
427 - if (!lstat(path, &st) && S_ISREG(st.st_mode)) {
428 - if (has_conflict_markers(istate, path))
429 - string_list_append(&unresolved_paths, path);
430 - }
431 - }
432 -
433 - if (unresolved_paths.nr) {
434 - struct strbuf sb = STRBUF_INIT;
435 - for (i = 0; i < unresolved_paths.nr; i++)
436 - strbuf_addf(&sb, "\t%s\n", unresolved_paths.items[i].string);
437 - die(_("the following paths still have conflict markers:\n%s"), sb.buf);
438 - }
439 -
440 - for (i = 0; i < unmerged_paths.nr; i++) {
441 - const char *path = unmerged_paths.items[i].string;
442 - struct stat st;
443 -
444 - if (lstat(path, &st)) {
445 - if (errno != ENOENT)
446 - die_errno(_("cannot lstat: '%s'"), path);
447 - if (remove_file_from_index_with_flags(istate, path, flags))
448 - exit_status = failed_to_add(flags, path);
449 - } else {
450 - if (add_file_to_index(istate, path, flags))
451 - exit_status = failed_to_add(flags, path);
452 - }
453 - }
454 -
455 - string_list_clear(&unmerged_paths, 0);
456 - string_list_clear(&unresolved_paths, 0);
457 - return exit_status;
458 - }
459 -
460 381 int cmd_add(int argc,
461 382 const char **argv,
462 383 const char *prefix,
@@ -471,7 +392,7 @@ int cmd_add(int argc,
471 392 char *seen = NULL;
472 393 char *ps_matched = NULL;
473 394 struct lock_file lock_file = LOCK_INIT;
474 - struct odb_transaction *transaction = NULL;
395 + struct odb_transaction *transaction;
475 396
476 397 repo_config(repo, add_config, NULL);
477 398
@@ -516,9 +437,8 @@ int cmd_add(int argc,
516 437 else if (take_worktree_changes && ADDREMOVE_DEFAULT)
517 438 addremove = 0; /* "-u" was given but not "-A" */
518 439
519 - die_for_incompatible_opt3(take_worktree_changes, "-u/--update",
520 - 0 < addremove_explicit, "-A/--all",
521 - add_resolved, "--resolved");
440 + if (addremove && take_worktree_changes)
441 + die(_("options '%s' and '%s' cannot be used together"), "-A", "-u");
522 442
523 443 if (!show_only && ignore_missing)
524 444 die(_("the option '%s' requires '%s'"), "--ignore-missing", "--dry-run");
@@ -527,11 +447,8 @@ int cmd_add(int argc,
527 447 chmod_arg[1] != 'x' || chmod_arg[2]))
528 448 die(_("--chmod param '%s' must be either -x or +x"), chmod_arg);
529 449
530 - add_new_files = !take_worktree_changes && !refresh_only &&
531 - !add_renormalize && !add_resolved;
532 - require_pathspec = !(take_worktree_changes ||
533 - (0 < addremove_explicit) ||
534 - add_resolved);
450 + add_new_files = !take_worktree_changes && !refresh_only && !add_renormalize;
451 + require_pathspec = !(take_worktree_changes || (0 < addremove_explicit));
535 452
536 453 repo_hold_locked_index(repo, &lock_file, LOCK_DIE_ON_ERROR);
537 454
@@ -563,8 +480,7 @@ int cmd_add(int argc,
563 480 return 0;
564 481 }
565 482
566 - if (!take_worktree_changes && !add_resolved &&
567 - addremove_explicit < 0 && pathspec.nr)
483 + if (!take_worktree_changes && addremove_explicit < 0 && pathspec.nr)
568 484 /* Turn "git add pathspec..." to "git add -A pathspec..." */
569 485 addremove = 1;
570 486
@@ -664,12 +580,10 @@ int cmd_add(int argc,
664 580 string_list_clear(&only_match_skip_worktree, 0);
665 581 }
666 582
667 - odb_transaction_begin_or_die(repo->objects, &transaction, 0);
583 + transaction = odb_transaction_begin(repo->objects);
668 584
669 585 ps_matched = xcalloc(pathspec.nr, 1);
670 - if (add_resolved)
671 - exit_status |= add_resolved_files(repo, &pathspec, flags);
672 - else if (add_renormalize)
586 + if (add_renormalize)
673 587 exit_status |= renormalize_tracked_files(repo, &pathspec, flags);
674 588 else
675 589 exit_status |= add_files_to_cache(repo, prefix,
@@ -685,7 +599,7 @@ int cmd_add(int argc,
685 599
686 600 if (chmod_arg && pathspec.nr)
687 601 exit_status |= chmod_pathspec(repo, &pathspec, chmod_arg[0], show_only);
688 - odb_transaction_commit_and_finalize_or_die(transaction);
602 + odb_transaction_commit(transaction);
689 603
690 604 finish:
691 605 if (write_locked_index(repo->index, &lock_file,
modified builtin/am.c
@@ -490,11 +490,9 @@ static int run_applypatch_msg_hook(struct am_state *state)
490 490
491 491 assert(state->msg);
492 492
493 - if (!state->no_verify) {
494 - struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
495 - strvec_push(&opt.args, am_path(state, "final-commit"));
496 - ret = run_hooks_opt(the_repository, "applypatch-msg", &opt);
497 - }
493 + if (!state->no_verify)
494 + ret = run_hooks_l(the_repository, "applypatch-msg",
495 + am_path(state, "final-commit"), NULL);
498 496
499 497 if (!ret) {
500 498 FREE_AND_NULL(state->msg);
modified builtin/archive.c
@@ -31,7 +31,7 @@ static int run_remote_archiver(int argc, const char **argv,
31 31
32 32 _remote = remote_get(remote);
33 33 transport = transport_get(_remote, _remote->url.v[0]);
34 - transport_connect(transport, GIT_CONNECT_UPLOAD_ARCHIVE, exec, fd);
34 + transport_connect(transport, "git-upload-archive", exec, fd);
35 35
36 36 /*
37 37 * Inject a fake --format field at the beginning of the
modified builtin/backfill.c
@@ -26,7 +26,7 @@
26 26 #include "path-walk.h"
27 27
28 28 static const char * const builtin_backfill_usage[] = {
29 - N_("git backfill [--min-batch-size=<n>] [--[no-]sparse] [--[no-]include-edges] [<revision-range>]"),
29 + N_("git backfill [--min-batch-size=<n>] [--[no-]sparse]"),
30 30 NULL
31 31 };
32 32
@@ -35,7 +35,6 @@ struct backfill_context {
35 35 struct oid_array current_batch;
36 36 size_t min_batch_size;
37 37 int sparse;
38 - int include_edges;
39 38 struct rev_info revs;
40 39 };
41 40
@@ -79,29 +78,6 @@ static int fill_missing_blobs(const char *path UNUSED,
79 78 return 0;
80 79 }
81 80
82 - static void reject_unsupported_rev_list_options(struct rev_info *revs)
83 - {
84 - if (revs->diffopt.pickaxe)
85 - die(_("'%s' cannot be used with 'git backfill'"),
86 - (revs->diffopt.pickaxe_opts & DIFF_PICKAXE_REGEX) ? "-G" : "-S");
87 - if (revs->diffopt.filter || revs->diffopt.filter_not)
88 - die(_("'%s' cannot be used with 'git backfill'"),
89 - "--diff-filter");
90 - if (revs->diffopt.flags.follow_renames)
91 - die(_("'%s' cannot be used with 'git backfill'"),
92 - "--follow");
93 - if (revs->line_level_traverse)
94 - die(_("'%s' cannot be used with 'git backfill'"),
95 - "-L");
96 - if (revs->explicit_diff_merges)
97 - die(_("'%s' cannot be used with 'git backfill'"),
98 - "--diff-merges");
99 - if (!path_walk_filter_compatible(&revs->filter))
100 - die(_("cannot backfill with these filter options"));
101 - if (revs->filter.blob_limit_value)
102 - die(_("cannot backfill with blob size limits"));
103 - }
104 -
105 81 static int do_backfill(struct backfill_context *ctx)
106 82 {
107 83 struct path_walk_info info = PATH_WALK_INFO_INIT;
@@ -109,7 +85,6 @@ static int do_backfill(struct backfill_context *ctx)
109 85
110 86 if (ctx->sparse) {
111 87 CALLOC_ARRAY(info.pl, 1);
112 - info.pl_sparse_trees = 1;
113 88 if (get_sparse_checkout_patterns(info.pl)) {
114 89 path_walk_info_clear(&info);
115 90 return error(_("problem loading sparse-checkout"));
@@ -119,8 +94,6 @@ static int do_backfill(struct backfill_context *ctx)
119 94 /* Walk from HEAD if otherwise unspecified. */
120 95 if (!ctx->revs.pending.nr)
121 96 add_head_to_pending(&ctx->revs);
122 - if (ctx->include_edges)
123 - ctx->revs.edge_hint = 1;
124 97
125 98 info.blobs = 1;
126 99 info.tags = info.commits = info.trees = 0;
@@ -148,15 +121,12 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
148 121 .min_batch_size = 50000,
149 122 .sparse = -1,
150 123 .revs = REV_INFO_INIT,
151 - .include_edges = 1,
152 124 };
153 125 struct option options[] = {
154 126 OPT_UNSIGNED(0, "min-batch-size", &ctx.min_batch_size,
155 127 N_("Minimum number of objects to request at a time")),
156 128 OPT_BOOL(0, "sparse", &ctx.sparse,
157 129 N_("Restrict the missing objects to the current sparse-checkout")),
158 - OPT_BOOL(0, "include-edges", &ctx.include_edges,
159 - N_("Include blobs from boundary commits in the backfill")),
160 130 OPT_END(),
161 131 };
162 132 struct repo_config_values *cfg = repo_config_values(the_repository);
@@ -174,7 +144,6 @@ int cmd_backfill(int argc, const char **argv, const char *prefix, struct reposit
174 144
175 145 if (argc > 1)
176 146 die(_("unrecognized argument: %s"), argv[1]);
177 - reject_unsupported_rev_list_options(&ctx.revs);
178 147
179 148 repo_config(repo, git_default_config, NULL);
180 149
modified builtin/bisect.c
@@ -24,12 +24,11 @@ static GIT_PATH_FUNC(git_path_bisect_start, "BISECT_START")
24 24 static GIT_PATH_FUNC(git_path_bisect_log, "BISECT_LOG")
25 25 static GIT_PATH_FUNC(git_path_bisect_names, "BISECT_NAMES")
26 26 static GIT_PATH_FUNC(git_path_bisect_first_parent, "BISECT_FIRST_PARENT")
27 - static GIT_PATH_FUNC(git_path_bisect_reset_when_found, "BISECT_RESET_WHEN_FOUND")
28 27 static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
29 28
30 29 #define BUILTIN_GIT_BISECT_START_USAGE \
31 30 N_("git bisect start [--term-(bad|new)=<term-new> --term-(good|old)=<term-old>]\n" \
32 - " [--no-checkout] [--first-parent] [--reset-when-found[=<where>]] [<bad> [<good>...]] [--] [<pathspec>...]")
31 + " [--no-checkout] [--first-parent] [<bad> [<good>...]] [--] [<pathspec>...]")
33 32 #define BUILTIN_GIT_BISECT_BAD_USAGE \
34 33 N_("git bisect (bad|new|<term-new>) [<rev>]")
35 34 #define BUILTIN_GIT_BISECT_GOOD_USAGE \
@@ -49,7 +48,7 @@ static GIT_PATH_FUNC(git_path_bisect_run, "BISECT_RUN")
49 48 #define BUILTIN_GIT_BISECT_LOG_USAGE \
50 49 "git bisect log"
51 50 #define BUILTIN_GIT_BISECT_RUN_USAGE \
52 - N_("git bisect run [--reset-when-found[=<where>]] <cmd> [<arg>...]")
51 + N_("git bisect run <cmd> [<arg>...]")
53 52 #define BUILTIN_GIT_BISECT_HELP_USAGE \
54 53 "git bisect help"
55 54
@@ -69,12 +68,6 @@ static const char * const git_bisect_usage[] = {
69 68 NULL
70 69 };
71 70
72 - enum reset_when_found_mode {
73 - RESET_WHEN_FOUND_NONE,
74 - RESET_WHEN_FOUND_TO_ORIGINAL,
75 - RESET_WHEN_FOUND_TO_FOUND,
76 - };
77 -
78 71 struct add_bisect_ref_data {
79 72 struct rev_info *revs;
80 73 unsigned int object_flags;
@@ -241,7 +234,7 @@ static int write_terms(const char *bad, const char *good)
241 234 return res;
242 235 }
243 236
244 - static int bisect_reset(const char *commit, bool quiet)
237 + static int bisect_reset(const char *commit)
245 238 {
246 239 struct strbuf branch = STRBUF_INIT;
247 240
@@ -262,10 +255,8 @@ static int bisect_reset(const char *commit, bool quiet)
262 255 struct child_process cmd = CHILD_PROCESS_INIT;
263 256
264 257 cmd.git_cmd = 1;
265 - strvec_pushl(&cmd.args, "checkout", "--ignore-other-worktrees", NULL);
266 - if (quiet)
267 - strvec_push(&cmd.args, "--quiet");
268 - strvec_pushl(&cmd.args, branch.buf, "--", NULL);
258 + strvec_pushl(&cmd.args, "checkout", "--ignore-other-worktrees",
259 + branch.buf, "--", NULL);
269 260 if (run_command(&cmd)) {
270 261 error(_("could not check out original"
271 262 " HEAD '%s'. Try 'git bisect"
@@ -276,79 +267,7 @@ static int bisect_reset(const char *commit, bool quiet)
276 267 }
277 268
278 269 strbuf_release(&branch);
279 - return 0;
280 - }
281 -
282 - static int parse_reset_when_found(const char *value,
283 - enum reset_when_found_mode *mode)
284 - {
285 - if (!strcmp(value, "original"))
286 - *mode = RESET_WHEN_FOUND_TO_ORIGINAL;
287 - else if (!strcmp(value, "found"))
288 - *mode = RESET_WHEN_FOUND_TO_FOUND;
289 - else
290 - return error(_("invalid value for '--reset-when-found': '%s'"),
291 - value);
292 -
293 - return 0;
294 - }
295 -
296 - static const char *reset_when_found_mode_name(enum reset_when_found_mode mode)
297 - {
298 - switch (mode) {
299 - case RESET_WHEN_FOUND_TO_ORIGINAL:
300 - return "original";
301 - case RESET_WHEN_FOUND_TO_FOUND:
302 - return "found";
303 - case RESET_WHEN_FOUND_NONE:
304 - BUG("no name for unset reset-when-found mode");
305 - }
306 - BUG("unknown reset-when-found mode %d", mode);
307 - }
308 -
309 - static int read_reset_when_found(enum reset_when_found_mode *mode)
310 - {
311 - struct strbuf value = STRBUF_INIT;
312 - int res = 0;
313 -
314 - *mode = RESET_WHEN_FOUND_NONE;
315 - if (is_empty_or_missing_file(git_path_bisect_reset_when_found()))
316 - return 0;
317 -
318 - if (strbuf_read_file(&value, git_path_bisect_reset_when_found(), 0) < 0) {
319 - res = error_errno(_("could not read '%s'"),
320 - git_path_bisect_reset_when_found());
321 - goto out;
322 - }
323 - strbuf_trim(&value);
324 - if (parse_reset_when_found(value.buf, mode))
325 - res = -1;
326 -
327 - out:
328 - strbuf_release(&value);
329 - return res;
330 - }
331 -
332 - static int bisect_reset_when_found(enum reset_when_found_mode mode)
333 - {
334 - struct bisect_terms terms = { 0 };
335 - char *commit = NULL;
336 - int res;
337 -
338 - if (mode == RESET_WHEN_FOUND_TO_FOUND) {
339 - read_bisect_terms(&terms.term_bad, &terms.term_good);
340 - commit = xstrfmt("refs/bisect/%s", terms.term_bad);
341 - } else if (mode == RESET_WHEN_FOUND_NONE) {
342 - BUG("automatic reset requested without a reset mode");
343 - }
344 -
345 - res = bisect_reset(commit, true);
346 - if (!res)
347 - res = bisect_clean_state();
348 -
349 - free(commit);
350 - free_terms(&terms);
351 - return res;
270 + return bisect_clean_state();
352 271 }
353 272
354 273 static void log_commit(FILE *fp,
@@ -546,16 +465,13 @@ static void bisect_print_status(const struct bisect_terms *terms)
546 465 return;
547 466
548 467 if (!state.nr_good && !state.nr_bad)
549 - bisect_log_printf(_("status: waiting for both '%s' and '%s' commits\n"),
550 - terms->term_good, terms->term_bad);
468 + bisect_log_printf(_("status: waiting for both good and bad commits\n"));
551 469 else if (state.nr_good)
552 - bisect_log_printf(Q_("status: waiting for '%s' commit, %d '%s' commit known\n",
553 - "status: waiting for '%s' commit, %d '%s' commits known\n",
554 - state.nr_good),
555 - terms->term_bad, state.nr_good, terms->term_good);
470 + bisect_log_printf(Q_("status: waiting for bad commit, %d good commit known\n",
471 + "status: waiting for bad commit, %d good commits known\n",
472 + state.nr_good), state.nr_good);
556 473 else
557 - bisect_log_printf(_("status: waiting for '%s' commit(s), '%s' commit known\n"),
558 - terms->term_good, terms->term_bad);
474 + bisect_log_printf(_("status: waiting for good commit(s), bad commit known\n"));
559 475 }
560 476
561 477 static int bisect_next_check(const struct bisect_terms *terms,
@@ -566,7 +482,7 @@ static int bisect_next_check(const struct bisect_terms *terms,
566 482 return decide_next(terms, current_term, !state.nr_good, !state.nr_bad);
567 483 }
568 484
569 - static int get_terms(struct bisect_terms *terms, int file_missing_is_ok)
485 + static int get_terms(struct bisect_terms *terms)
570 486 {
571 487 struct strbuf str = STRBUF_INIT;
572 488 FILE *fp = NULL;
@@ -574,21 +490,14 @@ static int get_terms(struct bisect_terms *terms, int file_missing_is_ok)
574 490
575 491 fp = fopen(git_path_bisect_terms(), "r");
576 492 if (!fp) {
577 - res = file_missing_is_ok ? 0 : -1;
493 + res = -1;
578 494 goto finish;
579 495 }
580 496
581 497 free_terms(terms);
582 - if (strbuf_getline_lf(&str, fp) == EOF) {
583 - res = -1;
584 - goto finish;
585 - }
498 + strbuf_getline_lf(&str, fp);
586 499 terms->term_bad = strbuf_detach(&str, NULL);
587 - if (strbuf_getline_lf(&str, fp) == EOF) {
588 - res = -1;
589 - FREE_AND_NULL(terms->term_bad);
590 - goto finish;
591 - }
500 + strbuf_getline_lf(&str, fp);
592 501 terms->term_good = strbuf_detach(&str, NULL);
593 502
594 503 finish:
@@ -600,12 +509,12 @@ finish:
600 509
601 510 static int bisect_terms(struct bisect_terms *terms, const char *option)
602 511 {
603 - if (get_terms(terms, 0))
512 + if (get_terms(terms))
604 513 return error(_("no terms defined"));
605 514
606 515 if (!option) {
607 - printf(_("Your current terms are '%s' for the old state\n"
608 - "and '%s' for the new state.\n"),
516 + printf(_("Your current terms are %s for the old state\n"
517 + "and %s for the new state.\n"),
609 518 terms->term_good, terms->term_bad);
610 519 return 0;
611 520 }
@@ -723,7 +632,7 @@ static int bisect_skipped_commits(struct bisect_terms *terms)
723 632 strbuf_reset(&commit_name);
724 633 repo_format_commit_message(the_repository, commit, "%s",
725 634 &commit_name, &pp);
726 - fprintf(fp, "# possible first '%s' commit: [%s] %s\n",
635 + fprintf(fp, "# possible first %s commit: [%s] %s\n",
727 636 terms->term_bad, oid_to_hex(&commit->object.oid),
728 637 commit_name.buf);
729 638 }
@@ -751,15 +660,10 @@ static int bisect_successful(struct bisect_terms *terms)
751 660
752 661 refs_read_ref(get_main_ref_store(the_repository), bad_ref, &oid);
753 662 commit = lookup_commit_reference_by_name(bad_ref);
754 - if (!commit) {
755 - error(_("could not find commit for '%s'"), bad_ref);
756 - free(bad_ref);
757 - return BISECT_FAILED;
758 - }
759 663 repo_format_commit_message(the_repository, commit, "%s", &commit_name,
760 664 &pp);
761 665
762 - res = append_to_file(git_path_bisect_log(), "# first '%s' commit: [%s] %s\n",
666 + res = append_to_file(git_path_bisect_log(), "# first %s commit: [%s] %s\n",
763 667 terms->term_bad, oid_to_hex(&commit->object.oid),
764 668 commit_name.buf);
765 669
@@ -768,8 +672,7 @@ static int bisect_successful(struct bisect_terms *terms)
768 672 return res;
769 673 }
770 674
771 - static enum bisect_error bisect_next(struct bisect_terms *terms,
772 - const char *prefix)
675 + static enum bisect_error bisect_next(struct bisect_terms *terms, const char *prefix)
773 676 {
774 677 enum bisect_error res;
775 678
@@ -792,8 +695,7 @@ static enum bisect_error bisect_next(struct bisect_terms *terms,
792 695 return res;
793 696 }
794 697
795 - static enum bisect_error bisect_auto_next(struct bisect_terms *terms,
796 - const char *prefix)
698 + static enum bisect_error bisect_auto_next(struct bisect_terms *terms, const char *prefix)
797 699 {
798 700 if (bisect_next_check(terms, NULL)) {
799 701 bisect_print_status(terms);
@@ -817,10 +719,9 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
817 719 struct strbuf bisect_names = STRBUF_INIT;
818 720 struct object_id head_oid;
819 721 struct object_id oid;
820 - enum reset_when_found_mode reset_when_found = RESET_WHEN_FOUND_NONE;
821 722 const char *head;
822 723
823 - if (is_bare_repository(the_repository))
724 + if (is_bare_repository())
824 725 no_checkout = 1;
825 726
826 727 /*
@@ -841,13 +742,6 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
841 742 no_checkout = 1;
842 743 } else if (!strcmp(arg, "--first-parent")) {
843 744 first_parent_only = 1;
844 - } else if (!strcmp(arg, "--reset-when-found")) {
845 - reset_when_found = RESET_WHEN_FOUND_TO_ORIGINAL;
846 - } else if (skip_prefix(arg, "--reset-when-found=", &arg)) {
847 - if (parse_reset_when_found(arg, &reset_when_found)) {
848 - res = BISECT_FAILED;
849 - goto finish;
850 - }
851 745 } else if (!strcmp(arg, "--term-good") ||
852 746 !strcmp(arg, "--term-old")) {
853 747 i++;
@@ -885,11 +779,6 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
885 779 break;
886 780 }
887 781 }
888 - if (reset_when_found != RESET_WHEN_FOUND_NONE && no_checkout) {
889 - res = error(_("options '%s' and '%s' cannot be used together"),
890 - "--reset-when-found", "--no-checkout");
891 - goto finish;
892 - }
893 782 pathspec_pos = i;
894 783
895 784 /*
@@ -914,11 +803,9 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
914 803 */
915 804 head = refs_resolve_ref_unsafe(get_main_ref_store(the_repository),
916 805 "HEAD", 0, &head_oid, &flags);
917 - if (!head) {
806 + if (!head)
918 807 if (repo_get_oid(the_repository, "HEAD", &head_oid))
919 808 return error(_("bad HEAD - I need a HEAD"));
920 - head = "HEAD";
921 - }
922 809
923 810 /*
924 811 * Check if we are bisecting
@@ -946,7 +833,7 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
946 833 if (!repo_get_oid(the_repository, head, &head_oid) &&
947 834 !starts_with(head, "refs/heads/")) {
948 835 strbuf_reset(&start_head);
949 - strbuf_add_oid_hex(&start_head, &head_oid);
836 + strbuf_addstr(&start_head, oid_to_hex(&head_oid));
950 837 } else if (!repo_get_oid(the_repository, head, &head_oid) &&
951 838 skip_prefix(head, "refs/heads/", &head)) {
952 839 strbuf_addstr(&start_head, head);
@@ -969,10 +856,6 @@ static enum bisect_error bisect_start(struct bisect_terms *terms, int argc,
969 856 if (first_parent_only)
970 857 write_file(git_path_bisect_first_parent(), "\n");
971 858
972 - if (reset_when_found != RESET_WHEN_FOUND_NONE)
973 - write_file(git_path_bisect_reset_when_found(), "%s\n",
974 - reset_when_found_mode_name(reset_when_found));
975 -
976 859 if (no_checkout) {
977 860 if (repo_get_oid(the_repository, start_head.buf, &oid) < 0) {
978 861 res = error(_("invalid ref: '%s'"), start_head.buf);
@@ -1164,8 +1047,7 @@ static int process_replay_line(struct bisect_terms *terms, struct strbuf *line)
1164 1047 rev = word_end + strspn(word_end, " \t");
1165 1048 *word_end = '\0'; /* NUL-terminate the word */
1166 1049
1167 - if (get_terms(terms, 1))
1168 - return error(_("no terms defined"));
1050 + get_terms(terms);
1169 1051 if (check_and_set_terms(terms, p))
1170 1052 return -1;
1171 1053
@@ -1204,7 +1086,7 @@ static enum bisect_error bisect_replay(struct bisect_terms *terms, const char *f
1204 1086 if (is_empty_or_missing_file(filename))
1205 1087 return error(_("cannot read file '%s' for replaying"), filename);
1206 1088
1207 - if (bisect_clean_state())
1089 + if (bisect_reset(NULL))
1208 1090 return BISECT_FAILED;
1209 1091
1210 1092 fp = fopen(filename, "r");
@@ -1352,36 +1234,13 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1352 1234 {
1353 1235 int res = BISECT_OK;
1354 1236 struct strbuf command = STRBUF_INIT;
1355 - const char *reset_when_found_arg;
1356 1237 const char *new_state;
1357 1238 int temporary_stdout_fd, saved_stdout;
1358 1239 int is_first_run = 1;
1359 - enum reset_when_found_mode reset_when_found = RESET_WHEN_FOUND_NONE;
1360 1240
1361 1241 if (bisect_next_check(terms, NULL))
1362 1242 return BISECT_FAILED;
1363 1243
1364 - if (argc && !strcmp(argv[0], "--reset-when-found")) {
1365 - reset_when_found = RESET_WHEN_FOUND_TO_ORIGINAL;
1366 - } else if (argc && skip_prefix(argv[0], "--reset-when-found=",
1367 - &reset_when_found_arg)) {
1368 - if (parse_reset_when_found(reset_when_found_arg,
1369 - &reset_when_found))
1370 - return BISECT_FAILED;
1371 - }
1372 -
1373 - if (reset_when_found != RESET_WHEN_FOUND_NONE &&
1374 - refs_ref_exists(get_main_ref_store(the_repository), "BISECT_HEAD"))
1375 - return error(_("options '%s' and '%s' cannot be used together"),
1376 - "--reset-when-found", "--no-checkout");
1377 -
1378 - if (reset_when_found != RESET_WHEN_FOUND_NONE) {
1379 - write_file(git_path_bisect_reset_when_found(), "%s\n",
1380 - reset_when_found_mode_name(reset_when_found));
1381 - argc--;
1382 - argv++;
1383 - }
1384 -
1385 1244 if (!argc) {
1386 1245 error(_("bisect run failed: no command provided."));
1387 1246 return BISECT_FAILED;
@@ -1403,14 +1262,14 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1403 1262 int rc = verify_good(terms, command.buf);
1404 1263 is_first_run = 0;
1405 1264 if (rc < 0 || 128 <= rc) {
1406 - error(_("unable to verify %s on '%s' revision"),
1407 - command.buf, terms->term_good);
1265 + error(_("unable to verify %s on good"
1266 + " revision"), command.buf);
1408 1267 res = BISECT_FAILED;
1409 1268 break;
1410 1269 }
1411 1270 if (rc == res) {
1412 - error(_("bogus exit code %d for '%s' revision"),
1413 - rc, terms->term_good);
1271 + error(_("bogus exit code %d for good revision"),
1272 + rc);
1414 1273 res = BISECT_FAILED;
1415 1274 break;
1416 1275 }
@@ -1438,14 +1297,7 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1438 1297
1439 1298 fflush(stdout);
1440 1299 saved_stdout = dup(1);
1441 - if (saved_stdout < 0 ||
1442 - dup2(temporary_stdout_fd, 1) < 0) {
1443 - res = error_errno(_("could not duplicate stdout"));
1444 - if (saved_stdout >= 0)
1445 - close(saved_stdout);
1446 - close(temporary_stdout_fd);
1447 - break;
1448 - }
1300 + dup2(temporary_stdout_fd, 1);
1449 1301
1450 1302 res = bisect_state(terms, 1, &new_state);
1451 1303
@@ -1462,7 +1314,8 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1462 1314 puts(_("bisect run success"));
1463 1315 res = BISECT_OK;
1464 1316 } else if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
1465 - printf(_("bisect found first '%s' commit\n"), terms->term_bad);
1317 + puts(_("bisect found first bad commit"));
1318 + res = BISECT_OK;
1466 1319 } else if (res) {
1467 1320 error(_("bisect run failed: 'git bisect %s'"
1468 1321 " exited with error code %d"), new_state, res);
@@ -1479,15 +1332,10 @@ static int bisect_run(struct bisect_terms *terms, int argc, const char **argv)
1479 1332 static int cmd_bisect__reset(int argc, const char **argv, const char *prefix UNUSED,
1480 1333 struct repository *repo UNUSED)
1481 1334 {
1482 - int res;
1483 -
1484 1335 if (argc > 1)
1485 1336 return error(_("'%s' requires either no argument or a commit"),
1486 1337 "git bisect reset");
1487 - res = bisect_reset(argc ? argv[0] : NULL, false);
1488 - if (res)
1489 - return res;
1490 - return bisect_clean_state();
1338 + return bisect_reset(argc ? argv[0] : NULL);
1491 1339 }
1492 1340
1493 1341 static int cmd_bisect__terms(int argc, const char **argv, const char *prefix UNUSED,
@@ -1525,8 +1373,7 @@ static int cmd_bisect__next(int argc, const char **argv UNUSED, const char *pref
1525 1373 if (argc)
1526 1374 return error(_("'%s' requires 0 arguments"),
1527 1375 "git bisect next");
1528 - if (get_terms(&terms, 1))
1529 - return error(_("no terms defined"));
1376 + get_terms(&terms);
1530 1377 res = bisect_next(&terms, prefix);
1531 1378 free_terms(&terms);
1532 1379 return res;
@@ -1560,8 +1407,7 @@ static int cmd_bisect__skip(int argc, const char **argv, const char *prefix UNUS
1560 1407 struct bisect_terms terms = { 0 };
1561 1408
1562 1409 set_terms(&terms, "bad", "good");
1563 - if (get_terms(&terms, 1))
1564 - return error(_("no terms defined"));
1410 + get_terms(&terms);
1565 1411 res = bisect_skip(&terms, argc, argv);
1566 1412 free_terms(&terms);
1567 1413 return res;
@@ -1573,8 +1419,7 @@ static int cmd_bisect__visualize(int argc, const char **argv, const char *prefix
1573 1419 int res;
1574 1420 struct bisect_terms terms = { 0 };
1575 1421
1576 - if (get_terms(&terms, 1))
1577 - return error(_("no terms defined"));
1422 + get_terms(&terms);
1578 1423 res = bisect_visualize(&terms, argc, argv);
1579 1424 free_terms(&terms);
1580 1425 return res;
@@ -1588,8 +1433,7 @@ static int cmd_bisect__run(int argc, const char **argv, const char *prefix UNUSE
1588 1433
1589 1434 if (!argc)
1590 1435 return error(_("'%s' failed: no command provided."), "git bisect run");
1591 - if (get_terms(&terms, 1))
1592 - return error(_("no terms defined"));
1436 + get_terms(&terms);
1593 1437 res = bisect_run(&terms, argc, argv);
1594 1438 free_terms(&terms);
1595 1439 return res;
@@ -1628,14 +1472,12 @@ int cmd_bisect(int argc,
1628 1472 usage_with_options(git_bisect_usage, options);
1629 1473
1630 1474 set_terms(&terms, "bad", "good");
1631 - if (get_terms(&terms, 1))
1632 - return error(_("no terms defined"));
1475 + get_terms(&terms);
1633 1476 if (check_and_set_terms(&terms, argv[0]) ||
1634 1477 !one_of(argv[0], terms.term_good, terms.term_bad, NULL))
1635 1478 usage_msg_optf(_("unknown command: '%s'"), git_bisect_usage,
1636 1479 options, argv[0]);
1637 - else
1638 - res = bisect_state(&terms, argc, argv);
1480 + res = bisect_state(&terms, argc, argv);
1639 1481 free_terms(&terms);
1640 1482 } else {
1641 1483 argc--;
@@ -1643,15 +1485,5 @@ int cmd_bisect(int argc,
1643 1485 res = fn(argc, argv, prefix, repo);
1644 1486 }
1645 1487
1646 - if (res == BISECT_INTERNAL_SUCCESS_1ST_BAD_FOUND) {
1647 - enum reset_when_found_mode mode;
1648 -
1649 - if (read_reset_when_found(&mode))
1650 - res = BISECT_FAILED;
1651 - else if (mode != RESET_WHEN_FOUND_NONE &&
1652 - bisect_reset_when_found(mode))
1653 - res = BISECT_FAILED;
1654 - }
1655 -
1656 1488 return is_bisect_success(res) ? 0 : -res;
1657 1489 }
modified builtin/blame.c
@@ -453,36 +453,6 @@ static void determine_line_heat(struct commit_info *ci, const char **dest_color)
453 453 *dest_color = colorfield[i].col;
454 454 }
455 455
456 - static inline int maybe_putc(int c, FILE *out)
457 - {
458 - return out ? putc(c, out) : 0;
459 - }
460 -
461 - static size_t print_marks(FILE *out, const struct blame_entry *ent, int opt)
462 - {
463 - size_t len = 0;
464 -
465 - if ((ent->suspect->commit->object.flags & UNINTERESTING) &&
466 - !blank_boundary && !(opt & OUTPUT_ANNOTATE_COMPAT)) {
467 - maybe_putc('^', out);
468 - len++;
469 - }
470 - if (mark_unblamable_lines && ent->unblamable) {
471 - maybe_putc('*', out);
472 - len++;
473 - }
474 - if (mark_ignored_lines && ent->ignored) {
475 - maybe_putc('?', out);
476 - len++;
477 - }
478 - return len;
479 - }
480 -
481 - static size_t count_marks(const struct blame_entry *ent, int opt)
482 - {
483 - return print_marks(NULL, ent, opt);
484 - }
485 -
486 456 static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent,
487 457 int opt, struct blame_entry *prev_ent)
488 458 {
@@ -529,10 +499,23 @@ static void emit_other(struct blame_scoreboard *sb, struct blame_entry *ent,
529 499 if (color)
530 500 fputs(color, stdout);
531 501
532 - if ((suspect->commit->object.flags & UNINTERESTING) &&
533 - blank_boundary)
534 - memset(hex, ' ', strlen(hex));
535 - length -= print_marks(stdout, ent, opt);
502 + if (suspect->commit->object.flags & UNINTERESTING) {
503 + if (blank_boundary) {
504 + memset(hex, ' ', strlen(hex));
505 + } else if (!(opt & OUTPUT_ANNOTATE_COMPAT)) {
506 + length--;
507 + putchar('^');
508 + }
509 + }
510 +
511 + if (mark_unblamable_lines && ent->unblamable) {
512 + length--;
513 + putchar('*');
514 + }
515 + if (mark_ignored_lines && ent->ignored) {
516 + length--;
517 + putchar('?');
518 + }
536 519
537 520 printf("%.*s", (int)(length < GIT_MAX_HEXSZ ? length : GIT_MAX_HEXSZ), hex);
538 521 if (opt & OUTPUT_ANNOTATE_COMPAT) {
@@ -664,15 +647,11 @@ static void find_alignment(struct blame_scoreboard *sb, int *option)
664 647 struct blame_entry *e;
665 648 int compute_auto_abbrev = (abbrev < 0);
666 649 int auto_abbrev = DEFAULT_ABBREV;
667 - size_t max_marks_count = 0;
668 650
669 651 for (e = sb->ent; e; e = e->next) {
670 652 struct blame_origin *suspect = e->suspect;
671 653 int num;
672 - size_t marks_count = count_marks(e, *option);
673 654
674 - if (max_marks_count < marks_count)
675 - max_marks_count = marks_count;
676 655 if (compute_auto_abbrev)
677 656 auto_abbrev = update_auto_abbrev(auto_abbrev, suspect);
678 657 if (strcmp(suspect->path, sb->path))
@@ -706,12 +685,8 @@ static void find_alignment(struct blame_scoreboard *sb, int *option)
706 685 max_score_digits = decimal_width(largest_score);
707 686
708 687 if (compute_auto_abbrev)
709 - abbrev = auto_abbrev;
710 - if (abbrev < (int)the_hash_algo->hexsz) {
711 - abbrev += max_marks_count;
712 - if (abbrev > (int)the_hash_algo->hexsz)
713 - abbrev = the_hash_algo->hexsz;
714 - }
688 + /* one more abbrev length is needed for the boundary commit */
689 + abbrev = auto_abbrev + 1;
715 690 }
716 691
717 692 static void sanity_check_on_fail(struct blame_scoreboard *sb, int baa)
@@ -733,7 +708,7 @@ static unsigned parse_score(const char *arg)
733 708
734 709 static char *add_prefix(const char *prefix, const char *path)
735 710 {
736 - return prefix_path(the_repository, prefix, prefix ? strlen(prefix) : 0, path);
711 + return prefix_path(prefix, prefix ? strlen(prefix) : 0, path);
737 712 }
738 713
739 714 static int git_blame_config(const char *var, const char *value,
@@ -1038,8 +1013,6 @@ int cmd_blame(int argc,
1038 1013 case PARSE_OPT_UNKNOWN:
1039 1014 break;
1040 1015 case PARSE_OPT_HELP:
1041 - exit(0);
1042 - case PARSE_OPT_HELP_ERROR:
1043 1016 case PARSE_OPT_ERROR:
1044 1017 case PARSE_OPT_SUBCOMMAND:
1045 1018 exit(129);
@@ -1074,7 +1047,10 @@ parse_done:
1074 1047 } else if (show_progress < 0)
1075 1048 show_progress = isatty(2);
1076 1049
1077 - if (!abbrev)
1050 + if (0 < abbrev && abbrev < (int)the_hash_algo->hexsz)
1051 + /* one more abbrev length is needed for the boundary commit */
1052 + abbrev++;
1053 + else if (!abbrev)
1078 1054 abbrev = the_hash_algo->hexsz;
1079 1055
1080 1056 if (revs_file && read_ancestry(revs_file))
@@ -1187,7 +1163,7 @@ parse_done:
1187 1163
1188 1164 revs.disable_stdin = 1;
1189 1165 setup_revisions(argc, argv, &revs, NULL);
1190 - if (!revs.pending.nr && is_bare_repository(the_repository)) {
1166 + if (!revs.pending.nr && is_bare_repository()) {
1191 1167 struct commit *head_commit;
1192 1168 struct object_id head_oid;
1193 1169
modified builtin/branch.c
@@ -21,7 +21,6 @@
21 21 #include "branch.h"
22 22 #include "path.h"
23 23 #include "string-list.h"
24 - #include "strmap.h"
25 24 #include "column.h"
26 25 #include "utf8.h"
27 26 #include "ref-filter.h"
@@ -31,7 +30,7 @@
31 30 #include "commit-reach.h"
32 31
33 32 static const char * const builtin_branch_usage[] = {
34 - N_("git branch [<options>] [-r | -a] [--merged] [--no-merged] [(--forked <branch>)...]"),
33 + N_("git branch [<options>] [-r | -a] [--merged] [--no-merged]"),
35 34 N_("git branch [<options>] [-f] [--recurse-submodules] <branch-name> [<start-point>]"),
36 35 N_("git branch [<options>] [-l] [<pattern>...]"),
37 36 N_("git branch [<options>] [-r] (-d | -D) <branch-name>..."),
@@ -39,8 +38,6 @@ static const char * const builtin_branch_usage[] = {
39 38 N_("git branch [<options>] (-c | -C) [<old-branch>] <new-branch>"),
40 39 N_("git branch [<options>] [-r | -a] [--points-at]"),
41 40 N_("git branch [<options>] [-r | -a] [--format]"),
42 - N_("git branch [<options>] (--delete-merged <pattern>)... "
43 - "[<branch-pattern>...]"),
44 41 NULL
45 42 };
46 43
@@ -171,13 +168,10 @@ static int branch_merged(int kind, const char *name,
171 168 * upstream, if any, otherwise with HEAD", we should just
172 169 * return the result of the repo_in_merge_bases() above without
173 170 * any of the following code, but during the transition period,
174 - * a gentle reminder is in order. Callers that opt out of the
175 - * HEAD fallback by passing head_rev=NULL are not interested in
176 - * the reminder either: they have already established that the
177 - * branch has an upstream, so HEAD is irrelevant to the decision.
171 + * a gentle reminder is in order.
178 172 */
179 - if (head_rev && head_rev != reference_rev) {
180 - int expect = repo_in_merge_bases(the_repository, rev, head_rev);
173 + if (head_rev != reference_rev) {
174 + int expect = head_rev ? repo_in_merge_bases(the_repository, rev, head_rev) : 0;
181 175 if (expect < 0)
182 176 exit(128);
183 177 if (expect == merged)
@@ -195,32 +189,20 @@ static int branch_merged(int kind, const char *name,
195 189 return merged;
196 190 }
197 191
198 - enum delete_branch_flags {
199 - DELETE_BRANCH_FORCE = (1 << 0),
200 - DELETE_BRANCH_QUIET = (1 << 1),
201 - DELETE_BRANCH_SKIP_UNMERGED = (1 << 2),
202 - DELETE_BRANCH_NO_HEAD_FALLBACK = (1 << 3),
203 - DELETE_BRANCH_DRY_RUN = (1 << 4),
204 - };
205 -
206 192 static int check_branch_commit(const char *branchname, const char *refname,
207 193 const struct object_id *oid, struct commit *head_rev,
208 - int kinds, unsigned int flags)
194 + int kinds, int force)
209 195 {
210 196 struct commit *rev = lookup_commit_reference(the_repository, oid);
211 - if (!(flags & DELETE_BRANCH_FORCE) && !rev) {
197 + if (!force && !rev) {
212 198 error(_("couldn't look up commit object for '%s'"), refname);
213 199 return -1;
214 200 }
215 - if (!(flags & DELETE_BRANCH_FORCE) &&
216 - !branch_merged(kinds, branchname, rev, head_rev)) {
217 - if (!(flags & DELETE_BRANCH_SKIP_UNMERGED)) {
218 - error(_("the branch '%s' is not fully merged"),
219 - branchname);
220 - advise_if_enabled(ADVICE_FORCE_DELETE_BRANCH,
221 - _("If you are sure you want to delete it, "
222 - "run 'git branch -D %s'"), branchname);
223 - }
201 + if (!force && !branch_merged(kinds, branchname, rev, head_rev)) {
202 + error(_("the branch '%s' is not fully merged"), branchname);
203 + advise_if_enabled(ADVICE_FORCE_DELETE_BRANCH,
204 + _("If you are sure you want to delete it, "
205 + "run 'git branch -D %s'"), branchname);
224 206 return -1;
225 207 }
226 208 return 0;
@@ -235,8 +217,8 @@ static void delete_branch_config(const char *branchname)
235 217 strbuf_release(&buf);
236 218 }
237 219
238 - static int delete_branches(int argc, const char **argv, int kinds,
239 - unsigned int flags)
220 + static int delete_branches(int argc, const char **argv, int force, int kinds,
221 + int quiet)
240 222 {
241 223 struct commit *head_rev = NULL;
242 224 struct object_id oid;
@@ -259,7 +241,7 @@ static int delete_branches(int argc, const char **argv, int kinds,
259 241 remote_branch = 1;
260 242 allowed_interpret = INTERPRET_BRANCH_REMOTE;
261 243
262 - flags |= DELETE_BRANCH_FORCE;
244 + force = 1;
263 245 break;
264 246 case FILTER_REFS_BRANCHES:
265 247 fmt = "refs/heads/%s";
@@ -270,28 +252,19 @@ static int delete_branches(int argc, const char **argv, int kinds,
270 252 }
271 253 branch_name_pos = strcspn(fmt, "%");
272 254
273 - if (!(flags & DELETE_BRANCH_FORCE) &&
274 - !(flags & DELETE_BRANCH_NO_HEAD_FALLBACK))
255 + if (!force)
275 256 head_rev = lookup_commit_reference(the_repository, &head_oid);
276 257
277 258 for (i = 0; i < argc; i++, strbuf_reset(&bname)) {
278 259 char *target = NULL;
279 - int ref_flags = 0;
260 + int flags = 0;
280 261
281 - copy_branchname(the_repository, &bname,
282 - argv[i], allowed_interpret);
262 + copy_branchname(&bname, argv[i], allowed_interpret);
283 263 free(name);
284 264 name = mkpathdup(fmt, bname.buf);
285 265
286 266 if (kinds == FILTER_REFS_BRANCHES) {
287 267 const char *path;
288 - if ((path = branch_bisecting(name))) {
289 - error(_("cannot delete branch '%s' "
290 - "used by worktree at '%s' for bisect"),
291 - bname.buf, path);
292 - ret = 1;
293 - continue;
294 - }
295 268 if ((path = branch_checked_out(name))) {
296 269 error(_("cannot delete branch '%s' "
297 270 "used by worktree at '%s'"),
@@ -306,7 +279,7 @@ static int delete_branches(int argc, const char **argv, int kinds,
306 279 RESOLVE_REF_READING
307 280 | RESOLVE_REF_NO_RECURSE
308 281 | RESOLVE_REF_ALLOW_BAD_NAME,
309 - &oid, &ref_flags);
282 + &oid, &flags);
310 283 if (!target) {
311 284 if (remote_branch) {
312 285 error(_("remote-tracking branch '%s' not found"), bname.buf);
@@ -318,7 +291,7 @@ static int delete_branches(int argc, const char **argv, int kinds,
318 291 | RESOLVE_REF_NO_RECURSE
319 292 | RESOLVE_REF_ALLOW_BAD_NAME,
320 293 &oid,
321 - &ref_flags);
294 + &flags);
322 295 FREE_AND_NULL(virtual_name);
323 296
324 297 if (virtual_target)
@@ -333,39 +306,31 @@ static int delete_branches(int argc, const char **argv, int kinds,
333 306 continue;
334 307 }
335 308
336 - if (!(ref_flags & (REF_ISSYMREF|REF_ISBROKEN)) &&
309 + if (!(flags & (REF_ISSYMREF|REF_ISBROKEN)) &&
337 310 check_branch_commit(bname.buf, name, &oid, head_rev, kinds,
338 - flags)) {
339 - if (!(flags & DELETE_BRANCH_SKIP_UNMERGED))
340 - ret = 1;
311 + force)) {
312 + ret = 1;
341 313 goto next;
342 314 }
343 315
344 316 item = string_list_append(&refs_to_delete, name);
345 - item->util = xstrdup((ref_flags & REF_ISBROKEN) ? "broken"
346 - : (ref_flags & REF_ISSYMREF) ? target
317 + item->util = xstrdup((flags & REF_ISBROKEN) ? "broken"
318 + : (flags & REF_ISSYMREF) ? target
347 319 : repo_find_unique_abbrev(the_repository, &oid, DEFAULT_ABBREV));
348 320
349 321 next:
350 322 free(target);
351 323 }
352 324
353 - if (!(flags & DELETE_BRANCH_DRY_RUN) &&
354 - refs_delete_refs(get_main_ref_store(the_repository), NULL, &refs_to_delete, REF_NO_DEREF))
325 + if (refs_delete_refs(get_main_ref_store(the_repository), NULL, &refs_to_delete, REF_NO_DEREF))
355 326 ret = 1;
356 327
357 328 for_each_string_list_item(item, &refs_to_delete) {
358 329 char *describe_ref = item->util;
359 330 char *name = item->string;
360 - if (flags & DELETE_BRANCH_DRY_RUN) {
361 - if (!(flags & DELETE_BRANCH_QUIET))
362 - printf(remote_branch
363 - ? _("Would delete remote-tracking branch %s (was %s).\n")
364 - : _("Would delete branch %s (was %s).\n"),
365 - name + branch_name_pos, describe_ref);
366 - } else if (!refs_ref_exists(get_main_ref_store(the_repository), name)) {
331 + if (!refs_ref_exists(get_main_ref_store(the_repository), name)) {
367 332 char *refname = name + branch_name_pos;
368 - if (!(flags & DELETE_BRANCH_QUIET))
333 + if (!quiet)
369 334 printf(remote_branch
370 335 ? _("Deleted remote-tracking branch %s (was %s).\n")
371 336 : _("Deleted branch %s (was %s).\n"),
@@ -614,9 +579,9 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
614 579 const char *interpreted_oldname = NULL;
615 580 const char *interpreted_newname = NULL;
616 581 int recovery = 0, oldref_usage = 0;
617 - struct worktree **worktrees = get_worktrees(the_repository);
582 + struct worktree **worktrees = get_worktrees();
618 583
619 - if (check_branch_ref(the_repository, &oldref, oldname)) {
584 + if (check_branch_ref(&oldref, oldname)) {
620 585 /*
621 586 * Bad name --- this could be an attempt to rename a
622 587 * ref that we used to allow to be created by accident.
@@ -708,208 +673,6 @@ static void copy_or_rename_branch(const char *oldname, const char *newname, int
708 673 free_worktrees(worktrees);
709 674 }
710 675
711 - static int parse_opt_forked(const struct option *opt, const char *arg, int unset)
712 - {
713 - struct ref_filter *filter = opt->value;
714 -
715 - BUG_ON_OPT_NEG(unset);
716 - if (ref_filter_forked_add(filter, arg) < 0)
717 - die(_("'%s' is not a valid branch or pattern"), arg);
718 - return 0;
719 - }
720 -
721 - struct stacked_branch_data {
722 - struct strset *deletable_branch_names;
723 - struct strset *protected_branch_names;
724 - };
725 -
726 - static int collect_stacked_branch_base(const struct reference *ref,
727 - void *cb_data)
728 - {
729 - struct stacked_branch_data *data = cb_data;
730 - const char *branch_name;
731 - struct branch *branch;
732 - const char *upstream_refname;
733 - const char *upstream_branch_name;
734 -
735 - if (!skip_prefix(ref->name, "refs/heads/", &branch_name))
736 - BUG("expected local branch ref, got '%s'", ref->name);
737 - if (strset_contains(data->deletable_branch_names, branch_name))
738 - return 0;
739 -
740 - branch = branch_get(branch_name);
741 - upstream_refname = branch_get_upstream(branch, NULL);
742 - if (!upstream_refname ||
743 - !skip_prefix(upstream_refname, "refs/heads/",
744 - &upstream_branch_name) ||
745 - !strset_contains(data->deletable_branch_names,
746 - upstream_branch_name))
747 - return 0;
748 -
749 - strset_add(data->protected_branch_names, upstream_branch_name);
750 - return 0;
751 - }
752 -
753 - static void protect_stacked_branch_bases(struct ref_store *refs,
754 - struct strset *deletable_branch_names,
755 - struct strset *protected_branch_names)
756 - {
757 - struct stacked_branch_data data = {
758 - .deletable_branch_names = deletable_branch_names,
759 - .protected_branch_names = protected_branch_names,
760 - };
761 - struct refs_for_each_ref_options opts = {
762 - .prefix = "refs/heads/",
763 - };
764 - struct hashmap_iter iter;
765 - struct strmap_entry *entry;
766 -
767 - refs_for_each_ref_ext(refs, collect_stacked_branch_base, &data, &opts);
768 -
769 - strset_for_each_entry(protected_branch_names, &iter, entry)
770 - strset_remove(deletable_branch_names, entry->key);
771 - }
772 -
773 - static void clear_deleted_upstreams(struct strset *protected_branch_names,
774 - struct strset *deletable_branch_names)
775 - {
776 - struct strbuf key = STRBUF_INIT;
777 - struct hashmap_iter iter;
778 - struct strmap_entry *entry;
779 -
780 - strset_for_each_entry(protected_branch_names, &iter, entry) {
781 - struct branch *branch = branch_get(entry->key);
782 - const char *upstream_refname = branch_get_upstream(branch, NULL);
783 - const char *upstream_branch_name;
784 -
785 - if (!upstream_refname ||
786 - !skip_prefix(upstream_refname, "refs/heads/",
787 - &upstream_branch_name) ||
788 - !strset_contains(deletable_branch_names,
789 - upstream_branch_name))
790 - continue;
791 -
792 - strbuf_addf(&key, "branch.%s.merge", branch->name);
793 - repo_config_set_gently(the_repository, key.buf, NULL);
794 - strbuf_reset(&key);
795 - strbuf_addf(&key, "branch.%s.remote", branch->name);
796 - repo_config_set_gently(the_repository, key.buf, NULL);
797 - strbuf_reset(&key);
798 - }
799 -
800 - strbuf_release(&key);
801 - }
802 -
803 - static int branch_pushes_to_upstream(struct branch *branch,
804 - const char *upstream)
805 - {
806 - struct remote *remote = remote_get(remote_for_branch(branch, NULL));
807 - char *push_refname = NULL;
808 - char *tracking = NULL;
809 - int ret = 0;
810 -
811 - if (!remote)
812 - return 0;
813 - if (remote->push.nr)
814 - push_refname = apply_refspecs(&remote->push, branch->refname);
815 - else
816 - push_refname = xstrdup(branch->refname);
817 - if (push_refname)
818 - tracking = apply_refspecs(&remote->fetch, push_refname);
819 - if (tracking && !strcmp(tracking, upstream))
820 - ret = 1;
821 -
822 - free(push_refname);
823 - free(tracking);
824 - return ret;
825 - }
826 -
827 - static int delete_merged_branches(const struct strvec *upstreams,
828 - const char **argv, unsigned int flags)
829 - {
830 - struct ref_store *refs = get_main_ref_store(the_repository);
831 - struct ref_filter filter = REF_FILTER_INIT;
832 - struct ref_array candidates = { 0 };
833 - struct strset deletable_branch_names = STRSET_INIT;
834 - struct strset protected_branch_names = STRSET_INIT;
835 - struct strvec branches_to_delete = STRVEC_INIT;
836 - struct strbuf key = STRBUF_INIT;
837 - struct hashmap_iter iter;
838 - struct strmap_entry *entry;
839 - int ret = 0;
840 -
841 - for (size_t i = 0; i < upstreams->nr; i++)
842 - if (ref_filter_forked_add(&filter, upstreams->v[i]) < 0)
843 - die(_("'%s' is not a valid branch or pattern"),
844 - upstreams->v[i]);
845 -
846 - filter.kind = FILTER_REFS_BRANCHES;
847 - filter.name_patterns = argv;
848 - filter_refs(&candidates, &filter, filter.kind);
849 -
850 - for (int i = 0; i < candidates.nr; i++) {
851 - const char *branch_refname = candidates.items[i]->refname;
852 - const char *branch_name;
853 - struct branch *branch;
854 - const char *upstream_refname;
855 - int opt_out;
856 -
857 - if (!skip_prefix(branch_refname, "refs/heads/", &branch_name))
858 - BUG("filter returned non-branch ref '%s'", branch_refname);
859 - if (branch_checked_out(branch_refname))
860 - continue;
861 -
862 - branch = branch_get(branch_name);
863 - upstream_refname = branch_get_upstream(branch, NULL);
864 - if (!upstream_refname || !refs_ref_exists(refs, upstream_refname))
865 - continue;
866 - if (branch_pushes_to_upstream(branch, upstream_refname))
867 - continue;
868 - if (check_branch_commit(branch_name, branch_name,
869 - &candidates.items[i]->objectname, NULL,
870 - FILTER_REFS_BRANCHES, DELETE_BRANCH_SKIP_UNMERGED))
871 - continue;
872 -
873 - strbuf_reset(&key);
874 - strbuf_addf(&key, "branch.%s.deletemerged", branch_name);
875 - if (!repo_config_get_bool(the_repository, key.buf, &opt_out) &&
876 - !opt_out) {
877 - if (!(flags & DELETE_BRANCH_QUIET))
878 - fprintf(stderr,
879 - _("Skipping '%s' (branch.%s.deleteMerged is false)\n"),
880 - branch_name, branch_name);
881 - continue;
882 - }
883 -
884 - strset_add(&deletable_branch_names, branch_name);
885 - }
886 -
887 - protect_stacked_branch_bases(refs, &deletable_branch_names,
888 - &protected_branch_names);
889 -
890 - strset_for_each_entry(&deletable_branch_names, &iter, entry)
891 - strvec_push(&branches_to_delete, entry->key);
892 -
893 - if (branches_to_delete.nr)
894 - ret = delete_branches(branches_to_delete.nr, branches_to_delete.v,
895 - FILTER_REFS_BRANCHES,
896 - DELETE_BRANCH_SKIP_UNMERGED |
897 - DELETE_BRANCH_NO_HEAD_FALLBACK |
898 - flags);
899 -
900 - if (!ret && !(flags & DELETE_BRANCH_DRY_RUN))
901 - clear_deleted_upstreams(&protected_branch_names,
902 - &deletable_branch_names);
903 -
904 - strbuf_release(&key);
905 - strvec_clear(&branches_to_delete);
906 - strset_clear(&protected_branch_names);
907 - strset_clear(&deletable_branch_names);
908 - ref_array_clear(&candidates);
909 - ref_filter_clear(&filter);
910 - return ret;
911 - }
912 -
913 676 static GIT_PATH_FUNC(edit_description, "EDIT_DESCRIPTION")
914 677
915 678 static int edit_branch_description(const char *branch_name)
@@ -943,29 +706,6 @@ static int edit_branch_description(const char *branch_name)
943 706 return 0;
944 707 }
945 708
946 - static void die_if_upstream_looks_like_remote(const char *new_upstream, const char *branch_name)
947 - {
948 - struct strbuf remote_ref = STRBUF_INIT;
949 - int code;
950 -
951 - if (strchr(new_upstream, '/') ||
952 - !remote_is_configured(remote_get(new_upstream), 0))
953 - return;
954 -
955 - strbuf_addf(&remote_ref, "refs/remotes/%s/%s", new_upstream, branch_name);
956 - if (!refs_ref_exists(get_main_ref_store(the_repository), remote_ref.buf)) {
957 - strbuf_release(&remote_ref);
958 - return;
959 - }
960 -
961 - code = die_message(_("--set-upstream-to takes a single <remote>/<branch> argument"));
962 - advise_if_enabled(ADVICE_SET_UPSTREAM_FAILURE,
963 - _("Did you mean to use: git branch --set-upstream-to=%s/%s?"),
964 - new_upstream, branch_name);
965 - strbuf_release(&remote_ref);
966 - exit(code);
967 - }
968 -
969 709 int cmd_branch(int argc,
970 710 const char **argv,
971 711 const char *prefix,
@@ -974,8 +714,6 @@ int cmd_branch(int argc,
974 714 /* possible actions */
975 715 int delete = 0, rename = 0, copy = 0, list = 0,
976 716 unset_upstream = 0, show_current = 0, edit_description = 0;
977 - struct strvec delete_merged = STRVEC_INIT;
978 - int dry_run = 0;
979 717 const char *new_upstream = NULL;
980 718 int noncreate_actions = 0;
981 719 /* possible options */
@@ -1029,17 +767,9 @@ int cmd_branch(int argc,
1029 767 OPT_BOOL(0, "create-reflog", &reflog, N_("create the branch's reflog")),
1030 768 OPT_BOOL(0, "edit-description", &edit_description,
1031 769 N_("edit the description for the branch")),
1032 - OPT_CALLBACK_F(0, "delete-merged", &delete_merged, N_("pattern"),
1033 - N_("delete merged branches whose upstream matches <pattern> (repeatable)"),
1034 - PARSE_OPT_NONEG, parse_opt_strvec),
1035 - OPT_BOOL(0, "dry-run", &dry_run,
1036 - N_("with --delete-merged, only print which branches would be deleted")),
1037 770 OPT__FORCE(&force, N_("force creation, move/rename, deletion"), PARSE_OPT_NOCOMPLETE),
1038 771 OPT_MERGED(&filter, N_("print only branches that are merged")),
1039 772 OPT_NO_MERGED(&filter, N_("print only branches that are not merged")),
1040 - OPT_CALLBACK_F(0, "forked", &filter, N_("branch"),
1041 - N_("print only branches whose upstream matches <branch> (repeatable)"),
1042 - PARSE_OPT_NONEG, parse_opt_forked),
1043 773 OPT_COLUMN(0, "column", &colopts, N_("list branches in columns")),
1044 774 OPT_REF_SORT(&sorting_options),
1045 775 OPT_CALLBACK(0, "points-at", &filter.points_at, N_("object"),
@@ -1081,24 +811,19 @@ int cmd_branch(int argc,
1081 811 0);
1082 812
1083 813 if (!delete && !rename && !copy && !edit_description && !new_upstream &&
1084 - !show_current && !unset_upstream && !delete_merged.nr &&
1085 - argc == 0)
814 + !show_current && !unset_upstream && argc == 0)
1086 815 list = 1;
1087 816
1088 817 if (filter.with_commit || filter.no_commit ||
1089 - filter.reachable_from || filter.unreachable_from ||
1090 - filter.points_at.nr || filter.forked.nr)
818 + filter.reachable_from || filter.unreachable_from || filter.points_at.nr)
1091 819 list = 1;
1092 820
1093 821 noncreate_actions = !!delete + !!rename + !!copy + !!new_upstream +
1094 822 !!show_current + !!list + !!edit_description +
1095 - !!unset_upstream + !!delete_merged.nr;
823 + !!unset_upstream;
1096 824 if (noncreate_actions > 1)
1097 825 usage_with_options(builtin_branch_usage, options);
1098 826
1099 - if (dry_run && !delete_merged.nr)
1100 - die(_("--dry-run requires --delete-merged"));
1101 -
1102 827 if (recurse_submodules_explicit) {
1103 828 if (!submodule_propagate_branches)
1104 829 die(_("branch with --recurse-submodules can only be used if submodule.propagateBranches is enabled"));
@@ -1133,14 +858,7 @@ int cmd_branch(int argc,
1133 858 if (delete) {
1134 859 if (!argc)
1135 860 die(_("branch name required"));
1136 - ret = delete_branches(argc, argv, filter.kind,
1137 - (delete > 1 ? DELETE_BRANCH_FORCE : 0) |
1138 - (quiet ? DELETE_BRANCH_QUIET : 0));
1139 - goto out;
1140 - } else if (delete_merged.nr) {
1141 - ret = delete_merged_branches(&delete_merged, argv,
1142 - (quiet ? DELETE_BRANCH_QUIET : 0) |
1143 - (dry_run ? DELETE_BRANCH_DRY_RUN : 0));
861 + ret = delete_branches(argc, argv, delete > 1, filter.kind, quiet);
1144 862 goto out;
1145 863 } else if (show_current) {
1146 864 print_current_branch_name();
@@ -1180,8 +898,7 @@ int cmd_branch(int argc,
1180 898 die(_("cannot give description to detached HEAD"));
1181 899 branch_name = head;
1182 900 } else if (argc == 1) {
1183 - copy_branchname(the_repository, &buf, argv[0],
1184 - INTERPRET_BRANCH_LOCAL);
901 + copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
1185 902 branch_name = buf.buf;
1186 903 } else {
1187 904 die(_("cannot edit description of more than one branch"));
@@ -1224,8 +941,7 @@ int cmd_branch(int argc,
1224 941 if (!argc)
1225 942 branch = branch_get(NULL);
1226 943 else if (argc == 1) {
1227 - copy_branchname(the_repository, &buf, argv[0],
1228 - INTERPRET_BRANCH_LOCAL);
944 + copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
1229 945 branch = branch_get(buf.buf);
1230 946 } else
1231 947 die(_("too many arguments to set new upstream"));
@@ -1241,15 +957,6 @@ int cmd_branch(int argc,
1241 957 if (!refs_ref_exists(get_main_ref_store(the_repository), branch->refname)) {
1242 958 if (!argc || branch_checked_out(branch->refname))
1243 959 die(_("no commit on branch '%s' yet"), branch->name);
1244 - /*
1245 - * Check the advice up front to avoid the ref
1246 - * lookups when the hint is off. The helper still
1247 - * calls advise_if_enabled() so the hint carries the
1248 - * standard "disable this message" instructions.
1249 - */
1250 - if (argc == 1 &&
1251 - advice_enabled(ADVICE_SET_UPSTREAM_FAILURE))
1252 - die_if_upstream_looks_like_remote(new_upstream, argv[0]);
1253 960 die(_("branch '%s' does not exist"), branch->name);
1254 961 }
1255 962
@@ -1264,8 +971,7 @@ int cmd_branch(int argc,
1264 971 if (!argc)
1265 972 branch = branch_get(NULL);
1266 973 else if (argc == 1) {
1267 - copy_branchname(the_repository, &buf, argv[0],
1268 - INTERPRET_BRANCH_LOCAL);
974 + copy_branchname(&buf, argv[0], INTERPRET_BRANCH_LOCAL);
1269 975 branch = branch_get(buf.buf);
1270 976 } else
1271 977 die(_("too many arguments to unset upstream"));
@@ -1313,7 +1019,6 @@ int cmd_branch(int argc,
1313 1019 ret = 0;
1314 1020
1315 1021 out:
1316 - strvec_clear(&delete_merged);
1317 1022 string_list_clear(&sorting_options, 0);
1318 1023 return ret;
1319 1024 }
modified builtin/bundle.c
@@ -68,25 +68,32 @@ static int parse_options_cmd_bundle(int argc,
68 68 }
69 69
70 70 static int cmd_bundle_create(int argc, const char **argv, const char *prefix,
71 - struct repository *repo UNUSED)
72 - {
73 - int progress = isatty(STDERR_FILENO);
71 + struct repository *repo UNUSED) {
72 + struct strvec pack_opts = STRVEC_INIT;
74 73 int version = -1;
74 + int ret;
75 75 struct option options[] = {
76 - OPT_NEGBIT('q', "quiet", &progress,
77 - N_("do not show progress meter"), 1),
78 - OPT_BIT(0, "progress", &progress,
79 - N_("show progress meter"), 1),
80 - OPT_BIT_F(0, "all-progress", &progress,
81 - N_("historical; same as --progress"), 1,
82 - PARSE_OPT_HIDDEN),
83 - OPT_NOOP_NOARG(0, "all-progress-implied"),
76 + OPT_PASSTHRU_ARGV('q', "quiet", &pack_opts, NULL,
77 + N_("do not show progress meter"),
78 + PARSE_OPT_NOARG),
79 + OPT_PASSTHRU_ARGV(0, "progress", &pack_opts, NULL,
80 + N_("show progress meter"),
81 + PARSE_OPT_NOARG),
82 + OPT_PASSTHRU_ARGV(0, "all-progress", &pack_opts, NULL,
83 + N_("historical; same as --progress"),
84 + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),
85 + OPT_PASSTHRU_ARGV(0, "all-progress-implied", &pack_opts, NULL,
86 + N_("historical; does nothing"),
87 + PARSE_OPT_NOARG | PARSE_OPT_HIDDEN),
84 88 OPT_INTEGER(0, "version", &version,
85 89 N_("specify bundle format version")),
86 90 OPT_END()
87 91 };
88 92 char *bundle_file;
89 - int ret;
93 +
94 + if (isatty(STDERR_FILENO))
95 + strvec_push(&pack_opts, "--progress");
96 + strvec_push(&pack_opts, "--all-progress-implied");
90 97
91 98 argc = parse_options_cmd_bundle(argc, argv, prefix,
92 99 builtin_bundle_create_usage, options, &bundle_file);
@@ -94,7 +101,8 @@ static int cmd_bundle_create(int argc, const char **argv, const char *prefix,
94 101
95 102 if (!startup_info->have_repository)
96 103 die(_("Need a repository to create a bundle."));
97 - ret = !!create_bundle(the_repository, bundle_file, argc, argv, version, progress);
104 + ret = !!create_bundle(the_repository, bundle_file, argc, argv, &pack_opts, version);
105 + strvec_clear(&pack_opts);
98 106 free(bundle_file);
99 107 return ret;
100 108 }
modified builtin/cat-file.c
@@ -20,6 +20,7 @@
20 20 #include "userdiff.h"
21 21 #include "oid-array.h"
22 22 #include "packfile.h"
23 + #include "pack-bitmap.h"
23 24 #include "object-file.h"
24 25 #include "object-name.h"
25 26 #include "odb.h"
@@ -28,23 +29,6 @@
28 29 #include "promisor-remote.h"
29 30 #include "mailmap.h"
30 31 #include "write-or-die.h"
31 - #include "alias.h"
32 - #include "remote.h"
33 - #include "transport.h"
34 - #include "fetch-object-info.h"
35 -
36 - /*
37 - * Maximum length for a remote URL. While no universal standard exists,
38 - * 8K is assumed to be a reasonable limit.
39 - */
40 - #define MAX_REMOTE_URL_LEN (8 * 1024)
41 -
42 - /* Maximum number of objects allowed in a single remote-object-info request. */
43 - #define MAX_ALLOWED_OBJ_LIMIT 10000
44 -
45 - /* Maximum input size permitted for the remote-object-info command. */
46 - #define MAX_REMOTE_OBJ_INFO_LINE \
47 - (MAX_REMOTE_URL_LEN + MAX_ALLOWED_OBJ_LIMIT * (GIT_MAX_HEXSZ + 1))
48 32
49 33 enum batch_mode {
50 34 BATCH_MODE_CONTENTS,
@@ -73,20 +57,6 @@ static int use_mailmap;
73 57
74 58 static char *replace_idents_using_mailmap(char *, size_t *);
75 59
76 - /*
77 - * The mailmap is initialized with .strdup_strings set to 0,
78 - * but read_mailmap() sets the bit to 1 (this is true even when
79 - * not a single mailmap entry is read), so it can be used for
80 - * lazy loading.
81 - */
82 - static void load_mailmap(void)
83 - {
84 - if (mailmap.strdup_strings)
85 - return;
86 -
87 - read_mailmap(the_repository, &mailmap);
88 - }
89 -
90 60 static char *replace_idents_using_mailmap(char *object_buf, size_t *size)
91 61 {
92 62 struct strbuf sb = STRBUF_INIT;
@@ -100,7 +70,7 @@ static char *replace_idents_using_mailmap(char *object_buf, size_t *size)
100 70
101 71 static int filter_object(const char *path, unsigned mode,
102 72 const struct object_id *oid,
103 - char **buf, size_t *size)
73 + char **buf, unsigned long *size)
104 74 {
105 75 enum object_type type;
106 76
@@ -136,7 +106,7 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
136 106 struct object_id oid;
137 107 enum object_type type;
138 108 char *buf;
139 - size_t size;
109 + unsigned long size;
140 110 struct object_context obj_context = {0};
141 111 struct object_info oi = OBJECT_INFO_INIT;
142 112 unsigned flags = OBJECT_INFO_LOOKUP_REPLACE;
@@ -179,8 +149,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
179 149 if (odb_read_object_info_extended(the_repository->objects, &oid, &oi, flags) < 0)
180 150 die("git cat-file: could not get object info");
181 151
182 - if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG))
183 - buf = replace_idents_using_mailmap(buf, &size);
152 + if (use_mailmap && (type == OBJ_COMMIT || type == OBJ_TAG)) {
153 + size_t s = size;
154 + buf = replace_idents_using_mailmap(buf, &s);
155 + size = cast_size_t_to_ulong(s);
156 + }
184 157
185 158 printf("%"PRIuMAX"\n", (uintmax_t)size);
186 159 ret = 0;
@@ -201,15 +174,9 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
201 174 break;
202 175
203 176 case 'c':
204 - {
205 - unsigned long size_ul = 0;
206 - int textconv_ret = textconv_object(the_repository, path,
207 - obj_context.mode, &oid, 1,
208 - &buf, &size_ul);
209 - size = size_ul;
210 - if (textconv_ret)
177 + if (textconv_object(the_repository, path, obj_context.mode,
178 + &oid, 1, &buf, &size))
211 179 break;
212 - }
213 180 /* else fallthrough */
214 181
215 182 case 'p':
@@ -235,8 +202,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
235 202 if (!buf)
236 203 die("Cannot read object %s", obj_name);
237 204
238 - if (use_mailmap)
239 - buf = replace_idents_using_mailmap(buf, &size);
205 + if (use_mailmap) {
206 + size_t s = size;
207 + buf = replace_idents_using_mailmap(buf, &s);
208 + size = cast_size_t_to_ulong(s);
209 + }
240 210
241 211 /* otherwise just spit out the data */
242 212 break;
@@ -279,8 +249,11 @@ static int cat_one_file(int opt, const char *exp_type, const char *obj_name)
279 249 buf = odb_read_object_peeled(the_repository->objects, &oid,
280 250 exp_type_id, &size, NULL);
281 251
282 - if (use_mailmap)
283 - buf = replace_idents_using_mailmap(buf, &size);
252 + if (use_mailmap) {
253 + size_t s = size;
254 + buf = replace_idents_using_mailmap(buf, &s);
255 + size = cast_size_t_to_ulong(s);
256 + }
284 257 break;
285 258 }
286 259 default:
@@ -301,7 +274,7 @@ cleanup:
301 274 struct expand_data {
302 275 struct object_id oid;
303 276 enum object_type type;
304 - size_t size;
277 + unsigned long size;
305 278 unsigned short mode;
306 279 off_t disk_size;
307 280 const char *rest;
@@ -333,24 +306,8 @@ struct expand_data {
333 306 * optimized out.
334 307 */
335 308 unsigned skip_object_info : 1;
336 -
337 - /*
338 - * Flags about when an object info is being fetched from remote.
339 - */
340 - unsigned is_remote:1;
341 -
342 - /*
343 - * List of atoms (i.e. "objectsize") that the server supports. Built
344 - * from the server's object-info advertised capabilities.
345 - */
346 - struct string_list remote_allowed_atoms;
347 309 };
348 -
349 - #define EXPAND_DATA_INIT { \
350 - .mode = S_IFINVALID, \
351 - .type = OBJ_BAD, \
352 - .remote_allowed_atoms = STRING_LIST_INIT_NODUP, \
353 - }
310 + #define EXPAND_DATA_INIT { .mode = S_IFINVALID }
354 311
355 312 static int is_atom(const char *atom, const char *s, int slen)
356 313 {
@@ -361,36 +318,24 @@ static int is_atom(const char *atom, const char *s, int slen)
361 318 static int expand_atom(struct strbuf *sb, const char *atom, int len,
362 319 struct expand_data *data)
363 320 {
364 - if (data->is_remote) {
365 - size_t i;
366 - for (i = 0; i < data->remote_allowed_atoms.nr; i++)
367 - if (is_atom(data->remote_allowed_atoms.items[i].string,
368 - atom, len))
369 - break;
370 - if (i == data->remote_allowed_atoms.nr)
371 - return 1;
372 - }
373 -
374 321 if (is_atom("objectname", atom, len)) {
375 322 if (!data->mark_query)
376 - strbuf_add_oid_hex(sb, &data->oid);
323 + strbuf_addstr(sb, oid_to_hex(&data->oid));
377 324 } else if (is_atom("objecttype", atom, len)) {
378 - if (data->mark_query) {
325 + if (data->mark_query)
379 326 data->info.typep = &data->type;
380 - } else {
381 - const char *t = type_name(data->type);
382 - strbuf_addstr(sb, t ? t : "");
383 - }
327 + else
328 + strbuf_addstr(sb, type_name(data->type));
384 329 } else if (is_atom("objectsize", atom, len)) {
385 330 if (data->mark_query)
386 331 data->info.sizep = &data->size;
387 332 else
388 - strbuf_add_uint(sb, data->size);
333 + strbuf_addf(sb, "%"PRIuMAX , (uintmax_t)data->size);
389 334 } else if (is_atom("objectsize:disk", atom, len)) {
390 335 if (data->mark_query)
391 336 data->info.disk_sizep = &data->disk_size;
392 337 else
393 - strbuf_add_uint(sb, data->disk_size);
338 + strbuf_addf(sb, "%"PRIuMAX, (uintmax_t)data->disk_size);
394 339 } else if (is_atom("rest", atom, len)) {
395 340 if (data->mark_query)
396 341 data->split_on_whitespace = 1;
@@ -400,7 +345,8 @@ static int expand_atom(struct strbuf *sb, const char *atom, int len,
400 345 if (data->mark_query)
401 346 data->info.delta_base_oid = &data->delta_base_oid;
402 347 else
403 - strbuf_add_oid_hex(sb, &data->delta_base_oid);
348 + strbuf_addstr(sb,
349 + oid_to_hex(&data->delta_base_oid));
404 350 } else if (is_atom("objectmode", atom, len)) {
405 351 if (!data->mark_query && !(S_IFINVALID == data->mode))
406 352 strbuf_addf(sb, "%06o", data->mode);
@@ -445,7 +391,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
445 391 fflush(stdout);
446 392 if (opt->transform_mode) {
447 393 char *contents;
448 - size_t size;
394 + unsigned long size;
449 395
450 396 if (!data->rest)
451 397 die("missing path for '%s'", oid_to_hex(oid));
@@ -457,12 +403,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
457 403 oid_to_hex(oid), data->rest);
458 404 } else if (opt->transform_mode == 'c') {
459 405 enum object_type type;
460 - unsigned long size_ul = 0;
461 - if (textconv_object(the_repository,
462 - data->rest, 0100644, oid,
463 - 1, &contents, &size_ul))
464 - size = size_ul;
465 - else
406 + if (!textconv_object(the_repository,
407 + data->rest, 0100644, oid,
408 + 1, &contents, &size))
466 409 contents = odb_read_object(the_repository->objects,
467 410 oid, &type, &size);
468 411 if (!contents)
@@ -478,7 +421,7 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
478 421 }
479 422 else {
480 423 enum object_type type;
481 - size_t size;
424 + unsigned long size;
482 425 void *contents;
483 426
484 427 contents = odb_read_object(the_repository->objects, oid,
@@ -486,8 +429,11 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
486 429 if (!contents)
487 430 die("object %s disappeared", oid_to_hex(oid));
488 431
489 - if (use_mailmap)
490 - contents = replace_idents_using_mailmap(contents, &size);
432 + if (use_mailmap) {
433 + size_t s = size;
434 + contents = replace_idents_using_mailmap(contents, &s);
435 + size = cast_size_t_to_ulong(s);
436 + }
491 437
492 438 if (type != data->type)
493 439 die("object %s changed type!?", oid_to_hex(oid));
@@ -502,12 +448,9 @@ static void print_object_or_die(struct batch_options *opt, struct expand_data *d
502 448 static void print_default_format(struct strbuf *scratch, struct expand_data *data,
503 449 struct batch_options *opt)
504 450 {
505 - strbuf_add_oid_hex(scratch, &data->oid);
506 - strbuf_addch(scratch, ' ');
507 - strbuf_addstr(scratch, type_name(data->type));
508 - strbuf_addch(scratch, ' ');
509 - strbuf_add_uint(scratch, data->size);
510 - strbuf_addch(scratch, opt->output_delim);
451 + strbuf_addf(scratch, "%s %s %"PRIuMAX"%c", oid_to_hex(&data->oid),
452 + type_name(data->type),
453 + (uintmax_t)data->size, opt->output_delim);
511 454 }
512 455
513 456 static void report_object_status(struct batch_options *opt,
@@ -544,7 +487,7 @@ static void batch_object_write(const char *obj_name,
544 487 data->info.sizep = &data->size;
545 488
546 489 if (pack)
547 - ret = packed_object_info(NULL, pack, offset, &data->info);
490 + ret = packed_object_info(pack, offset, &data->info);
548 491 else
549 492 ret = odb_read_object_info_extended(the_repository->objects,
550 493 &data->oid, &data->info,
@@ -590,13 +533,15 @@ static void batch_object_write(const char *obj_name,
590 533 }
591 534
592 535 if (use_mailmap && (data->type == OBJ_COMMIT || data->type == OBJ_TAG)) {
536 + size_t s = data->size;
593 537 char *buf = NULL;
594 538
595 539 buf = odb_read_object(the_repository->objects, &data->oid,
596 540 &data->type, &data->size);
597 541 if (!buf)
598 542 die(_("unable to read %s"), oid_to_hex(&data->oid));
599 - buf = replace_idents_using_mailmap(buf, &data->size);
543 + buf = replace_idents_using_mailmap(buf, &s);
544 + data->size = cast_size_t_to_ulong(s);
600 545
601 546 free(buf);
602 547 }
@@ -680,57 +625,6 @@ out:
680 625 object_context_release(&ctx);
681 626 }
682 627
683 - static int get_remote_info(int argc,
684 - const char **argv,
685 - struct fetch_object_info_results *results,
686 - struct oid_array *object_info_oids)
687 - {
688 - int retval = 0;
689 - struct remote *remote = NULL;
690 - struct object_id oid;
691 - struct transport *gtransport;
692 -
693 - remote = remote_get(argv[0]);
694 - if (!remote)
695 - die(_("must supply valid remote when using remote-object-info"));
696 -
697 - oid_array_clear(object_info_oids);
698 - for (size_t i = 1; i < argc; i++) {
699 - if (get_oid_hex(argv[i], &oid)) {
700 - size_t len = strlen(argv[i]);
701 -
702 - if (len < the_hash_algo->hexsz && len >= 4) {
703 - size_t j;
704 - for (j = 0; j < len; j++)
705 - if (!isxdigit(argv[i][j]))
706 - break;
707 - if (j == len)
708 - die(_("remote-object-info does not support "
709 - "short oids, %d characters required"),
710 - (int)the_hash_algo->hexsz);
711 - }
712 - die(_("not a valid object name '%s'"), argv[i]);
713 - }
714 - oid_array_append(object_info_oids, &oid);
715 - }
716 -
717 - if (!object_info_oids->nr)
718 - die(_("remote-object-info requires objects"));
719 -
720 - gtransport = transport_get(remote, NULL);
721 -
722 - if (!gtransport->smart_options) {
723 - retval = -1;
724 - goto cleanup;
725 - }
726 -
727 - retval = transport_fetch_object_info(gtransport, object_info_oids,
728 - results);
729 - cleanup:
730 - transport_disconnect(gtransport);
731 - return retval;
732 - }
733 -
734 628 struct object_cb_data {
735 629 struct batch_options *opt;
736 630 struct expand_data *expand;
@@ -785,11 +679,8 @@ static void parse_cmd_contents(struct batch_options *opt,
785 679 struct strbuf *output,
786 680 struct expand_data *data)
787 681 {
788 - enum object_type *saved_typep = data->info.typep;
789 - data->info.typep = &data->type;
790 682 opt->batch_mode = BATCH_MODE_CONTENTS;
791 683 batch_one_object(line, output, opt, data);
792 - data->info.typep = saved_typep;
793 684 }
794 685
795 686 static void parse_cmd_info(struct batch_options *opt,
@@ -801,100 +692,18 @@ static void parse_cmd_info(struct batch_options *opt,
801 692 batch_one_object(line, output, opt, data);
802 693 }
803 694
804 - static void parse_cmd_mailmap(struct batch_options *opt UNUSED,
805 - const char *line,
806 - struct strbuf *output UNUSED,
807 - struct expand_data *data UNUSED)
808 - {
809 - use_mailmap = git_parse_maybe_bool(line);
810 -
811 - if (use_mailmap < 0)
812 - die(_("mailmap: invalid boolean '%s'"), line);
813 -
814 - if (use_mailmap)
815 - load_mailmap();
816 - }
817 -
818 - static void parse_cmd_remote_object_info(struct batch_options *opt,
819 - const char *line, struct strbuf *output,
820 - struct expand_data *data)
821 - {
822 - int count;
823 - const char **argv;
824 - char *line_to_split;
825 - struct fetch_object_info_results results = FETCH_OBJECT_INFO_RESULTS_INIT;
826 - struct oid_array object_info_oids = OID_ARRAY_INIT;
827 -
828 - if (strlen(line) >= MAX_REMOTE_OBJ_INFO_LINE)
829 - die(_("remote-object-info command too long"));
830 -
831 - line_to_split = xstrdup(line);
832 - count = split_cmdline(line_to_split, &argv);
833 - if (count < 0)
834 - die(_("remote-object-info: failed to parse command line: %s"),
835 - split_cmdline_strerror(count));
836 - if (count - 1 > MAX_ALLOWED_OBJ_LIMIT)
837 - die(_("remote-object-info supports at most %d objects"),
838 - MAX_ALLOWED_OBJ_LIMIT);
839 -
840 - if (data->info.sizep)
841 - results.wants_size = 1;
842 - if (data->info.typep)
843 - results.wants_type = 1;
844 -
845 - if (get_remote_info(count, argv, &results, &object_info_oids))
846 - die(_("failed to get object info from the remote: %s"), argv[0]);
847 -
848 - string_list_clear(&data->remote_allowed_atoms, 0);
849 - string_list_append(&data->remote_allowed_atoms, "objectname");
850 - if (results.sizes)
851 - string_list_append(&data->remote_allowed_atoms, "objectsize");
852 - if (results.types)
853 - string_list_append(&data->remote_allowed_atoms, "objecttype");
854 -
855 - data->skip_object_info = 1;
856 - for (size_t i = 0; i < results.nr; i++) {
857 - data->oid = object_info_oids.oid[i];
858 -
859 - if (results.unrecognized[i]) {
860 - report_object_status(opt, oid_to_hex(&data->oid),
861 - &data->oid, "missing");
862 - continue;
863 - }
864 -
865 - /*
866 - * When reaching here, it means remote-object-info can retrieve
867 - * information from server without downloading them.
868 - */
869 - if (results.sizes)
870 - data->size = results.sizes[i];
871 -
872 - if (results.types)
873 - data->type = results.types[i];
874 -
875 - opt->batch_mode = BATCH_MODE_INFO;
876 - data->is_remote = 1;
877 - batch_object_write(argv[i + 1], output, opt, data, NULL, 0);
878 - data->is_remote = 0;
879 - }
880 - data->skip_object_info = 0;
881 -
882 - free_fetch_object_info_results(&results);
883 - free(line_to_split);
884 - free(argv);
885 - oid_array_clear(&object_info_oids);
886 - }
887 -
888 695 static void dispatch_calls(struct batch_options *opt,
889 696 struct strbuf *output,
890 697 struct expand_data *data,
891 698 struct queued_cmd *cmd,
892 - size_t nr)
699 + int nr)
893 700 {
701 + int i;
702 +
894 703 if (!opt->buffer_output)
895 704 die(_("flush is only for --buffer mode"));
896 705
897 - for (size_t i = 0; i < nr; i++)
706 + for (i = 0; i < nr; i++)
898 707 cmd[i].fn(opt, cmd[i].line, output, data);
899 708
900 709 fflush(stdout);
@@ -902,7 +711,9 @@ static void dispatch_calls(struct batch_options *opt,
902 711
903 712 static void free_cmds(struct queued_cmd *cmd, size_t *nr)
904 713 {
905 - for (size_t i = 0; i < *nr; i++)
714 + size_t i;
715 +
716 + for (i = 0; i < *nr; i++)
906 717 FREE_AND_NULL(cmd[i].line);
907 718
908 719 *nr = 0;
@@ -914,11 +725,9 @@ static const struct parse_cmd {
914 725 parse_cmd_fn_t fn;
915 726 unsigned takes_args;
916 727 } commands[] = {
917 - { "contents", parse_cmd_contents, 1 },
918 - { "flush", NULL, 0 },
919 - { "info", parse_cmd_info, 1 },
920 - { "mailmap", parse_cmd_mailmap, 1 },
921 - { "remote-object-info", parse_cmd_remote_object_info, 1 },
728 + { "contents", parse_cmd_contents, 1},
729 + { "info", parse_cmd_info, 1},
730 + { "flush", NULL, 0},
922 731 };
923 732
924 733 static void batch_objects_command(struct batch_options *opt,
@@ -930,6 +739,7 @@ static void batch_objects_command(struct batch_options *opt,
930 739 size_t alloc = 0, nr = 0;
931 740
932 741 while (strbuf_getdelim_strip_crlf(&input, stdin, opt->input_delim) != EOF) {
742 + int i;
933 743 const struct parse_cmd *cmd = NULL;
934 744 const char *p = NULL, *cmd_end;
935 745 struct queued_cmd call = {0};
@@ -939,7 +749,7 @@ static void batch_objects_command(struct batch_options *opt,
939 749 if (isspace(*input.buf))
940 750 die(_("whitespace before command: '%s'"), input.buf);
941 751
942 - for (size_t i = 0; i < ARRAY_SIZE(commands); i++) {
752 + for (i = 0; i < ARRAY_SIZE(commands); i++) {
943 753 if (!skip_prefix(input.buf, commands[i].name, &cmd_end))
944 754 continue;
945 755
@@ -1001,13 +811,34 @@ static int batch_one_object_oi(const struct object_id *oid,
1001 811 void *_payload)
1002 812 {
1003 813 struct for_each_object_payload *payload = _payload;
1004 - if (oi && oi->source_infop->source->type == ODB_SOURCE_PACKED)
1005 - return payload->callback(oid, oi->source_infop->u.packed.pack,
1006 - oi->source_infop->u.packed.offset,
814 + if (oi && oi->whence == OI_PACKED)
815 + return payload->callback(oid, oi->u.packed.pack, oi->u.packed.offset,
1007 816 payload->payload);
1008 817 return payload->callback(oid, NULL, 0, payload->payload);
1009 818 }
1010 819
820 + static int batch_one_object_packed(const struct object_id *oid,
821 + struct packed_git *pack,
822 + uint32_t pos,
823 + void *_payload)
824 + {
825 + struct for_each_object_payload *payload = _payload;
826 + return payload->callback(oid, pack, nth_packed_object_offset(pack, pos),
827 + payload->payload);
828 + }
829 +
830 + static int batch_one_object_bitmapped(const struct object_id *oid,
831 + enum object_type type UNUSED,
832 + int flags UNUSED,
833 + uint32_t hash UNUSED,
834 + struct packed_git *pack,
835 + off_t offset,
836 + void *_payload)
837 + {
838 + struct for_each_object_payload *payload = _payload;
839 + return payload->callback(oid, pack, offset, payload->payload);
840 + }
841 +
1011 842 static void batch_each_object(struct batch_options *opt,
1012 843 for_each_object_fn callback,
1013 844 unsigned flags,
@@ -1017,17 +848,52 @@ static void batch_each_object(struct batch_options *opt,
1017 848 .callback = callback,
1018 849 .payload = _payload,
1019 850 };
1020 - struct odb_source_info source_info;
1021 - struct object_info oi = {
1022 - .source_infop = &source_info,
1023 - };
1024 851 struct odb_for_each_object_options opts = {
1025 852 .flags = flags,
1026 - .filter = &opt->objects_filter,
1027 853 };
854 + struct bitmap_index *bitmap = NULL;
855 + struct odb_source *source;
856 +
857 + /*
858 + * TODO: we still need to tap into implementation details of the object
859 + * database sources. Ideally, we should extend `odb_for_each_object()`
860 + * to handle object filters itself so that we can move the filtering
861 + * logic into the individual sources.
862 + */
863 + odb_prepare_alternates(the_repository->objects);
864 + for (source = the_repository->objects->sources; source; source = source->next) {
865 + int ret = odb_source_loose_for_each_object(source, NULL, batch_one_object_oi,
866 + &payload, &opts);
867 + if (ret)
868 + break;
869 + }
870 +
871 + if (opt->objects_filter.choice != LOFC_DISABLED &&
872 + (bitmap = prepare_bitmap_git(the_repository)) &&
873 + !for_each_bitmapped_object(bitmap, &opt->objects_filter,
874 + batch_one_object_bitmapped, &payload)) {
875 + struct packed_git *pack;
876 +
877 + repo_for_each_pack(the_repository, pack) {
878 + if (bitmap_index_contains_pack(bitmap, pack) ||
879 + open_pack_index(pack))
880 + continue;
881 + for_each_object_in_pack(pack, batch_one_object_packed,
882 + &payload, flags);
883 + }
884 + } else {
885 + struct object_info oi = { 0 };
886 +
887 + for (source = the_repository->objects->sources; source; source = source->next) {
888 + struct odb_source_files *files = odb_source_files_downcast(source);
889 + int ret = packfile_store_for_each_object(files->packed, &oi,
890 + batch_one_object_oi, &payload, &opts);
891 + if (ret)
892 + break;
893 + }
894 + }
1028 895
1029 - odb_for_each_object_ext(the_repository->objects, &oi,
1030 - batch_one_object_oi, &payload, &opts);
896 + free_bitmap_index(bitmap);
1031 897 }
1032 898
1033 899 static int batch_objects(struct batch_options *opt)
@@ -1035,7 +901,6 @@ static int batch_objects(struct batch_options *opt)
1035 901 struct strbuf input = STRBUF_INIT;
1036 902 struct strbuf output = STRBUF_INIT;
1037 903 struct expand_data data = EXPAND_DATA_INIT;
1038 - struct repo_config_values *cfg = repo_config_values(the_repository);
1039 904 int save_warning;
1040 905 int retval = 0;
1041 906
@@ -1108,8 +973,8 @@ static int batch_objects(struct batch_options *opt)
1108 973 * warn) ends up dwarfing the actual cost of the object lookups
1109 974 * themselves. We can work around it by just turning off the warning.
1110 975 */
1111 - save_warning = cfg->warn_on_object_refname_ambiguity;
1112 - cfg->warn_on_object_refname_ambiguity = 0;
976 + save_warning = warn_on_object_refname_ambiguity;
977 + warn_on_object_refname_ambiguity = 0;
1113 978
1114 979 if (opt->batch_mode == BATCH_MODE_QUEUE_AND_DISPATCH) {
1115 980 batch_objects_command(opt, &output, &data);
@@ -1137,8 +1002,7 @@ static int batch_objects(struct batch_options *opt)
1137 1002 cleanup:
1138 1003 strbuf_release(&input);
1139 1004 strbuf_release(&output);
1140 - string_list_clear(&data.remote_allowed_atoms, 0);
1141 - cfg->warn_on_object_refname_ambiguity = save_warning;
1005 + warn_on_object_refname_ambiguity = save_warning;
1142 1006 return retval;
1143 1007 }
1144 1008
@@ -1267,7 +1131,7 @@ int cmd_cat_file(int argc,
1267 1131 opt_epts = (opt == 'e' || opt == 'p' || opt == 't' || opt == 's');
1268 1132
1269 1133 if (use_mailmap)
1270 - load_mailmap();
1134 + read_mailmap(the_repository, &mailmap);
1271 1135
1272 1136 switch (batch.objects_filter.choice) {
1273 1137 case LOFC_DISABLED:
modified builtin/check-attr.c
@@ -67,7 +67,7 @@ static void check_attr(const char *prefix, struct attr_check *check,
67 67
68 68 {
69 69 char *full_path =
70 - prefix_path(the_repository, prefix, prefix ? strlen(prefix) : 0, file);
70 + prefix_path(prefix, prefix ? strlen(prefix) : 0, file);
71 71
72 72 if (collect_all) {
73 73 git_all_attrs(the_repository->index, full_path, check);
@@ -116,8 +116,8 @@ int cmd_check_attr(int argc,
116 116 struct object_id initialized_oid;
117 117 int cnt, i, doubledash, filei;
118 118
119 - if (!is_bare_repository(the_repository))
120 - setup_work_tree(the_repository);
119 + if (!is_bare_repository())
120 + setup_work_tree();
121 121
122 122 repo_config(the_repository, git_default_config, NULL);
123 123
modified builtin/check-ref-format.c
@@ -1,9 +1,6 @@
1 1 /*
2 2 * GIT - The information manager from hell
3 3 */
4 -
5 - #define USE_THE_REPOSITORY_VARIABLE
6 -
7 4 #include "builtin.h"
8 5 #include "refs.h"
9 6 #include "setup.h"
@@ -44,8 +41,8 @@ static int check_ref_format_branch(const char *arg)
44 41 const char *name;
45 42 int nongit;
46 43
47 - setup_git_directory_gently(the_repository, &nongit);
48 - if (check_branch_ref(the_repository, &sb, arg) ||
44 + setup_git_directory_gently(&nongit);
45 + if (check_branch_ref(&sb, arg) ||
49 46 !skip_prefix(sb.buf, "refs/heads/", &name))
50 47 die("'%s' is not a valid branch name", arg);
51 48 printf("%s\n", name);
modified builtin/checkout-index.c
@@ -303,7 +303,7 @@ int cmd_checkout_index(int argc,
303 303 die("git checkout-index: don't mix '--all' and explicit filenames");
304 304 if (read_from_stdin)
305 305 die("git checkout-index: don't mix '--stdin' and explicit filenames");
306 - p = prefix_path(repo, prefix, prefix_length, arg);
306 + p = prefix_path(prefix, prefix_length, arg);
307 307 err |= checkout_file(repo->index, p, prefix);
308 308 free(p);
309 309 }
@@ -325,7 +325,7 @@ int cmd_checkout_index(int argc,
325 325 die("line is badly quoted");
326 326 strbuf_swap(&buf, &unquoted);
327 327 }
328 - p = prefix_path(repo, prefix, prefix_length, buf.buf);
328 + p = prefix_path(prefix, prefix_length, buf.buf);
329 329 err |= checkout_file(repo->index, p, prefix);
330 330 free(p);
331 331 }
modified builtin/checkout.c
@@ -17,6 +17,7 @@
17 17 #include "merge-ll.h"
18 18 #include "lockfile.h"
19 19 #include "mem-pool.h"
20 + #include "merge-ort-wrappers.h"
20 21 #include "object-file.h"
21 22 #include "object-name.h"
22 23 #include "odb.h"
@@ -29,10 +30,7 @@
29 30 #include "repo-settings.h"
30 31 #include "resolve-undo.h"
31 32 #include "revision.h"
32 - #include "sequencer.h"
33 33 #include "setup.h"
34 - #include "sparse-index.h"
35 - #include "strvec.h"
36 34 #include "submodule.h"
37 35 #include "symlinks.h"
38 36 #include "trace2.h"
@@ -101,8 +99,6 @@ struct checkout_opts {
101 99 .auto_advance = 1, \
102 100 }
103 101
104 - #define MERGE_WORKING_TREE_UNPACK_FAILED (-2)
105 -
106 102 struct branch_info {
107 103 char *name; /* The short name used */
108 104 char *path; /* The full name of a real branch */
@@ -127,80 +123,24 @@ static void branch_info_release(struct branch_info *info)
127 123 static int post_checkout_hook(struct commit *old_commit, struct commit *new_commit,
128 124 int changed)
129 125 {
130 - struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
131 -
132 - /*
133 - * "new_commit" can be NULL when checking out from the index before
134 - * a commit exists.
135 - */
136 - strvec_pushl(&opt.args,
137 - oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)),
138 - oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)),
139 - changed ? "1" : "0",
140 - NULL);
141 -
142 - return run_hooks_opt(the_repository, "post-checkout", &opt);
143 - }
144 -
145 - /*
146 - * Handle a tree object and determine if we need to recurse into the
147 - * tree (READ_TREE_RECURSIVE) or skip it (0).
148 - */
149 - static int try_update_sparse_directory(const struct object_id *oid,
150 - struct strbuf *base,
151 - const char *pathname,
152 - int overlay_mode)
153 - {
154 - struct strbuf dirpath = STRBUF_INIT;
155 - struct cache_entry *old;
156 - int pos, result = READ_TREE_RECURSIVE;
157 -
158 - if (!the_repository->index->sparse_index)
159 - return result;
160 -
161 - strbuf_addbuf(&dirpath, base);
162 - strbuf_addstr(&dirpath, pathname);
163 - strbuf_addch(&dirpath, '/');
164 -
165 - pos = index_name_pos_sparse(the_repository->index,
166 - dirpath.buf, dirpath.len);
167 - if (pos < 0)
168 - goto cleanup;
169 -
170 - old = the_repository->index->cache[pos];
171 - if (!S_ISSPARSEDIR(old->ce_mode))
172 - goto cleanup;
173 -
174 - if (oideq(oid, &old->oid)) {
175 - /* Tree content already matches; no need to descend. */
176 - result = 0;
177 - } else if (!overlay_mode) {
178 - /*
179 - * In non-overlay mode (e.g., restore --staged), replace the
180 - * sparse directory OID directly since files not present in
181 - * the source tree should be removed anyway.
182 - */
183 - oidcpy(&old->oid, oid);
184 - old->ce_flags |= CE_UPDATE;
185 - result = 0;
186 - }
126 + return run_hooks_l(the_repository, "post-checkout",
127 + oid_to_hex(old_commit ? &old_commit->object.oid : null_oid(the_hash_algo)),
128 + oid_to_hex(new_commit ? &new_commit->object.oid : null_oid(the_hash_algo)),
129 + changed ? "1" : "0", NULL);
130 + /* "new_commit" can be NULL when checking out from the index before
131 + a commit exists. */
187 132
188 - cleanup:
189 - strbuf_release(&dirpath);
190 - return result;
191 133 }
192 134
193 135 static int update_some(const struct object_id *oid, struct strbuf *base,
194 - const char *pathname, unsigned mode, void *context)
136 + const char *pathname, unsigned mode, void *context UNUSED)
195 137 {
196 138 int len;
197 139 struct cache_entry *ce;
198 140 int pos;
199 - int overlay_mode = context ? *((int *)context) : 1;
200 141
201 142 if (S_ISDIR(mode))
202 - return try_update_sparse_directory(oid, base, pathname,
203 - overlay_mode);
143 + return READ_TREE_RECURSIVE;
204 144
205 145 len = base->len + strlen(pathname);
206 146 ce = make_empty_cache_entry(the_repository->index, len);
@@ -216,7 +156,7 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
216 156 * entry in place. Whether it is UPTODATE or not, checkout_entry will
217 157 * do the right thing.
218 158 */
219 - pos = index_name_pos_sparse(the_repository->index, ce->name, ce->ce_namelen);
159 + pos = index_name_pos(the_repository->index, ce->name, ce->ce_namelen);
220 160 if (pos >= 0) {
221 161 struct cache_entry *old = the_repository->index->cache[pos];
222 162 if (ce->ce_mode == old->ce_mode &&
@@ -233,11 +173,10 @@ static int update_some(const struct object_id *oid, struct strbuf *base,
233 173 return 0;
234 174 }
235 175
236 - static int read_tree_some(struct tree *tree, const struct pathspec *pathspec,
237 - int overlay_mode)
176 + static int read_tree_some(struct tree *tree, const struct pathspec *pathspec)
238 177 {
239 178 read_tree(the_repository, tree,
240 - pathspec, update_some, &overlay_mode);
179 + pathspec, update_some, NULL);
241 180
242 181 /* update the index with the given tree's info
243 182 * for all args, expanding wildcards, and exit
@@ -632,8 +571,7 @@ static int checkout_paths(const struct checkout_opts *opts,
632 571 return error(_("index file corrupt"));
633 572
634 573 if (opts->source_tree)
635 - read_tree_some(opts->source_tree, &opts->pathspec,
636 - opts->overlay_mode);
574 + read_tree_some(opts->source_tree, &opts->pathspec);
637 575 if (opts->merge)
638 576 unmerge_index(the_repository->index, &opts->pathspec, CE_MATCHED);
639 577
@@ -805,7 +743,7 @@ static void setup_branch_path(struct branch_info *branch)
805 743 &branch->oid, &branch->refname, 0))
806 744 repo_get_oid_committish(the_repository, branch->name, &branch->oid);
807 745
808 - copy_branchname(the_repository, &buf, branch->name, INTERPRET_BRANCH_LOCAL);
746 + copy_branchname(&buf, branch->name, INTERPRET_BRANCH_LOCAL);
809 747 if (strcmp(buf.buf, branch->name)) {
810 748 free(branch->name);
811 749 branch->name = xstrdup(buf.buf);
@@ -815,9 +753,9 @@ static void setup_branch_path(struct branch_info *branch)
815 753 branch->path = strbuf_detach(&buf, NULL);
816 754 }
817 755
818 - static void init_topts(struct unpack_trees_options *topts,
756 + static void init_topts(struct unpack_trees_options *topts, int merge,
819 757 int show_progress, int overwrite_ignore,
820 - bool quiet)
758 + struct commit *old_commit)
821 759 {
822 760 memset(topts, 0, sizeof(*topts));
823 761 topts->head_idx = -1;
@@ -829,7 +767,7 @@ static void init_topts(struct unpack_trees_options *topts,
829 767 topts->initial_checkout = is_index_unborn(the_repository->index);
830 768 topts->update = 1;
831 769 topts->merge = 1;
832 - topts->quiet = quiet;
770 + topts->quiet = merge && old_commit;
833 771 topts->verbose_update = show_progress;
834 772 topts->fn = twoway_merge;
835 773 topts->preserve_ignored = !overwrite_ignore;
@@ -838,7 +776,6 @@ static void init_topts(struct unpack_trees_options *topts,
838 776 static int merge_working_tree(const struct checkout_opts *opts,
839 777 struct branch_info *old_branch_info,
840 778 struct branch_info *new_branch_info,
841 - bool quiet,
842 779 int *writeout_error)
843 780 {
844 781 int ret;
@@ -846,10 +783,8 @@ static int merge_working_tree(const struct checkout_opts *opts,
846 783 struct tree *new_tree;
847 784
848 785 repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
849 - if (repo_read_index_preload(the_repository, NULL, 0) < 0) {
850 - rollback_lock_file(&lock_file);
786 + if (repo_read_index_preload(the_repository, NULL, 0) < 0)
851 787 return error(_("index file corrupt"));
852 - }
853 788
854 789 resolve_undo_clear_index(the_repository->index);
855 790 if (opts->new_orphan_branch && opts->orphan_from_empty_tree) {
@@ -862,18 +797,14 @@ static int merge_working_tree(const struct checkout_opts *opts,
862 797 } else {
863 798 new_tree = repo_get_commit_tree(the_repository,
864 799 new_branch_info->commit);
865 - if (!new_tree) {
866 - rollback_lock_file(&lock_file);
800 + if (!new_tree)
867 801 return error(_("unable to read tree (%s)"),
868 802 oid_to_hex(&new_branch_info->commit->object.oid));
869 - }
870 803 }
871 804 if (opts->discard_changes) {
872 805 ret = reset_tree(new_tree, opts, 1, writeout_error, new_branch_info);
873 - if (ret) {
874 - rollback_lock_file(&lock_file);
806 + if (ret)
875 807 return ret;
876 - }
877 808 } else {
878 809 struct tree_desc trees[2];
879 810 struct tree *tree;
@@ -883,14 +814,13 @@ static int merge_working_tree(const struct checkout_opts *opts,
883 814 refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL);
884 815
885 816 if (unmerged_index(the_repository->index)) {
886 - rollback_lock_file(&lock_file);
887 817 error(_("you need to resolve your current index first"));
888 818 return 1;
889 819 }
890 820
891 821 /* 2-way merge to the new branch */
892 - init_topts(&topts, opts->show_progress,
893 - opts->overwrite_ignore, quiet);
822 + init_topts(&topts, opts->merge, opts->show_progress,
823 + opts->overwrite_ignore, old_branch_info->commit);
894 824 init_checkout_metadata(&topts.meta, new_branch_info->refname,
895 825 new_branch_info->commit ?
896 826 &new_branch_info->commit->object.oid :
@@ -916,8 +846,82 @@ static int merge_working_tree(const struct checkout_opts *opts,
916 846 ret = unpack_trees(2, trees, &topts);
917 847 clear_unpack_trees_porcelain(&topts);
918 848 if (ret == -1) {
919 - rollback_lock_file(&lock_file);
920 - return MERGE_WORKING_TREE_UNPACK_FAILED;
849 + /*
850 + * Unpack couldn't do a trivial merge; either
851 + * give up or do a real merge, depending on
852 + * whether the merge flag was used.
853 + */
854 + struct tree *work;
855 + struct tree *old_tree;
856 + struct merge_options o;
857 + struct strbuf sb = STRBUF_INIT;
858 + struct strbuf old_commit_shortname = STRBUF_INIT;
859 +
860 + if (!opts->merge)
861 + return 1;
862 +
863 + /*
864 + * Without old_branch_info->commit, the below is the same as
865 + * the two-tree unpack we already tried and failed.
866 + */
867 + if (!old_branch_info->commit)
868 + return 1;
869 + old_tree = repo_get_commit_tree(the_repository,
870 + old_branch_info->commit);
871 +
872 + if (repo_index_has_changes(the_repository, old_tree, &sb))
873 + die(_("cannot continue with staged changes in "
874 + "the following files:\n%s"), sb.buf);
875 + strbuf_release(&sb);
876 +
877 + /* Do more real merge */
878 +
879 + /*
880 + * We update the index fully, then write the
881 + * tree from the index, then merge the new
882 + * branch with the current tree, with the old
883 + * branch as the base. Then we reset the index
884 + * (but not the working tree) to the new
885 + * branch, leaving the working tree as the
886 + * merged version, but skipping unmerged
887 + * entries in the index.
888 + */
889 +
890 + add_files_to_cache(the_repository, NULL, NULL, NULL, 0,
891 + 0, 0);
892 + init_ui_merge_options(&o, the_repository);
893 + o.verbosity = 0;
894 + work = write_in_core_index_as_tree(the_repository,
895 + the_repository->index);
896 +
897 + ret = reset_tree(new_tree,
898 + opts, 1,
899 + writeout_error, new_branch_info);
900 + if (ret)
901 + return ret;
902 + o.ancestor = old_branch_info->name;
903 + if (!old_branch_info->name) {
904 + strbuf_add_unique_abbrev(&old_commit_shortname,
905 + &old_branch_info->commit->object.oid,
906 + DEFAULT_ABBREV);
907 + o.ancestor = old_commit_shortname.buf;
908 + }
909 + o.branch1 = new_branch_info->name;
910 + o.branch2 = "local";
911 + o.conflict_style = opts->conflict_style;
912 + ret = merge_ort_nonrecursive(&o,
913 + new_tree,
914 + work,
915 + old_tree);
916 + if (ret < 0)
917 + die(NULL);
918 + ret = reset_tree(new_tree,
919 + opts, 0,
920 + writeout_error, new_branch_info);
921 + strbuf_release(&o.obuf);
922 + strbuf_release(&old_commit_shortname);
923 + if (ret)
924 + return ret;
921 925 }
922 926 }
923 927
@@ -952,13 +956,10 @@ static void update_refs_for_switch(const struct checkout_opts *opts,
952 956 const char *old_desc, *reflog_msg;
953 957 if (opts->new_branch) {
954 958 if (opts->new_orphan_branch) {
955 - enum log_refs_config log_all_ref_updates = LOG_REFS_UNSET;
956 - const char *value;
959 + enum log_refs_config log_all_ref_updates =
960 + repo_settings_get_log_all_ref_updates(the_repository);
957 961 char *refname;
958 962
959 - if (!repo_config_get_string_tmp(the_repository, "core.logallrefupdates", &value))
960 - log_all_ref_updates = refs_parse_log_all_ref_updates_config(value);
961 -
962 963 refname = mkpathdup("refs/heads/%s", opts->new_orphan_branch);
963 964 if (opts->new_branch_log &&
964 965 !should_autocreate_reflog(log_all_ref_updates, refname)) {
@@ -1165,10 +1166,6 @@ static int switch_branches(const struct checkout_opts *opts,
1165 1166 struct object_id rev;
1166 1167 int flag, writeout_error = 0;
1167 1168 int do_merge = 1;
1168 - int created_autostash = 0;
1169 - struct strbuf old_commit_shortname = STRBUF_INIT;
1170 - struct strbuf autostash_msg = STRBUF_INIT;
1171 - const char *stash_label_base = NULL;
1172 1169
1173 1170 trace2_cmd_mode("branch");
1174 1171
@@ -1206,49 +1203,11 @@ static int switch_branches(const struct checkout_opts *opts,
1206 1203 do_merge = 0;
1207 1204 }
1208 1205
1209 - if (old_branch_info.name) {
1210 - stash_label_base = old_branch_info.name;
1211 - } else if (old_branch_info.commit) {
1212 - strbuf_add_unique_abbrev(&old_commit_shortname,
1213 - &old_branch_info.commit->object.oid,
1214 - DEFAULT_ABBREV);
1215 - stash_label_base = old_commit_shortname.buf;
1216 - }
1217 -
1218 1206 if (do_merge) {
1219 - ret = merge_working_tree(opts, &old_branch_info, new_branch_info,
1220 - opts->merge, &writeout_error);
1221 - if (ret == MERGE_WORKING_TREE_UNPACK_FAILED && opts->merge) {
1222 - strbuf_addf(&autostash_msg,
1223 - "autostash while switching to '%s'",
1224 - new_branch_info->name);
1225 - create_autostash_ref(the_repository,
1226 - "CHECKOUT_AUTOSTASH_HEAD",
1227 - autostash_msg.buf, true);
1228 - created_autostash = 1;
1229 - ret = merge_working_tree(opts, &old_branch_info, new_branch_info,
1230 - false, &writeout_error);
1231 - }
1232 - if (created_autostash) {
1233 - if (opts->conflict_style >= 0) {
1234 - struct strbuf cfg = STRBUF_INIT;
1235 - strbuf_addf(&cfg, "merge.conflictStyle=%s",
1236 - conflict_style_name(opts->conflict_style));
1237 - git_config_push_parameter(cfg.buf);
1238 - strbuf_release(&cfg);
1239 - }
1240 - apply_autostash_ref(the_repository,
1241 - "CHECKOUT_AUTOSTASH_HEAD",
1242 - new_branch_info->name,
1243 - "local",
1244 - stash_label_base,
1245 - autostash_msg.buf);
1246 - }
1207 + ret = merge_working_tree(opts, &old_branch_info, new_branch_info, &writeout_error);
1247 1208 if (ret) {
1248 1209 branch_info_release(&old_branch_info);
1249 - strbuf_release(&old_commit_shortname);
1250 - strbuf_release(&autostash_msg);
1251 - return ret < 0 ? 1 : ret;
1210 + return ret;
1252 1211 }
1253 1212 }
1254 1213
@@ -1257,22 +1216,8 @@ static int switch_branches(const struct checkout_opts *opts,
1257 1216
1258 1217 update_refs_for_switch(opts, &old_branch_info, new_branch_info);
1259 1218
1260 - if (created_autostash) {
1261 - discard_index(the_repository->index);
1262 - if (repo_read_index(the_repository) < 0)
1263 - die(_("index file corrupt"));
1264 -
1265 - if (!opts->quiet && new_branch_info->commit) {
1266 - printf(_("The following paths have local changes:\n"));
1267 - show_local_changes(&new_branch_info->commit->object,
1268 - &opts->diff_options);
1269 - }
1270 - }
1271 -
1272 1219 ret = post_checkout_hook(old_branch_info.commit, new_branch_info->commit, 1);
1273 1220 branch_info_release(&old_branch_info);
1274 - strbuf_release(&old_commit_shortname);
1275 - strbuf_release(&autostash_msg);
1276 1221
1277 1222 return ret || writeout_error;
1278 1223 }
@@ -1343,51 +1288,13 @@ enum checkout_command {
1343 1288 CHECKOUT_RESTORE = 3,
1344 1289 };
1345 1290
1346 - static void advise_disambiguating_remotes(enum checkout_command which_command,
1347 - const char *branch,
1348 - const struct string_list *matched_remote_names)
1349 - {
1350 - const char *cmdname;
1351 - struct string_list_item *item;
1352 -
1353 - switch (which_command) {
1354 - case CHECKOUT_CHECKOUT:
1355 - cmdname = "checkout";
1356 - break;
1357 - case CHECKOUT_SWITCH:
1358 - cmdname = "switch";
1359 - break;
1360 - default:
1361 - BUG("command <%d> should not reach advise_disambiguating_remotes",
1362 - which_command);
1363 - break;
1364 - }
1365 -
1366 - advise(_("Branch name '%s' appears in multiple remotes:"), branch);
1367 - for_each_string_list_item(item, matched_remote_names) {
1368 - advise(_(" %s"), item->string);
1369 - }
1370 - advise(_("If you meant to check out a remote tracking branch on <remote>,\n"
1371 - "you can do so by fully qualifying the name with the --track option:\n"
1372 - "\n"
1373 - " git %s --track <remote>/%s\n"
1374 - "\n"
1375 - "If you'd like to always have checkouts of an ambiguous name prefer\n"
1376 - "one remote, e.g. the 'origin' remote, consider setting\n"
1377 - "checkout.defaultRemote=origin in your config."),
1378 - cmdname, branch);
1379 - }
1380 -
1381 1291 static char *parse_remote_branch(const char *arg,
1382 1292 struct object_id *rev,
1383 1293 int could_be_checkout_paths,
1384 1294 enum checkout_command which_command)
1385 1295 {
1386 1296 int num_matches = 0;
1387 - struct string_list matched_remote_names = STRING_LIST_INIT_DUP;
1388 -
1389 - char *remote = unique_tracking_name(arg, rev, &num_matches,
1390 - &matched_remote_names);
1297 + char *remote = unique_tracking_name(arg, rev, &num_matches);
1391 1298
1392 1299 if (remote && could_be_checkout_paths) {
1393 1300 die(_("'%s' could be both a local file and a tracking branch.\n"
@@ -1396,15 +1303,37 @@ static char *parse_remote_branch(const char *arg,
1396 1303 }
1397 1304
1398 1305 if (!remote && num_matches > 1) {
1399 - if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME))
1400 - advise_disambiguating_remotes(which_command, arg,
1401 - &matched_remote_names);
1402 - die(_("'%s' matched multiple (%d) remote tracking branches"),
1403 - arg, num_matches);
1306 + if (advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME)) {
1307 + const char *cmdname;
1308 +
1309 + switch (which_command) {
1310 + case CHECKOUT_CHECKOUT:
1311 + cmdname = "checkout";
1312 + break;
1313 + case CHECKOUT_SWITCH:
1314 + cmdname = "switch";
1315 + break;
1316 + default:
1317 + BUG("command <%d> should not reach parse_remote_branch",
1318 + which_command);
1319 + break;
1320 + }
1321 +
1322 + advise(_("If you meant to check out a remote tracking branch on, e.g. 'origin',\n"
1323 + "you can do so by fully qualifying the name with the --track option:\n"
1324 + "\n"
1325 + " git %s --track origin/<name>\n"
1326 + "\n"
1327 + "If you'd like to always have checkouts of an ambiguous <name> prefer\n"
1328 + "one remote, e.g. the 'origin' remote, consider setting\n"
1329 + "checkout.defaultRemote=origin in your config."),
1330 + cmdname);
1331 + }
1332 +
1333 + die(_("'%s' matched multiple (%d) remote tracking branches"),
1334 + arg, num_matches);
1404 1335 }
1405 1336
1406 - string_list_clear(&matched_remote_names, 0);
1407 -
1408 1337 return remote;
1409 1338 }
1410 1339
@@ -1556,7 +1485,7 @@ static int parse_branchname_arg(int argc, const char **argv,
1556 1485 * it would be extremely annoying.
1557 1486 */
1558 1487 if (argc)
1559 - verify_non_filename(the_repository, opts->prefix, arg);
1488 + verify_non_filename(opts->prefix, arg);
1560 1489 } else if (opts->accept_pathspec) {
1561 1490 argcount++;
1562 1491 argv++;
modified builtin/clone.c
@@ -335,7 +335,7 @@ static void copy_or_link_directory(struct strbuf *src, struct strbuf *dest,
335 335 die_errno(_("failed to create link '%s'"), dest->buf);
336 336 option_no_hardlinks = 1;
337 337 }
338 - if (copy_file_with_time(the_repository, dest->buf, src->buf, 0666))
338 + if (copy_file_with_time(dest->buf, src->buf, 0666))
339 339 die_errno(_("failed to copy file to '%s'"), dest->buf);
340 340 }
341 341
@@ -557,7 +557,7 @@ static void update_remote_refs(const struct ref *refs,
557 557 write_followtags(refs, msg);
558 558 }
559 559
560 - if (remote_head_points_at && remote_head_points_at->peer_ref && !option_bare) {
560 + if (remote_head_points_at && !option_bare) {
561 561 struct strbuf head_ref = STRBUF_INIT;
562 562 strbuf_addstr(&head_ref, branch_top);
563 563 strbuf_addstr(&head_ref, "HEAD");
@@ -647,7 +647,6 @@ static int checkout(int submodule_progress,
647 647 struct tree *tree;
648 648 struct tree_desc t;
649 649 int err = 0;
650 - struct run_hooks_opt hook_opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
651 650
652 651 if (option_no_checkout)
653 652 return 0;
@@ -669,7 +668,7 @@ static int checkout(int submodule_progress,
669 668 }
670 669
671 670 /* We need to be in the new work tree for the checkout */
672 - setup_work_tree(the_repository);
671 + setup_work_tree();
673 672
674 673 repo_hold_locked_index(the_repository, &lock_file, LOCK_DIE_ON_ERROR);
675 674
@@ -698,9 +697,8 @@ static int checkout(int submodule_progress,
698 697 if (write_locked_index(the_repository->index, &lock_file, COMMIT_LOCK))
699 698 die(_("unable to write new index file"));
700 699
701 - strvec_pushl(&hook_opt.args, oid_to_hex(null_oid(the_hash_algo)),
702 - oid_to_hex(&oid), "1", NULL);
703 - err |= run_hooks_opt(the_repository, "post-checkout", &hook_opt);
700 + err |= run_hooks_l(the_repository, "post-checkout", oid_to_hex(null_oid(the_hash_algo)),
701 + oid_to_hex(&oid), "1", NULL);
704 702
705 703 if (!err && (option_recurse_submodules.nr > 0)) {
706 704 struct child_process cmd = CHILD_PROCESS_INIT;
@@ -1116,6 +1114,7 @@ int cmd_clone(int argc,
1116 1114 die_errno(_("could not create work tree dir '%s'"),
1117 1115 work_tree);
1118 1116 junk_work_tree = work_tree;
1117 + set_git_work_tree(work_tree);
1119 1118 }
1120 1119
1121 1120 if (real_git_dir) {
@@ -1185,10 +1184,9 @@ int cmd_clone(int argc,
1185 1184 * repository, and reference backends may persist that information into
1186 1185 * their on-disk data structures.
1187 1186 */
1188 - init_db(the_repository, git_dir, real_git_dir, work_tree, option_template,
1189 - GIT_HASH_UNKNOWN, ref_storage_format, NULL,
1190 - do_not_override_repo_unix_permissions,
1191 - INIT_DB_QUIET | INIT_DB_SKIP_REFDB);
1187 + init_db(git_dir, real_git_dir, option_template, GIT_HASH_UNKNOWN,
1188 + ref_storage_format, NULL,
1189 + do_not_override_repo_unix_permissions, INIT_DB_QUIET | INIT_DB_SKIP_REFDB);
1192 1190
1193 1191 if (real_git_dir) {
1194 1192 free((char *)git_dir);
@@ -1229,7 +1227,7 @@ int cmd_clone(int argc,
1229 1227 *
1230 1228 * This is sufficient for Git commands to discover the Git directory.
1231 1229 */
1232 - initialize_repository_version(the_repository, GIT_HASH_UNKNOWN,
1230 + initialize_repository_version(GIT_HASH_UNKNOWN,
1233 1231 the_repository->ref_storage_format, 1);
1234 1232
1235 1233 refs_create_refdir_stubs(the_repository, git_dir, NULL);
@@ -1442,9 +1440,9 @@ int cmd_clone(int argc,
1442 1440 * ours to the same thing.
1443 1441 */
1444 1442 hash_algo = hash_algo_by_ptr(transport_get_hash_algo(transport));
1445 - initialize_repository_version(the_repository, hash_algo, the_repository->ref_storage_format, 1);
1443 + initialize_repository_version(hash_algo, the_repository->ref_storage_format, 1);
1446 1444 repo_set_hash_algo(the_repository, hash_algo);
1447 - create_reference_database(the_repository, NULL, 1);
1445 + create_reference_database(NULL, 1);
1448 1446
1449 1447 /*
1450 1448 * Before fetching from the remote, download and install bundle
modified builtin/commit.c
@@ -1979,8 +1979,7 @@ int cmd_commit(int argc,
1979 1979 &oid, flags);
1980 1980 }
1981 1981
1982 - apply_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1983 - NULL, NULL, NULL, NULL);
1982 + apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1984 1983
1985 1984 cleanup:
1986 1985 free_commit_extra_headers(extra);
modified builtin/config.c
@@ -1,7 +1,6 @@
1 1 #define USE_THE_REPOSITORY_VARIABLE
2 2 #include "builtin.h"
3 3 #include "abspath.h"
4 - #include "advice.h"
5 4 #include "config.h"
6 5 #include "color.h"
7 6 #include "date.h"
@@ -211,26 +210,6 @@ static void check_argc(int argc, int min, int max)
211 210 exit(129);
212 211 }
213 212
214 - static NORETURN void die_missing_set_value(const char *arg)
215 - {
216 - const char *last_dot = strrchr(arg, '.');
217 - const char *eq = last_dot ? strchr(last_dot + 1, '=') : NULL;
218 - char *prefix = eq ? xstrndup(arg, eq - arg) : NULL;
219 -
220 - if (prefix && git_config_key_is_valid(prefix)) {
221 - error(_("missing value to set to the variable '%s'"), arg);
222 - advise(_("did you mean \"git config set %s %s\"?"),
223 - prefix, eq + 1);
224 - } else if (git_config_key_is_valid(arg)) {
225 - error(_("missing value to set to the variable '%s'"), arg);
226 - } else {
227 - error(_("missing value to set to a variable with an invalid name '%s'"),
228 - arg);
229 - }
230 - free(prefix);
231 - exit(129);
232 - }
233 -
234 213 static void show_config_origin(const struct config_display_options *opts,
235 214 const struct key_value_info *kvi,
236 215 struct strbuf *buf)
@@ -974,7 +953,7 @@ static void location_options_init(struct config_location_options *opts,
974 953 opts->source.file = opts->file_to_free = repo_git_path(the_repository, "config");
975 954 opts->source.scope = CONFIG_SCOPE_LOCAL;
976 955 } else if (opts->use_worktree_config) {
977 - struct worktree **worktrees = get_worktrees(the_repository);
956 + struct worktree **worktrees = get_worktrees();
978 957 if (the_repository->repository_format_worktree_config)
979 958 opts->source.file = opts->file_to_free =
980 959 repo_git_path(the_repository, "config.worktree");
@@ -1154,8 +1133,6 @@ static int cmd_config_set(int argc, const char **argv, const char *prefix,
1154 1133
1155 1134 argc = parse_options(argc, argv, prefix, opts, builtin_config_set_usage,
1156 1135 PARSE_OPT_STOP_AT_NON_OPTION);
1157 - if (argc == 1)
1158 - die_missing_set_value(argv[0]);
1159 1136 check_argc(argc, 2, 2);
1160 1137
1161 1138 if ((flags & CONFIG_FLAGS_FIXED_VALUE) && !value_pattern)
@@ -1313,10 +1290,7 @@ static int show_editor(struct config_location_options *opts)
1313 1290 else if (errno != EEXIST)
1314 1291 die_errno(_("cannot create configuration file %s"), config_file);
1315 1292 }
1316 - if (launch_editor(config_file, NULL, NULL)) {
1317 - free(config_file);
1318 - return -1;
1319 - }
1293 + launch_editor(config_file, NULL, NULL);
1320 1294 free(config_file);
1321 1295
1322 1296 return 0;
@@ -1397,7 +1371,6 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1397 1371 };
1398 1372 char *value = NULL, *comment = NULL;
1399 1373 int ret = 0;
1400 - int actions_implicit;
1401 1374 struct key_value_info default_kvi = KVI_INIT;
1402 1375
1403 1376 argc = parse_options(argc, argv, prefix, opts,
@@ -1412,8 +1385,7 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1412 1385 exit(129);
1413 1386 }
1414 1387
1415 - actions_implicit = (actions == 0);
1416 - if (actions_implicit)
1388 + if (actions == 0)
1417 1389 switch (argc) {
1418 1390 case 1: actions = ACTION_GET; break;
1419 1391 case 2: actions = ACTION_SET; break;
@@ -1422,11 +1394,6 @@ static int cmd_config_actions(int argc, const char **argv, const char *prefix)
1422 1394 error(_("no action specified"));
1423 1395 exit(129);
1424 1396 }
1425 - if (actions_implicit && argc == 1) {
1426 - const char *last_dot = strrchr(argv[0], '.');
1427 - if (last_dot && strchr(last_dot + 1, '='))
1428 - die_missing_set_value(argv[0]);
1429 - }
1430 1397 if (display_opts.omit_values &&
1431 1398 !(actions == ACTION_LIST || actions == ACTION_GET_REGEXP)) {
1432 1399 error(_("--name-only is only applicable to --list or --get-regexp"));
modified builtin/describe.c
@@ -251,19 +251,56 @@ static int compare_pt(const void *a_, const void *b_)
251 251 return 0;
252 252 }
253 253
254 - static unsigned long finish_depth_computation(struct prio_queue *queue,
254 + struct lazy_queue {
255 + struct prio_queue queue;
256 + bool get_pending;
257 + };
258 +
259 + #define LAZY_QUEUE_INIT { { compare_commits_by_commit_date }, false }
260 +
261 + static void *lazy_queue_get(struct lazy_queue *queue)
262 + {
263 + if (queue->get_pending)
264 + prio_queue_get(&queue->queue);
265 + else
266 + queue->get_pending = true;
267 + return prio_queue_peek(&queue->queue);
268 + }
269 +
270 + static void lazy_queue_put(struct lazy_queue *queue, void *thing)
271 + {
272 + if (queue->get_pending)
273 + prio_queue_replace(&queue->queue, thing);
274 + else
275 + prio_queue_put(&queue->queue, thing);
276 + queue->get_pending = false;
277 + }
278 +
279 + static bool lazy_queue_empty(const struct lazy_queue *queue)
280 + {
281 + return queue->queue.nr == (queue->get_pending ? 1 : 0);
282 + }
283 +
284 + static void lazy_queue_clear(struct lazy_queue *queue)
285 + {
286 + clear_prio_queue(&queue->queue);
287 + queue->get_pending = false;
288 + }
289 +
290 + static unsigned long finish_depth_computation(struct lazy_queue *queue,
255 291 struct possible_tag *best)
256 292 {
257 293 unsigned long seen_commits = 0;
258 294 struct oidset unflagged = OIDSET_INIT;
259 - struct commit *c;
260 295
261 - prio_queue_for_each(queue, c) {
262 - if (!(c->object.flags & best->flag_within))
263 - oidset_insert(&unflagged, &c->object.oid);
296 + for (size_t i = queue->get_pending ? 1 : 0; i < queue->queue.nr; i++) {
297 + struct commit *commit = queue->queue.array[i].data;
298 + if (!(commit->object.flags & best->flag_within))
299 + oidset_insert(&unflagged, &commit->object.oid);
264 300 }
265 301
266 - while ((c = prio_queue_get(queue))) {
302 + while (!lazy_queue_empty(queue)) {
303 + struct commit *c = lazy_queue_get(queue);
267 304 struct commit_list *parents = c->parents;
268 305 seen_commits++;
269 306 if (c->object.flags & best->flag_within) {
@@ -279,7 +316,7 @@ static unsigned long finish_depth_computation(struct prio_queue *queue,
279 316 repo_parse_commit(the_repository, p);
280 317 seen = p->object.flags & SEEN;
281 318 if (!seen)
282 - prio_queue_put(queue, p);
319 + lazy_queue_put(queue, p);
283 320 flag_before = p->object.flags & best->flag_within;
284 321 p->object.flags |= c->object.flags;
285 322 flag_after = p->object.flags & best->flag_within;
@@ -327,8 +364,8 @@ static void append_suffix(int depth, const struct object_id *oid, struct strbuf
327 364
328 365 static void describe_commit(struct commit *cmit, struct strbuf *dst)
329 366 {
330 - struct commit *c, *gave_up_on = NULL;
331 - struct prio_queue queue = { compare_commits_by_commit_date };
367 + struct commit *gave_up_on = NULL;
368 + struct lazy_queue queue = LAZY_QUEUE_INIT;
332 369 struct commit_name *n;
333 370 struct possible_tag all_matches[MAX_TAGS];
334 371 unsigned int match_cnt = 0, annotated_cnt = 0, cur_match;
@@ -370,8 +407,9 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
370 407 }
371 408
372 409 cmit->object.flags = SEEN;
373 - prio_queue_put(&queue, cmit);
374 - while ((c = prio_queue_get(&queue))) {
410 + lazy_queue_put(&queue, cmit);
411 + while (!lazy_queue_empty(&queue)) {
412 + struct commit *c = lazy_queue_get(&queue);
375 413 struct commit_list *parents = c->parents;
376 414 struct commit_name **slot;
377 415
@@ -405,7 +443,7 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
405 443 t->depth++;
406 444 }
407 445 /* Stop if last remaining path already covered by best candidate(s) */
408 - if (annotated_cnt && !prio_queue_size(&queue)) {
446 + if (annotated_cnt && lazy_queue_empty(&queue)) {
409 447 int best_depth = INT_MAX;
410 448 unsigned best_within = 0;
411 449 for (cur_match = 0; cur_match < match_cnt; cur_match++) {
@@ -428,7 +466,7 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
428 466 struct commit *p = parents->item;
429 467 repo_parse_commit(the_repository, p);
430 468 if (!(p->object.flags & SEEN))
431 - prio_queue_put(&queue, p);
469 + lazy_queue_put(&queue, p);
432 470 p->object.flags |= c->object.flags;
433 471 parents = parents->next;
434 472
@@ -443,7 +481,7 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
443 481 strbuf_add_unique_abbrev(dst, cmit_oid, abbrev);
444 482 if (suffix)
445 483 strbuf_addstr(dst, suffix);
446 - clear_prio_queue(&queue);
484 + lazy_queue_clear(&queue);
447 485 return;
448 486 }
449 487 if (unannotated_cnt)
@@ -459,11 +497,11 @@ static void describe_commit(struct commit *cmit, struct strbuf *dst)
459 497 QSORT(all_matches, match_cnt, compare_pt);
460 498
461 499 if (gave_up_on) {
462 - prio_queue_put(&queue, gave_up_on);
500 + lazy_queue_put(&queue, gave_up_on);
463 501 seen_commits--;
464 502 }
465 503 seen_commits += finish_depth_computation(&queue, &all_matches[0]);
466 - clear_prio_queue(&queue);
504 + lazy_queue_clear(&queue);
467 505
468 506 if (debug) {
469 507 static int label_width = -1;
@@ -674,25 +712,13 @@ int cmd_describe(int argc,
674 712 NULL);
675 713 if (always)
676 714 strvec_push(&args, "--always");
677 - if (!all)
715 + if (!all) {
678 716 strvec_push(&args, "--tags");
679 -
680 - for_each_string_list_item(item, &patterns)
681 - strvec_pushf(&args, "--refs=refs/tags/%s", item->string);
682 - for_each_string_list_item(item, &exclude_patterns)
683 - strvec_pushf(&args, "--exclude=refs/tags/%s", item->string);
684 -
685 - if (all) {
686 - for_each_string_list_item(item, &patterns)
687 - strvec_pushf(&args, "--refs=refs/heads/%s", item->string);
688 - for_each_string_list_item(item, &exclude_patterns)
689 - strvec_pushf(&args, "--exclude=refs/heads/%s", item->string);
690 717 for_each_string_list_item(item, &patterns)
691 - strvec_pushf(&args, "--refs=refs/remotes/%s", item->string);
718 + strvec_pushf(&args, "--refs=refs/tags/%s", item->string);
692 719 for_each_string_list_item(item, &exclude_patterns)
693 - strvec_pushf(&args, "--exclude=refs/remotes/%s", item->string);
720 + strvec_pushf(&args, "--exclude=refs/tags/%s", item->string);
694 721 }
695 -
696 722 if (argc)
697 723 strvec_pushv(&args, argv);
698 724 else
@@ -714,9 +740,6 @@ int cmd_describe(int argc,
714 740 return ret;
715 741 }
716 742
717 - if (!all)
718 - for_each_ref_opts.prefix = "refs/tags/";
719 -
720 743 hashmap_init(&names, commit_name_neq, NULL, 0);
721 744 refs_for_each_ref_ext(get_main_ref_store(the_repository),
722 745 get_name, NULL, &for_each_ref_opts);
@@ -758,7 +781,7 @@ int cmd_describe(int argc,
758 781 struct rev_info revs;
759 782 int fd;
760 783
761 - setup_work_tree(the_repository);
784 + setup_work_tree();
762 785 prepare_repo_settings(the_repository);
763 786 the_repository->settings.command_requires_full_index = 0;
764 787 repo_read_index(the_repository);
modified builtin/diff-index.c
@@ -69,7 +69,7 @@ int cmd_diff_index(int argc,
69 69 rev.max_count != -1 || rev.min_age != -1 || rev.max_age != -1)
70 70 usage(diff_cache_usage);
71 71 if (!(option & DIFF_INDEX_CACHED)) {
72 - setup_work_tree(the_repository);
72 + setup_work_tree();
73 73 if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
74 74 perror("repo_read_index_preload");
75 75 return -1;
modified builtin/diff.c
@@ -159,7 +159,7 @@ static void builtin_diff_index(struct rev_info *revs,
159 159 revs->max_age != -1)
160 160 usage(builtin_diff_usage);
161 161 if (!(option & DIFF_INDEX_CACHED)) {
162 - setup_work_tree(the_repository);
162 + setup_work_tree();
163 163 if (repo_read_index_preload(the_repository,
164 164 &revs->diffopt.pathspec, 0) < 0) {
165 165 die_errno("repo_read_index_preload");
@@ -281,7 +281,7 @@ static void builtin_diff_files(struct rev_info *revs, int argc, const char **arg
281 281 (revs->diffopt.output_format & DIFF_FORMAT_PATCH))
282 282 diff_merges_set_dense_combined_if_unset(revs);
283 283
284 - setup_work_tree(the_repository);
284 + setup_work_tree();
285 285 if (repo_read_index_preload(the_repository, &revs->diffopt.pathspec,
286 286 0) < 0) {
287 287 die_errno("repo_read_index_preload");
@@ -455,7 +455,7 @@ int cmd_diff(int argc,
455 455 break;
456 456 }
457 457
458 - prefix = setup_git_directory_gently(the_repository, &nongit);
458 + prefix = setup_git_directory_gently(&nongit);
459 459
460 460 if (!nongit) {
461 461 prepare_repo_settings(the_repository);
@@ -471,8 +471,8 @@ int cmd_diff(int argc,
471 471 * as a colourful "diff" replacement.
472 472 */
473 473 if (nongit || ((argc == i + 2) &&
474 - (!path_inside_repo(the_repository, prefix, argv[i]) ||
475 - !path_inside_repo(the_repository, prefix, argv[i + 1]))))
474 + (!path_inside_repo(prefix, argv[i]) ||
475 + !path_inside_repo(prefix, argv[i + 1]))))
476 476 no_index = DIFF_NO_INDEX_IMPLICIT;
477 477 }
478 478
@@ -579,13 +579,9 @@ int cmd_diff(int argc,
579 579 obj = deref_tag(the_repository, obj, NULL, 0);
580 580 if (!obj)
581 581 die(_("invalid object '%s' given."), name);
582 - if (obj->type == OBJ_COMMIT) {
583 - struct tree *tree = repo_get_commit_tree(
584 - the_repository, (struct commit *)obj);
585 - if (!tree)
586 - die(_("unable to read tree object for commit '%s'"), name);
587 - obj = &tree->object;
588 - }
582 + if (obj->type == OBJ_COMMIT)
583 + obj = &repo_get_commit_tree(the_repository,
584 + ((struct commit *)obj))->object;
589 585
590 586 if (obj->type == OBJ_TREE) {
591 587 if (sdiff.skip && bitmap_get(sdiff.skip, i))
modified builtin/difftool.c
@@ -319,7 +319,7 @@ static char *get_symlink(struct repository *repo,
319 319 data = strbuf_detach(&link, NULL);
320 320 } else {
321 321 enum object_type type;
322 - size_t size;
322 + unsigned long size;
323 323 data = odb_read_object(repo->objects, oid, &type, &size);
324 324 if (!data)
325 325 die(_("could not read object %s for symlink %s"),
@@ -552,7 +552,7 @@ static int run_dir_diff(struct repository *repo,
552 552 struct stat st;
553 553 if (stat(wtdir.buf, &st))
554 554 st.st_mode = 0644;
555 - if (copy_file(repo, rdir.buf, wtdir.buf,
555 + if (copy_file(rdir.buf, wtdir.buf,
556 556 st.st_mode)) {
557 557 ret = error("could not copy '%s' to '%s'", wtdir.buf, rdir.buf);
558 558 goto finish;
@@ -636,7 +636,7 @@ static int run_dir_diff(struct repository *repo,
636 636 struct lock_file lock = LOCK_INIT;
637 637 strbuf_reset(&buf);
638 638 strbuf_addf(&buf, "%s/wtindex", tmpdir.buf);
639 - if (repo_hold_lock_file_for_update(repo, &lock, buf.buf, 0) < 0 ||
639 + if (hold_lock_file_for_update(&lock, buf.buf, 0) < 0 ||
640 640 write_locked_index(&wtindex, &lock, COMMIT_LOCK)) {
641 641 ret = error("could not write %s", buf.buf);
642 642 goto finish;
@@ -658,7 +658,7 @@ static int run_dir_diff(struct repository *repo,
658 658 warning("%s", "");
659 659 err = 1;
660 660 } else if (unlink(wtdir.buf) ||
661 - copy_file(repo, wtdir.buf, rdir.buf, st.st_mode))
661 + copy_file(wtdir.buf, rdir.buf, st.st_mode))
662 662 warning_errno(_("could not copy '%s' to '%s'"),
663 663 rdir.buf, wtdir.buf);
664 664 }
@@ -767,7 +767,7 @@ int cmd_difftool(int argc,
767 767 die(_("difftool requires worktree or --no-index"));
768 768
769 769 if (!no_index){
770 - setup_work_tree(repo);
770 + setup_work_tree();
771 771 setenv(GIT_DIR_ENVIRONMENT, absolute_path(repo_get_git_dir(repo)), 1);
772 772 setenv(GIT_WORK_TREE_ENVIRONMENT, absolute_path(repo_get_work_tree(repo)), 1);
773 773 } else if (dir_diff)
modified builtin/fast-export.c
@@ -33,7 +33,7 @@
33 33 #include "gpg-interface.h"
34 34
35 35 static const char *const fast_export_usage[] = {
36 - N_("git fast-export [<options>] [<revision-range>] [[--] <path>...]"),
36 + N_("git fast-export [<rev-list-opts>]"),
37 37 NULL
38 38 };
39 39
@@ -51,7 +51,7 @@ static int show_original_ids;
51 51 static int mark_tags;
52 52 static struct string_list extra_refs = STRING_LIST_INIT_DUP;
53 53 static struct string_list tag_refs = STRING_LIST_INIT_DUP;
54 - static struct refspec refspecs;
54 + static struct refspec refspecs = REFSPEC_INIT_FETCH;
55 55 static int anonymize;
56 56 static struct hashmap anonymized_seeds;
57 57 static struct revision_sources revision_sources;
@@ -317,10 +317,7 @@ static void export_blob(const struct object_id *oid)
317 317 object = (struct object *)lookup_blob(the_repository, oid);
318 318 eaten = 0;
319 319 } else {
320 - size_t size_st = 0;
321 - buf = odb_read_object(the_repository->objects, oid, &type,
322 - &size_st);
323 - size = cast_size_t_to_ulong(size_st);
320 + buf = odb_read_object(the_repository->objects, oid, &type, &size);
324 321 if (!buf)
325 322 die(_("could not read blob %s"), oid_to_hex(oid));
326 323 if (check_object_signature(the_repository, oid, buf, size,
@@ -883,7 +880,7 @@ static char *anonymize_tag(void)
883 880
884 881 static void handle_tag(const char *name, struct tag *tag)
885 882 {
886 - size_t size;
883 + unsigned long size;
887 884 enum object_type type;
888 885 char *buf;
889 886 const char *tagger, *tagger_end, *message;
@@ -1372,8 +1369,6 @@ int cmd_fast_export(int argc,
1372 1369 /* we handle encodings */
1373 1370 repo_config(the_repository, git_default_config, NULL);
1374 1371
1375 - refspec_init_fetch(&refspecs, the_hash_algo);
1376 -
1377 1372 repo_init_revisions(the_repository, &revs, prefix);
1378 1373 init_revision_sources(&revision_sources);
1379 1374 revs.topo_order = 1;
modified builtin/fast-import.c
@@ -30,7 +30,6 @@
30 30 #include "khash.h"
31 31 #include "date.h"
32 32 #include "gpg-interface.h"
33 - #include "parse-options.h"
34 33
35 34 #define PACK_ID_BITS 16
36 35 #define MAX_PACK_ID ((1<<PACK_ID_BITS)-1)
@@ -183,8 +182,12 @@ static unsigned long branch_count;
183 182 static unsigned long branch_load_count;
184 183 static int failure;
185 184 static FILE *pack_edges;
186 - static int show_stats = 1;
187 - static int quiet;
185 + static unsigned int show_stats = 1;
186 + static unsigned int quiet;
187 + static int global_argc;
188 + static const char **global_argv;
189 + static const char *global_prefix;
190 +
188 191 static enum sign_mode signed_tag_mode = SIGN_VERBATIM;
189 192 static enum sign_mode signed_commit_mode = SIGN_VERBATIM;
190 193 static const char *signed_commit_keyid;
@@ -258,7 +261,9 @@ static struct recent_command *rc_free;
258 261 static unsigned int cmd_save = 100;
259 262 static uintmax_t next_mark;
260 263 static struct strbuf new_data = STRBUF_INIT;
264 + static int seen_data_command;
261 265 static int require_explicit_termination;
266 + static int allow_unsafe_features;
262 267
263 268 /* Signal handling */
264 269 static volatile sig_atomic_t checkpoint_requested;
@@ -271,33 +276,10 @@ static kh_oid_map_t *sub_oid_map;
271 276 /* Where to write output of cat-blob commands */
272 277 static int cat_blob_fd = STDOUT_FILENO;
273 278
274 - /* Command state */
275 - struct fast_import_state {
276 - int argc;
277 - const char **argv;
278 - const char *prefix;
279 - int seen_data_command;
280 - int allow_unsafe_features;
281 - struct option *option;
282 - };
283 -
284 - static void fast_import_state_init(struct fast_import_state *state,
285 - int argc, const char **argv,
286 - const char *prefix, struct option *option)
287 - {
288 - memset(state, 0, sizeof(*state));
289 - state->argc = argc;
290 - state->argv = argv;
291 - state->prefix = prefix;
292 - state->option = option;
293 - }
294 -
295 - static void parse_argv(struct fast_import_state *state);
296 - static void parse_get_mark(struct fast_import_state *state, const char *p);
297 - static void parse_cat_blob(struct fast_import_state *state, const char *p);
298 - static void parse_ls(struct fast_import_state *state,
299 - const char *p,
300 - struct branch *b);
279 + static void parse_argv(void);
280 + static void parse_get_mark(const char *p);
281 + static void parse_cat_blob(const char *p);
282 + static void parse_ls(const char *p, struct branch *b);
301 283
302 284 static void for_each_mark(struct mark_set *m, uintmax_t base, each_mark_fn_t callback, void *p)
303 285 {
@@ -980,14 +962,13 @@ static int store_object(
980 962 struct object_entry *e;
981 963 unsigned char hdr[96];
982 964 struct object_id oid;
983 - unsigned long hdrlen, deltalen = 0;
965 + unsigned long hdrlen, deltalen;
984 966 struct git_hash_ctx c;
985 967 git_zstream s;
986 - struct repo_config_values *cfg = repo_config_values(the_repository);
987 968
988 969 hdrlen = format_object_header((char *)hdr, sizeof(hdr), type,
989 970 dat->len);
990 - git_hash_init(&c, the_hash_algo);
971 + the_hash_algo->init_fn(&c);
991 972 git_hash_update(&c, hdr, hdrlen);
992 973 git_hash_update(&c, dat->buf, dat->len);
993 974 git_hash_final_oid(&oid, &c);
@@ -1016,17 +997,15 @@ static int store_object(
1016 997
1017 998 if (last && last->data.len && last->data.buf && last->depth < max_depth
1018 999 && dat->len > the_hash_algo->rawsz) {
1019 - size_t deltalen_st;
1020 1000
1021 1001 delta_count_attempts_by_type[type]++;
1022 1002 delta = diff_delta(last->data.buf, last->data.len,
1023 1003 dat->buf, dat->len,
1024 - &deltalen_st, dat->len - the_hash_algo->rawsz);
1025 - deltalen = cast_size_t_to_ulong(deltalen_st);
1004 + &deltalen, dat->len - the_hash_algo->rawsz);
1026 1005 } else
1027 1006 delta = NULL;
1028 1007
1029 - git_deflate_init(&s, cfg->pack_compression_level);
1008 + git_deflate_init(&s, pack_compression_level);
1030 1009 if (delta) {
1031 1010 s.next_in = delta;
1032 1011 s.avail_in = deltalen;
@@ -1053,7 +1032,7 @@ static int store_object(
1053 1032 if (delta) {
1054 1033 FREE_AND_NULL(delta);
1055 1034
1056 - git_deflate_init(&s, cfg->pack_compression_level);
1035 + git_deflate_init(&s, pack_compression_level);
1057 1036 s.next_in = (void *)dat->buf;
1058 1037 s.avail_in = dat->len;
1059 1038 s.avail_out = git_deflate_bound(&s, s.avail_in);
@@ -1136,7 +1115,6 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1136 1115 struct git_hash_ctx c;
1137 1116 git_zstream s;
1138 1117 struct hashfile_checkpoint checkpoint;
1139 - struct repo_config_values *cfg = repo_config_values(the_repository);
1140 1118 int status = Z_OK;
1141 1119
1142 1120 /* Determine if we should auto-checkpoint. */
@@ -1151,12 +1129,12 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1151 1129
1152 1130 hdrlen = format_object_header((char *)out_buf, out_sz, OBJ_BLOB, len);
1153 1131
1154 - git_hash_init(&c, the_hash_algo);
1132 + the_hash_algo->init_fn(&c);
1155 1133 git_hash_update(&c, out_buf, hdrlen);
1156 1134
1157 1135 crc32_begin(pack_file);
1158 1136
1159 - git_deflate_init(&s, cfg->pack_compression_level);
1137 + git_deflate_init(&s, pack_compression_level);
1160 1138
1161 1139 hdrlen = encode_in_pack_object_header(out_buf, out_sz, OBJ_BLOB, len);
1162 1140
@@ -1236,7 +1214,6 @@ static void stream_blob(uintmax_t len, struct object_id *oidout, uintmax_t mark)
1236 1214 out:
1237 1215 free(in_buf);
1238 1216 free(out_buf);
1239 - hashfile_checkpoint_release(&checkpoint);
1240 1217 }
1241 1218
1242 1219 /* All calls must be guarded by find_object() or find_mark() to
@@ -1262,8 +1239,6 @@ static void *gfi_unpack_entry(
1262 1239 unsigned long *sizep)
1263 1240 {
1264 1241 enum object_type type;
1265 - size_t size_st = 0;
1266 - void *data;
1267 1242 struct packed_git *p = all_packs[oe->pack_id];
1268 1243 if (p == pack_data && p->pack_size < (pack_size + the_hash_algo->rawsz)) {
1269 1244 /* The object is stored in the packfile we are writing to
@@ -1285,10 +1260,7 @@ static void *gfi_unpack_entry(
1285 1260 */
1286 1261 p->pack_size = pack_size + the_hash_algo->rawsz;
1287 1262 }
1288 - data = unpack_entry(the_repository, p, oe->idx.offset, &type, &size_st);
1289 - if (sizep)
1290 - *sizep = cast_size_t_to_ulong(size_st);
1291 - return data;
1263 + return unpack_entry(the_repository, p, oe->idx.offset, &type, sizep);
1292 1264 }
1293 1265
1294 1266 static void load_tree(struct tree_entry *root)
@@ -1314,10 +1286,7 @@ static void load_tree(struct tree_entry *root)
1314 1286 die(_("can't load tree %s"), oid_to_hex(oid));
1315 1287 } else {
1316 1288 enum object_type type;
1317 - size_t size_st = 0;
1318 - buf = odb_read_object(the_repository->objects, oid, &type,
1319 - &size_st);
1320 - size = cast_size_t_to_ulong(size_st);
1289 + buf = odb_read_object(the_repository->objects, oid, &type, &size);
1321 1290 if (!buf || type != OBJ_TREE)
1322 1291 die(_("can't load tree %s"), oid_to_hex(oid));
1323 1292 }
@@ -1865,7 +1834,7 @@ done:
1865 1834 }
1866 1835
1867 1836
1868 - static int read_next_command(struct fast_import_state *state)
1837 + static int read_next_command(void)
1869 1838 {
1870 1839 static int stdin_eof = 0;
1871 1840
@@ -1884,10 +1853,10 @@ static int read_next_command(struct fast_import_state *state)
1884 1853 if (stdin_eof)
1885 1854 return EOF;
1886 1855
1887 - if (!state->seen_data_command
1856 + if (!seen_data_command
1888 1857 && !starts_with(command_buf.buf, "feature ")
1889 1858 && !starts_with(command_buf.buf, "option ")) {
1890 - parse_argv(state);
1859 + parse_argv();
1891 1860 }
1892 1861
1893 1862 rc = rc_free;
@@ -1919,22 +1888,22 @@ static void skip_optional_lf(void)
1919 1888 ungetc(term_char, stdin);
1920 1889 }
1921 1890
1922 - static void parse_mark(struct fast_import_state *state)
1891 + static void parse_mark(void)
1923 1892 {
1924 1893 const char *v;
1925 1894 if (skip_prefix(command_buf.buf, "mark :", &v)) {
1926 1895 next_mark = strtoumax(v, NULL, 10);
1927 - read_next_command(state);
1896 + read_next_command();
1928 1897 }
1929 1898 else
1930 1899 next_mark = 0;
1931 1900 }
1932 1901
1933 - static void parse_original_identifier(struct fast_import_state *state)
1902 + static void parse_original_identifier(void)
1934 1903 {
1935 1904 const char *v;
1936 1905 if (skip_prefix(command_buf.buf, "original-oid ", &v))
1937 - read_next_command(state);
1906 + read_next_command();
1938 1907 }
1939 1908
1940 1909 static int parse_data(struct strbuf *sb, uintmax_t limit, uintmax_t *len_res)
@@ -2088,11 +2057,11 @@ static void parse_and_store_blob(
2088 2057 }
2089 2058 }
2090 2059
2091 - static void parse_new_blob(struct fast_import_state *state)
2060 + static void parse_new_blob(void)
2092 2061 {
2093 - read_next_command(state);
2094 - parse_mark(state);
2095 - parse_original_identifier(state);
2062 + read_next_command();
2063 + parse_mark();
2064 + parse_original_identifier();
2096 2065 parse_and_store_blob(&last_blob, NULL, next_mark);
2097 2066 }
2098 2067
@@ -2388,9 +2357,7 @@ static void parse_path_space(struct strbuf *sb, const char *p,
2388 2357 (*endp)++;
2389 2358 }
2390 2359
2391 - static void file_change_m(struct fast_import_state *state,
2392 - const char *p,
2393 - struct branch *b)
2360 + static void file_change_m(const char *p, struct branch *b)
2394 2361 {
2395 2362 static struct strbuf path = STRBUF_INIT;
2396 2363 struct object_entry *oe;
@@ -2457,10 +2424,10 @@ static void file_change_m(struct fast_import_state *state,
2457 2424 if (S_ISDIR(mode))
2458 2425 die(_("directories cannot be specified 'inline': %s"),
2459 2426 command_buf.buf);
2460 - while (read_next_command(state) != EOF) {
2427 + while (read_next_command() != EOF) {
2461 2428 const char *v;
2462 2429 if (skip_prefix(command_buf.buf, "cat-blob ", &v))
2463 - parse_cat_blob(state, v);
2430 + parse_cat_blob(v);
2464 2431 else {
2465 2432 parse_and_store_blob(&last_blob, &oid, 0);
2466 2433 break;
@@ -2534,10 +2501,7 @@ static void file_change_cr(const char *p, struct branch *b, int rename)
2534 2501 leaf.tree);
2535 2502 }
2536 2503
2537 - static void note_change_n(struct fast_import_state *state,
2538 - const char *p,
2539 - struct branch *b,
2540 - unsigned char *old_fanout)
2504 + static void note_change_n(const char *p, struct branch *b, unsigned char *old_fanout)
2541 2505 {
2542 2506 struct object_entry *oe;
2543 2507 struct branch *s;
@@ -2591,7 +2555,7 @@ static void note_change_n(struct fast_import_state *state,
2591 2555 die(_("mark :%" PRIuMAX " not a commit"), commit_mark);
2592 2556 oidcpy(&commit_oid, &commit_oe->idx.oid);
2593 2557 } else if (!repo_get_oid(the_repository, p, &commit_oid)) {
2594 - size_t size;
2558 + unsigned long size;
2595 2559 char *buf = odb_read_object_peeled(the_repository->objects,
2596 2560 &commit_oid, OBJ_COMMIT, &size,
2597 2561 &commit_oid);
@@ -2602,7 +2566,7 @@ static void note_change_n(struct fast_import_state *state,
2602 2566 die(_("invalid ref name or SHA1 expression: %s"), p);
2603 2567
2604 2568 if (inline_data) {
2605 - read_next_command(state);
2569 + read_next_command();
2606 2570 parse_and_store_blob(&last_blob, &oid, 0);
2607 2571 } else if (oe) {
2608 2572 if (oe->type != OBJ_BLOB)
@@ -2658,20 +2622,16 @@ static void parse_from_existing(struct branch *b)
2658 2622 oidclr(&b->branch_tree.versions[1].oid, the_repository->hash_algo);
2659 2623 } else {
2660 2624 unsigned long size;
2661 - size_t size_st = 0;
2662 2625 char *buf;
2663 2626
2664 2627 buf = odb_read_object_peeled(the_repository->objects, &b->oid,
2665 - OBJ_COMMIT, &size_st, &b->oid);
2666 - size = cast_size_t_to_ulong(size_st);
2628 + OBJ_COMMIT, &size, &b->oid);
2667 2629 parse_from_commit(b, buf, size);
2668 2630 free(buf);
2669 2631 }
2670 2632 }
2671 2633
2672 - static int parse_objectish(struct fast_import_state *state,
2673 - struct branch *b,
2674 - const char *objectish)
2634 + static int parse_objectish(struct branch *b, const char *objectish)
2675 2635 {
2676 2636 struct branch *s;
2677 2637 struct object_id oid;
@@ -2714,34 +2674,31 @@ static int parse_objectish(struct fast_import_state *state,
2714 2674 b->branch_tree.tree = NULL;
2715 2675 }
2716 2676
2717 - read_next_command(state);
2677 + read_next_command();
2718 2678 return 1;
2719 2679 }
2720 2680
2721 - static int parse_from(struct fast_import_state *state, struct branch *b)
2681 + static int parse_from(struct branch *b)
2722 2682 {
2723 2683 const char *from;
2724 2684
2725 2685 if (!skip_prefix(command_buf.buf, "from ", &from))
2726 2686 return 0;
2727 2687
2728 - return parse_objectish(state, b, from);
2688 + return parse_objectish(b, from);
2729 2689 }
2730 2690
2731 - static int parse_objectish_with_prefix(struct fast_import_state *state,
2732 - struct branch *b,
2733 - const char *prefix)
2691 + static int parse_objectish_with_prefix(struct branch *b, const char *prefix)
2734 2692 {
2735 2693 const char *base;
2736 2694
2737 2695 if (!skip_prefix(command_buf.buf, prefix, &base))
2738 2696 return 0;
2739 2697
2740 - return parse_objectish(state, b, base);
2698 + return parse_objectish(b, base);
2741 2699 }
2742 2700
2743 - static struct hash_list *parse_merge(struct fast_import_state *state,
2744 - unsigned int *count)
2701 + static struct hash_list *parse_merge(unsigned int *count)
2745 2702 {
2746 2703 struct hash_list *list = NULL, **tail = &list, *n;
2747 2704 const char *from;
@@ -2760,7 +2717,7 @@ static struct hash_list *parse_merge(struct fast_import_state *state,
2760 2717 die(_("mark :%" PRIuMAX " not a commit"), idnum);
2761 2718 oidcpy(&n->oid, &oe->idx.oid);
2762 2719 } else if (!repo_get_oid(the_repository, from, &n->oid)) {
2763 - size_t size;
2720 + unsigned long size;
2764 2721 char *buf = odb_read_object_peeled(the_repository->objects,
2765 2722 &n->oid, OBJ_COMMIT,
2766 2723 &size, &n->oid);
@@ -2775,7 +2732,7 @@ static struct hash_list *parse_merge(struct fast_import_state *state,
2775 2732 tail = &n->next;
2776 2733
2777 2734 (*count)++;
2778 - read_next_command(state);
2735 + read_next_command();
2779 2736 }
2780 2737 return list;
2781 2738 }
@@ -2786,9 +2743,7 @@ struct signature_data {
2786 2743 struct strbuf data; /* The actual signature data */
2787 2744 };
2788 2745
2789 - static void parse_one_signature(struct fast_import_state *state,
2790 - struct signature_data *sig,
2791 - const char *v)
2746 + static void parse_one_signature(struct signature_data *sig, const char *v)
2792 2747 {
2793 2748 char *args = xstrdup(v); /* Will be freed when sig->hash_algo is freed */
2794 2749 char *space = strchr(args, ' ');
@@ -2813,15 +2768,15 @@ static void parse_one_signature(struct fast_import_state *state,
2813 2768 warning(_("'unknown' signature format in gpgsig"));
2814 2769
2815 2770 /* Read signature data */
2816 - read_next_command(state);
2771 + read_next_command();
2817 2772 parse_data(&sig->data, 0, NULL);
2818 2773 }
2819 2774
2820 - static void discard_one_signature(struct fast_import_state *state)
2775 + static void discard_one_signature(void)
2821 2776 {
2822 2777 struct strbuf data = STRBUF_INIT;
2823 2778
2824 - read_next_command(state);
2779 + read_next_command();
2825 2780 parse_data(&data, 0, NULL);
2826 2781 strbuf_release(&data);
2827 2782 }
@@ -2859,14 +2814,13 @@ static void store_signature(struct signature_data *stored_sig,
2859 2814 }
2860 2815 }
2861 2816
2862 - static void import_one_signature(struct fast_import_state *state,
2863 - struct signature_data *sig_sha1,
2817 + static void import_one_signature(struct signature_data *sig_sha1,
2864 2818 struct signature_data *sig_sha256,
2865 2819 const char *v)
2866 2820 {
2867 2821 struct signature_data sig = { NULL, NULL, STRBUF_INIT };
2868 2822
2869 - parse_one_signature(state, &sig, v);
2823 + parse_one_signature(&sig, v);
2870 2824
2871 2825 if (!strcmp(sig.hash_algo, "sha1"))
2872 2826 store_signature(sig_sha1, &sig, "SHA-1");
@@ -2980,7 +2934,7 @@ static void handle_signature_if_invalid(struct strbuf *new_data,
2980 2934 strbuf_release(&tmp_buf);
2981 2935 }
2982 2936
2983 - static void parse_new_commit(struct fast_import_state *state, const char *arg)
2937 + static void parse_new_commit(const char *arg)
2984 2938 {
2985 2939 static struct strbuf msg = STRBUF_INIT;
2986 2940 struct signature_data sig_sha1 = { NULL, NULL, STRBUF_INIT };
@@ -2998,16 +2952,16 @@ static void parse_new_commit(struct fast_import_state *state, const char *arg)
2998 2952 if (!b)
2999 2953 b = new_branch(arg);
3000 2954
3001 - read_next_command(state);
3002 - parse_mark(state);
3003 - parse_original_identifier(state);
2955 + read_next_command();
2956 + parse_mark();
2957 + parse_original_identifier();
3004 2958 if (skip_prefix(command_buf.buf, "author ", &v)) {
3005 2959 author = parse_ident(v);
3006 - read_next_command(state);
2960 + read_next_command();
3007 2961 }
3008 2962 if (skip_prefix(command_buf.buf, "committer ", &v)) {
3009 2963 committer = parse_ident(v);
3010 - read_next_command(state);
2964 + read_next_command();
3011 2965 }
3012 2966 if (!committer)
3013 2967 die(_("expected committer but didn't get one"));
@@ -3023,7 +2977,7 @@ static void parse_new_commit(struct fast_import_state *state, const char *arg)
3023 2977 warning(_("stripping a commit signature"));
3024 2978 /* fallthru */
3025 2979 case SIGN_STRIP:
3026 - discard_one_signature(state);
2980 + discard_one_signature();
3027 2981 break;
3028 2982
3029 2983 /* Second, modes that parse the signature */
@@ -3034,24 +2988,24 @@ static void parse_new_commit(struct fast_import_state *state, const char *arg)
3034 2988 case SIGN_STRIP_IF_INVALID:
3035 2989 case SIGN_SIGN_IF_INVALID:
3036 2990 case SIGN_ABORT_IF_INVALID:
3037 - import_one_signature(state, &sig_sha1, &sig_sha256, v);
2991 + import_one_signature(&sig_sha1, &sig_sha256, v);
3038 2992 break;
3039 2993
3040 2994 /* Third, BUG */
3041 2995 default:
3042 2996 BUG("invalid signed_commit_mode value %d", signed_commit_mode);
3043 2997 }
3044 - read_next_command(state);
2998 + read_next_command();
3045 2999 }
3046 3000
3047 3001 if (skip_prefix(command_buf.buf, "encoding ", &v)) {
3048 3002 encoding = xstrdup(v);
3049 - read_next_command(state);
3003 + read_next_command();
3050 3004 }
3051 3005 parse_data(&msg, 0, NULL);
3052 - read_next_command(state);
3053 - parse_from(state, b);
3054 - merge_list = parse_merge(state, &merge_count);
3006 + read_next_command();
3007 + parse_from(b);
3008 + merge_list = parse_merge(&merge_count);
3055 3009
3056 3010 /* ensure the branch is active/loaded */
3057 3011 if (!b->branch_tree.tree || !max_active_branches) {
@@ -3064,7 +3018,7 @@ static void parse_new_commit(struct fast_import_state *state, const char *arg)
3064 3018 /* file_change* */
3065 3019 while (command_buf.len > 0) {
3066 3020 if (skip_prefix(command_buf.buf, "M ", &v))
3067 - file_change_m(state, v, b);
3021 + file_change_m(v, b);
3068 3022 else if (skip_prefix(command_buf.buf, "D ", &v))
3069 3023 file_change_d(v, b);
3070 3024 else if (skip_prefix(command_buf.buf, "R ", &v))
@@ -3072,18 +3026,18 @@ static void parse_new_commit(struct fast_import_state *state, const char *arg)
3072 3026 else if (skip_prefix(command_buf.buf, "C ", &v))
3073 3027 file_change_cr(v, b, 0);
3074 3028 else if (skip_prefix(command_buf.buf, "N ", &v))
3075 - note_change_n(state, v, b, &prev_fanout);
3029 + note_change_n(v, b, &prev_fanout);
3076 3030 else if (!strcmp("deleteall", command_buf.buf))
3077 3031 file_change_deleteall(b);
3078 3032 else if (skip_prefix(command_buf.buf, "ls ", &v))
3079 - parse_ls(state, v, b);
3033 + parse_ls(v, b);
3080 3034 else if (skip_prefix(command_buf.buf, "cat-blob ", &v))
3081 - parse_cat_blob(state, v);
3035 + parse_cat_blob(v);
3082 3036 else {
3083 3037 unread_command_buf = 1;
3084 3038 break;
3085 3039 }
3086 - if (read_next_command(state) == EOF)
3040 + if (read_next_command() == EOF)
3087 3041 break;
3088 3042 }
3089 3043
@@ -3221,7 +3175,7 @@ static void handle_tag_signature(struct strbuf *buf, struct strbuf *msg, const c
3221 3175 }
3222 3176 }
3223 3177
3224 - static void parse_new_tag(struct fast_import_state *state, const char *arg)
3178 + static void parse_new_tag(const char *arg)
3225 3179 {
3226 3180 static struct strbuf msg = STRBUF_INIT;
3227 3181 const char *from;
@@ -3240,8 +3194,8 @@ static void parse_new_tag(struct fast_import_state *state, const char *arg)
3240 3194 else
3241 3195 first_tag = t;
3242 3196 last_tag = t;
3243 - read_next_command(state);
3244 - parse_mark(state);
3197 + read_next_command();
3198 + parse_mark();
3245 3199
3246 3200 /* from ... */
3247 3201 if (!skip_prefix(command_buf.buf, "from ", &from))
@@ -3269,15 +3223,15 @@ static void parse_new_tag(struct fast_import_state *state, const char *arg)
3269 3223 type = oe->type;
3270 3224 } else
3271 3225 die(_("invalid ref name or SHA1 expression: %s"), from);
3272 - read_next_command(state);
3226 + read_next_command();
3273 3227
3274 3228 /* original-oid ... */
3275 - parse_original_identifier(state);
3229 + parse_original_identifier();
3276 3230
3277 3231 /* tagger ... */
3278 3232 if (skip_prefix(command_buf.buf, "tagger ", &v)) {
3279 3233 tagger = parse_ident(v);
3280 - read_next_command(state);
3234 + read_next_command();
3281 3235 } else
3282 3236 tagger = NULL;
3283 3237
@@ -3308,7 +3262,7 @@ static void parse_new_tag(struct fast_import_state *state, const char *arg)
3308 3262 t->pack_id = pack_id;
3309 3263 }
3310 3264
3311 - static void parse_reset_branch(struct fast_import_state *state, const char *arg)
3265 + static void parse_reset_branch(const char *arg)
3312 3266 {
3313 3267 struct branch *b;
3314 3268 const char *tag_name;
@@ -3325,8 +3279,8 @@ static void parse_reset_branch(struct fast_import_state *state, const char *arg)
3325 3279 }
3326 3280 else
3327 3281 b = new_branch(arg);
3328 - read_next_command(state);
3329 - parse_from(state, b);
3282 + read_next_command();
3283 + parse_from(b);
3330 3284 if (b->delete && skip_prefix(b->name, "refs/tags/", &tag_name)) {
3331 3285 /*
3332 3286 * Elsewhere, we call dump_branches() before dump_tags(),
@@ -3366,16 +3320,12 @@ static void cat_blob_write(const char *buf, unsigned long size)
3366 3320 static void cat_blob(struct object_entry *oe, struct object_id *oid)
3367 3321 {
3368 3322 struct strbuf line = STRBUF_INIT;
3369 - struct iovec iov[3];
3370 3323 unsigned long size;
3371 3324 enum object_type type = 0;
3372 3325 char *buf;
3373 3326
3374 3327 if (!oe || oe->pack_id == MAX_PACK_ID) {
3375 - size_t size_st = 0;
3376 - buf = odb_read_object(the_repository->objects, oid, &type,
3377 - &size_st);
3378 - size = cast_size_t_to_ulong(size_st);
3328 + buf = odb_read_object(the_repository->objects, oid, &type, &size);
3379 3329 } else {
3380 3330 type = oe->type;
3381 3331 buf = gfi_unpack_entry(oe, &size);
@@ -3400,21 +3350,10 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
3400 3350 strbuf_reset(&line);
3401 3351 strbuf_addf(&line, "%s %s %"PRIuMAX"\n", oid_to_hex(oid),
3402 3352 type_name(type), (uintmax_t)size);
3403 -
3404 - /*
3405 - * Write the header, the payload and the trailing newline with a
3406 - * single writev(3p) call instead of three separate write(3p) calls.
3407 - */
3408 - iov[0].iov_base = line.buf;
3409 - iov[0].iov_len = line.len;
3410 - iov[1].iov_base = buf;
3411 - iov[1].iov_len = size;
3412 - iov[2].iov_base = (void *) "\n";
3413 - iov[2].iov_len = 1;
3414 -
3415 - if (writev_in_full(cat_blob_fd, iov, ARRAY_SIZE(iov)) < 0)
3416 - die_errno(_("write to frontend failed"));
3353 + cat_blob_write(line.buf, line.len);
3417 3354 strbuf_release(&line);
3355 + cat_blob_write(buf, size);
3356 + cat_blob_write("\n", 1);
3418 3357 if (oe && oe->pack_id == pack_id) {
3419 3358 last_blob.offset = oe->idx.offset;
3420 3359 strbuf_attach(&last_blob.data, buf, size, size + 1);
@@ -3423,8 +3362,7 @@ static void cat_blob(struct object_entry *oe, struct object_id *oid)
3423 3362 free(buf);
3424 3363 }
3425 3364
3426 - static void parse_get_mark(struct fast_import_state *state UNUSED,
3427 - const char *p)
3365 + static void parse_get_mark(const char *p)
3428 3366 {
3429 3367 struct object_entry *oe;
3430 3368 char output[GIT_MAX_HEXSZ + 2];
@@ -3441,8 +3379,7 @@ static void parse_get_mark(struct fast_import_state *state UNUSED,
3441 3379 cat_blob_write(output, the_hash_algo->hexsz + 1);
3442 3380 }
3443 3381
3444 - static void parse_cat_blob(struct fast_import_state *state UNUSED,
3445 - const char *p)
3382 + static void parse_cat_blob(const char *p)
3446 3383 {
3447 3384 struct object_entry *oe;
3448 3385 struct object_id oid;
@@ -3496,10 +3433,8 @@ static struct object_entry *dereference(struct object_entry *oe,
3496 3433 buf = gfi_unpack_entry(oe, &size);
3497 3434 } else {
3498 3435 enum object_type unused;
3499 - size_t size_st = 0;
3500 3436 buf = odb_read_object(the_repository->objects, oid,
3501 - &unused, &size_st);
3502 - size = cast_size_t_to_ulong(size_st);
3437 + &unused, &size);
3503 3438 }
3504 3439 if (!buf)
3505 3440 die(_("can't load object %s"), oid_to_hex(oid));
@@ -3607,9 +3542,7 @@ static void print_ls(int mode, const unsigned char *hash, const char *path)
3607 3542 cat_blob_write(line.buf, line.len);
3608 3543 }
3609 3544
3610 - static void parse_ls(struct fast_import_state *state UNUSED,
3611 - const char *p,
3612 - struct branch *b)
3545 + static void parse_ls(const char *p, struct branch *b)
3613 3546 {
3614 3547 static struct strbuf path = STRBUF_INIT;
3615 3548 struct tree_entry *root = NULL;
@@ -3656,13 +3589,13 @@ static void checkpoint(void)
3656 3589 dump_marks();
3657 3590 }
3658 3591
3659 - static void parse_checkpoint(struct fast_import_state *state UNUSED)
3592 + static void parse_checkpoint(void)
3660 3593 {
3661 3594 checkpoint_requested = 1;
3662 3595 skip_optional_lf();
3663 3596 }
3664 3597
3665 - static void parse_progress(struct fast_import_state *state UNUSED)
3598 + static void parse_progress(void)
3666 3599 {
3667 3600 fwrite(command_buf.buf, 1, command_buf.len, stdout);
3668 3601 fputc('\n', stdout);
@@ -3670,40 +3603,37 @@ static void parse_progress(struct fast_import_state *state UNUSED)
3670 3603 skip_optional_lf();
3671 3604 }
3672 3605
3673 - static void parse_alias(struct fast_import_state *state)
3606 + static void parse_alias(void)
3674 3607 {
3675 3608 struct object_entry *e;
3676 3609 struct branch b;
3677 3610
3678 3611 skip_optional_lf();
3679 - read_next_command(state);
3612 + read_next_command();
3680 3613
3681 3614 /* mark ... */
3682 - parse_mark(state);
3615 + parse_mark();
3683 3616 if (!next_mark)
3684 3617 die(_("expected 'mark' command, got %s"), command_buf.buf);
3685 3618
3686 3619 /* to ... */
3687 3620 memset(&b, 0, sizeof(b));
3688 - if (!parse_objectish_with_prefix(state, &b, "to "))
3621 + if (!parse_objectish_with_prefix(&b, "to "))
3689 3622 die(_("expected 'to' command, got %s"), command_buf.buf);
3690 3623 e = find_object(&b.oid);
3691 3624 assert(e);
3692 3625 insert_mark(&marks, next_mark, e);
3693 3626 }
3694 3627
3695 - static char* make_fast_import_path(struct fast_import_state *state,
3696 - const char *path)
3628 + static char* make_fast_import_path(const char *path)
3697 3629 {
3698 3630 if (!relative_marks_paths || is_absolute_path(path))
3699 - return prefix_filename(state->prefix, path);
3631 + return prefix_filename(global_prefix, path);
3700 3632 return repo_git_path(the_repository, "info/fast-import/%s", path);
3701 3633 }
3702 3634
3703 - static void option_import_marks(struct fast_import_state *state,
3704 - const char *marks,
3705 - int from_stream,
3706 - int ignore_missing)
3635 + static void option_import_marks(const char *marks,
3636 + int from_stream, int ignore_missing)
3707 3637 {
3708 3638 if (import_marks_file) {
3709 3639 if (from_stream)
@@ -3715,7 +3645,7 @@ static void option_import_marks(struct fast_import_state *state,
3715 3645 }
3716 3646
3717 3647 free(import_marks_file);
3718 - import_marks_file = make_fast_import_path(state, marks);
3648 + import_marks_file = make_fast_import_path(marks);
3719 3649 import_marks_file_from_stream = from_stream;
3720 3650 import_marks_file_ignore_missing = ignore_missing;
3721 3651 }
@@ -3755,15 +3685,13 @@ static void option_active_branches(const char *branches)
3755 3685 max_active_branches = ulong_arg("--active-branches", branches);
3756 3686 }
3757 3687
3758 - static void option_export_marks(struct fast_import_state *state,
3759 - const char *marks)
3688 + static void option_export_marks(const char *marks)
3760 3689 {
3761 3690 free(export_marks_file);
3762 - export_marks_file = make_fast_import_path(state, marks);
3691 + export_marks_file = make_fast_import_path(marks);
3763 3692 }
3764 3693
3765 - static void option_cat_blob_fd(struct fast_import_state *state UNUSED,
3766 - const char *fd)
3694 + static void option_cat_blob_fd(const char *fd)
3767 3695 {
3768 3696 unsigned long n = ulong_arg("--cat-blob-fd", fd);
3769 3697 if (n > (unsigned long) INT_MAX)
@@ -3771,19 +3699,16 @@ static void option_cat_blob_fd(struct fast_import_state *state UNUSED,
3771 3699 cat_blob_fd = (int) n;
3772 3700 }
3773 3701
3774 - static void option_export_pack_edges(struct fast_import_state *state,
3775 - const char *edges)
3702 + static void option_export_pack_edges(const char *edges)
3776 3703 {
3777 - char *fn = prefix_filename(state->prefix, edges);
3704 + char *fn = prefix_filename(global_prefix, edges);
3778 3705 if (pack_edges)
3779 3706 fclose(pack_edges);
3780 3707 pack_edges = xfopen(fn, "a");
3781 3708 free(fn);
3782 3709 }
3783 3710
3784 - static void option_rewrite_submodules(struct fast_import_state *state,
3785 - const char *arg,
3786 - struct string_list *list)
3711 + static void option_rewrite_submodules(const char *arg, struct string_list *list)
3787 3712 {
3788 3713 struct mark_set *ms;
3789 3714 FILE *fp;
@@ -3795,7 +3720,7 @@ static void option_rewrite_submodules(struct fast_import_state *state,
3795 3720 f++;
3796 3721 CALLOC_ARRAY(ms, 1);
3797 3722
3798 - f = prefix_filename(state->prefix, f);
3723 + f = prefix_filename(global_prefix, f);
3799 3724 fp = fopen(f, "r");
3800 3725 if (!fp)
3801 3726 die_errno(_("cannot read '%s'"), f);
@@ -3808,67 +3733,40 @@ static void option_rewrite_submodules(struct fast_import_state *state,
3808 3733 free(s);
3809 3734 }
3810 3735
3811 - static void option_max_pack_size(const char *arg)
3812 - {
3813 - unsigned long v;
3814 -
3815 - if (!git_parse_ulong(arg, &v))
3816 - die(_("--max-pack-size: argument must be a non-negative integer"));
3817 - if (v < 8192) {
3818 - warning(_("max-pack-size is now in bytes, assuming --max-pack-size=%lum"), v);
3819 - v *= 1024 * 1024;
3820 - } else if (v < 1024 * 1024) {
3821 - warning(_("minimum max-pack-size is 1 MiB"));
3822 - v = 1024 * 1024;
3823 - }
3824 - max_packsize = v;
3825 - }
3826 -
3827 - static void option_big_file_threshold(const char *arg)
3828 - {
3829 - unsigned long v;
3830 -
3831 - if (!git_parse_ulong(arg, &v))
3832 - die(_("--big-file-threshold: argument must be a non-negative integer"));
3833 - repo_settings_set_big_file_threshold(the_repository, v);
3834 - }
3835 -
3836 - static void option_signed_commits(const char *arg)
3837 - {
3838 - if (parse_sign_mode(arg, &signed_commit_mode, &signed_commit_keyid))
3839 - usagef(_("unknown --signed-commits mode '%s'"), arg);
3840 - }
3841 -
3842 - static void option_signed_tags(const char *arg)
3843 - {
3844 - if (parse_sign_mode(arg, &signed_tag_mode, &signed_tag_keyid))
3845 - usagef(_("unknown --signed-tags mode '%s'"), arg);
3846 - }
3847 -
3848 - static void option_quiet(void)
3849 - {
3850 - show_stats = 0;
3851 - quiet = 1;
3852 - }
3853 -
3854 - static int parse_one_option(struct fast_import_state *state, const char *option)
3736 + static int parse_one_option(const char *option)
3855 3737 {
3856 3738 if (skip_prefix(option, "max-pack-size=", &option)) {
3857 - option_max_pack_size(option);
3739 + unsigned long v;
3740 + if (!git_parse_ulong(option, &v))
3741 + return 0;
3742 + if (v < 8192) {
3743 + warning(_("max-pack-size is now in bytes, assuming --max-pack-size=%lum"), v);
3744 + v *= 1024 * 1024;
3745 + } else if (v < 1024 * 1024) {
3746 + warning(_("minimum max-pack-size is 1 MiB"));
3747 + v = 1024 * 1024;
3748 + }
3749 + max_packsize = v;
3858 3750 } else if (skip_prefix(option, "big-file-threshold=", &option)) {
3859 - option_big_file_threshold(option);
3751 + unsigned long v;
3752 + if (!git_parse_ulong(option, &v))
3753 + return 0;
3754 + repo_settings_set_big_file_threshold(the_repository, v);
3860 3755 } else if (skip_prefix(option, "depth=", &option)) {
3861 3756 option_depth(option);
3862 3757 } else if (skip_prefix(option, "active-branches=", &option)) {
3863 3758 option_active_branches(option);
3864 3759 } else if (skip_prefix(option, "export-pack-edges=", &option)) {
3865 - option_export_pack_edges(state, option);
3760 + option_export_pack_edges(option);
3866 3761 } else if (skip_prefix(option, "signed-commits=", &option)) {
3867 - option_signed_commits(option);
3762 + if (parse_sign_mode(option, &signed_commit_mode, &signed_commit_keyid))
3763 + usagef(_("unknown --signed-commits mode '%s'"), option);
3868 3764 } else if (skip_prefix(option, "signed-tags=", &option)) {
3869 - option_signed_tags(option);
3765 + if (parse_sign_mode(option, &signed_tag_mode, &signed_tag_keyid))
3766 + usagef(_("unknown --signed-tags mode '%s'"), option);
3870 3767 } else if (!strcmp(option, "quiet")) {
3871 - option_quiet();
3768 + show_stats = 0;
3769 + quiet = 1;
3872 3770 } else if (!strcmp(option, "stats")) {
3873 3771 show_stats = 1;
3874 3772 } else if (!strcmp(option, "allow-unsafe-features")) {
@@ -3880,36 +3778,34 @@ static int parse_one_option(struct fast_import_state *state, const char *option)
3880 3778 return 1;
3881 3779 }
3882 3780
3883 - static void check_unsafe_feature(struct fast_import_state *state,
3884 - const char *feature)
3781 + static void check_unsafe_feature(const char *feature, int from_stream)
3885 3782 {
3886 - if (!state->allow_unsafe_features)
3783 + if (from_stream && !allow_unsafe_features)
3887 3784 die(_("feature '%s' forbidden in input without --allow-unsafe-features"),
3888 3785 feature);
3889 3786 }
3890 3787
3891 - static int parse_one_feature(struct fast_import_state *state,
3892 - const char *feature)
3788 + static int parse_one_feature(const char *feature, int from_stream)
3893 3789 {
3894 3790 const char *arg;
3895 3791
3896 3792 if (skip_prefix(feature, "date-format=", &arg)) {
3897 3793 option_date_format(arg);
3898 3794 } else if (skip_prefix(feature, "import-marks=", &arg)) {
3899 - check_unsafe_feature(state, "import-marks");
3900 - option_import_marks(state, arg, 1, 0);
3795 + check_unsafe_feature("import-marks", from_stream);
3796 + option_import_marks(arg, from_stream, 0);
3901 3797 } else if (skip_prefix(feature, "import-marks-if-exists=", &arg)) {
3902 - check_unsafe_feature(state, "import-marks-if-exists");
3903 - option_import_marks(state, arg, 1, 1);
3798 + check_unsafe_feature("import-marks-if-exists", from_stream);
3799 + option_import_marks(arg, from_stream, 1);
3904 3800 } else if (skip_prefix(feature, "export-marks=", &arg)) {
3905 - check_unsafe_feature(state, feature);
3906 - option_export_marks(state, arg);
3801 + check_unsafe_feature(feature, from_stream);
3802 + option_export_marks(arg);
3907 3803 } else if (!strcmp(feature, "alias")) {
3908 3804 ; /* Don't die - this feature is supported */
3909 3805 } else if (skip_prefix(feature, "rewrite-submodules-to=", &arg)) {
3910 - option_rewrite_submodules(state, arg, &sub_marks_to);
3806 + option_rewrite_submodules(arg, &sub_marks_to);
3911 3807 } else if (skip_prefix(feature, "rewrite-submodules-from=", &arg)) {
3912 - option_rewrite_submodules(state, arg, &sub_marks_from);
3808 + option_rewrite_submodules(arg, &sub_marks_from);
3913 3809 } else if (!strcmp(feature, "get-mark")) {
3914 3810 ; /* Don't die - this feature is supported */
3915 3811 } else if (!strcmp(feature, "cat-blob")) {
@@ -3931,23 +3827,23 @@ static int parse_one_feature(struct fast_import_state *state,
3931 3827 return 1;
3932 3828 }
3933 3829
3934 - static void parse_feature(struct fast_import_state *state, const char *feature)
3830 + static void parse_feature(const char *feature)
3935 3831 {
3936 - if (state->seen_data_command)
3832 + if (seen_data_command)
3937 3833 die(_("got feature command '%s' after data command"), feature);
3938 3834
3939 - if (parse_one_feature(state, feature))
3835 + if (parse_one_feature(feature, 1))
3940 3836 return;
3941 3837
3942 3838 die(_("this version of fast-import does not support feature %s."), feature);
3943 3839 }
3944 3840
3945 - static void parse_option(struct fast_import_state *state, const char *option)
3841 + static void parse_option(const char *option)
3946 3842 {
3947 - if (state->seen_data_command)
3843 + if (seen_data_command)
3948 3844 die(_("got option command '%s' after data command"), option);
3949 3845
3950 - if (parse_one_option(state, option))
3846 + if (parse_one_option(option))
3951 3847 return;
3952 3848
3953 3849 die(_("this version of fast-import does not support option: %s"), option);
@@ -3980,144 +3876,42 @@ static void git_pack_config(void)
3980 3876 repo_config(the_repository, git_default_config, NULL);
3981 3877 }
3982 3878
3983 - static const char *const fast_import_usage[] = {
3984 - N_("git fast-import [<options>]"),
3985 - NULL
3986 - };
3987 -
3988 - static void parse_argv(struct fast_import_state *state)
3989 - {
3990 - int argc = parse_options(state->argc, state->argv, state->prefix,
3991 - state->option, fast_import_usage,
3992 - PARSE_OPT_KEEP_ARGV0);
3993 -
3994 - if (argc > 1)
3995 - usage_with_options(fast_import_usage, state->option);
3996 -
3997 - state->seen_data_command = 1;
3998 - if (import_marks_file)
3999 - read_marks();
4000 - build_mark_map(&sub_marks_from, &sub_marks_to);
4001 - }
4002 -
4003 - static int option_parse_date_format(const struct option *opt UNUSED,
4004 - const char *arg, int unset)
4005 - {
4006 - BUG_ON_OPT_NEG(unset);
4007 - option_date_format(arg);
4008 - return 0;
4009 - }
3879 + static const char fast_import_usage[] =
3880 + "git fast-import [--date-format=<f>] [--max-pack-size=<n>] [--big-file-threshold=<n>] [--depth=<n>] [--active-branches=<n>] [--export-marks=<marks.file>]";
4010 3881
4011 - static int option_parse_export_pack_edges(const struct option *opt,
4012 - const char *arg, int unset)
3882 + static void parse_argv(void)
4013 3883 {
4014 - BUG_ON_OPT_NEG(unset);
4015 - option_export_pack_edges(opt->value, arg);
4016 - return 0;
4017 - }
4018 -
4019 - static int option_parse_max_pack_size(const struct option *opt UNUSED,
4020 - const char *arg, int unset)
4021 - {
4022 - BUG_ON_OPT_NEG(unset);
4023 - option_max_pack_size(arg);
4024 - return 0;
4025 - }
4026 -
4027 - static int option_parse_big_file_threshold(const struct option *opt UNUSED,
4028 - const char *arg, int unset)
4029 - {
4030 - BUG_ON_OPT_NEG(unset);
4031 - option_big_file_threshold(arg);
4032 - return 0;
4033 - }
4034 -
4035 - static int option_parse_signed_commits(const struct option *opt UNUSED,
4036 - const char *arg, int unset)
4037 - {
4038 - BUG_ON_OPT_NEG(unset);
4039 - option_signed_commits(arg);
4040 - return 0;
4041 - }
4042 -
4043 - static int option_parse_signed_tags(const struct option *opt UNUSED,
4044 - const char *arg, int unset)
4045 - {
4046 - BUG_ON_OPT_NEG(unset);
4047 - option_signed_tags(arg);
4048 - return 0;
4049 - }
4050 -
4051 - static int option_parse_rewrite_submodules_from(const struct option *opt,
4052 - const char *arg, int unset)
4053 - {
4054 - BUG_ON_OPT_NEG(unset);
4055 - option_rewrite_submodules(opt->value, arg, &sub_marks_from);
4056 - return 0;
4057 - }
3884 + unsigned int i;
4058 3885
4059 - static int option_parse_rewrite_submodules_to(const struct option *opt,
4060 - const char *arg, int unset)
4061 - {
4062 - BUG_ON_OPT_NEG(unset);
4063 - option_rewrite_submodules(opt->value, arg, &sub_marks_to);
4064 - return 0;
4065 - }
3886 + for (i = 1; i < global_argc; i++) {
3887 + const char *a = global_argv[i];
4066 3888
4067 - static int option_parse_cat_blob_fd(const struct option *opt,
4068 - const char *arg, int unset)
4069 - {
4070 - BUG_ON_OPT_NEG(unset);
4071 - option_cat_blob_fd(opt->value, arg);
4072 - return 0;
4073 - }
3889 + if (*a != '-' || !strcmp(a, "--"))
3890 + break;
4074 3891
4075 - static int option_parse_import_marks(const struct option *opt,
4076 - const char *arg, int unset)
4077 - {
4078 - BUG_ON_OPT_NEG(unset);
4079 - option_import_marks(opt->value, arg, 0, 0);
4080 - return 0;
4081 - }
3892 + if (!skip_prefix(a, "--", &a))
3893 + die(_("unknown option %s"), a);
4082 3894
4083 - static int option_parse_import_marks_if_exists(const struct option *opt,
4084 - const char *arg, int unset)
4085 - {
4086 - BUG_ON_OPT_NEG(unset);
4087 - option_import_marks(opt->value, arg, 0, 1);
4088 - return 0;
4089 - }
3895 + if (parse_one_option(a))
3896 + continue;
4090 3897
4091 - static int option_parse_export_marks(const struct option *opt,
4092 - const char *arg, int unset)
4093 - {
4094 - BUG_ON_OPT_NEG(unset);
4095 - option_export_marks(opt->value, arg);
4096 - return 0;
4097 - }
3898 + if (parse_one_feature(a, 0))
3899 + continue;
4098 3900
4099 - static int option_parse_depth(const struct option *opt UNUSED,
4100 - const char *arg, int unset)
4101 - {
4102 - BUG_ON_OPT_NEG(unset);
4103 - option_depth(arg);
4104 - return 0;
4105 - }
3901 + if (skip_prefix(a, "cat-blob-fd=", &a)) {
3902 + option_cat_blob_fd(a);
3903 + continue;
3904 + }
4106 3905
4107 - static int option_parse_active_branches(const struct option *opt UNUSED,
4108 - const char *arg, int unset)
4109 - {
4110 - BUG_ON_OPT_NEG(unset);
4111 - option_active_branches(arg);
4112 - return 0;
4113 - }
3906 + die(_("unknown option --%s"), a);
3907 + }
3908 + if (i != global_argc)
3909 + usage(fast_import_usage);
4114 3910
4115 - static int option_parse_quiet(const struct option *opt UNUSED,
4116 - const char *arg UNUSED, int unset)
4117 - {
4118 - BUG_ON_OPT_NEG(unset);
4119 - option_quiet();
4120 - return 0;
3911 + seen_data_command = 1;
3912 + if (import_marks_file)
3913 + read_marks();
3914 + build_mark_map(&sub_marks_from, &sub_marks_to);
4121 3915 }
4122 3916
4123 3917 int cmd_fast_import(int argc,
@@ -4125,80 +3919,9 @@ int cmd_fast_import(int argc,
4125 3919 const char *prefix,
4126 3920 struct repository *repo)
4127 3921 {
4128 - struct fast_import_state state;
4129 -
4130 - struct option fast_import_options[] = {
4131 - OPT_GROUP(N_("Common")),
4132 - OPT_CALLBACK_F(0, "date-format", NULL, N_("fmt"),
4133 - N_("format of the commit/tag dates"),
4134 - PARSE_OPT_NONEG, option_parse_date_format),
4135 - OPT_BOOL_F(0, "stats", &show_stats,
4136 - N_("display some basic statistics (objects, packfiles and memory)"),
4137 - PARSE_OPT_NONEG),
4138 - OPT_CALLBACK_F(0, "quiet", NULL, NULL,
4139 - N_("disable the output shown by --stats"),
4140 - PARSE_OPT_NOARG | PARSE_OPT_NONEG,
4141 - option_parse_quiet),
4142 - OPT_BOOL_F(0, "force", &force_update,
4143 - N_("force updating modified existing branches"), PARSE_OPT_NONEG),
4144 - OPT_BOOL_F(0, "done", &require_explicit_termination,
4145 - N_("require a terminating 'done' command"), PARSE_OPT_NONEG),
4146 - OPT_CALLBACK_F(0, "max-pack-size", NULL, N_("n"),
4147 - N_("maximum size of each output pack file"),
4148 - PARSE_OPT_NONEG, option_parse_max_pack_size),
4149 - OPT_CALLBACK_F(0, "big-file-threshold", NULL, N_("n"),
4150 - N_("maximum size of a blob that will be deltified"),
4151 - PARSE_OPT_NONEG, option_parse_big_file_threshold),
4152 - OPT_CALLBACK_F(0, "depth", NULL, N_("n"),
4153 - N_("maximum delta depth"),
4154 - PARSE_OPT_NONEG, option_parse_depth),
4155 - OPT_CALLBACK_F(0, "active-branches", NULL, N_("n"),
4156 - N_("maximum number of branches to maintain active"),
4157 - PARSE_OPT_NONEG, option_parse_active_branches),
4158 - OPT_GROUP(N_("Marks")),
4159 - OPT_CALLBACK_F(0, "import-marks", &state, N_("file"),
4160 - N_("import marks from <file>"),
4161 - PARSE_OPT_NONEG, option_parse_import_marks),
4162 - OPT_CALLBACK_F(0, "import-marks-if-exists", &state, N_("file"),
4163 - N_("import marks from <file> if it exists"),
4164 - PARSE_OPT_NONEG, option_parse_import_marks_if_exists),
4165 - OPT_CALLBACK_F(0, "export-marks", &state, N_("file"),
4166 - N_("dump marks to <file>"),
4167 - PARSE_OPT_NONEG, option_parse_export_marks),
4168 - OPT_BOOL(0, "relative-marks", &relative_marks_paths,
4169 - N_("are --(import|export)-marks= paths relative to '.git/info/fast-import'?")),
4170 - OPT_GROUP(N_("Submodule rewrite")),
4171 - OPT_CALLBACK_F(0, "rewrite-submodules-from", &state, N_("name:filename"),
4172 - N_("rewrite object IDs for submodule <name> from <filename>"),
4173 - PARSE_OPT_NONEG, option_parse_rewrite_submodules_from),
4174 - OPT_CALLBACK_F(0, "rewrite-submodules-to", &state, N_("name:filename"),
4175 - N_("rewrite object IDs for submodule <name> to <filename>"),
4176 - PARSE_OPT_NONEG, option_parse_rewrite_submodules_to),
4177 - OPT_GROUP(N_("Signing")),
4178 - OPT_CALLBACK_F(0, "signed-commits", NULL, N_("mode"),
4179 - N_("how to handle signed commits"),
4180 - PARSE_OPT_NONEG, option_parse_signed_commits),
4181 - OPT_CALLBACK_F(0, "signed-tags", NULL, N_("mode"),
4182 - N_("how to handle signed tags"),
4183 - PARSE_OPT_NONEG, option_parse_signed_tags),
4184 - OPT_HIDDEN_GROUP(N_("Advanced")),
4185 - OPT_BOOL_F(0, "allow-unsafe-features", &state.allow_unsafe_features,
4186 - N_("allow unsafe mark commands from the stream"),
4187 - PARSE_OPT_HIDDEN | PARSE_OPT_NONEG),
4188 - OPT_CALLBACK_F(0, "export-pack-edges", &state, N_("file"),
4189 - N_("dump edge commits to <file>"),
4190 - PARSE_OPT_HIDDEN | PARSE_OPT_NONEG,
4191 - option_parse_export_pack_edges),
4192 - OPT_CALLBACK_F(0, "cat-blob-fd", &state, N_("fd"),
4193 - N_("write some responses to <fd> instead of stdout"),
4194 - PARSE_OPT_HIDDEN | PARSE_OPT_NONEG,
4195 - option_parse_cat_blob_fd),
4196 - OPT_END()
4197 - };
4198 -
4199 - show_usage_with_options_if_asked(argc, argv, fast_import_usage, fast_import_options);
4200 -
4201 - fast_import_state_init(&state, argc, argv, prefix, fast_import_options);
3922 + unsigned int i;
3923 +
3924 + show_usage_if_asked(argc, argv, fast_import_usage);
4202 3925
4203 3926 reset_pack_idx_option(&pack_idx_opts);
4204 3927 git_pack_config();
@@ -4217,61 +3940,55 @@ int cmd_fast_import(int argc,
4217 3940 * "feature" lines at the start of the stream (which allows the command
4218 3941 * line to override stream data). But we must do an early parse of any
4219 3942 * command-line options that impact how we interpret the feature lines.
4220 - *
4221 - * NEEDSWORK: This scan only matches the exact "--allow-unsafe-features"
4222 - * spelling and stops at the first argument that doesn't start with a
4223 - * dash. As parse_options() below also accepts unambiguous abbreviations
4224 - * and values separated by a space from their option, the two disagree
4225 - * for command lines like "--allow-unsafe" or "--depth 5
4226 - * --allow-unsafe-features": parse_options() accepts the option, but
4227 - * this scan doesn't see it, so unsafe features from the stream are
4228 - * still refused. This errs on the safe side, but should be fixed by
4229 - * teaching this scan about the options that take a value.
4230 3943 */
4231 - for (int i = 1; i < argc; i++) {
3944 + for (i = 1; i < argc; i++) {
4232 3945 const char *arg = argv[i];
4233 3946 if (*arg != '-' || !strcmp(arg, "--"))
4234 3947 break;
4235 3948 if (!strcmp(arg, "--allow-unsafe-features"))
4236 - state.allow_unsafe_features = 1;
3949 + allow_unsafe_features = 1;
4237 3950 }
4238 3951
3952 + global_argc = argc;
3953 + global_argv = argv;
3954 + global_prefix = prefix;
3955 +
4239 3956 rc_free = mem_pool_alloc(&fi_mem_pool, cmd_save * sizeof(*rc_free));
4240 - for (unsigned int i = 0; i < (cmd_save - 1); i++)
3957 + for (i = 0; i < (cmd_save - 1); i++)
4241 3958 rc_free[i].next = &rc_free[i + 1];
4242 3959 rc_free[cmd_save - 1].next = NULL;
4243 3960
4244 3961 start_packfile();
4245 3962 set_die_routine(die_nicely);
4246 3963 set_checkpoint_signal();
4247 - while (read_next_command(&state) != EOF) {
3964 + while (read_next_command() != EOF) {
4248 3965 const char *v;
4249 3966 if (!strcmp("blob", command_buf.buf))
4250 - parse_new_blob(&state);
3967 + parse_new_blob();
4251 3968 else if (skip_prefix(command_buf.buf, "commit ", &v))
4252 - parse_new_commit(&state, v);
3969 + parse_new_commit(v);
4253 3970 else if (skip_prefix(command_buf.buf, "tag ", &v))
4254 - parse_new_tag(&state, v);
3971 + parse_new_tag(v);
4255 3972 else if (skip_prefix(command_buf.buf, "reset ", &v))
4256 - parse_reset_branch(&state, v);
3973 + parse_reset_branch(v);
4257 3974 else if (skip_prefix(command_buf.buf, "ls ", &v))
4258 - parse_ls(&state, v, NULL);
3975 + parse_ls(v, NULL);
4259 3976 else if (skip_prefix(command_buf.buf, "cat-blob ", &v))
4260 - parse_cat_blob(&state, v);
3977 + parse_cat_blob(v);
4261 3978 else if (skip_prefix(command_buf.buf, "get-mark ", &v))
4262 - parse_get_mark(&state, v);
3979 + parse_get_mark(v);
4263 3980 else if (!strcmp("checkpoint", command_buf.buf))
4264 - parse_checkpoint(&state);
3981 + parse_checkpoint();
4265 3982 else if (!strcmp("done", command_buf.buf))
4266 3983 break;
4267 3984 else if (!strcmp("alias", command_buf.buf))
4268 - parse_alias(&state);
3985 + parse_alias();
4269 3986 else if (starts_with(command_buf.buf, "progress "))
4270 - parse_progress(&state);
3987 + parse_progress();
4271 3988 else if (skip_prefix(command_buf.buf, "feature ", &v))
4272 - parse_feature(&state, v);
3989 + parse_feature(v);
4273 3990 else if (skip_prefix(command_buf.buf, "option git ", &v))
4274 - parse_option(&state, v);
3991 + parse_option(v);
4275 3992 else if (starts_with(command_buf.buf, "option "))
4276 3993 /* ignore non-git options*/;
4277 3994 else
@@ -4282,8 +3999,8 @@ int cmd_fast_import(int argc,
4282 3999 }
4283 4000
4284 4001 /* argv hasn't been parsed yet, do so */
4285 - if (!state.seen_data_command)
4286 - parse_argv(&state);
4002 + if (!seen_data_command)
4003 + parse_argv();
4287 4004
4288 4005 if (require_explicit_termination && feof(stdin))
4289 4006 die(_("stream ends early"));
@@ -4300,9 +4017,9 @@ int cmd_fast_import(int argc,
4300 4017
4301 4018 if (show_stats) {
4302 4019 uintmax_t total_count = 0, duplicate_count = 0;
4303 - for (size_t i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
4020 + for (i = 0; i < ARRAY_SIZE(object_count_by_type); i++)
4304 4021 total_count += object_count_by_type[i];
4305 - for (size_t i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
4022 + for (i = 0; i < ARRAY_SIZE(duplicate_count_by_type); i++)
4306 4023 duplicate_count += duplicate_count_by_type[i];
4307 4024
4308 4025 fprintf(stderr, "%s statistics:\n", argv[0]);
modified builtin/fetch-pack.c
@@ -49,7 +49,7 @@ static void add_sought_entry(struct ref ***sought, int *nr, int *alloc,
49 49 int cmd_fetch_pack(int argc,
50 50 const char **argv,
51 51 const char *prefix UNUSED,
52 - struct repository *repo)
52 + struct repository *repo UNUSED)
53 53 {
54 54 int i, ret;
55 55 struct ref *fetched_refs = NULL, *remote_refs = NULL;
@@ -67,6 +67,8 @@ int cmd_fetch_pack(int argc,
67 67 struct packet_reader reader;
68 68 enum protocol_version version;
69 69
70 + fetch_if_missing = 0;
71 +
70 72 packet_trace_identity("fetch-pack");
71 73
72 74 memset(&args, 0, sizeof(args));
@@ -75,8 +77,6 @@ int cmd_fetch_pack(int argc,
75 77
76 78 show_usage_if_asked(argc, argv, fetch_pack_usage);
77 79
78 - repo->fetch_if_missing = 0;
79 -
80 80 for (i = 1; i < argc && *argv[i] == '-'; i++) {
81 81 const char *arg = argv[i];
82 82
@@ -223,7 +223,7 @@ int cmd_fetch_pack(int argc,
223 223 int flags = args.verbose ? CONNECT_VERBOSE : 0;
224 224 if (args.diag_url)
225 225 flags |= CONNECT_DIAG_URL;
226 - conn = git_connect(fd, dest, GIT_CONNECT_UPLOAD_PACK,
226 + conn = git_connect(fd, dest, "git-upload-pack",
227 227 args.uploadpack, flags);
228 228 if (!conn)
229 229 return args.diag_url ? 0 : 1;
modified builtin/fetch.c
@@ -96,14 +96,12 @@ static struct string_list deepen_not = STRING_LIST_INIT_NODUP;
96 96 static struct strbuf default_rla = STRBUF_INIT;
97 97 static struct transport *gtransport;
98 98 static struct transport *gsecondary;
99 - static struct refspec refmap;
99 + static struct refspec refmap = REFSPEC_INIT_FETCH;
100 100 static struct string_list server_options = STRING_LIST_INIT_DUP;
101 - static struct string_list negotiation_restrict = STRING_LIST_INIT_NODUP;
102 - static struct string_list negotiation_include = STRING_LIST_INIT_NODUP;
101 + static struct string_list negotiation_tip = STRING_LIST_INIT_NODUP;
103 102
104 103 struct fetch_config {
105 104 enum display_format display_format;
106 - enum follow_remote_head_settings follow_remote_head;
107 105 int all;
108 106 int prune;
109 107 int prune_tags;
@@ -172,23 +170,6 @@ static int git_fetch_config(const char *k, const char *v,
172 170 else
173 171 die(_("invalid value for '%s': '%s'"),
174 172 "fetch.output", v);
175 - return 0;
176 - }
177 -
178 - if (!strcmp(k, "fetch.followremotehead")) {
179 - if (!v)
180 - return config_error_nonbool(k);
181 - else if (!strcmp(v, "never"))
182 - fetch_config->follow_remote_head = FOLLOW_REMOTE_NEVER;
183 - else if (!strcmp(v, "create"))
184 - fetch_config->follow_remote_head = FOLLOW_REMOTE_CREATE;
185 - else if (!strcmp(v, "warn"))
186 - fetch_config->follow_remote_head = FOLLOW_REMOTE_WARN;
187 - else if (!strcmp(v, "always"))
188 - fetch_config->follow_remote_head = FOLLOW_REMOTE_ALWAYS;
189 - else
190 - warning(_("unrecognized fetch.followRemoteHEAD value '%s' ignored"), v);
191 - return 0;
192 173 }
193 174
194 175 return git_default_config(k, v, ctx, cb);
@@ -601,8 +582,7 @@ static struct ref *get_ref_map(struct remote *remote,
601 582 struct refspec_item tag_refspec;
602 583
603 584 /* also fetch all tags */
604 - refspec_item_init_push(&tag_refspec, TAG_REFSPEC,
605 - the_hash_algo);
585 + refspec_item_init_push(&tag_refspec, TAG_REFSPEC);
606 586 get_fetch_map(remote_refs, &tag_refspec, &tail, 0);
607 587 refspec_item_clear(&tag_refspec);
608 588 } else if (tags == TAGS_DEFAULT && *autotags) {
@@ -1554,29 +1534,23 @@ static int add_oid(const struct reference *ref, void *cb_data)
1554 1534 return 0;
1555 1535 }
1556 1536
1557 - static void add_negotiation_tips(struct string_list *input_list,
1558 - struct oid_array **output_list,
1559 - const char *argname)
1537 + static void add_negotiation_tips(struct git_transport_options *smart_options)
1560 1538 {
1561 1539 struct oid_array *oids = xcalloc(1, sizeof(*oids));
1562 1540 int i;
1563 1541
1564 - for (i = 0; i < input_list->nr; i++) {
1565 - const char *s = input_list->items[i].string;
1542 + for (i = 0; i < negotiation_tip.nr; i++) {
1543 + const char *s = negotiation_tip.items[i].string;
1566 1544 struct refs_for_each_ref_options opts = {
1567 1545 .pattern = s,
1568 1546 };
1569 1547 int old_nr;
1570 1548 if (!has_glob_specials(s)) {
1571 1549 struct object_id oid;
1572 -
1573 - /* Ignore missing reference. */
1574 1550 if (repo_get_oid(the_repository, s, &oid))
1575 - continue;
1576 - /* Fail on missing object pointed by ref. */
1551 + die(_("%s is not a valid object"), s);
1577 1552 if (!odb_has_object(the_repository->objects, &oid, 0))
1578 1553 die(_("the object %s does not exist"), s);
1579 -
1580 1554 oid_array_append(oids, &oid);
1581 1555 continue;
1582 1556 }
@@ -1584,10 +1558,10 @@ static void add_negotiation_tips(struct string_list *input_list,
1584 1558 refs_for_each_ref_ext(get_main_ref_store(the_repository),
1585 1559 add_oid, oids, &opts);
1586 1560 if (old_nr == oids->nr)
1587 - warning(_("ignoring %s=%s because it does not match any refs"),
1588 - argname, s);
1561 + warning("ignoring --negotiation-tip=%s because it does not match any refs",
1562 + s);
1589 1563 }
1590 - *output_list = oids;
1564 + smart_options->negotiation_tips = oids;
1591 1565 }
1592 1566
1593 1567 static struct transport *prepare_transport(struct remote *remote, int deepen,
@@ -1621,50 +1595,11 @@ static struct transport *prepare_transport(struct remote *remote, int deepen,
1621 1595 set_option(transport, TRANS_OPT_LIST_OBJECTS_FILTER, spec);
1622 1596 set_option(transport, TRANS_OPT_FROM_PROMISOR, "1");
1623 1597 }
1624 - if (negotiation_restrict.nr) {
1598 + if (negotiation_tip.nr) {
1625 1599 if (transport->smart_options)
1626 - add_negotiation_tips(&negotiation_restrict,
1627 - &transport->smart_options->negotiation_restrict_tips,
1628 - "--negotiation-restrict");
1600 + add_negotiation_tips(transport->smart_options);
1629 1601 else
1630 - warning(_("ignoring %s because the protocol does not support it"),
1631 - "--negotiation-restrict");
1632 - } else if (remote->negotiation_restrict.nr) {
1633 - struct string_list_item *item;
1634 - for_each_string_list_item(item, &remote->negotiation_restrict)
1635 - string_list_append(&negotiation_restrict, item->string);
1636 - if (transport->smart_options)
1637 - add_negotiation_tips(&negotiation_restrict,
1638 - &transport->smart_options->negotiation_restrict_tips,
1639 - "--negotiation-restrict");
1640 - else {
1641 - struct strbuf config_name = STRBUF_INIT;
1642 - strbuf_addf(&config_name, "remote.%s.negotiationRestrict", remote->name);
1643 - warning(_("ignoring %s because the protocol does not support it"),
1644 - config_name.buf);
1645 - strbuf_release(&config_name);
1646 - }
1647 - }
1648 - if (negotiation_include.nr) {
1649 - if (transport->smart_options)
1650 - add_negotiation_tips(&negotiation_include,
1651 - &transport->smart_options->negotiation_include_tips,
1652 - "--negotiation-include");
1653 - else
1654 - warning(_("ignoring %s because the protocol does not support it"),
1655 - "--negotiation-include");
1656 - } else if (remote->negotiation_include.nr) {
1657 - if (transport->smart_options) {
1658 - add_negotiation_tips(&remote->negotiation_include,
1659 - &transport->smart_options->negotiation_include_tips,
1660 - "--negotiation-include");
1661 - } else {
1662 - struct strbuf config_name = STRBUF_INIT;
1663 - strbuf_addf(&config_name, "remote.%s.negotiationInclude", remote->name);
1664 - warning(_("ignoring %s because the protocol does not support it"),
1665 - config_name.buf);
1666 - strbuf_release(&config_name);
1667 - }
1602 + warning("ignoring --negotiation-tip because the protocol does not support it");
1668 1603 }
1669 1604 return transport;
1670 1605 }
@@ -1716,19 +1651,17 @@ static const char *strip_refshead(const char *name){
1716 1651 static void set_head_advice_msg(const char *remote, const char *head_name)
1717 1652 {
1718 1653 const char message_advice_set_head[] =
1719 - N_("Run 'git remote set-head %s %s' to follow the change, or modify\n"
1720 - "either of the 'remote.%s.followRemoteHEAD' or 'fetch.followRemoteHEAD'\n"
1721 - "configuration variables to handle the situation differently.\n\n"
1722 -
1723 - "Using this specific setting\n\n"
1724 - " git config set remote.%s.followRemoteHEAD warn-if-not-%s\n\n"
1725 - "will suppress the warning until the remote changes HEAD to something else.");
1654 + N_("Run 'git remote set-head %s %s' to follow the change, or set\n"
1655 + "'remote.%s.followRemoteHEAD' configuration option to a different value\n"
1656 + "if you do not want to see this message. Specifically running\n"
1657 + "'git config set remote.%s.followRemoteHEAD warn-if-not-branch-%s'\n"
1658 + "will disable the warning until the remote changes HEAD to something else.");
1726 1659
1727 1660 advise_if_enabled(ADVICE_FETCH_SET_HEAD_WARN, _(message_advice_set_head),
1728 1661 remote, head_name, remote, remote, head_name);
1729 1662 }
1730 1663
1731 - static void warn_set_head(const char *remote, const char *head_name,
1664 + static void report_set_head(const char *remote, const char *head_name,
1732 1665 struct strbuf *buf_prev, int updateres) {
1733 1666 struct strbuf buf_prefix = STRBUF_INIT;
1734 1667 const char *prev_head = NULL;
@@ -1750,12 +1683,12 @@ static void warn_set_head(const char *remote, const char *head_name,
1750 1683 strbuf_release(&buf_prefix);
1751 1684 }
1752 1685
1753 - static int set_head(const struct ref *remote_refs, struct remote *remote,
1754 - int follow_remote_head)
1686 + static int set_head(const struct ref *remote_refs, struct remote *remote)
1755 1687 {
1756 1688 int result = 0, create_only, baremirror, was_detached;
1757 1689 struct strbuf b_head = STRBUF_INIT, b_remote_head = STRBUF_INIT,
1758 1690 b_local_head = STRBUF_INIT;
1691 + int follow_remote_head = remote->follow_remote_head;
1759 1692 const char *no_warn_branch = remote->no_warn_branch;
1760 1693 char *head_name = NULL;
1761 1694 struct ref *ref, *matches;
@@ -1785,7 +1718,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote,
1785 1718
1786 1719 if (!head_name)
1787 1720 goto cleanup;
1788 - baremirror = is_bare_repository(the_repository) && remote->mirror;
1721 + baremirror = is_bare_repository() && remote->mirror;
1789 1722 create_only = follow_remote_head == FOLLOW_REMOTE_ALWAYS ? 0 : !baremirror;
1790 1723 if (baremirror) {
1791 1724 strbuf_addstr(&b_head, "HEAD");
@@ -1794,7 +1727,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote,
1794 1727 strbuf_addf(&b_head, "refs/remotes/%s/HEAD", remote->name);
1795 1728 strbuf_addf(&b_remote_head, "refs/remotes/%s/%s", remote->name, head_name);
1796 1729 }
1797 - /* make sure it's valid */
1730 + /* make sure it's valid */
1798 1731 if (!baremirror && !refs_ref_exists(refs, b_remote_head.buf)) {
1799 1732 result = 1;
1800 1733 goto cleanup;
@@ -1808,7 +1741,7 @@ static int set_head(const struct ref *remote_refs, struct remote *remote,
1808 1741 if (verbosity >= 0 &&
1809 1742 follow_remote_head == FOLLOW_REMOTE_WARN &&
1810 1743 (!no_warn_branch || strcmp(no_warn_branch, head_name)))
1811 - warn_set_head(remote->name, head_name, &b_local_head, was_detached);
1744 + report_set_head(remote->name, head_name, &b_local_head, was_detached);
1812 1745
1813 1746 cleanup:
1814 1747 free(head_name);
@@ -1840,7 +1773,7 @@ static void ref_transaction_rejection_handler(const char *refname,
1840 1773 {
1841 1774 struct ref_rejection_data *data = cb_data;
1842 1775
1843 - if (err == REF_TRANSACTION_ERROR_CASE_CONFLICT && repo_ignore_case(the_repository) &&
1776 + if (err == REF_TRANSACTION_ERROR_CASE_CONFLICT && ignore_case &&
1844 1777 !data->case_sensitive_msg_shown) {
1845 1778 error(_("You're on a case-insensitive filesystem, and the remote you are\n"
1846 1779 "trying to fetch from has references that only differ in casing. It\n"
@@ -1922,7 +1855,6 @@ static int do_fetch(struct transport *transport,
1922 1855 struct ref_update_display_info_array display_array = { 0 };
1923 1856 struct strmap rejected_refs = STRMAP_INIT;
1924 1857 int summary_width = 0;
1925 - int follow_remote_head;
1926 1858
1927 1859 if (tags == TAGS_DEFAULT) {
1928 1860 if (transport->remote->fetch_tags == 2)
@@ -1938,22 +1870,6 @@ static int do_fetch(struct transport *transport,
1938 1870 goto cleanup;
1939 1871 }
1940 1872
1941 - /*
1942 - * NEEDSWORK: By the time this function executes, we have already parsed
1943 - * all such followRemoteHEAD values from the external configuration,
1944 - * potentially emitting warning messages for bogus values. Ideally, if
1945 - * this fetch ends up not needing to consult these values, then git would
1946 - * not ever output a value warning. (eg: when pulling from a URL directly -
1947 - * rather than a configured remote, or when a remote's followRemoteHEAD
1948 - * overrides the fallback fetch setting)
1949 - */
1950 - if (transport->remote->follow_remote_head)
1951 - follow_remote_head = transport->remote->follow_remote_head;
1952 - else if (config->follow_remote_head)
1953 - follow_remote_head = config->follow_remote_head;
1954 - else
1955 - follow_remote_head = BUILTIN_FOLLOW_REMOTE_HEAD_DFLT;
1956 -
1957 1873 if (rs->nr) {
1958 1874 refspec_ref_prefixes(rs, &transport_ls_refs_options.ref_prefixes);
1959 1875 } else {
@@ -1962,7 +1878,7 @@ static int do_fetch(struct transport *transport,
1962 1878 if (transport->remote->fetch.nr) {
1963 1879 refspec_ref_prefixes(&transport->remote->fetch,
1964 1880 &transport_ls_refs_options.ref_prefixes);
1965 - if (follow_remote_head != FOLLOW_REMOTE_NEVER)
1881 + if (transport->remote->follow_remote_head != FOLLOW_REMOTE_NEVER)
1966 1882 do_set_head = 1;
1967 1883 }
1968 1884 if (branch && branch_has_merge_config(branch) &&
@@ -2169,7 +2085,7 @@ static int do_fetch(struct transport *transport,
2169 2085 * Way too many cases where this can go wrong so let's just
2170 2086 * ignore errors and fail silently for now.
2171 2087 */
2172 - set_head(remote_refs, transport->remote, follow_remote_head);
2088 + set_head(remote_refs, transport->remote);
2173 2089 }
2174 2090
2175 2091 cleanup:
@@ -2222,6 +2138,48 @@ static int get_one_remote_for_fetch(struct remote *remote, void *priv)
2222 2138 return 0;
2223 2139 }
2224 2140
2141 + struct remote_group_data {
2142 + const char *name;
2143 + struct string_list *list;
2144 + };
2145 +
2146 + static int get_remote_group(const char *key, const char *value,
2147 + const struct config_context *ctx UNUSED,
2148 + void *priv)
2149 + {
2150 + struct remote_group_data *g = priv;
2151 +
2152 + if (skip_prefix(key, "remotes.", &key) && !strcmp(key, g->name)) {
2153 + /* split list by white space */
2154 + while (*value) {
2155 + size_t wordlen = strcspn(value, " \t\n");
2156 +
2157 + if (wordlen >= 1)
2158 + string_list_append_nodup(g->list,
2159 + xstrndup(value, wordlen));
2160 + value += wordlen + (value[wordlen] != '\0');
2161 + }
2162 + }
2163 +
2164 + return 0;
2165 + }
2166 +
2167 + static int add_remote_or_group(const char *name, struct string_list *list)
2168 + {
2169 + int prev_nr = list->nr;
2170 + struct remote_group_data g;
2171 + g.name = name; g.list = list;
2172 +
2173 + repo_config(the_repository, get_remote_group, &g);
2174 + if (list->nr == prev_nr) {
2175 + struct remote *remote = remote_get(name);
2176 + if (!remote_is_configured(remote, 0))
2177 + return 0;
2178 + string_list_append(list, remote->name);
2179 + }
2180 + return 1;
2181 + }
2182 +
2225 2183 static void add_options_to_argv(struct strvec *argv,
2226 2184 const struct fetch_config *config)
2227 2185 {
@@ -2429,7 +2387,7 @@ static int fetch_one(struct remote *remote, int argc, const char **argv,
2429 2387 const struct fetch_config *config,
2430 2388 struct list_objects_filter_options *filter_options)
2431 2389 {
2432 - struct refspec rs = REFSPEC_INIT_FETCH(the_hash_algo);
2390 + struct refspec rs = REFSPEC_INIT_FETCH;
2433 2391 int i;
2434 2392 int exit_code;
2435 2393 int maybe_prune_tags;
@@ -2509,7 +2467,6 @@ int cmd_fetch(int argc,
2509 2467 {
2510 2468 struct fetch_config config = {
2511 2469 .display_format = DISPLAY_FORMAT_FULL,
2512 - .follow_remote_head = FOLLOW_REMOTE_UNCONFIGURED,
2513 2470 .prune = -1,
2514 2471 .prune_tags = -1,
2515 2472 .show_forced_updates = 1,
@@ -2608,11 +2565,8 @@ int cmd_fetch(int argc,
2608 2565 N_("specify fetch refmap"), PARSE_OPT_NONEG, parse_refmap_arg),
2609 2566 OPT_STRING_LIST('o', "server-option", &server_options, N_("server-specific"), N_("option to transmit")),
2610 2567 OPT_IPVERSION(&family),
2611 - OPT_STRING_LIST(0, "negotiation-restrict", &negotiation_restrict, N_("revision"),
2568 + OPT_STRING_LIST(0, "negotiation-tip", &negotiation_tip, N_("revision"),
2612 2569 N_("report that we have only objects reachable from this object")),
2613 - OPT_ALIAS(0, "negotiation-tip", "negotiation-restrict"),
2614 - OPT_STRING_LIST(0, "negotiation-include", &negotiation_include, N_("revision"),
2615 - N_("ensure this ref is always sent as a negotiation have")),
2616 2570 OPT_BOOL(0, "negotiate-only", &negotiate_only,
2617 2571 N_("do not fetch a packfile; instead, print ancestors of negotiation tips")),
2618 2572 OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
@@ -2631,8 +2585,6 @@ int cmd_fetch(int argc,
2631 2585
2632 2586 filter_options.allow_auto_filter = 1;
2633 2587
2634 - refspec_init_fetch(&refmap, the_hash_algo);
2635 -
2636 2588 packet_trace_identity("fetch");
2637 2589
2638 2590 /* Record the command line for the reflog */
@@ -2704,6 +2656,9 @@ int cmd_fetch(int argc,
2704 2656 config.display_format = DISPLAY_FORMAT_PORCELAIN;
2705 2657 }
2706 2658
2659 + if (negotiate_only && !negotiation_tip.nr)
2660 + die(_("--negotiate-only needs one or more --negotiation-tip=*"));
2661 +
2707 2662 if (deepen_relative) {
2708 2663 if (deepen_relative < 0)
2709 2664 die(_("negative depth in --deepen is not supported"));
@@ -2791,19 +2746,14 @@ int cmd_fetch(int argc,
2791 2746 if (!remote)
2792 2747 die(_("must supply remote when using --negotiate-only"));
2793 2748 gtransport = prepare_transport(remote, 1, &filter_options);
2794 -
2795 - if (!gtransport->smart_options) {
2749 + if (gtransport->smart_options) {
2750 + gtransport->smart_options->acked_commits = &acked_commits;
2751 + } else {
2796 2752 warning(_("protocol does not support --negotiate-only, exiting"));
2797 2753 result = 1;
2798 2754 trace2_region_leave("fetch", "negotiate-only", the_repository);
2799 2755 goto cleanup;
2800 2756 }
2801 - if (!gtransport->smart_options->negotiation_restrict_tips)
2802 - die(_("%s needs one or more %s"), "--negotiate-only",
2803 - "--negotiation-restrict=*");
2804 -
2805 - gtransport->smart_options->acked_commits = &acked_commits;
2806 -
2807 2757 if (server_options.nr)
2808 2758 gtransport->server_options = &server_options;
2809 2759 result = transport_fetch_refs(gtransport, NULL);
modified builtin/fsck.c
@@ -632,7 +632,7 @@ static void snapshot_refs(struct repository *repo,
632 632 refs_for_each_ref_ext(get_main_ref_store(repo),
633 633 snapshot_ref, &data, &opts);
634 634
635 - worktrees = get_worktrees(repo);
635 + worktrees = get_worktrees();
636 636 for (p = worktrees; *p; p++) {
637 637 struct worktree *wt = *p;
638 638 struct strbuf refname = STRBUF_INIT;
@@ -685,7 +685,7 @@ static void process_refs(struct repository *repo, struct snapshot *snap)
685 685 }
686 686
687 687 if (include_reflogs) {
688 - worktrees = get_worktrees(repo);
688 + worktrees = get_worktrees();
689 689 for (p = worktrees; *p; p++) {
690 690 struct worktree *wt = *p;
691 691
@@ -724,7 +724,7 @@ static int fsck_loose(const struct object_id *oid, const char *path,
724 724 struct for_each_loose_cb *data = cb_data;
725 725 struct object *obj;
726 726 enum object_type type = OBJ_NONE;
727 - size_t size;
727 + unsigned long size;
728 728 void *contents = NULL;
729 729 int eaten;
730 730 struct object_info oi = OBJECT_INFO_INIT;
@@ -1017,15 +1017,15 @@ int cmd_fsck(int argc,
1017 1017 .ref = NULL
1018 1018 };
1019 1019
1020 + /* fsck knows how to handle missing promisor objects */
1021 + fetch_if_missing = 0;
1022 +
1020 1023 errors_found = 0;
1021 1024 disable_replace_refs();
1022 1025 save_commit_buffer = 0;
1023 1026
1024 1027 argc = parse_options(argc, argv, prefix, fsck_opts, fsck_usage, 0);
1025 1028
1026 - /* fsck knows how to handle missing promisor objects */
1027 - repo->fetch_if_missing = 0;
1028 -
1029 1029 fsck_options_init(&fsck_walk_options, repo, FSCK_OPTIONS_DEFAULT);
1030 1030 fsck_walk_options.walk = mark_object;
1031 1031
@@ -1069,6 +1069,7 @@ int cmd_fsck(int argc,
1069 1069 odb_for_each_object(repo->objects, NULL,
1070 1070 mark_object_for_connectivity, repo, 0);
1071 1071 } else {
1072 + odb_prepare_alternates(repo->objects);
1072 1073 for (source = repo->objects->sources; source; source = source->next)
1073 1074 fsck_source(repo, source);
1074 1075
@@ -1120,7 +1121,7 @@ int cmd_fsck(int argc,
1120 1121 verify_index_checksum = 1;
1121 1122 verify_ce_order = 1;
1122 1123
1123 - worktrees = get_worktrees(repo);
1124 + worktrees = get_worktrees();
1124 1125 for (p = worktrees; *p; p++) {
1125 1126 struct worktree *wt = *p;
1126 1127 struct index_state istate =
@@ -1154,6 +1155,7 @@ int cmd_fsck(int argc,
1154 1155 if (repo->settings.core_commit_graph) {
1155 1156 struct child_process commit_graph_verify = CHILD_PROCESS_INIT;
1156 1157
1158 + odb_prepare_alternates(repo->objects);
1157 1159 for (source = repo->objects->sources; source; source = source->next) {
1158 1160 child_process_init(&commit_graph_verify);
1159 1161 commit_graph_verify.git_cmd = 1;
@@ -1171,6 +1173,7 @@ int cmd_fsck(int argc,
1171 1173 if (repo->settings.core_multi_pack_index) {
1172 1174 struct child_process midx_verify = CHILD_PROCESS_INIT;
1173 1175
1176 + odb_prepare_alternates(repo->objects);
1174 1177 for (source = repo->objects->sources; source; source = source->next) {
1175 1178 child_process_init(&midx_verify);
1176 1179 midx_verify.git_cmd = 1;
modified builtin/fsmonitor--daemon.c
@@ -16,7 +16,7 @@
16 16 #include "fsmonitor--daemon.h"
17 17
18 18 #include "simple-ipc.h"
19 - #include "strmap.h"
19 + #include "khash.h"
20 20 #include "run-command.h"
21 21 #include "trace.h"
22 22 #include "trace2.h"
@@ -86,8 +86,6 @@ static int do_as_client__send_stop(void)
86 86 {
87 87 struct strbuf answer = STRBUF_INIT;
88 88 int ret;
89 - int max_wait_ms = 30000;
90 - int elapsed_ms = 0;
91 89
92 90 ret = fsmonitor_ipc__send_command("quit", &answer);
93 91
@@ -98,16 +96,8 @@ static int do_as_client__send_stop(void)
98 96 return ret;
99 97
100 98 trace2_region_enter("fsm_client", "polling-for-daemon-exit", NULL);
101 - while (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING) {
102 - if (elapsed_ms >= max_wait_ms) {
103 - trace2_region_leave("fsm_client",
104 - "polling-for-daemon-exit", NULL);
105 - return error(_("daemon did not stop within %d seconds"),
106 - max_wait_ms / 1000);
107 - }
99 + while (fsmonitor_ipc__get_state() == IPC_STATE__LISTENING)
108 100 sleep_millisec(50);
109 - elapsed_ms += 50;
110 - }
111 101 trace2_region_leave("fsm_client", "polling-for-daemon-exit", NULL);
112 102
113 103 return 0;
@@ -207,31 +197,20 @@ static enum fsmonitor_cookie_item_result with_lock__wait_for_cookie(
207 197 unlink(cookie_pathname.buf);
208 198
209 199 /*
210 - * Wait for the listener thread to observe the cookie file.
211 - * Time out after a short interval so that the client
212 - * does not hang forever if the filesystem does not deliver
213 - * events (e.g., on certain container/overlay filesystems
214 - * where inotify watches succeed but events never arrive).
200 + * Technically, this is an infinite wait (well, unless another
201 + * thread sends us an abort). I'd like to change this to
202 + * use `pthread_cond_timedwait()` and return an error/timeout
203 + * and let the caller do the trivial response thing, but we
204 + * don't have that routine in our thread-utils.
205 + *
206 + * After extensive beta testing I'm not really worried about
207 + * this. Also note that the above open() and unlink() calls
208 + * will cause at least two FS events on that path, so the odds
209 + * of getting stuck are pretty slim.
215 210 */
216 - {
217 - struct timeval now;
218 - struct timespec ts;
219 - int err = 0;
220 -
221 - gettimeofday(&now, NULL);
222 - ts.tv_sec = now.tv_sec + 1;
223 - ts.tv_nsec = now.tv_usec * 1000;
224 -
225 - while (cookie->result == FCIR_INIT && !err)
226 - err = pthread_cond_timedwait(&state->cookies_cond,
227 - &state->main_lock,
228 - &ts);
229 - if (err == ETIMEDOUT && cookie->result == FCIR_INIT) {
230 - trace_printf_key(&trace_fsmonitor,
231 - "cookie_wait timed out");
232 - cookie->result = FCIR_ERROR;
233 - }
234 - }
211 + while (cookie->result == FCIR_INIT)
212 + pthread_cond_wait(&state->cookies_cond,
213 + &state->main_lock);
235 214
236 215 done:
237 216 hashmap_remove(&state->cookies, &cookie->entry, NULL);
@@ -674,6 +653,8 @@ static int fsmonitor_parse_client_token(const char *buf_token,
674 653 return 0;
675 654 }
676 655
656 + KHASH_INIT(str, const char *, int, 0, kh_str_hash_func, kh_str_hash_equal)
657 +
677 658 static int do_handle_client(struct fsmonitor_daemon_state *state,
678 659 const char *command,
679 660 ipc_server_reply_cb *reply,
@@ -690,7 +671,8 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
690 671 const struct fsmonitor_batch *batch;
691 672 struct fsmonitor_batch *remainder = NULL;
692 673 intmax_t count = 0, duplicates = 0;
693 - struct strset shown = STRSET_INIT;
674 + kh_str_t *shown;
675 + int hash_ret;
694 676 int do_trivial = 0;
695 677 int do_flush = 0;
696 678 int do_cookie = 0;
@@ -879,14 +861,14 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
879 861 * so walk the batch list backwards from the current head back
880 862 * to the batch (sequence number) they named.
881 863 *
882 - * We use a strset to de-dup the list of pathnames.
864 + * We use khash to de-dup the list of pathnames.
883 865 *
884 866 * NEEDSWORK: each batch contains a list of interned strings,
885 867 * so we only need to do pointer comparisons here to build the
886 868 * hash table. Currently, we're still comparing the string
887 869 * values.
888 870 */
889 - strset_init_with_options(&shown, NULL, 0);
871 + shown = kh_init_str();
890 872 for (batch = batch_head;
891 873 batch && batch->batch_seq_nr > requested_oldest_seq_nr;
892 874 batch = batch->next) {
@@ -896,9 +878,11 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
896 878 const char *s = batch->interned_paths[k];
897 879 size_t s_len;
898 880
899 - if (!strset_add(&shown, s))
881 + if (kh_get_str(shown, s) != kh_end(shown))
900 882 duplicates++;
901 883 else {
884 + kh_put_str(shown, s, &hash_ret);
885 +
902 886 trace_printf_key(&trace_fsmonitor,
903 887 "send[%"PRIuMAX"]: %s",
904 888 count, s);
@@ -925,6 +909,8 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
925 909 total_response_len += payload.len;
926 910 }
927 911
912 + kh_release_str(shown);
913 +
928 914 pthread_mutex_lock(&state->main_lock);
929 915
930 916 if (token_data->client_ref_count > 0)
@@ -968,7 +954,6 @@ static int do_handle_client(struct fsmonitor_daemon_state *state,
968 954 trace2_data_intmax("fsmonitor", the_repository, "response/count/duplicates", duplicates);
969 955
970 956 cleanup:
971 - strset_clear(&shown);
972 957 strbuf_release(&response_token);
973 958 strbuf_release(&requested_token_id);
974 959 strbuf_release(&payload);
@@ -1418,19 +1403,8 @@ static int fsmonitor_run_daemon(void)
1418 1403 err = fsmonitor_run_daemon_1(&state);
1419 1404
1420 1405 done:
1421 - fsmonitor_free_token_data(state.current_token_data);
1422 - state.current_token_data = NULL;
1423 1406 pthread_cond_destroy(&state.cookies_cond);
1424 1407 pthread_mutex_destroy(&state.main_lock);
1425 - {
1426 - struct hashmap_iter iter;
1427 - struct fsmonitor_cookie_item *cookie;
1428 -
1429 - hashmap_for_each_entry(&state.cookies, &iter, cookie, entry)
1430 - free(cookie->name);
1431 - hashmap_clear_and_free(&state.cookies,
1432 - struct fsmonitor_cookie_item, entry);
1433 - }
1434 1408 fsm_listen__dtor(&state);
1435 1409 fsm_health__dtor(&state);
1436 1410
@@ -1446,7 +1420,7 @@ done:
1446 1420 return err;
1447 1421 }
1448 1422
1449 - static int try_to_run_foreground_daemon(int detach_console)
1423 + static int try_to_run_foreground_daemon(int detach_console MAYBE_UNUSED)
1450 1424 {
1451 1425 /*
1452 1426 * Technically, we don't need to probe for an existing daemon
@@ -1466,21 +1440,10 @@ static int try_to_run_foreground_daemon(int detach_console)
1466 1440 fflush(stderr);
1467 1441 }
1468 1442
1469 - if (detach_console) {
1470 1443 #ifdef GIT_WINDOWS_NATIVE
1444 + if (detach_console)
1471 1445 FreeConsole();
1472 - #else
1473 - /*
1474 - * Create a new session so that the daemon is detached
1475 - * from the parent's process group. This prevents
1476 - * shells with job control (e.g. bash with "set -m")
1477 - * from waiting on the daemon when they wait for a
1478 - * foreground command that implicitly spawned it.
1479 - */
1480 - if (setsid() == -1)
1481 - warning_errno(_("setsid failed"));
1482 1446 #endif
1483 - }
1484 1447
1485 1448 return !!fsmonitor_run_daemon();
1486 1449 }
@@ -1543,7 +1506,6 @@ static int try_to_start_background_daemon(void)
1543 1506 cp.no_stdin = 1;
1544 1507 cp.no_stdout = 1;
1545 1508 cp.no_stderr = 1;
1546 - cp.close_fd_above_stderr = 1;
1547 1509
1548 1510 sbgr = start_bg_command(&cp, bg_wait_cb, NULL,
1549 1511 fsmonitor__start_timeout_sec);
modified builtin/gc.c
@@ -30,11 +30,16 @@
30 30 #include "commit-graph.h"
31 31 #include "packfile.h"
32 32 #include "object-file.h"
33 - #include "odb.h"
33 + #include "pack.h"
34 + #include "pack-objects.h"
34 35 #include "path.h"
35 36 #include "reflog.h"
37 + #include "repack.h"
36 38 #include "rerere.h"
37 39 #include "revision.h"
40 + #include "blob.h"
41 + #include "tree.h"
42 + #include "promisor-remote.h"
38 43 #include "refs.h"
39 44 #include "remote.h"
40 45 #include "exec-cmd.h"
@@ -125,11 +130,22 @@ struct gc_config {
125 130 unsigned long max_cruft_size;
126 131 int aggressive_depth;
127 132 int aggressive_window;
133 + int gc_auto_threshold;
134 + int gc_auto_pack_limit;
128 135 int detach_auto;
129 136 char *gc_log_expire;
130 137 char *prune_expire;
131 138 char *prune_worktrees_expire;
139 + char *repack_filter;
140 + char *repack_filter_to;
132 141 char *repack_expire_to;
142 + unsigned long big_pack_threshold;
143 + unsigned long max_delta_cache_size;
144 + /*
145 + * Remove this member from gc_config once repo_settings is passed
146 + * through the callchain.
147 + */
148 + size_t delta_base_cache_limit;
133 149 };
134 150
135 151 #define GC_CONFIG_INIT { \
@@ -138,10 +154,14 @@ struct gc_config {
138 154 .cruft_packs = 1, \
139 155 .aggressive_depth = 50, \
140 156 .aggressive_window = 250, \
157 + .gc_auto_threshold = 6700, \
158 + .gc_auto_pack_limit = 50, \
141 159 .detach_auto = 1, \
142 160 .gc_log_expire = xstrdup("1.day.ago"), \
143 161 .prune_expire = xstrdup("2.weeks.ago"), \
144 162 .prune_worktrees_expire = xstrdup("3.months.ago"), \
163 + .max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE, \
164 + .delta_base_cache_limit = DEFAULT_DELTA_BASE_CACHE_LIMIT, \
145 165 }
146 166
147 167 static void gc_config_release(struct gc_config *cfg)
@@ -149,12 +169,15 @@ static void gc_config_release(struct gc_config *cfg)
149 169 free(cfg->gc_log_expire);
150 170 free(cfg->prune_expire);
151 171 free(cfg->prune_worktrees_expire);
172 + free(cfg->repack_filter);
173 + free(cfg->repack_filter_to);
152 174 }
153 175
154 176 static void gc_config(struct gc_config *cfg)
155 177 {
156 178 const char *value;
157 179 char *owned = NULL;
180 + unsigned long ulongval;
158 181
159 182 if (!repo_config_get_value(the_repository, "gc.packrefs", &value)) {
160 183 if (value && !strcmp(value, "notbare"))
@@ -169,6 +192,8 @@ static void gc_config(struct gc_config *cfg)
169 192
170 193 repo_config_get_int(the_repository, "gc.aggressivewindow", &cfg->aggressive_window);
171 194 repo_config_get_int(the_repository, "gc.aggressivedepth", &cfg->aggressive_depth);
195 + repo_config_get_int(the_repository, "gc.auto", &cfg->gc_auto_threshold);
196 + repo_config_get_int(the_repository, "gc.autopacklimit", &cfg->gc_auto_pack_limit);
172 197 repo_config_get_bool(the_repository, "gc.autodetach", &cfg->detach_auto);
173 198 repo_config_get_bool(the_repository, "gc.cruftpacks", &cfg->cruft_packs);
174 199 repo_config_get_ulong(the_repository, "gc.maxcruftsize", &cfg->max_cruft_size);
@@ -188,6 +213,22 @@ static void gc_config(struct gc_config *cfg)
188 213 cfg->gc_log_expire = owned;
189 214 }
190 215
216 + repo_config_get_ulong(the_repository, "gc.bigpackthreshold", &cfg->big_pack_threshold);
217 + repo_config_get_ulong(the_repository, "pack.deltacachesize", &cfg->max_delta_cache_size);
218 +
219 + if (!repo_config_get_ulong(the_repository, "core.deltabasecachelimit", &ulongval))
220 + cfg->delta_base_cache_limit = ulongval;
221 +
222 + if (!repo_config_get_string(the_repository, "gc.repackfilter", &owned)) {
223 + free(cfg->repack_filter);
224 + cfg->repack_filter = owned;
225 + }
226 +
227 + if (!repo_config_get_string(the_repository, "gc.repackfilterto", &owned)) {
228 + free(cfg->repack_filter_to);
229 + cfg->repack_filter_to = owned;
230 + }
231 +
191 232 repo_config(the_repository, git_default_config, NULL);
192 233 }
193 234
@@ -371,7 +412,7 @@ static int worktree_prune_condition(struct gc_config *cfg)
371 412 while (limit && (d = readdir_skip_dot_and_dotdot(dir))) {
372 413 char *wtpath;
373 414 strbuf_reset(&buf);
374 - if (should_prune_worktree(the_repository, d->d_name, &buf, &wtpath, expiry_date))
415 + if (should_prune_worktree(d->d_name, &buf, &wtpath, expiry_date))
375 416 limit--;
376 417 free(wtpath);
377 418 }
@@ -423,13 +464,255 @@ out:
423 464 return should_gc;
424 465 }
425 466
426 - #define OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, aggressive) \
427 - .prune_expire = (cfg)->prune_expire, \
428 - .expire_to = (cfg)->repack_expire_to, \
429 - .cruft_packs = (cfg)->cruft_packs, \
430 - .max_cruft_size = (cfg)->max_cruft_size, \
431 - .window = (aggressive) ? (cfg)->aggressive_window : 0, \
432 - .depth = (aggressive) ? (cfg)->aggressive_depth : 0
467 + static int too_many_loose_objects(int limit)
468 + {
469 + /*
470 + * This is weird, but stems from legacy behaviour: the GC auto
471 + * threshold was always essentially interpreted as if it was rounded up
472 + * to the next multiple 256 of, so we retain this behaviour for now.
473 + */
474 + int auto_threshold = DIV_ROUND_UP(limit, 256) * 256;
475 + unsigned long loose_count;
476 +
477 + if (odb_source_loose_count_objects(the_repository->objects->sources,
478 + ODB_COUNT_OBJECTS_APPROXIMATE,
479 + &loose_count) < 0)
480 + return 0;
481 +
482 + return loose_count > auto_threshold;
483 + }
484 +
485 + static struct packed_git *find_base_packs(struct string_list *packs,
486 + unsigned long limit)
487 + {
488 + struct packed_git *p, *base = NULL;
489 +
490 + repo_for_each_pack(the_repository, p) {
491 + if (!p->pack_local || p->is_cruft)
492 + continue;
493 + if (limit) {
494 + if (p->pack_size >= limit)
495 + string_list_append(packs, p->pack_name);
496 + } else if (!base || base->pack_size < p->pack_size) {
497 + base = p;
498 + }
499 + }
500 +
501 + if (base)
502 + string_list_append(packs, base->pack_name);
503 +
504 + return base;
505 + }
506 +
507 + static int too_many_packs(struct gc_config *cfg)
508 + {
509 + struct packed_git *p;
510 + int cnt = 0;
511 +
512 + if (cfg->gc_auto_pack_limit <= 0)
513 + return 0;
514 +
515 + repo_for_each_pack(the_repository, p) {
516 + if (!p->pack_local)
517 + continue;
518 + if (p->pack_keep)
519 + continue;
520 + /*
521 + * Perhaps check the size of the pack and count only
522 + * very small ones here?
523 + */
524 + cnt++;
525 + }
526 + return cfg->gc_auto_pack_limit < cnt;
527 + }
528 +
529 + static uint64_t total_ram(void)
530 + {
531 + #if defined(HAVE_SYSINFO)
532 + struct sysinfo si;
533 +
534 + if (!sysinfo(&si)) {
535 + uint64_t total = si.totalram;
536 +
537 + if (si.mem_unit > 1)
538 + total *= (uint64_t)si.mem_unit;
539 + return total;
540 + }
541 + #elif defined(HAVE_BSD_SYSCTL) && (defined(HW_MEMSIZE) || defined(HW_PHYSMEM) || defined(HW_PHYSMEM64))
542 + uint64_t physical_memory;
543 + int mib[2];
544 + size_t length;
545 +
546 + mib[0] = CTL_HW;
547 + # if defined(HW_MEMSIZE)
548 + mib[1] = HW_MEMSIZE;
549 + # elif defined(HW_PHYSMEM64)
550 + mib[1] = HW_PHYSMEM64;
551 + # else
552 + mib[1] = HW_PHYSMEM;
553 + # endif
554 + length = sizeof(physical_memory);
555 + if (!sysctl(mib, 2, &physical_memory, &length, NULL, 0)) {
556 + if (length == 4) {
557 + uint32_t mem;
558 +
559 + if (!sysctl(mib, 2, &mem, &length, NULL, 0))
560 + physical_memory = mem;
561 + }
562 + return physical_memory;
563 + }
564 + #elif defined(GIT_WINDOWS_NATIVE)
565 + MEMORYSTATUSEX memInfo;
566 +
567 + memInfo.dwLength = sizeof(MEMORYSTATUSEX);
568 + if (GlobalMemoryStatusEx(&memInfo))
569 + return memInfo.ullTotalPhys;
570 + #endif
571 + return 0;
572 + }
573 +
574 + static uint64_t estimate_repack_memory(struct gc_config *cfg,
575 + struct packed_git *pack)
576 + {
577 + unsigned long nr_objects;
578 + size_t os_cache, heap;
579 +
580 + if (odb_count_objects(the_repository->objects,
581 + ODB_COUNT_OBJECTS_APPROXIMATE, &nr_objects) < 0)
582 + return 0;
583 +
584 + if (!pack || !nr_objects)
585 + return 0;
586 +
587 + /*
588 + * First we have to scan through at least one pack.
589 + * Assume enough room in OS file cache to keep the entire pack
590 + * or we may accidentally evict data of other processes from
591 + * the cache.
592 + */
593 + os_cache = pack->pack_size + pack->index_size;
594 + /* then pack-objects needs lots more for book keeping */
595 + heap = sizeof(struct object_entry) * nr_objects;
596 + /*
597 + * internal rev-list --all --objects takes up some memory too,
598 + * let's say half of it is for blobs
599 + */
600 + heap += sizeof(struct blob) * nr_objects / 2;
601 + /*
602 + * and the other half is for trees (commits and tags are
603 + * usually insignificant)
604 + */
605 + heap += sizeof(struct tree) * nr_objects / 2;
606 + /* and then obj_hash[], underestimated in fact */
607 + heap += sizeof(struct object *) * nr_objects;
608 + /* revindex is used also */
609 + heap += (sizeof(off_t) + sizeof(uint32_t)) * nr_objects;
610 + /*
611 + * read_sha1_file() (either at delta calculation phase, or
612 + * writing phase) also fills up the delta base cache
613 + */
614 + heap += cfg->delta_base_cache_limit;
615 + /* and of course pack-objects has its own delta cache */
616 + heap += cfg->max_delta_cache_size;
617 +
618 + return os_cache + heap;
619 + }
620 +
621 + static int keep_one_pack(struct string_list_item *item, void *data)
622 + {
623 + struct strvec *args = data;
624 + strvec_pushf(args, "--keep-pack=%s", basename(item->string));
625 + return 0;
626 + }
627 +
628 + static void add_repack_all_option(struct gc_config *cfg,
629 + struct string_list *keep_pack,
630 + struct strvec *args)
631 + {
632 + if (cfg->prune_expire && !strcmp(cfg->prune_expire, "now")
633 + && !(cfg->cruft_packs && cfg->repack_expire_to))
634 + strvec_push(args, "-a");
635 + else if (cfg->cruft_packs) {
636 + strvec_push(args, "--cruft");
637 + if (cfg->prune_expire)
638 + strvec_pushf(args, "--cruft-expiration=%s", cfg->prune_expire);
639 + if (cfg->max_cruft_size)
640 + strvec_pushf(args, "--max-cruft-size=%lu",
641 + cfg->max_cruft_size);
642 + if (cfg->repack_expire_to)
643 + strvec_pushf(args, "--expire-to=%s", cfg->repack_expire_to);
644 + } else {
645 + strvec_push(args, "-A");
646 + if (cfg->prune_expire)
647 + strvec_pushf(args, "--unpack-unreachable=%s", cfg->prune_expire);
648 + }
649 +
650 + if (keep_pack)
651 + for_each_string_list(keep_pack, keep_one_pack, args);
652 +
653 + if (cfg->repack_filter && *cfg->repack_filter)
654 + strvec_pushf(args, "--filter=%s", cfg->repack_filter);
655 + if (cfg->repack_filter_to && *cfg->repack_filter_to)
656 + strvec_pushf(args, "--filter-to=%s", cfg->repack_filter_to);
657 + }
658 +
659 + static void add_repack_incremental_option(struct strvec *args)
660 + {
661 + strvec_push(args, "--no-write-bitmap-index");
662 + }
663 +
664 + static int need_to_gc(struct gc_config *cfg, struct strvec *repack_args)
665 + {
666 + /*
667 + * Setting gc.auto to 0 or negative can disable the
668 + * automatic gc.
669 + */
670 + if (cfg->gc_auto_threshold <= 0)
671 + return 0;
672 +
673 + /*
674 + * If there are too many loose objects, but not too many
675 + * packs, we run "repack -d -l". If there are too many packs,
676 + * we run "repack -A -d -l". Otherwise we tell the caller
677 + * there is no need.
678 + */
679 + if (too_many_packs(cfg)) {
680 + struct string_list keep_pack = STRING_LIST_INIT_NODUP;
681 +
682 + if (cfg->big_pack_threshold) {
683 + find_base_packs(&keep_pack, cfg->big_pack_threshold);
684 + if (keep_pack.nr >= cfg->gc_auto_pack_limit) {
685 + cfg->big_pack_threshold = 0;
686 + string_list_clear(&keep_pack, 0);
687 + find_base_packs(&keep_pack, 0);
688 + }
689 + } else {
690 + struct packed_git *p = find_base_packs(&keep_pack, 0);
691 + uint64_t mem_have, mem_want;
692 +
693 + mem_have = total_ram();
694 + mem_want = estimate_repack_memory(cfg, p);
695 +
696 + /*
697 + * Only allow 1/2 of memory for pack-objects, leave
698 + * the rest for the OS and other processes in the
699 + * system.
700 + */
701 + if (!mem_have || mem_want < mem_have / 2)
702 + string_list_clear(&keep_pack, 0);
703 + }
704 +
705 + add_repack_all_option(cfg, &keep_pack, repack_args);
706 + string_list_clear(&keep_pack, 0);
707 + } else if (too_many_loose_objects(cfg->gc_auto_threshold))
708 + add_repack_incremental_option(repack_args);
709 + else
710 + return 0;
711 +
712 + if (run_hooks(the_repository, "pre-auto-gc"))
713 + return 0;
714 + return 1;
715 + }
433 716
434 717 /* return NULL on success, else hostname running the gc */
435 718 static const char *lock_repo_for_gc(int force, pid_t* ret_pid)
@@ -558,27 +841,6 @@ static int gc_foreground_tasks(struct maintenance_run_opts *opts,
558 841 return 0;
559 842 }
560 843
561 - static int maintenance_task_odb(struct maintenance_run_opts *opts,
562 - struct gc_config *cfg,
563 - int keep_largest_pack,
564 - int aggressive)
565 - {
566 - struct odb_optimize_options odb_opts = {
567 - .strategy = ODB_OPTIMIZE_INCREMENTAL,
568 - .keep_largest_pack = keep_largest_pack,
569 - OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, aggressive),
570 - };
571 -
572 - if (opts->auto_flag)
573 - odb_opts.flags |= ODB_OPTIMIZE_AUTO;
574 - if (!opts->quiet)
575 - odb_opts.flags |= ODB_OPTIMIZE_VERBOSE;
576 - if (aggressive)
577 - odb_opts.flags |= ODB_OPTIMIZE_NO_REUSE_DELTAS;
578 -
579 - return odb_optimize(the_repository->objects, &odb_opts);
580 - }
581 -
582 844 int cmd_gc(int argc,
583 845 const char **argv,
584 846 const char *prefix,
@@ -592,6 +854,7 @@ int cmd_gc(int argc,
592 854 int keep_largest_pack = -1;
593 855 int skip_foreground_tasks = 0;
594 856 timestamp_t dummy;
857 + struct strvec repack_args = STRVEC_INIT;
595 858 struct maintenance_run_opts opts = MAINTENANCE_RUN_OPTS_INIT;
596 859 struct gc_config cfg = GC_CONFIG_INIT;
597 860 const char *prune_expire_sentinel = "sentinel";
@@ -631,13 +894,15 @@ int cmd_gc(int argc,
631 894 show_usage_with_options_if_asked(argc, argv,
632 895 builtin_gc_usage, builtin_gc_options);
633 896
897 + strvec_pushl(&repack_args, "repack", "-d", "-l", NULL);
898 +
634 899 gc_config(&cfg);
635 900
636 901 if (parse_expiry_date(cfg.gc_log_expire, &gc_log_expire_time))
637 902 die(_("failed to parse gc.logExpiry value %s"), cfg.gc_log_expire);
638 903
639 904 if (cfg.pack_refs < 0)
640 - cfg.pack_refs = !is_bare_repository(the_repository);
905 + cfg.pack_refs = !is_bare_repository();
641 906
642 907 argc = parse_options(argc, argv, prefix, builtin_gc_options,
643 908 builtin_gc_usage, 0);
@@ -651,20 +916,24 @@ int cmd_gc(int argc,
651 916 if (cfg.prune_expire && parse_expiry_date(cfg.prune_expire, &dummy))
652 917 die(_("failed to parse prune expiry value %s"), cfg.prune_expire);
653 918
654 - if (opts.auto_flag) {
655 - struct odb_optimize_options optimize_opts = {
656 - .strategy = ODB_OPTIMIZE_INCREMENTAL,
657 - OPTIMIZE_FIELDS_FROM_GC_CONFIG(&cfg, 0),
658 - };
919 + if (aggressive) {
920 + strvec_push(&repack_args, "-f");
921 + if (cfg.aggressive_depth > 0)
922 + strvec_pushf(&repack_args, "--depth=%d", cfg.aggressive_depth);
923 + if (cfg.aggressive_window > 0)
924 + strvec_pushf(&repack_args, "--window=%d", cfg.aggressive_window);
925 + }
926 + if (opts.quiet)
927 + strvec_push(&repack_args, "-q");
659 928
929 + if (opts.auto_flag) {
660 930 if (cfg.detach_auto && opts.detach < 0)
661 931 opts.detach = 1;
662 932
663 933 /*
664 934 * Auto-gc should be least intrusive as possible.
665 935 */
666 - if (!odb_optimize_required(the_repository->objects, &optimize_opts) ||
667 - run_hooks(the_repository, "pre-auto-gc")) {
936 + if (!need_to_gc(&cfg, &repack_args)) {
668 937 ret = 0;
669 938 goto out;
670 939 }
@@ -676,6 +945,18 @@ int cmd_gc(int argc,
676 945 fprintf(stderr, _("Auto packing the repository for optimum performance.\n"));
677 946 fprintf(stderr, _("See \"git help gc\" for manual housekeeping.\n"));
678 947 }
948 + } else {
949 + struct string_list keep_pack = STRING_LIST_INIT_NODUP;
950 +
951 + if (keep_largest_pack != -1) {
952 + if (keep_largest_pack)
953 + find_base_packs(&keep_pack, 0);
954 + } else if (cfg.big_pack_threshold) {
955 + find_base_packs(&keep_pack, cfg.big_pack_threshold);
956 + }
957 +
958 + add_repack_all_option(&cfg, &keep_pack, &repack_args);
959 + string_list_clear(&keep_pack, 0);
679 960 }
680 961
681 962 if (opts.detach > 0) {
@@ -731,6 +1012,33 @@ int cmd_gc(int argc,
731 1012 if (opts.detach <= 0 && !skip_foreground_tasks)
732 1013 gc_foreground_tasks(&opts, &cfg);
733 1014
1015 + if (!the_repository->repository_format_precious_objects) {
1016 + struct child_process repack_cmd = CHILD_PROCESS_INIT;
1017 +
1018 + repack_cmd.git_cmd = 1;
1019 + repack_cmd.odb_to_close = the_repository->objects;
1020 + strvec_pushv(&repack_cmd.args, repack_args.v);
1021 + if (run_command(&repack_cmd))
1022 + die(FAILED_RUN, repack_args.v[0]);
1023 +
1024 + if (cfg.prune_expire) {
1025 + struct child_process prune_cmd = CHILD_PROCESS_INIT;
1026 +
1027 + strvec_pushl(&prune_cmd.args, "prune", "--expire", NULL);
1028 + /* run `git prune` even if using cruft packs */
1029 + strvec_push(&prune_cmd.args, cfg.prune_expire);
1030 + if (opts.quiet)
1031 + strvec_push(&prune_cmd.args, "--no-progress");
1032 + if (repo_has_promisor_remote(the_repository))
1033 + strvec_push(&prune_cmd.args,
1034 + "--exclude-promisor-objects");
1035 + prune_cmd.git_cmd = 1;
1036 +
1037 + if (run_command(&prune_cmd))
1038 + die(FAILED_RUN, prune_cmd.args.v[0]);
1039 + }
1040 + }
1041 +
734 1042 if (cfg.prune_worktrees_expire &&
735 1043 maintenance_task_worktree_prune(&opts, &cfg))
736 1044 die(FAILED_RUN, "worktree");
@@ -738,9 +1046,6 @@ int cmd_gc(int argc,
738 1046 if (maintenance_task_rerere_gc(&opts, &cfg))
739 1047 die(FAILED_RUN, "rerere");
740 1048
741 - if (maintenance_task_odb(&opts, &cfg, keep_largest_pack, aggressive))
742 - die(NULL);
743 -
744 1049 report_garbage = report_pack_garbage;
745 1050 odb_reprepare(the_repository->objects);
746 1051 if (pack_garbage.nr > 0) {
@@ -753,6 +1058,10 @@ int cmd_gc(int argc,
753 1058 !opts.quiet && !daemonized ? COMMIT_GRAPH_WRITE_PROGRESS : 0,
754 1059 NULL);
755 1060
1061 + if (opts.auto_flag && too_many_loose_objects(cfg.gc_auto_threshold))
1062 + warning(_("There are too many unreachable loose objects; "
1063 + "run 'git prune' to remove them."));
1064 +
756 1065 if (!daemonized) {
757 1066 char *path = repo_git_path(the_repository, "gc.log");
758 1067 unlink(path);
@@ -761,6 +1070,7 @@ int cmd_gc(int argc,
761 1070
762 1071 out:
763 1072 maintenance_run_opts_release(&opts);
1073 + strvec_clear(&repack_args);
764 1074 gc_config_release(&cfg);
765 1075 return 0;
766 1076 }
@@ -963,11 +1273,15 @@ static int maintenance_task_gc_background(struct maintenance_run_opts *opts,
963 1273
964 1274 static int gc_condition(struct gc_config *cfg)
965 1275 {
966 - struct odb_optimize_options opts = {
967 - .strategy = ODB_OPTIMIZE_INCREMENTAL,
968 - OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, 0),
969 - };
970 - return odb_optimize_required(the_repository->objects, &opts);
1276 + /*
1277 + * Note that it's fine to drop the repack arguments here, as we execute
1278 + * git-gc(1) as a separate child process anyway. So it knows to compute
1279 + * these arguments again.
1280 + */
1281 + struct strvec repack_args = STRVEC_INIT;
1282 + int ret = need_to_gc(cfg, &repack_args);
1283 + strvec_clear(&repack_args);
1284 + return ret;
971 1285 }
972 1286
973 1287 static int prune_packed(struct maintenance_run_opts *opts)
@@ -1256,24 +1570,104 @@ static int maintenance_task_incremental_repack(struct maintenance_run_opts *opts
1256 1570 static int maintenance_task_geometric_repack(struct maintenance_run_opts *opts,
1257 1571 struct gc_config *cfg)
1258 1572 {
1259 - struct odb_optimize_options odb_opts = {
1260 - .strategy = ODB_OPTIMIZE_GEOMETRIC,
1261 - OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, 0),
1573 + struct pack_geometry geometry = {
1574 + .split_factor = 2,
1262 1575 };
1576 + struct pack_objects_args po_args = {
1577 + .local = 1,
1578 + };
1579 + struct existing_packs existing_packs = EXISTING_PACKS_INIT;
1580 + struct string_list kept_packs = STRING_LIST_INIT_DUP;
1581 + struct child_process child = CHILD_PROCESS_INIT;
1582 + int ret;
1583 +
1584 + repo_config_get_int(the_repository, "maintenance.geometric-repack.splitFactor",
1585 + &geometry.split_factor);
1586 +
1587 + existing_packs.repo = the_repository;
1588 + existing_packs_collect(&existing_packs, &kept_packs);
1589 + pack_geometry_init(&geometry, &existing_packs, &po_args);
1590 + pack_geometry_split(&geometry);
1263 1591
1264 - if (!opts->quiet)
1265 - odb_opts.flags |= ODB_OPTIMIZE_VERBOSE;
1592 + child.git_cmd = 1;
1593 + child.odb_to_close = the_repository->objects;
1594 +
1595 + strvec_pushl(&child.args, "repack", "-d", "-l", NULL);
1596 + if (geometry.split < geometry.pack_nr)
1597 + strvec_pushf(&child.args, "--geometric=%d",
1598 + geometry.split_factor);
1599 + else
1600 + add_repack_all_option(cfg, NULL, &child.args);
1601 + if (opts->quiet)
1602 + strvec_push(&child.args, "--quiet");
1603 + if (the_repository->settings.core_multi_pack_index)
1604 + strvec_push(&child.args, "--write-midx");
1605 +
1606 + if (run_command(&child)) {
1607 + ret = error(_("failed to perform geometric repack"));
1608 + goto out;
1609 + }
1610 +
1611 + ret = 0;
1266 1612
1267 - return odb_optimize(the_repository->objects, &odb_opts);
1613 + out:
1614 + existing_packs_release(&existing_packs);
1615 + pack_geometry_release(&geometry);
1616 + return ret;
1268 1617 }
1269 1618
1270 - static int geometric_repack_auto_condition(struct gc_config *cfg)
1619 + static int geometric_repack_auto_condition(struct gc_config *cfg UNUSED)
1271 1620 {
1272 - struct odb_optimize_options opts = {
1273 - .strategy = ODB_OPTIMIZE_GEOMETRIC,
1274 - OPTIMIZE_FIELDS_FROM_GC_CONFIG(cfg, 0),
1621 + struct pack_geometry geometry = {
1622 + .split_factor = 2,
1623 + };
1624 + struct pack_objects_args po_args = {
1625 + .local = 1,
1275 1626 };
1276 - return odb_optimize_required(the_repository->objects, &opts);
1627 + struct existing_packs existing_packs = EXISTING_PACKS_INIT;
1628 + struct string_list kept_packs = STRING_LIST_INIT_DUP;
1629 + int auto_value = 100;
1630 + int ret;
1631 +
1632 + repo_config_get_int(the_repository, "maintenance.geometric-repack.auto",
1633 + &auto_value);
1634 + if (!auto_value)
1635 + return 0;
1636 + if (auto_value < 0)
1637 + return 1;
1638 +
1639 + repo_config_get_int(the_repository, "maintenance.geometric-repack.splitFactor",
1640 + &geometry.split_factor);
1641 +
1642 + existing_packs.repo = the_repository;
1643 + existing_packs_collect(&existing_packs, &kept_packs);
1644 + pack_geometry_init(&geometry, &existing_packs, &po_args);
1645 + pack_geometry_split(&geometry);
1646 +
1647 + /*
1648 + * When we'd merge at least two packs with one another we always
1649 + * perform the repack.
1650 + */
1651 + if (geometry.split) {
1652 + ret = 1;
1653 + goto out;
1654 + }
1655 +
1656 + /*
1657 + * Otherwise, we estimate the number of loose objects to determine
1658 + * whether we want to create a new packfile or not.
1659 + */
1660 + if (too_many_loose_objects(auto_value)) {
1661 + ret = 1;
1662 + goto out;
1663 + }
1664 +
1665 + ret = 0;
1666 +
1667 + out:
1668 + existing_packs_release(&existing_packs);
1669 + pack_geometry_release(&geometry);
1670 + return ret;
1277 1671 }
1278 1672
1279 1673 typedef int (*maintenance_task_fn)(struct maintenance_run_opts *opts,
@@ -1361,18 +1755,11 @@ enum task_phase {
1361 1755 TASK_PHASE_BACKGROUND,
1362 1756 };
1363 1757
1364 - enum auto_gc_hook_result {
1365 - AUTO_GC_HOOK_UNDECIDED = 0,
1366 - AUTO_GC_HOOK_RUN = 1,
1367 - AUTO_GC_HOOK_SKIP = 2,
1368 - };
1369 -
1370 1758 static int maybe_run_task(const struct maintenance_task *task,
1371 1759 struct repository *repo,
1372 1760 struct maintenance_run_opts *opts,
1373 1761 struct gc_config *cfg,
1374 - enum task_phase phase,
1375 - enum auto_gc_hook_result *auto_gc_hook_result)
1762 + enum task_phase phase)
1376 1763 {
1377 1764 int foreground = (phase == TASK_PHASE_FOREGROUND);
1378 1765 maintenance_task_fn fn = foreground ? task->foreground : task->background;
@@ -1381,19 +1768,9 @@ static int maybe_run_task(const struct maintenance_task *task,
1381 1768
1382 1769 if (!fn)
1383 1770 return 0;
1384 - if (opts->auto_flag) {
1385 - if (*auto_gc_hook_result == AUTO_GC_HOOK_SKIP)
1386 - return 0;
1387 -
1388 - if (!task->auto_condition || !task->auto_condition(cfg))
1389 - return 0;
1390 -
1391 - if (*auto_gc_hook_result == AUTO_GC_HOOK_UNDECIDED)
1392 - *auto_gc_hook_result = run_hooks(repo, "pre-auto-gc") ?
1393 - AUTO_GC_HOOK_SKIP : AUTO_GC_HOOK_RUN;
1394 - if (*auto_gc_hook_result == AUTO_GC_HOOK_SKIP)
1395 - return 0;
1396 - }
1771 + if (opts->auto_flag &&
1772 + (!task->auto_condition || !task->auto_condition(cfg)))
1773 + return 0;
1397 1774
1398 1775 trace2_region_enter(region, task->name, repo);
1399 1776 if (fn(opts, cfg)) {
@@ -1412,9 +1789,8 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
1412 1789 struct lock_file lk;
1413 1790 struct repository *r = the_repository;
1414 1791 char *lock_path = xstrfmt("%s/maintenance", r->objects->sources->path);
1415 - enum auto_gc_hook_result auto_gc_hook_result = AUTO_GC_HOOK_UNDECIDED;
1416 1792
1417 - if (repo_hold_lock_file_for_update(r, &lk, lock_path, LOCK_NO_DEREF) < 0) {
1793 + if (hold_lock_file_for_update(&lk, lock_path, LOCK_NO_DEREF) < 0) {
1418 1794 /*
1419 1795 * Another maintenance command is running.
1420 1796 *
@@ -1432,7 +1808,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
1432 1808
1433 1809 for (size_t i = 0; i < opts->tasks_nr; i++)
1434 1810 if (maybe_run_task(&tasks[opts->tasks[i]], r, opts, cfg,
1435 - TASK_PHASE_FOREGROUND, &auto_gc_hook_result))
1811 + TASK_PHASE_FOREGROUND))
1436 1812 result = 1;
1437 1813
1438 1814 /* Failure to daemonize is ok, we'll continue in foreground. */
@@ -1444,7 +1820,7 @@ static int maintenance_run_tasks(struct maintenance_run_opts *opts,
1444 1820
1445 1821 for (size_t i = 0; i < opts->tasks_nr; i++)
1446 1822 if (maybe_run_task(&tasks[opts->tasks[i]], r, opts, cfg,
1447 - TASK_PHASE_BACKGROUND, &auto_gc_hook_result))
1823 + TASK_PHASE_BACKGROUND))
1448 1824 result = 1;
1449 1825
1450 1826 rollback_lock_file(&lk);
modified builtin/grep.c
@@ -25,14 +25,12 @@
25 25 #include "setup.h"
26 26 #include "submodule.h"
27 27 #include "submodule-config.h"
28 + #include "object-file.h"
28 29 #include "object-name.h"
29 30 #include "odb.h"
30 - #include "odb/source.h"
31 - #include "oid-array.h"
32 - #include "oidset.h"
31 + #include "packfile.h"
33 32 #include "pager.h"
34 33 #include "path.h"
35 - #include "promisor-remote.h"
36 34 #include "read-cache-ll.h"
37 35 #include "write-or-die.h"
38 36
@@ -519,7 +517,7 @@ static int grep_submodule(struct grep_opt *opt,
519 517 enum object_type object_type;
520 518 struct tree_desc tree;
521 519 void *data;
522 - size_t size;
520 + unsigned long size;
523 521 struct strbuf base = STRBUF_INIT;
524 522
525 523 obj_read_lock();
@@ -572,7 +570,7 @@ static int grep_cache(struct grep_opt *opt,
572 570 enum object_type type;
573 571 struct tree_desc tree;
574 572 void *data;
575 - size_t size;
573 + unsigned long size;
576 574
577 575 data = odb_read_object(the_repository->objects, &ce->oid,
578 576 &type, &size);
@@ -665,7 +663,7 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
665 663 enum object_type type;
666 664 struct tree_desc sub;
667 665 void *data;
668 - size_t size;
666 + unsigned long size;
669 667
670 668 data = odb_read_object(the_repository->objects,
671 669 &entry.oid, &type, &size);
@@ -694,144 +692,6 @@ static int grep_tree(struct grep_opt *opt, const struct pathspec *pathspec,
694 692 return hit;
695 693 }
696 694
697 - static void collect_blob_oids_for_tree(struct repository *repo,
698 - const struct pathspec *pathspec,
699 - struct tree_desc *tree,
700 - struct strbuf *base,
701 - int tn_len,
702 - struct oidset *blob_oids)
703 - {
704 - struct name_entry entry;
705 - int old_baselen = base->len;
706 - struct strbuf name = STRBUF_INIT;
707 - enum interesting match = entry_not_interesting;
708 -
709 - while (tree_entry(tree, &entry)) {
710 - if (match != all_entries_interesting) {
711 - strbuf_addstr(&name, base->buf + tn_len);
712 - match = tree_entry_interesting(repo->index,
713 - &entry, &name,
714 - pathspec);
715 - strbuf_reset(&name);
716 -
717 - if (match == all_entries_not_interesting)
718 - break;
719 - if (match == entry_not_interesting)
720 - continue;
721 - }
722 -
723 - strbuf_add(base, entry.path, tree_entry_len(&entry));
724 -
725 - if (S_ISREG(entry.mode)) {
726 - if (!odb_has_object(repo->objects, &entry.oid, 0))
727 - oidset_insert(blob_oids, &entry.oid);
728 - } else if (S_ISDIR(entry.mode)) {
729 - enum object_type type;
730 - struct tree_desc sub_tree;
731 - void *data;
732 - size_t size;
733 -
734 - data = odb_read_object(repo->objects, &entry.oid,
735 - &type, &size);
736 - if (!data)
737 - die(_("unable to read tree (%s)"),
738 - oid_to_hex(&entry.oid));
739 -
740 - strbuf_addch(base, '/');
741 - init_tree_desc(&sub_tree, &entry.oid, data, size);
742 - collect_blob_oids_for_tree(repo, pathspec, &sub_tree,
743 - base, tn_len, blob_oids);
744 - free(data);
745 - }
746 - /*
747 - * ...no else clause for S_ISGITLINK: submodules have their
748 - * own promisor configuration and would need separate fetches
749 - * anyway.
750 - */
751 -
752 - strbuf_setlen(base, old_baselen);
753 - }
754 -
755 - strbuf_release(&name);
756 - }
757 -
758 - static void collect_blob_oids_for_treeish(struct grep_opt *opt,
759 - const struct pathspec *pathspec,
760 - const struct object_id *tree_ish_oid,
761 - const char *name,
762 - struct oidset *blob_oids)
763 - {
764 - struct tree_desc tree;
765 - void *data;
766 - size_t size;
767 - struct strbuf base = STRBUF_INIT;
768 - int len;
769 -
770 - data = odb_read_object_peeled(opt->repo->objects, tree_ish_oid,
771 - OBJ_TREE, &size, NULL);
772 -
773 - if (!data)
774 - return;
775 -
776 - len = name ? strlen(name) : 0;
777 - if (len) {
778 - strbuf_add(&base, name, len);
779 - strbuf_addch(&base, ':');
780 - }
781 - init_tree_desc(&tree, tree_ish_oid, data, size);
782 -
783 - collect_blob_oids_for_tree(opt->repo, pathspec, &tree,
784 - &base, base.len, blob_oids);
785 -
786 - strbuf_release(&base);
787 - free(data);
788 - }
789 -
790 - static void prefetch_grep_blobs(struct grep_opt *opt,
791 - const struct pathspec *pathspec,
792 - const struct object_array *list)
793 - {
794 - struct oidset blob_oids = OIDSET_INIT;
795 -
796 - /* Exit if we're not in a partial clone */
797 - if (!repo_has_promisor_remote(opt->repo))
798 - return;
799 -
800 - /* For each tree, gather the blobs in it */
801 - for (int i = 0; i < list->nr; i++) {
802 - struct object *real_obj;
803 -
804 - obj_read_lock();
805 - real_obj = deref_tag(opt->repo, list->objects[i].item,
806 - NULL, 0);
807 - obj_read_unlock();
808 -
809 - if (real_obj &&
810 - (real_obj->type == OBJ_COMMIT ||
811 - real_obj->type == OBJ_TREE))
812 - collect_blob_oids_for_treeish(opt, pathspec,
813 - &real_obj->oid,
814 - list->objects[i].name,
815 - &blob_oids);
816 - }
817 -
818 - /* Prefetch the blobs we found */
819 - if (oidset_size(&blob_oids)) {
820 - struct oid_array to_fetch = OID_ARRAY_INIT;
821 - struct oidset_iter iter;
822 - const struct object_id *oid;
823 -
824 - oidset_iter_init(&blob_oids, &iter);
825 - while ((oid = oidset_iter_next(&iter)))
826 - oid_array_append(&to_fetch, oid);
827 -
828 - promisor_remote_get_direct(opt->repo, to_fetch.oid, to_fetch.nr);
829 -
830 - oid_array_clear(&to_fetch);
831 - }
832 - oidset_clear(&blob_oids);
833 - }
834 -
835 695 static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
836 696 struct object *obj, const char *name, const char *path)
837 697 {
@@ -840,7 +700,7 @@ static int grep_object(struct grep_opt *opt, const struct pathspec *pathspec,
840 700 if (obj->type == OBJ_COMMIT || obj->type == OBJ_TREE) {
841 701 struct tree_desc tree;
842 702 void *data;
843 - size_t size;
703 + unsigned long size;
844 704 struct strbuf base;
845 705 int hit, len;
846 706
@@ -872,8 +732,6 @@ static int grep_objects(struct grep_opt *opt, const struct pathspec *pathspec,
872 732 int hit = 0;
873 733 const unsigned int nr = list->nr;
874 734
875 - prefetch_grep_blobs(opt, pathspec, list);
876 -
877 735 for (i = 0; i < nr; i++) {
878 736 struct object *real_obj;
879 737
@@ -1206,7 +1064,7 @@ int cmd_grep(int argc,
1206 1064 use_index = 0;
1207 1065 else
1208 1066 /* die the same way as if we did it at the beginning */
1209 - setup_git_directory(the_repository);
1067 + setup_git_directory();
1210 1068 }
1211 1069 /* Ignore --recurse-submodules if --no-index is given or implied */
1212 1070 if (!use_index)
@@ -1293,7 +1151,7 @@ int cmd_grep(int argc,
1293 1151
1294 1152 object = parse_object_or_die(the_repository, &oid, arg);
1295 1153 if (!seen_dashdash)
1296 - verify_non_filename(the_repository, prefix, arg);
1154 + verify_non_filename(prefix, arg);
1297 1155 add_object_array_with_path(object, arg, &list, oc.mode, oc.path);
1298 1156 object_context_release(&oc);
1299 1157 }
@@ -1305,7 +1163,7 @@ int cmd_grep(int argc,
1305 1163 if (!seen_dashdash) {
1306 1164 int j;
1307 1165 for (j = i; j < argc; j++)
1308 - verify_filename(the_repository, prefix, argv[j], j == i && allow_revs);
1166 + verify_filename(prefix, argv[j], j == i && allow_revs);
1309 1167 }
1310 1168
1311 1169 parse_pathspec(&pathspec, 0,
@@ -1356,8 +1214,15 @@ int cmd_grep(int argc,
1356 1214 if (recurse_submodules)
1357 1215 repo_read_gitmodules(the_repository, 1);
1358 1216
1359 - if (startup_info->have_repository)
1360 - odb_prepare(the_repository->objects, 0);
1217 + if (startup_info->have_repository) {
1218 + struct odb_source *source;
1219 +
1220 + odb_prepare_alternates(the_repository->objects);
1221 + for (source = the_repository->objects->sources; source; source = source->next) {
1222 + struct odb_source_files *files = odb_source_files_downcast(source);
1223 + packfile_store_prepare(files->packed);
1224 + }
1225 + }
1361 1226
1362 1227 start_threads(&opt);
1363 1228 } else {
@@ -1407,7 +1272,7 @@ int cmd_grep(int argc,
1407 1272 die(_("--[no-]exclude-standard cannot be used for tracked contents"));
1408 1273 } else if (!list.nr) {
1409 1274 if (!cached)
1410 - setup_work_tree(the_repository);
1275 + setup_work_tree();
1411 1276
1412 1277 hit = grep_cache(&opt, &pathspec, cached);
1413 1278 } else {
modified builtin/hash-object.c
@@ -100,9 +100,9 @@ int cmd_hash_object(int argc,
100 100 hash_object_usage, 0);
101 101
102 102 if (flags & INDEX_WRITE_OBJECT)
103 - prefix = setup_git_directory(the_repository);
103 + prefix = setup_git_directory();
104 104 else
105 - prefix = setup_git_directory_gently(the_repository, &nongit);
105 + prefix = setup_git_directory_gently(&nongit);
106 106
107 107 if (nongit && !the_hash_algo)
108 108 repo_set_hash_algo(the_repository, GIT_HASH_DEFAULT);
modified builtin/help.c
@@ -740,7 +740,7 @@ int cmd_help(int argc,
740 740 return 0;
741 741 }
742 742
743 - setup_git_directory_gently(the_repository, &nongit);
743 + setup_git_directory_gently(&nongit);
744 744 repo_config(the_repository, git_help_config, NULL);
745 745
746 746 if (parsed_help_format != HELP_FORMAT_NONE)
modified builtin/history.c
@@ -10,26 +10,19 @@
10 10 #include "gettext.h"
11 11 #include "hex.h"
12 12 #include "lockfile.h"
13 - #include "merge-ort.h"
14 13 #include "oidmap.h"
15 14 #include "parse-options.h"
16 15 #include "path.h"
17 16 #include "read-cache.h"
18 17 #include "refs.h"
19 18 #include "replay.h"
20 - #include "reset.h"
21 19 #include "revision.h"
22 20 #include "sequencer.h"
23 21 #include "strvec.h"
24 22 #include "tree.h"
25 - #include "tree-walk.h"
26 23 #include "unpack-trees.h"
27 24 #include "wt-status.h"
28 25
29 - #define GIT_HISTORY_DROP_USAGE \
30 - N_("git history drop <commit> [--dry-run] [--update-refs=(branches|head)] [--empty=(drop|keep|abort)]")
31 - #define GIT_HISTORY_FIXUP_USAGE \
32 - N_("git history fixup <commit> [--dry-run] [--update-refs=(branches|head)] [--reedit-message] [--empty=(drop|keep|abort)]")
33 26 #define GIT_HISTORY_REWORD_USAGE \
34 27 N_("git history reword <commit> [--dry-run] [--update-refs=(branches|head)]")
35 28 #define GIT_HISTORY_SPLIT_USAGE \
@@ -56,6 +49,11 @@ static int fill_commit_message(struct repository *repo,
56 49 " empty message aborts the commit.\n");
57 50 struct wt_status s;
58 51
52 + strbuf_addstr(out, default_message);
53 + strbuf_addch(out, '\n');
54 + strbuf_commented_addf(out, comment_line_str, hint, action, comment_line_str);
55 + write_file_buf(path, out->buf, out->len);
56 +
59 57 wt_status_prepare(repo, &s);
60 58 FREE_AND_NULL(s.branch);
61 59 s.ahead_behind_flags = AHEAD_BEHIND_QUICK;
@@ -67,22 +65,14 @@ static int fill_commit_message(struct repository *repo,
67 65 s.whence = FROM_COMMIT;
68 66 s.committable = 1;
69 67
70 - s.fp = fopen(path, "w");
68 + s.fp = fopen(git_path_commit_editmsg(), "a");
71 69 if (!s.fp)
72 - return error_errno(_("could not open '%s'"), path);
73 -
74 - strbuf_addstr(out, default_message);
75 - strbuf_addch(out, '\n');
76 - strbuf_commented_addf(out, comment_line_str, hint, action, comment_line_str);
77 - if (fwrite(out->buf, 1, out->len, s.fp) != out->len)
78 - die_errno(_("could not write to '%s'"), path);
70 + return error_errno(_("could not open '%s'"), git_path_commit_editmsg());
79 71
80 72 wt_status_collect_changes_trees(&s, old_tree, new_tree);
81 73 wt_status_print(&s);
82 74 wt_status_collect_free_buffers(&s);
83 75 string_list_clear_func(&s.change, change_data_free);
84 - if (fclose(s.fp))
85 - die_errno(_("could not write to '%s'"), path);
86 76
87 77 strbuf_reset(out);
88 78 if (launch_editor(path, out, NULL)) {
@@ -101,18 +91,13 @@ static int fill_commit_message(struct repository *repo,
101 91 return 0;
102 92 }
103 93
104 - enum commit_tree_flags {
105 - COMMIT_TREE_EDIT_MESSAGE = (1 << 0),
106 - };
107 -
108 - static int commit_tree_ext(struct repository *repo,
109 - const char *action,
110 - struct commit *commit_with_message,
111 - const struct commit_list *parents,
112 - const struct object_id *old_tree,
113 - const struct object_id *new_tree,
114 - struct commit **out,
115 - enum commit_tree_flags flags)
94 + static int commit_tree_with_edited_message_ext(struct repository *repo,
95 + const char *action,
96 + struct commit *commit_with_message,
97 + const struct commit_list *parents,
98 + const struct object_id *old_tree,
99 + const struct object_id *new_tree,
100 + struct commit **out)
116 101 {
117 102 const char *exclude_gpgsig[] = {
118 103 /* We reencode the message, so the encoding needs to be stripped. */
@@ -137,14 +122,10 @@ static int commit_tree_ext(struct repository *repo,
137 122 original_author = xmemdupz(ptr, len);
138 123 find_commit_subject(original_message, &original_body);
139 124
140 - if (flags & COMMIT_TREE_EDIT_MESSAGE) {
141 - ret = fill_commit_message(repo, old_tree, new_tree,
142 - original_body, action, &commit_message);
143 - if (ret < 0)
144 - goto out;
145 - } else {
146 - strbuf_addstr(&commit_message, original_body);
147 - }
125 + ret = fill_commit_message(repo, old_tree, new_tree,
126 + original_body, action, &commit_message);
127 + if (ret < 0)
128 + goto out;
148 129
149 130 original_extra_headers = read_commit_extra_headers(commit_with_message,
150 131 exclude_gpgsig);
@@ -187,8 +168,8 @@ static int commit_tree_with_edited_message(struct repository *repo,
187 168 oidcpy(&parent_tree_oid, repo->hash_algo->empty_tree);
188 169 }
189 170
190 - return commit_tree_ext(repo, action, original, original->parents,
191 - &parent_tree_oid, tree_oid, out, COMMIT_TREE_EDIT_MESSAGE);
171 + return commit_tree_with_edited_message_ext(repo, action, original, original->parents,
172 + &parent_tree_oid, tree_oid, out);
192 173 }
193 174
194 175 enum ref_action {
@@ -291,7 +272,7 @@ static int setup_revwalk(struct repository *repo,
291 272
292 273 commit_list_insert(original, &from_list);
293 274 ret = repo_is_descendant_of(repo, head, from_list);
294 - commit_list_free(from_list);
275 + free_commit_list(from_list);
295 276
296 277 if (ret < 0) {
297 278 ret = error(_("cannot determine descendance"));
@@ -340,17 +321,18 @@ static int handle_ref_update(struct ref_transaction *transaction,
340 321 NULL, NULL, 0, reflog_msg, err);
341 322 }
342 323
343 - static int compute_pending_ref_updates(struct rev_info *revs,
344 - enum ref_action action,
345 - struct commit *original,
346 - struct commit *rewritten,
347 - enum replay_empty_commit_action empty,
348 - struct replay_result *result)
324 + static int handle_reference_updates(struct rev_info *revs,
325 + enum ref_action action,
326 + struct commit *original,
327 + struct commit *rewritten,
328 + const char *reflog_msg,
329 + int dry_run)
349 330 {
350 331 const struct name_decoration *decoration;
351 - struct replay_revisions_options opts = {
352 - .empty = empty,
353 - };
332 + struct replay_revisions_options opts = { 0 };
333 + struct replay_result result = { 0 };
334 + struct ref_transaction *transaction = NULL;
335 + struct strbuf err = STRBUF_INIT;
354 336 char hex[GIT_MAX_HEXSZ + 1];
355 337 bool detached_head;
356 338 int head_flags = 0;
@@ -362,13 +344,34 @@ static int compute_pending_ref_updates(struct rev_info *revs,
362 344
363 345 opts.onto = oid_to_hex_r(hex, &rewritten->object.oid);
364 346
365 - ret = replay_revisions(revs, &opts, result);
347 + ret = replay_revisions(revs, &opts, &result);
366 348 if (ret)
367 - return ret;
349 + goto out;
368 350
369 351 if (action != REF_ACTION_BRANCHES && action != REF_ACTION_HEAD)
370 352 BUG("unsupported ref action %d", action);
371 353
354 + if (!dry_run) {
355 + transaction = ref_store_transaction_begin(get_main_ref_store(revs->repo), 0, &err);
356 + if (!transaction) {
357 + ret = error(_("failed to begin ref transaction: %s"), err.buf);
358 + goto out;
359 + }
360 + }
361 +
362 + for (size_t i = 0; i < result.updates_nr; i++) {
363 + ret = handle_ref_update(transaction,
364 + result.updates[i].refname,
365 + &result.updates[i].new_oid,
366 + &result.updates[i].old_oid,
367 + reflog_msg, &err);
368 + if (ret) {
369 + ret = error(_("failed to update ref '%s': %s"),
370 + result.updates[i].refname, err.buf);
371 + goto out;
372 + }
373 + }
374 +
372 375 /*
373 376 * `replay_revisions()` only updates references that are
374 377 * ancestors of `rewritten`, so we need to manually
@@ -396,41 +399,14 @@ static int compute_pending_ref_updates(struct rev_info *revs,
396 399 !detached_head)
397 400 continue;
398 401
399 - replay_result_queue_update(result, decoration->name,
400 - &original->object.oid,
401 - &rewritten->object.oid);
402 - }
403 -
404 - return 0;
405 - }
406 -
407 - static int apply_pending_ref_updates(struct repository *repo,
408 - const struct replay_result *result,
409 - const char *reflog_msg,
410 - int dry_run)
411 - {
412 - struct ref_transaction *transaction = NULL;
413 - struct strbuf err = STRBUF_INIT;
414 - int ret;
415 -
416 - if (!dry_run) {
417 - transaction = ref_store_transaction_begin(get_main_ref_store(repo),
418 - 0, &err);
419 - if (!transaction) {
420 - ret = error(_("failed to begin ref transaction: %s"), err.buf);
421 - goto out;
422 - }
423 - }
424 -
425 - for (size_t i = 0; i < result->updates_nr; i++) {
426 402 ret = handle_ref_update(transaction,
427 - result->updates[i].refname,
428 - &result->updates[i].new_oid,
429 - &result->updates[i].old_oid,
403 + decoration->name,
404 + &rewritten->object.oid,
405 + &original->object.oid,
430 406 reflog_msg, &err);
431 407 if (ret) {
432 408 ret = error(_("failed to update ref '%s': %s"),
433 - result->updates[i].refname, err.buf);
409 + decoration->name, err.buf);
434 410 goto out;
435 411 }
436 412 }
@@ -444,260 +420,8 @@ static int apply_pending_ref_updates(struct repository *repo,
444 420
445 421 out:
446 422 ref_transaction_free(transaction);
447 - strbuf_release(&err);
448 - return ret;
449 - }
450 -
451 - static int handle_reference_updates(struct rev_info *revs,
452 - enum ref_action action,
453 - struct commit *original,
454 - struct commit *rewritten,
455 - const char *reflog_msg,
456 - int dry_run,
457 - enum replay_empty_commit_action empty)
458 - {
459 - struct replay_result result = { 0 };
460 - int ret;
461 -
462 - ret = compute_pending_ref_updates(revs, action, original, rewritten,
463 - empty, &result);
464 - if (ret)
465 - goto out;
466 -
467 - ret = apply_pending_ref_updates(revs->repo, &result, reflog_msg, dry_run);
468 -
469 - out:
470 423 replay_result_release(&result);
471 - return ret;
472 - }
473 -
474 - static int commit_became_empty(struct repository *repo,
475 - struct commit *original,
476 - struct tree *result)
477 - {
478 - struct commit *parent = original->parents ? original->parents->item : NULL;
479 - struct object_id parent_tree_oid;
480 -
481 - if (parent) {
482 - if (repo_parse_commit(repo, parent))
483 - return error(_("unable to parse parent of %s"),
484 - oid_to_hex(&original->object.oid));
485 -
486 - parent_tree_oid = repo_get_commit_tree(repo, parent)->object.oid;
487 - } else {
488 - oidcpy(&parent_tree_oid, repo->hash_algo->empty_tree);
489 - }
490 -
491 - return oideq(&result->object.oid, &parent_tree_oid);
492 - }
493 -
494 - static int parse_opt_empty(const struct option *opt, const char *arg, int unset)
495 - {
496 - enum replay_empty_commit_action *value = opt->value;
497 -
498 - BUG_ON_OPT_NEG(unset);
499 -
500 - if (!strcmp(arg, "drop"))
501 - *value = REPLAY_EMPTY_COMMIT_DROP;
502 - else if (!strcmp(arg, "keep"))
503 - *value = REPLAY_EMPTY_COMMIT_KEEP;
504 - else if (!strcmp(arg, "abort"))
505 - *value = REPLAY_EMPTY_COMMIT_ABORT;
506 - else
507 - die(_("unrecognized '--empty=' action '%s'; "
508 - "valid values are \"drop\", \"keep\", and \"abort\"."), arg);
509 -
510 - return 0;
511 - }
512 -
513 - static int cmd_history_fixup(int argc,
514 - const char **argv,
515 - const char *prefix,
516 - struct repository *repo)
517 - {
518 - const char * const usage[] = {
519 - GIT_HISTORY_FIXUP_USAGE,
520 - NULL,
521 - };
522 - enum replay_empty_commit_action empty = REPLAY_EMPTY_COMMIT_DROP;
523 - enum ref_action action = REF_ACTION_DEFAULT;
524 - enum commit_tree_flags flags = 0;
525 - int dry_run = 0;
526 - struct option options[] = {
527 - OPT_CALLBACK_F(0, "update-refs", &action, "(branches|head)",
528 - N_("control which refs should be updated"),
529 - PARSE_OPT_NONEG, parse_ref_action),
530 - OPT_BOOL('n', "dry-run", &dry_run,
531 - N_("perform a dry-run without updating any refs")),
532 - OPT_BIT(0, "reedit-message", &flags,
533 - N_("open an editor to modify the commit message"),
534 - COMMIT_TREE_EDIT_MESSAGE),
535 - OPT_CALLBACK_F(0, "empty", &empty, "(drop|keep|abort)",
536 - N_("how to handle commits that become empty"),
537 - PARSE_OPT_NONEG, parse_opt_empty),
538 - OPT_END(),
539 - };
540 - struct merge_result merge_result = { 0 };
541 - struct merge_options merge_opts = { 0 };
542 - struct strbuf reflog_msg = STRBUF_INIT;
543 - struct commit *head_commit, *original, *rewritten;
544 - struct tree *head_tree, *original_tree, *index_tree;
545 - struct rev_info revs = { 0 };
546 - bool skip_commit = false;
547 - int ret;
548 -
549 - argc = parse_options(argc, argv, prefix, options, usage, 0);
550 - if (argc != 1) {
551 - ret = error(_("command expects a single revision"));
552 - goto out;
553 - }
554 - repo_config(repo, git_default_config, NULL);
555 -
556 - if (action == REF_ACTION_DEFAULT)
557 - action = REF_ACTION_BRANCHES;
558 -
559 - if (is_bare_repository(repo)) {
560 - ret = error(_("cannot run fixup in a bare repository"));
561 - goto out;
562 - }
563 -
564 - /* Resolve the original commit, which is the one we want to fix up. */
565 - original = lookup_commit_reference_by_name(argv[0]);
566 - if (!original) {
567 - ret = error(_("commit cannot be found: %s"), argv[0]);
568 - goto out;
569 - }
570 -
571 - /*
572 - * Resolve HEAD so we can use its tree as the merge base: the staged
573 - * changes are expressed as a diff from HEAD's tree to the index tree.
574 - */
575 - head_commit = lookup_commit_reference_by_name("HEAD");
576 - if (!head_commit) {
577 - ret = error(_("cannot look up HEAD"));
578 - goto out;
579 - }
580 -
581 - head_tree = repo_get_commit_tree(repo, head_commit);
582 - if (!head_tree) {
583 - ret = error(_("cannot get tree for HEAD"));
584 - goto out;
585 - }
586 -
587 - if (repo_read_index(repo) < 0) {
588 - ret = error(_("unable to read index"));
589 - goto out;
590 - }
591 -
592 - if (!repo_index_has_changes(repo, head_tree, NULL)) {
593 - ret = error(_("nothing to fixup: no staged changes"));
594 - goto out;
595 - }
596 -
597 - /*
598 - * Write the index as a tree object. This is the "theirs" side of the
599 - * three-way merge: it is HEAD's tree with the staged changes applied.
600 - */
601 - index_tree = write_in_core_index_as_tree(repo, repo->index);
602 - if (!index_tree) {
603 - ret = error(_("unable to write index as a tree"));
604 - goto out;
605 - }
606 -
607 - original_tree = repo_get_commit_tree(repo, original);
608 - if (!original_tree) {
609 - ret = error(_("cannot get tree for commit %s"), argv[0]);
610 - goto out;
611 - }
612 -
613 - /*
614 - * Perform the three-way merge to reapply changes in the index onto the
615 - * target commit. This is using basically the same logic as a
616 - * cherry-pick, where the base commit is our HEAD, ours is the original
617 - * tree and theirs is the index tree.
618 - */
619 - init_basic_merge_options(&merge_opts, repo);
620 - merge_opts.ancestor = "HEAD";
621 - merge_opts.branch1 = argv[0];
622 - merge_opts.branch2 = "staged";
623 - merge_incore_nonrecursive(&merge_opts, head_tree,
624 - original_tree, index_tree, &merge_result);
625 -
626 - if (merge_result.clean < 0) {
627 - ret = error(_("merge failed while applying fixup"));
628 - goto out;
629 - }
630 -
631 - if (!merge_result.clean) {
632 - ret = error(_("fixup would produce conflicts; aborting"));
633 - goto out;
634 - }
635 -
636 - ret = commit_became_empty(repo, original, merge_result.tree);
637 - if (ret < 0)
638 - goto out;
639 - if (ret > 0) {
640 - switch (empty) {
641 - case REPLAY_EMPTY_COMMIT_DROP:
642 - /*
643 - * Drop the target commit by replaying its descendants
644 - * directly onto its parent.
645 - */
646 - rewritten = original->parents ? original->parents->item : NULL;
647 -
648 - /*
649 - * TODO: we don't yet have the ability to drop root
650 - * commits, but there's ultimately no good reason for
651 - * this restriction to exist other than a technical
652 - * limitation.
653 - */
654 - if (!rewritten) {
655 - ret = error(_("cannot drop root commit %s: "
656 - "it has no parent to replay onto"),
657 - argv[0]);
658 - goto out;
659 - }
660 -
661 - skip_commit = true;
662 - break;
663 - case REPLAY_EMPTY_COMMIT_KEEP:
664 - /* Proceed and record the empty commit. */
665 - break;
666 - case REPLAY_EMPTY_COMMIT_ABORT:
667 - ret = error(_("fixup makes commit %s empty"), argv[0]);
668 - goto out;
669 - }
670 - }
671 -
672 - ret = setup_revwalk(repo, action, original, &revs);
673 - if (ret)
674 - goto out;
675 -
676 - if (!skip_commit) {
677 - ret = commit_tree_ext(repo, "fixup", original, original->parents,
678 - &original_tree->object.oid, &merge_result.tree->object.oid,
679 - &rewritten, flags);
680 - if (ret < 0) {
681 - ret = error(_("failed writing fixed-up commit"));
682 - goto out;
683 - }
684 - }
685 -
686 - strbuf_addf(&reflog_msg, "fixup: updating %s", argv[0]);
687 -
688 - ret = handle_reference_updates(&revs, action, original, rewritten,
689 - reflog_msg.buf, dry_run, empty);
690 - if (ret < 0) {
691 - ret = error(_("failed replaying descendants"));
692 - goto out;
693 - }
694 -
695 - ret = 0;
696 -
697 - out:
698 - merge_finalize(&merge_opts, &merge_result);
699 - strbuf_release(&reflog_msg);
700 - release_revisions(&revs);
424 + strbuf_release(&err);
701 425 return ret;
702 426 }
703 427
@@ -754,7 +478,7 @@ static int cmd_history_reword(int argc,
754 478 strbuf_addf(&reflog_msg, "reword: updating %s", argv[0]);
755 479
756 480 ret = handle_reference_updates(&revs, action, original, rewritten,
757 - reflog_msg.buf, dry_run, REPLAY_EMPTY_COMMIT_ABORT);
481 + reflog_msg.buf, dry_run);
758 482 if (ret < 0) {
759 483 ret = error(_("failed replaying descendants"));
760 484 goto out;
@@ -795,7 +519,7 @@ static int write_ondisk_index(struct repository *repo,
795 519
796 520 prime_cache_tree(repo, &index, tree);
797 521
798 - if (repo_hold_lock_file_for_update(repo, &lock, path, 0) < 0) {
522 + if (hold_lock_file_for_update(&lock, path, 0) < 0) {
799 523 ret = error_errno(_("unable to acquire index lock"));
800 524 goto out;
801 525 }
@@ -892,8 +616,9 @@ static int split_commit(struct repository *repo,
892 616 * The first commit is constructed from the split-out tree. The base
893 617 * that shall be diffed against is the parent of the original commit.
894 618 */
895 - ret = commit_tree_ext(repo, "split-out", original, original->parents, &parent_tree_oid,
896 - &split_tree->object.oid, &first_commit, COMMIT_TREE_EDIT_MESSAGE);
619 + ret = commit_tree_with_edited_message_ext(repo, "split-out", original,
620 + original->parents, &parent_tree_oid,
621 + &split_tree->object.oid, &first_commit);
897 622 if (ret < 0) {
898 623 ret = error(_("failed writing first commit"));
899 624 goto out;
@@ -909,8 +634,9 @@ static int split_commit(struct repository *repo,
909 634 old_tree_oid = &repo_get_commit_tree(repo, first_commit)->object.oid;
910 635 new_tree_oid = &repo_get_commit_tree(repo, original)->object.oid;
911 636
912 - ret = commit_tree_ext(repo, "split-out", original, parents, old_tree_oid,
913 - new_tree_oid, &second_commit, COMMIT_TREE_EDIT_MESSAGE);
637 + ret = commit_tree_with_edited_message_ext(repo, "split-out", original,
638 + parents, old_tree_oid,
639 + new_tree_oid, &second_commit);
914 640 if (ret < 0) {
915 641 ret = error(_("failed writing second commit"));
916 642 goto out;
@@ -923,7 +649,7 @@ out:
923 649 if (index_file.len)
924 650 unlink(index_file.buf);
925 651 strbuf_release(&index_file);
926 - commit_list_free(parents);
652 + free_commit_list(parents);
927 653 release_index(&index);
928 654 return ret;
929 655 }
@@ -991,7 +717,7 @@ static int cmd_history_split(int argc,
991 717 strbuf_addf(&reflog_msg, "split: updating %s", argv[0]);
992 718
993 719 ret = handle_reference_updates(&revs, action, original, rewritten,
994 - reflog_msg.buf, dry_run, REPLAY_EMPTY_COMMIT_ABORT);
720 + reflog_msg.buf, dry_run);
995 721 if (ret < 0) {
996 722 ret = error(_("failed replaying descendants"));
997 723 goto out;
@@ -1006,200 +732,18 @@ out:
1006 732 return ret;
1007 733 }
1008 734
1009 - static int update_worktree(struct repository *repo,
1010 - const struct commit *old_head,
1011 - const struct commit *new_head,
1012 - bool dry_run)
1013 - {
1014 - struct reset_working_tree_options opts = {
1015 - .oid_from = &old_head->object.oid,
1016 - .oid = &new_head->object.oid,
1017 - };
1018 - if (dry_run)
1019 - opts.flags |= RESET_WORKING_TREE_DRY_RUN;
1020 - return reset_working_tree(repo, &opts);
1021 - }
1022 -
1023 - static int find_head_tree_change(struct repository *repo,
1024 - const struct replay_result *result,
1025 - struct commit **old_head,
1026 - struct commit **new_head,
1027 - bool *changed)
1028 - {
1029 - const struct replay_ref_update *head_update = NULL;
1030 - struct commit *old_head_commit, *new_head_commit;
1031 - struct tree *old_head_tree, *new_head_tree;
1032 - const char *head_target;
1033 - int head_flags;
1034 -
1035 - *changed = false;
1036 -
1037 - head_target = refs_resolve_ref_unsafe(get_main_ref_store(repo), "HEAD",
1038 - RESOLVE_REF_NO_RECURSE | RESOLVE_REF_READING,
1039 - NULL, &head_flags);
1040 - if (!head_target)
1041 - return error(_("cannot look up HEAD"));
1042 -
1043 - for (size_t i = 0; i < result->updates_nr; i++) {
1044 - if (!strcmp(result->updates[i].refname, head_target)) {
1045 - head_update = &result->updates[i];
1046 - break;
1047 - }
1048 - }
1049 -
1050 - if (!head_update)
1051 - return 0;
1052 -
1053 - old_head_commit = lookup_commit_reference(repo, &head_update->old_oid);
1054 - new_head_commit = lookup_commit_reference(repo, &head_update->new_oid);
1055 - if (!old_head_commit || !new_head_commit)
1056 - return error(_("cannot resolve HEAD commit"));
1057 -
1058 - old_head_tree = repo_get_commit_tree(repo, old_head_commit);
1059 - new_head_tree = repo_get_commit_tree(repo, new_head_commit);
1060 - if (!old_head_tree || !new_head_tree)
1061 - return error(_("cannot resolve tree for HEAD"));
1062 -
1063 - if (oideq(&old_head_tree->object.oid, &new_head_tree->object.oid))
1064 - return 0;
1065 -
1066 - *old_head = old_head_commit;
1067 - *new_head = new_head_commit;
1068 - *changed = true;
1069 -
1070 - return 0;
1071 - }
1072 -
1073 - static int cmd_history_drop(int argc,
1074 - const char **argv,
1075 - const char *prefix,
1076 - struct repository *repo)
1077 - {
1078 - const char * const usage[] = {
1079 - GIT_HISTORY_DROP_USAGE,
1080 - NULL,
1081 - };
1082 - enum replay_empty_commit_action empty = REPLAY_EMPTY_COMMIT_DROP;
1083 - enum ref_action action = REF_ACTION_DEFAULT;
1084 - int dry_run = 0;
1085 - struct option options[] = {
1086 - OPT_CALLBACK_F(0, "update-refs", &action, "(branches|head)",
1087 - N_("control which refs should be updated"),
1088 - PARSE_OPT_NONEG, parse_ref_action),
1089 - OPT_BOOL('n', "dry-run", &dry_run,
1090 - N_("perform a dry-run without updating any refs")),
1091 - OPT_CALLBACK_F(0, "empty", &empty, "(drop|keep|abort)",
1092 - N_("how to handle descendants that become empty"),
1093 - PARSE_OPT_NONEG, parse_opt_empty),
1094 - OPT_END(),
1095 - };
1096 - struct strbuf reflog_msg = STRBUF_INIT;
1097 - struct commit *original, *rewritten;
1098 - struct rev_info revs = { 0 };
1099 - struct replay_result result = { 0 };
1100 - struct commit *old_head, *new_head;
1101 - bool head_moves = false;
1102 - int ret;
1103 -
1104 - argc = parse_options(argc, argv, prefix, options, usage, 0);
1105 - if (argc != 1) {
1106 - ret = error(_("command expects a single revision"));
1107 - goto out;
1108 - }
1109 - repo_config(repo, git_default_config, NULL);
1110 -
1111 - if (action == REF_ACTION_DEFAULT)
1112 - action = REF_ACTION_BRANCHES;
1113 -
1114 - original = lookup_commit_reference_by_name(argv[0]);
1115 - if (!original) {
1116 - ret = error(_("commit cannot be found: %s"), argv[0]);
1117 - goto out;
1118 - }
1119 -
1120 - if (!original->parents) {
1121 - ret = error(_("cannot drop root commit %s: "
1122 - "it has no parent to replay onto"),
1123 - argv[0]);
1124 - goto out;
1125 - } else if (original->parents->next) {
1126 - ret = error(_("cannot drop merge commit: %s"), argv[0]);
1127 - goto out;
1128 - }
1129 -
1130 - ret = setup_revwalk(repo, action, original, &revs);
1131 - if (ret)
1132 - goto out;
1133 -
1134 - rewritten = original->parents->item;
1135 -
1136 - ret = compute_pending_ref_updates(&revs, action, original, rewritten,
1137 - empty, &result);
1138 - if (ret) {
1139 - ret = error(_("failed replaying descendants"));
1140 - goto out;
1141 - }
1142 -
1143 - /*
1144 - * If HEAD will move as a result of the rewrite then we'll have to
1145 - * merge in the changes into the worktree and index. This merge can of
1146 - * course conflict, which will cause the whole operation to abort.
1147 - *
1148 - * If we had already updated the refs at that point then we'd have an
1149 - * inconsistent repository state. So we first perform a dry-run merge
1150 - * here before updating refs.
1151 - */
1152 - if (!is_bare_repository(repo)) {
1153 - ret = find_head_tree_change(repo, &result, &old_head,
1154 - &new_head, &head_moves);
1155 - if (ret < 0)
1156 - goto out;
1157 -
1158 - if (head_moves && update_worktree(repo, old_head, new_head, true) < 0) {
1159 - ret = error(_("dropping this commit would "
1160 - "overwrite local changes; aborting"));
1161 - goto out;
1162 - }
1163 - }
1164 -
1165 - strbuf_addf(&reflog_msg, "drop: dropping %s", argv[0]);
1166 - ret = apply_pending_ref_updates(repo, &result, reflog_msg.buf, dry_run);
1167 - if (ret < 0) {
1168 - ret = error(_("failed to update references"));
1169 - goto out;
1170 - }
1171 -
1172 - if (!dry_run && head_moves && update_worktree(repo, old_head, new_head, false) < 0) {
1173 - ret = error(_("could not update working tree to new commit %s"),
1174 - oid_to_hex(&new_head->object.oid));
1175 - goto out;
1176 - }
1177 -
1178 - ret = 0;
1179 -
1180 - out:
1181 - replay_result_release(&result);
1182 - strbuf_release(&reflog_msg);
1183 - release_revisions(&revs);
1184 - return ret;
1185 - }
1186 -
1187 735 int cmd_history(int argc,
1188 736 const char **argv,
1189 737 const char *prefix,
1190 738 struct repository *repo)
1191 739 {
1192 740 const char * const usage[] = {
1193 - GIT_HISTORY_DROP_USAGE,
1194 - GIT_HISTORY_FIXUP_USAGE,
1195 741 GIT_HISTORY_REWORD_USAGE,
1196 742 GIT_HISTORY_SPLIT_USAGE,
1197 743 NULL,
1198 744 };
1199 745 parse_opt_subcommand_fn *fn = NULL;
1200 746 struct option options[] = {
1201 - OPT_SUBCOMMAND("drop", &fn, cmd_history_drop),
1202 - OPT_SUBCOMMAND("fixup", &fn, cmd_history_fixup),
1203 747 OPT_SUBCOMMAND("reword", &fn, cmd_history_reword),
1204 748 OPT_SUBCOMMAND("split", &fn, cmd_history_split),
1205 749 OPT_END(),
modified builtin/hook.c
@@ -4,15 +4,23 @@
4 4 #include "environment.h"
5 5 #include "gettext.h"
6 6 #include "hook.h"
7 + #include "hook-list.h"
7 8 #include "parse-options.h"
8 - #include "thread-utils.h"
9 9
10 10 #define BUILTIN_HOOK_RUN_USAGE \
11 - N_("git hook run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] [(-j|--jobs) <n>]\n" \
12 - "<hook-name> [-- <hook-args>]")
11 + N_("git hook run [--allow-unknown-hook-name] [--ignore-missing] [--to-stdin=<path>] <hook-name> [-- <hook-args>]")
13 12 #define BUILTIN_HOOK_LIST_USAGE \
14 13 N_("git hook list [--allow-unknown-hook-name] [-z] [--show-scope] <hook-name>")
15 14
15 + static int is_known_hook(const char *name)
16 + {
17 + const char **p;
18 + for (p = hook_name_list; *p; p++)
19 + if (!strcmp(*p, name))
20 + return 1;
21 + return 0;
22 + }
23 +
16 24 static const char * const builtin_hook_usage[] = {
17 25 BUILTIN_HOOK_RUN_USAGE,
18 26 BUILTIN_HOOK_LIST_USAGE,
@@ -88,22 +96,14 @@ static int list(int argc, const char **argv, const char *prefix,
88 96 const char *name = h->u.configured.friendly_name;
89 97 const char *scope = show_scope ?
90 98 config_scope_name(h->u.configured.scope) : NULL;
91 - /*
92 - * Show the most relevant disable reason. Event-level
93 - * takes precedence: if the whole event is off, that
94 - * is what the user needs to know. The per-hook
95 - * "disabled" surfaces once the event is re-enabled.
96 - */
97 - const char *disability =
98 - h->u.configured.event_disabled ? "event-disabled\t" :
99 - h->u.configured.disabled ? "disabled\t" :
100 - "";
101 99 if (scope)
102 - printf("%s\t%s%s%c", scope, disability, name,
103 - line_terminator);
100 + printf("%s\t%s%s%c", scope,
101 + h->u.configured.disabled ? "disabled\t" : "",
102 + name, line_terminator);
104 103 else
105 - printf("%s%s%c", disability, name,
106 - line_terminator);
104 + printf("%s%s%c",
105 + h->u.configured.disabled ? "disabled\t" : "",
106 + name, line_terminator);
107 107 break;
108 108 }
109 109 default:
@@ -124,7 +124,6 @@ static int run(int argc, const char **argv, const char *prefix,
124 124 struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
125 125 int ignore_missing = 0;
126 126 int allow_unknown = 0;
127 - int jobs = 0;
128 127 const char *hook_name;
129 128 struct option run_options[] = {
130 129 OPT_BOOL(0, "allow-unknown-hook-name", &allow_unknown,
@@ -133,8 +132,6 @@ static int run(int argc, const char **argv, const char *prefix,
133 132 N_("silently ignore missing requested <hook-name>")),
134 133 OPT_STRING(0, "to-stdin", &opt.path_to_stdin, N_("path"),
135 134 N_("file to read into hooks' stdin")),
136 - OPT_INTEGER('j', "jobs", &jobs,
137 - N_("run up to <n> hooks simultaneously (-1 for CPU count)")),
138 135 OPT_END(),
139 136 };
140 137 int ret;
@@ -143,15 +140,6 @@ static int run(int argc, const char **argv, const char *prefix,
143 140 builtin_hook_run_usage,
144 141 PARSE_OPT_KEEP_DASHDASH);
145 142
146 - if (jobs == -1)
147 - opt.jobs = online_cpus();
148 - else if (jobs < 0)
149 - die(_("invalid value for -j: %d"
150 - " (use -1 for CPU count or a"
151 - " positive integer)"), jobs);
152 - else
153 - opt.jobs = jobs;
154 -
155 143 if (!argc)
156 144 goto usage;
157 145
modified builtin/index-pack.c
@@ -37,7 +37,7 @@ static const char index_pack_usage[] =
37 37
38 38 struct object_entry {
39 39 struct pack_idx_entry idx;
40 - size_t size;
40 + unsigned long size;
41 41 unsigned char hdr_size;
42 42 signed char type;
43 43 signed char real_type;
@@ -71,7 +71,7 @@ struct base_data {
71 71 /* Not initialized by make_base(). */
72 72 struct list_head list;
73 73 void *data;
74 - size_t size;
74 + unsigned long size;
75 75 };
76 76
77 77 /*
@@ -145,7 +145,8 @@ static int check_self_contained_and_connected;
145 145
146 146 static struct progress *progress;
147 147
148 - static unsigned char input_buffer[DEFAULT_IO_BUFFER_SIZE];
148 + /* We always read in 4kB chunks. */
149 + static unsigned char input_buffer[4096];
149 150 static unsigned int input_offset, input_len;
150 151 static off_t consumed_bytes;
151 152 static off_t max_input_size;
@@ -258,7 +259,7 @@ static unsigned check_object(struct object *obj)
258 259 return 0;
259 260
260 261 if (!(obj->flags & FLAG_CHECKED)) {
261 - size_t size;
262 + unsigned long size;
262 263 int type = odb_read_object_info(the_repository->objects,
263 264 &obj->oid, &size);
264 265 if (type <= 0)
@@ -374,7 +375,7 @@ static const char *open_pack_file(const char *pack_name)
374 375 output_fd = -1;
375 376 nothread_data.pack_fd = input_fd;
376 377 }
377 - git_hash_init(&input_ctx, the_hash_algo);
378 + the_hash_algo->init_fn(&input_ctx);
378 379 return pack_name;
379 380 }
380 381
@@ -468,7 +469,7 @@ static int is_delta_type(enum object_type type)
468 469 return (type == OBJ_REF_DELTA || type == OBJ_OFS_DELTA);
469 470 }
470 471
471 - static void *unpack_entry_data(off_t offset, size_t size,
472 + static void *unpack_entry_data(off_t offset, unsigned long size,
472 473 enum object_type type, struct object_id *oid)
473 474 {
474 475 static char fixed_buf[8192];
@@ -481,7 +482,7 @@ static void *unpack_entry_data(off_t offset, size_t size,
481 482
482 483 if (!is_delta_type(type)) {
483 484 hdrlen = format_object_header(hdr, sizeof(hdr), type, size);
484 - git_hash_init(&c, the_hash_algo);
485 + the_hash_algo->init_fn(&c);
485 486 git_hash_update(&c, hdr, hdrlen);
486 487 } else
487 488 oid = NULL;
@@ -523,7 +524,7 @@ static void *unpack_raw_entry(struct object_entry *obj,
523 524 struct object_id *oid)
524 525 {
525 526 unsigned char *p;
526 - size_t size, c;
527 + unsigned long size, c;
527 528 off_t base_offset;
528 529 unsigned shift;
529 530 void *data;
@@ -538,8 +539,6 @@ static void *unpack_raw_entry(struct object_entry *obj,
538 539 size = (c & 15);
539 540 shift = 4;
540 541 while (c & 0x80) {
541 - if ((bitsizeof(size_t) - 7) < shift)
542 - die(_("object size too large for this platform"));
543 542 p = fill(1);
544 543 c = *p;
545 544 use(1);
@@ -763,7 +762,7 @@ static void find_ref_delta_children(const struct object_id *oid,
763 762
764 763 struct compare_data {
765 764 struct object_entry *entry;
766 - struct odb_stream *st;
765 + struct odb_read_stream *st;
767 766 unsigned char *buf;
768 767 unsigned long buf_size;
769 768 };
@@ -780,7 +779,7 @@ static int compare_objects(const unsigned char *buf, unsigned long size,
780 779 }
781 780
782 781 while (size) {
783 - ssize_t len = odb_stream_read(data->st, data->buf, size);
782 + ssize_t len = odb_read_stream_read(data->st, data->buf, size);
784 783 if (len == 0)
785 784 die(_("SHA1 COLLISION FOUND WITH %s !"),
786 785 oid_to_hex(&data->entry->idx.oid));
@@ -806,14 +805,14 @@ static int check_collison(struct object_entry *entry)
806 805
807 806 memset(&data, 0, sizeof(data));
808 807 data.entry = entry;
809 - data.st = odb_stream_from_object(the_repository->objects, &entry->idx.oid, NULL);
808 + data.st = odb_read_stream_open(the_repository->objects, &entry->idx.oid, NULL);
810 809 if (!data.st)
811 810 return -1;
812 811 if (data.st->size != entry->size || data.st->type != entry->type)
813 812 die(_("SHA1 COLLISION FOUND WITH %s !"),
814 813 oid_to_hex(&entry->idx.oid));
815 814 unpack_data(entry, compare_objects, &data);
816 - odb_stream_close(data.st);
815 + odb_read_stream_close(data.st);
817 816 free(data.buf);
818 817 return 0;
819 818 }
@@ -905,7 +904,7 @@ static void sha1_object(const void *data, struct object_entry *obj_entry,
905 904 if (collision_test_needed) {
906 905 void *has_data;
907 906 enum object_type has_type;
908 - size_t has_size;
907 + unsigned long has_size;
909 908 read_lock();
910 909 has_type = odb_read_object_info(the_repository->objects, oid, &has_size);
911 910 if (has_type < 0)
@@ -1048,7 +1047,7 @@ static struct base_data *resolve_delta(struct object_entry *delta_obj,
1048 1047 {
1049 1048 void *delta_data, *result_data;
1050 1049 struct base_data *result;
1051 - size_t result_size;
1050 + unsigned long result_size;
1052 1051
1053 1052 if (show_stat) {
1054 1053 int i = delta_obj - objects;
@@ -1212,6 +1211,7 @@ static void *threaded_second_pass(void *data)
1212 1211 list_add(&child->list, &work_head);
1213 1212 base_cache_used += child->size;
1214 1213 prune_base_data(NULL);
1214 + free_base_data(child);
1215 1215 } else if (child) {
1216 1216 /*
1217 1217 * This child does not have its own children. It may be
@@ -1291,7 +1291,7 @@ static void parse_pack_objects(unsigned char *hash)
1291 1291
1292 1292 /* Check pack integrity */
1293 1293 flush();
1294 - git_hash_init(&tmp_ctx, the_hash_algo);
1294 + the_hash_algo->init_fn(&tmp_ctx);
1295 1295 git_hash_clone(&tmp_ctx, &input_ctx);
1296 1296 git_hash_final(hash, &tmp_ctx);
1297 1297 if (!hasheq(fill(the_hash_algo->rawsz), hash, the_repository->hash_algo))
@@ -1416,9 +1416,8 @@ static int write_compressed(struct hashfile *f, void *in, unsigned int size)
1416 1416 git_zstream stream;
1417 1417 int status;
1418 1418 unsigned char outbuf[4096];
1419 - struct repo_config_values *cfg = repo_config_values(the_repository);
1420 1419
1421 - git_deflate_init(&stream, cfg->zlib_compression_level);
1420 + git_deflate_init(&stream, zlib_compression_level);
1422 1421 stream.next_in = in;
1423 1422 stream.avail_in = size;
1424 1423
@@ -1515,7 +1514,7 @@ static void fix_unresolved_deltas(struct hashfile *f)
1515 1514 struct ref_delta_entry *d = sorted_by_pos[i];
1516 1515 enum object_type type;
1517 1516 void *data;
1518 - size_t size;
1517 + unsigned long size;
1519 1518
1520 1519 if (objects[d->obj_no].real_type != OBJ_REF_DELTA)
1521 1520 continue;
@@ -1825,16 +1824,11 @@ static void repack_local_links(void)
1825 1824
1826 1825 oidset_iter_init(&outgoing_links, &iter);
1827 1826 while ((oid = oidset_iter_next(&iter))) {
1828 - struct odb_source_info source_info;
1829 - struct object_info info = {
1830 - .source_infop = &source_info,
1831 - };
1832 -
1827 + struct object_info info = OBJECT_INFO_INIT;
1833 1828 if (odb_read_object_info_extended(the_repository->objects, oid, &info, 0))
1834 1829 /* Missing; assume it is a promisor object */
1835 1830 continue;
1836 - if (source_info.source->type == ODB_SOURCE_PACKED &&
1837 - source_info.u.packed.pack->pack_promisor)
1831 + if (info.whence == OI_PACKED && info.u.packed.pack->pack_promisor)
1838 1832 continue;
1839 1833
1840 1834 if (!cmd.args.nr) {
@@ -1886,7 +1880,7 @@ static void repack_local_links(void)
1886 1880 int cmd_index_pack(int argc,
1887 1881 const char **argv,
1888 1882 const char *prefix,
1889 - struct repository *repo)
1883 + struct repository *repo UNUSED)
1890 1884 {
1891 1885 int i, fix_thin_pack = 0, verify = 0, stat_only = 0, rev_index;
1892 1886 const char *curr_index;
@@ -1903,15 +1897,15 @@ int cmd_index_pack(int argc,
1903 1897 int report_end_of_input = 0;
1904 1898 int hash_algo = 0;
1905 1899
1906 - show_usage_if_asked(argc, argv, index_pack_usage);
1907 -
1908 1900 /*
1909 1901 * index-pack never needs to fetch missing objects except when
1910 1902 * REF_DELTA bases are missing (which are explicitly handled). It only
1911 1903 * accesses the repo to do hash collision checks and to check which
1912 1904 * REF_DELTA bases need to be fetched.
1913 1905 */
1914 - (repo ? repo : the_repository)->fetch_if_missing = 0;
1906 + fetch_if_missing = 0;
1907 +
1908 + show_usage_if_asked(argc, argv, index_pack_usage);
1915 1909
1916 1910 disable_replace_refs();
1917 1911
modified builtin/init-db.c
@@ -81,7 +81,6 @@ int cmd_init_db(int argc,
81 81 const char *template_dir = NULL;
82 82 char *template_dir_to_free = NULL;
83 83 unsigned int flags = 0;
84 - int bare = startup_info->force_bare_repository ? 1 : -1;
85 84 const char *object_format = NULL;
86 85 const char *ref_format = NULL;
87 86 const char *initial_branch = NULL;
@@ -91,7 +90,7 @@ int cmd_init_db(int argc,
91 90 const struct option init_db_options[] = {
92 91 OPT_STRING(0, "template", &template_dir, N_("template-directory"),
93 92 N_("directory from which templates will be used")),
94 - OPT_SET_INT(0, "bare", &bare,
93 + OPT_SET_INT(0, "bare", &is_bare_repository_cfg,
95 94 N_("create a bare repository"), 1),
96 95 {
97 96 .type = OPTION_CALLBACK,
@@ -117,7 +116,7 @@ int cmd_init_db(int argc,
117 116
118 117 argc = parse_options(argc, argv, prefix, init_db_options, init_db_usage, 0);
119 118
120 - if (real_git_dir && bare == 1)
119 + if (real_git_dir && is_bare_repository_cfg == 1)
121 120 die(_("options '%s' and '%s' cannot be used together"), "--separate-git-dir", "--bare");
122 121
123 122 if (real_git_dir && !is_absolute_path(real_git_dir))
@@ -161,7 +160,7 @@ int cmd_init_db(int argc,
161 160 } else if (0 < argc) {
162 161 usage(init_db_usage[0]);
163 162 }
164 - if (bare == 1) {
163 + if (is_bare_repository_cfg == 1) {
165 164 char *cwd = xgetcwd();
166 165 setenv(GIT_DIR_ENVIRONMENT, cwd, argc > 0);
167 166 free(cwd);
@@ -188,7 +187,7 @@ int cmd_init_db(int argc,
188 187 */
189 188 git_dir = xstrdup_or_null(getenv(GIT_DIR_ENVIRONMENT));
190 189 work_tree = xstrdup_or_null(getenv(GIT_WORK_TREE_ENVIRONMENT));
191 - if ((!git_dir || bare == 1) && work_tree)
190 + if ((!git_dir || is_bare_repository_cfg == 1) && work_tree)
192 191 die(_("%s (or --work-tree=<directory>) not allowed without "
193 192 "specifying %s (or --git-dir=<directory>)"),
194 193 GIT_WORK_TREE_ENVIRONMENT,
@@ -225,31 +224,36 @@ int cmd_init_db(int argc,
225 224 strbuf_release(&sb);
226 225 }
227 226
228 - if (bare < 0)
229 - bare = guess_repository_type(git_dir);
227 + if (is_bare_repository_cfg < 0)
228 + is_bare_repository_cfg = guess_repository_type(git_dir);
230 229
231 - if (!bare) {
230 + if (!is_bare_repository_cfg) {
232 231 const char *git_dir_parent = strrchr(git_dir, '/');
233 -
234 - if (!work_tree) {
235 - if (git_dir_parent) {
236 - char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
237 - work_tree = real_pathdup(rel, 1);
238 - free(rel);
239 - } else {
240 - work_tree = xgetcwd();
241 - }
232 + if (git_dir_parent) {
233 + char *rel = xstrndup(git_dir, git_dir_parent - git_dir);
234 + git_work_tree_cfg = real_pathdup(rel, 1);
235 + free(rel);
242 236 }
243 -
244 - if (access(work_tree, X_OK))
245 - die_errno (_("Cannot access work tree '%s'"), work_tree);
246 - } else if (real_git_dir) {
247 - die(_("--separate-git-dir incompatible with bare repository"));
237 + if (!git_work_tree_cfg)
238 + git_work_tree_cfg = xgetcwd();
239 + if (work_tree)
240 + set_git_work_tree(work_tree);
241 + else
242 + set_git_work_tree(git_work_tree_cfg);
243 + if (access(repo_get_work_tree(the_repository), X_OK))
244 + die_errno (_("Cannot access work tree '%s'"),
245 + repo_get_work_tree(the_repository));
246 + }
247 + else {
248 + if (real_git_dir)
249 + die(_("--separate-git-dir incompatible with bare repository"));
250 + if (work_tree)
251 + set_git_work_tree(work_tree);
248 252 }
249 253
250 254 flags |= INIT_DB_EXIST_OK;
251 - ret = init_db(the_repository, git_dir, real_git_dir, work_tree,
252 - template_dir, hash_algo, ref_storage_format, initial_branch,
255 + ret = init_db(git_dir, real_git_dir, template_dir, hash_algo,
256 + ref_storage_format, initial_branch,
253 257 init_shared_repository, flags);
254 258
255 259 free(template_dir_to_free);
modified builtin/last-modified.c
@@ -290,8 +290,7 @@ static void process_parent(struct last_modified *lm,
290 290 {
291 291 struct bitmap *active_p;
292 292
293 - if (repo_parse_commit(lm->rev.repo, parent))
294 - return;
293 + repo_parse_commit(lm->rev.repo, parent);
295 294 active_p = active_paths_for(lm, parent);
296 295
297 296 /*
@@ -345,7 +344,6 @@ static void process_parent(struct last_modified *lm,
345 344 static int last_modified_run(struct last_modified *lm)
346 345 {
347 346 int max_count, queue_popped = 0;
348 - struct commit *c, *n;
349 347 struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
350 348 struct prio_queue not_queue = { compare_commits_by_gen_then_commit_date };
351 349 struct commit_list *list;
@@ -391,9 +389,10 @@ static int last_modified_run(struct last_modified *lm)
391 389 }
392 390 }
393 391
394 - while ((c = prio_queue_get(&queue))) {
392 + while (queue.nr) {
395 393 int parent_i;
396 394 struct commit_list *p;
395 + struct commit *c = prio_queue_get(&queue);
397 396 struct bitmap *active_c = active_paths_for(lm, c);
398 397
399 398 if ((0 <= max_count && max_count < ++queue_popped) ||
@@ -415,14 +414,13 @@ static int last_modified_run(struct last_modified *lm)
415 414 * Otherwise, make sure that 'c' isn't reachable from anything
416 415 * in the '--not' queue.
417 416 */
418 - if (repo_parse_commit(lm->rev.repo, c))
419 - goto cleanup;
417 + repo_parse_commit(lm->rev.repo, c);
420 418
421 - while ((n = prio_queue_get(&not_queue))) {
419 + while (not_queue.nr) {
422 420 struct commit_list *np;
421 + struct commit *n = prio_queue_get(&not_queue);
423 422
424 - if (repo_parse_commit(lm->rev.repo, n))
425 - continue;
423 + repo_parse_commit(lm->rev.repo, n);
426 424
427 425 for (np = n->parents; np; np = np->next) {
428 426 if (!(np->item->object.flags & PARENT2)) {
modified builtin/log.c
@@ -21,12 +21,10 @@
21 21 #include "color.h"
22 22 #include "commit.h"
23 23 #include "diff.h"
24 - #include "diffcore.h"
25 24 #include "diff-merges.h"
26 25 #include "revision.h"
27 26 #include "log-tree.h"
28 27 #include "oid-array.h"
29 - #include "oidset.h"
30 28 #include "tag.h"
31 29 #include "reflog-walk.h"
32 30 #include "patch-ids.h"
@@ -45,11 +43,9 @@
45 43 #include "utf8.h"
46 44
47 45 #include "commit-reach.h"
48 - #include "promisor-remote.h"
49 46 #include "range-diff.h"
50 47 #include "tmp-objdir.h"
51 48 #include "tree.h"
52 - #include "userdiff.h"
53 49 #include "write-or-die.h"
54 50
55 51 #define MAIL_DEFAULT_WRAP 72
@@ -613,7 +609,7 @@ static int show_blob_object(const struct object_id *oid, struct rev_info *rev, c
613 609
614 610 static int show_tag_object(const struct object_id *oid, struct rev_info *rev)
615 611 {
616 - size_t size;
612 + unsigned long size;
617 613 enum object_type type;
618 614 char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
619 615 unsigned long offset = 0;
@@ -1888,7 +1884,6 @@ static void prepare_bases(struct base_tree_info *bases,
1888 1884 bases->nr_patch_id++;
1889 1885 }
1890 1886 clear_commit_base(&commit_base);
1891 - release_revisions(&revs);
1892 1887 }
1893 1888
1894 1889 static void print_bases(struct base_tree_info *bases, FILE *file)
@@ -2607,131 +2602,6 @@ static void print_commit(char sign, struct commit *commit, int verbose,
2607 2602 }
2608 2603 }
2609 2604
2610 - /*
2611 - * Enumerate blob OIDs from a single commit's diff, inserting them into blobs.
2612 - * Skips files whose userdiff driver explicitly declares binary status
2613 - * (drv->binary > 0), since patch-ID uses oid_to_hex() for those and
2614 - * never reads blob content. Use userdiff_find_by_path() since
2615 - * diff_filespec_load_driver() is static in diff.c.
2616 - *
2617 - * Clean up with diff_queue_clear() (from diffcore.h).
2618 - */
2619 - static void collect_diff_blob_oids(struct commit *commit,
2620 - struct diff_options *opts,
2621 - struct oidset *blobs)
2622 - {
2623 - struct diff_queue_struct *q;
2624 -
2625 - /*
2626 - * Merge commits are filtered out by patch_id_defined() in patch-ids.c,
2627 - * so we'll never be called with one.
2628 - */
2629 - assert(!commit->parents || !commit->parents->next);
2630 -
2631 - if (commit->parents)
2632 - diff_tree_oid(&commit->parents->item->object.oid,
2633 - &commit->object.oid, "", opts);
2634 - else
2635 - diff_root_tree_oid(&commit->object.oid, "", opts);
2636 - diffcore_std(opts);
2637 -
2638 - q = &diff_queued_diff;
2639 - for (int i = 0; i < q->nr; i++) {
2640 - struct diff_filepair *p = q->queue[i];
2641 - struct userdiff_driver *drv;
2642 -
2643 - /* Skip binary files */
2644 - drv = userdiff_find_by_path(opts->repo->index, p->one->path);
2645 - if (drv && drv->binary > 0)
2646 - continue;
2647 -
2648 - if (DIFF_FILE_VALID(p->one) &&
2649 - odb_read_object_info_extended(opts->repo->objects,
2650 - &p->one->oid, NULL,
2651 - OBJECT_INFO_FOR_PREFETCH))
2652 - oidset_insert(blobs, &p->one->oid);
2653 - if (DIFF_FILE_VALID(p->two) &&
2654 - odb_read_object_info_extended(opts->repo->objects,
2655 - &p->two->oid, NULL,
2656 - OBJECT_INFO_FOR_PREFETCH))
2657 - oidset_insert(blobs, &p->two->oid);
2658 - }
2659 - diff_queue_clear(q);
2660 - }
2661 -
2662 - static int always_match(const void *cmp_data UNUSED,
2663 - const struct hashmap_entry *entry1 UNUSED,
2664 - const struct hashmap_entry *entry2 UNUSED,
2665 - const void *keydata UNUSED)
2666 - {
2667 - return 0;
2668 - }
2669 -
2670 - /*
2671 - * Prefetch blobs for git cherry in partial clones.
2672 - *
2673 - * Called between the revision walk (which builds the head-side
2674 - * commit list) and the has_commit_patch_id() comparison loop.
2675 - *
2676 - * Uses a cmpfn-swap trick to avoid reading blobs: temporarily
2677 - * replaces the hashmap's comparison function with a trivial
2678 - * always-match function, so hashmap_get()/hashmap_get_next() match
2679 - * any entry with the same oidhash bucket. These are the set of oids
2680 - * that would trigger patch_id_neq() during normal lookup and cause
2681 - * blobs to be read on demand, and we want to prefetch them all at
2682 - * once instead.
2683 - */
2684 - static void prefetch_cherry_blobs(struct repository *repo,
2685 - struct commit_list *list,
2686 - struct patch_ids *ids)
2687 - {
2688 - struct oidset blobs = OIDSET_INIT;
2689 - hashmap_cmp_fn original_cmpfn;
2690 -
2691 - /* Exit if we're not in a partial clone */
2692 - if (!repo_has_promisor_remote(repo))
2693 - return;
2694 -
2695 - /* Save original cmpfn, replace with always_match */
2696 - original_cmpfn = ids->patches.cmpfn;
2697 - ids->patches.cmpfn = always_match;
2698 -
2699 - /* Find header-only collisions, gather blobs from those commits */
2700 - for (struct commit_list *l = list; l; l = l->next) {
2701 - struct commit *c = l->item;
2702 - bool match_found = false;
2703 - for (struct patch_id *cur = patch_id_iter_first(c, ids);
2704 - cur;
2705 - cur = patch_id_iter_next(cur, ids)) {
2706 - match_found = true;
2707 - collect_diff_blob_oids(cur->commit, &ids->diffopts,
2708 - &blobs);
2709 - }
2710 - if (match_found)
2711 - collect_diff_blob_oids(c, &ids->diffopts, &blobs);
2712 - }
2713 -
2714 - /* Restore original cmpfn */
2715 - ids->patches.cmpfn = original_cmpfn;
2716 -
2717 - /* If we have any blobs to fetch, fetch them */
2718 - if (oidset_size(&blobs)) {
2719 - struct oid_array to_fetch = OID_ARRAY_INIT;
2720 - struct oidset_iter iter;
2721 - const struct object_id *oid;
2722 -
2723 - oidset_iter_init(&blobs, &iter);
2724 - while ((oid = oidset_iter_next(&iter)))
2725 - oid_array_append(&to_fetch, oid);
2726 -
2727 - promisor_remote_get_direct(repo, to_fetch.oid, to_fetch.nr);
2728 -
2729 - oid_array_clear(&to_fetch);
2730 - }
2731 -
2732 - oidset_clear(&blobs);
2733 - }
2734 -
2735 2605 int cmd_cherry(int argc,
2736 2606 const char **argv,
2737 2607 const char *prefix,
@@ -2803,8 +2673,6 @@ int cmd_cherry(int argc,
2803 2673 commit_list_insert(commit, &list);
2804 2674 }
2805 2675
2806 - prefetch_cherry_blobs(the_repository, list, &ids);
2807 -
2808 2676 for (struct commit_list *l = list; l; l = l->next) {
2809 2677 char sign = '+';
2810 2678
modified builtin/ls-files.c
@@ -250,23 +250,20 @@ static void expand_objectsize(struct repository *repo, struct strbuf *line,
250 250 const struct object_id *oid,
251 251 const enum object_type type, unsigned int padded)
252 252 {
253 - static const char padding[] = " ";
254 - size_t min_len = padded ? strlen(padding) : 0;
255 - size_t orig_len = line->len;
256 - size_t len;
257 -
258 253 if (type == OBJ_BLOB) {
259 - size_t size;
254 + unsigned long size;
260 255 if (odb_read_object_info(repo->objects, oid, &size) < 0)
261 256 die(_("could not get object info about '%s'"),
262 257 oid_to_hex(oid));
263 - strbuf_add_uint(line, size);
258 + if (padded)
259 + strbuf_addf(line, "%7"PRIuMAX, (uintmax_t)size);
260 + else
261 + strbuf_addf(line, "%"PRIuMAX, (uintmax_t)size);
262 + } else if (padded) {
263 + strbuf_addf(line, "%7s", "-");
264 264 } else {
265 265 strbuf_addstr(line, "-");
266 266 }
267 - len = line->len - orig_len;
268 - if (len < min_len)
269 - strbuf_insert(line, orig_len, padding, min_len - len);
270 267 }
271 268
272 269 static void show_ce_fmt(struct repository *repo, const struct cache_entry *ce,
@@ -453,17 +450,6 @@ static void show_files(struct repository *repo, struct dir_struct *dir)
453 450 continue;
454 451 if (ce_skip_worktree(ce))
455 452 continue;
456 - /*
457 - * match_pathspec() is linear in pathspec.nr, so prefilter only
458 - * the single-pathspec case. Only entries shown by show_ce()
459 - * satisfy --error-unmatch.
460 - */
461 - if (pathspec.nr == 1 &&
462 - !match_pathspec(repo->index, &pathspec, fullname.buf,
463 - fullname.len, max_prefix_len, NULL,
464 - S_ISDIR(ce->ce_mode) ||
465 - S_ISGITLINK(ce->ce_mode)))
466 - continue;
467 453 stat_err = lstat(fullname.buf, &st);
468 454 if (stat_err && (errno != ENOENT && errno != ENOTDIR))
469 455 error_errno("cannot lstat '%s'", fullname.buf);
@@ -717,8 +703,8 @@ int cmd_ls_files(int argc,
717 703 if (dir.exclude_per_dir)
718 704 exc_given = 1;
719 705
720 - if (require_work_tree && !is_inside_work_tree(repo))
721 - setup_work_tree(repo);
706 + if (require_work_tree && !is_inside_work_tree())
707 + setup_work_tree();
722 708
723 709 if (recurse_submodules &&
724 710 (show_deleted || show_others || show_unmerged ||
modified builtin/ls-tree.c
@@ -26,23 +26,20 @@ static const char * const ls_tree_usage[] = {
26 26 static void expand_objectsize(struct strbuf *line, const struct object_id *oid,
27 27 const enum object_type type, unsigned int padded)
28 28 {
29 - static const char padding[] = " ";
30 - size_t min_len = padded ? strlen(padding) : 0;
31 - size_t orig_len = line->len;
32 - size_t len;
33 -
34 29 if (type == OBJ_BLOB) {
35 - size_t size;
30 + unsigned long size;
36 31 if (odb_read_object_info(the_repository->objects, oid, &size) < 0)
37 32 die(_("could not get object info about '%s'"),
38 33 oid_to_hex(oid));
39 - strbuf_add_uint(line, size);
34 + if (padded)
35 + strbuf_addf(line, "%7"PRIuMAX, (uintmax_t)size);
36 + else
37 + strbuf_addf(line, "%"PRIuMAX, (uintmax_t)size);
38 + } else if (padded) {
39 + strbuf_addf(line, "%7s", "-");
40 40 } else {
41 41 strbuf_addstr(line, "-");
42 42 }
43 - len = line->len - orig_len;
44 - if (len < min_len)
45 - strbuf_insert(line, orig_len, padding, min_len - len);
46 43 }
47 44
48 45 struct ls_tree_options {
@@ -220,7 +217,7 @@ static int show_tree_long(const struct object_id *oid, struct strbuf *base,
220 217 return early;
221 218
222 219 if (type == OBJ_BLOB) {
223 - size_t size;
220 + unsigned long size;
224 221 if (odb_read_object_info(the_repository->objects, oid, &size) == OBJ_BAD)
225 222 xsnprintf(size_text, sizeof(size_text), "BAD");
226 223 else
modified builtin/mailsplit.c
@@ -225,14 +225,14 @@ static int split_mbox(const char *file, const char *dir, int allow_bare,
225 225 FILE *f = !strcmp(file, "-") ? stdin : fopen(file, "r");
226 226 int file_done = 0;
227 227
228 + if (isatty(fileno(f)))
229 + warning(_("reading patches from stdin/tty..."));
230 +
228 231 if (!f) {
229 232 error_errno("cannot open mbox %s", file);
230 233 goto out;
231 234 }
232 235
233 - if (isatty(fileno(f)))
234 - warning(_("reading patches from stdin/tty..."));
235 -
236 236 do {
237 237 peek = fgetc(f);
238 238 if (peek == EOF) {
modified builtin/merge-base.c
@@ -11,12 +11,10 @@
11 11
12 12 static int show_merge_base(struct commit **rev, size_t rev_nr, int show_all)
13 13 {
14 - enum merge_base_flags flags = show_all ? MERGE_BASE_FIND_ALL : 0;
15 14 struct commit_list *result = NULL, *r;
16 15
17 16 if (repo_get_merge_bases_many_dirty(the_repository, rev[0],
18 - rev_nr - 1, rev + 1,
19 - flags, &result) < 0) {
17 + rev_nr - 1, rev + 1, &result) < 0) {
20 18 commit_list_free(result);
21 19 return -1;
22 20 }
modified builtin/merge-file.c
@@ -110,7 +110,7 @@ int cmd_merge_file(int argc,
110 110
111 111 if (!repo && object_id)
112 112 /* emit the correct "not a git repo" error in this case */
113 - setup_git_directory(the_repository);
113 + setup_git_directory();
114 114
115 115 for (i = 0; i < 3; i++) {
116 116 char *fname;
modified builtin/merge-tree.c
@@ -69,7 +69,7 @@ static const char *explanation(struct merge_list *entry)
69 69 return "removed in remote";
70 70 }
71 71
72 - static void *result(struct merge_list *entry, size_t *size)
72 + static void *result(struct merge_list *entry, unsigned long *size)
73 73 {
74 74 enum object_type type;
75 75 struct blob *base, *our, *their;
@@ -96,7 +96,7 @@ static void *result(struct merge_list *entry, size_t *size)
96 96 base, our, their, size);
97 97 }
98 98
99 - static void *origin(struct merge_list *entry, size_t *size)
99 + static void *origin(struct merge_list *entry, unsigned long *size)
100 100 {
101 101 enum object_type type;
102 102 while (entry) {
@@ -119,7 +119,7 @@ static int show_outf(void *priv UNUSED, mmbuffer_t *mb, int nbuf)
119 119
120 120 static void show_diff(struct merge_list *entry)
121 121 {
122 - size_t size;
122 + unsigned long size;
123 123 mmfile_t src, dst;
124 124 xpparam_t xpp;
125 125 xdemitconf_t xecfg;
modified builtin/merge.c
@@ -537,8 +537,7 @@ static void finish(struct commit *head_commit,
537 537 run_hooks_l(the_repository, "post-merge", squash ? "1" : "0", NULL);
538 538
539 539 if (new_head)
540 - apply_autostash_ref(the_repository, "MERGE_AUTOSTASH",
541 - NULL, NULL, NULL, NULL);
540 + apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
542 541 strbuf_release(&reflog_message);
543 542 }
544 543
@@ -553,7 +552,7 @@ static void merge_name(const char *remote, struct strbuf *msg)
553 552 char *found_ref = NULL;
554 553 int len, early;
555 554
556 - copy_branchname(the_repository, &bname, remote, 0);
555 + copy_branchname(&bname, remote, 0);
557 556 remote = bname.buf;
558 557
559 558 oidclr(&branch_head, the_repository->hash_algo);
@@ -1373,7 +1372,7 @@ int cmd_merge(int argc,
1373 1372 struct commit_list *common = NULL;
1374 1373 const char *best_strategy = NULL, *wt_strategy = NULL;
1375 1374 struct commit_list *remoteheads = NULL, *p;
1376 - void *branch_to_free, *argv_to_free = NULL;
1375 + void *branch_to_free;
1377 1376 int orig_argc = argc;
1378 1377 int merge_log_config = -1;
1379 1378
@@ -1517,10 +1516,8 @@ int cmd_merge(int argc,
1517 1516 option_commit = 1;
1518 1517
1519 1518 if (!argc) {
1520 - if (default_to_upstream) {
1519 + if (default_to_upstream)
1521 1520 argc = setup_with_upstream(&argv);
1522 - argv_to_free = argv;
1523 - }
1524 1521 else
1525 1522 die(_("No commit specified and merge.defaultToUpstream not set."));
1526 1523 } else if (argc == 1 && !strcmp(argv[0], "-")) {
@@ -1675,14 +1672,12 @@ int cmd_merge(int argc,
1675 1672 }
1676 1673
1677 1674 if (autostash)
1678 - create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1679 - NULL, false);
1675 + create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1680 1676 if (checkout_fast_forward(the_repository,
1681 1677 &head_commit->object.oid,
1682 1678 &commit->object.oid,
1683 1679 overwrite_ignore)) {
1684 - apply_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1685 - NULL, NULL, NULL, NULL);
1680 + apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1686 1681 ret = 1;
1687 1682 goto done;
1688 1683 }
@@ -1740,11 +1735,21 @@ int cmd_merge(int argc,
1740 1735 struct commit_list *j;
1741 1736
1742 1737 for (j = remoteheads; j; j = j->next) {
1743 - int ret = repo_in_merge_bases(the_repository,
1744 - j->item, head_commit);
1745 - if (ret < 0)
1738 + struct commit_list *common_one = NULL;
1739 + struct commit *common_item;
1740 +
1741 + /*
1742 + * Here we *have* to calculate the individual
1743 + * merge_bases again, otherwise "git merge HEAD^
1744 + * HEAD^^" would be missed.
1745 + */
1746 + if (repo_get_merge_bases(the_repository, head_commit,
1747 + j->item, &common_one) < 0)
1746 1748 exit(128);
1747 - if (!ret) {
1749 +
1750 + common_item = common_one->item;
1751 + commit_list_free(common_one);
1752 + if (!oideq(&common_item->object.oid, &j->item->object.oid)) {
1748 1753 up_to_date = 0;
1749 1754 break;
1750 1755 }
@@ -1759,8 +1764,7 @@ int cmd_merge(int argc,
1759 1764 die_ff_impossible();
1760 1765
1761 1766 if (autostash)
1762 - create_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1763 - NULL, false);
1767 + create_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1764 1768
1765 1769 /* We are going to make a new commit. */
1766 1770 git_committer_info(IDENT_STRICT);
@@ -1845,8 +1849,7 @@ int cmd_merge(int argc,
1845 1849 else
1846 1850 fprintf(stderr, _("Merge with strategy %s failed.\n"),
1847 1851 use_strategies[0]->name);
1848 - apply_autostash_ref(the_repository, "MERGE_AUTOSTASH",
1849 - NULL, NULL, NULL, NULL);
1852 + apply_autostash_ref(the_repository, "MERGE_AUTOSTASH");
1850 1853 ret = 2;
1851 1854 goto done;
1852 1855 } else if (best_strategy == wt_strategy)
@@ -1882,7 +1885,6 @@ done:
1882 1885 }
1883 1886 strbuf_release(&buf);
1884 1887 free(branch_to_free);
1885 - free(argv_to_free);
1886 1888 free(pull_twohead);
1887 1889 free(pull_octopus);
1888 1890 discard_index(the_repository->index);
modified builtin/mktag.c
@@ -50,7 +50,7 @@ static int verify_object_in_tag(struct object_id *tagged_oid, int *tagged_type)
50 50 {
51 51 int ret;
52 52 enum object_type type;
53 - size_t size;
53 + unsigned long size;
54 54 void *buffer;
55 55 const struct object_id *repl;
56 56
modified builtin/multi-pack-index.c
@@ -10,20 +10,17 @@
10 10 #include "trace2.h"
11 11 #include "odb.h"
12 12 #include "odb/source.h"
13 - #include "odb/source-files.h"
14 13 #include "replace-object.h"
15 14 #include "repository.h"
16 15
17 16 #define BUILTIN_MIDX_WRITE_USAGE \
18 17 N_("git multi-pack-index [<options>] write [--preferred-pack=<pack>]\n" \
19 18 " [--[no-]bitmap] [--[no-]incremental] [--[no-]stdin-packs]\n" \
20 - " [--refs-snapshot=<path>] [--[no-]write-chain-file]\n" \
21 - " [--base=<checksum>]")
19 + " [--refs-snapshot=<path>]")
22 20
23 21 #define BUILTIN_MIDX_COMPACT_USAGE \
24 22 N_("git multi-pack-index [<options>] compact [--[no-]incremental]\n" \
25 - " [--[no-]bitmap] [--base=<checksum>] [--[no-]write-chain-file]\n" \
26 - " <from> <to>")
23 + " [--[no-]bitmap] <from> <to>")
27 24
28 25 #define BUILTIN_MIDX_VERIFY_USAGE \
29 26 N_("git multi-pack-index [<options>] verify")
@@ -66,7 +63,6 @@ static char const * const builtin_multi_pack_index_usage[] = {
66 63 static struct opts_multi_pack_index {
67 64 char *object_dir;
68 65 const char *preferred_pack;
69 - const char *incremental_base;
70 66 char *refs_snapshot;
71 67 unsigned long batch_size;
72 68 unsigned flags;
@@ -86,12 +82,12 @@ static int parse_object_dir(const struct option *opt, const char *arg,
86 82 return 0;
87 83 }
88 84
89 - static struct odb_source_files *handle_object_dir_option(struct repository *repo)
85 + static struct odb_source *handle_object_dir_option(struct repository *repo)
90 86 {
91 87 struct odb_source *source = odb_find_source(repo->objects, opts.object_dir);
92 88 if (!source)
93 89 source = odb_add_to_alternates_memory(repo->objects, opts.object_dir);
94 - return odb_source_files_downcast(source);
90 + return source;
95 91 }
96 92
97 93 static struct option common_opts[] = {
@@ -155,20 +151,15 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
155 151 N_("pack for reuse when computing a multi-pack bitmap")),
156 152 OPT_BIT(0, "bitmap", &opts.flags, N_("write multi-pack bitmap"),
157 153 MIDX_WRITE_BITMAP | MIDX_WRITE_REV_INDEX),
158 - OPT_STRING(0, "base", &opts.incremental_base, N_("checksum"),
159 - N_("base MIDX for incremental writes")),
160 154 OPT_BIT(0, "incremental", &opts.flags,
161 155 N_("write a new incremental MIDX"), MIDX_WRITE_INCREMENTAL),
162 - OPT_NEGBIT(0, "write-chain-file", &opts.flags,
163 - N_("write the multi-pack-index chain file"),
164 - MIDX_WRITE_NO_CHAIN),
165 156 OPT_BOOL(0, "stdin-packs", &opts.stdin_packs,
166 157 N_("write multi-pack index containing only given indexes")),
167 158 OPT_FILENAME(0, "refs-snapshot", &opts.refs_snapshot,
168 159 N_("refs snapshot for selecting bitmap commits")),
169 160 OPT_END(),
170 161 };
171 - struct odb_source_files *source;
162 + struct odb_source *source;
172 163 int ret;
173 164
174 165 opts.flags |= MIDX_WRITE_BITMAP_HASH_CACHE;
@@ -187,22 +178,6 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
187 178 if (argc)
188 179 usage_with_options(builtin_multi_pack_index_write_usage,
189 180 options);
190 -
191 - if (opts.flags & MIDX_WRITE_NO_CHAIN &&
192 - !(opts.flags & MIDX_WRITE_INCREMENTAL)) {
193 - error(_("cannot use %s without %s"),
194 - "--no-write-chain-file", "--incremental");
195 - usage_with_options(builtin_multi_pack_index_write_usage,
196 - options);
197 - }
198 -
199 - if (opts.incremental_base &&
200 - !(opts.flags & MIDX_WRITE_NO_CHAIN)) {
201 - error(_("cannot use --base without --no-write-chain-file"));
202 - usage_with_options(builtin_multi_pack_index_write_usage,
203 - options);
204 - }
205 -
206 181 source = handle_object_dir_option(repo);
207 182
208 183 FREE_AND_NULL(options);
@@ -212,10 +187,9 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
212 187
213 188 read_packs_from_stdin(&packs);
214 189
215 - ret = write_midx_file_only(source->packed, &packs,
190 + ret = write_midx_file_only(source, &packs,
216 191 opts.preferred_pack,
217 - opts.refs_snapshot,
218 - opts.incremental_base, opts.flags);
192 + opts.refs_snapshot, opts.flags);
219 193
220 194 string_list_clear(&packs, 0);
221 195 free(opts.refs_snapshot);
@@ -224,7 +198,7 @@ static int cmd_multi_pack_index_write(int argc, const char **argv,
224 198
225 199 }
226 200
227 - ret = write_midx_file(source->packed, opts.preferred_pack,
201 + ret = write_midx_file(source, opts.preferred_pack,
228 202 opts.refs_snapshot, opts.flags);
229 203
230 204 free(opts.refs_snapshot);
@@ -238,20 +212,15 @@ static int cmd_multi_pack_index_compact(int argc, const char **argv,
238 212 struct multi_pack_index *m, *cur;
239 213 struct multi_pack_index *from_midx = NULL;
240 214 struct multi_pack_index *to_midx = NULL;
241 - struct odb_source_files *source;
215 + struct odb_source *source;
242 216 int ret;
243 217
244 218 struct option *options;
245 219 static struct option builtin_multi_pack_index_compact_options[] = {
246 - OPT_STRING(0, "base", &opts.incremental_base, N_("checksum"),
247 - N_("base MIDX for incremental writes")),
248 220 OPT_BIT(0, "bitmap", &opts.flags, N_("write multi-pack bitmap"),
249 221 MIDX_WRITE_BITMAP | MIDX_WRITE_REV_INDEX),
250 222 OPT_BIT(0, "incremental", &opts.flags,
251 223 N_("write a new incremental MIDX"), MIDX_WRITE_INCREMENTAL),
252 - OPT_NEGBIT(0, "write-chain-file", &opts.flags,
253 - N_("write the multi-pack-index chain file"),
254 - MIDX_WRITE_NO_CHAIN),
255 224 OPT_END(),
256 225 };
257 226
@@ -270,20 +239,11 @@ static int cmd_multi_pack_index_compact(int argc, const char **argv,
270 239 if (argc != 2)
271 240 usage_with_options(builtin_multi_pack_index_compact_usage,
272 241 options);
273 -
274 - if (opts.flags & MIDX_WRITE_NO_CHAIN &&
275 - !(opts.flags & MIDX_WRITE_INCREMENTAL)) {
276 - error(_("cannot use %s without %s"),
277 - "--no-write-chain-file", "--incremental");
278 - usage_with_options(builtin_multi_pack_index_compact_usage,
279 - options);
280 - }
281 -
282 242 source = handle_object_dir_option(the_repository);
283 243
284 244 FREE_AND_NULL(options);
285 245
286 - m = get_multi_pack_index(source->packed);
246 + m = get_multi_pack_index(source);
287 247
288 248 for (cur = m; cur && !(from_midx && to_midx); cur = cur->base_midx) {
289 249 const char *midx_csum = midx_get_checksum_hex(cur);
@@ -306,8 +266,7 @@ static int cmd_multi_pack_index_compact(int argc, const char **argv,
306 266 die(_("MIDX %s must be an ancestor of %s"), argv[0], argv[1]);
307 267 }
308 268
309 - ret = write_midx_file_compact(source->packed, from_midx, to_midx,
310 - opts.incremental_base, opts.flags);
269 + ret = write_midx_file_compact(source, from_midx, to_midx, opts.flags);
311 270
312 271 return ret;
313 272 }
@@ -320,7 +279,7 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv,
320 279 static struct option builtin_multi_pack_index_verify_options[] = {
321 280 OPT_END(),
322 281 };
323 - struct odb_source_files *source;
282 + struct odb_source *source;
324 283
325 284 options = add_common_options(builtin_multi_pack_index_verify_options);
326 285
@@ -338,7 +297,7 @@ static int cmd_multi_pack_index_verify(int argc, const char **argv,
338 297
339 298 FREE_AND_NULL(options);
340 299
341 - return verify_midx_file(source->packed, opts.flags);
300 + return verify_midx_file(source, opts.flags);
342 301 }
343 302
344 303 static int cmd_multi_pack_index_expire(int argc, const char **argv,
@@ -349,7 +308,7 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv,
349 308 static struct option builtin_multi_pack_index_expire_options[] = {
350 309 OPT_END(),
351 310 };
352 - struct odb_source_files *source;
311 + struct odb_source *source;
353 312
354 313 options = add_common_options(builtin_multi_pack_index_expire_options);
355 314
@@ -367,7 +326,7 @@ static int cmd_multi_pack_index_expire(int argc, const char **argv,
367 326
368 327 FREE_AND_NULL(options);
369 328
370 - return expire_midx_packs(source->packed, opts.flags);
329 + return expire_midx_packs(source, opts.flags);
371 330 }
372 331
373 332 static int cmd_multi_pack_index_repack(int argc, const char **argv,
@@ -380,7 +339,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
380 339 N_("during repack, collect pack-files of smaller size into a batch that is larger than this size")),
381 340 OPT_END(),
382 341 };
383 - struct odb_source_files *source;
342 + struct odb_source *source;
384 343
385 344 options = add_common_options(builtin_multi_pack_index_repack_options);
386 345
@@ -399,7 +358,7 @@ static int cmd_multi_pack_index_repack(int argc, const char **argv,
399 358
400 359 FREE_AND_NULL(options);
401 360
402 - return midx_repack(source->packed, (size_t)opts.batch_size, opts.flags);
361 + return midx_repack(source, (size_t)opts.batch_size, opts.flags);
403 362 }
404 363
405 364 int cmd_multi_pack_index(int argc,
modified builtin/mv.c
@@ -22,7 +22,6 @@
22 22 #include "string-list.h"
23 23 #include "parse-options.h"
24 24 #include "read-cache-ll.h"
25 - #include "symlinks.h"
26 25
27 26 #include "setup.h"
28 27 #include "strvec.h"
@@ -49,12 +48,6 @@ enum update_mode {
49 48 MOVE_VIA_PARENT_DIR = (1 << 5),
50 49 };
51 50
52 - static int needs_worktree_rename(enum update_mode mode, enum update_mode dst_mode)
53 - {
54 - return !(mode & (INDEX | SPARSE | SKIP_WORKTREE_DIR)) &&
55 - !(dst_mode & (SKIP_WORKTREE_DIR | SPARSE));
56 - }
57 -
58 51 #define DUP_BASENAME 1
59 52 #define KEEP_TRAILING_SLASH 2
60 53
@@ -78,7 +71,7 @@ static void internal_prefix_pathspec(struct strvec *out,
78 71
79 72 trimmed = xmemdupz(pathspec[i], to_copy);
80 73 maybe_basename = (flags & DUP_BASENAME) ? basename(trimmed) : trimmed;
81 - prefixed_path = prefix_path(the_repository, prefix, prefixlen, maybe_basename);
74 + prefixed_path = prefix_path(prefix, prefixlen, maybe_basename);
82 75 strvec_push(out, prefixed_path);
83 76
84 77 free(prefixed_path);
@@ -401,8 +394,7 @@ dir_check:
401 394 for (j = 0; j < last - first; j++) {
402 395 const struct cache_entry *ce = the_repository->index->cache[first + j];
403 396 const char *path = ce->name;
404 - char *prefixed_path = prefix_path(the_repository, dst_with_slash,
405 - dst_with_slash_len, path + length + 1);
397 + char *prefixed_path = prefix_path(dst_with_slash, dst_with_slash_len, path + length + 1);
406 398
407 399 strvec_push(&sources, path);
408 400 strvec_push(&destinations, prefixed_path);
@@ -426,7 +418,7 @@ dir_check:
426 418 goto act_on_entry;
427 419 }
428 420 if (lstat(dst, &st) == 0 &&
429 - (!repo_ignore_case(the_repository) || strcasecmp(src, dst))) {
421 + (!ignore_case || strcasecmp(src, dst))) {
430 422 bad = _("destination exists");
431 423 if (force) {
432 424 /*
@@ -450,41 +442,6 @@ dir_check:
450 442 bad = _("destination directory does not exist");
451 443 goto act_on_entry;
452 444 }
453 - if (has_symlink_leading_path(dst, strlen(dst))) {
454 - bad = _("destination is beyond a symbolic link");
455 - goto act_on_entry;
456 - }
457 -
458 - /*
459 - * If we are going to move SRC to DST on disk, DST's leading
460 - * directories must already exist.
461 - */
462 - if (needs_worktree_rename(modes[i], dst_mode)) {
463 - const char *slash_ = strrchr(dst, '/');
464 -
465 - if (slash_) {
466 - struct stat dir_st;
467 - char *dst_dir = xstrdup(dst);
468 - char *slash = &dst_dir[slash_ - dst];
469 -
470 - *slash = '\0';
471 - if (lstat(dst_dir, &dir_st) < 0) {
472 - /*
473 - * other errors fall through to rename(),
474 - * which reports them
475 - */
476 - if (errno == ENOENT || errno == ENOTDIR)
477 - bad = _("destination directory does not exist");
478 - } else if (!S_ISDIR(dir_st.st_mode)) {
479 - bad = _("destination is not a directory");
480 - }
481 -
482 - free(dst_dir);
483 - }
484 -
485 - if (bad)
486 - goto act_on_entry;
487 - }
488 445
489 446 if (ignore_sparse &&
490 447 (dst_mode & (SKIP_WORKTREE_DIR | SPARSE)) &&
@@ -586,11 +543,12 @@ remove_entry:
586 543 printf(_("Renaming %s to %s\n"), src, dst);
587 544 if (show_only)
588 545 continue;
589 - if (needs_worktree_rename(mode, dst_mode) &&
546 + if (!(mode & (INDEX | SPARSE | SKIP_WORKTREE_DIR)) &&
547 + !(dst_mode & (SKIP_WORKTREE_DIR | SPARSE)) &&
590 548 rename(src, dst) < 0) {
591 549 if (ignore_errors)
592 550 continue;
593 - die_errno(_("renaming '%s' to '%s' failed"), src, dst);
551 + die_errno(_("renaming '%s' failed"), src);
594 552 }
595 553 if (submodule_gitfiles[i]) {
596 554 if (!update_path_in_gitmodules(src, dst))
@@ -616,7 +574,7 @@ remove_entry:
616 574
617 575 if (ignore_sparse &&
618 576 cfg->apply_sparse_checkout &&
619 - cfg->core_sparse_checkout_cone) {
577 + core_sparse_checkout_cone) {
620 578 /*
621 579 * NEEDSWORK: we are *not* paying attention to
622 580 * "out-to-out" move (<source> is out-of-cone and
modified builtin/name-rev.c
@@ -17,10 +17,6 @@
17 17 #include "commit-graph.h"
18 18 #include "wildmatch.h"
19 19 #include "mem-pool.h"
20 - #include "pretty.h"
21 - #include "revision.h"
22 - #include "notes.h"
23 - #include "write-or-die.h"
24 20
25 21 /*
26 22 * One day. See the 'name a rev shortly after epoch' test in t6120 when
@@ -274,43 +270,6 @@ struct name_ref_data {
274 270 struct string_list exclude_filters;
275 271 };
276 272
277 - struct pretty_format {
278 - struct pretty_print_context ctx;
279 - struct userformat_want want;
280 - };
281 -
282 - enum command_type {
283 - NAME_REV = 1,
284 - FORMAT_REV = 2,
285 - };
286 -
287 - enum stdin_mode {
288 - TEXT = 1,
289 - REVS = 2,
290 - };
291 -
292 - struct command {
293 - enum command_type type;
294 - union {
295 - int name_only;
296 - struct pretty_format *pretty_format;
297 - } u;
298 - };
299 -
300 - static void init_name_rev_command(struct command *cmd,
301 - int name_only)
302 - {
303 - cmd->type = NAME_REV;
304 - cmd->u.name_only = name_only;
305 - }
306 -
307 - static void init_format_rev_command(struct command *cmd,
308 - struct pretty_format *pretty_format)
309 - {
310 - cmd->type = FORMAT_REV;
311 - cmd->u.pretty_format = pretty_format;
312 - }
313 -
314 273 static struct tip_table {
315 274 struct tip_table_entry {
316 275 struct object_id oid;
@@ -505,9 +464,9 @@ static const char *get_rev_name(const struct object *o, struct strbuf *buf)
505 464 if (!n)
506 465 return NULL;
507 466
508 - if (!n->generation) {
467 + if (!n->generation)
509 468 return n->tip_name;
510 - } else {
469 + else {
511 470 strbuf_reset(buf);
512 471 strbuf_addstr(buf, n->tip_name);
513 472 strbuf_strip_suffix(buf, "^0");
@@ -516,27 +475,6 @@ static const char *get_rev_name(const struct object *o, struct strbuf *buf)
516 475 }
517 476 }
518 477
519 - static const char *get_format_rev(const struct commit *c,
520 - struct pretty_format *format_ctx,
521 - struct strbuf *buf)
522 - {
523 - strbuf_reset(buf);
524 -
525 - if (format_ctx->want.notes) {
526 - struct strbuf notebuf = STRBUF_INIT;
527 -
528 - format_display_notes(&c->object.oid, &notebuf,
529 - get_log_output_encoding(),
530 - format_ctx->ctx.fmt == CMIT_FMT_USERFORMAT);
531 - format_ctx->ctx.notes_message = strbuf_detach(&notebuf, NULL);
532 - }
533 -
534 - pretty_print_commit(&format_ctx->ctx, c, buf);
535 - FREE_AND_NULL(format_ctx->ctx.notes_message);
536 -
537 - return buf->buf;
538 - }
539 -
540 478 static void show_name(const struct object *obj,
541 479 const char *caller_name,
542 480 int always, int allow_undefined, int name_only)
@@ -567,7 +505,7 @@ static char const * const name_rev_usage[] = {
567 505 NULL
568 506 };
569 507
570 - static void name_rev_line(char *p, struct command *cmd)
508 + static void name_rev_line(char *p, struct name_ref_data *data)
571 509 {
572 510 struct strbuf buf = STRBUF_INIT;
573 511 int counter = 0;
@@ -576,52 +514,33 @@ static void name_rev_line(char *p, struct command *cmd)
576 514
577 515 for (p_start = p; *p; p++) {
578 516 #define ishex(x) (isdigit((x)) || ((x) >= 'a' && (x) <= 'f'))
579 - if (!ishex(*p)) {
517 + if (!ishex(*p))
580 518 counter = 0;
581 - } else if (++counter == hexsz &&
582 - !ishex(*(p + 1))) {
519 + else if (++counter == hexsz &&
520 + !ishex(*(p+1))) {
583 521 struct object_id oid;
584 522 const char *name = NULL;
585 - char c = *(p + 1);
523 + char c = *(p+1);
586 524 int p_len = p - p_start + 1;
587 - struct object *o = NULL;
588 - int oid_ret = 1;
589 525
590 526 counter = 0;
591 527
592 - *(p + 1) = 0;
593 - oid_ret = repo_get_oid(the_repository, p - (hexsz - 1), &oid);
594 - *(p + 1) = c;
595 -
596 - switch (cmd->type) {
597 - case NAME_REV:
598 - if (!oid_ret)
599 - o = lookup_object(the_repository, &oid);
528 + *(p+1) = 0;
529 + if (!repo_get_oid(the_repository, p - (hexsz - 1), &oid)) {
530 + struct object *o =
531 + lookup_object(the_repository, &oid);
600 532 if (o)
601 533 name = get_rev_name(o, &buf);
602 - if (!name)
603 - continue;
604 - if (cmd->u.name_only)
605 - printf("%.*s%s", p_len - hexsz, p_start, name);
606 - else
607 - printf("%.*s (%s)", p_len, p_start, name);
608 - break;
609 - case FORMAT_REV:
610 - if (!oid_ret)
611 - o = parse_object(the_repository, &oid);
612 - if (o && o->type == OBJ_COMMIT)
613 - name = get_format_rev((const struct commit *)o,
614 - cmd->u.pretty_format,
615 - &buf);
616 - if (name)
617 - printf("%.*s%s", p_len - hexsz, p_start, name);
618 - else
619 - printf("%.*s", p_len, p_start);
620 - break;
621 - default:
622 - BUG("uncovered case: %d", cmd->type);
623 534 }
535 + *(p+1) = c;
624 536
537 + if (!name)
538 + continue;
539 +
540 + if (data->name_only)
541 + printf("%.*s%s", p_len - hexsz, p_start, name);
542 + else
543 + printf("%.*s (%s)", p_len, p_start, name);
625 544 p_start = p + 1;
626 545 }
627 546 }
@@ -646,14 +565,13 @@ int cmd_name_rev(int argc,
646 565 #endif
647 566 int all = 0, annotate_stdin = 0, allow_undefined = 1, always = 0, peel_tag = 0;
648 567 struct name_ref_data data = { 0, 0, STRING_LIST_INIT_NODUP, STRING_LIST_INIT_NODUP };
649 - struct command cmd;
650 568 struct option opts[] = {
651 569 OPT_BOOL(0, "name-only", &data.name_only, N_("print only ref-based names (no object names)")),
652 570 OPT_BOOL(0, "tags", &data.tags_only, N_("only use tags to name the commits")),
653 571 OPT_STRING_LIST(0, "refs", &data.ref_filters, N_("pattern"),
654 - N_("only use refs matching <pattern>")),
572 + N_("only use refs matching <pattern>")),
655 573 OPT_STRING_LIST(0, "exclude", &data.exclude_filters, N_("pattern"),
656 - N_("ignore refs matching <pattern>")),
574 + N_("ignore refs matching <pattern>")),
657 575 OPT_GROUP(""),
658 576 OPT_BOOL(0, "all", &all, N_("list all commits reachable from all refs")),
659 577 #ifndef WITH_BREAKING_CHANGES
@@ -665,10 +583,10 @@ int cmd_name_rev(int argc,
665 583 #endif /* WITH_BREAKING_CHANGES */
666 584 OPT_BOOL(0, "annotate-stdin", &annotate_stdin, N_("annotate text from stdin")),
667 585 OPT_BOOL(0, "undefined", &allow_undefined, N_("allow to print `undefined` names (default)")),
668 - OPT_BOOL(0, "always", &always,
669 - N_("show abbreviated commit object as fallback")),
586 + OPT_BOOL(0, "always", &always,
587 + N_("show abbreviated commit object as fallback")),
670 588 OPT_HIDDEN_BOOL(0, "peel-tag", &peel_tag,
671 - N_("dereference tags in the input (internal use)")),
589 + N_("dereference tags in the input (internal use)")),
672 590 OPT_END(),
673 591 };
674 592
@@ -676,7 +594,6 @@ int cmd_name_rev(int argc,
676 594 init_commit_rev_name(&rev_names);
677 595 repo_config(the_repository, git_default_config, NULL);
678 596 argc = parse_options(argc, argv, prefix, opts, name_rev_usage, 0);
679 - init_name_rev_command(&cmd, data.name_only);
680 597
681 598 #ifndef WITH_BREAKING_CHANGES
682 599 if (transform_stdin) {
@@ -744,7 +661,7 @@ int cmd_name_rev(int argc,
744 661
745 662 while (strbuf_getline(&sb, stdin) != EOF) {
746 663 strbuf_addch(&sb, '\n');
747 - name_rev_line(sb.buf, &cmd);
664 + name_rev_line(sb.buf, &data);
748 665 }
749 666 strbuf_release(&sb);
750 667 } else if (all) {
@@ -771,170 +688,3 @@ int cmd_name_rev(int argc,
771 688 object_array_clear(&revs);
772 689 return 0;
773 690 }
774 -
775 - struct format_nul_data {
776 - bool nul_input;
777 - bool nul_output;
778 - };
779 -
780 - static int format_nul_cb(const struct option *option,
781 - const char *arg,
782 - int unset)
783 - {
784 - struct format_nul_data *data = option->value;
785 - data->nul_input = 1;
786 - data->nul_output = 1;
787 - BUG_ON_OPT_NEG(unset);
788 - BUG_ON_OPT_ARG(arg);
789 - return 0;
790 - }
791 -
792 - static enum stdin_mode parse_stdin_mode(const char *stdin_mode)
793 - {
794 - if (!strcmp(stdin_mode, "text"))
795 - return TEXT;
796 - else if (!strcmp(stdin_mode, "revs") ||
797 - !strcmp(stdin_mode, "rev"))
798 - return REVS;
799 - else
800 - die(_("'%s' needs to be either text, revs, or rev"),
801 - "--stdin-mode");
802 - }
803 -
804 - static char const *const format_rev_usage[] = {
805 - N_("(EXPERIMENTAL!) git format-rev --stdin-mode=<mode> "
806 - "--format=<pretty> [--[no-]notes=<ref>] "
807 - "[-z] [--[no-]null-output] [--[no-]null-input]"),
808 - NULL
809 - };
810 -
811 - int cmd_format_rev(int argc,
812 - const char **argv,
813 - const char *prefix,
814 - struct repository *repo UNUSED)
815 - {
816 - const char *format = NULL;
817 - enum stdin_mode stdin_mode;
818 - const char *stdin_mode_arg = NULL;
819 - struct format_nul_data nul_data = { 0, 0 };
820 - char output_terminator;
821 - strbuf_getline_fn getline_fn;
822 - struct display_notes_opt format_notes_opt;
823 - struct rev_info format_rev = REV_INFO_INIT;
824 - struct pretty_format format_pp = { 0 };
825 - struct string_list notes = STRING_LIST_INIT_NODUP;
826 - struct strbuf scratch_buf = STRBUF_INIT;
827 - struct command cmd;
828 - struct option opts[] = {
829 - OPT_STRING(0, "format", &format, N_("format"),
830 - N_("pretty format to use")),
831 - OPT_STRING(0, "stdin-mode", &stdin_mode_arg, N_("stdin-mode"),
832 - N_("how revs are processed")),
833 - OPT_STRING_LIST(0, "notes", &notes, N_("notes"),
834 - N_("display notes for pretty format")),
835 - OPT_CALLBACK_F('z', "null", &nul_data, N_("z"),
836 - N_("Use NUL for input and output termination"),
837 - PARSE_OPT_NOARG | PARSE_OPT_NONEG, format_nul_cb),
838 - OPT_BOOL(0, "null-input", &nul_data.nul_input,
839 - N_("Use NUL for input termination")),
840 - OPT_BOOL(0, "null-output", &nul_data.nul_output,
841 - N_("Use NUL for output termination")),
842 - OPT_END(),
843 - };
844 -
845 - argc = parse_options(argc, argv, prefix, opts, format_rev_usage, 0);
846 -
847 - if (argc > 0) {
848 - error(_("too many arguments"));
849 - usage_with_options(format_rev_usage, opts);
850 - }
851 -
852 - if (!format)
853 - die(_("'%s' is required"), "--format");
854 - if (!stdin_mode_arg)
855 - die(_("'%s' is required"), "--stdin-mode");
856 -
857 - getline_fn = nul_data.nul_input ? strbuf_getline_nul : strbuf_getline_lf;
858 - output_terminator = nul_data.nul_output ? '\0' : '\n';
859 -
860 - init_display_notes(&format_notes_opt);
861 - stdin_mode = parse_stdin_mode(stdin_mode_arg);
862 -
863 - get_commit_format(format, &format_rev);
864 - format_pp.ctx.rev = &format_rev;
865 - format_pp.ctx.fmt = format_rev.commit_format;
866 - format_pp.ctx.abbrev = format_rev.abbrev;
867 - format_pp.ctx.date_mode_explicit = format_rev.date_mode_explicit;
868 - format_pp.ctx.date_mode = format_rev.date_mode;
869 - format_pp.ctx.color = GIT_COLOR_AUTO;
870 -
871 - userformat_find_requirements(format,
872 - &format_pp.want);
873 - if (format_pp.want.notes) {
874 - int ignore_show_notes = 0;
875 - struct string_list_item *n;
876 -
877 - for_each_string_list_item(n, &notes)
878 - enable_ref_display_notes(&format_notes_opt,
879 - &ignore_show_notes,
880 - n->string);
881 - load_display_notes(&format_notes_opt);
882 - }
883 -
884 - init_format_rev_command(&cmd, &format_pp);
885 -
886 - switch (stdin_mode) {
887 - case TEXT:
888 - while (getline_fn(&scratch_buf, stdin) != EOF) {
889 - name_rev_line(scratch_buf.buf, &cmd);
890 - /*
891 - * We do not pass on the terminator to name_rev_line,
892 - * unlike name-rev.
893 - */
894 - printf("%c", output_terminator);
895 - maybe_flush_or_die(stdout, "stdout");
896 - }
897 - break;
898 - case REVS:
899 - while (getline_fn(&scratch_buf, stdin) != EOF) {
900 - struct object_id oid;
901 - struct object *object;
902 - struct object *peeled;
903 -
904 - if (repo_get_oid(the_repository, scratch_buf.buf, &oid)) {
905 - fprintf(stderr, "Could not get object name for %s. Skipping.\n",
906 - scratch_buf.buf);
907 - continue;
908 - }
909 -
910 - object = parse_object(the_repository, &oid);
911 - if (!object) {
912 - fprintf(stderr, "Could not get object for %s. Skipping.\n",
913 - scratch_buf.buf);
914 - continue;
915 - }
916 -
917 - peeled = deref_tag(the_repository, object, scratch_buf.buf, 0);
918 - if (!peeled || peeled->type != OBJ_COMMIT) {
919 - fprintf(stderr,
920 - "Could not get commit for %s. Skipping.\n",
921 - scratch_buf.buf);
922 - continue;
923 - }
924 -
925 - get_format_rev((struct commit *)peeled,
926 - &format_pp, &scratch_buf);
927 - printf("%s%c", scratch_buf.buf, output_terminator);
928 - maybe_flush_or_die(stdout, "stdout");
929 - strbuf_release(&scratch_buf);
930 - }
931 - break;
932 - default:
933 - BUG("uncovered case: %d", stdin_mode);
934 - }
935 -
936 - strbuf_release(&scratch_buf);
937 - string_list_clear(&notes, 0);
938 - release_display_notes(&format_notes_opt);
939 - return 0;
940 - }
modified builtin/notes.c
@@ -150,7 +150,7 @@ static int list_each_note(const struct object_id *object_oid,
150 150
151 151 static void copy_obj_to_fd(int fd, const struct object_id *oid)
152 152 {
153 - size_t size;
153 + unsigned long size;
154 154 enum object_type type;
155 155 char *buf = odb_read_object(the_repository->objects, oid, &type, &size);
156 156 if (buf) {
@@ -313,7 +313,7 @@ static int parse_reuse_arg(const struct option *opt, const char *arg, int unset)
313 313 char *value;
314 314 struct object_id object;
315 315 enum object_type type;
316 - size_t len;
316 + unsigned long len;
317 317
318 318 BUG_ON_OPT_NEG(unset);
319 319
@@ -721,7 +721,7 @@ static int append_edit(int argc, const char **argv, const char *prefix,
721 721
722 722 if (note && !edit) {
723 723 /* Append buf to previous note contents */
724 - size_t size;
724 + unsigned long size;
725 725 enum object_type type;
726 726 struct strbuf buf = STRBUF_INIT;
727 727 char *prev_buf = odb_read_object(the_repository->objects, note, &type, &size);
@@ -989,7 +989,7 @@ static int merge(int argc, const char **argv, const char *prefix,
989 989 "NOTES_MERGE_PARTIAL", &result_oid, NULL,
990 990 0, UPDATE_REFS_DIE_ON_ERR);
991 991 /* Store ref-to-be-updated into .git/NOTES_MERGE_REF */
992 - worktrees = get_worktrees(the_repository);
992 + worktrees = get_worktrees();
993 993 wt = find_shared_symref(worktrees, "NOTES_MERGE_REF",
994 994 notes_ref);
995 995 if (wt)
modified builtin/pack-objects.c
@@ -32,7 +32,6 @@
32 32 #include "list.h"
33 33 #include "packfile.h"
34 34 #include "object-file.h"
35 - #include "object-file-convert.h"
36 35 #include "odb.h"
37 36 #include "odb/streaming.h"
38 37 #include "replace-object.h"
@@ -67,8 +66,8 @@ static inline struct object_entry *oe_delta(
67 66 return &pack->objects[e->delta_idx - 1];
68 67 }
69 68
70 - static inline size_t oe_delta_size(struct packing_data *pack,
71 - const struct object_entry *e)
69 + static inline unsigned long oe_delta_size(struct packing_data *pack,
70 + const struct object_entry *e)
72 71 {
73 72 if (e->delta_size_valid)
74 73 return e->delta_size_;
@@ -84,11 +83,11 @@ static inline size_t oe_delta_size(struct packing_data *pack,
84 83 return pack->delta_size[e - pack->objects];
85 84 }
86 85
87 - size_t oe_get_size_slow(struct packing_data *pack,
88 - const struct object_entry *e);
86 + unsigned long oe_get_size_slow(struct packing_data *pack,
87 + const struct object_entry *e);
89 88
90 - static inline size_t oe_size(struct packing_data *pack,
91 - const struct object_entry *e)
89 + static inline unsigned long oe_size(struct packing_data *pack,
90 + const struct object_entry *e)
92 91 {
93 92 if (e->size_valid)
94 93 return e->size_;
@@ -146,7 +145,7 @@ static inline void oe_set_delta_sibling(struct packing_data *pack,
146 145
147 146 static inline void oe_set_size(struct packing_data *pack,
148 147 struct object_entry *e,
149 - size_t size)
148 + unsigned long size)
150 149 {
151 150 if (size < pack->oe_size_limit) {
152 151 e->size_ = size;
@@ -160,7 +159,7 @@ static inline void oe_set_size(struct packing_data *pack,
160 159
161 160 static inline void oe_set_delta_size(struct packing_data *pack,
162 161 struct object_entry *e,
163 - size_t size)
162 + unsigned long size)
164 163 {
165 164 if (size < pack->oe_delta_size_limit) {
166 165 e->delta_size_ = size;
@@ -261,8 +260,8 @@ static int exclude_promisor_objects_best_effort;
261 260
262 261 static int use_delta_islands;
263 262
264 - static size_t delta_cache_size = 0;
265 - static size_t max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
263 + static unsigned long delta_cache_size = 0;
264 + static unsigned long max_delta_cache_size = DEFAULT_DELTA_CACHE_SIZE;
266 265 static unsigned long cache_max_small_delta_size = 1000;
267 266
268 267 static unsigned long window_memory_limit = 0;
@@ -354,21 +353,17 @@ static void index_commit_for_bitmap(struct commit *commit)
354 353
355 354 static void *get_delta(struct object_entry *entry)
356 355 {
357 - unsigned long size, base_size;
358 - size_t delta_size;
356 + unsigned long size, base_size, delta_size;
359 357 void *buf, *base_buf, *delta_buf;
360 358 enum object_type type;
361 - size_t size_st = 0, base_size_st = 0;
362 359
363 360 buf = odb_read_object(the_repository->objects, &entry->idx.oid,
364 - &type, &size_st);
365 - size = cast_size_t_to_ulong(size_st);
361 + &type, &size);
366 362 if (!buf)
367 363 die(_("unable to read %s"), oid_to_hex(&entry->idx.oid));
368 364 base_buf = odb_read_object(the_repository->objects,
369 365 &DELTA(entry)->idx.oid, &type,
370 - &base_size_st);
371 - base_size = cast_size_t_to_ulong(base_size_st);
366 + &base_size);
372 367 if (!base_buf)
373 368 die("unable to read %s",
374 369 oid_to_hex(&DELTA(entry)->idx.oid));
@@ -391,9 +386,8 @@ static unsigned long do_compress(void **pptr, unsigned long size)
391 386 git_zstream stream;
392 387 void *in, *out;
393 388 unsigned long maxsize;
394 - struct repo_config_values *cfg = repo_config_values(the_repository);
395 389
396 - git_deflate_init(&stream, cfg->pack_compression_level);
390 + git_deflate_init(&stream, pack_compression_level);
397 391 maxsize = git_deflate_bound(&stream, size);
398 392
399 393 in = *pptr;
@@ -412,21 +406,20 @@ static unsigned long do_compress(void **pptr, unsigned long size)
412 406 return stream.total_out;
413 407 }
414 408
415 - static unsigned long write_large_blob_data(struct odb_stream *st, struct hashfile *f,
409 + static unsigned long write_large_blob_data(struct odb_read_stream *st, struct hashfile *f,
416 410 const struct object_id *oid)
417 411 {
418 412 git_zstream stream;
419 413 unsigned char ibuf[1024 * 16];
420 414 unsigned char obuf[1024 * 16];
421 415 unsigned long olen = 0;
422 - struct repo_config_values *cfg = repo_config_values(the_repository);
423 416
424 - git_deflate_init(&stream, cfg->pack_compression_level);
417 + git_deflate_init(&stream, pack_compression_level);
425 418
426 419 for (;;) {
427 420 ssize_t readlen;
428 421 int zret = Z_OK;
429 - readlen = odb_stream_read(st, ibuf, sizeof(ibuf));
422 + readlen = odb_read_stream_read(st, ibuf, sizeof(ibuf));
430 423 if (readlen == -1)
431 424 die(_("unable to read %s"), oid_to_hex(oid));
432 425
@@ -460,7 +453,7 @@ static int check_pack_inflate(struct packed_git *p,
460 453 struct pack_window **w_curs,
461 454 off_t offset,
462 455 off_t len,
463 - size_t expect)
456 + unsigned long expect)
464 457 {
465 458 git_zstream stream;
466 459 unsigned char fakebuf[4096], *in;
@@ -489,7 +482,7 @@ static void copy_pack_data(struct hashfile *f,
489 482 off_t len)
490 483 {
491 484 unsigned char *in;
492 - size_t avail;
485 + unsigned long avail;
493 486
494 487 while (len) {
495 488 in = use_pack(p, w_curs, offset, &avail);
@@ -503,7 +496,7 @@ static void copy_pack_data(struct hashfile *f,
503 496
504 497 static inline int oe_size_greater_than(struct packing_data *pack,
505 498 const struct object_entry *lhs,
506 - size_t rhs)
499 + unsigned long rhs)
507 500 {
508 501 if (lhs->size_valid)
509 502 return lhs->size_ > rhs;
@@ -522,24 +515,22 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
522 515 unsigned hdrlen;
523 516 enum object_type type;
524 517 void *buf;
525 - struct odb_stream *st = NULL;
518 + struct odb_read_stream *st = NULL;
526 519 const unsigned hashsz = the_hash_algo->rawsz;
527 520
528 521 if (!usable_delta) {
529 522 if (oe_type(entry) == OBJ_BLOB &&
530 523 oe_size_greater_than(&to_pack, entry,
531 524 repo_settings_get_big_file_threshold(the_repository)) &&
532 - (st = odb_stream_from_object(the_repository->objects, &entry->idx.oid,
533 - NULL)) != NULL) {
525 + (st = odb_read_stream_open(the_repository->objects, &entry->idx.oid,
526 + NULL)) != NULL) {
534 527 buf = NULL;
535 528 type = st->type;
536 529 size = st->size;
537 530 } else {
538 - size_t size_st = 0;
539 531 buf = odb_read_object(the_repository->objects,
540 532 &entry->idx.oid, &type,
541 - &size_st);
542 - size = cast_size_t_to_ulong(size_st);
533 + &size);
543 534 if (!buf)
544 535 die(_("unable to read %s"),
545 536 oid_to_hex(&entry->idx.oid));
@@ -590,7 +581,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
590 581 dheader[--pos] = 128 | (--ofs & 127);
591 582 if (limit && hdrlen + sizeof(dheader) - pos + datalen + hashsz >= limit) {
592 583 if (st)
593 - odb_stream_close(st);
584 + odb_read_stream_close(st);
594 585 free(buf);
595 586 return 0;
596 587 }
@@ -604,7 +595,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
604 595 */
605 596 if (limit && hdrlen + hashsz + datalen + hashsz >= limit) {
606 597 if (st)
607 - odb_stream_close(st);
598 + odb_read_stream_close(st);
608 599 free(buf);
609 600 return 0;
610 601 }
@@ -614,7 +605,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
614 605 } else {
615 606 if (limit && hdrlen + datalen + hashsz >= limit) {
616 607 if (st)
617 - odb_stream_close(st);
608 + odb_read_stream_close(st);
618 609 free(buf);
619 610 return 0;
620 611 }
@@ -622,7 +613,7 @@ static unsigned long write_no_reuse_object(struct hashfile *f, struct object_ent
622 613 }
623 614 if (st) {
624 615 datalen = write_large_blob_data(st, f, &entry->idx.oid);
625 - odb_stream_close(st);
616 + odb_read_stream_close(st);
626 617 } else {
627 618 hashwrite(f, buf, datalen);
628 619 free(buf);
@@ -638,21 +629,14 @@ static off_t write_reuse_object(struct hashfile *f, struct object_entry *entry,
638 629 struct packed_git *p = IN_PACK(entry);
639 630 struct pack_window *w_curs = NULL;
640 631 uint32_t pos;
641 - off_t offset, cur;
632 + off_t offset;
642 633 enum object_type type = oe_type(entry);
643 - enum object_type in_pack_type;
644 634 off_t datalen;
645 635 unsigned char header[MAX_PACK_OBJECT_HEADER],
646 636 dheader[MAX_PACK_OBJECT_HEADER];
647 637 unsigned hdrlen;
648 638 const unsigned hashsz = the_hash_algo->rawsz;
649 - size_t entry_size;
650 -
651 - cur = entry->in_pack_offset;
652 - in_pack_type = unpack_object_header(p, &w_curs, &cur, &entry_size);
653 - if (in_pack_type < 0)
654 - die(_("write_reuse_object: unable to parse object header of %s"),
655 - oid_to_hex(&entry->idx.oid));
639 + unsigned long entry_size = SIZE(entry);
656 640
657 641 if (DELTA(entry))
658 642 type = (allow_ofs_delta && DELTA(entry)->idx.offset) ?
@@ -1103,7 +1087,7 @@ static void write_reused_pack_one(struct packed_git *reuse_packfile,
1103 1087 {
1104 1088 off_t offset, next, cur;
1105 1089 enum object_type type;
1106 - size_t size;
1090 + unsigned long size;
1107 1091
1108 1092 offset = pack_pos_to_offset(reuse_packfile, pos);
1109 1093 next = pack_pos_to_offset(reuse_packfile, pos + 1);
@@ -1338,7 +1322,6 @@ static void write_pack_file(void)
1338 1322 uint32_t nr_remaining = nr_result;
1339 1323 time_t last_mtime = 0;
1340 1324 struct object_entry **write_order;
1341 - off_t bytes_written = 0;
1342 1325
1343 1326 if (progress > pack_to_stdout)
1344 1327 progress_state = start_progress(the_repository,
@@ -1358,7 +1341,7 @@ static void write_pack_file(void)
1358 1341 * length of them as buffer length.
1359 1342 *
1360 1343 * Note that we need to subtract one though to
1361 - * accommodate for the sideband byte.
1344 + * accomodate for the sideband byte.
1362 1345 */
1363 1346 struct hashfd_options opts = {
1364 1347 .progress = progress_state,
@@ -1391,8 +1374,6 @@ static void write_pack_file(void)
1391 1374 display_progress(progress_state, written);
1392 1375 }
1393 1376
1394 - bytes_written += hashfile_total(f) +
1395 - the_repository->hash_algo->rawsz;
1396 1377 if (pack_to_stdout) {
1397 1378 /*
1398 1379 * We never fsync when writing to stdout since we may
@@ -1514,8 +1495,6 @@ static void write_pack_file(void)
1514 1495 written, nr_result);
1515 1496 trace2_data_intmax("pack-objects", the_repository,
1516 1497 "write_pack_file/wrote", nr_result);
1517 - trace2_data_intmax("pack-objects", the_repository,
1518 - "write_pack_file/wrote_bytes", bytes_written);
1519 1498 }
1520 1499
1521 1500 static int no_try_delta(const char *path)
@@ -1763,11 +1742,9 @@ static int want_object_in_pack_mtime(const struct object_id *oid,
1763 1742 * skip the local object source.
1764 1743 */
1765 1744 struct odb_source *source = the_repository->objects->sources->next;
1766 - for (; source; source = source->next) {
1767 - struct odb_source_files *files = odb_source_files_downcast(source);
1768 - if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL))
1745 + for (; source; source = source->next)
1746 + if (odb_source_loose_has_object(source, oid))
1769 1747 return 0;
1770 - }
1771 1748 }
1772 1749
1773 1750 /*
@@ -1785,12 +1762,13 @@ static int want_object_in_pack_mtime(const struct object_id *oid,
1785 1762 *found_offset = 0;
1786 1763 }
1787 1764
1765 + odb_prepare_alternates(the_repository->objects);
1766 +
1788 1767 for (source = the_repository->objects->sources; source; source = source->next) {
1789 - struct odb_source_files *files = odb_source_files_downcast(source);
1790 - struct multi_pack_index *m = get_multi_pack_index(files->packed);
1768 + struct multi_pack_index *m = get_multi_pack_index(source);
1791 1769 struct pack_entry e;
1792 1770
1793 - if (m && fill_midx_entry(m, oid, &e, NULL)) {
1771 + if (m && fill_midx_entry(m, oid, &e)) {
1794 1772 want = want_object_in_pack_one(e.p, oid, exclude, found_pack, found_offset, found_mtime);
1795 1773 if (want != -1)
1796 1774 return want;
@@ -1872,8 +1850,8 @@ static const char no_closure_warning[] = N_(
1872 1850 "disabling bitmap writing, as some objects are not being packed"
1873 1851 );
1874 1852
1875 - static void add_object_entry(const struct object_id *oid, enum object_type type,
1876 - const char *name, int exclude)
1853 + static int add_object_entry(const struct object_id *oid, enum object_type type,
1854 + const char *name, int exclude)
1877 1855 {
1878 1856 struct packed_git *found_pack = NULL;
1879 1857 off_t found_offset = 0;
@@ -1881,7 +1859,7 @@ static void add_object_entry(const struct object_id *oid, enum object_type type,
1881 1859 display_progress(progress_state, ++nr_seen);
1882 1860
1883 1861 if (have_duplicate_entry(oid, exclude))
1884 - return;
1862 + return 0;
1885 1863
1886 1864 if (!want_object_in_pack(oid, exclude, &found_pack, &found_offset)) {
1887 1865 /* The pack is missing an object, so it will not have closure */
@@ -1890,12 +1868,13 @@ static void add_object_entry(const struct object_id *oid, enum object_type type,
1890 1868 warning(_(no_closure_warning));
1891 1869 write_bitmap_index = 0;
1892 1870 }
1893 - return;
1871 + return 0;
1894 1872 }
1895 1873
1896 1874 create_object_entry(oid, type, pack_name_hash_fn(name),
1897 1875 exclude, name && no_try_delta(name),
1898 1876 found_pack, found_offset);
1877 + return 1;
1899 1878 }
1900 1879
1901 1880 static int add_object_entry_from_bitmap(const struct object_id *oid,
@@ -1913,7 +1892,7 @@ static int add_object_entry_from_bitmap(const struct object_id *oid,
1913 1892 return 0;
1914 1893
1915 1894 create_object_entry(oid, type, name_hash, 0, 0, pack, offset);
1916 - return 0;
1895 + return 1;
1917 1896 }
1918 1897
1919 1898 struct pbase_tree_cache {
@@ -1949,7 +1928,6 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
1949 1928 struct pbase_tree_cache *ent, *nent;
1950 1929 void *data;
1951 1930 unsigned long size;
1952 - size_t size_st = 0;
1953 1931 enum object_type type;
1954 1932 int neigh;
1955 1933 int my_ix = pbase_tree_cache_ix(oid);
@@ -1977,8 +1955,7 @@ static struct pbase_tree_cache *pbase_tree_get(const struct object_id *oid)
1977 1955 /* Did not find one. Either we got a bogus request or
1978 1956 * we need to read and perhaps cache.
1979 1957 */
1980 - data = odb_read_object(the_repository->objects, oid, &type, &size_st);
1981 - size = cast_size_t_to_ulong(size_st);
1958 + data = odb_read_object(the_repository->objects, oid, &type, &size);
1982 1959 if (!data)
1983 1960 return NULL;
1984 1961 if (type != OBJ_TREE) {
@@ -2133,15 +2110,13 @@ static void add_preferred_base(struct object_id *oid)
2133 2110 struct pbase_tree *it;
2134 2111 void *data;
2135 2112 unsigned long size;
2136 - size_t size_st = 0;
2137 2113 struct object_id tree_oid;
2138 2114
2139 2115 if (window <= num_preferred_base++)
2140 2116 return;
2141 2117
2142 2118 data = odb_read_object_peeled(the_repository->objects, oid,
2143 - OBJ_TREE, &size_st, &tree_oid);
2144 - size = cast_size_t_to_ulong(size_st);
2119 + OBJ_TREE, &size, &tree_oid);
2145 2120 if (!data)
2146 2121 return;
2147 2122
@@ -2253,7 +2228,7 @@ static void prefetch_to_pack(uint32_t object_index_start) {
2253 2228
2254 2229 static void check_object(struct object_entry *entry, uint32_t object_index)
2255 2230 {
2256 - size_t canonical_size;
2231 + unsigned long canonical_size;
2257 2232 enum object_type type;
2258 2233 struct object_info oi = {.typep = &type, .sizep = &canonical_size};
2259 2234
@@ -2263,11 +2238,12 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
2263 2238 int have_base = 0;
2264 2239 struct object_id base_ref;
2265 2240 struct object_entry *base_entry;
2266 - size_t used, used_0, avail;
2241 + unsigned long used, used_0;
2242 + unsigned long avail;
2267 2243 off_t ofs;
2268 2244 unsigned char *buf, c;
2269 2245 enum object_type type;
2270 - size_t in_pack_size;
2246 + unsigned long in_pack_size;
2271 2247
2272 2248 buf = use_pack(p, &w_curs, entry->in_pack_offset, &avail);
2273 2249
@@ -2372,8 +2348,7 @@ static void check_object(struct object_entry *entry, uint32_t object_index)
2372 2348 * object size from the delta header.
2373 2349 */
2374 2350 delta_pos = entry->in_pack_offset + entry->in_pack_header_size;
2375 - canonical_size = get_size_from_delta(p, &w_curs,
2376 - delta_pos);
2351 + canonical_size = get_size_from_delta(p, &w_curs, delta_pos);
2377 2352 if (canonical_size == 0)
2378 2353 goto give_up;
2379 2354 SET_SIZE(entry, canonical_size);
@@ -2451,7 +2426,7 @@ static void drop_reused_delta(struct object_entry *entry)
2451 2426 unsigned *idx = &to_pack.objects[entry->delta_idx - 1].delta_child_idx;
2452 2427 struct object_info oi = OBJECT_INFO_INIT;
2453 2428 enum object_type type;
2454 - size_t size;
2429 + unsigned long size;
2455 2430
2456 2431 while (*idx) {
2457 2432 struct object_entry *oe = &to_pack.objects[*idx - 1];
@@ -2466,7 +2441,7 @@ static void drop_reused_delta(struct object_entry *entry)
2466 2441
2467 2442 oi.sizep = &size;
2468 2443 oi.typep = &type;
2469 - if (packed_object_info(NULL, IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2444 + if (packed_object_info(IN_PACK(entry), entry->in_pack_offset, &oi) < 0) {
2470 2445 /*
2471 2446 * We failed to get the info from this pack for some reason;
2472 2447 * fall back to odb_read_object_info, which may find another copy.
@@ -2691,8 +2666,8 @@ struct unpacked {
2691 2666 unsigned depth;
2692 2667 };
2693 2668
2694 - static int delta_cacheable(size_t src_size, size_t trg_size,
2695 - size_t delta_size)
2669 + static int delta_cacheable(unsigned long src_size, unsigned long trg_size,
2670 + unsigned long delta_size)
2696 2671 {
2697 2672 if (max_delta_cache_size && delta_cache_size + delta_size > max_delta_cache_size)
2698 2673 return 0;
@@ -2729,7 +2704,7 @@ static pthread_mutex_t progress_mutex;
2729 2704
2730 2705 static inline int oe_size_less_than(struct packing_data *pack,
2731 2706 const struct object_entry *lhs,
2732 - size_t rhs)
2707 + unsigned long rhs)
2733 2708 {
2734 2709 if (lhs->size_valid)
2735 2710 return lhs->size_ < rhs;
@@ -2747,45 +2722,28 @@ static inline void oe_set_tree_depth(struct packing_data *pack,
2747 2722 pack->tree_depth[e - pack->objects] = tree_depth;
2748 2723 }
2749 2724
2750 - static void record_tree_depth(const struct object_id *oid, const char *name)
2751 - {
2752 - const char *p;
2753 - unsigned depth;
2754 - struct object_entry *ent;
2755 -
2756 - /* the empty string is a root tree, which is depth 0 */
2757 - depth = *name ? 1 : 0;
2758 - for (p = strchr(name, '/'); p; p = strchr(p + 1, '/'))
2759 - depth++;
2760 -
2761 - ent = packlist_find(&to_pack, oid);
2762 - if (ent && depth > oe_tree_depth(&to_pack, ent))
2763 - oe_set_tree_depth(&to_pack, ent, depth);
2764 - }
2765 -
2766 2725 /*
2767 2726 * Return the size of the object without doing any delta
2768 2727 * reconstruction (so non-deltas are true object sizes, but deltas
2769 2728 * return the size of the delta data).
2770 2729 */
2771 - size_t oe_get_size_slow(struct packing_data *pack,
2772 - const struct object_entry *e)
2730 + unsigned long oe_get_size_slow(struct packing_data *pack,
2731 + const struct object_entry *e)
2773 2732 {
2774 2733 struct packed_git *p;
2775 2734 struct pack_window *w_curs;
2776 2735 unsigned char *buf;
2777 2736 enum object_type type;
2778 - size_t used, avail, size;
2737 + unsigned long used, avail, size;
2779 2738
2780 2739 if (e->type_ != OBJ_OFS_DELTA && e->type_ != OBJ_REF_DELTA) {
2781 - size_t sz;
2782 2740 packing_data_lock(&to_pack);
2783 2741 if (odb_read_object_info(the_repository->objects,
2784 - &e->idx.oid, &sz) < 0)
2742 + &e->idx.oid, &size) < 0)
2785 2743 die(_("unable to get size of %s"),
2786 2744 oid_to_hex(&e->idx.oid));
2787 2745 packing_data_unlock(&to_pack);
2788 - return sz;
2746 + return size;
2789 2747 }
2790 2748
2791 2749 p = oe_in_pack(pack, e);
@@ -2806,12 +2764,11 @@ size_t oe_get_size_slow(struct packing_data *pack,
2806 2764 }
2807 2765
2808 2766 static int try_delta(struct unpacked *trg, struct unpacked *src,
2809 - unsigned max_depth, size_t *mem_usage)
2767 + unsigned max_depth, unsigned long *mem_usage)
2810 2768 {
2811 2769 struct object_entry *trg_entry = trg->entry;
2812 2770 struct object_entry *src_entry = src->entry;
2813 - unsigned long trg_size, src_size, sizediff, max_size, sz;
2814 - size_t delta_size;
2771 + unsigned long trg_size, src_size, delta_size, sizediff, max_size, sz;
2815 2772 unsigned ref_depth;
2816 2773 enum object_type type;
2817 2774 void *delta_buf;
@@ -2864,12 +2821,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
2864 2821
2865 2822 /* Load data if not already done */
2866 2823 if (!trg->data) {
2867 - size_t sz_st = 0;
2868 2824 packing_data_lock(&to_pack);
2869 2825 trg->data = odb_read_object(the_repository->objects,
2870 2826 &trg_entry->idx.oid, &type,
2871 - &sz_st);
2872 - sz = cast_size_t_to_ulong(sz_st);
2827 + &sz);
2873 2828 packing_data_unlock(&to_pack);
2874 2829 if (!trg->data)
2875 2830 die(_("object %s cannot be read"),
@@ -2881,12 +2836,10 @@ static int try_delta(struct unpacked *trg, struct unpacked *src,
2881 2836 *mem_usage += sz;
2882 2837 }
2883 2838 if (!src->data) {
2884 - size_t sz_st = 0;
2885 2839 packing_data_lock(&to_pack);
2886 2840 src->data = odb_read_object(the_repository->objects,
2887 2841 &src_entry->idx.oid, &type,
2888 - &sz_st);
2889 - sz = cast_size_t_to_ulong(sz_st);
2842 + &sz);
2890 2843 packing_data_unlock(&to_pack);
2891 2844 if (!src->data) {
2892 2845 if (src_entry->preferred_base) {
@@ -2975,9 +2928,9 @@ static unsigned int check_delta_limit(struct object_entry *me, unsigned int n)
2975 2928 return m;
2976 2929 }
2977 2930
2978 - static size_t free_unpacked(struct unpacked *n)
2931 + static unsigned long free_unpacked(struct unpacked *n)
2979 2932 {
2980 - size_t freed_mem = sizeof_delta_index(n->index);
2933 + unsigned long freed_mem = sizeof_delta_index(n->index);
2981 2934 free_delta_index(n->index);
2982 2935 n->index = NULL;
2983 2936 if (n->data) {
@@ -2994,7 +2947,7 @@ static void find_deltas(struct object_entry **list, unsigned *list_size,
2994 2947 {
2995 2948 uint32_t i, idx = 0, count = 0;
2996 2949 struct unpacked *array;
2997 - size_t mem_usage = 0;
2950 + unsigned long mem_usage = 0;
2998 2951
2999 2952 CALLOC_ARRAY(array, window);
3000 2953
@@ -3704,7 +3657,7 @@ static int git_pack_config(const char *k, const char *v,
3704 3657 return 0;
3705 3658 }
3706 3659 if (!strcmp(k, "pack.deltacachesize")) {
3707 - max_delta_cache_size = git_config_size_t(k, v, ctx->kvi);
3660 + max_delta_cache_size = git_config_int(k, v, ctx->kvi);
3708 3661 return 0;
3709 3662 }
3710 3663 if (!strcmp(k, "pack.deltacachelimit")) {
@@ -3823,7 +3776,7 @@ static int add_object_entry_from_pack(const struct object_id *oid,
3823 3776 ofs = nth_packed_object_offset(p, pos);
3824 3777
3825 3778 oi.typep = &type;
3826 - if (packed_object_info(NULL, p, ofs, &oi) < 0) {
3779 + if (packed_object_info(p, ofs, &oi) < 0) {
3827 3780 die(_("could not get type of object %s in pack %s"),
3828 3781 oid_to_hex(oid), p->pack_name);
3829 3782 } else if (type == OBJ_COMMIT) {
@@ -4090,10 +4043,9 @@ static void stdin_packs_read_input(struct rev_info *revs,
4090 4043
4091 4044 static void add_unreachable_loose_objects(struct rev_info *revs);
4092 4045
4093 - static void read_stdin_packs(struct repository *repo,
4094 - enum stdin_packs_mode mode, int rev_list_unpacked)
4046 + static void read_stdin_packs(enum stdin_packs_mode mode, int rev_list_unpacked)
4095 4047 {
4096 - int prev_fetch_if_missing = repo->fetch_if_missing;
4048 + int prev_fetch_if_missing = fetch_if_missing;
4097 4049 struct rev_info revs;
4098 4050
4099 4051 /*
@@ -4101,9 +4053,9 @@ static void read_stdin_packs(struct repository *repo,
4101 4053 * walk is best-effort though we don't want to perform backfill fetches
4102 4054 * for them.
4103 4055 */
4104 - repo->fetch_if_missing = 0;
4056 + fetch_if_missing = 0;
4105 4057
4106 - repo_init_revisions(repo, &revs, NULL);
4058 + repo_init_revisions(the_repository, &revs, NULL);
4107 4059 /*
4108 4060 * Use a revision walk to fill in the namehash of objects in the include
4109 4061 * packs. To save time, we'll avoid traversing through objects that are
@@ -4149,7 +4101,7 @@ static void read_stdin_packs(struct repository *repo,
4149 4101 trace2_data_intmax("pack-objects", the_repository, "stdin_packs_hints",
4150 4102 stdin_packs_hints_nr);
4151 4103
4152 - repo->fetch_if_missing = prev_fetch_if_missing;
4104 + fetch_if_missing = prev_fetch_if_missing;
4153 4105 }
4154 4106
4155 4107 static void add_cruft_object_entry(const struct object_id *oid, enum object_type type,
@@ -4173,11 +4125,9 @@ static void add_cruft_object_entry(const struct object_id *oid, enum object_type
4173 4125 struct odb_source *source = the_repository->objects->sources;
4174 4126 int found = 0;
4175 4127
4176 - for (; !found && source; source = source->next) {
4177 - struct odb_source_files *files = odb_source_files_downcast(source);
4178 - if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL))
4128 + for (; !found && source; source = source->next)
4129 + if (odb_source_loose_has_object(source, oid))
4179 4130 found = 1;
4180 - }
4181 4131
4182 4132 /*
4183 4133 * If a traversed tree has a missing blob then we want
@@ -4315,7 +4265,6 @@ static void enumerate_and_traverse_cruft_objects(struct string_list *fresh_packs
4315 4265 traverse_commit_list(&revs, show_cruft_commit, show_cruft_object, NULL);
4316 4266
4317 4267 stop_progress(&progress_state);
4318 - release_revisions(&revs);
4319 4268 }
4320 4269
4321 4270 static void read_cruft_objects(void)
@@ -4426,8 +4375,20 @@ static void show_object(struct object *obj, const char *name,
4426 4375 add_preferred_base_object(name);
4427 4376 add_object_entry(&obj->oid, obj->type, name, 0);
4428 4377
4429 - if (use_delta_islands)
4430 - record_tree_depth(&obj->oid, name);
4378 + if (use_delta_islands) {
4379 + const char *p;
4380 + unsigned depth;
4381 + struct object_entry *ent;
4382 +
4383 + /* the empty string is a root tree, which is depth 0 */
4384 + depth = *name ? 1 : 0;
4385 + for (p = strchr(name, '/'); p; p = strchr(p + 1, '/'))
4386 + depth++;
4387 +
4388 + ent = packlist_find(&to_pack, &obj->oid);
4389 + if (ent && depth > oe_tree_depth(&to_pack, ent))
4390 + oe_set_tree_depth(&to_pack, ent, depth);
4391 + }
4431 4392 }
4432 4393
4433 4394 static void show_object__ma_allow_any(struct object *obj, const char *name, void *data)
@@ -4459,11 +4420,9 @@ static void show_object__ma_allow_promisor(struct object *obj, const char *name,
4459 4420 show_object(obj, name, data);
4460 4421 }
4461 4422
4462 - static int option_parse_missing_action(const struct option *opt,
4423 + static int option_parse_missing_action(const struct option *opt UNUSED,
4463 4424 const char *arg, int unset)
4464 4425 {
4465 - struct repository *repo = opt->value;
4466 -
4467 4426 assert(arg);
4468 4427 assert(!unset);
4469 4428
@@ -4475,14 +4434,14 @@ static int option_parse_missing_action(const struct option *opt,
4475 4434
4476 4435 if (!strcmp(arg, "allow-any")) {
4477 4436 arg_missing_action = MA_ALLOW_ANY;
4478 - repo->fetch_if_missing = 0;
4437 + fetch_if_missing = 0;
4479 4438 fn_show_object = show_object__ma_allow_any;
4480 4439 return 0;
4481 4440 }
4482 4441
4483 4442 if (!strcmp(arg, "allow-promisor")) {
4484 4443 arg_missing_action = MA_ALLOW_PROMISOR;
4485 - repo->fetch_if_missing = 0;
4444 + fetch_if_missing = 0;
4486 4445 fn_show_object = show_object__ma_allow_promisor;
4487 4446 return 0;
4488 4447 }
@@ -4501,9 +4460,8 @@ static int add_object_in_unpacked_pack(const struct object_id *oid,
4501 4460 void *data UNUSED)
4502 4461 {
4503 4462 if (cruft) {
4504 - add_cruft_object_entry(oid, OBJ_NONE, oi->source_infop->u.packed.pack,
4505 - oi->source_infop->u.packed.offset, NULL,
4506 - *oi->mtimep);
4463 + add_cruft_object_entry(oid, OBJ_NONE, oi->u.packed.pack,
4464 + oi->u.packed.offset, NULL, *oi->mtimep);
4507 4465 } else {
4508 4466 add_object_entry(oid, OBJ_NONE, "", 0);
4509 4467 }
@@ -4520,20 +4478,19 @@ static void add_objects_in_unpacked_packs(void)
4520 4478 ODB_FOR_EACH_OBJECT_SKIP_IN_CORE_KEPT_PACKS |
4521 4479 ODB_FOR_EACH_OBJECT_SKIP_ON_DISK_KEPT_PACKS,
4522 4480 };
4523 - struct odb_source_info source_info;
4524 4481 struct object_info oi = {
4525 4482 .mtimep = &mtime,
4526 - .source_infop = &source_info,
4527 4483 };
4528 4484
4485 + odb_prepare_alternates(to_pack.repo->objects);
4529 4486 for (source = to_pack.repo->objects->sources; source; source = source->next) {
4530 4487 struct odb_source_files *files = odb_source_files_downcast(source);
4531 4488
4532 4489 if (!source->local)
4533 4490 continue;
4534 4491
4535 - if (odb_source_for_each_object(&files->packed->base, &oi,
4536 - add_object_in_unpacked_pack, NULL, &opts))
4492 + if (packfile_store_for_each_object(files->packed, &oi,
4493 + add_object_in_unpacked_pack, NULL, &opts))
4537 4494 die(_("cannot open pack index"));
4538 4495 }
4539 4496 }
@@ -4627,51 +4584,6 @@ static int loosened_object_can_be_discarded(const struct object_id *oid,
4627 4584 return 1;
4628 4585 }
4629 4586
4630 - static int force_object_loose(struct odb_source *source,
4631 - const struct object_id *oid,
4632 - const time_t *mtime)
4633 - {
4634 - struct odb_source_files *files = odb_source_files_downcast(source);
4635 - const struct git_hash_algo *compat = source->odb->repo->compat_hash_algo;
4636 - struct object_info oi = OBJECT_INFO_INIT;
4637 - struct object_id compat_oid, *compat_oid_p = NULL;
4638 - enum object_type type;
4639 - void *buf = NULL;
4640 - size_t len;
4641 - int ret;
4642 -
4643 - for (struct odb_source *s = source->odb->sources; s; s = s->next) {
4644 - struct odb_source_files *files = odb_source_files_downcast(s);
4645 - if (!odb_source_read_object_info(&files->loose->base, oid, NULL, 0, NULL))
4646 - return 0;
4647 - }
4648 -
4649 - oi.typep = &type;
4650 - oi.sizep = &len;
4651 - oi.contentp = &buf;
4652 - if (odb_read_object_info_extended(source->odb, oid, &oi, 0)) {
4653 - ret = error(_("cannot read object for %s"), oid_to_hex(oid));
4654 - goto out;
4655 - }
4656 -
4657 - if (compat) {
4658 - if (repo_oid_to_algop(source->odb->repo, oid, compat, &compat_oid)) {
4659 - ret = error(_("cannot map object %s to %s"),
4660 - oid_to_hex(oid), compat->name);
4661 - goto out;
4662 - }
4663 -
4664 - compat_oid_p = &compat_oid;
4665 - }
4666 -
4667 - ret = odb_source_write_object(&files->loose->base, buf, len, type, oid,
4668 - compat_oid_p, mtime, 0);
4669 -
4670 - out:
4671 - free(buf);
4672 - return ret;
4673 - }
4674 -
4675 4587 static void loosen_unused_packed_objects(void)
4676 4588 {
4677 4589 struct packed_git *p;
@@ -4692,7 +4604,7 @@ static void loosen_unused_packed_objects(void)
4692 4604 !has_sha1_pack_kept_or_nonlocal(&oid) &&
4693 4605 !loosened_object_can_be_discarded(&oid, p->mtime)) {
4694 4606 if (force_object_loose(the_repository->objects->sources,
4695 - &oid, &p->mtime))
4607 + &oid, p->mtime))
4696 4608 die(_("unable to force loose object"));
4697 4609 loosened_objects_nr++;
4698 4610 }
@@ -4820,31 +4732,6 @@ static int add_objects_by_path(const char *path,
4820 4732 continue;
4821 4733
4822 4734 add_object_entry(oid, type, path, exclude);
4823 -
4824 - if (type == OBJ_COMMIT) {
4825 - struct commit *commit;
4826 -
4827 - if (!write_bitmap_index && !use_delta_islands)
4828 - continue;
4829 -
4830 - commit = lookup_commit(the_repository, oid);
4831 - if (!commit)
4832 - die(_("could not find commit %s"), oid_to_hex(oid));
4833 - if (write_bitmap_index)
4834 - index_commit_for_bitmap(commit);
4835 - /*
4836 - * Skip island propagation for boundary commits.
4837 - * The regular traversal's show_commit() is only
4838 - * called for interesting commits; matching that
4839 - * here keeps path-walk from doing extra work that
4840 - * would only be a no-op anyway (boundary commits
4841 - * are not in island_marks).
4842 - */
4843 - if (use_delta_islands && !exclude)
4844 - propagate_island_marks(the_repository, commit);
4845 - } else if (type == OBJ_TREE && use_delta_islands) {
4846 - record_tree_depth(oid, path);
4847 - }
4848 4735 }
4849 4736
4850 4737 oe_end = to_pack.nr_objects;
@@ -4867,7 +4754,7 @@ static int add_objects_by_path(const char *path,
4867 4754 return 0;
4868 4755 }
4869 4756
4870 - static int get_object_list_path_walk(struct rev_info *revs)
4757 + static void get_object_list_path_walk(struct rev_info *revs)
4871 4758 {
4872 4759 struct path_walk_info info = PATH_WALK_INFO_INIT;
4873 4760 unsigned int processed = 0;
@@ -4877,13 +4764,6 @@ static int get_object_list_path_walk(struct rev_info *revs)
4877 4764 info.path_fn = add_objects_by_path;
4878 4765 info.path_fn_data = &processed;
4879 4766
4880 - /*
4881 - * Path-walk needs boundary commits to discover thin-pack bases, but
4882 - * bitmap traversal does not understand the boundary state. Set it
4883 - * here so any prior bitmap attempt sees the usual non-boundary walk.
4884 - */
4885 - revs->boundary = 1;
4886 -
4887 4767 /*
4888 4768 * Allow the --[no-]sparse option to be interesting here, if only
4889 4769 * for testing purposes. Paths with no interesting objects will not
@@ -4897,9 +4777,8 @@ static int get_object_list_path_walk(struct rev_info *revs)
4897 4777 result = walk_objects_by_path(&info);
4898 4778 trace2_region_leave("pack-objects", "path-walk", revs->repo);
4899 4779
4900 - path_walk_info_clear(&info);
4901 -
4902 - return result;
4780 + if (result)
4781 + die(_("failed to pack objects via path-walk"));
4903 4782 }
4904 4783
4905 4784 static void get_object_list(struct rev_info *revs, struct strvec *argv)
@@ -4907,7 +4786,6 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
4907 4786 struct setup_revision_opt s_r_opt = {
4908 4787 .allow_exclude_promisor_objects = 1,
4909 4788 };
4910 - struct repo_config_values *cfg = repo_config_values(the_repository);
4911 4789 char line[1000];
4912 4790 int flags = 0;
4913 4791 int save_warning;
@@ -4918,8 +4796,8 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
4918 4796 /* make sure shallows are read */
4919 4797 is_repository_shallow(the_repository);
4920 4798
4921 - save_warning = cfg->warn_on_object_refname_ambiguity;
4922 - cfg->warn_on_object_refname_ambiguity = 0;
4799 + save_warning = warn_on_object_refname_ambiguity;
4800 + warn_on_object_refname_ambiguity = 0;
4923 4801
4924 4802 while (fgets(line, sizeof(line), stdin) != NULL) {
4925 4803 int len = strlen(line);
@@ -4947,7 +4825,7 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
4947 4825 die(_("bad revision '%s'"), line);
4948 4826 }
4949 4827
4950 - cfg->warn_on_object_refname_ambiguity = save_warning;
4828 + warn_on_object_refname_ambiguity = save_warning;
4951 4829
4952 4830 if (use_bitmap_index && !get_object_list_from_bitmap(revs))
4953 4831 return;
@@ -4963,13 +4841,8 @@ static void get_object_list(struct rev_info *revs, struct strvec *argv)
4963 4841 fn_show_object = show_object;
4964 4842
4965 4843 if (path_walk) {
4966 - if (get_object_list_path_walk(revs)) {
4967 - warning(_("failed to pack objects via path-walk"));
4968 - path_walk = 0;
4969 - }
4970 - }
4971 -
4972 - if (!path_walk) {
4844 + get_object_list_path_walk(revs);
4845 + } else {
4973 4846 if (prepare_revision_walk(revs))
4974 4847 die(_("revision walk setup failed"));
4975 4848 mark_edges_uninteresting(revs, show_edge, sparse);
@@ -5089,14 +4962,10 @@ static int option_parse_cruft_expiration(const struct option *opt UNUSED,
5089 4962
5090 4963 static int is_not_in_promisor_pack_obj(struct object *obj, void *data UNUSED)
5091 4964 {
5092 - struct odb_source_info source_info;
5093 - struct object_info info = {
5094 - .source_infop = &source_info,
5095 - };
5096 -
4965 + struct object_info info = OBJECT_INFO_INIT;
5097 4966 if (odb_read_object_info_extended(the_repository->objects, &obj->oid, &info, 0))
5098 4967 BUG("should_include_obj should only be called on existing objects");
5099 - return source_info.source->type != ODB_SOURCE_PACKED || !source_info.u.packed.pack->pack_promisor;
4968 + return info.whence != OI_PACKED || !info.u.packed.pack->pack_promisor;
5100 4969 }
5101 4970
5102 4971 static int is_not_in_promisor_pack(struct commit *commit, void *data) {
@@ -5123,7 +4992,7 @@ static int parse_stdin_packs_mode(const struct option *opt, const char *arg,
5123 4992 int cmd_pack_objects(int argc,
5124 4993 const char **argv,
5125 4994 const char *prefix,
5126 - struct repository *repo)
4995 + struct repository *repo UNUSED)
5127 4996 {
5128 4997 int use_internal_rev_list = 0;
5129 4998 int all_progress_implied = 0;
@@ -5134,7 +5003,6 @@ int cmd_pack_objects(int argc,
5134 5003 struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
5135 5004 struct list_objects_filter_options filter_options =
5136 5005 LIST_OBJECTS_FILTER_INIT;
5137 - struct repo_config_values *cfg = repo_config_values(the_repository);
5138 5006
5139 5007 struct option pack_objects_options[] = {
5140 5008 OPT_CALLBACK_F('q', "quiet", &progress, NULL,
@@ -5216,7 +5084,7 @@ int cmd_pack_objects(int argc,
5216 5084 N_("ignore packs that have companion .keep file")),
5217 5085 OPT_STRING_LIST(0, "keep-pack", &keep_pack_list, N_("name"),
5218 5086 N_("ignore this pack")),
5219 - OPT_INTEGER(0, "compression", &cfg->pack_compression_level,
5087 + OPT_INTEGER(0, "compression", &pack_compression_level,
5220 5088 N_("pack compression level")),
5221 5089 OPT_BOOL(0, "keep-true-parents", &grafts_keep_true_parents,
5222 5090 N_("do not hide commits by grafts")),
@@ -5230,7 +5098,7 @@ int cmd_pack_objects(int argc,
5230 5098 N_("write a bitmap index if possible"),
5231 5099 WRITE_BITMAP_QUIET, PARSE_OPT_HIDDEN),
5232 5100 OPT_PARSE_LIST_OBJECTS_FILTER(&filter_options),
5233 - OPT_CALLBACK_F(0, "missing", repo, N_("action"),
5101 + OPT_CALLBACK_F(0, "missing", NULL, N_("action"),
5234 5102 N_("handling for missing objects"), PARSE_OPT_NONEG,
5235 5103 option_parse_missing_action),
5236 5104 OPT_BOOL(0, "exclude-promisor-objects", &exclude_promisor_objects,
@@ -5309,8 +5177,10 @@ int cmd_pack_objects(int argc,
5309 5177
5310 5178 if (path_walk) {
5311 5179 const char *option = NULL;
5312 - if (!path_walk_filter_compatible(&filter_options))
5180 + if (filter_options.choice)
5313 5181 option = "--filter";
5182 + else if (use_delta_islands)
5183 + option = "--delta-islands";
5314 5184
5315 5185 if (option) {
5316 5186 warning(_("cannot use %s with %s"),
@@ -5319,7 +5189,12 @@ int cmd_pack_objects(int argc,
5319 5189 }
5320 5190 }
5321 5191 if (path_walk) {
5322 - strvec_push(&rp, "--objects");
5192 + strvec_push(&rp, "--boundary");
5193 + /*
5194 + * We must disable the bitmaps because we are removing
5195 + * the --objects / --objects-edge[-aggressive] options.
5196 + */
5197 + use_bitmap_index = 0;
5323 5198 } else if (thin) {
5324 5199 use_internal_rev_list = 1;
5325 5200 strvec_push(&rp, shallow
@@ -5350,7 +5225,7 @@ int cmd_pack_objects(int argc,
5350 5225 exclude_promisor_objects_best_effort,
5351 5226 "--exclude-promisor-objects-best-effort");
5352 5227 if (exclude_promisor_objects) {
5353 - repo->fetch_if_missing = 0;
5228 + fetch_if_missing = 0;
5354 5229
5355 5230 /* --stdin-packs handles promisor objects separately. */
5356 5231 if (!stdin_packs) {
@@ -5359,9 +5234,8 @@ int cmd_pack_objects(int argc,
5359 5234 }
5360 5235 } else if (exclude_promisor_objects_best_effort) {
5361 5236 use_internal_rev_list = 1;
5362 - arg_missing_action = MA_ALLOW_ANY;
5363 - repo->fetch_if_missing = 0;
5364 - fn_show_object = show_object__ma_allow_any;
5237 + fetch_if_missing = 0;
5238 + option_parse_missing_action(NULL, "allow-any", 0);
5365 5239 /* revs configured below */
5366 5240 }
5367 5241 if (unpack_unreachable || keep_unreachable || pack_loose_unreachable)
@@ -5369,10 +5243,10 @@ int cmd_pack_objects(int argc,
5369 5243
5370 5244 if (!reuse_object)
5371 5245 reuse_delta = 0;
5372 - if (cfg->pack_compression_level == -1)
5373 - cfg->pack_compression_level = Z_DEFAULT_COMPRESSION;
5374 - else if (cfg->pack_compression_level < 0 || cfg->pack_compression_level > Z_BEST_COMPRESSION)
5375 - die(_("bad pack compression level %d"), cfg->pack_compression_level);
5246 + if (pack_compression_level == -1)
5247 + pack_compression_level = Z_DEFAULT_COMPRESSION;
5248 + else if (pack_compression_level < 0 || pack_compression_level > Z_BEST_COMPRESSION)
5249 + die(_("bad pack compression level %d"), pack_compression_level);
5376 5250
5377 5251 if (!delta_search_threads) /* --threads=0 means autodetect */
5378 5252 delta_search_threads = online_cpus();
@@ -5477,7 +5351,7 @@ int cmd_pack_objects(int argc,
5477 5351 progress_state = start_progress(the_repository,
5478 5352 _("Enumerating objects"), 0);
5479 5353 if (stdin_packs) {
5480 - read_stdin_packs(repo, stdin_packs, rev_list_unpacked);
5354 + read_stdin_packs(stdin_packs, rev_list_unpacked);
5481 5355 } else if (cruft) {
5482 5356 read_cruft_objects();
5483 5357 } else if (!use_internal_rev_list) {
modified builtin/patch-id.c
@@ -73,7 +73,7 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu
73 73 char pre_oid_str[GIT_MAX_HEXSZ + 1], post_oid_str[GIT_MAX_HEXSZ + 1];
74 74 struct git_hash_ctx ctx;
75 75
76 - git_hash_init(&ctx, the_hash_algo);
76 + the_hash_algo->init_fn(&ctx);
77 77 oidclr(result, the_repository->hash_algo);
78 78
79 79 while (strbuf_getwholeline(line_buf, stdin, '\n') != EOF) {
@@ -173,7 +173,6 @@ static size_t get_one_patchid(struct object_id *next_oid, struct object_id *resu
173 173 oidclr(next_oid, the_repository->hash_algo);
174 174
175 175 flush_one_hunk(result, &ctx);
176 - git_hash_discard(&ctx);
177 176
178 177 return patchlen;
179 178 }
modified builtin/prune.c
@@ -194,7 +194,7 @@ int cmd_prune(int argc,
194 194 if (show_progress == -1)
195 195 show_progress = isatty(2);
196 196 if (exclude_promisor_objects) {
197 - repo->fetch_if_missing = 0;
197 + fetch_if_missing = 0;
198 198 revs.exclude_promisor_objects = 1;
199 199 }
200 200
modified builtin/pull.c
@@ -612,7 +612,7 @@ static const char *get_tracking_branch(const char *remote, const char *refspec)
612 612 const char *spec_src;
613 613 const char *merge_branch;
614 614
615 - if (!refspec_item_init_fetch(&spec, refspec, the_hash_algo))
615 + if (!refspec_item_init_fetch(&spec, refspec))
616 616 die(_("invalid refspec '%s'"), refspec);
617 617 spec_src = spec.src;
618 618 if (!*spec_src || !strcmp(spec_src, "HEAD"))
@@ -996,13 +996,9 @@ int cmd_pull(int argc,
996 996 OPT_PASSTHRU('6', "ipv6", &opt_ipv6, NULL,
997 997 N_("use IPv6 addresses only"),
998 998 PARSE_OPT_NOARG),
999 - OPT_PASSTHRU_ARGV(0, "negotiation-restrict", &opt_fetch, N_("revision"),
999 + OPT_PASSTHRU_ARGV(0, "negotiation-tip", &opt_fetch, N_("revision"),
1000 1000 N_("report that we have only objects reachable from this object"),
1001 1001 0),
1002 - OPT_ALIAS(0, "negotiation-tip", "negotiation-restrict"),
1003 - OPT_PASSTHRU_ARGV(0, "negotiation-include", &opt_fetch, N_("revision"),
1004 - N_("ensure this ref is always sent as a negotiation have"),
1005 - 0),
1006 1002 OPT_BOOL(0, "show-forced-updates", &opt_show_forced_updates,
1007 1003 N_("check for forced-updates on all updated branches")),
1008 1004 OPT_PASSTHRU(0, "set-upstream", &set_upstream, NULL,
modified builtin/push.c
@@ -8,10 +8,8 @@
8 8 #include "advice.h"
9 9 #include "branch.h"
10 10 #include "config.h"
11 - #include "dir.h"
12 11 #include "environment.h"
13 12 #include "gettext.h"
14 - #include "hex.h"
15 13 #include "refspec.h"
16 14 #include "run-command.h"
17 15 #include "remote.h"
@@ -66,7 +64,7 @@ static enum transport_family family;
66 64
67 65 static struct push_cas_option cas;
68 66
69 - static struct refspec rs;
67 + static struct refspec rs = REFSPEC_INIT_PUSH;
70 68
71 69 static struct string_list push_options_config = STRING_LIST_INIT_DUP;
72 70
@@ -74,7 +72,6 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref,
74 72 struct remote *remote, struct ref *matched)
75 73 {
76 74 const char *branch_name;
77 - struct repo_config_values *cfg = repo_config_values(the_repository);
78 75
79 76 if (remote->push.nr) {
80 77 struct refspec_item query = {
@@ -90,7 +87,7 @@ static void refspec_append_mapped(struct refspec *refspec, const char *ref,
90 87 }
91 88 }
92 89
93 - if (cfg->push_default == PUSH_DEFAULT_UPSTREAM &&
90 + if (push_default == PUSH_DEFAULT_UPSTREAM &&
94 91 skip_prefix(matched->name, "refs/heads/", &branch_name)) {
95 92 struct branch *branch = branch_get(branch_name);
96 93 if (branch->merge_nr == 1 && branch->merge[0]->src) {
@@ -162,7 +159,7 @@ static NORETURN void die_push_simple(struct branch *branch,
162 159 * Don't show advice for people who explicitly set
163 160 * push.default.
164 161 */
165 - if (cfg->push_default == PUSH_DEFAULT_UNSPECIFIED)
162 + if (push_default == PUSH_DEFAULT_UNSPECIFIED)
166 163 advice_pushdefault_maybe = _("\n"
167 164 "To choose either option permanently, "
168 165 "see push.default in 'git help config'.\n");
@@ -233,9 +230,8 @@ static void setup_default_push_refspecs(int *flags, struct remote *remote)
233 230 struct branch *branch;
234 231 const char *dst;
235 232 int same_remote;
236 - struct repo_config_values *cfg = repo_config_values(the_repository);
237 233
238 - switch (cfg->push_default) {
234 + switch (push_default) {
239 235 case PUSH_DEFAULT_MATCHING:
240 236 refspec_append(&rs, ":");
241 237 return;
@@ -255,7 +251,7 @@ static void setup_default_push_refspecs(int *flags, struct remote *remote)
255 251 dst = branch->refname;
256 252 same_remote = !strcmp(remote->name, remote_for_branch(branch, NULL));
257 253
258 - switch (cfg->push_default) {
254 + switch (push_default) {
259 255 default:
260 256 case PUSH_DEFAULT_UNSPECIFIED:
261 257 case PUSH_DEFAULT_SIMPLE:
@@ -548,146 +544,6 @@ static int git_push_config(const char *k, const char *v,
548 544 return git_default_config(k, v, ctx, NULL);
549 545 }
550 546
551 - static int push_multiple(struct string_list *list,
552 - const struct string_list *push_options,
553 - int flags,
554 - int tags,
555 - const char **refspecs,
556 - int refspec_nr)
557 - {
558 - int result = 0;
559 - size_t i;
560 - struct strvec argv = STRVEC_INIT;
561 -
562 - strvec_push(&argv, "push");
563 -
564 - if (flags & TRANSPORT_PUSH_FORCE)
565 - strvec_push(&argv, "--force");
566 - if (flags & TRANSPORT_PUSH_DRY_RUN)
567 - strvec_push(&argv, "--dry-run");
568 - if (flags & TRANSPORT_PUSH_PORCELAIN)
569 - strvec_push(&argv, "--porcelain");
570 - if (flags & TRANSPORT_PUSH_PRUNE)
571 - strvec_push(&argv, "--prune");
572 - if (flags & TRANSPORT_PUSH_NO_HOOK)
573 - strvec_push(&argv, "--no-verify");
574 - if (flags & TRANSPORT_PUSH_FOLLOW_TAGS)
575 - strvec_push(&argv, "--follow-tags");
576 - if (flags & TRANSPORT_PUSH_SET_UPSTREAM)
577 - strvec_push(&argv, "--set-upstream");
578 - if (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES)
579 - strvec_push(&argv, "--force-if-includes");
580 - if (flags & TRANSPORT_PUSH_ALL)
581 - strvec_push(&argv, "--all");
582 - if (flags & TRANSPORT_PUSH_MIRROR)
583 - strvec_push(&argv, "--mirror");
584 -
585 - if (flags & TRANSPORT_PUSH_CERT_ALWAYS)
586 - strvec_push(&argv, "--signed=yes");
587 - else if (flags & TRANSPORT_PUSH_CERT_IF_ASKED)
588 - strvec_push(&argv, "--signed=if-asked");
589 - if (!thin)
590 - strvec_push(&argv, "--no-thin");
591 -
592 - if (deleterefs)
593 - strvec_push(&argv, "--delete");
594 -
595 - if (receivepack)
596 - strvec_pushf(&argv, "--receive-pack=%s", receivepack);
597 - if (verbosity >= 2)
598 - strvec_push(&argv, "-v");
599 - if (verbosity >= 1)
600 - strvec_push(&argv, "-v");
601 - else if (verbosity < 0)
602 - strvec_push(&argv, "-q");
603 - if (progress > 0)
604 - strvec_push(&argv, "--progress");
605 - else if (progress == 0)
606 - strvec_push(&argv, "--no-progress");
607 -
608 - if (family == TRANSPORT_FAMILY_IPV4)
609 - strvec_push(&argv, "--ipv4");
610 - else if (family == TRANSPORT_FAMILY_IPV6)
611 - strvec_push(&argv, "--ipv6");
612 -
613 - if (recurse_submodules == RECURSE_SUBMODULES_CHECK)
614 - strvec_push(&argv, "--recurse-submodules=check");
615 - else if (recurse_submodules == RECURSE_SUBMODULES_ON_DEMAND)
616 - strvec_push(&argv, "--recurse-submodules=on-demand");
617 - else if (recurse_submodules == RECURSE_SUBMODULES_ONLY)
618 - strvec_push(&argv, "--recurse-submodules=only");
619 - else if (recurse_submodules == RECURSE_SUBMODULES_OFF)
620 - strvec_push(&argv, "--recurse-submodules=no");
621 -
622 -
623 - if (tags)
624 - strvec_push(&argv, "--tags");
625 -
626 - for (i = 0; i < push_options->nr; i++)
627 - strvec_pushf(&argv, "--push-option=%s",
628 - push_options->items[i].string);
629 -
630 - for (i = 0; i < cas.nr; i++) {
631 - if (cas.entry[i].use_tracking) {
632 - strvec_pushf(&argv, "--force-with-lease=%s",
633 - cas.entry[i].refname);
634 - } else if (!is_null_oid(&cas.entry[i].expect)) {
635 - strvec_pushf(&argv, "--force-with-lease=%s:%s",
636 - cas.entry[i].refname,
637 - oid_to_hex(&cas.entry[i].expect));
638 - } else {
639 - strvec_push(&argv, "--force-with-lease");
640 - }
641 - }
642 -
643 - for (i = 0; i < list->nr; i++) {
644 - const char *name = list->items[i].string;
645 - struct child_process cmd = CHILD_PROCESS_INIT;
646 - int j;
647 -
648 - strvec_pushv(&cmd.args, argv.v);
649 - strvec_push(&cmd.args, name);
650 -
651 - for (j = 0; j < refspec_nr; j++)
652 - strvec_push(&cmd.args, refspecs[j]);
653 -
654 - if (verbosity >= 0)
655 - printf(_("Pushing to %s\n"), name);
656 -
657 - cmd.git_cmd = 1;
658 - if (run_command(&cmd)) {
659 - error(_("could not push to %s"), name);
660 - result = 1;
661 - }
662 - }
663 -
664 - strvec_clear(&argv);
665 - return result;
666 - }
667 -
668 - static void die_if_repo_looks_like_ref(const char *repo)
669 - {
670 - const char *slash = strchr(repo, '/');
671 - struct strbuf name = STRBUF_INIT;
672 - int code;
673 -
674 - if (!slash || !slash[1] || file_exists(repo))
675 - return;
676 -
677 - strbuf_add(&name, repo, slash - repo);
678 - if (!remote_is_configured(remote_get(name.buf), 0)) {
679 - strbuf_release(&name);
680 - return;
681 - }
682 -
683 - code = die_message(_("'%s' is not a valid push target"), repo);
684 - advise_if_enabled(ADVICE_PUSH_REPO_LOOKS_LIKE_REF,
685 - _("Did you mean to use: git push %s %s?"),
686 - name.buf, slash + 1);
687 - strbuf_release(&name);
688 - exit(code);
689 - }
690 -
691 547 int cmd_push(int argc,
692 548 const char **argv,
693 549 const char *prefix,
@@ -696,13 +552,12 @@ int cmd_push(int argc,
696 552 int flags = 0;
697 553 int tags = 0;
698 554 int push_cert = -1;
699 - int rc = 0;
700 - int base_flags;
555 + int rc;
701 556 const char *repo = NULL; /* default repository */
702 557 struct string_list push_options_cmdline = STRING_LIST_INIT_DUP;
703 - struct string_list remote_group = STRING_LIST_INIT_DUP;
704 558 struct string_list *push_options;
705 559 const struct string_list_item *item;
560 + struct remote *remote;
706 561
707 562 struct option options[] = {
708 563 OPT__VERBOSITY(&verbosity),
@@ -751,8 +606,6 @@ int cmd_push(int argc,
751 606 : &push_options_config);
752 607 set_push_cert_flags(&flags, push_cert);
753 608
754 - refspec_init_push(&rs, the_hash_algo);
755 -
756 609 die_for_incompatible_opt4(deleterefs, "--delete",
757 610 tags, "--tags",
758 611 flags & TRANSPORT_PUSH_ALL, "--all/--branches",
@@ -767,56 +620,39 @@ int cmd_push(int argc,
767 620 else if (recurse_submodules == RECURSE_SUBMODULES_ONLY)
768 621 flags |= TRANSPORT_RECURSE_SUBMODULES_ONLY;
769 622
623 + if (tags)
624 + refspec_append(&rs, "refs/tags/*");
625 +
770 626 if (argc > 0)
771 627 repo = argv[0];
772 628
773 - if (repo) {
774 - if (!add_remote_or_group(repo, &remote_group)) {
775 - struct remote *r;
776 -
777 - /*
778 - * Check the advice up front to avoid the remote
779 - * lookup when the hint is off. The helper still
780 - * calls advise_if_enabled() so the hint carries the
781 - * standard "disable this message" instructions.
782 - */
783 - if (advice_enabled(ADVICE_PUSH_REPO_LOOKS_LIKE_REF))
784 - die_if_repo_looks_like_ref(repo);
785 -
786 - /*
787 - * Not a configured remote name or group name.
788 - * Try treating it as a direct URL or path, e.g.
789 - * git push /tmp/foo.git
790 - * git push https://github.com/user/repo.git
791 - * pushremote_get() creates an anonymous remote
792 - * from the URL so the loop below can handle it
793 - * identically to a named remote.
794 - */
795 - r = pushremote_get(repo);
796 - if (!r)
797 - die(_("bad repository '%s'"), repo);
798 - string_list_append(&remote_group, r->name);
799 - }
800 - } else {
801 - struct remote *r = pushremote_get(NULL);
802 - if (!r)
803 - die(_("No configured push destination.\n"
804 - "Either specify the URL from the command-line or configure a remote repository using\n"
805 - "\n"
806 - " git remote add <name> <url>\n"
807 - "\n"
808 - "and then push using the remote name\n"
809 - "\n"
810 - " git push <name>\n"
811 - "\n"
812 - "To push to multiple remotes at once, configure a remote group using\n"
813 - "\n"
814 - " git config remotes.<groupname> \"<remote1> <remote2>\"\n"
815 - "\n"
816 - "and then push using the group name\n"
817 - "\n"
818 - " git push <groupname>\n"));
819 - string_list_append(&remote_group, r->name);
629 + remote = pushremote_get(repo);
630 + if (!remote) {
631 + if (repo)
632 + die(_("bad repository '%s'"), repo);
633 + die(_("No configured push destination.\n"
634 + "Either specify the URL from the command-line or configure a remote repository using\n"
635 + "\n"
636 + " git remote add <name> <url>\n"
637 + "\n"
638 + "and then push using the remote name\n"
639 + "\n"
640 + " git push <name>\n"));
641 + }
642 +
643 + if (argc > 0)
644 + set_refspecs(argv + 1, argc - 1, remote);
645 +
646 + if (remote->mirror)
647 + flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
648 +
649 + if (flags & TRANSPORT_PUSH_ALL) {
650 + if (argc >= 2)
651 + die(_("--all can't be combined with refspecs"));
652 + }
653 + if (flags & TRANSPORT_PUSH_MIRROR) {
654 + if (argc >= 2)
655 + die(_("--mirror can't be combined with refspecs"));
820 656 }
821 657
822 658 if (!is_empty_cas(&cas) && (flags & TRANSPORT_PUSH_FORCE_IF_INCLUDES))
@@ -826,70 +662,10 @@ int cmd_push(int argc,
826 662 if (strchr(item->string, '\n'))
827 663 die(_("push options must not have new line characters"));
828 664
829 - if (remote_group.nr == 1) {
830 - /*
831 - * Single remote (the common case): run do_push() directly
832 - * in this process. The loop runs exactly once.
833 - *
834 - * Mirror detection and the --mirror/--all + refspec conflict
835 - * checks are done here. rs is rebuilt so that per-remote push
836 - * mappings (remote.NAME.push config) are resolved against the
837 - * correct remote. inner_flags is a snapshot of flags so that a
838 - * mirror remote cannot bleed TRANSPORT_PUSH_FORCE into any
839 - * subsequent call.
840 - */
841 - base_flags = flags;
842 - {
843 - int inner_flags = base_flags;
844 - struct remote *r = pushremote_get(remote_group.items[0].string);
845 - if (!r)
846 - die(_("no such remote or remote group: %s"),
847 - remote_group.items[0].string);
848 -
849 - if (r->mirror)
850 - inner_flags |= (TRANSPORT_PUSH_MIRROR|TRANSPORT_PUSH_FORCE);
851 -
852 - if (inner_flags & TRANSPORT_PUSH_ALL) {
853 - if (argc >= 2)
854 - die(_("--all can't be combined with refspecs"));
855 - }
856 - if (inner_flags & TRANSPORT_PUSH_MIRROR) {
857 - if (argc >= 2)
858 - die(_("--mirror can't be combined with refspecs"));
859 - }
860 -
861 - refspec_clear(&rs);
862 - rs = (struct refspec) REFSPEC_INIT_PUSH(the_hash_algo);
863 -
864 - if (tags)
865 - refspec_append(&rs, "refs/tags/*");
866 - if (argc > 0)
867 - set_refspecs(argv + 1, argc - 1, r);
868 -
869 - rc = do_push(inner_flags, push_options, r);
870 - }
871 - } else {
872 - /*
873 - * Multiple remotes: spawn one "git push <remote> [<refspecs>]"
874 - * subprocess per remote, sequentially.
875 - *
876 - * Options that only make sense for a single transport connection
877 - * are rejected here.
878 - */
879 - if (flags & TRANSPORT_PUSH_ATOMIC)
880 - die(_("--atomic can only be used when pushing to one remote"));
881 -
882 - rc = push_multiple(&remote_group, push_options, flags,
883 - tags,
884 - argc > 1 ? argv + 1 : NULL,
885 - argc > 1 ? argc - 1 : 0);
886 - }
887 -
665 + rc = do_push(flags, push_options, remote);
888 666 string_list_clear(&push_options_cmdline, 0);
889 667 string_list_clear(&push_options_config, 0);
890 - string_list_clear(&remote_group, 0);
891 668 clear_cas_option(&cas);
892 -
893 669 if (rc == -1)
894 670 usage_with_options(push_usage, options);
895 671 else
modified builtin/read-tree.c
@@ -229,7 +229,7 @@ int cmd_read_tree(int argc,
229 229 opts.preserve_ignored = 0;
230 230 /* otherwise, opts.preserve_ignored is irrelevant */
231 231 if (opts.merge && !opts.index_only)
232 - setup_work_tree(the_repository);
232 + setup_work_tree();
233 233
234 234 if (opts.skip_sparse_checkout)
235 235 ensure_full_index(the_repository->index);
modified builtin/rebase.c
@@ -592,7 +592,7 @@ static int finish_rebase(struct rebase_options *opts)
592 592 static int move_to_original_branch(struct rebase_options *opts)
593 593 {
594 594 struct strbuf branch_reflog = STRBUF_INIT, head_reflog = STRBUF_INIT;
595 - struct reset_working_tree_options ropts = { 0 };
595 + struct reset_head_opts ropts = { 0 };
596 596 int ret;
597 597
598 598 if (!opts->head_name)
@@ -607,11 +607,10 @@ static int move_to_original_branch(struct rebase_options *opts)
607 607 strbuf_addf(&head_reflog, "%s (finish): returning to %s",
608 608 opts->reflog_action, opts->head_name);
609 609 ropts.branch = opts->head_name;
610 - ropts.flags = RESET_WORKING_TREE_REFS_ONLY |
611 - RESET_WORKING_TREE_UPDATE_HEAD;
610 + ropts.flags = RESET_HEAD_REFS_ONLY;
612 611 ropts.branch_msg = branch_reflog.buf;
613 612 ropts.head_msg = head_reflog.buf;
614 - ret = reset_working_tree(the_repository, &ropts);
613 + ret = reset_head(the_repository, &ropts);
615 614
616 615 strbuf_release(&branch_reflog);
617 616 strbuf_release(&head_reflog);
@@ -686,7 +685,7 @@ static int run_am(struct rebase_options *opts)
686 685
687 686 status = run_command(&format_patch);
688 687 if (status) {
689 - struct reset_working_tree_options ropts = { 0 };
688 + struct reset_head_opts ropts = { 0 };
690 689 unlink(rebased_patches);
691 690 free(rebased_patches);
692 691 child_process_clear(&am);
@@ -694,8 +693,7 @@ static int run_am(struct rebase_options *opts)
694 693 ropts.oid = &opts->orig_head->object.oid;
695 694 ropts.branch = opts->head_name;
696 695 ropts.default_reflog_action = opts->reflog_action;
697 - ropts.flags = RESET_WORKING_TREE_UPDATE_HEAD;
698 - reset_working_tree(the_repository, &ropts);
696 + reset_head(the_repository, &ropts);
699 697 error(_("\ngit encountered an error while preparing the "
700 698 "patches to replay\n"
701 699 "these revisions:\n"
@@ -857,19 +855,18 @@ static int rebase_config(const char *var, const char *value,
857 855 static int checkout_up_to_date(struct rebase_options *options)
858 856 {
859 857 struct strbuf buf = STRBUF_INIT;
860 - struct reset_working_tree_options ropts = { 0 };
858 + struct reset_head_opts ropts = { 0 };
861 859 int ret = 0;
862 860
863 861 strbuf_addf(&buf, "%s: checkout %s",
864 862 options->reflog_action, options->switch_to);
865 863 ropts.oid = &options->orig_head->object.oid;
866 864 ropts.branch = options->head_name;
867 - ropts.flags = RESET_WORKING_TREE_RUN_POST_CHECKOUT_HOOK |
868 - RESET_WORKING_TREE_UPDATE_HEAD;
865 + ropts.flags = RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
869 866 if (!ropts.branch)
870 - ropts.flags |= RESET_WORKING_TREE_DETACH;
867 + ropts.flags |= RESET_HEAD_DETACH;
871 868 ropts.head_msg = buf.buf;
872 - if (reset_working_tree(the_repository, &ropts) < 0)
869 + if (reset_head(the_repository, &ropts) < 0)
873 870 ret = error(_("could not switch to %s"), options->switch_to);
874 871 strbuf_release(&buf);
875 872
@@ -1119,7 +1116,7 @@ int cmd_rebase(int argc,
1119 1116 int reschedule_failed_exec = -1;
1120 1117 int allow_preemptive_ff = 1;
1121 1118 int preserve_merges_selected = 0;
1122 - struct reset_working_tree_options ropts = { 0 };
1119 + struct reset_head_opts ropts = { 0 };
1123 1120 struct option builtin_rebase_options[] = {
1124 1121 OPT_STRING(0, "onto", &options.onto_name,
1125 1122 N_("revision"),
@@ -1387,9 +1384,8 @@ int cmd_rebase(int argc,
1387 1384
1388 1385 rerere_clear(the_repository, &merge_rr);
1389 1386 string_list_clear(&merge_rr, 1);
1390 - ropts.flags = RESET_WORKING_TREE_HARD |
1391 - RESET_WORKING_TREE_UPDATE_HEAD;
1392 - if (reset_working_tree(the_repository, &ropts) < 0)
1387 + ropts.flags = RESET_HEAD_HARD;
1388 + if (reset_head(the_repository, &ropts) < 0)
1393 1389 die(_("could not discard worktree changes"));
1394 1390 remove_branch_state(the_repository, 0);
1395 1391 if (read_basic_state(&options))
@@ -1413,9 +1409,8 @@ int cmd_rebase(int argc,
1413 1409 ropts.oid = &options.orig_head->object.oid;
1414 1410 ropts.head_msg = head_msg.buf;
1415 1411 ropts.branch = options.head_name;
1416 - ropts.flags = RESET_WORKING_TREE_HARD |
1417 - RESET_WORKING_TREE_UPDATE_HEAD;
1418 - if (reset_working_tree(the_repository, &ropts) < 0)
1412 + ropts.flags = RESET_HEAD_HARD;
1413 + if (reset_head(the_repository, &ropts) < 0)
1419 1414 die(_("could not move back to %s"),
1420 1415 oid_to_hex(&options.orig_head->object.oid));
1421 1416 strbuf_release(&head_msg);
@@ -1881,13 +1876,11 @@ int cmd_rebase(int argc,
1881 1876 options.reflog_action, options.onto_name);
1882 1877 ropts.oid = &options.onto->object.oid;
1883 1878 ropts.orig_head = &options.orig_head->object.oid;
1884 - ropts.flags = RESET_WORKING_TREE_DETACH |
1885 - RESET_WORKING_TREE_UPDATE_HEAD |
1886 - RESET_WORKING_TREE_UPDATE_ORIG_HEAD |
1887 - RESET_WORKING_TREE_RUN_POST_CHECKOUT_HOOK;
1879 + ropts.flags = RESET_HEAD_DETACH | RESET_ORIG_HEAD |
1880 + RESET_HEAD_RUN_POST_CHECKOUT_HOOK;
1888 1881 ropts.head_msg = msg.buf;
1889 1882 ropts.default_reflog_action = options.reflog_action;
1890 - if (reset_working_tree(the_repository, &ropts)) {
1883 + if (reset_head(the_repository, &ropts)) {
1891 1884 ret = error(_("Could not detach HEAD"));
1892 1885 goto cleanup_autostash;
1893 1886 }
modified builtin/receive-pack.c
@@ -15,6 +15,7 @@
15 15 #include "gpg-interface.h"
16 16 #include "hex.h"
17 17 #include "hook.h"
18 + #include "lockfile.h"
18 19 #include "object.h"
19 20 #include "object-file.h"
20 21 #include "object-name.h"
@@ -22,6 +23,7 @@
22 23 #include "oid-array.h"
23 24 #include "oidset.h"
24 25 #include "pack.h"
26 + #include "packfile.h"
25 27 #include "parse-options.h"
26 28 #include "pkt-line.h"
27 29 #include "protocol.h"
@@ -35,6 +37,7 @@
35 37 #include "sigchain.h"
36 38 #include "string-list.h"
37 39 #include "strvec.h"
40 + #include "tmp-objdir.h"
38 41 #include "trace.h"
39 42 #include "trace2.h"
40 43 #include "version.h"
@@ -60,9 +63,12 @@ static enum deny_action deny_delete_current = DENY_UNCONFIGURED;
60 63 static int receive_fsck_objects = -1;
61 64 static int transfer_fsck_objects = -1;
62 65 static struct strbuf fsck_msg_types = STRBUF_INIT;
66 + static int receive_unpack_limit = -1;
67 + static int transfer_unpack_limit = -1;
63 68 static int advertise_atomic_push = 1;
64 69 static int advertise_push_options;
65 70 static int advertise_sid;
71 + static int unpack_limit = 100;
66 72 static off_t max_input_size;
67 73 static int report_status;
68 74 static int report_status_v2;
@@ -81,6 +87,7 @@ static const char *head_name;
81 87 static void *head_name_to_free;
82 88 static int sent_capabilities;
83 89 static int shallow_update;
90 + static const char *alt_shallow_file;
84 91 static struct strbuf push_cert = STRBUF_INIT;
85 92 static struct object_id push_cert_oid;
86 93 static struct signature_check sigcheck;
@@ -105,6 +112,8 @@ static enum {
105 112 } use_keepalive;
106 113 static int keepalive_in_sec = 5;
107 114
115 + static struct tmp_objdir *tmp_objdir;
116 +
108 117 static struct proc_receive_ref {
109 118 unsigned int want_add:1,
110 119 want_delete:1,
@@ -152,6 +161,16 @@ static int receive_pack_config(const char *var, const char *value,
152 161 return 0;
153 162 }
154 163
164 + if (strcmp(var, "receive.unpacklimit") == 0) {
165 + receive_unpack_limit = git_config_int(var, value, ctx->kvi);
166 + return 0;
167 + }
168 +
169 + if (strcmp(var, "transfer.unpacklimit") == 0) {
170 + transfer_unpack_limit = git_config_int(var, value, ctx->kvi);
171 + return 0;
172 + }
173 +
155 174 if (strcmp(var, "receive.fsck.skiplist") == 0) {
156 175 char *path;
157 176
@@ -596,7 +615,7 @@ static void hmac_hash(unsigned char *out,
596 615 /* RFC 2104 2. (1) */
597 616 memset(key, '\0', GIT_MAX_BLKSZ);
598 617 if (the_hash_algo->blksz < key_len) {
599 - git_hash_init(&ctx, the_hash_algo);
618 + the_hash_algo->init_fn(&ctx);
600 619 git_hash_update(&ctx, key_in, key_len);
601 620 git_hash_final(key, &ctx);
602 621 } else {
@@ -610,13 +629,13 @@ static void hmac_hash(unsigned char *out,
610 629 }
611 630
612 631 /* RFC 2104 2. (3) & (4) */
613 - git_hash_init(&ctx, the_hash_algo);
632 + the_hash_algo->init_fn(&ctx);
614 633 git_hash_update(&ctx, k_ipad, sizeof(k_ipad));
615 634 git_hash_update(&ctx, text, text_len);
616 635 git_hash_final(out, &ctx);
617 636
618 637 /* RFC 2104 2. (6) & (7) */
619 - git_hash_init(&ctx, the_hash_algo);
638 + the_hash_algo->init_fn(&ctx);
620 639 git_hash_update(&ctx, k_opad, sizeof(k_opad));
621 640 git_hash_update(&ctx, out, the_hash_algo->rawsz);
622 641 git_hash_final(out, &ctx);
@@ -907,7 +926,6 @@ static void receive_hook_feed_state_free(void *data)
907 926 static int run_receive_hook(struct command *commands,
908 927 const char *hook_name,
909 928 int skip_broken,
910 - struct odb_transaction *transaction,
911 929 const struct string_list *push_options)
912 930 {
913 931 struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
@@ -941,8 +959,8 @@ static int run_receive_hook(struct command *commands,
941 959 strvec_push(&opt.env, "GIT_PUSH_OPTION_COUNT");
942 960 }
943 961
944 - if (transaction)
945 - odb_transaction_env(transaction, &opt.env);
962 + if (tmp_objdir)
963 + strvec_pushv(&opt.env, tmp_objdir_env(tmp_objdir));
946 964
947 965 prepare_push_cert_sha1(&opt);
948 966
@@ -1345,6 +1363,7 @@ static int update_shallow_ref(struct command *cmd, struct shallow_info *si)
1345 1363 !delayed_reachability_test(si, i))
1346 1364 oid_array_append(&extra, &si->shallow->oid[i]);
1347 1365
1366 + opt.env = tmp_objdir_env(tmp_objdir);
1348 1367 setup_alternate_shallow(&shallow_lock, &opt.shallow_file, &extra);
1349 1368 if (check_connected(command_singleton_iterator, cmd, &opt)) {
1350 1369 rollback_shallow_file(the_repository, &shallow_lock);
@@ -1437,12 +1456,11 @@ static const char *push_to_checkout(unsigned char *hash,
1437 1456 struct strvec *env,
1438 1457 const char *work_tree)
1439 1458 {
1440 - struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
1441 -
1459 + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
1442 1460 opt.invoked_hook = invoked_hook;
1443 1461
1462 + strvec_pushf(env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
1444 1463 strvec_pushv(&opt.env, env->v);
1445 - strvec_pushf(&opt.env, "GIT_WORK_TREE=%s", absolute_path(work_tree));
1446 1464 strvec_push(&opt.args, hash_to_hex(hash));
1447 1465 if (run_hooks_opt(the_repository, push_to_checkout_hook, &opt))
1448 1466 return "push-to-checkout hook declined";
@@ -1484,7 +1502,7 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1484 1502 struct object_id *old_oid = &cmd->old_oid;
1485 1503 struct object_id *new_oid = &cmd->new_oid;
1486 1504 int do_update_worktree = 0;
1487 - struct worktree **worktrees = get_worktrees(the_repository);
1505 + struct worktree **worktrees = get_worktrees();
1488 1506 const struct worktree *worktree =
1489 1507 find_shared_symref(worktrees, "HEAD", name);
1490 1508
@@ -1623,8 +1641,8 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1623 1641 ret = NULL; /* good */
1624 1642 }
1625 1643 strbuf_release(&err);
1626 - } else {
1627 - enum ref_transaction_error tx_err;
1644 + }
1645 + else {
1628 1646 struct strbuf err = STRBUF_INIT;
1629 1647 if (shallow_update && si->shallow_ref[cmd->index] &&
1630 1648 update_shallow_ref(cmd, si)) {
@@ -1632,18 +1650,14 @@ static const char *update(struct command *cmd, struct shallow_info *si)
1632 1650 goto out;
1633 1651 }
1634 1652
1635 - tx_err = ref_transaction_update(transaction,
1636 - namespaced_name,
1637 - new_oid, old_oid,
1638 - NULL, NULL,
1639 - 0, "push",
1640 - &err);
1641 - if (tx_err) {
1653 + if (ref_transaction_update(transaction,
1654 + namespaced_name,
1655 + new_oid, old_oid,
1656 + NULL, NULL,
1657 + 0, "push",
1658 + &err)) {
1642 1659 rp_error("%s", err.buf);
1643 - if (tx_err == REF_TRANSACTION_ERROR_GENERIC)
1644 - ret = "failed to update ref";
1645 - else
1646 - ret = ref_transaction_error_msg(tx_err);
1660 + ret = "failed to update ref";
1647 1661 } else {
1648 1662 ret = NULL; /* good */
1649 1663 }
@@ -1771,30 +1785,24 @@ static const struct object_id *command_singleton_iterator(void *cb_data)
1771 1785 }
1772 1786
1773 1787 static void set_connectivity_errors(struct command *commands,
1774 - struct shallow_info *si,
1775 - struct odb_transaction *transaction)
1788 + struct shallow_info *si)
1776 1789 {
1777 1790 struct command *cmd;
1778 1791
1779 1792 for (cmd = commands; cmd; cmd = cmd->next) {
1780 1793 struct command *singleton = cmd;
1781 1794 struct check_connected_options opt = CHECK_CONNECTED_INIT;
1782 - struct strvec env = STRVEC_INIT;
1783 1795
1784 1796 if (shallow_update && si->shallow_ref[cmd->index])
1785 1797 /* to be checked in update_shallow_ref() */
1786 1798 continue;
1787 1799
1788 - odb_transaction_env(transaction, &env);
1789 - opt.env = env.v;
1790 -
1800 + opt.env = tmp_objdir_env(tmp_objdir);
1791 1801 if (!check_connected(command_singleton_iterator, &singleton,
1792 1802 &opt))
1793 1803 continue;
1794 1804
1795 1805 cmd->error_string = "missing necessary objects";
1796 -
1797 - strvec_clear(&env);
1798 1806 }
1799 1807 }
1800 1808
@@ -2013,9 +2021,8 @@ cleanup:
2013 2021 }
2014 2022
2015 2023 static void execute_commands(struct command *commands,
2016 - int unpacker_error,
2024 + const char *unpacker_error,
2017 2025 struct shallow_info *si,
2018 - struct odb_transaction *transaction,
2019 2026 const struct string_list *push_options)
2020 2027 {
2021 2028 struct check_connected_options opt = CHECK_CONNECTED_INIT;
@@ -2032,8 +2039,6 @@ static void execute_commands(struct command *commands,
2032 2039 }
2033 2040
2034 2041 if (!skip_connectivity_check) {
2035 - struct strvec env = STRVEC_INIT;
2036 -
2037 2042 if (use_sideband) {
2038 2043 memset(&muxer, 0, sizeof(muxer));
2039 2044 muxer.proc = copy_to_sideband;
@@ -2047,17 +2052,14 @@ static void execute_commands(struct command *commands,
2047 2052 data.si = si;
2048 2053 opt.err_fd = err_fd;
2049 2054 opt.progress = err_fd && !quiet;
2050 - odb_transaction_env(transaction, &env);
2051 - opt.env = env.v;
2055 + opt.env = tmp_objdir_env(tmp_objdir);
2052 2056 opt.exclude_hidden_refs_section = "receive";
2053 2057
2054 2058 if (check_connected(iterate_receive_command_list, &data, &opt))
2055 - set_connectivity_errors(commands, si, transaction);
2059 + set_connectivity_errors(commands, si);
2056 2060
2057 2061 if (use_sideband)
2058 2062 finish_async(&muxer);
2059 -
2060 - strvec_clear(&env);
2061 2063 }
2062 2064
2063 2065 reject_updates_to_hidden(commands);
@@ -2078,7 +2080,7 @@ static void execute_commands(struct command *commands,
2078 2080 }
2079 2081 }
2080 2082
2081 - if (run_receive_hook(commands, "pre-receive", 0, transaction, push_options)) {
2083 + if (run_receive_hook(commands, "pre-receive", 0, push_options)) {
2082 2084 for (cmd = commands; cmd; cmd = cmd->next) {
2083 2085 if (!cmd->error_string)
2084 2086 cmd->error_string = "pre-receive hook declined";
@@ -2099,13 +2101,14 @@ static void execute_commands(struct command *commands,
2099 2101 * Now we'll start writing out refs, which means the objects need
2100 2102 * to be in their final positions so that other processes can see them.
2101 2103 */
2102 - if (odb_transaction_commit(transaction)) {
2104 + if (tmp_objdir_migrate(tmp_objdir) < 0) {
2103 2105 for (cmd = commands; cmd; cmd = cmd->next) {
2104 2106 if (!cmd->error_string)
2105 2107 cmd->error_string = "unable to migrate objects to permanent storage";
2106 2108 }
2107 2109 return;
2108 2110 }
2111 + tmp_objdir = NULL;
2109 2112
2110 2113 check_aliased_updates(commands);
2111 2114
@@ -2290,44 +2293,161 @@ static void read_push_options(struct packet_reader *reader,
2290 2293 }
2291 2294 }
2292 2295
2293 - static int unpack_with_sideband(struct odb_transaction *transaction,
2294 - const char *shallow_file,
2295 - struct strbuf *err_msg)
2296 + static const char *parse_pack_header(struct pack_header *hdr)
2297 + {
2298 + switch (read_pack_header(0, hdr)) {
2299 + case PH_ERROR_EOF:
2300 + return "eof before pack header was fully read";
2301 +
2302 + case PH_ERROR_PACK_SIGNATURE:
2303 + return "protocol error (pack signature mismatch detected)";
2304 +
2305 + case PH_ERROR_PROTOCOL:
2306 + return "protocol error (pack version unsupported)";
2307 +
2308 + default:
2309 + return "unknown error in parse_pack_header";
2310 +
2311 + case 0:
2312 + return NULL;
2313 + }
2314 + }
2315 +
2316 + static struct tempfile *pack_lockfile;
2317 +
2318 + static void push_header_arg(struct strvec *args, struct pack_header *hdr)
2319 + {
2320 + strvec_pushf(args, "--pack_header=%"PRIu32",%"PRIu32,
2321 + ntohl(hdr->hdr_version), ntohl(hdr->hdr_entries));
2322 + }
2323 +
2324 + static const char *unpack(int err_fd, struct shallow_info *si)
2325 + {
2326 + struct pack_header hdr;
2327 + const char *hdr_err;
2328 + int status;
2329 + struct child_process child = CHILD_PROCESS_INIT;
2330 + int fsck_objects = (receive_fsck_objects >= 0
2331 + ? receive_fsck_objects
2332 + : transfer_fsck_objects >= 0
2333 + ? transfer_fsck_objects
2334 + : 0);
2335 +
2336 + hdr_err = parse_pack_header(&hdr);
2337 + if (hdr_err) {
2338 + if (err_fd > 0)
2339 + close(err_fd);
2340 + return hdr_err;
2341 + }
2342 +
2343 + if (si->nr_ours || si->nr_theirs) {
2344 + alt_shallow_file = setup_temporary_shallow(si->shallow);
2345 + strvec_push(&child.args, "--shallow-file");
2346 + strvec_push(&child.args, alt_shallow_file);
2347 + }
2348 +
2349 + tmp_objdir = tmp_objdir_create(the_repository, "incoming");
2350 + if (!tmp_objdir) {
2351 + if (err_fd > 0)
2352 + close(err_fd);
2353 + return "unable to create temporary object directory";
2354 + }
2355 + strvec_pushv(&child.env, tmp_objdir_env(tmp_objdir));
2356 +
2357 + /*
2358 + * Normally we just pass the tmp_objdir environment to the child
2359 + * processes that do the heavy lifting, but we may need to see these
2360 + * objects ourselves to set up shallow information.
2361 + */
2362 + tmp_objdir_add_as_alternate(tmp_objdir);
2363 +
2364 + if (ntohl(hdr.hdr_entries) < unpack_limit) {
2365 + strvec_push(&child.args, "unpack-objects");
2366 + push_header_arg(&child.args, &hdr);
2367 + if (quiet)
2368 + strvec_push(&child.args, "-q");
2369 + if (fsck_objects)
2370 + strvec_pushf(&child.args, "--strict%s",
2371 + fsck_msg_types.buf);
2372 + if (max_input_size)
2373 + strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX,
2374 + (uintmax_t)max_input_size);
2375 + child.no_stdout = 1;
2376 + child.err = err_fd;
2377 + child.git_cmd = 1;
2378 + status = run_command(&child);
2379 + if (status)
2380 + return "unpack-objects abnormal exit";
2381 + } else {
2382 + char hostname[HOST_NAME_MAX + 1];
2383 + char *lockfile;
2384 +
2385 + strvec_pushl(&child.args, "index-pack", "--stdin", NULL);
2386 + push_header_arg(&child.args, &hdr);
2387 +
2388 + if (xgethostname(hostname, sizeof(hostname)))
2389 + xsnprintf(hostname, sizeof(hostname), "localhost");
2390 + strvec_pushf(&child.args,
2391 + "--keep=receive-pack %"PRIuMAX" on %s",
2392 + (uintmax_t)getpid(),
2393 + hostname);
2394 +
2395 + if (!quiet && err_fd)
2396 + strvec_push(&child.args, "--show-resolving-progress");
2397 + if (use_sideband)
2398 + strvec_push(&child.args, "--report-end-of-input");
2399 + if (fsck_objects)
2400 + strvec_pushf(&child.args, "--strict%s",
2401 + fsck_msg_types.buf);
2402 + if (!reject_thin)
2403 + strvec_push(&child.args, "--fix-thin");
2404 + if (max_input_size)
2405 + strvec_pushf(&child.args, "--max-input-size=%"PRIuMAX,
2406 + (uintmax_t)max_input_size);
2407 + child.out = -1;
2408 + child.err = err_fd;
2409 + child.git_cmd = 1;
2410 + status = start_command(&child);
2411 + if (status)
2412 + return "index-pack fork failed";
2413 +
2414 + lockfile = index_pack_lockfile(the_repository, child.out, NULL);
2415 + if (lockfile) {
2416 + pack_lockfile = register_tempfile(lockfile);
2417 + free(lockfile);
2418 + }
2419 + close(child.out);
2420 +
2421 + status = finish_command(&child);
2422 + if (status)
2423 + return "index-pack abnormal exit";
2424 + odb_reprepare(the_repository->objects);
2425 + }
2426 + return NULL;
2427 + }
2428 +
2429 + static const char *unpack_with_sideband(struct shallow_info *si)
2296 2430 {
2297 - struct odb_transaction_write_pack_opts opts = {
2298 - .fsck_objects = (receive_fsck_objects >= 0
2299 - ? receive_fsck_objects
2300 - : transfer_fsck_objects >= 0
2301 - ? transfer_fsck_objects
2302 - : 0),
2303 - .fsck_msg_types = fsck_msg_types.buf,
2304 - .max_input_size = max_input_size,
2305 - .shallow_file = shallow_file,
2306 - .reject_thin = reject_thin,
2307 - .quiet = quiet,
2308 - };
2309 2431 struct async muxer;
2310 - int ret;
2432 + const char *ret;
2311 2433
2312 2434 if (!use_sideband)
2313 - return odb_transaction_write_pack(transaction, 0, err_msg, &opts);
2435 + return unpack(0, si);
2314 2436
2315 2437 use_keepalive = KEEPALIVE_AFTER_NUL;
2316 2438 memset(&muxer, 0, sizeof(muxer));
2317 2439 muxer.proc = copy_to_sideband;
2318 2440 muxer.in = -1;
2319 2441 if (start_async(&muxer))
2320 - return 0;
2442 + return NULL;
2321 2443
2322 - opts.err_fd = muxer.in;
2323 - ret = odb_transaction_write_pack(transaction, 0, err_msg, &opts);
2444 + ret = unpack(muxer.in, si);
2324 2445
2325 2446 finish_async(&muxer);
2326 2447 return ret;
2327 2448 }
2328 2449
2329 - static void prepare_shallow_update(struct shallow_info *si,
2330 - const char *shallow_file)
2450 + static void prepare_shallow_update(struct shallow_info *si)
2331 2451 {
2332 2452 int i, j, k, bitmap_size = DIV_ROUND_UP(si->ref->nr, 32);
2333 2453
@@ -2367,13 +2487,12 @@ static void prepare_shallow_update(struct shallow_info *si,
2367 2487 * command. check_connected() will be done with
2368 2488 * true .git/shallow though.
2369 2489 */
2370 - setenv(GIT_SHALLOW_FILE_ENVIRONMENT, shallow_file, 1);
2490 + setenv(GIT_SHALLOW_FILE_ENVIRONMENT, alt_shallow_file, 1);
2371 2491 }
2372 2492
2373 2493 static void update_shallow_info(struct command *commands,
2374 2494 struct shallow_info *si,
2375 - struct oid_array *ref,
2376 - const char *shallow_file)
2495 + struct oid_array *ref)
2377 2496 {
2378 2497 struct command *cmd;
2379 2498 int *ref_status;
@@ -2392,7 +2511,7 @@ static void update_shallow_info(struct command *commands,
2392 2511 si->ref = ref;
2393 2512
2394 2513 if (shallow_update) {
2395 - prepare_shallow_update(si, shallow_file);
2514 + prepare_shallow_update(si);
2396 2515 return;
2397 2516 }
2398 2517
@@ -2409,13 +2528,13 @@ static void update_shallow_info(struct command *commands,
2409 2528 free(ref_status);
2410 2529 }
2411 2530
2412 - static void report(struct command *commands, const struct strbuf *unpack_status)
2531 + static void report(struct command *commands, const char *unpack_status)
2413 2532 {
2414 2533 struct command *cmd;
2415 2534 struct strbuf buf = STRBUF_INIT;
2416 2535
2417 2536 packet_buf_write(&buf, "unpack %s\n",
2418 - unpack_status->len ? unpack_status->buf : "ok");
2537 + unpack_status ? unpack_status : "ok");
2419 2538 for (cmd = commands; cmd; cmd = cmd->next) {
2420 2539 if (!cmd->error_string)
2421 2540 packet_buf_write(&buf, "ok %s\n",
@@ -2433,14 +2552,14 @@ static void report(struct command *commands, const struct strbuf *unpack_status)
2433 2552 strbuf_release(&buf);
2434 2553 }
2435 2554
2436 - static void report_v2(struct command *commands, const struct strbuf *unpack_status)
2555 + static void report_v2(struct command *commands, const char *unpack_status)
2437 2556 {
2438 2557 struct command *cmd;
2439 2558 struct strbuf buf = STRBUF_INIT;
2440 2559 struct ref_push_report *report;
2441 2560
2442 2561 packet_buf_write(&buf, "unpack %s\n",
2443 - unpack_status->len ? unpack_status->buf : "ok");
2562 + unpack_status ? unpack_status : "ok");
2444 2563 for (cmd = commands; cmd; cmd = cmd->next) {
2445 2564 int count = 0;
2446 2565
@@ -2499,7 +2618,6 @@ int cmd_receive_pack(int argc,
2499 2618 struct oid_array ref = OID_ARRAY_INIT;
2500 2619 struct shallow_info si;
2501 2620 struct packet_reader reader;
2502 - struct odb_transaction *transaction = NULL;
2503 2621
2504 2622 struct option options[] = {
2505 2623 OPT__QUIET(&quiet, N_("quiet")),
@@ -2524,13 +2642,18 @@ int cmd_receive_pack(int argc,
2524 2642
2525 2643 setup_path();
2526 2644
2527 - if (!enter_repo(the_repository, service_dir, 0))
2645 + if (!enter_repo(service_dir, 0))
2528 2646 die("'%s' does not appear to be a git repository", service_dir);
2529 2647
2530 2648 repo_config(the_repository, receive_pack_config, NULL);
2531 2649 if (cert_nonce_seed)
2532 2650 push_cert_nonce = prepare_push_cert_nonce(service_dir, time(NULL));
2533 2651
2652 + if (0 <= receive_unpack_limit)
2653 + unpack_limit = receive_unpack_limit;
2654 + else if (0 <= transfer_unpack_limit)
2655 + unpack_limit = transfer_unpack_limit;
2656 +
2534 2657 switch (determine_protocol_version_server()) {
2535 2658 case protocol_v2:
2536 2659 /*
@@ -2564,8 +2687,8 @@ int cmd_receive_pack(int argc,
2564 2687 PACKET_READ_DIE_ON_ERR_PACKET);
2565 2688
2566 2689 if ((commands = read_head_info(&reader, &shallow))) {
2690 + const char *unpack_status = NULL;
2567 2691 struct string_list push_options = STRING_LIST_INIT_DUP;
2568 - struct strbuf unpack_status = STRBUF_INIT;
2569 2692
2570 2693 if (use_push_options)
2571 2694 read_push_options(&reader, &push_options);
@@ -2579,29 +2702,20 @@ int cmd_receive_pack(int argc,
2579 2702 if (!si.nr_ours && !si.nr_theirs)
2580 2703 shallow_update = 0;
2581 2704 if (!delete_only(commands)) {
2582 - const char *alt_shallow_file = NULL;
2583 -
2584 - if (si.nr_ours || si.nr_theirs)
2585 - alt_shallow_file = setup_temporary_shallow(si.shallow);
2586 -
2587 - if (odb_transaction_begin(the_repository->objects, &transaction, ODB_TRANSACTION_RECEIVE))
2588 - strbuf_addstr(&unpack_status, "unable to start object transaction");
2589 - else
2590 - unpack_with_sideband(transaction, alt_shallow_file, &unpack_status);
2591 -
2592 - update_shallow_info(commands, &si, &ref, alt_shallow_file);
2705 + unpack_status = unpack_with_sideband(&si);
2706 + update_shallow_info(commands, &si, &ref);
2593 2707 }
2594 2708 use_keepalive = KEEPALIVE_ALWAYS;
2595 - execute_commands(commands, !!unpack_status.len, &si, transaction,
2709 + execute_commands(commands, unpack_status, &si,
2596 2710 &push_options);
2597 - odb_transaction_finalize(transaction);
2711 + delete_tempfile(&pack_lockfile);
2598 2712 sigchain_push(SIGPIPE, SIG_IGN);
2599 2713 if (report_status_v2)
2600 - report_v2(commands, &unpack_status);
2714 + report_v2(commands, unpack_status);
2601 2715 else if (report_status)
2602 - report(commands, &unpack_status);
2716 + report(commands, unpack_status);
2603 2717 sigchain_pop(SIGPIPE);
2604 - run_receive_hook(commands, "post-receive", 1, NULL,
2718 + run_receive_hook(commands, "post-receive", 1,
2605 2719 &push_options);
2606 2720 run_update_post_hook(commands);
2607 2721 free_commands(commands);
@@ -2624,7 +2738,6 @@ int cmd_receive_pack(int argc,
2624 2738 if (auto_update_server_info)
2625 2739 update_server_info(the_repository, 0);
2626 2740 clear_shallow_info(&si);
2627 - strbuf_release(&unpack_status);
2628 2741 }
2629 2742 if (use_sideband)
2630 2743 packet_flush(1);
modified builtin/reflog.c
@@ -250,7 +250,7 @@ static int cmd_reflog_expire(int argc, const char **argv, const char *prefix,
250 250 struct string_list_item *item;
251 251 struct worktree **worktrees, **p;
252 252
253 - worktrees = get_worktrees(the_repository);
253 + worktrees = get_worktrees();
254 254 for (p = worktrees; *p; p++) {
255 255 if (single_worktree && !(*p)->is_current)
256 256 continue;
@@ -374,7 +374,7 @@ static int cmd_reflog_drop(int argc, const char **argv, const char *prefix,
374 374 struct string_list_item *item;
375 375 struct worktree **worktrees, **p;
376 376
377 - worktrees = get_worktrees(the_repository);
377 + worktrees = get_worktrees();
378 378 for (p = worktrees; *p; p++) {
379 379 if (single_worktree && !(*p)->is_current)
380 380 continue;
modified builtin/refs.c
@@ -1,3 +1,4 @@
1 + #define USE_THE_REPOSITORY_VARIABLE
1 2 #include "builtin.h"
2 3 #include "config.h"
3 4 #include "fsck.h"
@@ -21,20 +22,8 @@
21 22 #define REFS_OPTIMIZE_USAGE \
22 23 N_("git refs optimize " PACK_REFS_OPTS)
23 24
24 - #define REFS_CREATE_USAGE \
25 - N_("git refs create [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value>")
26 -
27 - #define REFS_DELETE_USAGE \
28 - N_("git refs delete [--message=<reason>] [--no-deref] <ref> [<old-value>]")
29 -
30 - #define REFS_UPDATE_USAGE \
31 - N_("git refs update [--message=<reason>] [--no-deref] [--create-reflog] <ref> <new-value> [<old-value>]")
32 -
33 - #define REFS_RENAME_USAGE \
34 - N_("git refs rename [--message=<reason>] <old-ref> <new-ref>")
35 -
36 25 static int cmd_refs_migrate(int argc, const char **argv, const char *prefix,
37 - struct repository *repo)
26 + struct repository *repo UNUSED)
38 27 {
39 28 const char * const migrate_usage[] = {
40 29 REFS_MIGRATE_USAGE,
@@ -70,13 +59,13 @@ static int cmd_refs_migrate(int argc, const char **argv, const char *prefix,
70 59 goto out;
71 60 }
72 61
73 - if (repo->ref_storage_format == format) {
62 + if (the_repository->ref_storage_format == format) {
74 63 err = error(_("repository already uses '%s' format"),
75 64 ref_storage_format_to_name(format));
76 65 goto out;
77 66 }
78 67
79 - if (repo_migrate_ref_storage_format(repo, format, flags, &errbuf) < 0) {
68 + if (repo_migrate_ref_storage_format(the_repository, format, flags, &errbuf) < 0) {
80 69 err = error("%s", errbuf.buf);
81 70 goto out;
82 71 }
@@ -110,10 +99,10 @@ static int cmd_refs_verify(int argc, const char **argv, const char *prefix,
110 99 if (argc)
111 100 usage(_("'git refs verify' takes no arguments"));
112 101
113 - repo_config(repo, git_fsck_config, &fsck_refs_options);
114 - prepare_repo_settings(repo);
102 + repo_config(the_repository, git_fsck_config, &fsck_refs_options);
103 + prepare_repo_settings(the_repository);
115 104
116 - worktrees = get_worktrees_without_reading_head(repo);
105 + worktrees = get_worktrees_without_reading_head();
117 106 for (size_t i = 0; worktrees[i]; i++)
118 107 ret |= refs_fsck(get_worktree_ref_store(worktrees[i]),
119 108 &fsck_refs_options, worktrees[i]);
@@ -135,7 +124,7 @@ static int cmd_refs_list(int argc, const char **argv, const char *prefix,
135 124 }
136 125
137 126 static int cmd_refs_exists(int argc, const char **argv, const char *prefix,
138 - struct repository *repo)
127 + struct repository *repo UNUSED)
139 128 {
140 129 struct strbuf unused_referent = STRBUF_INIT;
141 130 struct object_id unused_oid;
@@ -156,7 +145,7 @@ static int cmd_refs_exists(int argc, const char **argv, const char *prefix,
156 145 die(_("'git refs exists' requires a reference"));
157 146
158 147 ref = *argv++;
159 - if (refs_read_raw_ref(get_main_ref_store(repo), ref,
148 + if (refs_read_raw_ref(get_main_ref_store(the_repository), ref,
160 149 &unused_oid, &unused_referent, &unused_type,
161 150 &failure_errno)) {
162 151 if (failure_errno == ENOENT || failure_errno == EISDIR) {
@@ -187,193 +176,6 @@ static int cmd_refs_optimize(int argc, const char **argv, const char *prefix,
187 176 return pack_refs_core(argc, argv, prefix, repo, refs_optimize_usage);
188 177 }
189 178
190 - static int cmd_refs_create(int argc, const char **argv, const char *prefix,
191 - struct repository *repo)
192 - {
193 - static char const * const refs_create_usage[] = {
194 - REFS_CREATE_USAGE,
195 - NULL
196 - };
197 - const char *message = NULL;
198 - unsigned flags = 0;
199 - struct option opts[] = {
200 - OPT_STRING(0, "message", &message, N_("reason"),
201 - N_("reason of the update")),
202 - OPT_BIT(0 ,"no-deref", &flags,
203 - N_("update <refname> not the one it points to"),
204 - REF_NO_DEREF),
205 - OPT_BIT(0, "create-reflog", &flags, N_("create a reflog"),
206 - REF_FORCE_CREATE_REFLOG),
207 - OPT_END(),
208 - };
209 - struct object_id newoid;
210 - const char *refname;
211 - int ret;
212 -
213 - argc = parse_options(argc, argv, prefix, opts, refs_create_usage, 0);
214 - if (argc != 2)
215 - usage(_("create requires reference name and an object ID"));
216 -
217 - if (message && !*message)
218 - die(_("refusing to perform update with empty message"));
219 -
220 - repo_config(repo, git_default_config, NULL);
221 -
222 - refname = argv[0];
223 - if (repo_get_oid_with_flags(repo, argv[1], &newoid, GET_OID_SKIP_AMBIGUITY_CHECK))
224 - die(_("invalid object ID: '%s'"), argv[1]);
225 - if (is_null_oid(&newoid))
226 - die(_("cannot create reference with null new object ID"));
227 -
228 - ret = refs_update_ref(get_main_ref_store(repo), message, refname,
229 - &newoid, null_oid(repo->hash_algo), flags,
230 - UPDATE_REFS_MSG_ON_ERR);
231 -
232 - if (ret < 0)
233 - ret = 1;
234 - return ret;
235 - }
236 -
237 - static int cmd_refs_delete(int argc, const char **argv, const char *prefix,
238 - struct repository *repo)
239 - {
240 - static char const * const refs_delete_usage[] = {
241 - REFS_DELETE_USAGE,
242 - NULL
243 - };
244 - const char *message = NULL;
245 - unsigned flags = 0;
246 - struct option opts[] = {
247 - OPT_STRING(0, "message", &message, N_("reason"),
248 - N_("reason of the update")),
249 - OPT_BIT(0 ,"no-deref", &flags,
250 - N_("update <refname> not the one it points to"),
251 - REF_NO_DEREF),
252 - OPT_END(),
253 - };
254 - struct object_id oldoid;
255 - const char *refname;
256 - int ret;
257 -
258 - argc = parse_options(argc, argv, prefix, opts, refs_delete_usage, 0);
259 - if (argc < 1 || argc > 2)
260 - usage(_("delete requires reference name and an optional old object ID"));
261 -
262 - if (message && !*message)
263 - die(_("refusing to perform update with empty message"));
264 -
265 - repo_config(repo, git_default_config, NULL);
266 -
267 - refname = argv[0];
268 - if (argc == 2) {
269 - if (repo_get_oid_with_flags(repo, argv[1], &oldoid, GET_OID_SKIP_AMBIGUITY_CHECK))
270 - die(_("invalid old object ID: '%s'"), argv[1]);
271 - if (is_null_oid(&oldoid))
272 - die(_("cannot delete reference with null old object ID"));
273 - }
274 -
275 - ret = refs_delete_ref(get_main_ref_store(repo), message, refname,
276 - argc == 2 ? &oldoid : NULL, flags);
277 -
278 - if (ret < 0)
279 - ret = 1;
280 - return ret;
281 - }
282 -
283 - static int cmd_refs_update(int argc, const char **argv, const char *prefix,
284 - struct repository *repo)
285 - {
286 - static char const * const refs_update_usage[] = {
287 - REFS_UPDATE_USAGE,
288 - NULL
289 - };
290 - const char *message = NULL;
291 - unsigned flags = 0;
292 - struct option opts[] = {
293 - OPT_STRING(0, "message", &message, N_("reason"),
294 - N_("reason of the update")),
295 - OPT_BIT(0 ,"no-deref", &flags,
296 - N_("update <refname> not the one it points to"),
297 - REF_NO_DEREF),
298 - OPT_BIT(0, "create-reflog", &flags, N_("create a reflog"),
299 - REF_FORCE_CREATE_REFLOG),
300 - OPT_END(),
301 - };
302 - struct object_id newoid, oldoid;
303 - const char *refname;
304 - int ret;
305 -
306 - argc = parse_options(argc, argv, prefix, opts, refs_update_usage, 0);
307 - if (argc < 2 || argc > 3)
308 - usage(_("update requires reference name, new value and an optional old value"));
309 -
310 - if (message && !*message)
311 - die(_("refusing to perform update with empty message"));
312 -
313 - repo_config(repo, git_default_config, NULL);
314 -
315 - refname = argv[0];
316 - if (repo_get_oid_with_flags(repo, argv[1], &newoid,
317 - GET_OID_SKIP_AMBIGUITY_CHECK))
318 - die(_("invalid new object ID: '%s'"), argv[1]);
319 - if (argc == 3 &&
320 - repo_get_oid_with_flags(repo, argv[2], &oldoid,
321 - GET_OID_SKIP_AMBIGUITY_CHECK))
322 - die(_("invalid old object ID: '%s'"), argv[2]);
323 -
324 - ret = refs_update_ref(get_main_ref_store(repo), message, refname,
325 - &newoid, argc == 3 ? &oldoid : NULL, flags,
326 - UPDATE_REFS_MSG_ON_ERR);
327 -
328 - if (ret < 0)
329 - ret = 1;
330 - return ret;
331 - }
332 -
333 - static int cmd_refs_rename(int argc, const char **argv, const char *prefix,
334 - struct repository *repo)
335 - {
336 - static char const * const refs_rename_usage[] = {
337 - REFS_RENAME_USAGE,
338 - NULL
339 - };
340 - const char *message = NULL;
341 - struct option opts[] = {
342 - OPT_STRING(0, "message", &message, N_("reason"),
343 - N_("reason of the update")),
344 - OPT_END(),
345 - };
346 - const char *oldref, *newref;
347 - int ret;
348 -
349 - argc = parse_options(argc, argv, prefix, opts, refs_rename_usage, 0);
350 - if (argc != 2)
351 - usage(_("rename requires old and new reference name"));
352 - if (message && !*message)
353 - die(_("refusing to perform update with empty message"));
354 -
355 - repo_config(repo, git_default_config, NULL);
356 -
357 - oldref = argv[0];
358 - newref = argv[1];
359 -
360 - if (check_refname_format(oldref, 0))
361 - die(_("invalid ref format: '%s'"), oldref);
362 - if (check_refname_format(newref, 0))
363 - die(_("invalid ref format: '%s'"), newref);
364 -
365 - if (!refs_ref_exists(get_main_ref_store(repo), oldref))
366 - die(_("reference does not exist: '%s'"), oldref);
367 - if (refs_ref_exists(get_main_ref_store(repo), newref))
368 - die(_("reference already exists: '%s'"), newref);
369 -
370 - ret = refs_rename_ref(get_main_ref_store(repo), oldref, newref, message);
371 -
372 - if (ret < 0)
373 - ret = 1;
374 - return ret;
375 - }
376 -
377 179 int cmd_refs(int argc,
378 180 const char **argv,
379 181 const char *prefix,
@@ -385,10 +187,6 @@ int cmd_refs(int argc,
385 187 "git refs list " COMMON_USAGE_FOR_EACH_REF,
386 188 REFS_EXISTS_USAGE,
387 189 REFS_OPTIMIZE_USAGE,
388 - REFS_CREATE_USAGE,
389 - REFS_DELETE_USAGE,
390 - REFS_UPDATE_USAGE,
391 - REFS_RENAME_USAGE,
392 190 NULL,
393 191 };
394 192 parse_opt_subcommand_fn *fn = NULL;
@@ -398,10 +196,6 @@ int cmd_refs(int argc,
398 196 OPT_SUBCOMMAND("list", &fn, cmd_refs_list),
399 197 OPT_SUBCOMMAND("exists", &fn, cmd_refs_exists),
400 198 OPT_SUBCOMMAND("optimize", &fn, cmd_refs_optimize),
401 - OPT_SUBCOMMAND("create", &fn, cmd_refs_create),
402 - OPT_SUBCOMMAND("delete", &fn, cmd_refs_delete),
403 - OPT_SUBCOMMAND("update", &fn, cmd_refs_update),
404 - OPT_SUBCOMMAND("rename", &fn, cmd_refs_rename),
405 199 OPT_END(),
406 200 };
407 201
modified builtin/repack.c
@@ -1,3 +1,4 @@
1 + #define USE_THE_REPOSITORY_VARIABLE
1 2 #define DISABLE_SIGN_COMPARE_WARNINGS
2 3
3 4 #include "builtin.h"
@@ -14,11 +15,6 @@
14 15 #include "promisor-remote.h"
15 16 #include "repack.h"
16 17 #include "shallow.h"
17 - #include "list-objects-filter-options.h"
18 - #include "oidset.h"
19 - #include "hex.h"
20 - #include "wt-status.h"
21 - #include "read-cache-ll.h"
22 18
23 19 #define ALL_INTO_ONE 1
24 20 #define LOOSEN_UNREACHABLE 2
@@ -33,15 +29,11 @@ static int use_delta_islands;
33 29 static int run_update_server_info = 1;
34 30 static char *packdir, *packtmp_name, *packtmp;
35 31 static int midx_must_contain_cruft = 1;
36 - static int drop_filtered;
37 - static int dry_run;
38 - static int write_bitmaps_given;
39 32
40 33 static const char *const git_repack_usage[] = {
41 34 N_("git repack [-a] [-A] [-d] [-f] [-F] [-l] [-n] [-q] [-b] [-m]\n"
42 35 "[--window=<n>] [--depth=<n>] [--threads=<n>] [--keep-pack=<pack-name>]\n"
43 - "[--write-midx[=<mode>]] [--name-hash-version=<n>] [--path-walk]\n"
44 - "[--filter=<filter-spec>] [--drop-filtered [--dry-run]]"),
36 + "[--write-midx] [--name-hash-version=<n>] [--path-walk]"),
45 37 NULL
46 38 };
47 39
@@ -50,14 +42,9 @@ static const char incremental_bitmap_conflict_error[] = N_(
50 42 "--no-write-bitmap-index or disable the pack.writeBitmaps configuration."
51 43 );
52 44
53 - #define DEFAULT_MIDX_SPLIT_FACTOR 2
54 - #define DEFAULT_MIDX_NEW_LAYER_THRESHOLD 8
55 -
56 45 struct repack_config_ctx {
57 46 struct pack_objects_args *po_args;
58 47 struct pack_objects_args *cruft_po_args;
59 - int midx_split_factor;
60 - int midx_new_layer_threshold;
61 48 };
62 49
63 50 static int repack_config(const char *var, const char *value,
@@ -107,54 +94,9 @@ static int repack_config(const char *var, const char *value,
107 94 midx_must_contain_cruft = git_config_bool(var, value);
108 95 return 0;
109 96 }
110 - if (!strcmp(var, "repack.midxsplitfactor")) {
111 - repack_ctx->midx_split_factor = git_config_int(var, value,
112 - ctx->kvi);
113 - return 0;
114 - }
115 - if (!strcmp(var, "repack.midxnewlayerthreshold")) {
116 - repack_ctx->midx_new_layer_threshold = git_config_int(var, value,
117 - ctx->kvi);
118 - return 0;
119 - }
120 97 return git_default_config(var, value, ctx, cb);
121 98 }
122 99
123 - static int option_parse_write_bitmaps(const struct option *opt, const char *arg,
124 - int unset)
125 - {
126 - int *value = opt->value;
127 -
128 - BUG_ON_OPT_ARG(arg);
129 - if (unset)
130 - *value = 0;
131 - else
132 - *value = 1;
133 -
134 - write_bitmaps_given = 1;
135 - return 0;
136 - }
137 -
138 - static int option_parse_write_midx(const struct option *opt, const char *arg,
139 - int unset)
140 - {
141 - enum repack_write_midx_mode *cfg = opt->value;
142 -
143 - if (unset) {
144 - *cfg = REPACK_WRITE_MIDX_NONE;
145 - return 0;
146 - }
147 -
148 - if (!arg || !*arg)
149 - *cfg = REPACK_WRITE_MIDX_DEFAULT;
150 - else if (!strcmp(arg, "incremental"))
151 - *cfg = REPACK_WRITE_MIDX_INCREMENTAL;
152 - else
153 - return error(_("unknown value for %s: %s"), opt->long_name, arg);
154 -
155 - return 0;
156 - }
157 -
158 100 int cmd_repack(int argc,
159 101 const char **argv,
160 102 const char *prefix,
@@ -164,7 +106,6 @@ int cmd_repack(int argc,
164 106 struct string_list_item *item;
165 107 struct string_list names = STRING_LIST_INIT_DUP;
166 108 struct existing_packs existing = EXISTING_PACKS_INIT;
167 - struct oidset drop_oids = OIDSET_INIT;
168 109 struct pack_geometry geometry = { 0 };
169 110 struct tempfile *refs_snapshot = NULL;
170 111 int i, ret;
@@ -178,7 +119,7 @@ int cmd_repack(int argc,
178 119 struct string_list keep_pack_list = STRING_LIST_INIT_NODUP;
179 120 struct pack_objects_args po_args = PACK_OBJECTS_ARGS_INIT;
180 121 struct pack_objects_args cruft_po_args = PACK_OBJECTS_ARGS_INIT;
181 - enum repack_write_midx_mode write_midx = REPACK_WRITE_MIDX_NONE;
122 + int write_midx = 0;
182 123 const char *cruft_expiration = NULL;
183 124 const char *expire_to = NULL;
184 125 const char *filter_to = NULL;
@@ -219,9 +160,8 @@ int cmd_repack(int argc,
219 160 OPT__QUIET(&po_args.quiet, N_("be quiet")),
220 161 OPT_BOOL('l', "local", &po_args.local,
221 162 N_("pass --local to git-pack-objects")),
222 - OPT_CALLBACK_F('b', "write-bitmap-index", &write_bitmaps, NULL,
223 - N_("write bitmap index"),
224 - PARSE_OPT_NOARG, option_parse_write_bitmaps),
163 + OPT_BOOL('b', "write-bitmap-index", &write_bitmaps,
164 + N_("write bitmap index")),
225 165 OPT_BOOL('i', "delta-islands", &use_delta_islands,
226 166 N_("pass --delta-islands to git-pack-objects")),
227 167 OPT_STRING(0, "unpack-unreachable", &unpack_unreachable, N_("approxidate"),
@@ -245,22 +185,12 @@ int cmd_repack(int argc,
245 185 N_("do not repack this pack")),
246 186 OPT_INTEGER('g', "geometric", &geometry.split_factor,
247 187 N_("find a geometric progression with factor <N>")),
248 - OPT_CALLBACK_F(0, "write-midx", &write_midx,
249 - N_("mode"),
250 - N_("write a multi-pack index of the resulting packs"),
251 - PARSE_OPT_OPTARG, option_parse_write_midx),
252 - OPT_SET_INT_F('m', NULL, &write_midx,
253 - N_("write a multi-pack index of the resulting packs"),
254 - REPACK_WRITE_MIDX_DEFAULT,
255 - PARSE_OPT_HIDDEN),
188 + OPT_BOOL('m', "write-midx", &write_midx,
189 + N_("write a multi-pack index of the resulting packs")),
256 190 OPT_STRING(0, "expire-to", &expire_to, N_("dir"),
257 191 N_("pack prefix to store a pack containing pruned objects")),
258 192 OPT_STRING(0, "filter-to", &filter_to, N_("dir"),
259 193 N_("pack prefix to store a pack containing filtered out objects")),
260 - OPT_BOOL(0, "drop-filtered", &drop_filtered,
261 - N_("delete filtered out objects (requires --filter)")),
262 - OPT_BOOL(0, "dry-run", &dry_run,
263 - N_("only show which objects would be dropped")),
264 194 OPT_END()
265 195 };
266 196
@@ -269,8 +199,6 @@ int cmd_repack(int argc,
269 199 memset(&config_ctx, 0, sizeof(config_ctx));
270 200 config_ctx.po_args = &po_args;
271 201 config_ctx.cruft_po_args = &cruft_po_args;
272 - config_ctx.midx_split_factor = DEFAULT_MIDX_SPLIT_FACTOR;
273 - config_ctx.midx_new_layer_threshold = DEFAULT_MIDX_NEW_LAYER_THRESHOLD;
274 202
275 203 repo_config(repo, repack_config, &config_ctx);
276 204
@@ -282,118 +210,6 @@ int cmd_repack(int argc,
282 210 po_args.depth = xstrdup_or_null(opt_depth);
283 211 po_args.threads = xstrdup_or_null(opt_threads);
284 212
285 - die_for_incompatible_opt2(drop_filtered, "--drop-filtered",
286 - !!filter_to, "--filter-to");
287 -
288 - if (dry_run && !drop_filtered)
289 - die(_("--dry-run only takes effect with --drop-filtered"));
290 -
291 - if (drop_filtered) {
292 - if (!po_args.filter_options.choice)
293 - die(_("--drop-filtered requires --filter"));
294 -
295 - if (!(pack_everything & ALL_INTO_ONE))
296 - die(_("--drop-filtered requires -a"));
297 -
298 - /*
299 - * Only blob:limit=<n> is supported for now. Reject other
300 - * filter choices early, before walking the object database.
301 - */
302 - if (po_args.filter_options.choice != LOFC_BLOB_LIMIT)
303 - die(_("--drop-filtered only supports --filter=blob:limit=<n> for now"));
304 -
305 - /*
306 - * An explicit -b on the command line is a conflict we have to
307 - * report; a bitmap setting from config is silently overridden
308 - * for the duration of the command.
309 - */
310 - if (write_bitmaps_given && write_bitmaps > 0)
311 - die(_("options '%s' and '%s' cannot be used together"),
312 - "--drop-filtered", "--write-bitmap-index");
313 -
314 - /*
315 - * Without a promisor remote there is nowhere to re-fetch the
316 - * dropped objects from, so dropping them would be permanent
317 - * data loss.
318 - */
319 - if (!repo_has_promisor_remote(repo))
320 - die(_("--drop-filtered requires a promisor remote"));
321 -
322 - /*
323 - * Refuse to run while another operation is in progress. A
324 - * dropped object would just be lazily re-fetched when the
325 - * operation resumes, but triggering a network fetch in the
326 - * middle of a half-finished
327 - * merge/rebase/cherry-pick/revert/bisect is a poor
328 - * experience, so this is a UX convenience rather than a
329 - * safety measure. Bare repositories have no such state, so
330 - * the check is skipped there.
331 - */
332 - if (!is_bare_repository(repo)) {
333 - struct wt_status_state state = { 0 };
334 -
335 - wt_status_get_state(repo, &state, 0);
336 - if (state.merge_in_progress || state.revert_in_progress ||
337 - state.rebase_in_progress || state.bisect_in_progress ||
338 - state.cherry_pick_in_progress || state.am_in_progress ||
339 - state.rebase_interactive_in_progress) {
340 - wt_status_state_free_buffers(&state);
341 - die(_("--drop-filtered cannot be used while "
342 - "another operation (merge, rebase, am, "
343 - "cherry-pick, revert, or bisect) is in "
344 - "progress"));
345 - }
346 - wt_status_state_free_buffers(&state);
347 - }
348 -
349 - write_bitmaps = 0;
350 -
351 - /*
352 - * Dropping objects means rebuilding the promisor packs
353 - * without them and then removing the old packs, so the
354 - * redundant packs must be deleted. Imply -d on a real run.
355 - */
356 - if (!dry_run)
357 - delete_redundant = 1;
358 -
359 - ret = enumerate_promisor_blobs(repo, &po_args.filter_options, &drop_oids);
360 -
361 - if (ret)
362 - goto cleanup;
363 -
364 - /*
365 - * Refuse to drop blobs that the current index references.
366 - * Such a blob would only be lazily re-fetched by the next
367 - * command that touches the worktree, so dropping it reclaims
368 - * nothing. This guard just avoids that churn. Bare
369 - * repositories have no index, so the check is skipped there.
370 - */
371 - if (!is_bare_repository(repo) && oidset_size(&drop_oids)) {
372 - struct index_state *istate = repo->index;
373 - unsigned int i;
374 -
375 - if (repo_read_index(repo) < 0)
376 - die(_("could not read the index"));
377 -
378 - for (i = 0; i < istate->cache_nr; i++) {
379 - const struct cache_entry *ce = istate->cache[i];
380 -
381 - if (oidset_contains(&drop_oids, &ce->oid))
382 - die(_("cannot drop '%s' (%s): it is referenced by the current index"),
383 - ce->name, oid_to_hex(&ce->oid));
384 - }
385 - }
386 -
387 - if (dry_run) {
388 - struct oidset_iter iter;
389 - const struct object_id *oid;
390 -
391 - oidset_iter_init(&drop_oids, &iter);
392 - while ((oid = oidset_iter_next(&iter)))
393 - printf("%s\n", oid_to_hex(oid));
394 - }
395 - }
396 -
397 213 if (delete_redundant && repo->repository_format_precious_objects)
398 214 die(_("cannot delete packs in a precious-objects repo"));
399 215
@@ -405,16 +221,14 @@ int cmd_repack(int argc,
405 221 pack_everything |= ALL_INTO_ONE;
406 222
407 223 if (write_bitmaps < 0) {
408 - if (write_midx == REPACK_WRITE_MIDX_NONE &&
409 - (!(pack_everything & ALL_INTO_ONE) || !is_bare_repository(repo)))
224 + if (!write_midx &&
225 + (!(pack_everything & ALL_INTO_ONE) || !is_bare_repository()))
410 226 write_bitmaps = 0;
411 227 }
412 228 if (po_args.pack_kept_objects < 0)
413 - po_args.pack_kept_objects = write_bitmaps > 0 &&
414 - write_midx == REPACK_WRITE_MIDX_NONE;
229 + po_args.pack_kept_objects = write_bitmaps > 0 && !write_midx;
415 230
416 - if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) &&
417 - write_midx == REPACK_WRITE_MIDX_NONE)
231 + if (write_bitmaps && !(pack_everything & ALL_INTO_ONE) && !write_midx)
418 232 die(_(incremental_bitmap_conflict_error));
419 233
420 234 if (write_bitmaps && po_args.local &&
@@ -430,14 +244,7 @@ int cmd_repack(int argc,
430 244 write_bitmaps = 0;
431 245 }
432 246
433 - if (config_ctx.midx_split_factor < 2)
434 - die(_("invalid value for %s: %d"), "--midx-split-factor",
435 - config_ctx.midx_split_factor);
436 - if (config_ctx.midx_new_layer_threshold < 1)
437 - die(_("invalid value for %s: %d"), "--midx-new-layer-threshold",
438 - config_ctx.midx_new_layer_threshold);
439 -
440 - if (write_midx != REPACK_WRITE_MIDX_NONE && write_bitmaps) {
247 + if (write_midx && write_bitmaps) {
441 248 struct strbuf path = STRBUF_INIT;
442 249
443 250 strbuf_addf(&path, "%s/%s_XXXXXX",
@@ -460,10 +267,6 @@ int cmd_repack(int argc,
460 267 if (geometry.split_factor) {
461 268 if (pack_everything)
462 269 die(_("options '%s' and '%s' cannot be used together"), "--geometric", "-A/-a");
463 - if (write_midx == REPACK_WRITE_MIDX_INCREMENTAL) {
464 - geometry.midx_layer_threshold = config_ctx.midx_new_layer_threshold;
465 - geometry.midx_layer_threshold_set = true;
466 - }
467 270 pack_geometry_init(&geometry, &existing, &po_args);
468 271 pack_geometry_split(&geometry);
469 272 }
@@ -494,7 +297,7 @@ int cmd_repack(int argc,
494 297 }
495 298 if (repo_has_promisor_remote(repo))
496 299 strvec_push(&cmd.args, "--exclude-promisor-objects");
497 - if (write_midx == REPACK_WRITE_MIDX_NONE) {
300 + if (!write_midx) {
498 301 if (write_bitmaps > 0)
499 302 strvec_push(&cmd.args, "--write-bitmap-index");
500 303 else if (write_bitmaps < 0)
@@ -504,8 +307,7 @@ int cmd_repack(int argc,
504 307 strvec_push(&cmd.args, "--delta-islands");
505 308
506 309 if (pack_everything & ALL_INTO_ONE) {
507 - repack_promisor_objects(repo, &po_args, &names, packtmp,
508 - (drop_filtered && !dry_run) ? &drop_oids : NULL);
310 + repack_promisor_objects(repo, &po_args, &names, packtmp);
509 311
510 312 if (existing_packs_has_non_kept(&existing) &&
511 313 delete_redundant &&
@@ -600,8 +402,6 @@ int cmd_repack(int argc,
600 402 }
601 403
602 404 if (!names.nr) {
603 - struct odb_source_files *files = odb_source_files_downcast(existing.source);
604 -
605 405 if (!po_args.quiet)
606 406 printf_ln(_("Nothing new to pack."));
607 407 /*
@@ -617,7 +417,7 @@ int cmd_repack(int argc,
617 417 * midx_has_unknown_packs() will make the decision for
618 418 * us.
619 419 */
620 - if (!get_multi_pack_index(files->packed))
420 + if (!get_multi_pack_index(repo->objects->sources))
621 421 midx_must_contain_cruft = 1;
622 422 }
623 423
@@ -688,7 +488,7 @@ int cmd_repack(int argc,
688 488 }
689 489 }
690 490
691 - if (po_args.filter_options.choice && !drop_filtered) {
491 + if (po_args.filter_options.choice) {
692 492 struct write_pack_opts opts = {
693 493 .po_args = &po_args,
694 494 .destination = filter_to,
@@ -716,13 +516,10 @@ int cmd_repack(int argc,
716 516 packtmp);
717 517 /* End of pack replacement. */
718 518
719 - if (delete_redundant && pack_everything & ALL_INTO_ONE) {
720 - if (write_midx == REPACK_WRITE_MIDX_INCREMENTAL)
721 - existing_packs_retain_midx_packs(&existing);
519 + if (delete_redundant && pack_everything & ALL_INTO_ONE)
722 520 existing_packs_mark_for_deletion(&existing, &names);
723 - }
724 521
725 - if (write_midx != REPACK_WRITE_MIDX_NONE) {
522 + if (write_midx) {
726 523 struct repack_write_midx_opts opts = {
727 524 .existing = &existing,
728 525 .geometry = &geometry,
@@ -731,13 +528,11 @@ int cmd_repack(int argc,
731 528 .packdir = packdir,
732 529 .show_progress = show_progress,
733 530 .write_bitmaps = write_bitmaps > 0,
734 - .midx_must_contain_cruft = midx_must_contain_cruft,
735 - .midx_split_factor = config_ctx.midx_split_factor,
736 - .midx_new_layer_threshold = config_ctx.midx_new_layer_threshold,
737 - .mode = write_midx,
531 + .midx_must_contain_cruft = midx_must_contain_cruft
738 532 };
739 533
740 - ret = repack_write_midx(&opts);
534 + ret = write_midx_included_packs(&opts);
535 +
741 536 if (ret)
742 537 goto cleanup;
743 538 }
@@ -746,15 +541,11 @@ int cmd_repack(int argc,
746 541
747 542 if (delete_redundant) {
748 543 int opts = 0;
749 - bool wrote_incremental_midx = write_midx == REPACK_WRITE_MIDX_INCREMENTAL;
750 -
751 - existing_packs_remove_redundant(&existing, packdir,
752 - wrote_incremental_midx);
544 + existing_packs_remove_redundant(&existing, packdir);
753 545
754 546 if (geometry.split_factor)
755 547 pack_geometry_remove_redundant(&geometry, &names,
756 - &existing, packdir,
757 - wrote_incremental_midx);
548 + &existing, packdir);
758 549 if (show_progress)
759 550 opts |= PRUNE_PACKED_VERBOSE;
760 551 prune_packed_objects(opts);
@@ -770,18 +561,16 @@ int cmd_repack(int argc,
770 561 update_server_info(repo, 0);
771 562
772 563 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX, 0)) {
773 - struct odb_source_files *files = odb_source_files_downcast(existing.source);
774 564 unsigned flags = 0;
775 -
776 565 if (git_env_bool(GIT_TEST_MULTI_PACK_INDEX_WRITE_INCREMENTAL, 0))
777 566 flags |= MIDX_WRITE_INCREMENTAL;
778 - write_midx_file(files->packed, NULL, NULL, flags);
567 + write_midx_file(repo->objects->sources,
568 + NULL, NULL, flags);
779 569 }
780 570
781 571 cleanup:
782 572 string_list_clear(&keep_pack_list, 0);
783 573 string_list_clear(&names, 1);
784 - oidset_clear(&drop_oids);
785 574 existing_packs_release(&existing);
786 575 pack_geometry_release(&geometry);
787 576 pack_objects_args_release(&po_args);
modified builtin/replace.c
@@ -127,7 +127,7 @@ static int for_each_replace_name(const char **argv, each_replace_name_fn fn)
127 127 }
128 128
129 129 strbuf_setlen(&ref, base_len);
130 - strbuf_add_oid_hex(&ref, &oid);
130 + strbuf_addstr(&ref, oid_to_hex(&oid));
131 131 full_hex = ref.buf + base_len;
132 132
133 133 if (refs_read_ref(get_main_ref_store(the_repository), ref.buf, &oid)) {
modified builtin/repo.c
@@ -7,14 +7,12 @@
7 7 #include "hex.h"
8 8 #include "odb.h"
9 9 #include "parse-options.h"
10 - #include "path.h"
11 10 #include "path-walk.h"
12 11 #include "progress.h"
13 12 #include "quote.h"
14 13 #include "ref-filter.h"
15 14 #include "refs.h"
16 15 #include "revision.h"
17 - #include "setup.h"
18 16 #include "strbuf.h"
19 17 #include "string-list.h"
20 18 #include "shallow.h"
@@ -60,7 +58,7 @@ struct repo_info_field {
60 58
61 59 static int get_layout_bare(struct repository *repo UNUSED, struct strbuf *buf)
62 60 {
63 - strbuf_addstr(buf, is_bare_repository(the_repository) ? "true" : "false");
61 + strbuf_addstr(buf, is_bare_repository() ? "true" : "false");
64 62 return 0;
65 63 }
66 64
@@ -77,50 +75,6 @@ static int get_object_format(struct repository *repo, struct strbuf *buf)
77 75 return 0;
78 76 }
79 77
80 - static int get_path_commondir_absolute(struct repository *repo, struct strbuf *buf)
81 - {
82 - const char *common_dir = repo_get_common_dir(repo);
83 -
84 - if (!common_dir)
85 - return error(_("unable to get common directory"));
86 -
87 - format_path(buf, common_dir, repo->prefix, PATH_FORMAT_CANONICAL);
88 - return 0;
89 - }
90 -
91 - static int get_path_commondir_relative(struct repository *repo, struct strbuf *buf)
92 - {
93 - const char *common_dir = repo_get_common_dir(repo);
94 -
95 - if (!common_dir)
96 - return error(_("unable to get common directory"));
97 -
98 - format_path(buf, common_dir, repo->prefix, PATH_FORMAT_RELATIVE);
99 - return 0;
100 - }
101 -
102 - static int get_path_gitdir_absolute(struct repository *repo, struct strbuf *buf)
103 - {
104 - const char *git_dir = repo_get_git_dir(repo);
105 -
106 - if (!git_dir)
107 - return error(_("unable to get git directory"));
108 -
109 - format_path(buf, git_dir, repo->prefix, PATH_FORMAT_CANONICAL);
110 - return 0;
111 - }
112 -
113 - static int get_path_gitdir_relative(struct repository *repo, struct strbuf *buf)
114 - {
115 - const char *git_dir = repo_get_git_dir(repo);
116 -
117 - if (!git_dir)
118 - return error(_("unable to get git directory"));
119 -
120 - format_path(buf, git_dir, repo->prefix, PATH_FORMAT_RELATIVE);
121 - return 0;
122 - }
123 -
124 78 static int get_references_format(struct repository *repo, struct strbuf *buf)
125 79 {
126 80 strbuf_addstr(buf,
@@ -133,10 +87,6 @@ static const struct repo_info_field repo_info_field[] = {
133 87 { "layout.bare", get_layout_bare },
134 88 { "layout.shallow", get_layout_shallow },
135 89 { "object.format", get_object_format },
136 - { "path.commondir.absolute", get_path_commondir_absolute },
137 - { "path.commondir.relative", get_path_commondir_relative },
138 - { "path.gitdir.absolute", get_path_gitdir_absolute },
139 - { "path.gitdir.relative", get_path_gitdir_relative },
140 90 { "references.format", get_references_format },
141 91 };
142 92
@@ -834,14 +784,13 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
834 784 for (size_t i = 0; i < oids->nr; i++) {
835 785 struct object_info oi = OBJECT_INFO_INIT;
836 786 unsigned long inflated;
837 - size_t inflated_st = 0;
838 787 struct commit *commit;
839 788 struct object *obj;
840 789 void *content;
841 790 off_t disk;
842 791 int eaten;
843 792
844 - oi.sizep = &inflated_st;
793 + oi.sizep = &inflated;
845 794 oi.disk_sizep = &disk;
846 795 oi.contentp = &content;
847 796
@@ -849,7 +798,6 @@ static int count_objects(const char *path UNUSED, struct oid_array *oids,
849 798 OBJECT_INFO_SKIP_FETCH_OBJECT |
850 799 OBJECT_INFO_QUICK) < 0)
851 800 continue;
852 - inflated = cast_size_t_to_ulong(inflated_st);
853 801
854 802 obj = parse_object_buffer(the_repository, &oids->oid[i], type,
855 803 inflated, content, &eaten);
modified builtin/reset.c
@@ -281,11 +281,11 @@ static void parse_args(struct pathspec *pathspec,
281 281 * Ok, argv[0] looks like a commit/tree; it should not
282 282 * be a filename.
283 283 */
284 - verify_non_filename(the_repository, prefix, argv[0]);
284 + verify_non_filename(prefix, argv[0]);
285 285 rev = *argv++;
286 286 } else {
287 287 /* Otherwise we treat this as a filename */
288 - verify_filename(the_repository, prefix, argv[0], 1);
288 + verify_filename(prefix, argv[0], 1);
289 289 }
290 290 }
291 291
@@ -468,9 +468,9 @@ int cmd_reset(int argc,
468 468 trace2_cmd_mode(reset_type_names[reset_type]);
469 469
470 470 if (reset_type != SOFT && (reset_type != MIXED || repo_get_work_tree(the_repository)))
471 - setup_work_tree(the_repository);
471 + setup_work_tree();
472 472
473 - if (reset_type == MIXED && is_bare_repository(the_repository))
473 + if (reset_type == MIXED && is_bare_repository())
474 474 die(_("%s reset is not allowed in a bare repository"),
475 475 _(reset_type_names[reset_type]));
476 476
modified builtin/rev-list.c
@@ -486,7 +486,7 @@ static int show_object_fast(
486 486 void *payload UNUSED)
487 487 {
488 488 fprintf(stdout, "%s\n", oid_to_hex(oid));
489 - return 0;
489 + return 1;
490 490 }
491 491
492 492 static void print_disk_usage(off_t size)
@@ -500,8 +500,7 @@ static void print_disk_usage(off_t size)
500 500 strbuf_release(&sb);
501 501 }
502 502
503 - static inline int parse_missing_action_value(struct repository *repo,
504 - const char *value)
503 + static inline int parse_missing_action_value(const char *value)
505 504 {
506 505 if (!strcmp(value, "error")) {
507 506 arg_missing_action = MA_ERROR;
@@ -510,25 +509,25 @@ static inline int parse_missing_action_value(struct repository *repo,
510 509
511 510 if (!strcmp(value, "allow-any")) {
512 511 arg_missing_action = MA_ALLOW_ANY;
513 - repo->fetch_if_missing = 0;
512 + fetch_if_missing = 0;
514 513 return 1;
515 514 }
516 515
517 516 if (!strcmp(value, "print")) {
518 517 arg_missing_action = MA_PRINT;
519 - repo->fetch_if_missing = 0;
518 + fetch_if_missing = 0;
520 519 return 1;
521 520 }
522 521
523 522 if (!strcmp(value, "print-info")) {
524 523 arg_missing_action = MA_PRINT_INFO;
525 - repo->fetch_if_missing = 0;
524 + fetch_if_missing = 0;
526 525 return 1;
527 526 }
528 527
529 528 if (!strcmp(value, "allow-promisor")) {
530 529 arg_missing_action = MA_ALLOW_PROMISOR;
531 - repo->fetch_if_missing = 0;
530 + fetch_if_missing = 0;
532 531 return 1;
533 532 }
534 533
@@ -693,7 +692,7 @@ static void prepare_maximal_independent(struct rev_info *revs)
693 692 int cmd_rev_list(int argc,
694 693 const char **argv,
695 694 const char *prefix,
696 - struct repository *repo)
695 + struct repository *repo UNUSED)
697 696 {
698 697 struct rev_info revs;
699 698 struct rev_list_info info;
@@ -746,10 +745,10 @@ int cmd_rev_list(int argc,
746 745 for (i = 1; i < argc; i++) {
747 746 const char *arg = argv[i];
748 747 if (!strcmp(arg, "--exclude-promisor-objects")) {
749 - repo->fetch_if_missing = 0;
748 + fetch_if_missing = 0;
750 749 revs.exclude_promisor_objects = 1;
751 750 } else if (skip_prefix(arg, "--missing=", &arg)) {
752 - parse_missing_action_value(repo, arg);
751 + parse_missing_action_value(arg);
753 752 } else if (!strcmp(arg, "-z")) {
754 753 line_term = '\0';
755 754 info_term = '\0';
modified builtin/rev-parse.c
@@ -10,7 +10,6 @@
10 10 #include "builtin.h"
11 11
12 12 #include "abspath.h"
13 - #include "bisect.h"
14 13 #include "config.h"
15 14 #include "commit.h"
16 15 #include "environment.h"
@@ -255,7 +254,7 @@ static int show_file(const char *arg, int output_prefix)
255 254 show_default();
256 255 if ((filter & (DO_NONFLAGS|DO_NOREV)) == (DO_NONFLAGS|DO_NOREV)) {
257 256 if (output_prefix) {
258 - const char *prefix = the_repository->prefix;
257 + const char *prefix = startup_info->prefix;
259 258 char *fname = prefix_filename(prefix, arg);
260 259 show(fname);
261 260 free(fname);
@@ -653,46 +652,53 @@ enum default_type {
653 652 DEFAULT_UNMODIFIED,
654 653 };
655 654
656 - static void print_path(const char *path, const char *prefix,
657 - enum format_type format, enum default_type def)
655 + static void print_path(const char *path, const char *prefix, enum format_type format, enum default_type def)
658 656 {
659 - struct strbuf sb = STRBUF_INIT;
660 - enum path_format fmt;
661 -
662 - if (format == FORMAT_DEFAULT) {
663 - switch (def) {
664 - case DEFAULT_RELATIVE:
665 - fmt = PATH_FORMAT_RELATIVE;
666 - break;
667 - case DEFAULT_RELATIVE_IF_SHARED:
668 - fmt = PATH_FORMAT_RELATIVE_IF_SHARED;
669 - break;
670 - case DEFAULT_CANONICAL:
671 - fmt = PATH_FORMAT_CANONICAL;
672 - break;
673 - case DEFAULT_UNMODIFIED:
674 - default:
675 - fmt = PATH_FORMAT_UNMODIFIED;
676 - break;
657 + char *cwd = NULL;
658 + /*
659 + * We don't ever produce a relative path if prefix is NULL, so set the
660 + * prefix to the current directory so that we can produce a relative
661 + * path whenever possible. If we're using RELATIVE_IF_SHARED mode, then
662 + * we want an absolute path unless the two share a common prefix, so don't
663 + * set it in that case, since doing so causes a relative path to always
664 + * be produced if possible.
665 + */
666 + if (!prefix && (format != FORMAT_DEFAULT || def != DEFAULT_RELATIVE_IF_SHARED))
667 + prefix = cwd = xgetcwd();
668 + if (format == FORMAT_DEFAULT && def == DEFAULT_UNMODIFIED) {
669 + puts(path);
670 + } else if (format == FORMAT_RELATIVE ||
671 + (format == FORMAT_DEFAULT && def == DEFAULT_RELATIVE)) {
672 + /*
673 + * In order for relative_path to work as expected, we need to
674 + * make sure that both paths are absolute paths. If we don't,
675 + * we can end up with an unexpected absolute path that the user
676 + * didn't want.
677 + */
678 + struct strbuf buf = STRBUF_INIT, realbuf = STRBUF_INIT, prefixbuf = STRBUF_INIT;
679 + if (!is_absolute_path(path)) {
680 + strbuf_realpath_forgiving(&realbuf, path, 1);
681 + path = realbuf.buf;
677 682 }
678 - } else {
679 - switch (format) {
680 - case FORMAT_RELATIVE:
681 - fmt = PATH_FORMAT_RELATIVE;
682 - break;
683 - case FORMAT_CANONICAL:
684 - fmt = PATH_FORMAT_CANONICAL;
685 - break;
686 - default:
687 - fmt = PATH_FORMAT_UNMODIFIED;
688 - break;
683 + if (!is_absolute_path(prefix)) {
684 + strbuf_realpath_forgiving(&prefixbuf, prefix, 1);
685 + prefix = prefixbuf.buf;
689 686 }
687 + puts(relative_path(path, prefix, &buf));
688 + strbuf_release(&buf);
689 + strbuf_release(&realbuf);
690 + strbuf_release(&prefixbuf);
691 + } else if (format == FORMAT_DEFAULT && def == DEFAULT_RELATIVE_IF_SHARED) {
692 + struct strbuf buf = STRBUF_INIT;
693 + puts(relative_path(path, prefix, &buf));
694 + strbuf_release(&buf);
695 + } else {
696 + struct strbuf buf = STRBUF_INIT;
697 + strbuf_realpath_forgiving(&buf, path, 1);
698 + puts(buf.buf);
699 + strbuf_release(&buf);
690 700 }
691 -
692 - format_path(&sb, path, prefix, fmt);
693 - puts(sb.buf);
694 -
695 - strbuf_release(&sb);
701 + free(cwd);
696 702 }
697 703
698 704 int cmd_rev_parse(int argc,
@@ -733,7 +739,7 @@ int cmd_rev_parse(int argc,
733 739
734 740 /* No options; just report on whether we're in a git repo or not. */
735 741 if (argc == 1) {
736 - setup_git_directory(the_repository);
742 + setup_git_directory();
737 743 repo_config(the_repository, git_default_config, NULL);
738 744 return 0;
739 745 }
@@ -743,7 +749,7 @@ int cmd_rev_parse(int argc,
743 749
744 750 if (as_is) {
745 751 if (show_file(arg, output_prefix) && as_is < 2)
746 - verify_filename(the_repository, prefix, arg, 0);
752 + verify_filename(prefix, arg, 0);
747 753 continue;
748 754 }
749 755
@@ -768,7 +774,7 @@ int cmd_rev_parse(int argc,
768 774
769 775 /* The rest of the options require a git repository. */
770 776 if (!did_repo_setup) {
771 - prefix = setup_git_directory(the_repository);
777 + prefix = setup_git_directory();
772 778 repo_config(the_repository, git_default_config, NULL);
773 779 did_repo_setup = 1;
774 780
@@ -832,8 +838,7 @@ int cmd_rev_parse(int argc,
832 838 prefix = argv[++i];
833 839 if (!prefix)
834 840 die(_("--prefix requires an argument"));
835 - FREE_AND_NULL(the_repository->prefix);
836 - the_repository->prefix = xstrdup(prefix);
841 + startup_info->prefix = prefix;
837 842 output_prefix = 1;
838 843 continue;
839 844 }
@@ -935,23 +940,13 @@ int cmd_rev_parse(int argc,
935 940 continue;
936 941 }
937 942 if (!strcmp(arg, "--bisect")) {
938 - char *prefix;
939 - char *term_bad = NULL;
940 - char *term_good = NULL;
941 943 struct refs_for_each_ref_options opts = { 0 };
942 - read_bisect_terms(&term_bad, &term_good);
943 - prefix = xstrfmt("refs/bisect/%s", term_bad);
944 - opts.prefix = prefix;
944 + opts.prefix = "refs/bisect/bad";
945 945 refs_for_each_ref_ext(get_main_ref_store(the_repository),
946 946 show_reference, NULL, &opts);
947 - free(prefix);
948 - prefix = xstrfmt("refs/bisect/%s", term_good);
949 - opts.prefix = prefix;
947 + opts.prefix = "refs/bisect/good";
950 948 refs_for_each_ref_ext(get_main_ref_store(the_repository),
951 949 anti_reference, NULL, &opts);
952 - free(prefix);
953 - free(term_good);
954 - free(term_bad);
955 950 continue;
956 951 }
957 952 if (opt_with_value(arg, "--branches", &arg)) {
@@ -1011,7 +1006,7 @@ int cmd_rev_parse(int argc,
1011 1006 }
1012 1007 if (!strcmp(arg, "--show-cdup")) {
1013 1008 const char *pfx = prefix;
1014 - if (!is_inside_work_tree(the_repository)) {
1009 + if (!is_inside_work_tree()) {
1015 1010 const char *work_tree =
1016 1011 repo_get_work_tree(the_repository);
1017 1012 if (work_tree)
@@ -1068,17 +1063,17 @@ int cmd_rev_parse(int argc,
1068 1063 continue;
1069 1064 }
1070 1065 if (!strcmp(arg, "--is-inside-git-dir")) {
1071 - printf("%s\n", is_inside_git_dir(the_repository) ? "true"
1066 + printf("%s\n", is_inside_git_dir() ? "true"
1072 1067 : "false");
1073 1068 continue;
1074 1069 }
1075 1070 if (!strcmp(arg, "--is-inside-work-tree")) {
1076 - printf("%s\n", is_inside_work_tree(the_repository) ? "true"
1071 + printf("%s\n", is_inside_work_tree() ? "true"
1077 1072 : "false");
1078 1073 continue;
1079 1074 }
1080 1075 if (!strcmp(arg, "--is-bare-repository")) {
1081 - printf("%s\n", is_bare_repository(the_repository) ? "true"
1076 + printf("%s\n", is_bare_repository() ? "true"
1082 1077 : "false");
1083 1078 continue;
1084 1079 }
@@ -1178,7 +1173,7 @@ int cmd_rev_parse(int argc,
1178 1173 as_is = 1;
1179 1174 if (!show_file(arg, output_prefix))
1180 1175 continue;
1181 - verify_filename(the_repository, prefix, arg, 1);
1176 + verify_filename(prefix, arg, 1);
1182 1177 }
1183 1178 strbuf_release(&buf);
1184 1179 if (verify) {
modified builtin/rm.c
@@ -296,7 +296,7 @@ int cmd_rm(int argc,
296 296 die(_("No pathspec was given. Which files should I remove?"));
297 297
298 298 if (!index_only)
299 - setup_work_tree(the_repository);
299 + setup_work_tree();
300 300
301 301 prepare_repo_settings(the_repository);
302 302 the_repository->settings.command_requires_full_index = 0;
modified builtin/send-pack.c
@@ -153,7 +153,7 @@ int cmd_send_pack(int argc,
153 153 const char *prefix,
154 154 struct repository *repo)
155 155 {
156 - struct refspec rs;
156 + struct refspec rs = REFSPEC_INIT_PUSH;
157 157 const char *remote_name = NULL;
158 158 struct remote *remote = NULL;
159 159 const char *dest = NULL;
@@ -214,9 +214,6 @@ int cmd_send_pack(int argc,
214 214
215 215 repo_config(repo, send_pack_config, NULL);
216 216 argc = parse_options(argc, argv, prefix, options, send_pack_usage, 0);
217 -
218 - refspec_init_push(&rs, repo->hash_algo);
219 -
220 217 if (argc > 0) {
221 218 dest = argv[0];
222 219 refspec_appendn(&rs, argv + 1, argc - 1);
@@ -276,9 +273,8 @@ int cmd_send_pack(int argc,
276 273 fd[0] = 0;
277 274 fd[1] = 1;
278 275 } else {
279 - conn = git_connect(fd, dest, GIT_CONNECT_RECEIVE_PACK,
280 - receivepack,
281 - args.verbose ? CONNECT_VERBOSE : 0);
276 + conn = git_connect(fd, dest, "git-receive-pack", receivepack,
277 + args.verbose ? CONNECT_VERBOSE : 0);
282 278 }
283 279
284 280 packet_reader_init(&reader, fd[0], NULL, 0,
modified builtin/shortlog.c
@@ -433,8 +433,6 @@ int cmd_shortlog(int argc,
433 433 case PARSE_OPT_UNKNOWN:
434 434 break;
435 435 case PARSE_OPT_HELP:
436 - exit(0);
437 - case PARSE_OPT_HELP_ERROR:
438 436 case PARSE_OPT_ERROR:
439 437 case PARSE_OPT_SUBCOMMAND:
440 438 exit(129);
modified builtin/show-branch.c
@@ -62,10 +62,11 @@ static const char *get_color_reset_code(void)
62 62
63 63 static struct commit *interesting(struct prio_queue *queue)
64 64 {
65 - struct commit *commit;
66 - prio_queue_for_each(queue, commit) {
67 - if (!(commit->object.flags & UNINTERESTING))
68 - return commit;
65 + for (size_t i = 0; i < queue->nr; i++) {
66 + struct commit *commit = queue->array[i].data;
67 + if (commit->object.flags & UNINTERESTING)
68 + continue;
69 + return commit;
69 70 }
70 71 return NULL;
71 72 }
@@ -227,18 +228,17 @@ static void join_revs(struct prio_queue *queue,
227 228 {
228 229 int all_mask = ((1u << (REV_SHIFT + num_rev)) - 1);
229 230 int all_revs = all_mask & ~((1u << REV_SHIFT) - 1);
230 - struct commit *commit;
231 231
232 - while ((commit = prio_queue_peek(queue))) {
232 + while (queue->nr) {
233 233 struct commit_list *parents;
234 234 int still_interesting = !!interesting(queue);
235 + struct commit *commit = prio_queue_peek(queue);
236 + bool get_pending = true;
235 237 int flags = commit->object.flags & all_mask;
236 238
237 239 if (!still_interesting && extra <= 0)
238 240 break;
239 241
240 - prio_queue_get(queue);
241 -
242 242 mark_seen(commit, seen_p);
243 243 if ((flags & all_revs) == all_revs)
244 244 flags |= UNINTERESTING;
@@ -254,8 +254,14 @@ static void join_revs(struct prio_queue *queue,
254 254 if (mark_seen(p, seen_p) && !still_interesting)
255 255 extra--;
256 256 p->object.flags |= flags;
257 - prio_queue_put(queue, p);
257 + if (get_pending)
258 + prio_queue_replace(queue, p);
259 + else
260 + prio_queue_put(queue, p);
261 + get_pending = false;
258 262 }
263 + if (get_pending)
264 + prio_queue_get(queue);
259 265 }
260 266
261 267 /*
modified builtin/sparse-checkout.c
@@ -63,7 +63,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
63 63 int res;
64 64 struct repo_config_values *cfg = repo_config_values(the_repository);
65 65
66 - setup_work_tree(the_repository);
66 + setup_work_tree();
67 67 if (!cfg->apply_sparse_checkout)
68 68 die(_("this worktree is not sparse"));
69 69
@@ -73,7 +73,7 @@ static int sparse_checkout_list(int argc, const char **argv, const char *prefix,
73 73
74 74 memset(&pl, 0, sizeof(pl));
75 75
76 - pl.use_cone_patterns = cfg->core_sparse_checkout_cone;
76 + pl.use_cone_patterns = core_sparse_checkout_cone;
77 77
78 78 sparse_filename = get_sparse_checkout_filename();
79 79 res = add_patterns_from_file_to_list(sparse_filename, "", 0, &pl, NULL, 0);
@@ -229,7 +229,7 @@ static int update_working_directory(struct repository *r,
229 229 o.dst_index = r->index;
230 230 o.skip_sparse_checkout = 0;
231 231
232 - setup_work_tree(the_repository);
232 + setup_work_tree();
233 233
234 234 repo_hold_locked_index(r, &lock_file, LOCK_DIE_ON_ERROR);
235 235
@@ -334,15 +334,13 @@ static int write_patterns_and_update(struct repository *repo,
334 334 FILE *fp;
335 335 struct lock_file lk = LOCK_INIT;
336 336 int result;
337 - struct repo_config_values *cfg = repo_config_values(the_repository);
338 337
339 338 sparse_filename = get_sparse_checkout_filename();
340 339
341 340 if (safe_create_leading_directories(repo, sparse_filename))
342 341 die(_("failed to create directory for sparse-checkout file"));
343 342
344 - repo_hold_lock_file_for_update(repo, &lk, sparse_filename,
345 - LOCK_DIE_ON_ERROR);
343 + hold_lock_file_for_update(&lk, sparse_filename, LOCK_DIE_ON_ERROR);
346 344
347 345 result = update_working_directory(repo, pl);
348 346 if (result) {
@@ -355,7 +353,7 @@ static int write_patterns_and_update(struct repository *repo,
355 353 if (!fp)
356 354 die_errno(_("unable to fdopen %s"), get_lock_file_path(&lk));
357 355
358 - if (cfg->core_sparse_checkout_cone)
356 + if (core_sparse_checkout_cone)
359 357 write_cone_to_file(fp, pl);
360 358 else
361 359 write_patterns_to_file(fp, pl);
@@ -404,15 +402,15 @@ static enum sparse_checkout_mode update_cone_mode(int *cone_mode) {
404 402
405 403 /* If not specified, use previous definition of cone mode */
406 404 if (*cone_mode == -1 && cfg->apply_sparse_checkout)
407 - *cone_mode = cfg->core_sparse_checkout_cone;
405 + *cone_mode = core_sparse_checkout_cone;
408 406
409 407 /* Set cone/non-cone mode appropriately */
410 408 cfg->apply_sparse_checkout = 1;
411 409 if (*cone_mode == 1 || *cone_mode == -1) {
412 - cfg->core_sparse_checkout_cone = 1;
410 + core_sparse_checkout_cone = 1;
413 411 return MODE_CONE_PATTERNS;
414 412 }
415 - cfg->core_sparse_checkout_cone = 0;
413 + core_sparse_checkout_cone = 0;
416 414 return MODE_ALL_PATTERNS;
417 415 }
418 416
@@ -470,7 +468,7 @@ static int sparse_checkout_init(int argc, const char **argv, const char *prefix,
470 468 OPT_END(),
471 469 };
472 470
473 - setup_work_tree(the_repository);
471 + setup_work_tree();
474 472 repo_read_index(repo);
475 473
476 474 init_opts.cone_mode = -1;
@@ -579,9 +577,7 @@ static void add_patterns_from_input(struct pattern_list *pl,
579 577 FILE *file)
580 578 {
581 579 int i;
582 - struct repo_config_values *cfg = repo_config_values(the_repository);
583 -
584 - if (cfg->core_sparse_checkout_cone) {
580 + if (core_sparse_checkout_cone) {
585 581 struct strbuf line = STRBUF_INIT;
586 582
587 583 hashmap_init(&pl->recursive_hashmap, pl_hashmap_cmp, NULL, 0);
@@ -640,14 +636,13 @@ static void add_patterns_cone_mode(int argc, const char **argv,
640 636 struct pattern_entry *pe;
641 637 struct hashmap_iter iter;
642 638 struct pattern_list existing;
643 - struct repo_config_values *cfg = repo_config_values(the_repository);
644 639 char *sparse_filename = get_sparse_checkout_filename();
645 640
646 641 add_patterns_from_input(pl, argc, argv,
647 642 use_stdin ? stdin : NULL);
648 643
649 644 memset(&existing, 0, sizeof(existing));
650 - existing.use_cone_patterns = cfg->core_sparse_checkout_cone;
645 + existing.use_cone_patterns = core_sparse_checkout_cone;
651 646
652 647 if (add_patterns_from_file_to_list(sparse_filename, "", 0,
653 648 &existing, NULL, 0))
@@ -695,7 +690,7 @@ static int modify_pattern_list(struct repository *repo,
695 690
696 691 switch (m) {
697 692 case ADD:
698 - if (cfg->core_sparse_checkout_cone)
693 + if (core_sparse_checkout_cone)
699 694 add_patterns_cone_mode(args->nr, args->v, pl, use_stdin);
700 695 else
701 696 add_patterns_literal(args->nr, args->v, pl, use_stdin);
@@ -728,12 +723,11 @@ static void sanitize_paths(struct repository *repo,
728 723 const char *prefix, int skip_checks)
729 724 {
730 725 int i;
731 - struct repo_config_values *cfg = repo_config_values(the_repository);
732 726
733 727 if (!args->nr)
734 728 return;
735 729
736 - if (prefix && *prefix && cfg->core_sparse_checkout_cone) {
730 + if (prefix && *prefix && core_sparse_checkout_cone) {
737 731 /*
738 732 * The args are not pathspecs, so unfortunately we
739 733 * cannot imitate how cmd_add() uses parse_pathspec().
@@ -741,8 +735,7 @@ static void sanitize_paths(struct repository *repo,
741 735 int prefix_len = strlen(prefix);
742 736
743 737 for (i = 0; i < args->nr; i++) {
744 - char *prefixed_path = prefix_path(the_repository, prefix,
745 - prefix_len, args->v[i]);
738 + char *prefixed_path = prefix_path(prefix, prefix_len, args->v[i]);
746 739 strvec_replace(args, i, prefixed_path);
747 740 free(prefixed_path);
748 741 }
@@ -751,10 +744,10 @@ static void sanitize_paths(struct repository *repo,
751 744 if (skip_checks)
752 745 return;
753 746
754 - if (prefix && *prefix && !cfg->core_sparse_checkout_cone)
747 + if (prefix && *prefix && !core_sparse_checkout_cone)
755 748 die(_("please run from the toplevel directory in non-cone mode"));
756 749
757 - if (cfg->core_sparse_checkout_cone) {
750 + if (core_sparse_checkout_cone) {
758 751 for (i = 0; i < args->nr; i++) {
759 752 if (args->v[i][0] == '/')
760 753 die(_("specify directories rather than patterns (no leading slash)"));
@@ -776,7 +769,7 @@ static void sanitize_paths(struct repository *repo,
776 769 if (S_ISSPARSEDIR(ce->ce_mode))
777 770 continue;
778 771
779 - if (cfg->core_sparse_checkout_cone)
772 + if (core_sparse_checkout_cone)
780 773 die(_("'%s' is not a directory; to treat it as a directory anyway, rerun with --skip-checks"), args->v[i]);
781 774 else
782 775 warning(_("pass a leading slash before paths such as '%s' if you want a single file (see NON-CONE PROBLEMS in the git-sparse-checkout manual)."), args->v[i]);
@@ -808,7 +801,7 @@ static int sparse_checkout_add(int argc, const char **argv, const char *prefix,
808 801 int ret;
809 802 struct repo_config_values *cfg = repo_config_values(the_repository);
810 803
811 - setup_work_tree(the_repository);
804 + setup_work_tree();
812 805 if (!cfg->apply_sparse_checkout)
813 806 die(_("no sparse-checkout to add to"));
814 807
@@ -843,7 +836,6 @@ static struct sparse_checkout_set_opts {
843 836 static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
844 837 struct repository *repo)
845 838 {
846 - struct repo_config_values *cfg = repo_config_values(the_repository);
847 839 int default_patterns_nr = 2;
848 840 const char *default_patterns[] = {"/*", "!/*/", NULL};
849 841
@@ -863,7 +855,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
863 855 struct strvec patterns = STRVEC_INIT;
864 856 int ret;
865 857
866 - setup_work_tree(the_repository);
858 + setup_work_tree();
867 859 repo_read_index(repo);
868 860
869 861 set_opts.cone_mode = -1;
@@ -881,7 +873,7 @@ static int sparse_checkout_set(int argc, const char **argv, const char *prefix,
881 873 * non-cone mode, if nothing is specified, manually select just the
882 874 * top-level directory (much as 'init' would do).
883 875 */
884 - if (!cfg->core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {
876 + if (!core_sparse_checkout_cone && !set_opts.use_stdin && argc == 0) {
885 877 for (int i = 0; i < default_patterns_nr; i++)
886 878 strvec_push(&patterns, default_patterns[i]);
887 879 } else {
@@ -919,7 +911,7 @@ static int sparse_checkout_reapply(int argc, const char **argv,
919 911 };
920 912 struct repo_config_values *cfg = repo_config_values(the_repository);
921 913
922 - setup_work_tree(the_repository);
914 + setup_work_tree();
923 915 if (!cfg->apply_sparse_checkout)
924 916 die(_("must be in a sparse-checkout to reapply sparsity patterns"));
925 917
@@ -982,10 +974,10 @@ static int sparse_checkout_clean(int argc, const char **argv,
982 974 OPT_END(),
983 975 };
984 976
985 - setup_work_tree(the_repository);
977 + setup_work_tree();
986 978 if (!cfg->apply_sparse_checkout)
987 979 die(_("must be in a sparse-checkout to clean directories"));
988 - if (!cfg->core_sparse_checkout_cone)
980 + if (!core_sparse_checkout_cone)
989 981 die(_("must be in a cone-mode sparse-checkout to clean directories"));
990 982
991 983 argc = parse_options(argc, argv, prefix,
@@ -1060,7 +1052,7 @@ static int sparse_checkout_disable(int argc, const char **argv,
1060 1052 * forcibly return to a dense checkout regardless of initial state.
1061 1053 */
1062 1054
1063 - setup_work_tree(the_repository);
1055 + setup_work_tree();
1064 1056 argc = parse_options(argc, argv, prefix,
1065 1057 builtin_sparse_checkout_disable_options,
1066 1058 builtin_sparse_checkout_disable_usage, 0);
@@ -1149,7 +1141,6 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
1149 1141 FILE *fp;
1150 1142 int ret;
1151 1143 struct pattern_list pl = {0};
1152 - struct repo_config_values *cfg = repo_config_values(the_repository);
1153 1144 char *sparse_filename;
1154 1145 check_rules_opts.cone_mode = -1;
1155 1146
@@ -1161,7 +1152,7 @@ static int sparse_checkout_check_rules(int argc, const char **argv, const char *
1161 1152 check_rules_opts.cone_mode = 1;
1162 1153
1163 1154 update_cone_mode(&check_rules_opts.cone_mode);
1164 - pl.use_cone_patterns = cfg->core_sparse_checkout_cone;
1155 + pl.use_cone_patterns = core_sparse_checkout_cone;
1165 1156 if (check_rules_opts.rules_file) {
1166 1157 fp = xfopen(check_rules_opts.rules_file, "r");
1167 1158 add_patterns_from_input(&pl, argc, argv, fp);
modified builtin/stash.c
@@ -44,7 +44,7 @@
44 44 #define BUILTIN_STASH_POP_USAGE \
45 45 N_("git stash pop [--index] [-q | --quiet] [<stash>]")
46 46 #define BUILTIN_STASH_APPLY_USAGE \
47 - N_("git stash apply [--index] [-q | --quiet] [--label-ours=<label>] [--label-theirs=<label>] [--label-base=<label>] [<stash>]")
47 + N_("git stash apply [--index] [-q | --quiet] [<stash>]")
48 48 #define BUILTIN_STASH_BRANCH_USAGE \
49 49 N_("git stash branch <branchname> [<stash>]")
50 50 #define BUILTIN_STASH_STORE_USAGE \
@@ -372,56 +372,6 @@ static int reset_tree(struct object_id *i_tree, int update, int reset)
372 372 return 0;
373 373 }
374 374
375 - static int create_index_from_tree(const struct object_id *tree_id,
376 - const char *index_path)
377 - {
378 - int nr_trees = 1;
379 - int ret = 0;
380 - struct unpack_trees_options opts;
381 - struct tree_desc t[MAX_UNPACK_TREES];
382 - struct tree *tree;
383 - struct index_state dst_istate = INDEX_STATE_INIT(the_repository);
384 - struct lock_file lock_file = LOCK_INIT;
385 -
386 - repo_read_index_preload(the_repository, NULL, 0);
387 - refresh_index(the_repository->index, REFRESH_QUIET, NULL, NULL, NULL);
388 -
389 - hold_lock_file_for_update(&lock_file, index_path, LOCK_DIE_ON_ERROR);
390 -
391 - memset(&opts, 0, sizeof(opts));
392 -
393 - tree = repo_parse_tree_indirect(the_repository, tree_id);
394 - if (!tree || repo_parse_tree(the_repository, tree)) {
395 - ret = -1;
396 - goto done;
397 - }
398 -
399 - init_tree_desc(t, &tree->object.oid, tree->buffer, tree->size);
400 -
401 - opts.head_idx = 1;
402 - opts.src_index = the_repository->index;
403 - opts.dst_index = &dst_istate;
404 - opts.merge = 1;
405 - opts.reset = UNPACK_RESET_PROTECT_UNTRACKED;
406 - opts.fn = oneway_merge;
407 -
408 - if (unpack_trees(nr_trees, t, &opts)) {
409 - ret = -1;
410 - goto done;
411 - }
412 -
413 - if (write_locked_index(&dst_istate, &lock_file, COMMIT_LOCK)) {
414 - ret = error(_("unable to write new index file"));
415 - goto done;
416 - }
417 -
418 - done:
419 - release_index(&dst_istate);
420 - if (ret)
421 - rollback_lock_file(&lock_file);
422 - return ret;
423 - }
424 -
425 375 static int diff_tree_binary(struct strbuf *out, struct object_id *w_commit)
426 376 {
427 377 struct child_process cp = CHILD_PROCESS_INIT;
@@ -641,9 +591,7 @@ static void unstage_changes_unless_new(struct object_id *orig_tree)
641 591 }
642 592
643 593 static int do_apply_stash(const char *prefix, struct stash_info *info,
644 - int index, int quiet,
645 - const char *label_ours, const char *label_theirs,
646 - const char *label_base)
594 + int index, int quiet)
647 595 {
648 596 int clean, ret;
649 597 int has_index = index;
@@ -695,9 +643,9 @@ static int do_apply_stash(const char *prefix, struct stash_info *info,
695 643
696 644 init_ui_merge_options(&o, the_repository);
697 645
698 - o.branch1 = label_ours ? label_ours : "Updated upstream";
699 - o.branch2 = label_theirs ? label_theirs : "Stashed changes";
700 - o.ancestor = label_base ? label_base : "Stash base";
646 + o.branch1 = "Updated upstream";
647 + o.branch2 = "Stashed changes";
648 + o.ancestor = "Stash base";
701 649
702 650 if (oideq(&info->b_tree, &c_tree))
703 651 o.branch1 = "Version stash was based on";
@@ -775,18 +723,11 @@ static int apply_stash(int argc, const char **argv, const char *prefix,
775 723 int ret = -1;
776 724 int quiet = 0;
777 725 int index = use_index;
778 - const char *label_ours = NULL, *label_theirs = NULL, *label_base = NULL;
779 726 struct stash_info info = STASH_INFO_INIT;
780 727 struct option options[] = {
781 728 OPT__QUIET(&quiet, N_("be quiet, only report errors")),
782 729 OPT_BOOL(0, "index", &index,
783 730 N_("attempt to recreate the index")),
784 - OPT_STRING(0, "label-ours", &label_ours, N_("label"),
785 - N_("label for the upstream side in conflict markers")),
786 - OPT_STRING(0, "label-theirs", &label_theirs, N_("label"),
787 - N_("label for the stashed side in conflict markers")),
788 - OPT_STRING(0, "label-base", &label_base, N_("label"),
789 - N_("label for the base in diff3 conflict markers")),
790 731 OPT_END()
791 732 };
792 733
@@ -796,8 +737,7 @@ static int apply_stash(int argc, const char **argv, const char *prefix,
796 737 if (get_stash_info(&info, argc, argv))
797 738 goto cleanup;
798 739
799 - ret = do_apply_stash(prefix, &info, index, quiet,
800 - label_ours, label_theirs, label_base);
740 + ret = do_apply_stash(prefix, &info, index, quiet);
801 741 cleanup:
802 742 free_stash_info(&info);
803 743 return ret;
@@ -896,8 +836,7 @@ static int pop_stash(int argc, const char **argv, const char *prefix,
896 836 if (get_stash_info_assert(&info, argc, argv))
897 837 goto cleanup;
898 838
899 - if ((ret = do_apply_stash(prefix, &info, index, quiet,
900 - NULL, NULL, NULL)))
839 + if ((ret = do_apply_stash(prefix, &info, index, quiet)))
901 840 printf_ln(_("The stash entry is kept in case "
902 841 "you need it again."));
903 842 else
@@ -938,8 +877,7 @@ static int branch_stash(int argc, const char **argv, const char *prefix,
938 877 strvec_push(&cp.args, oid_to_hex(&info.b_commit));
939 878 ret = run_command(&cp);
940 879 if (!ret)
941 - ret = do_apply_stash(prefix, &info, 1, 0,
942 - NULL, NULL, NULL);
880 + ret = do_apply_stash(prefix, &info, 1, 0);
943 881 if (!ret && info.is_stash_ref)
944 882 ret = do_drop_stash(&info, 0);
945 883
@@ -1371,26 +1309,18 @@ static int stash_patch(struct stash_info *info, const struct pathspec *ps,
1371 1309 struct interactive_options *interactive_opts)
1372 1310 {
1373 1311 int ret = 0;
1312 + struct child_process cp_read_tree = CHILD_PROCESS_INIT;
1374 1313 struct child_process cp_diff_tree = CHILD_PROCESS_INIT;
1375 - struct commit *head_commit;
1376 - const struct object_id *head_tree;
1377 1314 struct index_state istate = INDEX_STATE_INIT(the_repository);
1378 1315 char *old_index_env = NULL, *old_repo_index_file;
1379 1316
1380 1317 remove_path(stash_index_path.buf);
1381 1318
1382 - head_commit = lookup_commit(the_repository, &info->b_commit);
1383 - if (!head_commit || repo_parse_commit(the_repository, head_commit)) {
1384 - ret = -1;
1385 - goto done;
1386 - }
1387 - head_tree = get_commit_tree_oid(head_commit);
1388 - if (!head_tree) {
1389 - ret = -1;
1390 - goto done;
1391 - }
1392 -
1393 - if (create_index_from_tree(head_tree, stash_index_path.buf)) {
1319 + cp_read_tree.git_cmd = 1;
1320 + strvec_pushl(&cp_read_tree.args, "read-tree", "HEAD", NULL);
1321 + strvec_pushf(&cp_read_tree.env, "GIT_INDEX_FILE=%s",
1322 + stash_index_path.buf);
1323 + if (run_command(&cp_read_tree)) {
1394 1324 ret = -1;
1395 1325 goto done;
1396 1326 }
@@ -1702,8 +1632,8 @@ static int do_push_stash(const struct pathspec *ps, const char *stash_msg, int q
1702 1632 if (!include_untracked && ps->nr) {
1703 1633 char *ps_matched = xcalloc(ps->nr, 1);
1704 1634
1705 - if (pathspec_needs_expanded_index(the_repository->index, ps))
1706 - ensure_full_index(the_repository->index);
1635 + /* TODO: audit for interaction with sparse-index. */
1636 + ensure_full_index(the_repository->index);
1707 1637 for (size_t i = 0; i < the_repository->index->cache_nr; i++)
1708 1638 ce_path_match(the_repository->index, the_repository->index->cache[i], ps,
1709 1639 ps_matched);
modified builtin/stripspace.c
@@ -54,7 +54,7 @@ int cmd_stripspace(int argc,
54 54 usage_with_options(stripspace_usage, options);
55 55
56 56 if (mode == STRIP_COMMENTS || mode == COMMENT_LINES) {
57 - setup_git_directory_gently(the_repository, &nongit);
57 + setup_git_directory_gently(&nongit);
58 58 repo_config(the_repository, git_default_config, NULL);
59 59 }
60 60
modified builtin/submodule--helper.c
@@ -549,13 +549,12 @@ static void create_default_gitdir_config(const char *submodule_name)
549 549 }
550 550
551 551 /* Case 2.4: If all the above failed, try a hash of the name as a last resort */
552 - header_len = snprintf(header, sizeof(header),
553 - "blob %"PRIuMAX, (uintmax_t)strlen(submodule_name));
554 - git_hash_init(&ctx, the_hash_algo);
555 - git_hash_update(&ctx, header, header_len);
556 - git_hash_update(&ctx, "\0", 1);
557 - git_hash_update(&ctx, submodule_name, strlen(submodule_name));
558 - git_hash_final(raw_name_hash, &ctx);
552 + header_len = snprintf(header, sizeof(header), "blob %zu", strlen(submodule_name));
553 + the_hash_algo->init_fn(&ctx);
554 + the_hash_algo->update_fn(&ctx, header, header_len);
555 + the_hash_algo->update_fn(&ctx, "\0", 1);
556 + the_hash_algo->update_fn(&ctx, submodule_name, strlen(submodule_name));
557 + the_hash_algo->final_fn(raw_name_hash, &ctx);
559 558 hash_to_hex_algop_r(hex_name_hash, raw_name_hash, the_hash_algo);
560 559 strbuf_reset(&gitdir_path);
561 560 repo_git_path_append(the_repository, &gitdir_path, "modules/%s", hex_name_hash);
@@ -1251,7 +1250,7 @@ static int compute_summary_module_list(struct object_id *head_oid,
1251 1250
1252 1251 if (!info->cached) {
1253 1252 if (diff_cmd == DIFF_INDEX)
1254 - setup_work_tree(the_repository);
1253 + setup_work_tree();
1255 1254 if (repo_read_index_preload(the_repository, &rev.diffopt.pathspec, 0) < 0) {
1256 1255 perror("repo_read_index_preload");
1257 1256 ret = -1;
@@ -2991,7 +2990,7 @@ static int module_update(int argc, const char **argv, const char *prefix,
2991 2990 struct option module_update_options[] = {
2992 2991 OPT__SUPER_PREFIX(&opt.super_prefix),
2993 2992 OPT__FORCE(&opt.force, N_("force checkout updates"), 0),
2994 - OPT_BOOL('i', "init", &opt.init,
2993 + OPT_BOOL(0, "init", &opt.init,
2995 2994 N_("initialize uninitialized submodules before update")),
2996 2995 OPT_BOOL(0, "remote", &opt.remote,
2997 2996 N_("use SHA-1 of submodule's remote tracking branch")),
@@ -3151,7 +3150,7 @@ static int push_check(int argc, const char **argv, const char *prefix UNUSED,
3151 3150 if (argc > 2) {
3152 3151 int i;
3153 3152 struct ref *local_refs = get_local_heads();
3154 - struct refspec refspec = REFSPEC_INIT_PUSH(the_hash_algo);
3153 + struct refspec refspec = REFSPEC_INIT_PUSH;
3155 3154
3156 3155 refspec_appendn(&refspec, argv + 2, argc - 2);
3157 3156
modified builtin/tag.c
@@ -238,7 +238,7 @@ static int git_tag_config(const char *var, const char *value,
238 238
239 239 static void write_tag_body(int fd, const struct object_id *oid)
240 240 {
241 - size_t size;
241 + unsigned long size;
242 242 enum object_type type;
243 243 char *buf, *sp, *orig;
244 244 struct strbuf payload = STRBUF_INIT;
@@ -388,7 +388,7 @@ static void create_reflog_msg(const struct object_id *oid, struct strbuf *sb)
388 388 enum object_type type;
389 389 struct commit *c;
390 390 char *buf;
391 - size_t size;
391 + unsigned long size;
392 392 int subject_len = 0;
393 393 const char *subject_start;
394 394
modified builtin/unpack-file.c
@@ -12,7 +12,7 @@ static char *create_temp_file(struct object_id *oid)
12 12 static char path[50];
13 13 void *buf;
14 14 enum object_type type;
15 - size_t size;
15 + unsigned long size;
16 16 int fd;
17 17
18 18 buf = odb_read_object(the_repository->objects, oid, &type, &size);
modified builtin/unpack-objects.c
@@ -9,8 +9,6 @@
9 9 #include "hex.h"
10 10 #include "object-file.h"
11 11 #include "odb.h"
12 - #include "odb/streaming.h"
13 - #include "odb/transaction.h"
14 12 #include "object.h"
15 13 #include "delta.h"
16 14 #include "pack.h"
@@ -25,7 +23,8 @@
25 23 static int dry_run, quiet, recover, has_errors, strict;
26 24 static const char unpack_usage[] = "git unpack-objects [-n] [-q] [-r] [--strict]";
27 25
28 - static unsigned char buffer[DEFAULT_IO_BUFFER_SIZE];
26 + /* We always read in 4kB chunks. */
27 + static unsigned char buffer[4096];
29 28 static unsigned int offset, len;
30 29 static off_t consumed_bytes;
31 30 static off_t max_input_size;
@@ -231,7 +230,7 @@ static int check_object(struct object *obj, enum object_type type,
231 230 die("object type mismatch");
232 231
233 232 if (!(obj->flags & FLAG_OPEN)) {
234 - size_t size;
233 + unsigned long size;
235 234 int type = odb_read_object_info(the_repository->objects, &obj->oid, &size);
236 235 if (type != obj->type || type <= 0)
237 236 die("object of unexpected type");
@@ -314,7 +313,7 @@ static void resolve_delta(unsigned nr, enum object_type type,
314 313 void *delta, unsigned long delta_size)
315 314 {
316 315 void *result;
317 - size_t result_size;
316 + unsigned long result_size;
318 317
319 318 result = patch_delta(base, base_size,
320 319 delta, delta_size,
@@ -358,55 +357,56 @@ static void unpack_non_delta_entry(enum object_type type, unsigned long size,
358 357 write_object(nr, type, buf, size);
359 358 }
360 359
361 - struct zlib_stream {
362 - struct odb_stream base;
360 + struct input_zstream_data {
363 361 git_zstream *zstream;
362 + unsigned char buf[8192];
364 363 int status;
365 364 };
366 365
367 - static ssize_t zlib_stream_read(struct odb_stream *in_stream,
368 - char *buf, size_t buf_len)
366 + static const void *feed_input_zstream(struct odb_write_stream *in_stream,
367 + unsigned long *readlen)
369 368 {
370 - struct zlib_stream *data = container_of(in_stream, struct zlib_stream, base);
369 + struct input_zstream_data *data = in_stream->data;
371 370 git_zstream *zstream = data->zstream;
371 + void *in = fill(1);
372 372
373 - if (data->status != Z_OK)
374 - return 0;
373 + if (in_stream->is_finished) {
374 + *readlen = 0;
375 + return NULL;
376 + }
375 377
376 - zstream->next_out = (unsigned char *) buf;
377 - zstream->avail_out = buf_len;
378 + zstream->next_out = data->buf;
379 + zstream->avail_out = sizeof(data->buf);
380 + zstream->next_in = in;
381 + zstream->avail_in = len;
378 382
379 - while (data->status == Z_OK && zstream->avail_out == buf_len) {
380 - zstream->next_in = fill(1);
381 - zstream->avail_in = len;
382 - data->status = git_inflate(zstream, 0);
383 - use(len - zstream->avail_in);
384 - }
383 + data->status = git_inflate(zstream, 0);
384 +
385 + in_stream->is_finished = data->status != Z_OK;
386 + use(len - zstream->avail_in);
387 + *readlen = sizeof(data->buf) - zstream->avail_out;
385 388
386 - return buf_len - zstream->avail_out;
389 + return data->buf;
387 390 }
388 391
389 392 static void stream_blob(unsigned long size, unsigned nr)
390 393 {
391 394 git_zstream zstream = { 0 };
392 - struct zlib_stream in_stream = {
393 - .base = {
394 - .read = zlib_stream_read,
395 - .size = size,
396 - .type = OBJ_BLOB,
397 - },
398 - .zstream = &zstream,
399 - .status = Z_OK,
395 + struct input_zstream_data data = { 0 };
396 + struct odb_write_stream in_stream = {
397 + .read = feed_input_zstream,
398 + .data = &data,
400 399 };
401 400 struct obj_info *info = &obj_list[nr];
402 401
402 + data.zstream = &zstream;
403 403 git_inflate_init(&zstream);
404 404
405 - if (odb_write_object_stream(the_repository->objects, &in_stream.base, &info->oid))
405 + if (odb_write_object_stream(the_repository->objects, &in_stream, size, &info->oid))
406 406 die(_("failed to write object in stream"));
407 407
408 - if (in_stream.status != Z_STREAM_END)
409 - die(_("inflate returned (%d)"), in_stream.status);
408 + if (data.status != Z_STREAM_END)
409 + die(_("inflate returned (%d)"), data.status);
410 410 git_inflate_end(&zstream);
411 411
412 412 if (strict) {
@@ -440,7 +440,6 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
440 440 {
441 441 void *delta_data, *base;
442 442 unsigned long base_size;
443 - size_t base_size_st = 0;
444 443 struct object_id base_oid;
445 444
446 445 if (type == OBJ_REF_DELTA) {
@@ -517,8 +516,7 @@ static void unpack_delta_entry(enum object_type type, unsigned long delta_size,
517 516 return;
518 517
519 518 base = odb_read_object(the_repository->objects, &base_oid,
520 - &type, &base_size_st);
521 - base_size = cast_size_t_to_ulong(base_size_st);
519 + &type, &base_size);
522 520 if (!base) {
523 521 error("failed to read delta-pack base object %s",
524 522 oid_to_hex(&base_oid));
@@ -535,7 +533,7 @@ static void unpack_one(unsigned nr)
535 533 {
536 534 unsigned shift;
537 535 unsigned char *pack;
538 - size_t size, c;
536 + unsigned long size, c;
539 537 enum object_type type;
540 538
541 539 obj_list[nr].offset = consumed_bytes;
@@ -547,8 +545,6 @@ static void unpack_one(unsigned nr)
547 545 size = (c & 15);
548 546 shift = 4;
549 547 while (c & 0x80) {
550 - if ((bitsizeof(size_t) - 7) < shift)
551 - die(_("object size too large for this platform"));
552 548 pack = fill(1);
553 549 c = *pack;
554 550 use(1);
@@ -602,12 +598,12 @@ static void unpack_all(void)
602 598 progress = start_progress(the_repository,
603 599 _("Unpacking objects"), nr_objects);
604 600 CALLOC_ARRAY(obj_list, nr_objects);
605 - odb_transaction_begin_or_die(the_repository->objects, &transaction, 0);
601 + transaction = odb_transaction_begin(the_repository->objects);
606 602 for (i = 0; i < nr_objects; i++) {
607 603 unpack_one(i);
608 604 display_progress(progress, i + 1);
609 605 }
610 - odb_transaction_commit_and_finalize_or_die(transaction);
606 + odb_transaction_commit(transaction);
611 607 stop_progress(&progress);
612 608
613 609 if (delta_list)
@@ -674,10 +670,10 @@ int cmd_unpack_objects(int argc,
674 670 /* We don't take any non-flag arguments now.. Maybe some day */
675 671 usage(unpack_usage);
676 672 }
677 - git_hash_init(&ctx, the_hash_algo);
673 + the_hash_algo->init_fn(&ctx);
678 674 unpack_all();
679 675 git_hash_update(&ctx, buffer, offset);
680 - git_hash_init(&tmp_ctx, the_hash_algo);
676 + the_hash_algo->init_fn(&tmp_ctx);
681 677 git_hash_clone(&tmp_ctx, &ctx);
682 678 git_hash_final_oid(&oid, &tmp_ctx);
683 679 if (strict) {
modified builtin/update-index.c
@@ -19,7 +19,6 @@
19 19 #include "tree-walk.h"
20 20 #include "object-file.h"
21 21 #include "odb.h"
22 - #include "odb/transaction.h"
23 22 #include "refs.h"
24 23 #include "resolve-undo.h"
25 24 #include "parse-options.h"
@@ -294,7 +293,7 @@ static int add_one_path(const struct cache_entry *old, const char *path, int len
294 293 ce->ce_flags = create_ce_flags(0);
295 294 ce->ce_namelen = len;
296 295 fill_stat_cache_info(the_repository->index, ce, st);
297 - ce->ce_mode = ce_mode_from_stat(the_repository, old, st->st_mode);
296 + ce->ce_mode = ce_mode_from_stat(old, st->st_mode);
298 297
299 298 if (index_path(the_repository->index, &ce->oid, path, st,
300 299 info_only ? 0 : INDEX_WRITE_OBJECT)) {
@@ -656,7 +655,7 @@ static int do_unresolve(int ac, const char **av,
656 655
657 656 for (i = 1; i < ac; i++) {
658 657 const char *arg = av[i];
659 - char *p = prefix_path(the_repository, prefix, prefix_length, arg);
658 + char *p = prefix_path(prefix, prefix_length, arg);
660 659 err |= unresolve_one(p);
661 660 free(p);
662 661 }
@@ -733,7 +732,7 @@ struct refresh_params {
733 732
734 733 static int refresh(struct refresh_params *o, unsigned int flag)
735 734 {
736 - setup_work_tree(the_repository);
735 + setup_work_tree();
737 736 repo_read_index(the_repository);
738 737 *o->has_errors |= refresh_index(the_repository->index, o->flags | flag, NULL,
739 738 NULL, NULL);
@@ -875,7 +874,7 @@ static enum parse_opt_result unresolve_callback(
875 874 const char *arg, int unset)
876 875 {
877 876 int *has_errors = opt->value;
878 - const char *prefix = the_repository->prefix;
877 + const char *prefix = startup_info->prefix;
879 878
880 879 BUG_ON_OPT_NEG(unset);
881 880 BUG_ON_OPT_ARG(arg);
@@ -896,13 +895,13 @@ static enum parse_opt_result reupdate_callback(
896 895 const char *arg, int unset)
897 896 {
898 897 int *has_errors = opt->value;
899 - const char *prefix = the_repository->prefix;
898 + const char *prefix = startup_info->prefix;
900 899
901 900 BUG_ON_OPT_NEG(unset);
902 901 BUG_ON_OPT_ARG(arg);
903 902
904 903 /* consume remaining arguments. */
905 - setup_work_tree(the_repository);
904 + setup_work_tree();
906 905 *has_errors = do_reupdate(ctx->argv + 1, prefix);
907 906 if (*has_errors)
908 907 the_repository->index->cache_changed = 0;
@@ -1124,7 +1123,7 @@ int cmd_update_index(int argc,
1124 1123 * Allow the object layer to optimize adding multiple objects in
1125 1124 * a batch.
1126 1125 */
1127 - odb_transaction_begin_or_die(the_repository->objects, &transaction, 0);
1126 + transaction = odb_transaction_begin(the_repository->objects);
1128 1127 while (ctx.argc) {
1129 1128 if (parseopt_state != PARSE_OPT_DONE)
1130 1129 parseopt_state = parse_options_step(&ctx, options,
@@ -1133,8 +1132,6 @@ int cmd_update_index(int argc,
1133 1132 break;
1134 1133 switch (parseopt_state) {
1135 1134 case PARSE_OPT_HELP:
1136 - exit(0);
1137 - case PARSE_OPT_HELP_ERROR:
1138 1135 case PARSE_OPT_ERROR:
1139 1136 exit(129);
1140 1137 case PARSE_OPT_COMPLETE:
@@ -1156,12 +1153,12 @@ int cmd_update_index(int argc,
1156 1153 * a transaction.
1157 1154 */
1158 1155 if (transaction && verbose) {
1159 - odb_transaction_commit_and_finalize_or_die(transaction);
1156 + odb_transaction_commit(transaction);
1160 1157 transaction = NULL;
1161 1158 }
1162 1159
1163 - setup_work_tree(the_repository);
1164 - p = prefix_path(the_repository, prefix, prefix_length, path);
1160 + setup_work_tree();
1161 + p = prefix_path(prefix, prefix_length, path);
1165 1162 update_one(p);
1166 1163 if (set_executable_bit)
1167 1164 chmod_path(set_executable_bit, p);
@@ -1202,7 +1199,7 @@ int cmd_update_index(int argc,
1202 1199 struct strbuf buf = STRBUF_INIT;
1203 1200 struct strbuf unquoted = STRBUF_INIT;
1204 1201
1205 - setup_work_tree(the_repository);
1202 + setup_work_tree();
1206 1203 while (getline_fn(&buf, stdin) != EOF) {
1207 1204 char *p;
1208 1205 if (!nul_term_line && buf.buf[0] == '"') {
@@ -1211,7 +1208,7 @@ int cmd_update_index(int argc,
1211 1208 die("line is badly quoted");
1212 1209 strbuf_swap(&buf, &unquoted);
1213 1210 }
1214 - p = prefix_path(the_repository, prefix, prefix_length, buf.buf);
1211 + p = prefix_path(prefix, prefix_length, buf.buf);
1215 1212 update_one(p);
1216 1213 if (set_executable_bit)
1217 1214 chmod_path(set_executable_bit, p);
@@ -1224,7 +1221,7 @@ int cmd_update_index(int argc,
1224 1221 /*
1225 1222 * By now we have added all of the new objects
1226 1223 */
1227 - odb_transaction_commit_and_finalize_or_die(transaction);
1224 + odb_transaction_commit(transaction);
1228 1225
1229 1226 if (split_index > 0) {
1230 1227 if (repo_config_get_split_index(the_repository) == 0)
@@ -1256,7 +1253,7 @@ int cmd_update_index(int argc,
1256 1253 report(_("Untracked cache disabled"));
1257 1254 break;
1258 1255 case UC_TEST:
1259 - setup_work_tree(the_repository);
1256 + setup_work_tree();
1260 1257 return !test_if_untracked_cache_is_supported();
1261 1258 case UC_ENABLE:
1262 1259 case UC_FORCE:
modified builtin/update-ref.c
@@ -25,15 +25,6 @@ static unsigned int default_flags;
25 25 static unsigned create_reflog_flag;
26 26 static const char *msg;
27 27
28 - struct command_options {
29 - /*
30 - * Individual updates are allowed to fail without causing
31 - * update-ref to exit. This is set when using the
32 - * '--batch-updates' flag.
33 - */
34 - bool allow_update_failures;
35 - };
36 -
37 28 /*
38 29 * Parse one whitespace- or NUL-terminated, possibly C-quoted argument
39 30 * and append the result to arg. Return a pointer to the terminator.
@@ -243,53 +234,6 @@ static int parse_next_oid(const char **next, const char *end,
243 234 command, refname);
244 235 }
245 236
246 - static void print_rejected_refs(const char *refname,
247 - const struct object_id *old_oid,
248 - const struct object_id *new_oid,
249 - const char *old_target,
250 - const char *new_target,
251 - enum ref_transaction_error err,
252 - const char *details,
253 - void *cb_data UNUSED)
254 - {
255 - struct strbuf sb = STRBUF_INIT;
256 -
257 - if (details && *details)
258 - error("%s", details);
259 -
260 - strbuf_addf(&sb, "rejected %s %s %s %s\n", refname,
261 - new_oid ? oid_to_hex(new_oid) : new_target,
262 - old_oid ? oid_to_hex(old_oid) : old_target,
263 - ref_transaction_error_msg(err));
264 -
265 - fwrite(sb.buf, sb.len, 1, stdout);
266 - strbuf_release(&sb);
267 - }
268 -
269 - /*
270 - * Handle transaction errors. If we're using batches updates, we want to only
271 - * die for generic errors and print the remaining to the user.
272 - */
273 - static void handle_ref_transaction_error(const char *refname,
274 - struct object_id *new_oid,
275 - struct object_id *old_oid,
276 - const char *new_target,
277 - const char *old_target,
278 - enum ref_transaction_error tx_err,
279 - struct strbuf *err,
280 - struct command_options *opts)
281 - {
282 - if (!tx_err)
283 - return;
284 -
285 - if (tx_err != REF_TRANSACTION_ERROR_GENERIC && opts->allow_update_failures) {
286 - print_rejected_refs(refname, old_oid, new_oid, old_target,
287 - new_target, tx_err, err->buf, NULL);
288 - return;
289 - }
290 -
291 - die("%s", err->buf);
292 - }
293 237
294 238 /*
295 239 * The following five parse_cmd_*() functions parse the corresponding
@@ -302,13 +246,11 @@ static void handle_ref_transaction_error(const char *refname,
302 246 */
303 247
304 248 static void parse_cmd_update(struct ref_transaction *transaction,
305 - const char *next, const char *end,
306 - struct command_options *opts)
249 + const char *next, const char *end)
307 250 {
308 251 struct strbuf err = STRBUF_INIT;
309 252 char *refname;
310 253 struct object_id new_oid, old_oid;
311 - enum ref_transaction_error tx_err;
312 254 int have_old;
313 255
314 256 refname = parse_refname(&next);
@@ -325,14 +267,12 @@ static void parse_cmd_update(struct ref_transaction *transaction,
325 267 if (*next != line_termination)
326 268 die("update %s: extra input: %s", refname, next);
327 269
328 - tx_err = ref_transaction_update(transaction, refname,
329 - &new_oid, have_old ? &old_oid : NULL,
330 - NULL, NULL,
331 - update_flags | create_reflog_flag,
332 - msg, &err);
333 - handle_ref_transaction_error(refname, &new_oid, have_old ? &old_oid : NULL,
334 - NULL, NULL, tx_err, &err, opts);
335 -
270 + if (ref_transaction_update(transaction, refname,
271 + &new_oid, have_old ? &old_oid : NULL,
272 + NULL, NULL,
273 + update_flags | create_reflog_flag,
274 + msg, &err))
275 + die("%s", err.buf);
336 276
337 277 update_flags = default_flags;
338 278 free(refname);
@@ -340,11 +280,9 @@ static void parse_cmd_update(struct ref_transaction *transaction,
340 280 }
341 281
342 282 static void parse_cmd_symref_update(struct ref_transaction *transaction,
343 - const char *next, const char *end UNUSED,
344 - struct command_options *opts)
283 + const char *next, const char *end UNUSED)
345 284 {
346 285 char *refname, *new_target, *old_arg;
347 - enum ref_transaction_error tx_err;
348 286 char *old_target = NULL;
349 287 struct strbuf err = STRBUF_INIT;
350 288 struct object_id old_oid;
@@ -381,15 +319,13 @@ static void parse_cmd_symref_update(struct ref_transaction *transaction,
381 319 if (*next != line_termination)
382 320 die("symref-update %s: extra input: %s", refname, next);
383 321
384 - tx_err = ref_transaction_update(transaction, refname, NULL,
385 - have_old_oid ? &old_oid : NULL,
386 - new_target,
387 - have_old_oid ? NULL : old_target,
388 - update_flags | create_reflog_flag,
389 - msg, &err);
390 - handle_ref_transaction_error(refname, NULL, have_old_oid ? &old_oid : NULL,
391 - new_target, have_old_oid ? NULL : old_target,
392 - tx_err, &err, opts);
322 + if (ref_transaction_update(transaction, refname, NULL,
323 + have_old_oid ? &old_oid : NULL,
324 + new_target,
325 + have_old_oid ? NULL : old_target,
326 + update_flags | create_reflog_flag,
327 + msg, &err))
328 + die("%s", err.buf);
393 329
394 330 update_flags = default_flags;
395 331 free(refname);
@@ -400,13 +336,11 @@ static void parse_cmd_symref_update(struct ref_transaction *transaction,
400 336 }
401 337
402 338 static void parse_cmd_create(struct ref_transaction *transaction,
403 - const char *next, const char *end,
404 - struct command_options *opts)
339 + const char *next, const char *end)
405 340 {
406 341 struct strbuf err = STRBUF_INIT;
407 342 char *refname;
408 343 struct object_id new_oid;
409 - enum ref_transaction_error tx_err;
410 344
411 345 refname = parse_refname(&next);
412 346 if (!refname)
@@ -421,24 +355,22 @@ static void parse_cmd_create(struct ref_transaction *transaction,
421 355 if (*next != line_termination)
422 356 die("create %s: extra input: %s", refname, next);
423 357
424 - tx_err = ref_transaction_create(transaction, refname, &new_oid, NULL,
425 - update_flags | create_reflog_flag,
426 - msg, &err);
427 - handle_ref_transaction_error(refname, &new_oid, NULL, NULL, NULL, tx_err,
428 - &err, opts);
358 + if (ref_transaction_create(transaction, refname, &new_oid, NULL,
359 + update_flags | create_reflog_flag,
360 + msg, &err))
361 + die("%s", err.buf);
429 362
430 363 update_flags = default_flags;
431 364 free(refname);
432 365 strbuf_release(&err);
433 366 }
434 367
368 +
435 369 static void parse_cmd_symref_create(struct ref_transaction *transaction,
436 - const char *next, const char *end UNUSED,
437 - struct command_options *opts)
370 + const char *next, const char *end UNUSED)
438 371 {
439 372 struct strbuf err = STRBUF_INIT;
440 373 char *refname, *new_target;
441 - enum ref_transaction_error tx_err;
442 374
443 375 refname = parse_refname(&next);
444 376 if (!refname)
@@ -451,11 +383,10 @@ static void parse_cmd_symref_create(struct ref_transaction *transaction,
451 383 if (*next != line_termination)
452 384 die("symref-create %s: extra input: %s", refname, next);
453 385
454 - tx_err = ref_transaction_create(transaction, refname, NULL, new_target,
455 - update_flags | create_reflog_flag,
456 - msg, &err);
457 - handle_ref_transaction_error(refname, NULL, NULL, new_target, NULL,
458 - tx_err, &err, opts);
386 + if (ref_transaction_create(transaction, refname, NULL, new_target,
387 + update_flags | create_reflog_flag,
388 + msg, &err))
389 + die("%s", err.buf);
459 390
460 391 update_flags = default_flags;
461 392 free(refname);
@@ -464,8 +395,7 @@ static void parse_cmd_symref_create(struct ref_transaction *transaction,
464 395 }
465 396
466 397 static void parse_cmd_delete(struct ref_transaction *transaction,
467 - const char *next, const char *end,
468 - struct command_options *opts UNUSED)
398 + const char *next, const char *end)
469 399 {
470 400 struct strbuf err = STRBUF_INIT;
471 401 char *refname;
@@ -498,9 +428,9 @@ static void parse_cmd_delete(struct ref_transaction *transaction,
498 428 strbuf_release(&err);
499 429 }
500 430
431 +
501 432 static void parse_cmd_symref_delete(struct ref_transaction *transaction,
502 - const char *next, const char *end UNUSED,
503 - struct command_options *opts UNUSED)
433 + const char *next, const char *end UNUSED)
504 434 {
505 435 struct strbuf err = STRBUF_INIT;
506 436 char *refname, *old_target;
@@ -527,9 +457,9 @@ static void parse_cmd_symref_delete(struct ref_transaction *transaction,
527 457 strbuf_release(&err);
528 458 }
529 459
460 +
530 461 static void parse_cmd_verify(struct ref_transaction *transaction,
531 - const char *next, const char *end,
532 - struct command_options *opts UNUSED)
462 + const char *next, const char *end)
533 463 {
534 464 struct strbuf err = STRBUF_INIT;
535 465 char *refname;
@@ -556,8 +486,7 @@ static void parse_cmd_verify(struct ref_transaction *transaction,
556 486 }
557 487
558 488 static void parse_cmd_symref_verify(struct ref_transaction *transaction,
559 - const char *next, const char *end UNUSED,
560 - struct command_options *opts UNUSED)
489 + const char *next, const char *end UNUSED)
561 490 {
562 491 struct strbuf err = STRBUF_INIT;
563 492 struct object_id old_oid;
@@ -599,8 +528,7 @@ static void report_ok(const char *command)
599 528 }
600 529
601 530 static void parse_cmd_option(struct ref_transaction *transaction UNUSED,
602 - const char *next, const char *end UNUSED,
603 - struct command_options *opts UNUSED)
531 + const char *next, const char *end UNUSED)
604 532 {
605 533 const char *rest;
606 534 if (skip_prefix(next, "no-deref", &rest) && *rest == line_termination)
@@ -610,8 +538,7 @@ static void parse_cmd_option(struct ref_transaction *transaction UNUSED,
610 538 }
611 539
612 540 static void parse_cmd_start(struct ref_transaction *transaction UNUSED,
613 - const char *next, const char *end UNUSED,
614 - struct command_options *opts UNUSED)
541 + const char *next, const char *end UNUSED)
615 542 {
616 543 if (*next != line_termination)
617 544 die("start: extra input: %s", next);
@@ -619,8 +546,7 @@ static void parse_cmd_start(struct ref_transaction *transaction UNUSED,
619 546 }
620 547
621 548 static void parse_cmd_prepare(struct ref_transaction *transaction,
622 - const char *next, const char *end UNUSED,
623 - struct command_options *opts UNUSED)
549 + const char *next, const char *end UNUSED)
624 550 {
625 551 struct strbuf error = STRBUF_INIT;
626 552 if (*next != line_termination)
@@ -631,8 +557,7 @@ static void parse_cmd_prepare(struct ref_transaction *transaction,
631 557 }
632 558
633 559 static void parse_cmd_abort(struct ref_transaction *transaction,
634 - const char *next, const char *end UNUSED,
635 - struct command_options *opts UNUSED)
560 + const char *next, const char *end UNUSED)
636 561 {
637 562 struct strbuf error = STRBUF_INIT;
638 563 if (*next != line_termination)
@@ -642,9 +567,31 @@ static void parse_cmd_abort(struct ref_transaction *transaction,
642 567 report_ok("abort");
643 568 }
644 569
570 + static void print_rejected_refs(const char *refname,
571 + const struct object_id *old_oid,
572 + const struct object_id *new_oid,
573 + const char *old_target,
574 + const char *new_target,
575 + enum ref_transaction_error err,
576 + const char *details,
577 + void *cb_data UNUSED)
578 + {
579 + struct strbuf sb = STRBUF_INIT;
580 +
581 + if (details && *details)
582 + error("%s", details);
583 +
584 + strbuf_addf(&sb, "rejected %s %s %s %s\n", refname,
585 + new_oid ? oid_to_hex(new_oid) : new_target,
586 + old_oid ? oid_to_hex(old_oid) : old_target,
587 + ref_transaction_error_msg(err));
588 +
589 + fwrite(sb.buf, sb.len, 1, stdout);
590 + strbuf_release(&sb);
591 + }
592 +
645 593 static void parse_cmd_commit(struct ref_transaction *transaction,
646 - const char *next, const char *end UNUSED,
647 - struct command_options *opts UNUSED)
594 + const char *next, const char *end UNUSED)
648 595 {
649 596 struct strbuf error = STRBUF_INIT;
650 597 if (*next != line_termination)
@@ -672,8 +619,7 @@ enum update_refs_state {
672 619
673 620 static const struct parse_cmd {
674 621 const char *prefix;
675 - void (*fn)(struct ref_transaction *, const char *, const char *,
676 - struct command_options *);
622 + void (*fn)(struct ref_transaction *, const char *, const char *);
677 623 unsigned args;
678 624 enum update_refs_state state;
679 625 } command[] = {
@@ -699,10 +645,6 @@ static void update_refs_stdin(unsigned int flags)
699 645 struct ref_transaction *transaction;
700 646 int i, j;
701 647
702 - struct command_options opts = {
703 - .allow_update_failures = flags & REF_TRANSACTION_ALLOW_FAILURE,
704 - };
705 -
706 648 transaction = ref_store_transaction_begin(get_main_ref_store(the_repository),
707 649 flags, &err);
708 650 if (!transaction)
@@ -780,7 +722,7 @@ static void update_refs_stdin(unsigned int flags)
780 722 }
781 723
782 724 cmd->fn(transaction, input.buf + strlen(cmd->prefix) + !!cmd->args,
783 - input.buf + input.len, &opts);
725 + input.buf + input.len);
784 726 }
785 727
786 728 switch (state) {
modified builtin/upload-archive.c
@@ -31,7 +31,7 @@ int cmd_upload_archive_writer(int argc,
31 31 if (argc != 2)
32 32 usage(upload_archive_usage);
33 33
34 - if (!enter_repo(the_repository, argv[1], 0))
34 + if (!enter_repo(argv[1], 0))
35 35 die("'%s' does not appear to be a git repository", argv[1]);
36 36
37 37 init_archivers();
modified builtin/upload-pack.c
@@ -59,7 +59,7 @@ int cmd_upload_pack(int argc,
59 59
60 60 if (strict)
61 61 enter_repo_flags |= ENTER_REPO_STRICT;
62 - if (!enter_repo(the_repository, dir, enter_repo_flags))
62 + if (!enter_repo(dir, enter_repo_flags))
63 63 die("'%s' does not appear to be a git repository", dir);
64 64
65 65 switch (determine_protocol_version_server()) {
deleted builtin/url-parse.c mode 100644
@@ -1,135 +0,0 @@
1 - #include "builtin.h"
2 - #include "gettext.h"
3 - #include "parse-options.h"
4 - #include "url.h"
5 - #include "urlmatch.h"
6 -
7 - static const char * const builtin_url_parse_usage[] = {
8 - N_("git url-parse [-c <component>] [--] <url>..."),
9 - NULL
10 - };
11 -
12 - static char *component_arg;
13 -
14 - static struct option builtin_url_parse_options[] = {
15 - OPT_STRING('c', "component", &component_arg, N_("component"),
16 - N_("which URL component to extract")),
17 - OPT_END(),
18 - };
19 -
20 - enum url_component {
21 - URL_NONE = 0,
22 - URL_SCHEME,
23 - URL_USER,
24 - URL_PASSWORD,
25 - URL_HOST,
26 - URL_PORT,
27 - URL_PATH,
28 - };
29 -
30 - static void parse_or_die(const char *url, struct url_info *info)
31 - {
32 - if (url_is_local_not_ssh(url)) {
33 - if (*url == '/')
34 - die("'%s' is not a URL; if you meant a local "
35 - "repository, use 'file://%s'", url, url);
36 - if (has_dos_drive_prefix(url))
37 - die("'%s' is not a URL; if you meant a local "
38 - "repository, use 'file:///%s'", url, url);
39 - die("'%s' is not a URL; if you meant a local repository, "
40 - "use a 'file://' URL with an absolute path", url);
41 - }
42 - if (!url_parse(url, info))
43 - die("invalid git URL '%s': %s", url, info->err);
44 - }
45 -
46 - static enum url_component get_component_or_die(const char *arg)
47 - {
48 - if (!strcmp("path", arg))
49 - return URL_PATH;
50 - if (!strcmp("host", arg))
51 - return URL_HOST;
52 - if (!strcmp("scheme", arg))
53 - return URL_SCHEME;
54 - if (!strcmp("user", arg))
55 - return URL_USER;
56 - if (!strcmp("password", arg))
57 - return URL_PASSWORD;
58 - if (!strcmp("port", arg))
59 - return URL_PORT;
60 - die("invalid git URL component '%s'", arg);
61 - }
62 -
63 - static char *extract_component(enum url_component component,
64 - struct url_info *info)
65 - {
66 - size_t offset, length;
67 -
68 - switch (component) {
69 - case URL_SCHEME:
70 - offset = 0;
71 - length = info->scheme_len;
72 - break;
73 - case URL_USER:
74 - offset = info->user_off;
75 - length = info->user_len;
76 - break;
77 - case URL_PASSWORD:
78 - offset = info->passwd_off;
79 - length = info->passwd_len;
80 - break;
81 - case URL_HOST:
82 - offset = info->host_off;
83 - length = info->host_len;
84 - break;
85 - case URL_PORT:
86 - offset = info->port_off;
87 - length = info->port_len;
88 - break;
89 - case URL_PATH:
90 - offset = info->path_off;
91 - length = info->path_len;
92 - break;
93 - case URL_NONE:
94 - return NULL;
95 - }
96 -
97 - return xstrndup(info->url + offset, length);
98 - }
99 -
100 - int cmd_url_parse(int argc,
101 - const char **argv,
102 - const char *prefix,
103 - struct repository *repo UNUSED)
104 - {
105 - struct url_info info;
106 - enum url_component selected = URL_NONE;
107 - char *extracted;
108 - int i;
109 -
110 - argc = parse_options(argc, argv, prefix, builtin_url_parse_options,
111 - builtin_url_parse_usage, 0);
112 -
113 - if (argc == 0)
114 - usage_with_options(builtin_url_parse_usage,
115 - builtin_url_parse_options);
116 -
117 - if (component_arg)
118 - selected = get_component_or_die(component_arg);
119 -
120 - for (i = 0; i < argc; i++) {
121 - parse_or_die(argv[i], &info);
122 -
123 - if (selected != URL_NONE) {
124 - extracted = extract_component(selected, &info);
125 - if (extracted) {
126 - puts(extracted);
127 - free(extracted);
128 - }
129 - }
130 -
131 - free(info.url);
132 - }
133 -
134 - return 0;
135 - }
modified builtin/worktree.c
@@ -226,7 +226,7 @@ static void prune_worktrees(void)
226 226 while ((d = readdir_skip_dot_and_dotdot(dir)) != NULL) {
227 227 char *path;
228 228 strbuf_reset(&reason);
229 - if (should_prune_worktree(the_repository, d->d_name, &reason, &path, expire))
229 + if (should_prune_worktree(d->d_name, &reason, &path, expire))
230 230 prune_worktree(d->d_name, reason.buf);
231 231 else if (path)
232 232 string_list_append_nodup(&kept, path)->util = xstrdup(d->d_name);
@@ -294,7 +294,7 @@ static void remove_junk_on_signal(int signo)
294 294 raise(signo);
295 295 }
296 296
297 - static char *worktree_basename_dup(const char *path)
297 + static const char *worktree_basename(const char *path, int *olen)
298 298 {
299 299 const char *name;
300 300 int len;
@@ -303,11 +303,14 @@ static char *worktree_basename_dup(const char *path)
303 303 while (len && is_dir_sep(path[len - 1]))
304 304 len--;
305 305
306 - name = path + len;
307 - while (name > path && !is_dir_sep(name[-1]))
308 - name--;
306 + for (name = path + len - 1; name > path; name--)
307 + if (is_dir_sep(*name)) {
308 + name++;
309 + break;
310 + }
309 311
310 - return xmemdupz(name, path + len - name);
312 + *olen = len;
313 + return name;
311 314 }
312 315
313 316 /* check that path is viable location for worktree */
@@ -346,7 +349,7 @@ static void copy_sparse_checkout(const char *worktree_git_dir)
346 349
347 350 if (file_exists(from_file)) {
348 351 if (safe_create_leading_directories(the_repository, to_file) ||
349 - copy_file(the_repository, to_file, from_file, 0666))
352 + copy_file(to_file, from_file, 0666))
350 353 error(_("failed to copy '%s' to '%s'; sparse-checkout may not work correctly"),
351 354 from_file, to_file);
352 355 }
@@ -365,7 +368,7 @@ static void copy_filtered_worktree_config(const char *worktree_git_dir)
365 368 int bare;
366 369
367 370 if (safe_create_leading_directories(the_repository, to_file) ||
368 - copy_file(the_repository, to_file, from_file, 0666)) {
371 + copy_file(to_file, from_file, 0666)) {
369 372 error(_("failed to copy worktree config from '%s' to '%s'"),
370 373 from_file, to_file);
371 374 goto worktree_copy_cleanup;
@@ -461,7 +464,6 @@ static int add_worktree(const char *path, const char *refname,
461 464 struct strbuf sb_git = STRBUF_INIT, sb_repo = STRBUF_INIT;
462 465 struct strbuf sb = STRBUF_INIT;
463 466 const char *name;
464 - char *name_to_free = NULL;
465 467 struct strvec child_env = STRVEC_INIT;
466 468 unsigned int counter = 0;
467 469 int len, ret;
@@ -473,13 +475,13 @@ static int add_worktree(const char *path, const char *refname,
473 475 struct ref_store *wt_refs;
474 476 struct repo_config_values *cfg = repo_config_values(the_repository);
475 477
476 - worktrees = get_worktrees(the_repository);
478 + worktrees = get_worktrees();
477 479 check_candidate_path(path, opts->force, worktrees, "add");
478 480 free_worktrees(worktrees);
479 481 worktrees = NULL;
480 482
481 483 /* is 'refname' a branch or commit? */
482 - if (!opts->detach && !check_branch_ref(the_repository, &symref, refname) &&
484 + if (!opts->detach && !check_branch_ref(&symref, refname) &&
483 485 refs_ref_exists(get_main_ref_store(the_repository), symref.buf)) {
484 486 is_branch = 1;
485 487 if (!opts->force)
@@ -489,12 +491,12 @@ static int add_worktree(const char *path, const char *refname,
489 491 if (!commit && !opts->orphan)
490 492 die(_("invalid reference: %s"), refname);
491 493
492 - name = name_to_free = worktree_basename_dup(path);
493 - if (!*name)
494 - die(_("invalid path '%s'"), path);
495 - sanitize_refname_component(name, &sb_name);
494 + name = worktree_basename(path, &len);
495 + strbuf_add(&sb, name, path + len - name);
496 + sanitize_refname_component(sb.buf, &sb_name);
496 497 if (!sb_name.len)
497 - BUG("How come '%s' becomes empty after sanitization?", name);
498 + BUG("How come '%s' becomes empty after sanitization?", sb.buf);
499 + strbuf_reset(&sb);
498 500 name = sb_name.buf;
499 501 repo_git_path_replace(the_repository, &sb_repo, "worktrees/%s", name);
500 502 len = sb_repo.len;
@@ -537,8 +539,7 @@ static int add_worktree(const char *path, const char *refname,
537 539
538 540 strbuf_reset(&sb);
539 541 strbuf_addf(&sb, "%s/gitdir", sb_repo.buf);
540 - write_worktree_linking_files(the_repository, sb_git.buf,
541 - sb.buf, opts->relative_paths);
542 + write_worktree_linking_files(sb_git.buf, sb.buf, opts->relative_paths);
542 543 strbuf_reset(&sb);
543 544 strbuf_addf(&sb, "%s/commondir", sb_repo.buf);
544 545 write_file(sb.buf, "../..");
@@ -546,7 +547,7 @@ static int add_worktree(const char *path, const char *refname,
546 547 /*
547 548 * Set up the ref store of the worktree and create the HEAD reference.
548 549 */
549 - wt = get_linked_worktree(the_repository, name, 1);
550 + wt = get_linked_worktree(name, 1);
550 551 if (!wt) {
551 552 ret = error(_("could not find created worktree '%s'"), name);
552 553 goto done;
@@ -608,7 +609,7 @@ done:
608 609 * is_junk is cleared, but do return appropriate code when hook fails.
609 610 */
610 611 if (!ret && opts->checkout && !opts->orphan) {
611 - struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
612 + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
612 613
613 614 strvec_pushl(&opt.env, "GIT_DIR", "GIT_WORK_TREE", NULL);
614 615 strvec_pushl(&opt.args,
@@ -628,7 +629,6 @@ done:
628 629 strbuf_release(&sb_git);
629 630 strbuf_release(&sb_name);
630 631 free_worktree(wt);
631 - free(name_to_free);
632 632 return ret;
633 633 }
634 634
@@ -649,7 +649,7 @@ static void print_preparing_worktree_line(int detach,
649 649 fprintf_ln(stderr, _("Preparing worktree (new branch '%s')"), new_branch);
650 650 } else {
651 651 struct strbuf s = STRBUF_INIT;
652 - if (!detach && !check_branch_ref(the_repository, &s, branch) &&
652 + if (!detach && !check_branch_ref(&s, branch) &&
653 653 refs_ref_exists(get_main_ref_store(the_repository), s.buf))
654 654 fprintf_ln(stderr, _("Preparing worktree (checking out '%s')"),
655 655 branch);
@@ -763,32 +763,15 @@ static int dwim_orphan(const struct add_opts *opts, int opt_track, int remote)
763 763 return 1;
764 764 }
765 765
766 - static void advise_disambiguating_remotes(const char *path, const char *branch,
767 - const struct string_list *matched_remote_names)
768 - {
769 - struct string_list_item *item;
770 -
771 - advise(_("Branch name '%s' appears in multiple remotes:"), branch);
772 - for_each_string_list_item(item, matched_remote_names) {
773 - advise(_(" %s"), item->string);
774 - }
775 - advise(_("If you meant to create a worktree from a remote tracking branch on\n"
776 - "<remote>, you can do so by:\n"
777 - "\n"
778 - " git worktree add -b %s %s <remote>/%s\n"
779 - "\n"
780 - "If you'd like to always prefer some remote, e.g. 'origin',\n"
781 - "consider setting checkout.defaultRemote=origin in your config."),
782 - branch, path, branch);
783 - }
784 -
785 - static char *dwim_branch(const struct add_opts *opts, const char *path, char **new_branch)
766 + static char *dwim_branch(const char *path, char **new_branch)
786 767 {
768 + int n;
787 769 int branch_exists;
788 - char *branchname = worktree_basename_dup(path);
770 + const char *s = worktree_basename(path, &n);
771 + char *branchname = xstrndup(s, n);
789 772 struct strbuf ref = STRBUF_INIT;
790 773
791 - branch_exists = !check_branch_ref(the_repository, &ref, branchname) &&
774 + branch_exists = !check_branch_ref(&ref, branchname) &&
792 775 refs_ref_exists(get_main_ref_store(the_repository),
793 776 ref.buf);
794 777 strbuf_release(&ref);
@@ -798,21 +781,7 @@ static char *dwim_branch(const struct add_opts *opts, const char *path, char **n
798 781 *new_branch = branchname;
799 782 if (guess_remote) {
800 783 struct object_id oid;
801 - char *remote;
802 - int num_matches = 0;
803 - struct string_list matched_remote_names = STRING_LIST_INIT_DUP;
804 -
805 - remote = unique_tracking_name(*new_branch, &oid, &num_matches,
806 - &matched_remote_names);
807 - if (!remote && num_matches > 1) {
808 - if (!opts->quiet &&
809 - advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME))
810 - advise_disambiguating_remotes(path, *new_branch,
811 - &matched_remote_names);
812 - die(_("'%s' matched multiple (%d) remote tracking branches"),
813 - *new_branch, num_matches);
814 - }
815 - string_list_clear(&matched_remote_names, 0);
784 + char *remote = unique_tracking_name(*new_branch, &oid, NULL);
816 785 return remote;
817 786 }
818 787 return NULL;
@@ -899,14 +868,16 @@ static int add(int ac, const char **av, const char *prefix,
899 868 new_branch = new_branch_force;
900 869
901 870 if (!opts.force &&
902 - !check_branch_ref(the_repository, &symref, new_branch) &&
871 + !check_branch_ref(&symref, new_branch) &&
903 872 refs_ref_exists(get_main_ref_store(the_repository), symref.buf))
904 873 die_if_checked_out(symref.buf, 0);
905 874 strbuf_release(&symref);
906 875 }
907 876
908 877 if (opts.orphan && !new_branch) {
909 - new_branch = new_branch_to_free = worktree_basename_dup(path);
878 + int n;
879 + const char *s = worktree_basename(path, &n);
880 + new_branch = new_branch_to_free = xstrndup(s, n);
910 881 } else if (opts.orphan) {
911 882 ; /* no-op */
912 883 } else if (opts.detach) {
@@ -918,40 +889,25 @@ static int add(int ac, const char **av, const char *prefix,
918 889 opts.orphan = dwim_orphan(&opts, !!opt_track, 0);
919 890 } else if (ac < 2) {
920 891 /* DWIM: Guess branch name from path. */
921 - char *s = dwim_branch(&opts, path, &new_branch_to_free);
892 + char *s = dwim_branch(path, &new_branch_to_free);
922 893 if (s)
923 894 branch = branch_to_free = s;
924 895 new_branch = new_branch_to_free;
925 896
926 897 /* DWIM: Infer --orphan when repo has no refs. */
927 898 opts.orphan = (!s) && dwim_orphan(&opts, !!opt_track, 1);
928 - } else if (ac == 2 && new_branch) {
929 - if (!strcmp(branch, "HEAD"))
930 - can_use_local_refs(&opts);
931 899 } else if (ac == 2) {
900 + struct object_id oid;
932 901 struct commit *commit;
902 + char *remote;
933 903
934 904 commit = lookup_commit_reference_by_name(branch);
935 905 if (!commit) {
936 - struct object_id oid;
937 - char *remote;
938 - int num_matches = 0;
939 - struct string_list matched_remote_names = STRING_LIST_INIT_DUP;
940 -
941 - remote = unique_tracking_name(branch, &oid, &num_matches,
942 - &matched_remote_names);
906 + remote = unique_tracking_name(branch, &oid, NULL);
943 907 if (remote) {
944 908 new_branch = branch;
945 909 branch = new_branch_to_free = remote;
946 - } else if (num_matches > 1) {
947 - if (!opts.quiet &&
948 - advice_enabled(ADVICE_CHECKOUT_AMBIGUOUS_REMOTE_BRANCH_NAME))
949 - advise_disambiguating_remotes(path, branch,
950 - &matched_remote_names);
951 - die(_("'%s' matched multiple (%d) remote tracking branches"),
952 - branch, num_matches);
953 910 }
954 - string_list_clear(&matched_remote_names, 0);
955 911 }
956 912
957 913 if (!strcmp(branch, "HEAD"))
@@ -989,17 +945,14 @@ static int add(int ac, const char **av, const char *prefix,
989 945 strvec_push(&cp.args, branch);
990 946 if (opt_track)
991 947 strvec_push(&cp.args, opt_track);
992 - if (run_command(&cp)) {
993 - ret = -1;
994 - goto cleanup;
995 - }
948 + if (run_command(&cp))
949 + return -1;
996 950 branch = new_branch;
997 951 } else if (opt_track) {
998 952 die(_("--[no-]track can only be used if a new branch is created"));
999 953 }
1000 954
1001 955 ret = add_worktree(path, branch, &opts);
1002 - cleanup:
1003 956 free(path);
1004 957 free(opt_track);
1005 958 free(branch_to_free);
@@ -1150,7 +1103,7 @@ static int list(int ac, const char **av, const char *prefix,
1150 1103 else if (!line_terminator && !porcelain)
1151 1104 die(_("the option '%s' requires '%s'"), "-z", "--porcelain");
1152 1105 else {
1153 - struct worktree **worktrees = get_worktrees(the_repository);
1106 + struct worktree **worktrees = get_worktrees();
1154 1107 int path_maxwidth = 0, abbrev = DEFAULT_ABBREV, i;
1155 1108 struct worktree_display *display = NULL;
1156 1109
@@ -1193,7 +1146,7 @@ static int lock_worktree(int ac, const char **av, const char *prefix,
1193 1146 if (ac != 1)
1194 1147 usage_with_options(git_worktree_lock_usage, options);
1195 1148
1196 - worktrees = get_worktrees(the_repository);
1149 + worktrees = get_worktrees();
1197 1150 wt = find_worktree(worktrees, prefix, av[0]);
1198 1151 if (!wt)
1199 1152 die(_("'%s' is not a working tree"), av[0]);
@@ -1230,7 +1183,7 @@ static int unlock_worktree(int ac, const char **av, const char *prefix,
1230 1183 if (ac != 1)
1231 1184 usage_with_options(git_worktree_unlock_usage, options);
1232 1185
1233 - worktrees = get_worktrees(the_repository);
1186 + worktrees = get_worktrees();
1234 1187 wt = find_worktree(worktrees, prefix, av[0]);
1235 1188 if (!wt)
1236 1189 die(_("'%s' is not a working tree"), av[0]);
@@ -1316,7 +1269,7 @@ static int move_worktree(int ac, const char **av, const char *prefix,
1316 1269 strbuf_addstr(&dst, path);
1317 1270 free(path);
1318 1271
1319 - worktrees = get_worktrees(the_repository);
1272 + worktrees = get_worktrees();
1320 1273 wt = find_worktree(worktrees, prefix, av[0]);
1321 1274 if (!wt)
1322 1275 die(_("'%s' is not a working tree"), av[0]);
@@ -1441,7 +1394,7 @@ static int remove_worktree(int ac, const char **av, const char *prefix,
1441 1394 if (ac != 1)
1442 1395 usage_with_options(git_worktree_remove_usage, options);
1443 1396
1444 - worktrees = get_worktrees(the_repository);
1397 + worktrees = get_worktrees();
1445 1398 wt = find_worktree(worktrees, prefix, av[0]);
1446 1399 if (!wt)
1447 1400 die(_("'%s' is not a working tree"), av[0]);
@@ -1503,9 +1456,8 @@ static int repair(int ac, const char **av, const char *prefix,
1503 1456 ac = parse_options(ac, av, prefix, options, git_worktree_repair_usage, 0);
1504 1457 p = ac > 0 ? av : self;
1505 1458 for (; *p; p++)
1506 - repair_worktree_at_path(the_repository, *p, report_repair,
1507 - &rc, use_relative_paths);
1508 - repair_worktrees(the_repository, report_repair, &rc, use_relative_paths);
1459 + repair_worktree_at_path(*p, report_repair, &rc, use_relative_paths);
1460 + repair_worktrees(report_repair, &rc, use_relative_paths);
1509 1461 return rc;
1510 1462 }
1511 1463
modified bundle-uri.c
@@ -378,7 +378,7 @@ cleanup:
378 378 if (child_in)
379 379 fclose(child_in);
380 380 if (finish_command(&cp))
381 - result = 1;
381 + return 1;
382 382 if (child_out)
383 383 fclose(child_out);
384 384 return result;
@@ -396,7 +396,7 @@ static int copy_uri_to_file(const char *filename, const char *uri)
396 396 uri = out;
397 397
398 398 /* Copy as a file */
399 - return copy_file(the_repository, filename, uri, 0);
399 + return copy_file(filename, uri, 0);
400 400 }
401 401
402 402 static int unbundle_from_file(struct repository *r, const char *file)
@@ -946,12 +946,8 @@ static int config_to_packet_line(const char *key, const char *value,
946 946 {
947 947 struct packet_reader *writer = data;
948 948
949 - if (starts_with(key, "bundle.")) {
950 - if (value && *value)
951 - packet_write_fmt(writer->fd, "%s=%s", key, value);
952 - else
953 - warning(_("config '%s' has no value"), key);
954 - }
949 + if (starts_with(key, "bundle."))
950 + packet_write_fmt(writer->fd, "%s=%s", key, value);
955 951
956 952 return 0;
957 953 }
modified bundle.c
@@ -1,3 +1,4 @@
1 + #define USE_THE_REPOSITORY_VARIABLE
1 2 #define DISABLE_SIGN_COMPARE_WARNINGS
2 3
3 4 #include "git-compat-util.h"
@@ -20,13 +21,6 @@
20 21 #include "connected.h"
21 22 #include "write-or-die.h"
22 23
23 - /*
24 - * NEEDSWORK: this function implicitly depends on `the_repository` and is not
25 - * available because we dropped USE_THE_REPOSITORY_VARIABLE. We can remove the
26 - * declaration once it's accessible via `repo_config_values`.
27 - */
28 - extern const char *get_log_output_encoding(void);
29 -
30 24 static const char v2_bundle_signature[] = "# v2 git bundle\n";
31 25 static const char v3_bundle_signature[] = "# v3 git bundle\n";
32 26 static struct {
@@ -300,10 +294,9 @@ int list_bundle_refs(struct bundle_header *header, int argc, const char **argv)
300 294 return list_refs(&header->references, argc, argv);
301 295 }
302 296
303 - static int is_tag_in_date_range(struct repository *repo,
304 - struct object *tag, struct rev_info *revs)
297 + static int is_tag_in_date_range(struct object *tag, struct rev_info *revs)
305 298 {
306 - size_t size;
299 + unsigned long size;
307 300 enum object_type type;
308 301 char *buf = NULL, *line, *lineend;
309 302 timestamp_t date;
@@ -312,7 +305,7 @@ static int is_tag_in_date_range(struct repository *repo,
312 305 if (revs->max_age == -1 && revs->min_age == -1)
313 306 goto out;
314 307
315 - buf = odb_read_object(repo->objects, &tag->oid, &type, &size);
308 + buf = odb_read_object(the_repository->objects, &tag->oid, &type, &size);
316 309 if (!buf)
317 310 goto out;
318 311 line = memmem(buf, size, "\ntagger ", 8);
@@ -332,52 +325,50 @@ out:
332 325
333 326
334 327 /* Write the pack data to bundle_fd */
335 - static int write_pack_data(int bundle_fd, struct rev_info *revs, int progress)
328 + static int write_pack_data(int bundle_fd, struct rev_info *revs, struct strvec *pack_options)
336 329 {
337 - struct odb_generate_pack_options opts = ODB_GENERATE_PACK_OPTIONS_INIT;
338 - struct odb_pack_generator *generator;
339 - int ret = 0;
330 + struct child_process pack_objects = CHILD_PROCESS_INIT;
340 331 int i;
341 332
342 - opts.thin = 1;
343 - opts.ofs_delta = 1;
344 - if (progress)
345 - opts.progress = ODB_GENERATE_PACK_PROGRESS_VERBOSE;
333 + strvec_pushl(&pack_objects.args,
334 + "pack-objects",
335 + "--stdout", "--thin", "--delta-base-offset",
336 + NULL);
337 + strvec_pushv(&pack_objects.args, pack_options->v);
346 338 if (revs->filter.choice)
347 - opts.filter_spec = list_objects_filter_spec(&revs->filter);
339 + strvec_pushf(&pack_objects.args, "--filter=%s",
340 + list_objects_filter_spec(&revs->filter));
341 + pack_objects.in = -1;
342 + pack_objects.out = bundle_fd;
343 + pack_objects.git_cmd = 1;
348 344
349 345 /*
350 - * The pack generator will consume our descriptor if it's >1.
351 - * Duplicate it to avoid surprising the caller.
346 + * start_command() will close our descriptor if it's >1. Duplicate it
347 + * to avoid surprising the caller.
352 348 */
353 - opts.pack_fd = bundle_fd;
354 - if (opts.pack_fd > 1) {
355 - opts.pack_fd = dup(bundle_fd);
356 - if (opts.pack_fd < 0)
357 - return error_errno(_("unable to dup bundle descriptor"));
349 + if (pack_objects.out > 1) {
350 + pack_objects.out = dup(pack_objects.out);
351 + if (pack_objects.out < 0) {
352 + error_errno(_("unable to dup bundle descriptor"));
353 + child_process_clear(&pack_objects);
354 + return -1;
355 + }
358 356 }
359 357
358 + if (start_command(&pack_objects))
359 + return error(_("Could not spawn pack-objects"));
360 +
360 361 for (i = 0; i < revs->pending.nr; i++) {
361 362 struct object *object = revs->pending.objects[i].item;
362 363 if (object->flags & UNINTERESTING)
363 - oid_array_append(&opts.haves, &object->oid);
364 - else
365 - oid_array_append(&opts.wants, &object->oid);
366 - }
367 -
368 - if (odb_generate_pack(revs->repo->objects, &generator, &opts)) {
369 - ret = error(_("Could not spawn pack-objects"));
370 - goto out;
364 + write_or_die(pack_objects.in, "^", 1);
365 + write_or_die(pack_objects.in, oid_to_hex(&object->oid), the_hash_algo->hexsz);
366 + write_or_die(pack_objects.in, "\n", 1);
371 367 }
372 -
373 - if (odb_pack_generator_finish(generator)) {
374 - ret = error(_("pack-objects died"));
375 - goto out;
376 - }
377 -
378 - out:
379 - odb_generate_pack_options_release(&opts);
380 - return ret;
368 + close(pack_objects.in);
369 + if (finish_command(&pack_objects))
370 + return error(_("pack-objects died"));
371 + return 0;
381 372 }
382 373
383 374 /*
@@ -404,10 +395,10 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
404 395
405 396 if (e->item->flags & UNINTERESTING)
406 397 continue;
407 - if (repo_dwim_ref(revs->repo, e->name, strlen(e->name),
398 + if (repo_dwim_ref(the_repository, e->name, strlen(e->name),
408 399 &oid, &ref, 0) != 1)
409 400 goto skip_write_ref;
410 - if (refs_read_ref_full(get_main_ref_store(revs->repo), e->name, RESOLVE_REF_READING, &oid, &flag))
401 + if (refs_read_ref_full(get_main_ref_store(the_repository), e->name, RESOLVE_REF_READING, &oid, &flag))
411 402 flag = 0;
412 403 display_ref = (flag & REF_ISSYMREF) ? e->name : ref;
413 404
@@ -415,7 +406,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
415 406 goto skip_write_ref;
416 407
417 408 if (e->item->type == OBJ_TAG &&
418 - !is_tag_in_date_range(revs->repo, e->item, revs)) {
409 + !is_tag_in_date_range(e->item, revs)) {
419 410 e->item->flags |= UNINTERESTING;
420 411 goto skip_write_ref;
421 412 }
@@ -437,8 +428,7 @@ static int write_bundle_refs(int bundle_fd, struct rev_info *revs)
437 428
438 429 ref_count++;
439 430 strset_add(&objects, display_ref);
440 - write_or_die(bundle_fd, oid_to_hex(&e->item->oid),
441 - revs->repo->hash_algo->hexsz);
431 + write_or_die(bundle_fd, oid_to_hex(&e->item->oid), the_hash_algo->hexsz);
442 432 write_or_die(bundle_fd, " ", 1);
443 433 write_or_die(bundle_fd, display_ref, strlen(display_ref));
444 434 write_or_die(bundle_fd, "\n", 1);
@@ -486,7 +476,7 @@ static void write_bundle_prerequisites(struct commit *commit, void *data)
486 476 }
487 477
488 478 int create_bundle(struct repository *r, const char *path,
489 - int argc, const char **argv, int version, int progress)
479 + int argc, const char **argv, struct strvec *pack_options, int version)
490 480 {
491 481 struct lock_file lock = LOCK_INIT;
492 482 int bundle_fd = -1;
@@ -517,7 +507,7 @@ int create_bundle(struct repository *r, const char *path,
517 507 * SHA1.
518 508 * 2. @filter is required because we parsed an object filter.
519 509 */
520 - if (r->hash_algo != &hash_algos[GIT_HASH_SHA1_LEGACY] || revs.filter.choice)
510 + if (the_hash_algo != &hash_algos[GIT_HASH_SHA1_LEGACY] || revs.filter.choice)
521 511 min_version = 3;
522 512
523 513 if (argc > 1) {
@@ -529,8 +519,8 @@ int create_bundle(struct repository *r, const char *path,
529 519 if (bundle_to_stdout)
530 520 bundle_fd = 1;
531 521 else
532 - bundle_fd = repo_hold_lock_file_for_update(r, &lock, path,
533 - LOCK_DIE_ON_ERROR);
522 + bundle_fd = hold_lock_file_for_update(&lock, path,
523 + LOCK_DIE_ON_ERROR);
534 524
535 525 if (version == -1)
536 526 version = min_version;
@@ -538,15 +528,14 @@ int create_bundle(struct repository *r, const char *path,
538 528 if (version < 2 || version > 3) {
539 529 die(_("unsupported bundle version %d"), version);
540 530 } else if (version < min_version) {
541 - die(_("cannot write bundle version %d with algorithm %s"), version,
542 - r->hash_algo->name);
531 + die(_("cannot write bundle version %d with algorithm %s"), version, the_hash_algo->name);
543 532 } else if (version == 2) {
544 533 write_or_die(bundle_fd, v2_bundle_signature, strlen(v2_bundle_signature));
545 534 } else {
546 535 const char *capability = "@object-format=";
547 536 write_or_die(bundle_fd, v3_bundle_signature, strlen(v3_bundle_signature));
548 537 write_or_die(bundle_fd, capability, strlen(capability));
549 - write_or_die(bundle_fd, r->hash_algo->name, strlen(r->hash_algo->name));
538 + write_or_die(bundle_fd, the_hash_algo->name, strlen(the_hash_algo->name));
550 539 write_or_die(bundle_fd, "\n", 1);
551 540
552 541 if (revs.filter.choice) {
@@ -595,7 +584,7 @@ int create_bundle(struct repository *r, const char *path,
595 584 }
596 585
597 586 /* write pack */
598 - if (write_pack_data(bundle_fd, &revs_copy, progress)) {
587 + if (write_pack_data(bundle_fd, &revs_copy, pack_options)) {
599 588 ret = -1;
600 589 goto out;
601 590 }
modified bundle.h
@@ -27,7 +27,8 @@ int read_bundle_header(const char *path, struct bundle_header *header);
27 27 int read_bundle_header_fd(int fd, struct bundle_header *header,
28 28 const char *report_path);
29 29 int create_bundle(struct repository *r, const char *path,
30 - int argc, const char **argv, int version, int progress);
30 + int argc, const char **argv, struct strvec *pack_options,
31 + int version);
31 32
32 33 enum verify_bundle_flags {
33 34 VERIFY_BUNDLE_VERBOSE = (1 << 0),
modified cache-tree.c
@@ -10,7 +10,6 @@
10 10 #include "cache-tree.h"
11 11 #include "object-file.h"
12 12 #include "odb.h"
13 - #include "odb/transaction.h"
14 13 #include "read-cache-ll.h"
15 14 #include "replace-object.h"
16 15 #include "repository.h"
@@ -162,54 +161,6 @@ void cache_tree_invalidate_path(struct index_state *istate, const char *path)
162 161 istate->cache_changed |= CACHE_TREE_CHANGED;
163 162 }
164 163
165 - /*
166 - * Check whether this_ce and the next entry in the index form a D/F
167 - * conflict ("path" vs "path/file"). Returns the conflicting "path/..."
168 - * name when one is found, or NULL otherwise.
169 - *
170 - * The cache is sorted, so "path/file" sorts after "path" and the
171 - * conflict is usually visible as adjacent entries. But other entries
172 - * can sort between them -- e.g. "path-internal" sits between "path"
173 - * and "path/file" because '-' (0x2D) precedes '/' (0x2F) -- so when
174 - * the immediately following entry shares our prefix but starts with a
175 - * character that sorts before '/', binary search for "path/" instead.
176 - */
177 - static const char *find_df_conflict(struct index_state *istate,
178 - const struct cache_entry *this_ce,
179 - const struct cache_entry *next_ce)
180 - {
181 - const char *this_name = this_ce->name;
182 - const char *next_name = next_ce->name;
183 - int this_len = ce_namelen(this_ce);
184 - const struct cache_entry *other;
185 - struct strbuf probe = STRBUF_INIT;
186 - int pos;
187 -
188 - if (this_len >= ce_namelen(next_ce) ||
189 - next_name[this_len] > '/' ||
190 - strncmp(this_name, next_name, this_len))
191 - return NULL;
192 -
193 - if (next_name[this_len] == '/')
194 - return next_name;
195 -
196 - strbuf_add(&probe, this_name, this_len);
197 - strbuf_addch(&probe, '/');
198 - pos = index_name_pos_sparse(istate, probe.buf, probe.len);
199 - strbuf_release(&probe);
200 -
201 - if (pos < 0)
202 - pos = -pos - 1;
203 - if (pos >= (int)istate->cache_nr)
204 - return NULL;
205 - other = istate->cache[pos];
206 - if (ce_namelen(other) > this_len &&
207 - other->name[this_len] == '/' &&
208 - !strncmp(this_name, other->name, this_len))
209 - return other->name;
210 - return NULL;
211 - }
212 -
213 164 static int verify_cache(struct index_state *istate, int flags)
214 165 {
215 166 unsigned i, funny;
@@ -239,18 +190,24 @@ static int verify_cache(struct index_state *istate, int flags)
239 190 */
240 191 funny = 0;
241 192 for (i = 0; i + 1 < istate->cache_nr; i++) {
193 + /* path/file always comes after path because of the way
194 + * the cache is sorted. Also path can appear only once,
195 + * which means conflicting one would immediately follow.
196 + */
242 197 const struct cache_entry *this_ce = istate->cache[i];
243 198 const struct cache_entry *next_ce = istate->cache[i + 1];
244 - const char *conflict_name;
245 -
246 - conflict_name = find_df_conflict(istate, this_ce, next_ce);
247 - if (conflict_name) {
199 + const char *this_name = this_ce->name;
200 + const char *next_name = next_ce->name;
201 + int this_len = ce_namelen(this_ce);
202 + if (this_len < ce_namelen(next_ce) &&
203 + next_name[this_len] == '/' &&
204 + strncmp(this_name, next_name, this_len) == 0) {
248 205 if (10 < ++funny) {
249 206 fprintf(stderr, "...\n");
250 207 break;
251 208 }
252 209 fprintf(stderr, "You have both %s and %s\n",
253 - this_ce->name, conflict_name);
210 + this_name, next_name);
254 211 }
255 212 }
256 213 if (funny)
@@ -281,8 +238,8 @@ int cache_tree_fully_valid(struct cache_tree *it)
281 238 if (!it)
282 239 return 0;
283 240 if (it->entry_count < 0 ||
284 - !odb_has_object(the_repository->objects, &it->oid,
285 - ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
241 + odb_has_object(the_repository->objects, &it->oid,
242 + ODB_HAS_OBJECT_RECHECK_PACKED | ODB_HAS_OBJECT_FETCH_PROMISOR))
286 243 return 0;
287 244 for (i = 0; i < it->subtree_nr; i++) {
288 245 if (!cache_tree_fully_valid(it->down[i]->cache_tree))
@@ -516,7 +473,6 @@ static int update_one(struct cache_tree *it,
516 473
517 474 int cache_tree_update(struct index_state *istate, int flags)
518 475 {
519 - int inflight = !!the_repository->objects->transaction;
520 476 struct odb_transaction *transaction;
521 477 int skip, i;
522 478
@@ -533,12 +489,10 @@ int cache_tree_update(struct index_state *istate, int flags)
533 489
534 490 trace_performance_enter();
535 491 trace2_region_enter("cache_tree", "update", istate->repo);
536 - if (!inflight)
537 - odb_transaction_begin_or_die(the_repository->objects, &transaction, 0);
492 + transaction = odb_transaction_begin(the_repository->objects);
538 493 i = update_one(istate->cache_tree, istate->cache, istate->cache_nr,
539 494 "", 0, &skip, flags);
540 - if (!inflight)
541 - odb_transaction_commit_and_finalize_or_die(transaction);
495 + odb_transaction_commit(transaction);
542 496 trace2_region_leave("cache_tree", "update", istate->repo);
543 497 trace_performance_leave("cache_tree_update");
544 498 if (i < 0)
modified cbtree.c
@@ -7,11 +7,6 @@
7 7 #include "git-compat-util.h"
8 8 #include "cbtree.h"
9 9
10 - static inline uint8_t *cb_node_key(struct cb_tree *t, struct cb_node *node)
11 - {
12 - return (uint8_t *) node + t->key_offset;
13 - }
14 -
15 10 static struct cb_node *cb_node_of(const void *p)
16 11 {
17 12 return (struct cb_node *)((uintptr_t)p - 1);
@@ -38,7 +33,6 @@ struct cb_node *cb_insert(struct cb_tree *t, struct cb_node *node, size_t klen)
38 33 uint8_t c;
39 34 int newdirection;
40 35 struct cb_node **wherep, *p;
41 - uint8_t *node_key, *p_key;
42 36
43 37 assert(!((uintptr_t)node & 1)); /* allocations must be aligned */
44 38
@@ -47,26 +41,23 @@ struct cb_node *cb_insert(struct cb_tree *t, struct cb_node *node, size_t klen)
47 41 return NULL; /* success */
48 42 }
49 43
50 - node_key = cb_node_key(t, node);
51 -
52 44 /* see if a node already exists */
53 - p = cb_internal_best_match(t->root, node_key, klen);
54 - p_key = cb_node_key(t, p);
45 + p = cb_internal_best_match(t->root, node->k, klen);
55 46
56 47 /* find first differing byte */
57 48 for (newbyte = 0; newbyte < klen; newbyte++) {
58 - if (p_key[newbyte] != node_key[newbyte])
49 + if (p->k[newbyte] != node->k[newbyte])
59 50 goto different_byte_found;
60 51 }
61 52 return p; /* element exists, let user deal with it */
62 53
63 54 different_byte_found:
64 - newotherbits = p_key[newbyte] ^ node_key[newbyte];
55 + newotherbits = p->k[newbyte] ^ node->k[newbyte];
65 56 newotherbits |= newotherbits >> 1;
66 57 newotherbits |= newotherbits >> 2;
67 58 newotherbits |= newotherbits >> 4;
68 59 newotherbits = (newotherbits & ~(newotherbits >> 1)) ^ 255;
69 - c = p_key[newbyte];
60 + c = p->k[newbyte];
70 61 newdirection = (1 + (newotherbits | c)) >> 8;
71 62
72 63 node->byte = newbyte;
@@ -87,7 +78,7 @@ different_byte_found:
87 78 break;
88 79 if (q->byte == newbyte && q->otherbits > newotherbits)
89 80 break;
90 - c = q->byte < klen ? node_key[q->byte] : 0;
81 + c = q->byte < klen ? node->k[q->byte] : 0;
91 82 direction = (1 + (q->otherbits | c)) >> 8;
92 83 wherep = q->child + direction;
93 84 }
@@ -102,7 +93,7 @@ struct cb_node *cb_lookup(struct cb_tree *t, const uint8_t *k, size_t klen)
102 93 {
103 94 struct cb_node *p = cb_internal_best_match(t->root, k, klen);
104 95
105 - return p && !memcmp(cb_node_key(t, p), k, klen) ? p : NULL;
96 + return p && !memcmp(p->k, k, klen) ? p : NULL;
106 97 }
107 98
108 99 static int cb_descend(struct cb_node *p, cb_iter fn, void *arg)
@@ -124,7 +115,6 @@ int cb_each(struct cb_tree *t, const uint8_t *kpfx, size_t klen,
124 115 struct cb_node *p = t->root;
125 116 struct cb_node *top = p;
126 117 size_t i = 0;
127 - uint8_t *p_key;
128 118
129 119 if (!p)
130 120 return 0; /* empty tree */
@@ -140,9 +130,8 @@ int cb_each(struct cb_tree *t, const uint8_t *kpfx, size_t klen,
140 130 top = p;
141 131 }
142 132
143 - p_key = cb_node_key(t, p);
144 133 for (i = 0; i < klen; i++) {
145 - if (p_key[i] != kpfx[i])
134 + if (p->k[i] != kpfx[i])
146 135 return 0; /* "best" match failed */
147 136 }
148 137
modified cbtree.h
@@ -6,9 +6,9 @@
6 6 *
7 7 * This is adapted to store arbitrary data (not just NUL-terminated C strings
8 8 * and allocates no memory internally. The user needs to allocate
9 - * "struct cb_node" and provide `key_offset` to indicate where the key can be
10 - * found relative to the `struct cb_node` for memcmp.
11 - * If "klen" is variable, then it should be embedded into the key.
9 + * "struct cb_node" and fill cb_node.k[] with arbitrary match data
10 + * for memcmp.
11 + * If "klen" is variable, then it should be embedded into "c_node.k[]"
12 12 * Recursion is bound by the maximum value of "klen" used.
13 13 */
14 14 #ifndef CBTREE_H
@@ -23,19 +23,18 @@ struct cb_node {
23 23 */
24 24 uint32_t byte;
25 25 uint8_t otherbits;
26 + uint8_t k[FLEX_ARRAY]; /* arbitrary data, unaligned */
26 27 };
27 28
28 29 struct cb_tree {
29 30 struct cb_node *root;
30 - ptrdiff_t key_offset;
31 31 };
32 32
33 - static inline void cb_init(struct cb_tree *t,
34 - ptrdiff_t key_offset)
33 + #define CBTREE_INIT { 0 }
34 +
35 + static inline void cb_init(struct cb_tree *t)
35 36 {
36 - struct cb_tree blank = {
37 - .key_offset = key_offset,
38 - };
37 + struct cb_tree blank = CBTREE_INIT;
39 38 memcpy(t, &blank, sizeof(*t));
40 39 }
41 40
modified chdir-notify.c
@@ -7,22 +7,25 @@
7 7 #include "trace.h"
8 8
9 9 struct chdir_notify_entry {
10 + const char *name;
10 11 chdir_notify_callback cb;
11 12 void *data;
12 13 struct list_head list;
13 14 };
14 15 static LIST_HEAD(chdir_notify_entries);
15 16
16 - void chdir_notify_register(chdir_notify_callback cb,
17 + void chdir_notify_register(const char *name,
18 + chdir_notify_callback cb,
17 19 void *data)
18 20 {
19 21 struct chdir_notify_entry *e = xmalloc(sizeof(*e));
22 + e->name = name;
20 23 e->cb = cb;
21 24 e->data = data;
22 25 list_add_tail(&e->list, &chdir_notify_entries);
23 26 }
24 27
25 - void chdir_notify_unregister(chdir_notify_callback cb,
28 + void chdir_notify_unregister(const char *name, chdir_notify_callback cb,
26 29 void *data)
27 30 {
28 31 struct list_head *pos, *p;
@@ -31,7 +34,8 @@ void chdir_notify_unregister(chdir_notify_callback cb,
31 34 struct chdir_notify_entry *e =
32 35 list_entry(pos, struct chdir_notify_entry, list);
33 36
34 - if (e->cb != cb || e->data != data)
37 + if (e->cb != cb || e->data != data || !e->name != !name ||
38 + (e->name && strcmp(e->name, name)))
35 39 continue;
36 40
37 41 list_del(pos);
@@ -39,6 +43,32 @@ void chdir_notify_unregister(chdir_notify_callback cb,
39 43 }
40 44 }
41 45
46 + static void reparent_cb(const char *name,
47 + const char *old_cwd,
48 + const char *new_cwd,
49 + void *data)
50 + {
51 + char **path = data;
52 + char *tmp = *path;
53 +
54 + if (!tmp)
55 + return;
56 +
57 + *path = reparent_relative_path(old_cwd, new_cwd, tmp);
58 + free(tmp);
59 +
60 + if (name) {
61 + trace_printf_key(&trace_setup_key,
62 + "setup: reparent %s to '%s'",
63 + name, *path);
64 + }
65 + }
66 +
67 + void chdir_notify_reparent(const char *name, char **path)
68 + {
69 + chdir_notify_register(name, reparent_cb, path);
70 + }
71 +
42 72 int chdir_notify(const char *new_cwd)
43 73 {
44 74 struct strbuf old_cwd = STRBUF_INIT;
@@ -60,7 +90,7 @@ int chdir_notify(const char *new_cwd)
60 90 list_for_each(pos, &chdir_notify_entries) {
61 91 struct chdir_notify_entry *e =
62 92 list_entry(pos, struct chdir_notify_entry, list);
63 - e->cb(old_cwd.buf, new_cwd, e->data);
93 + e->cb(e->name, old_cwd.buf, new_cwd, e->data);
64 94 }
65 95
66 96 strbuf_release(&old_cwd);
modified chdir-notify.h
@@ -19,7 +19,10 @@
19 19 * chdir_notify_register("description", foo, data);
20 20 *
21 21 * In practice most callers will want to move a relative path to the new root;
22 - * they can use the reparent_relative_path() helper for that.
22 + * they can use the reparent_relative_path() helper for that. If that's all
23 + * you're doing, you can also use the convenience function:
24 + *
25 + * chdir_notify_reparent("description", &my_path);
23 26 *
24 27 * Whenever a chdir event occurs, that will update my_path (if it's relative)
25 28 * to adjust for the new cwd by freeing any existing string and allocating a
@@ -33,11 +36,14 @@
33 36 * $GIT_TRACE_SETUP. It may be NULL, but if non-NULL should point to
34 37 * storage which lasts as long as the registration is active.
35 38 */
36 - typedef void (*chdir_notify_callback)(const char *old_cwd,
39 + typedef void (*chdir_notify_callback)(const char *name,
40 + const char *old_cwd,
37 41 const char *new_cwd,
38 42 void *data);
39 - void chdir_notify_register(chdir_notify_callback cb, void *data);
40 - void chdir_notify_unregister(chdir_notify_callback cb, void *data);
43 + void chdir_notify_register(const char *name, chdir_notify_callback cb, void *data);
44 + void chdir_notify_unregister(const char *name, chdir_notify_callback cb,
45 + void *data);
46 + void chdir_notify_reparent(const char *name, char **path);
41 47
42 48 /*
43 49 *
modified checkout.c
@@ -8,7 +8,6 @@
8 8 #include "checkout.h"
9 9 #include "config.h"
10 10 #include "strbuf.h"
11 - #include "string-list.h"
12 11
13 12 struct tracking_name_data {
14 13 /* const */ char *src_ref;
@@ -18,7 +17,6 @@ struct tracking_name_data {
18 17 const char *default_remote;
19 18 char *default_dst_ref;
20 19 struct object_id *default_dst_oid;
21 - struct string_list *remote_names;
22 20 };
23 21
24 22 #define TRACKING_NAME_DATA_INIT { 0 }
@@ -41,8 +39,6 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
41 39 oidcpy(dst, cb->dst_oid);
42 40 cb->default_dst_oid = dst;
43 41 }
44 - if (cb->remote_names)
45 - string_list_append(cb->remote_names, remote->name);
46 42 if (cb->dst_ref) {
47 43 free(query.dst);
48 44 return 0;
@@ -52,19 +48,14 @@ static int check_tracking_name(struct remote *remote, void *cb_data)
52 48 }
53 49
54 50 char *unique_tracking_name(const char *name, struct object_id *oid,
55 - int *dwim_remotes_matched,
56 - struct string_list *dwim_remote_names)
51 + int *dwim_remotes_matched)
57 52 {
58 53 struct tracking_name_data cb_data = TRACKING_NAME_DATA_INIT;
59 54 const char *default_remote = NULL;
60 -
61 - if (!repo_config_get_string_tmp(the_repository,
62 - "checkout.defaultremote",
63 - &default_remote))
55 + if (!repo_config_get_string_tmp(the_repository, "checkout.defaultremote", &default_remote))
64 56 cb_data.default_remote = default_remote;
65 57 cb_data.src_ref = xstrfmt("refs/heads/%s", name);
66 58 cb_data.dst_oid = oid;
67 - cb_data.remote_names = dwim_remote_names;
68 59 for_each_remote(check_tracking_name, &cb_data);
69 60 if (dwim_remotes_matched)
70 61 *dwim_remotes_matched = cb_data.num_matches;
modified checkout.h
@@ -3,8 +3,6 @@
3 3
4 4 #include "hash.h"
5 5
6 - struct string_list;
7 -
8 6 /*
9 7 * Check if the branch name uniquely matches a branch name on a remote
10 8 * tracking branch. Return the name of the remote if such a branch
@@ -12,7 +10,6 @@ struct string_list;
12 10 */
13 11 char *unique_tracking_name(const char *name,
14 12 struct object_id *oid,
15 - int *dwim_remotes_matched,
16 - struct string_list *dwim_remote_names);
13 + int *dwim_remotes_matched);
17 14
18 15 #endif /* CHECKOUT_H */
deleted ci/install-dependencies.ps1 mode 100755
@@ -1,55 +0,0 @@
1 - param(
2 - [string]$DownloadDirectory = '.dependencies'
3 - )
4 -
5 - $ErrorActionPreference = 'Stop'
6 - $ProgressPreference = 'SilentlyContinue'
7 -
8 - $GitVersion = '2.54.0.windows.1'
9 - $MesonVersion = '1.11.0'
10 - $RustVersion = '1.96.0'
11 -
12 - New-Item -Path $DownloadDirectory -ItemType Directory -Force | Out-Null
13 - New-Item -Path .git/info -ItemType Directory -Force | Out-Null
14 - New-Item -Path .git/info/exclude -ItemType File -Force | Out-Null
15 - Add-Content -Path .git/info/exclude -Value "/$DownloadDirectory"
16 -
17 - function Get-Installer {
18 - param(
19 - [Parameter(Mandatory = $true)][string]$Name,
20 - [Parameter(Mandatory = $true)][string]$Url
21 - )
22 -
23 - $path = Join-Path $DownloadDirectory $Name
24 - if (-not (Test-Path $path)) {
25 - Write-Host "Downloading $Url"
26 - Invoke-WebRequest $Url -OutFile $path -TimeoutSec 300
27 - }
28 - return $path
29 - }
30 -
31 - function Invoke-Installer {
32 - param(
33 - [Parameter(Mandatory = $true)][string]$FilePath,
34 - [Parameter(Mandatory = $true)][string[]]$ArgumentList
35 - )
36 -
37 - Write-Host "Running $FilePath $($ArgumentList -join ' ')"
38 - $process = Start-Process -Wait -PassThru -FilePath $FilePath -ArgumentList $ArgumentList
39 - if ($process.ExitCode -ne 0) {
40 - throw "$FilePath failed with exit code $($process.ExitCode)"
41 - }
42 - }
43 -
44 - $gitAssetVersion = $GitVersion -replace '\.windows\.\d+$', ''
45 - $gitInstaller = Get-Installer "Git-Installer.exe" `
46 - "https://github.com/git-for-windows/git/releases/download/v$GitVersion/PortableGit-$gitAssetVersion-64-bit.7z.exe"
47 - Invoke-Installer $gitInstaller @('-y', '-o"C:\Program Files\Git"')
48 -
49 - $mesonMsi = Get-Installer "meson.msi" `
50 - "https://github.com/mesonbuild/meson/releases/download/$MesonVersion/meson-$MesonVersion-64.msi"
51 - Invoke-Installer msiexec.exe @('/i', $mesonMsi, 'INSTALLDIR=C:\Meson', '/quiet', '/norestart')
52 -
53 - $rustMsi = Get-Installer "rust.msi" `
54 - "https://static.rust-lang.org/dist/rust-$RustVersion-x86_64-pc-windows-msvc.msi"
55 - Invoke-Installer msiexec.exe @('/i', $rustMsi, 'INSTALLDIR=C:\Rust', 'ADDLOCAL=Rustc,Cargo,Std', '/quiet', '/norestart')
modified ci/install-dependencies.sh
@@ -29,7 +29,7 @@ alpine-*)
29 29 apk add --update shadow sudo meson ninja-build gcc libc-dev curl-dev openssl-dev expat-dev gettext \
30 30 zlib-ng-dev pcre2-dev python3 musl-libintl perl-utils ncurses \
31 31 apache2 apache2-http2 apache2-proxy apache2-ssl apache2-webdav apr-util-dbd_sqlite3 \
32 - bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty cargo >/dev/null
32 + bash cvs gnupg perl-cgi perl-dbd-sqlite perl-io-tty >/dev/null
33 33 ;;
34 34 fedora-*|almalinux-*)
35 35 case "$jobname" in
modified ci/lib.sh
@@ -215,7 +215,6 @@ then
215 215 test macos != "$CI_OS_NAME" || CI_OS_NAME=osx
216 216 CI_REPO_SLUG="$GITHUB_REPOSITORY"
217 217 CI_JOB_ID="$GITHUB_RUN_ID"
218 - CI_EVENT="$GITHUB_EVENT_NAME"
219 218 CC="${CC_PACKAGE:-${CC:-gcc}}"
220 219 DONT_SKIP_TAGS=t
221 220 handle_failed_tests () {
@@ -240,13 +239,6 @@ then
240 239 CI_BRANCH="$CI_COMMIT_REF_NAME"
241 240 CI_COMMIT="$CI_COMMIT_SHA"
242 241
243 - case "$CI_PIPELINE_SOURCE" in
244 - merge_request_event)
245 - CI_EVENT=pull_request;;
246 - *)
247 - CI_EVENT="$CI_PIPELINE_SOURCE";;
248 - esac
249 -
250 242 case "$OS,$CI_JOB_IMAGE" in
251 243 Windows_NT,*)
252 244 CI_OS_NAME=windows
@@ -262,7 +254,7 @@ then
262 254 CI_OS_NAME=osx
263 255 JOBS=$(nproc)
264 256 ;;
265 - *,almalinux:*|*,alpine:*|*,debian:*|*,fedora:*|*,ubuntu:*|*,i386/ubuntu:*)
257 + *,alpine:*|*,fedora:*|*,ubuntu:*|*,i386/ubuntu:*)
266 258 CI_OS_NAME=linux
267 259 JOBS=$(nproc)
268 260 ;;
@@ -322,17 +314,6 @@ export DEFAULT_TEST_TARGET=prove
322 314 export GIT_TEST_CLONE_2GB=true
323 315 export SKIP_DASHED_BUILT_INS=YesPlease
324 316
325 - # In order to give maximum test coverage to contributor builds,
326 - # preferrably even before the changes consume public review bandwidth,
327 - # enable "expensive" tests for PR events.
328 - # In order to catch bugs introduced at integration time by mismerges,
329 - # enable the long tests for pushes to the integration branches as well.
330 - case "$CI_EVENT,$CI_BRANCH" in
331 - pull_request,*|push,*next*|push,*master*|push,*main*|push,*maint*)
332 - export GIT_TEST_LONG=${GIT_TEST_LONG:-true}
333 - ;;
334 - esac
335 -
336 317 case "$distro" in
337 318 ubuntu-*)
338 319 # Python 2 is end of life, and Ubuntu 23.04 and newer don't actually
@@ -391,9 +372,6 @@ linux-asan-ubsan)
391 372 osx-meson)
392 373 MESONFLAGS="$MESONFLAGS -Dcredential_helpers=osxkeychain"
393 374 ;;
394 - windows-*)
395 - export NO_RUST=UnfortunatelyYes
396 - ;;
397 375 esac
398 376
399 377 MAKEFLAGS="$MAKEFLAGS CC=${CC:-cc}"
modified ci/run-build-and-minimal-fuzzers.sh
@@ -21,7 +21,6 @@ date
21 21 pack-headers
22 22 pack-idx
23 23 parse-attr-line
24 - reftable
25 24 url-decode-mem
26 25 "
27 26
modified ci/run-build-and-tests.sh
@@ -7,20 +7,12 @@
7 7
8 8 export TEST_CONTRIB_TOO=yes
9 9
10 - case "$jobname" in
11 - linux-musl-meson)
12 - MESONFLAGS="$MESONFLAGS -Drust=disabled"
13 - export GIT_TEST_USE_SET_E=yes
14 - ;;
15 - almalinux-*|debian-*|fedora-*|linux-*)
16 - export GIT_TEST_USE_SET_E=yes
17 - ;;
18 - esac
19 -
20 10 case "$jobname" in
21 11 fedora-breaking-changes-musl|linux-breaking-changes)
22 12 export WITH_BREAKING_CHANGES=YesPlease
13 + export WITH_RUST=YesPlease
23 14 MESONFLAGS="$MESONFLAGS -Dbreaking_changes=true"
15 + MESONFLAGS="$MESONFLAGS -Drust=enabled"
24 16 ;;
25 17 linux-TEST-vars)
26 18 export OPENSSL_SHA1_UNSAFE=YesPlease
@@ -38,7 +30,6 @@ linux-TEST-vars)
38 30 export GIT_TEST_PACK_USE_BITMAP_BOUNDARY_TRAVERSAL=1
39 31 ;;
40 32 linux-clang)
41 - export NO_RUST=UnfortunatelyYes
42 33 export GIT_TEST_DEFAULT_HASH=sha1
43 34 ;;
44 35 linux-sha256)
modified combine-diff.c
@@ -325,9 +325,7 @@ static char *grab_blob(struct repository *r,
325 325 *size = fill_textconv(r, textconv, df, &blob);
326 326 free_filespec(df);
327 327 } else {
328 - size_t size_st = 0;
329 - blob = odb_read_object(r->objects, oid, &type, &size_st);
330 - *size = cast_size_t_to_ulong(size_st);
328 + blob = odb_read_object(r->objects, oid, &type, size);
331 329 if (!blob)
332 330 die(_("unable to read %s"), oid_to_hex(oid));
333 331 if (type != OBJ_BLOB)
@@ -668,7 +666,7 @@ static int make_hunks(struct sline *sline, unsigned long cnt,
668 666 * (-) line, which records from what parents the line
669 667 * was removed; this line does not appear in the result.
670 668 * then check the set of parents the result has difference
671 - * from, from all lines. If there are lines that have
669 + * from, from all lines. If there are lines that has
672 670 * different set of parents that the result has differences
673 671 * from, that means we have more than two versions.
674 672 *
@@ -1080,7 +1078,7 @@ static void show_patch_diff(struct combine_diff_path *elem, int num_parent,
1080 1078 /* if symlinks don't work, assume symlink if all parents
1081 1079 * are symlinks
1082 1080 */
1083 - is_file = repo_has_symlinks(rev->repo);
1081 + is_file = has_symlinks;
1084 1082 for (i = 0; !is_file && i < num_parent; i++)
1085 1083 is_file = !S_ISLNK(elem->parent[i].mode);
1086 1084 if (!is_file)
modified command-list.txt
@@ -108,7 +108,6 @@ git-fmt-merge-msg purehelpers
108 108 git-for-each-ref plumbinginterrogators
109 109 git-for-each-repo plumbinginterrogators
110 110 git-format-patch mainporcelain
111 - git-format-rev plumbinginterrogators
112 111 git-fsck ancillaryinterrogators complete
113 112 git-gc mainporcelain
114 113 git-get-tar-commit-id plumbinginterrogators
@@ -203,7 +202,6 @@ git-update-ref plumbingmanipulators
203 202 git-update-server-info synchingrepositories
204 203 git-upload-archive synchelpers
205 204 git-upload-pack synchelpers
206 - git-url-parse purehelpers
207 205 git-var plumbinginterrogators
208 206 git-verify-commit ancillaryinterrogators
209 207 git-verify-pack plumbinginterrogators
modified commit-graph.c
@@ -651,6 +651,8 @@ struct commit_graph *load_commit_graph_chain_fd_st(struct object_database *odb,
651 651 count = st->st_size / (odb->repo->hash_algo->hexsz + 1);
652 652 CALLOC_ARRAY(oids, count);
653 653
654 + odb_prepare_alternates(odb);
655 +
654 656 for (i = 0; i < count; i++) {
655 657 struct odb_source *source;
656 658
@@ -738,13 +740,13 @@ static struct commit_graph *prepare_commit_graph(struct repository *r)
738 740 struct odb_source *source;
739 741
740 742 /*
741 - * Early return if there is no object database or if the commit graph is
743 + * Early return if there is no git dir or if the commit graph is
742 744 * disabled.
743 745 *
744 746 * This must come before the "already attempted?" check below, because
745 747 * we want to disable even an already-loaded graph file.
746 748 */
747 - if (!r->objects || r->commit_graph_disabled)
749 + if (!r->gitdir || r->commit_graph_disabled)
748 750 return NULL;
749 751
750 752 if (r->objects->commit_graph_attempted)
@@ -766,6 +768,7 @@ static struct commit_graph *prepare_commit_graph(struct repository *r)
766 768 if (!commit_graph_compatible(r))
767 769 return NULL;
768 770
771 + odb_prepare_alternates(r->objects);
769 772 for (source = r->objects->sources; source; source = source->next) {
770 773 r->objects->commit_graph = read_commit_graph_one(source);
771 774 if (r->objects->commit_graph)
@@ -1535,7 +1538,7 @@ static int add_packed_commits(const struct object_id *oid,
1535 1538 struct object_info oi = OBJECT_INFO_INIT;
1536 1539
1537 1540 oi.typep = &type;
1538 - if (packed_object_info(NULL, pack, offset, &oi) < 0)
1541 + if (packed_object_info(pack, offset, &oi) < 0)
1539 1542 die(_("unable to get type of object %s"), oid_to_hex(oid));
1540 1543
1541 1544 return add_packed_commits_oi(oid, &oi, data);
@@ -1650,7 +1653,6 @@ static void compute_reachable_generation_numbers(
1650 1653 {
1651 1654 int i;
1652 1655 struct commit_list *list = NULL;
1653 - intmax_t steps = 0;
1654 1656
1655 1657 for (i = 0; i < info->commits->nr; i++) {
1656 1658 struct commit *c = info->commits->items[i];
@@ -1667,9 +1669,8 @@ static void compute_reachable_generation_numbers(
1667 1669 struct commit *current = list->item;
1668 1670 struct commit_list *parent;
1669 1671 int all_parents_computed = 1;
1670 - timestamp_t max_gen = 0;
1672 + uint32_t max_gen = 0;
1671 1673
1672 - steps++;
1673 1674 for (parent = current->parents; parent; parent = parent->next) {
1674 1675 repo_parse_commit(info->r, parent->item);
1675 1676 gen = info->get_generation(parent->item, info->data);
@@ -1693,9 +1694,6 @@ static void compute_reachable_generation_numbers(
1693 1694 }
1694 1695 }
1695 1696 }
1696 -
1697 - trace2_data_intmax("commit-graph", info->r,
1698 - "generation-dfs-steps", steps);
1699 1697 }
1700 1698
1701 1699 static timestamp_t get_topo_level(struct commit *c, void *data)
@@ -2015,10 +2013,11 @@ static void fill_oids_from_all_packs(struct write_commit_graph_context *ctx)
2015 2013 _("Finding commits for commit graph among packed objects"),
2016 2014 ctx->approx_nr_objects);
2017 2015
2016 + odb_prepare_alternates(ctx->r->objects);
2018 2017 for (source = ctx->r->objects->sources; source; source = source->next) {
2019 2018 struct odb_source_files *files = odb_source_files_downcast(source);
2020 - odb_source_for_each_object(&files->packed->base, &oi, add_packed_commits_oi,
2021 - ctx, &opts);
2019 + packfile_store_for_each_object(files->packed, &oi, add_packed_commits_oi,
2020 + ctx, &opts);
2022 2021 }
2023 2022
2024 2023 if (ctx->progress_done < ctx->approx_nr_objects)
@@ -2123,8 +2122,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
2123 2122 if (ctx->split) {
2124 2123 char *lock_name = get_commit_graph_chain_filename(ctx->odb_source);
2125 2124
2126 - repo_hold_lock_file_for_update_mode(ctx->r, &lk, lock_name,
2127 - LOCK_DIE_ON_ERROR, 0444);
2125 + hold_lock_file_for_update_mode(&lk, lock_name,
2126 + LOCK_DIE_ON_ERROR, 0444);
2128 2127 free(lock_name);
2129 2128
2130 2129 graph_layer = mks_tempfile_m(ctx->graph_name, 0444);
@@ -2142,9 +2141,8 @@ static int write_commit_graph_file(struct write_commit_graph_context *ctx)
2142 2141 f = hashfd(ctx->r->hash_algo,
2143 2142 get_tempfile_fd(graph_layer), get_tempfile_path(graph_layer));
2144 2143 } else {
2145 - repo_hold_lock_file_for_update_mode(ctx->r, &lk,
2146 - ctx->graph_name,
2147 - LOCK_DIE_ON_ERROR, 0444);
2144 + hold_lock_file_for_update_mode(&lk, ctx->graph_name,
2145 + LOCK_DIE_ON_ERROR, 0444);
2148 2146 f = hashfd(ctx->r->hash_algo,
2149 2147 get_lock_file_fd(&lk), get_lock_file_path(&lk));
2150 2148 }
@@ -2607,7 +2605,7 @@ int write_commit_graph(struct odb_source *source,
2607 2605
2608 2606 g = prepare_commit_graph(ctx.r);
2609 2607 for (struct commit_graph *chain = g; chain; chain = chain->base_graph)
2610 - chain->topo_levels = &topo_levels;
2608 + g->topo_levels = &topo_levels;
2611 2609
2612 2610 if (flags & COMMIT_GRAPH_WRITE_BLOOM_FILTERS)
2613 2611 ctx.changed_paths = 1;
modified commit-graph.h
@@ -18,7 +18,7 @@
18 18 * This method is only used to enhance coverage of the commit-graph
19 19 * feature in the test suite with the GIT_TEST_COMMIT_GRAPH and
20 20 * GIT_TEST_COMMIT_GRAPH_CHANGED_PATHS environment variables. Do not
21 - * call this method outside of a builtin, and only if you know what
21 + * call this method oustide of a builtin, and only if you know what
22 22 * you are doing!
23 23 */
24 24 void git_test_write_commit_graph_or_die(struct odb_source *source);
modified commit-reach.c
@@ -11,16 +11,14 @@
11 11 #include "tag.h"
12 12 #include "commit-reach.h"
13 13 #include "ewah/ewok.h"
14 - #include "trace2.h"
15 14
16 15 /* Remember to update object flag allocation in object.h */
17 16 #define PARENT1 (1u<<16)
18 17 #define PARENT2 (1u<<17)
19 18 #define STALE (1u<<18)
20 19 #define RESULT (1u<<19)
21 - #define ENQUEUED (1u<<20)
22 20
23 - static const unsigned all_flags = (PARENT1 | PARENT2 | STALE | RESULT | ENQUEUED);
21 + static const unsigned all_flags = (PARENT1 | PARENT2 | STALE | RESULT);
24 22
25 23 static int compare_commits_by_gen(const void *_a, const void *_b)
26 24 {
@@ -41,204 +39,64 @@ static int compare_commits_by_gen(const void *_a, const void *_b)
41 39 return 0;
42 40 }
43 41
44 - /*
45 - * A prio_queue with O(1) termination check. 'max_nonstale' tracks
46 - * the lowest-priority non-stale commit enqueued so far; once it is
47 - * popped, every remaining entry is known to be STALE.
48 - */
49 - struct nonstale_queue {
50 - struct prio_queue pq;
51 - struct commit *max_nonstale;
52 - };
53 -
54 - static void nonstale_queue_put(struct nonstale_queue *queue,
55 - struct commit *c)
42 + static int queue_has_nonstale(struct prio_queue *queue)
56 43 {
57 - struct commit *old = queue->max_nonstale;
58 -
59 - prio_queue_put(&queue->pq, c);
60 - if (c->object.flags & STALE)
61 - return;
62 - if (!old || queue->pq.compare(old, c, queue->pq.cb_data) <= 0)
63 - queue->max_nonstale = c;
64 - }
65 -
66 - static struct commit *nonstale_queue_get(struct nonstale_queue *queue)
67 - {
68 - struct commit *commit = prio_queue_get(&queue->pq);
69 -
70 - if (commit == queue->max_nonstale)
71 - queue->max_nonstale = NULL;
72 -
73 - return commit;
74 - }
75 -
76 - static void clear_nonstale_queue(struct nonstale_queue *queue)
77 - {
78 - clear_prio_queue(&queue->pq);
79 - queue->max_nonstale = NULL;
80 - }
81 -
82 - /*
83 - * Priority queue with per-side commit counters for paint_down_to_common().
84 - * Each non-stale queued commit occupies exactly one bucket: PARENT1-only,
85 - * PARENT2-only, or both (a pending merge-base candidate).
86 - */
87 - struct paint_state {
88 - struct prio_queue queue;
89 - size_t parent1_count;
90 - size_t parent2_count;
91 - size_t mb_candidate_count;
92 - timestamp_t min_generation;
93 - timestamp_t last_gen;
94 - timestamp_t topo_ceiling;
95 - };
96 -
97 - static void paint_count_update(struct paint_state *state,
98 - unsigned flags, int delta)
99 - {
100 - switch (flags & (PARENT1 | PARENT2 | STALE)) {
101 - case PARENT1:
102 - state->parent1_count += delta;
103 - break;
104 -
105 - case PARENT2:
106 - state->parent2_count += delta;
107 - break;
108 -
109 - case PARENT1 | PARENT2:
110 - state->mb_candidate_count += delta;
111 - break;
112 -
113 - case PARENT1 | PARENT2 | STALE:
114 - break;
115 -
116 - default:
117 - BUG("unexpected paint state");
118 - }
119 - }
120 -
121 - static void paint_queue_put(struct paint_state *state,
122 - struct commit *c, unsigned add_flags)
123 - {
124 - unsigned old_flags = c->object.flags;
125 - c->object.flags |= add_flags;
126 -
127 - if (old_flags & ENQUEUED) {
128 - paint_count_update(state, old_flags, -1);
129 - paint_count_update(state, c->object.flags, 1);
130 - } else {
131 - c->object.flags |= ENQUEUED;
132 - prio_queue_put(&state->queue, c);
133 - paint_count_update(state, c->object.flags, 1);
134 - }
135 - }
136 -
137 - /*
138 - * Dequeue the next commit for the paint walk, or return NULL when
139 - * no more merge bases can be discovered.
140 - */
141 - static struct commit *paint_queue_get(struct paint_state *state)
142 - {
143 - struct commit *commit = prio_queue_get(&state->queue);
144 - timestamp_t generation;
145 -
146 - if (!commit)
147 - return NULL;
148 -
149 - commit->object.flags &= ~ENQUEUED;
150 - generation = commit_graph_generation(commit);
151 -
152 - if (state->min_generation && generation > state->last_gen)
153 - BUG("bad generation skip %"PRItime" > %"PRItime" at %s",
154 - generation, state->last_gen,
155 - oid_to_hex(&commit->object.oid));
156 - state->last_gen = generation;
157 -
158 - /* generation cutoff */
159 - if (generation < state->min_generation)
160 - return NULL;
161 -
162 - /*
163 - * Check exit condition before decrementing: the counters
164 - * still include this commit, so the last non-stale commit
165 - * sees a non-zero count and is returned for processing.
166 - */
167 - if (!state->mb_candidate_count) {
168 - /* only stale entries remain */
169 - if (!state->parent1_count && !state->parent2_count)
170 - return NULL;
171 -
172 - /* one side is exhausted */
173 - if ((!state->parent1_count || !state->parent2_count) &&
174 - generation < state->topo_ceiling)
175 - return NULL;
44 + for (size_t i = 0; i < queue->nr; i++) {
45 + struct commit *commit = queue->array[i].data;
46 + if (!(commit->object.flags & STALE))
47 + return 1;
176 48 }
177 -
178 - paint_count_update(state, commit->object.flags, -1);
179 - return commit;
49 + return 0;
180 50 }
181 51
182 - /*
183 - * See Documentation/technical/paint-down-to-common.adoc
184 - *
185 - * All input commits in one and twos[] must have been parsed!
186 - */
52 + /* all input commits in one and twos[] must have been parsed! */
187 53 static int paint_down_to_common(struct repository *r,
188 54 struct commit *one, int n,
189 55 struct commit **twos,
190 56 timestamp_t min_generation,
191 - enum merge_base_flags mb_flags,
57 + int ignore_missing_commits,
192 58 struct commit_list **result)
193 59 {
194 - /*
195 - * Generation ordering is required for the side-exhaustion and
196 - * single-result early exits, which rely on topological traversal
197 - * order (children visited before parents) in the ordered region.
198 - */
199 - struct paint_state state = {
200 - .queue = { compare_commits_by_gen_then_commit_date }
201 - };
202 - struct commit *commit;
60 + struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
203 61 int i;
204 - int steps = 0;
62 + timestamp_t last_gen = GENERATION_NUMBER_INFINITY;
205 63 struct commit_list **tail = result;
206 64
207 - state.min_generation = min_generation;
208 - state.last_gen = GENERATION_NUMBER_INFINITY;
209 - state.topo_ceiling = corrected_commit_dates_enabled(r)
210 - ? GENERATION_NUMBER_INFINITY
211 - : GENERATION_NUMBER_V1_MAX;
212 -
65 + if (!min_generation && !corrected_commit_dates_enabled(r))
66 + queue.compare = compare_commits_by_commit_date;
213 67
214 68 one->object.flags |= PARENT1;
215 69 if (!n) {
216 70 commit_list_append(one, result);
217 71 return 0;
218 72 }
219 - paint_queue_put(&state, one, 0);
73 + prio_queue_put(&queue, one);
220 74
221 - for (i = 0; i < n; i++)
222 - paint_queue_put(&state, twos[i], PARENT2);
75 + for (i = 0; i < n; i++) {
76 + twos[i]->object.flags |= PARENT2;
77 + prio_queue_put(&queue, twos[i]);
78 + }
223 79
224 - while ((commit = paint_queue_get(&state))) {
80 + while (queue_has_nonstale(&queue)) {
81 + struct commit *commit = prio_queue_get(&queue);
225 82 struct commit_list *parents;
226 83 int flags;
227 - steps++;
84 + timestamp_t generation = commit_graph_generation(commit);
85 +
86 + if (min_generation && generation > last_gen)
87 + BUG("bad generation skip %"PRItime" > %"PRItime" at %s",
88 + generation, last_gen,
89 + oid_to_hex(&commit->object.oid));
90 + last_gen = generation;
91 +
92 + if (generation < min_generation)
93 + break;
228 94
229 95 flags = commit->object.flags & (PARENT1 | PARENT2 | STALE);
230 96 if (flags == (PARENT1 | PARENT2)) {
231 97 if (!(commit->object.flags & RESULT)) {
232 98 commit->object.flags |= RESULT;
233 99 tail = commit_list_append(commit, tail);
234 - /*
235 - * When the queue is generation-ordered,
236 - * no remaining common ancestor can be a
237 - * descendant of this one.
238 - */
239 - if (!(mb_flags & MERGE_BASE_FIND_ALL) &&
240 - state.last_gen < state.topo_ceiling)
241 - break;
242 100 }
243 101 /* Mark parents of a found merge stale */
244 102 flags |= STALE;
@@ -250,7 +108,7 @@ static int paint_down_to_common(struct repository *r,
250 108 if ((p->object.flags & flags) == flags)
251 109 continue;
252 110 if (repo_parse_commit(r, p)) {
253 - clear_prio_queue(&state.queue);
111 + clear_prio_queue(&queue);
254 112 commit_list_free(*result);
255 113 *result = NULL;
256 114 /*
@@ -260,18 +118,17 @@ static int paint_down_to_common(struct repository *r,
260 118 * corrupt commits would already have been
261 119 * dispatched with a `die()`.
262 120 */
263 - if (mb_flags & MERGE_BASE_IGNORE_MISSING_COMMITS)
121 + if (ignore_missing_commits)
264 122 return 0;
265 123 return error(_("could not parse commit %s"),
266 124 oid_to_hex(&p->object.oid));
267 125 }
268 - paint_queue_put(&state, p, flags);
126 + p->object.flags |= flags;
127 + prio_queue_put(&queue, p);
269 128 }
270 129 }
271 130
272 - clear_prio_queue(&state.queue);
273 - trace2_data_intmax("paint_down_to_common", r,
274 - "steps", steps);
131 + clear_prio_queue(&queue);
275 132 commit_list_sort_by_date(result);
276 133 return 0;
277 134 }
@@ -279,7 +136,6 @@ static int paint_down_to_common(struct repository *r,
279 136 static int merge_bases_many(struct repository *r,
280 137 struct commit *one, int n,
281 138 struct commit **twos,
282 - enum merge_base_flags mb_flags,
283 139 struct commit_list **result)
284 140 {
285 141 struct commit_list *list = NULL, **tail = result;
@@ -309,7 +165,7 @@ static int merge_bases_many(struct repository *r,
309 165 oid_to_hex(&twos[i]->object.oid));
310 166 }
311 167
312 - if (paint_down_to_common(r, one, n, twos, 0, mb_flags, &list)) {
168 + if (paint_down_to_common(r, one, n, twos, 0, 0, &list)) {
313 169 commit_list_free(list);
314 170 return -1;
315 171 }
@@ -390,8 +246,7 @@ static int remove_redundant_no_gen(struct repository *r,
390 246 min_generation = curr_generation;
391 247 }
392 248 if (paint_down_to_common(r, array[i], filled,
393 - work, min_generation,
394 - MERGE_BASE_FIND_ALL, &common)) {
249 + work, min_generation, 0, &common)) {
395 250 clear_commit_marks(array[i], all_flags);
396 251 clear_commit_marks_many(filled, work, all_flags);
397 252 commit_list_free(common);
@@ -570,7 +425,6 @@ static int get_merge_bases_many_0(struct repository *r,
570 425 size_t n,
571 426 struct commit **twos,
572 427 int cleanup,
573 - enum merge_base_flags mb_flags,
574 428 struct commit_list **result)
575 429 {
576 430 struct commit_list *list, **tail = result;
@@ -578,7 +432,7 @@ static int get_merge_bases_many_0(struct repository *r,
578 432 size_t cnt, i;
579 433 int ret;
580 434
581 - if (merge_bases_many(r, one, n, twos, mb_flags, result) < 0)
435 + if (merge_bases_many(r, one, n, twos, result) < 0)
582 436 return -1;
583 437 for (i = 0; i < n; i++) {
584 438 if (one == twos[i])
@@ -621,18 +475,16 @@ int repo_get_merge_bases_many(struct repository *r,
621 475 struct commit **twos,
622 476 struct commit_list **result)
623 477 {
624 - return get_merge_bases_many_0(r, one, n, twos, 1,
625 - MERGE_BASE_FIND_ALL, result);
478 + return get_merge_bases_many_0(r, one, n, twos, 1, result);
626 479 }
627 480
628 481 int repo_get_merge_bases_many_dirty(struct repository *r,
629 482 struct commit *one,
630 483 size_t n,
631 484 struct commit **twos,
632 - enum merge_base_flags mb_flags,
633 485 struct commit_list **result)
634 486 {
635 - return get_merge_bases_many_0(r, one, n, twos, 0, mb_flags, result);
487 + return get_merge_bases_many_0(r, one, n, twos, 0, result);
636 488 }
637 489
638 490 int repo_get_merge_bases(struct repository *r,
@@ -640,8 +492,7 @@ int repo_get_merge_bases(struct repository *r,
640 492 struct commit *two,
641 493 struct commit_list **result)
642 494 {
643 - return get_merge_bases_many_0(r, one, 1, &two, 1,
644 - MERGE_BASE_FIND_ALL, result);
495 + return get_merge_bases_many_0(r, one, 1, &two, 1, result);
645 496 }
646 497
647 498 /*
@@ -686,10 +537,6 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,
686 537 struct commit_list *bases = NULL;
687 538 int ret = 0, i;
688 539 timestamp_t generation, max_generation = GENERATION_NUMBER_ZERO;
689 - enum merge_base_flags mb_flags = MERGE_BASE_FIND_ALL;
690 -
691 - if (ignore_missing_commits)
692 - mb_flags |= MERGE_BASE_IGNORE_MISSING_COMMITS;
693 540
694 541 if (repo_parse_commit(r, commit))
695 542 return ignore_missing_commits ? 0 : -1;
@@ -708,7 +555,7 @@ int repo_in_merge_bases_many(struct repository *r, struct commit *commit,
708 555
709 556 if (paint_down_to_common(r, commit,
710 557 nr_reference, reference,
711 - generation, mb_flags, &bases))
558 + generation, ignore_missing_commits, &bases))
712 559 ret = -1;
713 560 else if (commit->object.flags & PARENT2)
714 561 ret = 1;
@@ -843,8 +690,7 @@ static int in_commit_list(const struct commit_list *want, struct commit *c)
843 690
844 691 /*
845 692 * Test whether the candidate is contained in the list.
846 - * Do not recurse to find out, though, but return CONTAINS_UNKNOWN if
847 - * inconclusive.
693 + * Do not recurse to find out, though, but return -1 if inconclusive.
848 694 */
849 695 static enum contains_result contains_test(struct commit *candidate,
850 696 const struct commit_list *want,
@@ -901,7 +747,6 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
901 747 if (result != CONTAINS_UNKNOWN)
902 748 return result;
903 749
904 - *contains_cache_at(cache, candidate) = CONTAINS_IN_PROGRESS;
905 750 push_to_contains_stack(candidate, &contains_stack);
906 751 while (contains_stack.nr) {
907 752 struct contains_stack_entry *entry = &contains_stack.contains_stack[contains_stack.nr - 1];
@@ -913,8 +758,8 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
913 758 contains_stack.nr--;
914 759 }
915 760 /*
916 - * A parent may have just been popped and marked, or may still
917 - * be active when replacement refs create a cycle.
761 + * If we just popped the stack, parents->item has been marked,
762 + * therefore contains_test will return a meaningful yes/no.
918 763 */
919 764 else switch (contains_test(parents->item, want, cache, cutoff)) {
920 765 case CONTAINS_YES:
@@ -924,11 +769,7 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
924 769 case CONTAINS_NO:
925 770 entry->parents = parents->next;
926 771 break;
927 - case CONTAINS_IN_PROGRESS:
928 - die(_("commit ancestry contains a cycle"));
929 772 case CONTAINS_UNKNOWN:
930 - *contains_cache_at(cache, parents->item) =
931 - CONTAINS_IN_PROGRESS;
932 773 push_to_contains_stack(parents->item, &contains_stack);
933 774 break;
934 775 }
@@ -940,16 +781,9 @@ static enum contains_result contains_tag_algo(struct commit *candidate,
940 781 int commit_contains(struct ref_filter *filter, struct commit *commit,
941 782 struct commit_list *list, struct contains_cache *cache)
942 783 {
943 - int result;
944 -
945 - if (filter->with_commit_tag_algo ||
946 - generation_numbers_enabled(the_repository))
784 + if (filter->with_commit_tag_algo)
947 785 return contains_tag_algo(commit, list, cache) == CONTAINS_YES;
948 -
949 - result = repo_is_descendant_of(the_repository, commit, list);
950 - if (result < 0)
951 - die(_("failed to check reachability"));
952 - return result;
786 + return repo_is_descendant_of(the_repository, commit, list);
953 787 }
954 788
955 789 int can_all_from_reach_with_flag(struct object_array *from,
@@ -1188,11 +1022,11 @@ struct commit_list *get_reachable_subset(struct commit **from, size_t nr_from,
1188 1022 define_commit_slab(bit_arrays, struct bitmap *);
1189 1023 static struct bit_arrays bit_arrays;
1190 1024
1191 - static void insert_no_dup(struct nonstale_queue *queue, struct commit *c)
1025 + static void insert_no_dup(struct prio_queue *queue, struct commit *c)
1192 1026 {
1193 1027 if (c->object.flags & PARENT2)
1194 1028 return;
1195 - nonstale_queue_put(queue, c);
1029 + prio_queue_put(queue, c);
1196 1030 c->object.flags |= PARENT2;
1197 1031 }
1198 1032
@@ -1217,10 +1051,7 @@ void ahead_behind(struct repository *r,
1217 1051 struct commit **commits, size_t commits_nr,
1218 1052 struct ahead_behind_count *counts, size_t counts_nr)
1219 1053 {
1220 - struct nonstale_queue queue = {
1221 - { .compare = compare_commits_by_gen_then_commit_date }
1222 - };
1223 - void *entry;
1054 + struct prio_queue queue = { .compare = compare_commits_by_gen_then_commit_date };
1224 1055 size_t width = DIV_ROUND_UP(commits_nr, BITS_IN_EWORD);
1225 1056
1226 1057 if (!commits_nr || !counts_nr)
@@ -1243,8 +1074,8 @@ void ahead_behind(struct repository *r,
1243 1074 insert_no_dup(&queue, c);
1244 1075 }
1245 1076
1246 - while (queue.max_nonstale) {
1247 - struct commit *c = nonstale_queue_get(&queue);
1077 + while (queue_has_nonstale(&queue)) {
1078 + struct commit *c = prio_queue_get(&queue);
1248 1079 struct commit_list *p;
1249 1080 struct bitmap *bitmap_c = get_bit_array(c, width);
1250 1081
@@ -1286,14 +1117,15 @@ void ahead_behind(struct repository *r,
1286 1117
1287 1118 /* STALE is used here, PARENT2 is used by insert_no_dup(). */
1288 1119 repo_clear_commit_marks(r, PARENT2 | STALE);
1289 - prio_queue_for_each(&queue.pq, entry)
1290 - free_bit_array(entry);
1120 + for (size_t i = 0; i < queue.nr; i++)
1121 + free_bit_array(queue.array[i].data);
1291 1122 clear_bit_arrays(&bit_arrays);
1292 - clear_nonstale_queue(&queue);
1123 + clear_prio_queue(&queue);
1293 1124 }
1294 1125
1295 1126 struct commit_and_index {
1296 1127 struct commit *commit;
1128 + unsigned int index;
1297 1129 timestamp_t generation;
1298 1130 };
1299 1131
@@ -1333,6 +1165,7 @@ void tips_reachable_from_bases(struct repository *r,
1333 1165
1334 1166 for (size_t i = 0; i < tips_nr; i++) {
1335 1167 commits[i].commit = tips[i];
1168 + commits[i].index = i;
1336 1169 commits[i].generation = commit_graph_generation(tips[i]);
1337 1170 }
1338 1171
@@ -1340,9 +1173,6 @@ void tips_reachable_from_bases(struct repository *r,
1340 1173 QSORT(commits, tips_nr, compare_commit_and_index_by_generation);
1341 1174 min_generation = commits[0].generation;
1342 1175
1343 - for (size_t i = 0; i < tips_nr; i++)
1344 - commits[i].commit->object.flags |= RESULT;
1345 -
1346 1176 while (bases) {
1347 1177 repo_parse_commit(r, bases->item);
1348 1178 commit_list_insert(bases->item, &stack);
@@ -1353,16 +1183,20 @@ void tips_reachable_from_bases(struct repository *r,
1353 1183 int explored_all_parents = 1;
1354 1184 struct commit_list *p;
1355 1185 struct commit *c = stack->item;
1186 + timestamp_t c_gen = commit_graph_generation(c);
1356 1187
1357 1188 /* Does it match any of our tips? */
1358 - {
1359 - if (c->object.flags & RESULT) {
1360 - c->object.flags |= mark;
1189 + for (size_t j = min_generation_index; j < tips_nr; j++) {
1190 + if (c_gen < commits[j].generation)
1191 + break;
1192 +
1193 + if (commits[j].commit == c) {
1194 + tips[commits[j].index]->object.flags |= mark;
1361 1195
1362 - if (commits[min_generation_index].commit->object.flags & mark) {
1363 - unsigned int k = min_generation_index + 1;
1196 + if (j == min_generation_index) {
1197 + unsigned int k = j + 1;
1364 1198 while (k < tips_nr &&
1365 - (commits[k].commit->object.flags & mark))
1199 + (tips[commits[k].index]->object.flags & mark))
1366 1200 k++;
1367 1201
1368 1202 /* Terminate early if all found. */
@@ -1398,8 +1232,6 @@ void tips_reachable_from_bases(struct repository *r,
1398 1232 }
1399 1233
1400 1234 done:
1401 - for (size_t i = 0; i < tips_nr; i++)
1402 - commits[i].commit->object.flags &= ~RESULT;
1403 1235 free(commits);
1404 1236 repo_clear_commit_marks(r, SEEN);
1405 1237 commit_list_free(stack);
@@ -1420,7 +1252,7 @@ int get_branch_base_for_tip(struct repository *r,
1420 1252 size_t bases_nr)
1421 1253 {
1422 1254 int best_index = -1;
1423 - struct commit *c, *branch_point = NULL;
1255 + struct commit *branch_point = NULL;
1424 1256 struct prio_queue queue = { compare_commits_by_gen_then_commit_date };
1425 1257 int found_missing_gen = 0;
1426 1258
@@ -1473,7 +1305,8 @@ int get_branch_base_for_tip(struct repository *r,
1473 1305 prio_queue_put(&queue, c);
1474 1306 }
1475 1307
1476 - while ((c = prio_queue_get(&queue))) {
1308 + while (queue.nr) {
1309 + struct commit *c = prio_queue_get(&queue);
1477 1310 int best_for_c = get_best(c);
1478 1311 int best_for_p, positive;
1479 1312 struct commit *parent;
modified commit-reach.h
@@ -17,20 +17,10 @@ int repo_get_merge_bases_many(struct repository *r,
17 17 struct commit *one, size_t n,
18 18 struct commit **twos,
19 19 struct commit_list **result);
20 - enum merge_base_flags {
21 - MERGE_BASE_IGNORE_MISSING_COMMITS = (1 << 0),
22 - MERGE_BASE_FIND_ALL = (1 << 1),
23 - };
24 -
25 - /*
26 - * To be used only when object flags after this call no longer matter.
27 - * Without MERGE_BASE_FIND_ALL and with generation numbers available,
28 - * returns after finding the first merge-base, skipping the STALE drain.
29 - */
20 + /* To be used only when object flags after this call no longer matter */
30 21 int repo_get_merge_bases_many_dirty(struct repository *r,
31 22 struct commit *one, size_t n,
32 23 struct commit **twos,
33 - enum merge_base_flags mb_flags,
34 24 struct commit_list **result);
35 25
36 26 int get_octopus_merge_bases(struct commit_list *in, struct commit_list **result);
@@ -73,8 +63,7 @@ int ref_newer(const struct object_id *new_oid, const struct object_id *old_oid);
73 63 enum contains_result {
74 64 CONTAINS_UNKNOWN = 0,
75 65 CONTAINS_NO,
76 - CONTAINS_YES,
77 - CONTAINS_IN_PROGRESS
66 + CONTAINS_YES
78 67 };
79 68
80 69 define_commit_slab(contains_cache, enum contains_result);
modified commit.c
@@ -395,7 +395,7 @@ const void *repo_get_commit_buffer(struct repository *r,
395 395 const void *ret = get_cached_commit_buffer(r, commit, sizep);
396 396 if (!ret) {
397 397 enum object_type type;
398 - size_t size;
398 + unsigned long size;
399 399 ret = odb_read_object(r->objects, &commit->object.oid, &type, &size);
400 400 if (!ret)
401 401 die("cannot read commit object %s",
@@ -404,7 +404,7 @@ const void *repo_get_commit_buffer(struct repository *r,
404 404 die("expected commit for %s, got %s",
405 405 oid_to_hex(&commit->object.oid), type_name(type));
406 406 if (sizep)
407 - *sizep = cast_size_t_to_ulong(size);
407 + *sizep = size;
408 408 }
409 409 return ret;
410 410 }
@@ -434,27 +434,6 @@ static inline void set_commit_tree(struct commit *c, struct tree *t)
434 434 c->maybe_tree = t;
435 435 }
436 436
437 - static void load_tree_from_commit_contents(struct repository *r, struct commit *commit)
438 - {
439 - enum object_type type;
440 - size_t size;
441 - char *buf;
442 - const char *p;
443 - struct object_id tree_oid;
444 -
445 - buf = odb_read_object(r->objects, &commit->object.oid, &type, &size);
446 - if (!buf)
447 - return;
448 -
449 - if (type == OBJ_COMMIT &&
450 - skip_prefix(buf, "tree ", &p) &&
451 - !parse_oid_hex_algop(p, &tree_oid, &p, r->hash_algo) &&
452 - *p == '\n')
453 - set_commit_tree(commit, lookup_tree(r, &tree_oid));
454 -
455 - free(buf);
456 - }
457 -
458 437 struct tree *repo_get_commit_tree(struct repository *r,
459 438 const struct commit *commit)
460 439 {
@@ -464,17 +443,7 @@ struct tree *repo_get_commit_tree(struct repository *r,
464 443 if (commit_graph_position(commit) != COMMIT_NOT_FROM_GRAPH)
465 444 return get_commit_tree_in_graph(r, commit);
466 445
467 - /*
468 - * This is either a corrupt commit, or one which we partially loaded
469 - * from a graph file but then subsequently threw away the graph data.
470 - *
471 - * Optimistically assume it's the latter and try to reload from
472 - * scratch. This gives a performance penalty if it really is a corrupt
473 - * commit, but presumably that happens rarely (and only once per
474 - * process).
475 - */
476 - load_tree_from_commit_contents(r, (struct commit *)commit);
477 - return commit->maybe_tree;
446 + return NULL;
478 447 }
479 448
480 449 struct object_id *get_commit_tree_oid(const struct commit *commit)
@@ -604,7 +573,7 @@ int repo_parse_commit_internal(struct repository *r,
604 573 {
605 574 enum object_type type;
606 575 void *buffer;
607 - size_t size;
576 + unsigned long size;
608 577 struct object_info oi = {
609 578 .typep = &type,
610 579 .sizep = &size,
@@ -760,6 +729,19 @@ void commit_list_free(struct commit_list *list)
760 729 pop_commit(&list);
761 730 }
762 731
732 + struct commit_list * commit_list_insert_by_date(struct commit *item, struct commit_list **list)
733 + {
734 + struct commit_list **pp = list;
735 + struct commit_list *p;
736 + while ((p = *pp) != NULL) {
737 + if (p->item->date < item->date) {
738 + break;
739 + }
740 + pp = &p->next;
741 + }
742 + return commit_list_insert(item, pp);
743 + }
744 +
763 745 static int commit_list_compare_by_date(const struct commit_list *a,
764 746 const struct commit_list *b)
765 747 {
@@ -782,17 +764,24 @@ void commit_list_sort_by_date(struct commit_list **list)
782 764 struct commit *pop_most_recent_commit(struct prio_queue *queue,
783 765 unsigned int mark)
784 766 {
785 - struct commit *ret = prio_queue_get(queue);
767 + struct commit *ret = prio_queue_peek(queue);
768 + int get_pending = 1;
786 769 struct commit_list *parents = ret->parents;
787 770
788 771 while (parents) {
789 772 struct commit *commit = parents->item;
790 773 if (!repo_parse_commit(the_repository, commit) && !(commit->object.flags & mark)) {
791 774 commit->object.flags |= mark;
792 - prio_queue_put(queue, commit);
775 + if (get_pending)
776 + prio_queue_replace(queue, commit);
777 + else
778 + prio_queue_put(queue, commit);
779 + get_pending = 0;
793 780 }
794 781 parents = parents->next;
795 782 }
783 + if (get_pending)
784 + prio_queue_get(queue);
796 785 return ret;
797 786 }
798 787
@@ -1293,7 +1282,7 @@ static void handle_signed_tag(const struct commit *parent, struct commit_extra_h
1293 1282 struct merge_remote_desc *desc;
1294 1283 struct commit_extra_header *mergetag;
1295 1284 char *buf;
1296 - size_t size;
1285 + unsigned long size;
1297 1286 enum object_type type;
1298 1287 struct strbuf payload = STRBUF_INIT;
1299 1288 struct strbuf signature = STRBUF_INIT;
@@ -1569,16 +1558,16 @@ int commit_tree(const char *msg, size_t msg_len, const struct object_id *tree,
1569 1558 return result;
1570 1559 }
1571 1560
1572 - static bool has_invalid_utf8(const char *buf, size_t len, size_t *bad_offset)
1561 + static int find_invalid_utf8(const char *buf, int len)
1573 1562 {
1574 - size_t offset = 0;
1563 + int offset = 0;
1575 1564 static const unsigned int max_codepoint[] = {
1576 1565 0x7f, 0x7ff, 0xffff, 0x10ffff
1577 1566 };
1578 1567
1579 1568 while (len) {
1580 1569 unsigned char c = *buf++;
1581 - unsigned bytes;
1570 + int bytes, bad_offset;
1582 1571 unsigned int codepoint;
1583 1572 unsigned int min_val, max_val;
1584 1573
@@ -1589,7 +1578,7 @@ static bool has_invalid_utf8(const char *buf, size_t len, size_t *bad_offset)
1589 1578 if (c < 0x80)
1590 1579 continue;
1591 1580
1592 - *bad_offset = offset-1;
1581 + bad_offset = offset-1;
1593 1582
1594 1583 /*
1595 1584 * Count how many more high bits set: that's how
@@ -1606,11 +1595,11 @@ static bool has_invalid_utf8(const char *buf, size_t len, size_t *bad_offset)
1606 1595 * codepoints beyond U+10FFFF, which are guaranteed never to exist.
1607 1596 */
1608 1597 if (bytes < 1 || 3 < bytes)
1609 - return true;
1598 + return bad_offset;
1610 1599
1611 1600 /* Do we *have* that many bytes? */
1612 1601 if (len < bytes)
1613 - return true;
1602 + return bad_offset;
1614 1603
1615 1604 /*
1616 1605 * Place the encoded bits at the bottom of the value and compute the
@@ -1628,42 +1617,43 @@ static bool has_invalid_utf8(const char *buf, size_t len, size_t *bad_offset)
1628 1617 codepoint <<= 6;
1629 1618 codepoint |= *buf & 0x3f;
1630 1619 if ((*buf++ & 0xc0) != 0x80)
1631 - return true;
1620 + return bad_offset;
1632 1621 } while (--bytes);
1633 1622
1634 1623 /* Reject codepoints that are out of range for the sequence length. */
1635 1624 if (codepoint < min_val || codepoint > max_val)
1636 - return true;
1625 + return bad_offset;
1637 1626 /* Surrogates are only for UTF-16 and cannot be encoded in UTF-8. */
1638 1627 if ((codepoint & 0x1ff800) == 0xd800)
1639 - return true;
1628 + return bad_offset;
1640 1629 /* U+xxFFFE and U+xxFFFF are guaranteed non-characters. */
1641 1630 if ((codepoint & 0xfffe) == 0xfffe)
1642 - return true;
1631 + return bad_offset;
1643 1632 /* So are anything in the range U+FDD0..U+FDEF. */
1644 1633 if (codepoint >= 0xfdd0 && codepoint <= 0xfdef)
1645 - return true;
1634 + return bad_offset;
1646 1635 }
1647 - return false;
1636 + return -1;
1648 1637 }
1649 1638
1650 1639 /*
1651 - * This ensures that the buffer is in proper utf8 format.
1640 + * This verifies that the buffer is in proper utf8 format.
1652 1641 *
1653 1642 * If it isn't, it assumes any non-utf8 characters are Latin1,
1654 1643 * and does the conversion.
1655 1644 */
1656 - static int ensure_utf8(struct strbuf *buf)
1645 + static int verify_utf8(struct strbuf *buf)
1657 1646 {
1658 1647 int ok = 1;
1659 - size_t pos = 0;
1648 + long pos = 0;
1660 1649
1661 1650 for (;;) {
1662 - size_t bad;
1651 + int bad;
1663 1652 unsigned char c;
1664 1653 unsigned char replace[2];
1665 1654
1666 - if (!has_invalid_utf8(buf->buf + pos, buf->len - pos, &bad))
1655 + bad = find_invalid_utf8(buf->buf + pos, buf->len - pos);
1656 + if (bad < 0)
1667 1657 return ok;
1668 1658 pos += bad;
1669 1659 ok = 0;
@@ -1736,7 +1726,6 @@ int commit_tree_extended(const char *msg, size_t msg_len,
1736 1726 struct repository *r = the_repository;
1737 1727 int result = 0;
1738 1728 int encoding_is_utf8;
1739 - bool warned = false;
1740 1729 struct strbuf buffer = STRBUF_INIT, compat_buffer = STRBUF_INIT;
1741 1730 struct strbuf sig = STRBUF_INIT, compat_sig = STRBUF_INIT;
1742 1731 struct object_id *parent_buf = NULL, *compat_oid = NULL;
@@ -1758,13 +1747,6 @@ int commit_tree_extended(const char *msg, size_t msg_len,
1758 1747 oidcpy(&parent_buf[i++], &p->item->object.oid);
1759 1748
1760 1749 write_commit_tree(&buffer, msg, msg_len, tree, parent_buf, nparents, author, committer, extra);
1761 -
1762 - /* And check the encoding. */
1763 - if (encoding_is_utf8 && !ensure_utf8(&buffer)) {
1764 - fprintf(stderr, _(commit_utf8_warn));
1765 - warned = true;
1766 - }
1767 -
1768 1750 if (sign_commit && sign_buffer(&buffer, &sig, sign_commit,
1769 1751 SIGN_BUFFER_USE_DEFAULT_KEY)) {
1770 1752 result = -1;
@@ -1798,9 +1780,6 @@ int commit_tree_extended(const char *msg, size_t msg_len,
1798 1780 free_commit_extra_headers(compat_extra);
1799 1781 free(mapped_parents);
1800 1782
1801 - if (encoding_is_utf8 && !ensure_utf8(&compat_buffer) && !warned)
1802 - fprintf(stderr, _(commit_utf8_warn));
1803 -
1804 1783 if (sign_commit && sign_buffer(&compat_buffer, &compat_sig,
1805 1784 sign_commit,
1806 1785 SIGN_BUFFER_USE_DEFAULT_KEY)) {
@@ -1839,6 +1818,10 @@ int commit_tree_extended(const char *msg, size_t msg_len,
1839 1818 }
1840 1819 }
1841 1820
1821 + /* And check the encoding. */
1822 + if (encoding_is_utf8 && (!verify_utf8(&buffer) || !verify_utf8(&compat_buffer)))
1823 + fprintf(stderr, _(commit_utf8_warn));
1824 +
1842 1825 if (r->compat_hash_algo) {
1843 1826 hash_object_file(r->compat_hash_algo, compat_buffer.buf, compat_buffer.len,
1844 1827 OBJ_COMMIT, &compat_oid_buf);
@@ -1987,7 +1970,7 @@ size_t ignored_log_message_bytes(const char *buf, size_t len)
1987 1970 int run_commit_hook(int editor_is_used, const char *index_file,
1988 1971 int *invoked_hook, const char *name, ...)
1989 1972 {
1990 - struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT_FORCE_SERIAL;
1973 + struct run_hooks_opt opt = RUN_HOOKS_OPT_INIT;
1991 1974 va_list args;
1992 1975 const char *arg;
1993 1976
modified commit.h
@@ -191,6 +191,8 @@ int commit_list_contains(struct commit *item,
191 191 struct commit_list **commit_list_append(struct commit *commit,
192 192 struct commit_list **next);
193 193 unsigned commit_list_count(const struct commit_list *l);
194 + struct commit_list *commit_list_insert_by_date(struct commit *item,
195 + struct commit_list **list);
194 196 void commit_list_sort_by_date(struct commit_list **list);
195 197
196 198 /* Shallow copy of the input list */
@@ -201,6 +203,25 @@ struct commit_list *commit_list_reverse(struct commit_list *list);
201 203
202 204 void commit_list_free(struct commit_list *list);
203 205
206 + /*
207 + * Deprecated compatibility functions for `struct commit_list`, to be removed
208 + * once Git 2.53 is released.
209 + */
210 + static inline struct commit_list *copy_commit_list(struct commit_list *l)
211 + {
212 + return commit_list_copy(l);
213 + }
214 +
215 + static inline struct commit_list *reverse_commit_list(struct commit_list *l)
216 + {
217 + return commit_list_reverse(l);
218 + }
219 +
220 + static inline void free_commit_list(struct commit_list *l)
221 + {
222 + commit_list_free(l);
223 + }
224 +
204 225 struct rev_info; /* in revision.h, it circularly uses enum cmit_fmt */
205 226
206 227 const char *repo_logmsg_reencode(struct repository *r,
modified common-init.c
@@ -5,10 +5,7 @@
5 5 #include "exec-cmd.h"
6 6 #include "gettext.h"
7 7 #include "attr.h"
8 - #include "odb.h"
9 - #include "parse.h"
10 8 #include "repository.h"
11 - #include "replace-object.h"
12 9 #include "setup.h"
13 10 #include "strbuf.h"
14 11 #include "trace2.h"
@@ -34,22 +31,6 @@ static void restore_sigpipe_to_default(void)
34 31 signal(SIGPIPE, SIG_DFL);
35 32 }
36 33
37 - static void setup_environment(void)
38 - {
39 - char *git_replace_ref_base;
40 - const char *replace_ref_base;
41 -
42 - if (getenv(NO_REPLACE_OBJECTS_ENVIRONMENT))
43 - disable_replace_refs();
44 - replace_ref_base = getenv(GIT_REPLACE_REF_BASE_ENVIRONMENT);
45 - git_replace_ref_base = xstrdup(replace_ref_base ? replace_ref_base
46 - : "refs/replace/");
47 - update_ref_namespace(NAMESPACE_REPLACE, git_replace_ref_base);
48 -
49 - if (git_env_bool(NO_LAZY_FETCH_ENVIRONMENT, 0))
50 - the_repository->fetch_if_missing = 0;
51 - }
52 -
53 34 void init_git(const char **argv)
54 35 {
55 36 struct strbuf tmp = STRBUF_INIT;
@@ -70,7 +51,6 @@ void init_git(const char **argv)
70 51 git_setup_gettext();
71 52
72 53 initialize_repository(the_repository);
73 - setup_environment();
74 54
75 55 attr_start();
76 56
deleted compat/fsmonitor/fsm-health-linux.c mode 100644
@@ -1,33 +0,0 @@
1 - #include "git-compat-util.h"
2 - #include "config.h"
3 - #include "fsmonitor-ll.h"
4 - #include "fsm-health.h"
5 - #include "fsmonitor--daemon.h"
6 -
7 - /*
8 - * The Linux fsmonitor implementation uses inotify which has its own
9 - * mechanisms for detecting filesystem unmount and other events that
10 - * would require the daemon to shutdown. Therefore, we don't need
11 - * a separate health thread like Windows does.
12 - *
13 - * These stub functions satisfy the interface requirements.
14 - */
15 -
16 - int fsm_health__ctor(struct fsmonitor_daemon_state *state UNUSED)
17 - {
18 - return 0;
19 - }
20 -
21 - void fsm_health__dtor(struct fsmonitor_daemon_state *state UNUSED)
22 - {
23 - return;
24 - }
25 -
26 - void fsm_health__loop(struct fsmonitor_daemon_state *state UNUSED)
27 - {
28 - return;
29 - }
30 -
31 - void fsm_health__stop_async(struct fsmonitor_daemon_state *state UNUSED)
32 - {
33 - }
renamed 100% compat/fsmonitor/fsm-ipc-unix.c โ†’ compat/fsmonitor/fsm-ipc-darwin.c

No content changes.

deleted compat/fsmonitor/fsm-listen-linux.c mode 100644
@@ -1,746 +0,0 @@
1 - #include "git-compat-util.h"
2 - #include "dir.h"
3 - #include "fsmonitor-ll.h"
4 - #include "fsm-listen.h"
5 - #include "fsmonitor--daemon.h"
6 - #include "fsmonitor-path-utils.h"
7 - #include "gettext.h"
8 - #include "simple-ipc.h"
9 - #include "string-list.h"
10 - #include "trace.h"
11 -
12 - #include <sys/inotify.h>
13 -
14 - /*
15 - * Safe value to bitwise OR with rest of mask for
16 - * kernels that do not support IN_MASK_CREATE
17 - */
18 - #ifndef IN_MASK_CREATE
19 - #define IN_MASK_CREATE 0x00000000
20 - #endif
21 -
22 - enum shutdown_reason {
23 - SHUTDOWN_CONTINUE = 0,
24 - SHUTDOWN_STOP,
25 - SHUTDOWN_ERROR,
26 - SHUTDOWN_FORCE
27 - };
28 -
29 - struct watch_entry {
30 - struct hashmap_entry ent;
31 - int wd;
32 - uint32_t cookie;
33 - const char *dir;
34 - };
35 -
36 - struct rename_entry {
37 - struct hashmap_entry ent;
38 - time_t whence;
39 - uint32_t cookie;
40 - const char *dir;
41 - };
42 -
43 - struct fsm_listen_data {
44 - int fd_inotify;
45 - enum shutdown_reason shutdown;
46 - struct hashmap watches;
47 - struct hashmap renames;
48 - struct hashmap revwatches;
49 - };
50 -
51 - static int watch_entry_cmp(const void *cmp_data UNUSED,
52 - const struct hashmap_entry *eptr,
53 - const struct hashmap_entry *entry_or_key,
54 - const void *keydata UNUSED)
55 - {
56 - const struct watch_entry *e1, *e2;
57 -
58 - e1 = container_of(eptr, const struct watch_entry, ent);
59 - e2 = container_of(entry_or_key, const struct watch_entry, ent);
60 - return e1->wd != e2->wd;
61 - }
62 -
63 - static int revwatches_entry_cmp(const void *cmp_data UNUSED,
64 - const struct hashmap_entry *eptr,
65 - const struct hashmap_entry *entry_or_key,
66 - const void *keydata UNUSED)
67 - {
68 - const struct watch_entry *e1, *e2;
69 -
70 - e1 = container_of(eptr, const struct watch_entry, ent);
71 - e2 = container_of(entry_or_key, const struct watch_entry, ent);
72 - return strcmp(e1->dir, e2->dir);
73 - }
74 -
75 - static int rename_entry_cmp(const void *cmp_data UNUSED,
76 - const struct hashmap_entry *eptr,
77 - const struct hashmap_entry *entry_or_key,
78 - const void *keydata UNUSED)
79 - {
80 - const struct rename_entry *e1, *e2;
81 -
82 - e1 = container_of(eptr, const struct rename_entry, ent);
83 - e2 = container_of(entry_or_key, const struct rename_entry, ent);
84 - return e1->cookie != e2->cookie;
85 - }
86 -
87 - /*
88 - * Register an inotify watch, add watch descriptor to path mapping
89 - * and the reverse mapping.
90 - */
91 - static int add_watch(const char *path, struct fsm_listen_data *data)
92 - {
93 - const char *interned = strintern(path);
94 - struct watch_entry *w1, *w2;
95 -
96 - /* add the inotify watch, don't allow watches to be modified */
97 - int wd = inotify_add_watch(data->fd_inotify, interned,
98 - (IN_ALL_EVENTS | IN_ONLYDIR | IN_MASK_CREATE)
99 - ^ IN_ACCESS ^ IN_CLOSE ^ IN_OPEN);
100 - if (wd < 0) {
101 - if (errno == ENOENT || errno == ENOTDIR)
102 - return 0; /* directory was deleted or is not a directory */
103 - if (errno == EEXIST)
104 - return 0; /* watch already exists, no action needed */
105 - if (errno == ENOSPC)
106 - return error(_("inotify watch limit reached; "
107 - "increase fs.inotify.max_user_watches"));
108 - return error_errno(_("inotify_add_watch('%s') failed"), interned);
109 - }
110 -
111 - /* add watch descriptor -> directory mapping */
112 - CALLOC_ARRAY(w1, 1);
113 - w1->wd = wd;
114 - w1->dir = interned;
115 - hashmap_entry_init(&w1->ent, memhash(&w1->wd, sizeof(int)));
116 - hashmap_add(&data->watches, &w1->ent);
117 -
118 - /* add directory -> watch descriptor mapping */
119 - CALLOC_ARRAY(w2, 1);
120 - w2->wd = wd;
121 - w2->dir = interned;
122 - hashmap_entry_init(&w2->ent, strhash(w2->dir));
123 - hashmap_add(&data->revwatches, &w2->ent);
124 -
125 - return 0;
126 - }
127 -
128 - /*
129 - * Remove the inotify watch, the watch descriptor to path mapping
130 - * and the reverse mapping.
131 - */
132 - static void remove_watch(struct watch_entry *w, struct fsm_listen_data *data)
133 - {
134 - struct watch_entry k1, k2, *w1, *w2;
135 -
136 - /* remove watch, ignore error if kernel already did it */
137 - if (inotify_rm_watch(data->fd_inotify, w->wd) && errno != EINVAL)
138 - error_errno(_("inotify_rm_watch() failed"));
139 -
140 - k1.wd = w->wd;
141 - hashmap_entry_init(&k1.ent, memhash(&k1.wd, sizeof(int)));
142 - w1 = hashmap_remove_entry(&data->watches, &k1, ent, NULL);
143 - if (!w1)
144 - BUG("double remove of watch for '%s'", w->dir);
145 -
146 - if (w1->cookie)
147 - BUG("removing watch for '%s' which has a pending rename", w1->dir);
148 -
149 - k2.dir = w->dir;
150 - hashmap_entry_init(&k2.ent, strhash(k2.dir));
151 - w2 = hashmap_remove_entry(&data->revwatches, &k2, ent, NULL);
152 - if (!w2)
153 - BUG("double remove of reverse watch for '%s'", w->dir);
154 -
155 - /* w1->dir and w2->dir are interned strings, we don't own them */
156 - free(w1);
157 - free(w2);
158 - }
159 -
160 - /*
161 - * Check for stale directory renames.
162 - *
163 - * https://man7.org/linux/man-pages/man7/inotify.7.html
164 - *
165 - * Allow for some small timeout to account for the fact that insertion of the
166 - * IN_MOVED_FROM+IN_MOVED_TO event pair is not atomic, and the possibility that
167 - * there may not be any IN_MOVED_TO event.
168 - *
169 - * If the IN_MOVED_TO event is not received within the timeout then events have
170 - * been missed and the monitor is in an inconsistent state with respect to the
171 - * filesystem.
172 - */
173 - static int check_stale_dir_renames(struct hashmap *renames, time_t max_age)
174 - {
175 - struct rename_entry *re;
176 - struct hashmap_iter iter;
177 -
178 - hashmap_for_each_entry(renames, &iter, re, ent) {
179 - if (re->whence <= max_age)
180 - return -1;
181 - }
182 - return 0;
183 - }
184 -
185 - /*
186 - * Track pending renames.
187 - *
188 - * Tracking is done via an event cookie to watch descriptor mapping.
189 - *
190 - * A rename is not complete until matching an IN_MOVED_TO event is received
191 - * for a corresponding IN_MOVED_FROM event.
192 - */
193 - static void add_dir_rename(uint32_t cookie, const char *path,
194 - struct fsm_listen_data *data)
195 - {
196 - struct watch_entry k, *w;
197 - struct rename_entry *re;
198 -
199 - /* lookup the watch descriptor for the given path */
200 - k.dir = path;
201 - hashmap_entry_init(&k.ent, strhash(path));
202 - w = hashmap_get_entry(&data->revwatches, &k, ent, NULL);
203 - if (!w) {
204 - /*
205 - * This can happen in rare cases where the directory was
206 - * moved before we had a chance to add a watch on it.
207 - * Just ignore this rename.
208 - */
209 - trace_printf_key(&trace_fsmonitor,
210 - "no watch found for rename from '%s'", path);
211 - return;
212 - }
213 - w->cookie = cookie;
214 -
215 - /* add the pending rename to match against later */
216 - CALLOC_ARRAY(re, 1);
217 - re->dir = w->dir;
218 - re->cookie = w->cookie;
219 - re->whence = time(NULL);
220 - hashmap_entry_init(&re->ent, memhash(&re->cookie, sizeof(uint32_t)));
221 - hashmap_add(&data->renames, &re->ent);
222 - }
223 -
224 - /*
225 - * Handle directory renames
226 - *
227 - * Once an IN_MOVED_TO event is received, lookup the rename tracking information
228 - * via the event cookie and use this information to update the watch.
229 - */
230 - static void rename_dir(uint32_t cookie, const char *path,
231 - struct fsm_listen_data *data)
232 - {
233 - struct rename_entry rek, *re;
234 - struct watch_entry k, *w;
235 -
236 - /* lookup a pending rename to match */
237 - rek.cookie = cookie;
238 - hashmap_entry_init(&rek.ent, memhash(&rek.cookie, sizeof(uint32_t)));
239 - re = hashmap_get_entry(&data->renames, &rek, ent, NULL);
240 - if (re) {
241 - k.dir = re->dir;
242 - hashmap_entry_init(&k.ent, strhash(k.dir));
243 - w = hashmap_get_entry(&data->revwatches, &k, ent, NULL);
244 - if (w) {
245 - w->cookie = 0; /* rename handled */
246 - remove_watch(w, data);
247 - if (add_watch(path, data))
248 - trace_printf_key(&trace_fsmonitor,
249 - "failed to add watch for renamed dir '%s'",
250 - path);
251 - } else {
252 - /* Directory was moved out of watch tree */
253 - trace_printf_key(&trace_fsmonitor,
254 - "no matching watch for rename to '%s'", path);
255 - }
256 - hashmap_remove_entry(&data->renames, &rek, ent, NULL);
257 - free(re);
258 - } else {
259 - /* Directory was moved from outside the watch tree */
260 - trace_printf_key(&trace_fsmonitor,
261 - "no matching cookie for rename to '%s'", path);
262 - }
263 - }
264 -
265 - /*
266 - * Recursively add watches to every directory under path
267 - */
268 - static int register_inotify(const char *path,
269 - struct fsmonitor_daemon_state *state,
270 - struct fsmonitor_batch *batch)
271 - {
272 - DIR *dir;
273 - const char *rel;
274 - struct strbuf current = STRBUF_INIT;
275 - struct dirent *de;
276 - struct stat fs;
277 - int ret = -1;
278 -
279 - dir = opendir(path);
280 - if (!dir) {
281 - if (errno == ENOENT || errno == ENOTDIR)
282 - return 0; /* directory was deleted */
283 - return error_errno(_("opendir('%s') failed"), path);
284 - }
285 -
286 - while ((de = readdir_skip_dot_and_dotdot(dir)) != NULL) {
287 - strbuf_reset(&current);
288 - strbuf_addf(&current, "%s/%s", path, de->d_name);
289 - if (lstat(current.buf, &fs)) {
290 - if (errno == ENOENT)
291 - continue; /* file was deleted */
292 - error_errno(_("lstat('%s') failed"), current.buf);
293 - goto failed;
294 - }
295 -
296 - /* recurse into directory */
297 - if (S_ISDIR(fs.st_mode)) {
298 - if (add_watch(current.buf, state->listen_data))
299 - goto failed;
300 - if (register_inotify(current.buf, state, batch))
301 - goto failed;
302 - } else if (batch) {
303 - rel = current.buf + state->path_worktree_watch.len + 1;
304 - trace_printf_key(&trace_fsmonitor, "explicitly adding '%s'", rel);
305 - fsmonitor_batch__add_path(batch, rel);
306 - }
307 - }
308 - ret = 0;
309 -
310 - failed:
311 - strbuf_release(&current);
312 - if (closedir(dir) < 0)
313 - return error_errno(_("closedir('%s') failed"), path);
314 - return ret;
315 - }
316 -
317 - static int em_rename_dir_from(uint32_t mask)
318 - {
319 - return ((mask & IN_ISDIR) && (mask & IN_MOVED_FROM));
320 - }
321 -
322 - static int em_rename_dir_to(uint32_t mask)
323 - {
324 - return ((mask & IN_ISDIR) && (mask & IN_MOVED_TO));
325 - }
326 -
327 - static int em_remove_watch(uint32_t mask)
328 - {
329 - return (mask & IN_DELETE_SELF);
330 - }
331 -
332 - static int em_dir_renamed(uint32_t mask)
333 - {
334 - return ((mask & IN_ISDIR) && (mask & IN_MOVE));
335 - }
336 -
337 - static int em_dir_created(uint32_t mask)
338 - {
339 - return ((mask & IN_ISDIR) && (mask & IN_CREATE));
340 - }
341 -
342 - static int em_dir_deleted(uint32_t mask)
343 - {
344 - return ((mask & IN_ISDIR) && (mask & IN_DELETE));
345 - }
346 -
347 - static int em_force_shutdown(uint32_t mask)
348 - {
349 - return (mask & IN_UNMOUNT) || (mask & IN_Q_OVERFLOW);
350 - }
351 -
352 - static int em_ignore(uint32_t mask)
353 - {
354 - return (mask & IN_IGNORED) || (mask & IN_MOVE_SELF);
355 - }
356 -
357 - static void log_mask_set(const char *path, uint32_t mask)
358 - {
359 - struct strbuf msg = STRBUF_INIT;
360 -
361 - if (mask & IN_ACCESS)
362 - strbuf_addstr(&msg, "IN_ACCESS|");
363 - if (mask & IN_MODIFY)
364 - strbuf_addstr(&msg, "IN_MODIFY|");
365 - if (mask & IN_ATTRIB)
366 - strbuf_addstr(&msg, "IN_ATTRIB|");
367 - if (mask & IN_CLOSE_WRITE)
368 - strbuf_addstr(&msg, "IN_CLOSE_WRITE|");
369 - if (mask & IN_CLOSE_NOWRITE)
370 - strbuf_addstr(&msg, "IN_CLOSE_NOWRITE|");
371 - if (mask & IN_OPEN)
372 - strbuf_addstr(&msg, "IN_OPEN|");
373 - if (mask & IN_MOVED_FROM)
374 - strbuf_addstr(&msg, "IN_MOVED_FROM|");
375 - if (mask & IN_MOVED_TO)
376 - strbuf_addstr(&msg, "IN_MOVED_TO|");
377 - if (mask & IN_CREATE)
378 - strbuf_addstr(&msg, "IN_CREATE|");
379 - if (mask & IN_DELETE)
380 - strbuf_addstr(&msg, "IN_DELETE|");
381 - if (mask & IN_DELETE_SELF)
382 - strbuf_addstr(&msg, "IN_DELETE_SELF|");
383 - if (mask & IN_MOVE_SELF)
384 - strbuf_addstr(&msg, "IN_MOVE_SELF|");
385 - if (mask & IN_UNMOUNT)
386 - strbuf_addstr(&msg, "IN_UNMOUNT|");
387 - if (mask & IN_Q_OVERFLOW)
388 - strbuf_addstr(&msg, "IN_Q_OVERFLOW|");
389 - if (mask & IN_IGNORED)
390 - strbuf_addstr(&msg, "IN_IGNORED|");
391 - if (mask & IN_ISDIR)
392 - strbuf_addstr(&msg, "IN_ISDIR|");
393 -
394 - strbuf_strip_suffix(&msg, "|");
395 -
396 - trace_printf_key(&trace_fsmonitor, "inotify_event: '%s', mask=%#8.8x %s",
397 - path, mask, msg.buf);
398 -
399 - strbuf_release(&msg);
400 - }
401 -
402 - int fsm_listen__ctor(struct fsmonitor_daemon_state *state)
403 - {
404 - int fd;
405 - int ret = 0;
406 - struct fsm_listen_data *data;
407 -
408 - CALLOC_ARRAY(data, 1);
409 - state->listen_data = data;
410 - state->listen_error_code = -1;
411 - data->fd_inotify = -1;
412 - data->shutdown = SHUTDOWN_ERROR;
413 -
414 - fd = inotify_init1(O_NONBLOCK);
415 - if (fd < 0) {
416 - FREE_AND_NULL(state->listen_data);
417 - return error_errno(_("inotify_init1() failed"));
418 - }
419 -
420 - data->fd_inotify = fd;
421 -
422 - hashmap_init(&data->watches, watch_entry_cmp, NULL, 0);
423 - hashmap_init(&data->renames, rename_entry_cmp, NULL, 0);
424 - hashmap_init(&data->revwatches, revwatches_entry_cmp, NULL, 0);
425 -
426 - if (add_watch(state->path_worktree_watch.buf, data))
427 - ret = -1;
428 - else if (register_inotify(state->path_worktree_watch.buf, state, NULL))
429 - ret = -1;
430 - else if (state->nr_paths_watching > 1) {
431 - if (add_watch(state->path_gitdir_watch.buf, data))
432 - ret = -1;
433 - else if (register_inotify(state->path_gitdir_watch.buf, state, NULL))
434 - ret = -1;
435 - }
436 -
437 - if (!ret) {
438 - state->listen_error_code = 0;
439 - data->shutdown = SHUTDOWN_CONTINUE;
440 - }
441 -
442 - return ret;
443 - }
444 -
445 - void fsm_listen__dtor(struct fsmonitor_daemon_state *state)
446 - {
447 - struct fsm_listen_data *data;
448 - struct hashmap_iter iter;
449 - struct watch_entry *w;
450 - struct watch_entry **to_remove;
451 - size_t nr_to_remove = 0, alloc_to_remove = 0;
452 - size_t i;
453 - int fd;
454 -
455 - if (!state || !state->listen_data)
456 - return;
457 -
458 - data = state->listen_data;
459 - fd = data->fd_inotify;
460 -
461 - /*
462 - * Collect all entries first, then remove them.
463 - * We can't modify the hashmap while iterating over it.
464 - */
465 - to_remove = NULL;
466 - hashmap_for_each_entry(&data->watches, &iter, w, ent) {
467 - ALLOC_GROW(to_remove, nr_to_remove + 1, alloc_to_remove);
468 - to_remove[nr_to_remove++] = w;
469 - }
470 -
471 - for (i = 0; i < nr_to_remove; i++) {
472 - to_remove[i]->cookie = 0; /* ignore any pending renames */
473 - remove_watch(to_remove[i], data);
474 - }
475 - free(to_remove);
476 -
477 - hashmap_clear(&data->watches);
478 -
479 - hashmap_clear(&data->revwatches); /* remove_watch freed the entries */
480 -
481 - hashmap_clear_and_free(&data->renames, struct rename_entry, ent);
482 -
483 - FREE_AND_NULL(state->listen_data);
484 -
485 - if (fd >= 0 && (close(fd) < 0))
486 - error_errno(_("closing inotify file descriptor failed"));
487 - }
488 -
489 - void fsm_listen__stop_async(struct fsmonitor_daemon_state *state)
490 - {
491 - if (state && state->listen_data &&
492 - state->listen_data->shutdown == SHUTDOWN_CONTINUE)
493 - state->listen_data->shutdown = SHUTDOWN_STOP;
494 - }
495 -
496 - /*
497 - * Process a single inotify event and queue for publication.
498 - */
499 - static int process_event(const char *path,
500 - const struct inotify_event *event,
501 - struct fsmonitor_batch **batch,
502 - struct string_list *cookie_list,
503 - struct fsmonitor_daemon_state *state)
504 - {
505 - const char *rel;
506 - const char *last_sep;
507 -
508 - switch (fsmonitor_classify_path_absolute(state, path)) {
509 - case IS_INSIDE_DOT_GIT_WITH_COOKIE_PREFIX:
510 - case IS_INSIDE_GITDIR_WITH_COOKIE_PREFIX:
511 - /* Use just the filename of the cookie file. */
512 - last_sep = find_last_dir_sep(path);
513 - string_list_append(cookie_list,
514 - last_sep ? last_sep + 1 : path);
515 - break;
516 - case IS_INSIDE_DOT_GIT:
517 - case IS_INSIDE_GITDIR:
518 - break;
519 - case IS_DOT_GIT:
520 - case IS_GITDIR:
521 - /*
522 - * If .git directory is deleted or renamed away,
523 - * we have to quit.
524 - */
525 - if (em_dir_deleted(event->mask)) {
526 - trace_printf_key(&trace_fsmonitor,
527 - "event: gitdir removed");
528 - state->listen_data->shutdown = SHUTDOWN_FORCE;
529 - goto done;
530 - }
531 -
532 - if (em_dir_renamed(event->mask)) {
533 - trace_printf_key(&trace_fsmonitor,
534 - "event: gitdir renamed");
535 - state->listen_data->shutdown = SHUTDOWN_FORCE;
536 - goto done;
537 - }
538 - break;
539 - case IS_WORKDIR_PATH:
540 - /* normal events in the working directory */
541 - if (trace_pass_fl(&trace_fsmonitor))
542 - log_mask_set(path, event->mask);
543 -
544 - if (!*batch)
545 - *batch = fsmonitor_batch__new();
546 -
547 - rel = path + state->path_worktree_watch.len + 1;
548 - fsmonitor_batch__add_path(*batch, rel);
549 -
550 - if (em_dir_deleted(event->mask))
551 - break;
552 -
553 - /* received IN_MOVE_FROM, add tracking for expected IN_MOVE_TO */
554 - if (em_rename_dir_from(event->mask))
555 - add_dir_rename(event->cookie, path, state->listen_data);
556 -
557 - /* received IN_MOVE_TO, update watch to reflect new path */
558 - if (em_rename_dir_to(event->mask)) {
559 - rename_dir(event->cookie, path, state->listen_data);
560 - if (register_inotify(path, state, *batch)) {
561 - state->listen_data->shutdown = SHUTDOWN_ERROR;
562 - goto done;
563 - }
564 - }
565 -
566 - if (em_dir_created(event->mask)) {
567 - if (add_watch(path, state->listen_data)) {
568 - state->listen_data->shutdown = SHUTDOWN_ERROR;
569 - goto done;
570 - }
571 - if (register_inotify(path, state, *batch)) {
572 - state->listen_data->shutdown = SHUTDOWN_ERROR;
573 - goto done;
574 - }
575 - }
576 - break;
577 - case IS_OUTSIDE_CONE:
578 - default:
579 - trace_printf_key(&trace_fsmonitor,
580 - "ignoring '%s'", path);
581 - break;
582 - }
583 - return 0;
584 - done:
585 - return -1;
586 - }
587 -
588 - /*
589 - * Read the inotify event stream and pre-process events before further
590 - * processing and eventual publishing.
591 - */
592 - static void handle_events(struct fsmonitor_daemon_state *state)
593 - {
594 - /* See https://man7.org/linux/man-pages/man7/inotify.7.html */
595 - char buf[4096]
596 - __attribute__ ((aligned(__alignof__(struct inotify_event))));
597 -
598 - struct hashmap *watches = &state->listen_data->watches;
599 - struct fsmonitor_batch *batch = NULL;
600 - struct string_list cookie_list = STRING_LIST_INIT_DUP;
601 - struct watch_entry k, *w;
602 - struct strbuf path = STRBUF_INIT;
603 - const struct inotify_event *event;
604 - int fd = state->listen_data->fd_inotify;
605 - ssize_t len;
606 - char *ptr, *p;
607 -
608 - for (;;) {
609 - len = read(fd, buf, sizeof(buf));
610 - if (len == -1) {
611 - if (errno == EAGAIN || errno == EINTR)
612 - goto done;
613 - error_errno(_("reading inotify message stream failed"));
614 - state->listen_data->shutdown = SHUTDOWN_ERROR;
615 - goto done;
616 - }
617 -
618 - /* nothing to read */
619 - if (len == 0)
620 - goto done;
621 -
622 - /* Loop over all events in the buffer. */
623 - for (ptr = buf; ptr < buf + len;
624 - ptr += sizeof(struct inotify_event) + event->len) {
625 -
626 - event = (const struct inotify_event *)ptr;
627 -
628 - if (em_ignore(event->mask))
629 - continue;
630 -
631 - /* File system was unmounted or event queue overflowed */
632 - if (em_force_shutdown(event->mask)) {
633 - if (trace_pass_fl(&trace_fsmonitor))
634 - log_mask_set("forcing shutdown", event->mask);
635 - state->listen_data->shutdown = SHUTDOWN_FORCE;
636 - goto done;
637 - }
638 -
639 - k.wd = event->wd;
640 - hashmap_entry_init(&k.ent, memhash(&k.wd, sizeof(int)));
641 -
642 - w = hashmap_get_entry(watches, &k, ent, NULL);
643 - if (!w) {
644 - /* Watch was removed, skip event */
645 - continue;
646 - }
647 -
648 - /* directory watch was removed */
649 - if (em_remove_watch(event->mask)) {
650 - remove_watch(w, state->listen_data);
651 - continue;
652 - }
653 -
654 - strbuf_reset(&path);
655 - strbuf_addf(&path, "%s/%s", w->dir, event->name);
656 -
657 - p = fsmonitor__resolve_alias(path.buf, &state->alias);
658 - if (!p)
659 - p = strbuf_detach(&path, NULL);
660 -
661 - if (process_event(p, event, &batch, &cookie_list, state)) {
662 - free(p);
663 - goto done;
664 - }
665 - free(p);
666 - }
667 - strbuf_reset(&path);
668 - fsmonitor_publish(state, batch, &cookie_list);
669 - string_list_clear(&cookie_list, 0);
670 - batch = NULL;
671 - }
672 - done:
673 - strbuf_release(&path);
674 - fsmonitor_batch__free_list(batch);
675 - string_list_clear(&cookie_list, 0);
676 - }
677 -
678 - /*
679 - * Non-blocking read of the inotify events stream. The inotify fd is polled
680 - * frequently to help minimize the number of queue overflows.
681 - */
682 - void fsm_listen__loop(struct fsmonitor_daemon_state *state)
683 - {
684 - int poll_num;
685 - /*
686 - * Interval in seconds between checks for stale directory renames.
687 - * A directory rename that is not completed within this window
688 - * (i.e. no matching IN_MOVED_TO for an IN_MOVED_FROM) indicates
689 - * missed events, forcing a shutdown.
690 - */
691 - const int interval = 1;
692 - time_t checked = time(NULL);
693 - struct pollfd fds[1];
694 -
695 - fds[0].fd = state->listen_data->fd_inotify;
696 - fds[0].events = POLLIN;
697 -
698 - /*
699 - * Our fs event listener is now running, so it's safe to start
700 - * serving client requests.
701 - */
702 - ipc_server_start_async(state->ipc_server_data);
703 -
704 - for (;;) {
705 - switch (state->listen_data->shutdown) {
706 - case SHUTDOWN_CONTINUE:
707 - poll_num = poll(fds, 1, 50);
708 - if (poll_num == -1) {
709 - if (errno == EINTR)
710 - continue;
711 - error_errno(_("polling inotify message stream failed"));
712 - state->listen_data->shutdown = SHUTDOWN_ERROR;
713 - continue;
714 - }
715 -
716 - if ((time(NULL) - checked) >= interval) {
717 - checked = time(NULL);
718 - if (check_stale_dir_renames(&state->listen_data->renames,
719 - checked - interval)) {
720 - trace_printf_key(&trace_fsmonitor,
721 - "missed IN_MOVED_TO events, forcing shutdown");
722 - state->listen_data->shutdown = SHUTDOWN_FORCE;
723 - continue;
724 - }
725 - }
726 -
727 - if (poll_num > 0 && (fds[0].revents & POLLIN))
728 - handle_events(state);
729 -
730 - continue;
731 - case SHUTDOWN_ERROR:
732 - state->listen_error_code = -1;
733 - ipc_server_stop_async(state->ipc_server_data);
734 - break;
735 - case SHUTDOWN_FORCE:
736 - state->listen_error_code = 0;
737 - ipc_server_stop_async(state->ipc_server_data);
738 - break;
739 - case SHUTDOWN_STOP:
740 - default:
741 - state->listen_error_code = 0;
742 - break;
743 - }
744 - return;
745 - }
746 - }
deleted compat/fsmonitor/fsm-path-utils-linux.c mode 100644
@@ -1,217 +0,0 @@
1 - #include "git-compat-util.h"
2 - #include "fsmonitor-ll.h"
3 - #include "fsmonitor-path-utils.h"
4 - #include "gettext.h"
5 - #include "trace.h"
6 -
7 - #include <sys/statfs.h>
8 -
9 - #ifdef HAVE_LINUX_MAGIC_H
10 - #include <linux/magic.h>
11 - #endif
12 -
13 - /*
14 - * Filesystem magic numbers for remote filesystems.
15 - * Defined here if not available in linux/magic.h.
16 - */
17 - #ifndef CIFS_SUPER_MAGIC
18 - #define CIFS_SUPER_MAGIC 0xff534d42
19 - #endif
20 - #ifndef SMB_SUPER_MAGIC
21 - #define SMB_SUPER_MAGIC 0x517b
22 - #endif
23 - #ifndef SMB2_SUPER_MAGIC
24 - #define SMB2_SUPER_MAGIC 0xfe534d42
25 - #endif
26 - #ifndef NFS_SUPER_MAGIC
27 - #define NFS_SUPER_MAGIC 0x6969
28 - #endif
29 - #ifndef AFS_SUPER_MAGIC
30 - #define AFS_SUPER_MAGIC 0x5346414f
31 - #endif
32 - #ifndef CODA_SUPER_MAGIC
33 - #define CODA_SUPER_MAGIC 0x73757245
34 - #endif
35 - #ifndef FUSE_SUPER_MAGIC
36 - #define FUSE_SUPER_MAGIC 0x65735546
37 - #endif
38 -
39 - /*
40 - * Check if filesystem type is a remote filesystem.
41 - */
42 - static int is_remote_fs(unsigned long f_type)
43 - {
44 - switch (f_type) {
45 - case CIFS_SUPER_MAGIC:
46 - case SMB_SUPER_MAGIC:
47 - case SMB2_SUPER_MAGIC:
48 - case NFS_SUPER_MAGIC:
49 - case AFS_SUPER_MAGIC:
50 - case CODA_SUPER_MAGIC:
51 - case FUSE_SUPER_MAGIC:
52 - return 1;
53 - default:
54 - return 0;
55 - }
56 - }
57 -
58 - /*
59 - * Map filesystem magic numbers to human-readable names as a fallback
60 - * when /proc/mounts is unavailable. This only covers the remote and
61 - * special filesystems in is_remote_fs() above; local filesystems are
62 - * never flagged as incompatible, so we do not need their names here.
63 - */
64 - static const char *get_fs_typename(unsigned long f_type)
65 - {
66 - switch (f_type) {
67 - case CIFS_SUPER_MAGIC:
68 - return "cifs";
69 - case SMB_SUPER_MAGIC:
70 - return "smb";
71 - case SMB2_SUPER_MAGIC:
72 - return "smb2";
73 - case NFS_SUPER_MAGIC:
74 - return "nfs";
75 - case AFS_SUPER_MAGIC:
76 - return "afs";
77 - case CODA_SUPER_MAGIC:
78 - return "coda";
79 - case FUSE_SUPER_MAGIC:
80 - return "fuse";
81 - default:
82 - return "unknown";
83 - }
84 - }
85 -
86 - /*
87 - * Find the mount point for a given path by reading /proc/mounts.
88 - *
89 - * statfs(2) gives us f_type (the magic number) but not the human-readable
90 - * filesystem type string. We scan /proc/mounts to find the mount entry
91 - * whose path is the longest prefix of ours and whose f_fsid matches,
92 - * which gives us the fstype string (e.g. "nfs", "ext4") for logging.
93 - */
94 - static char *find_mount(const char *path, const struct statfs *path_fs)
95 - {
96 - FILE *fp;
97 - struct strbuf line = STRBUF_INIT;
98 - struct strbuf match = STRBUF_INIT;
99 - struct strbuf fstype = STRBUF_INIT;
100 - char *result = NULL;
101 -
102 - fp = fopen("/proc/mounts", "r");
103 - if (!fp)
104 - return NULL;
105 -
106 - while (strbuf_getline(&line, fp) != EOF) {
107 - char *fields[6];
108 - char *p = line.buf;
109 - int i;
110 -
111 - /* Parse mount entry: device mountpoint fstype options dump pass */
112 - for (i = 0; i < 6 && p; i++) {
113 - fields[i] = p;
114 - p = strchr(p, ' ');
115 - if (p)
116 - *p++ = '\0';
117 - }
118 -
119 - if (i >= 3) {
120 - const char *mountpoint = fields[1];
121 - const char *type = fields[2];
122 - struct statfs mount_fs;
123 -
124 - /* Check if this mount point is a prefix of our path */
125 - if (starts_with(path, mountpoint) &&
126 - (path[strlen(mountpoint)] == '/' ||
127 - path[strlen(mountpoint)] == '\0')) {
128 - /* Check if filesystem ID matches */
129 - if (statfs(mountpoint, &mount_fs) == 0 &&
130 - !memcmp(&mount_fs.f_fsid, &path_fs->f_fsid,
131 - sizeof(mount_fs.f_fsid))) {
132 - /* Keep the longest matching mount point */
133 - if (strlen(mountpoint) > match.len) {
134 - strbuf_reset(&match);
135 - strbuf_addstr(&match, mountpoint);
136 - strbuf_reset(&fstype);
137 - strbuf_addstr(&fstype, type);
138 - }
139 - }
140 - }
141 - }
142 - }
143 -
144 - fclose(fp);
145 - strbuf_release(&line);
146 - strbuf_release(&match);
147 -
148 - if (fstype.len)
149 - result = strbuf_detach(&fstype, NULL);
150 - else
151 - strbuf_release(&fstype);
152 -
153 - return result;
154 - }
155 -
156 - int fsmonitor__get_fs_info(const char *path, struct fs_info *fs_info)
157 - {
158 - struct statfs fs;
159 -
160 - if (statfs(path, &fs) == -1) {
161 - int saved_errno = errno;
162 - trace_printf_key(&trace_fsmonitor, "statfs('%s') failed: %s",
163 - path, strerror(saved_errno));
164 - errno = saved_errno;
165 - return -1;
166 - }
167 -
168 - trace_printf_key(&trace_fsmonitor,
169 - "statfs('%s') [type 0x%08lx]",
170 - path, (unsigned long)fs.f_type);
171 -
172 - fs_info->is_remote = is_remote_fs(fs.f_type);
173 -
174 - /*
175 - * Try to get filesystem type from /proc/mounts for a more
176 - * descriptive name.
177 - */
178 - fs_info->typename = find_mount(path, &fs);
179 - if (!fs_info->typename)
180 - fs_info->typename = xstrdup(get_fs_typename(fs.f_type));
181 -
182 - trace_printf_key(&trace_fsmonitor,
183 - "'%s' is_remote: %d, typename: %s",
184 - path, fs_info->is_remote, fs_info->typename);
185 -
186 - return 0;
187 - }
188 -
189 - int fsmonitor__is_fs_remote(const char *path)
190 - {
191 - struct fs_info fs;
192 -
193 - if (fsmonitor__get_fs_info(path, &fs))
194 - return -1;
195 -
196 - free(fs.typename);
197 -
198 - return fs.is_remote;
199 - }
200 -
201 - /*
202 - * No-op for Linux - we don't have firmlinks like macOS.
203 - */
204 - int fsmonitor__get_alias(const char *path UNUSED,
205 - struct alias_info *info UNUSED)
206 - {
207 - return 0;
208 - }
209 -
210 - /*
211 - * No-op for Linux - we don't have firmlinks like macOS.
212 - */
213 - char *fsmonitor__resolve_alias(const char *path UNUSED,
214 - const struct alias_info *info UNUSED)
215 - {
216 - return NULL;
217 - }
renamed 100% compat/fsmonitor/fsm-settings-unix.c โ†’ compat/fsmonitor/fsm-settings-darwin.c

No content changes.

modified compat/mingw.c
@@ -7,14 +7,12 @@
7 7 #include "config.h"
8 8 #include "dir.h"
9 9 #include "environment.h"
10 - #include "repository.h"
11 10 #include "gettext.h"
12 11 #include "run-command.h"
13 12 #include "strbuf.h"
14 13 #include "symlinks.h"
15 14 #include "trace2.h"
16 15 #include "win32.h"
17 - #include "win32/exit-process.h"
18 16 #include "win32/lazyload.h"
19 17 #include "wrapper.h"
20 18 #include <aclapi.h>
@@ -353,29 +351,6 @@ process_phantom_symlink(const wchar_t *wtarget, const wchar_t *wlink)
353 351 wchar_t relative[MAX_PATH];
354 352 const wchar_t *rel;
355 353
356 - /*
357 - * Do not follow symlinks to network shares, to avoid NTLM credential
358 - * leak from crafted repositories (e.g. \\attacker-server\share).
359 - * Since paths come in all kind of enterprising shapes and forms (in
360 - * addition to the canonical `\\host\share` form, there's also
361 - * `\??\UNC\host\share`, `\GLOBAL??\UNC\host\share` and also
362 - * `\Device\Mup\host\share`, just to name a few), we simply avoid
363 - * following every symlink target that starts with a slash.
364 - *
365 - * This also catches drive-less absolute paths, of course. These are
366 - * uncommon in practice (and also fragile because they are relative to
367 - * the current working directory's drive). The only "harm" this does
368 - * is that it now requires users to specify via the Git attributes if
369 - * they have such an uncommon symbolic link and need it to be a
370 - * directory type link.
371 - */
372 - if (is_wdir_sep(wtarget[0])) {
373 - warning("created file symlink '%ls' pointing to '%ls';\n"
374 - "set the `symlink` gitattribute to `dir` if a "
375 - "directory symlink is required", wlink, wtarget);
376 - return PHANTOM_SYMLINK_DONE;
377 - }
378 -
379 354 /* check that wlink is still a file symlink */
380 355 if ((GetFileAttributesW(wlink)
381 356 & (FILE_ATTRIBUTE_REPARSE_POINT | FILE_ATTRIBUTE_DIRECTORY))
@@ -1068,7 +1043,7 @@ int mingw_chdir(const char *dirname)
1068 1043 if (xutftowcs_path(wdirname, dirname) < 0)
1069 1044 return -1;
1070 1045
1071 - if (repo_has_symlinks(the_repository)) {
1046 + if (has_symlinks) {
1072 1047 HANDLE hnd = CreateFileW(wdirname, 0,
1073 1048 FILE_SHARE_READ | FILE_SHARE_WRITE | FILE_SHARE_DELETE, NULL,
1074 1049 OPEN_EXISTING, FILE_FLAG_BACKUP_SEMANTICS, NULL);
@@ -2276,26 +2251,16 @@ int mingw_execvp(const char *cmd, char *const *argv)
2276 2251 int mingw_kill(pid_t pid, int sig)
2277 2252 {
2278 2253 if (pid > 0 && sig == SIGTERM) {
2279 - HANDLE h = OpenProcess(PROCESS_CREATE_THREAD |
2280 - PROCESS_QUERY_INFORMATION |
2281 - PROCESS_VM_OPERATION | PROCESS_VM_WRITE |
2282 - PROCESS_VM_READ | PROCESS_TERMINATE,
2283 - FALSE, pid);
2284 - int ret;
2285 -
2286 - if (h)
2287 - ret = exit_process(h, 128 + sig);
2288 - else {
2289 - h = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
2290 - if (!h) {
2291 - errno = err_win_to_posix(GetLastError());
2292 - return -1;
2293 - }
2294 - ret = terminate_process_tree(h, 128 + sig);
2254 + HANDLE h = OpenProcess(PROCESS_TERMINATE, FALSE, pid);
2255 +
2256 + if (TerminateProcess(h, -1)) {
2257 + CloseHandle(h);
2258 + return 0;
2295 2259 }
2296 - if (ret)
2297 - errno = err_win_to_posix(GetLastError());
2298 - return ret;
2260 +
2261 + errno = err_win_to_posix(GetLastError());
2262 + CloseHandle(h);
2263 + return -1;
2299 2264 } else if (pid > 0 && sig == 0) {
2300 2265 HANDLE h = OpenProcess(PROCESS_QUERY_INFORMATION, FALSE, pid);
2301 2266 if (h) {
@@ -2938,7 +2903,7 @@ int symlink(const char *target, const char *link)
2938 2903 int len;
2939 2904
2940 2905 /* fail if symlinks are disabled or API is not supported (WinXP) */
2941 - if (!repo_has_symlinks(the_repository)) {
2906 + if (!has_symlinks) {
2942 2907 errno = ENOSYS;
2943 2908 return -1;
2944 2909 }
@@ -3208,23 +3173,15 @@ static void setup_windows_environment(void)
3208 3173 if (!tmp && (tmp = getenv("USERPROFILE")))
3209 3174 setenv("HOME", tmp, 1);
3210 3175 }
3211 - }
3212 3176
3213 - int mingw_platform_has_symlinks(void)
3214 - {
3215 - static int has_symlinks = -1;
3216 3177 /*
3217 3178 * Change 'core.symlinks' default to false, unless native symlinks are
3218 3179 * enabled in MSys2 (via 'MSYS=winsymlinks:nativestrict'). Thus we can
3219 3180 * run the test suite (which doesn't obey config files) with or without
3220 3181 * symlink support.
3221 3182 */
3222 - if (has_symlinks < 0) {
3223 - const char *tmp = getenv("MSYS");
3224 - has_symlinks = (tmp && strstr(tmp, "winsymlinks:nativestrict")) ? 1 : 0;
3225 - }
3226 -
3227 - return has_symlinks;
3183 + if (!(tmp = getenv("MSYS")) || !strstr(tmp, "winsymlinks:nativestrict"))
3184 + has_symlinks = 0;
3228 3185 }
3229 3186
3230 3187 static void get_current_user_sid(PSID *sid, HANDLE *linked_token)
@@ -3435,7 +3392,7 @@ int is_valid_win32_path(const char *path, int allow_literal_nul)
3435 3392 const char *p = path;
3436 3393 int preceding_space_or_period = 0, i = 0, periods = 0;
3437 3394
3438 - if (!repo_protect_ntfs(the_repository))
3395 + if (!protect_ntfs)
3439 3396 return 1;
3440 3397
3441 3398 skip_dos_drive_prefix((char **)&path);
@@ -3653,14 +3610,7 @@ static void adjust_symlink_flags(void)
3653 3610 symlink_file_flags |= 2;
3654 3611 symlink_directory_flags |= 2;
3655 3612 }
3656 - }
3657 3613
3658 - static BOOL WINAPI handle_ctrl_c(DWORD ctrl_type)
3659 - {
3660 - if (ctrl_type != CTRL_C_EVENT)
3661 - return FALSE; /* we did not handle this */
3662 - mingw_raise(SIGINT);
3663 - return TRUE; /* we did handle this */
3664 3614 }
3665 3615
3666 3616 #ifdef _MSC_VER
@@ -3697,8 +3647,6 @@ int wmain(int argc, const wchar_t **wargv)
3697 3647 #endif
3698 3648 #endif
3699 3649
3700 - SetConsoleCtrlHandler(handle_ctrl_c, TRUE);
3701 -
3702 3650 maybe_redirect_std_handles();
3703 3651 adjust_symlink_flags();
3704 3652
modified compat/mingw.h
@@ -208,9 +208,6 @@ void open_in_gdb(void);
208 208 */
209 209 int err_win_to_posix(DWORD winerr);
210 210
211 - int mingw_platform_has_symlinks(void);
212 - #define platform_has_symlinks() mingw_platform_has_symlinks()
213 -
214 211 #ifndef NO_UNIX_SOCKETS
215 212 int mingw_have_unix_sockets(void);
216 213 #undef have_unix_sockets
modified compat/msvc-posix.h
@@ -16,6 +16,7 @@
16 16 #define __attribute__(x)
17 17 #define strcasecmp _stricmp
18 18 #define strncasecmp _strnicmp
19 + #define ftruncate _chsize
19 20 #define strtoull _strtoui64
20 21 #define strtoll _strtoi64
21 22
@@ -29,27 +30,4 @@ typedef int sigset_t;
29 30
30 31 #include "mingw-posix.h"
31 32
32 - /*
33 - * MSVC's `_chsize()` takes a 32-bit `long` and silently truncates files
34 - * to 2 GiB. `_chsize_s()` accepts a 64-bit length but returns 0 on
35 - * success or an errno value on failure, rather than the -1/errno
36 - * convention POSIX `ftruncate()` callers expect. Wrap it so callers
37 - * that test the return value as `< 0` or against `-1` keep working.
38 - *
39 - * Note: this declaration must follow `#include "mingw-posix.h"` so
40 - * `off_t` resolves to `off64_t` and the parameter type matches the
41 - * underlying `_chsize_s()` width.
42 - */
43 - static inline int msvc_ftruncate(int fd, off_t length)
44 - {
45 - int err = _chsize_s(fd, length);
46 -
47 - if (err) {
48 - errno = err;
49 - return -1;
50 - }
51 - return 0;
52 - }
53 - #define ftruncate msvc_ftruncate
54 -
55 33 #endif /* COMPAT_MSVC_POSIX_H */
modified compat/posix.h
@@ -4,33 +4,22 @@
4 4 #define _FILE_OFFSET_BITS 64
5 5
6 6 /*
7 - * Convenience macros to test the versions of GCC (or a compatible compiler).
7 + * Derived from Linux "Features Test Macro" header
8 + * Convenience macros to test the versions of gcc (or
9 + * a compatible compiler).
8 10 * Use them like this:
9 11 * #if GIT_GNUC_PREREQ (2,8)
10 - * ... code requiring GCC 2.8 or later ...
12 + * ... code requiring gcc 2.8 or later ...
11 13 * #endif
12 14 *
13 - * Note that Clang and other compilers define __GNUC__ for compatibility; use
14 - * GIT_CLANG_PREREQ() to check for specific Clang versions.
15 - *
16 15 * This macro of course is not part of POSIX, but we need it for the UNUSED
17 16 * macro which is used by some of our POSIX compatibility wrappers.
18 - */
17 + */
19 18 #if defined(__GNUC__) && defined(__GNUC_MINOR__)
20 19 # define GIT_GNUC_PREREQ(maj, min) \
21 - ((__GNUC__ > (maj)) || \
22 - (__GNUC__ == (maj) && __GNUC_MINOR__ >= (min)))
23 - #else
24 - # define GIT_GNUC_PREREQ(maj, min) 0
25 - #endif
26 -
27 - /* Similar for Clang. */
28 - #if defined(__clang__) && defined(__clang_minor__) && defined(__clang_major__)
29 - # define GIT_CLANG_PREREQ(maj, min) \
30 - ((__clang_major__ > (maj)) || \
31 - (__clang_major__ == (maj) && __clang_minor__ >= (min)))
20 + ((__GNUC__ << 16) + __GNUC_MINOR__ >= ((maj) << 16) + (min))
32 21 #else
33 - # define GIT_CLANG_PREREQ(maj, min) 0
22 + #define GIT_GNUC_PREREQ(maj, min) 0
34 23 #endif
35 24
36 25 /*
@@ -46,17 +35,17 @@
46 35 * When a parameter may be used or unused, depending on conditional
47 36 * compilation, consider using MAYBE_UNUSED instead.
48 37 */
49 - #if GIT_GNUC_PREREQ(4, 5) || GIT_CLANG_PREREQ(2, 9)
50 - # define UNUSED __attribute__((unused)) \
51 - __attribute__((deprecated("parameter declared as UNUSED")))
38 + #if GIT_GNUC_PREREQ(4, 5)
39 + #define UNUSED __attribute__((unused)) \
40 + __attribute__((deprecated ("parameter declared as UNUSED")))
52 41 #elif defined(__GNUC__)
53 - # define UNUSED __attribute__((unused)) \
42 + #define UNUSED __attribute__((unused)) \
54 43 __attribute__((deprecated))
55 44 #else
56 - # define UNUSED
45 + #define UNUSED
57 46 #endif
58 47
59 - #if defined(__MINGW32__) || defined(__MINGW64__)
48 + #ifdef __MINGW64__
60 49 #define _POSIX_C_SOURCE 1
61 50 #elif defined(__sun__)
62 51 /*
@@ -148,9 +137,6 @@
148 137 #include <sys/socket.h>
149 138 #include <sys/ioctl.h>
150 139 #include <sys/statvfs.h>
151 - #ifndef NO_WRITEV
152 - #include <sys/uio.h>
153 - #endif
154 140 #include <termios.h>
155 141 #ifndef NO_SYS_SELECT_H
156 142 #include <sys/select.h>
@@ -337,17 +323,6 @@ int git_lstat(const char *, struct stat *);
337 323 ssize_t git_pread(int fd, void *buf, size_t count, off_t offset);
338 324 #endif
339 325
340 - #ifdef NO_WRITEV
341 - #define writev git_writev
342 - #define iovec git_iovec
343 - struct git_iovec {
344 - void *iov_base;
345 - size_t iov_len;
346 - };
347 -
348 - ssize_t git_writev(int fd, const struct iovec *iov, int iovcnt);
349 - #endif
350 -
351 326 #ifdef NO_SETENV
352 327 #define setenv gitsetenv
353 328 int gitsetenv(const char *, const char *, int);
modified compat/pread.c
@@ -7,8 +7,6 @@ ssize_t git_pread(int fd, void *buf, size_t count, off_t offset)
7 7 ssize_t rc;
8 8
9 9 current_offset = lseek(fd, 0, SEEK_CUR);
10 - if (current_offset < 0)
11 - return -1;
12 10
13 11 if (lseek(fd, offset, SEEK_SET) < 0)
14 12 return -1;
modified compat/precompose_utf8.c
@@ -19,11 +19,6 @@ typedef char *iconv_ibp;
19 19 static const char *repo_encoding = "UTF-8";
20 20 static const char *path_encoding = "UTF-8-MAC";
21 21
22 - static size_t dirent_prec_psx_size(size_t max_name_len)
23 - {
24 - return st_add(offsetof(dirent_prec_psx, d_name), max_name_len);
25 - }
26 -
27 22 static size_t has_non_ascii(const char *s, size_t maxlen, size_t *strlen_c)
28 23 {
29 24 const uint8_t *ptr = (const uint8_t *)s;
@@ -53,18 +48,16 @@ void probe_utf8_pathname_composition(void)
53 48 static const char *auml_nfc = "\xc3\xa4";
54 49 static const char *auml_nfd = "\x61\xcc\x88";
55 50 int output_fd;
56 - struct repo_config_values *cfg = repo_config_values(the_repository);
57 -
58 - if (cfg->precomposed_unicode != -1)
51 + if (precomposed_unicode != -1)
59 52 return; /* We found it defined in the global config, respect it */
60 53 repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
61 54 output_fd = open(path.buf, O_CREAT|O_EXCL|O_RDWR, 0600);
62 55 if (output_fd >= 0) {
63 56 close(output_fd);
64 57 repo_git_path_replace(the_repository, &path, "%s", auml_nfd);
65 - cfg->precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
58 + precomposed_unicode = access(path.buf, R_OK) ? 0 : 1;
66 59 repo_config_set(the_repository, "core.precomposeunicode",
67 - cfg->precomposed_unicode ? "true" : "false");
60 + precomposed_unicode ? "true" : "false");
68 61 repo_git_path_replace(the_repository, &path, "%s", auml_nfc);
69 62 if (unlink(path.buf))
70 63 die_errno(_("failed to unlink '%s'"), path.buf);
@@ -76,16 +69,14 @@ const char *precompose_string_if_needed(const char *in)
76 69 {
77 70 size_t inlen;
78 71 size_t outlen;
79 - struct repo_config_values *cfg = repo_config_values(the_repository);
80 -
81 72 if (!in)
82 73 return NULL;
83 74 if (has_non_ascii(in, (size_t)-1, &inlen)) {
84 75 iconv_t ic_prec;
85 76 char *out;
86 - if (cfg->precomposed_unicode < 0)
87 - repo_config_get_bool(the_repository, "core.precomposeunicode", &cfg->precomposed_unicode);
88 - if (cfg->precomposed_unicode != 1)
77 + if (precomposed_unicode < 0)
78 + repo_config_get_bool(the_repository, "core.precomposeunicode", &precomposed_unicode);
79 + if (precomposed_unicode != 1)
89 80 return in;
90 81 ic_prec = iconv_open(repo_encoding, path_encoding);
91 82 if (ic_prec == (iconv_t) -1)
@@ -94,7 +85,7 @@ const char *precompose_string_if_needed(const char *in)
94 85 out = reencode_string_iconv(in, inlen, ic_prec, 0, &outlen);
95 86 if (out) {
96 87 if (outlen == inlen && !memcmp(in, out, outlen))
97 - free(out); /* no need to return identical */
88 + free(out); /* no need to return indentical */
98 89 else
99 90 in = out;
100 91 }
@@ -119,8 +110,8 @@ const char *precompose_argv_prefix(int argc, const char **argv, const char *pref
119 110 PREC_DIR *precompose_utf8_opendir(const char *dirname)
120 111 {
121 112 PREC_DIR *prec_dir = xmalloc(sizeof(PREC_DIR));
122 - prec_dir->dirent_nfc = xmalloc(dirent_prec_psx_size(NAME_MAX + 1));
123 - prec_dir->dirent_nfc->max_name_len = NAME_MAX + 1;
113 + prec_dir->dirent_nfc = xmalloc(sizeof(dirent_prec_psx));
114 + prec_dir->dirent_nfc->max_name_len = sizeof(prec_dir->dirent_nfc->d_name);
124 115
125 116 prec_dir->dirp = opendir(dirname);
126 117 if (!prec_dir->dirp) {
@@ -139,9 +130,7 @@ PREC_DIR *precompose_utf8_opendir(const char *dirname)
139 130
140 131 struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *prec_dir)
141 132 {
142 - struct repo_config_values *cfg = repo_config_values(the_repository);
143 133 struct dirent *res;
144 -
145 134 res = readdir(prec_dir->dirp);
146 135 if (res) {
147 136 size_t namelenz = strlen(res->d_name) + 1; /* \0 */
@@ -150,7 +139,8 @@ struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *prec_dir)
150 139 int ret_errno = errno;
151 140
152 141 if (new_maxlen > prec_dir->dirent_nfc->max_name_len) {
153 - size_t new_len = dirent_prec_psx_size(new_maxlen);
142 + size_t new_len = sizeof(dirent_prec_psx) + new_maxlen -
143 + sizeof(prec_dir->dirent_nfc->d_name);
154 144
155 145 prec_dir->dirent_nfc = xrealloc(prec_dir->dirent_nfc, new_len);
156 146 prec_dir->dirent_nfc->max_name_len = new_maxlen;
@@ -159,7 +149,7 @@ struct dirent_prec_psx *precompose_utf8_readdir(PREC_DIR *prec_dir)
159 149 prec_dir->dirent_nfc->d_ino = res->d_ino;
160 150 prec_dir->dirent_nfc->d_type = res->d_type;
161 151
162 - if ((cfg->precomposed_unicode == 1) && has_non_ascii(res->d_name, (size_t)-1, NULL)) {
152 + if ((precomposed_unicode == 1) && has_non_ascii(res->d_name, (size_t)-1, NULL)) {
163 153 if (prec_dir->ic_precompose == (iconv_t)-1) {
164 154 die("iconv_open(%s,%s) failed, but needed:\n"
165 155 " precomposed unicode is not supported.\n"
modified compat/precompose_utf8.h
@@ -14,12 +14,11 @@ typedef struct dirent_prec_psx {
14 14
15 15 /*
16 16 * See http://pubs.opengroup.org/onlinepubs/9699919799/basedefs/dirent.h.html
17 - * Start with room for NAME_MAX + 1 bytes, but keep d_name as a
18 - * flexible array. Some systems have NAME_MAX=255 while strlen(d_name)
19 - * from readdir() may return 508 or 510 bytes. Grow the allocation as
20 - * needed in precompose_utf8_readdir().
17 + * NAME_MAX + 1 should be enough, but some systems have
18 + * NAME_MAX=255 and strlen(d_name) may return 508 or 510
19 + * Solution: allocate more when needed, see precompose_utf8_readdir()
21 20 */
22 - char d_name[FLEX_ARRAY];
21 + char d_name[NAME_MAX+1];
23 22 } dirent_prec_psx;
24 23
25 24
deleted compat/win32/exit-process.h mode 100644
@@ -1,166 +0,0 @@
1 - #ifndef EXIT_PROCESS_H
2 - #define EXIT_PROCESS_H
3 -
4 - /*
5 - * This file contains functions to terminate a Win32 process, as gently as
6 - * possible.
7 - *
8 - * At first, we will attempt to inject a thread that calls ExitProcess(). If
9 - * that fails, we will fall back to terminating the entire process tree.
10 - *
11 - * For simplicity, these functions are marked as file-local.
12 - */
13 -
14 - #include <tlhelp32.h>
15 -
16 - /*
17 - * Terminates the process corresponding to the process ID and all of its
18 - * directly and indirectly spawned subprocesses.
19 - *
20 - * This way of terminating the processes is not gentle: the processes get
21 - * no chance of cleaning up after themselves (closing file handles, removing
22 - * .lock files, terminating spawned processes (if any), etc).
23 - */
24 - static int terminate_process_tree(HANDLE main_process, int exit_status)
25 - {
26 - HANDLE snapshot = CreateToolhelp32Snapshot(TH32CS_SNAPPROCESS, 0);
27 - PROCESSENTRY32 entry;
28 - DWORD pids[16384];
29 - int max_len = sizeof(pids) / sizeof(*pids), i, len, ret = 0;
30 - pid_t pid = GetProcessId(main_process);
31 -
32 - pids[0] = (DWORD)pid;
33 - len = 1;
34 -
35 - /*
36 - * Even if Process32First()/Process32Next() seem to traverse the
37 - * processes in topological order (i.e. parent processes before
38 - * child processes), there is nothing in the Win32 API documentation
39 - * suggesting that this is guaranteed.
40 - *
41 - * Therefore, run through them at least twice and stop when no more
42 - * process IDs were added to the list.
43 - */
44 - for (;;) {
45 - int orig_len = len;
46 -
47 - memset(&entry, 0, sizeof(entry));
48 - entry.dwSize = sizeof(entry);
49 -
50 - if (!Process32First(snapshot, &entry))
51 - break;
52 -
53 - do {
54 - for (i = len - 1; i >= 0; i--) {
55 - if (pids[i] == entry.th32ProcessID)
56 - break;
57 - if (pids[i] == entry.th32ParentProcessID)
58 - pids[len++] = entry.th32ProcessID;
59 - }
60 - } while (len < max_len && Process32Next(snapshot, &entry));
61 -
62 - if (orig_len == len || len >= max_len)
63 - break;
64 - }
65 -
66 - for (i = len - 1; i > 0; i--) {
67 - HANDLE process = OpenProcess(PROCESS_TERMINATE, FALSE, pids[i]);
68 -
69 - if (process) {
70 - if (!TerminateProcess(process, exit_status))
71 - ret = -1;
72 - CloseHandle(process);
73 - }
74 - }
75 - if (!TerminateProcess(main_process, exit_status))
76 - ret = -1;
77 - CloseHandle(main_process);
78 -
79 - return ret;
80 - }
81 -
82 - /**
83 - * Determine whether a process runs in the same architecture as the current
84 - * one. That test is required before we assume that GetProcAddress() returns
85 - * a valid address *for the target process*.
86 - */
87 - static inline int process_architecture_matches_current(HANDLE process)
88 - {
89 - static BOOL current_is_wow = -1;
90 - BOOL is_wow;
91 -
92 - if (current_is_wow == -1 &&
93 - !IsWow64Process (GetCurrentProcess(), &current_is_wow))
94 - current_is_wow = -2;
95 - if (current_is_wow == -2)
96 - return 0; /* could not determine current process' WoW-ness */
97 - if (!IsWow64Process (process, &is_wow))
98 - return 0; /* cannot determine */
99 - return is_wow == current_is_wow;
100 - }
101 -
102 - /**
103 - * Inject a thread into the given process that runs ExitProcess().
104 - *
105 - * Note: as kernel32.dll is loaded before any process, the other process and
106 - * this process will have ExitProcess() at the same address.
107 - *
108 - * This function expects the process handle to have the access rights for
109 - * CreateRemoteThread(): PROCESS_CREATE_THREAD, PROCESS_QUERY_INFORMATION,
110 - * PROCESS_VM_OPERATION, PROCESS_VM_WRITE, and PROCESS_VM_READ.
111 - *
112 - * The idea comes from the Dr Dobb's article "A Safer Alternative to
113 - * TerminateProcess()" by Andrew Tucker (July 1, 1999),
114 - * http://www.drdobbs.com/a-safer-alternative-to-terminateprocess/184416547
115 - *
116 - * If this method fails, we fall back to running terminate_process_tree().
117 - */
118 - static int exit_process(HANDLE process, int exit_code)
119 - {
120 - DWORD code;
121 -
122 - if (GetExitCodeProcess(process, &code) && code == STILL_ACTIVE) {
123 - static int initialized;
124 - static LPTHREAD_START_ROUTINE exit_process_address;
125 - PVOID arg = (PVOID)(intptr_t)exit_code;
126 - DWORD thread_id;
127 - HANDLE thread = NULL;
128 -
129 - if (!initialized) {
130 - HINSTANCE kernel32 = GetModuleHandleA("kernel32");
131 - if (!kernel32)
132 - die("BUG: cannot find kernel32");
133 - exit_process_address =
134 - (LPTHREAD_START_ROUTINE)(void (*)(void))
135 - GetProcAddress(kernel32, "ExitProcess");
136 - initialized = 1;
137 - }
138 - if (!exit_process_address ||
139 - !process_architecture_matches_current(process))
140 - return terminate_process_tree(process, exit_code);
141 -
142 - thread = CreateRemoteThread(process, NULL, 0,
143 - exit_process_address,
144 - arg, 0, &thread_id);
145 - if (thread) {
146 - CloseHandle(thread);
147 - /*
148 - * If the process survives for 10 seconds (a completely
149 - * arbitrary value picked from thin air), fall back to
150 - * killing the process tree via TerminateProcess().
151 - */
152 - if (WaitForSingleObject(process, 10000) ==
153 - WAIT_OBJECT_0) {
154 - CloseHandle(process);
155 - return 0;
156 - }
157 - }
158 -
159 - return terminate_process_tree(process, exit_code);
160 - }
161 -
162 - CloseHandle(process);
163 - return 0;
164 - }
165 -
166 - #endif
modified compat/win32/path-utils.c
@@ -2,7 +2,6 @@
2 2
3 3 #include "../../git-compat-util.h"
4 4 #include "../../environment.h"
5 - #include "../../repository.h"
6 5
7 6 int win32_has_dos_drive_prefix(const char *path)
8 7 {
@@ -76,7 +75,7 @@ int win32_fspathncmp(const char *a, const char *b, size_t count)
76 75 } else if (is_dir_sep(*b))
77 76 return +1;
78 77
79 - diff = repo_ignore_case(the_repository) ?
78 + diff = ignore_case ?
80 79 (unsigned char)tolower(*a) - (int)(unsigned char)tolower(*b) :
81 80 (unsigned char)*a - (int)(unsigned char)*b;
82 81 if (diff)
modified compat/win32/pthread.c
@@ -66,29 +66,3 @@ int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex)
66 66 return err_win_to_posix(GetLastError());
67 67 return 0;
68 68 }
69 -
70 - int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
71 - const struct timespec *abstime)
72 - {
73 - struct timeval now;
74 - long long now_ms, deadline_ms;
75 - DWORD timeout_ms;
76 -
77 - gettimeofday(&now, NULL);
78 - now_ms = (long long)now.tv_sec * 1000 + now.tv_usec / 1000;
79 - deadline_ms = (long long)abstime->tv_sec * 1000 +
80 - abstime->tv_nsec / 1000000;
81 -
82 - if (deadline_ms <= now_ms)
83 - return ETIMEDOUT;
84 - else
85 - timeout_ms = (DWORD)(deadline_ms - now_ms);
86 -
87 - if (SleepConditionVariableCS(cond, mutex, timeout_ms) == 0) {
88 - DWORD err = GetLastError();
89 - if (err == ERROR_TIMEOUT)
90 - return ETIMEDOUT;
91 - return err_win_to_posix(err);
92 - }
93 - return 0;
94 - }
modified compat/win32/pthread.h
@@ -64,8 +64,6 @@ int win32_pthread_join(pthread_t *thread, void **value_ptr);
64 64 pthread_t pthread_self(void);
65 65
66 66 int pthread_cond_wait(pthread_cond_t *cond, pthread_mutex_t *mutex);
67 - int pthread_cond_timedwait(pthread_cond_t *cond, pthread_mutex_t *mutex,
68 - const struct timespec *abstime);
69 67
70 68 static inline void NORETURN pthread_exit(void *ret)
71 69 {
deleted compat/writev.c mode 100644
@@ -1,41 +0,0 @@
1 - #include "../git-compat-util.h"
2 - #include "../wrapper.h"
3 -
4 - ssize_t git_writev(int fd, const struct iovec *iov, int iovcnt)
5 - {
6 - size_t sum = 0;
7 -
8 - if (iovcnt <= 0) {
9 - errno = EINVAL;
10 - return -1;
11 - }
12 -
13 - /*
14 - * According to writev(3p), the syscall shall error with EINVAL in case
15 - * the sum of `iov_len` overflows `ssize_t`.
16 - */
17 - for (int i = 0; i < iovcnt; i++) {
18 - if (iov[i].iov_len > maximum_signed_value_of_type(ssize_t) ||
19 - unsigned_add_overflows(iov[i].iov_len, sum) ||
20 - iov[i].iov_len + sum > maximum_signed_value_of_type(ssize_t)) {
21 - errno = EINVAL;
22 - return -1;
23 - }
24 -
25 - sum += iov[i].iov_len;
26 - }
27 -
28 - /*
29 - * We only ever write the first non-empty vector so that we can
30 - * guarantee the call to be non-interleaving as guaranteed by POSIX.
31 - * This works just fine as callers have to loop around writev anyway.
32 - */
33 - for (int i = 0; i < iovcnt; i++) {
34 - if (!iov[i].iov_len)
35 - continue;
36 - return xwrite(fd, iov[i].iov_base, iov[i].iov_len);
37 - }
38 -
39 - /* When all iovec members were zero we ought to return 0 according to POSIX. */
40 - return 0;
41 - }
modified compat/zlib-compat.h
@@ -7,8 +7,6 @@
7 7 # define z_stream_s zng_stream_s
8 8 # define gz_header_s zng_gz_header_s
9 9
10 - # define adler32(adler, buf, len) zng_adler32(adler, buf, len)
11 -
12 10 # define crc32(crc, buf, len) zng_crc32(crc, buf, len)
13 11
14 12 # define inflate(strm, bits) zng_inflate(strm, bits)
modified config.c
@@ -235,20 +235,23 @@ static int prepare_include_condition_pattern(const struct key_value_info *kvi,
235 235 return 0;
236 236 }
237 237
238 - static int include_by_path(const struct key_value_info *kvi,
239 - const char *path,
240 - const char *cond, size_t cond_len, int icase)
238 + static int include_by_gitdir(const struct key_value_info *kvi,
239 + const struct config_options *opts,
240 + const char *cond, size_t cond_len, int icase)
241 241 {
242 242 struct strbuf text = STRBUF_INIT;
243 243 struct strbuf pattern = STRBUF_INIT;
244 244 size_t prefix;
245 245 int ret = 0;
246 + const char *git_dir;
246 247 int already_tried_absolute = 0;
247 248
248 - if (!path)
249 + if (opts->git_dir)
250 + git_dir = opts->git_dir;
251 + else
249 252 goto done;
250 253
251 - strbuf_realpath(&text, path, 1);
254 + strbuf_realpath(&text, git_dir, 1);
252 255 strbuf_add(&pattern, cond, cond_len);
253 256 ret = prepare_include_condition_pattern(kvi, &pattern, &prefix);
254 257 if (ret < 0)
@@ -281,7 +284,7 @@ again:
281 284 * which'll do the right thing
282 285 */
283 286 strbuf_reset(&text);
284 - strbuf_add_absolute_path(&text, path);
287 + strbuf_add_absolute_path(&text, git_dir);
285 288 already_tried_absolute = 1;
286 289 goto again;
287 290 }
@@ -397,15 +400,9 @@ static int include_condition_is_true(const struct key_value_info *kvi,
397 400 const struct config_options *opts = inc->opts;
398 401
399 402 if (skip_prefix_mem(cond, cond_len, "gitdir:", &cond, &cond_len))
400 - return include_by_path(kvi, opts->git_dir, cond, cond_len, 0);
403 + return include_by_gitdir(kvi, opts, cond, cond_len, 0);
401 404 else if (skip_prefix_mem(cond, cond_len, "gitdir/i:", &cond, &cond_len))
402 - return include_by_path(kvi, opts->git_dir, cond, cond_len, 1);
403 - else if (skip_prefix_mem(cond, cond_len, "worktree:", &cond, &cond_len))
404 - return include_by_path(kvi, inc->repo ? repo_get_work_tree(inc->repo) : NULL,
405 - cond, cond_len, 0);
406 - else if (skip_prefix_mem(cond, cond_len, "worktree/i:", &cond, &cond_len))
407 - return include_by_path(kvi, inc->repo ? repo_get_work_tree(inc->repo) : NULL,
408 - cond, cond_len, 1);
405 + return include_by_gitdir(kvi, opts, cond, cond_len, 1);
409 406 else if (skip_prefix_mem(cond, cond_len, "onbranch:", &cond, &cond_len))
410 407 return include_by_branch(inc, cond, cond_len);
411 408 else if (skip_prefix_mem(cond, cond_len, "hasconfig:remote.*.url:", &cond,
@@ -539,14 +536,11 @@ static inline int iskeychar(int c)
539 536 * -2 if there is no section name in the key.
540 537 *
541 538 * store_key - pointer to char* which will hold a copy of the key with
542 - * lowercase section and variable name, can be NULL to skip
543 - * allocation when only validation is needed
539 + * lowercase section and variable name
544 540 * baselen - pointer to size_t which will hold the length of the
545 541 * section + subsection part, can be NULL
546 - * quiet - when non-zero, suppress error() reports on rejection
547 542 */
548 - static int do_parse_config_key(const char *key, char **store_key,
549 - size_t *baselen_, int quiet)
543 + int git_config_parse_key(const char *key, char **store_key, size_t *baselen_)
550 544 {
551 545 size_t i, baselen;
552 546 int dot;
@@ -558,14 +552,12 @@ static int do_parse_config_key(const char *key, char **store_key,
558 552 */
559 553
560 554 if (last_dot == NULL || last_dot == key) {
561 - if (!quiet)
562 - error(_("key does not contain a section: %s"), key);
555 + error(_("key does not contain a section: %s"), key);
563 556 return -CONFIG_NO_SECTION_OR_NAME;
564 557 }
565 558
566 559 if (!last_dot[1]) {
567 - if (!quiet)
568 - error(_("key does not contain variable name: %s"), key);
560 + error(_("key does not contain variable name: %s"), key);
569 561 return -CONFIG_NO_SECTION_OR_NAME;
570 562 }
571 563
@@ -576,8 +568,7 @@ static int do_parse_config_key(const char *key, char **store_key,
576 568 /*
577 569 * Validate the key and while at it, lower case it for matching.
578 570 */
579 - if (store_key)
580 - *store_key = xmallocz(strlen(key));
571 + *store_key = xmallocz(strlen(key));
581 572
582 573 dot = 0;
583 574 for (i = 0; key[i]; i++) {
@@ -588,38 +579,24 @@ static int do_parse_config_key(const char *key, char **store_key,
588 579 if (!dot || i > baselen) {
589 580 if (!iskeychar(c) ||
590 581 (i == baselen + 1 && !isalpha(c))) {
591 - if (!quiet)
592 - error(_("invalid key: %s"), key);
582 + error(_("invalid key: %s"), key);
593 583 goto out_free_ret_1;
594 584 }
595 585 c = tolower(c);
596 586 } else if (c == '\n') {
597 - if (!quiet)
598 - error(_("invalid key (newline): %s"), key);
587 + error(_("invalid key (newline): %s"), key);
599 588 goto out_free_ret_1;
600 589 }
601 - if (store_key)
602 - (*store_key)[i] = c;
590 + (*store_key)[i] = c;
603 591 }
604 592
605 593 return 0;
606 594
607 595 out_free_ret_1:
608 - if (store_key)
609 - FREE_AND_NULL(*store_key);
596 + FREE_AND_NULL(*store_key);
610 597 return -CONFIG_INVALID_KEY;
611 598 }
612 599
613 - int git_config_parse_key(const char *key, char **store_key, size_t *baselen_)
614 - {
615 - return do_parse_config_key(key, store_key, baselen_, 0);
616 - }
617 -
618 - int git_config_key_is_valid(const char *key)
619 - {
620 - return !do_parse_config_key(key, NULL, NULL, 1);
621 - }
622 -
623 600 static int config_parse_pair(const char *key, const char *value,
624 601 struct key_value_info *kvi,
625 602 config_fn_t fn, void *data)
@@ -1235,15 +1212,6 @@ int git_config_int(const char *name, const char *value,
1235 1212 return ret;
1236 1213 }
1237 1214
1238 - unsigned int git_config_uint(const char *name, const char *value,
1239 - const struct key_value_info *kvi)
1240 - {
1241 - unsigned int ret;
1242 - if (!git_parse_uint(value, &ret))
1243 - die_bad_number(name, value, kvi);
1244 - return ret;
1245 - }
1246 -
1247 1215 int64_t git_config_int64(const char *name, const char *value,
1248 1216 const struct key_value_info *kvi)
1249 1217 {
@@ -1271,15 +1239,6 @@ ssize_t git_config_ssize_t(const char *name, const char *value,
1271 1239 return ret;
1272 1240 }
1273 1241
1274 - size_t git_config_size_t(const char *name, const char *value,
1275 - const struct key_value_info *kvi)
1276 - {
1277 - size_t ret;
1278 - if (!git_parse_size_t(value, &ret))
1279 - die_bad_number(name, value, kvi);
1280 - return ret;
1281 - }
1282 -
1283 1242 double git_config_double(const char *name, const char *value,
1284 1243 const struct key_value_info *kvi)
1285 1244 {
@@ -1474,7 +1433,7 @@ int git_config_from_blob_oid(config_fn_t fn,
1474 1433 {
1475 1434 enum object_type type;
1476 1435 char *buf;
1477 - size_t size;
1436 + unsigned long size;
1478 1437 int ret;
1479 1438
1480 1439 buf = odb_read_object(repo->objects, oid, &type, &size);
@@ -1948,18 +1907,6 @@ int git_configset_get_int(struct config_set *set, const char *key, int *dest)
1948 1907 return 1;
1949 1908 }
1950 1909
1951 - int git_configset_get_uint(struct config_set *set, const char *key, unsigned int *dest)
1952 - {
1953 - const char *value;
1954 - struct key_value_info kvi;
1955 -
1956 - if (!git_configset_get_value(set, key, &value, &kvi)) {
1957 - *dest = git_config_uint(key, value, &kvi);
1958 - return 0;
1959 - } else
1960 - return 1;
1961 - }
1962 -
1963 1910 int git_configset_get_ulong(struct config_set *set, const char *key, unsigned long *dest)
1964 1911 {
1965 1912 const char *value;
@@ -2409,13 +2356,6 @@ int repo_config_get_int(struct repository *repo,
2409 2356 return git_configset_get_int(repo->config, key, dest);
2410 2357 }
2411 2358
2412 - int repo_config_get_uint(struct repository *repo,
2413 - const char *key, unsigned int *dest)
2414 - {
2415 - git_config_check_init(repo);
2416 - return git_configset_get_uint(repo->config, key, dest);
2417 - }
2418 -
2419 2359 int repo_config_get_ulong(struct repository *repo,
2420 2360 const char *key, unsigned long *dest)
2421 2361 {
@@ -2963,24 +2903,6 @@ char *git_config_prepare_comment_string(const char *comment)
2963 2903 return prepared;
2964 2904 }
2965 2905
2966 - /*
2967 - * How long to retry acquiring config.lock when another process holds
2968 - * it. Default matches core.packedRefsTimeout; override via
2969 - * core.configLockTimeout.
2970 - */
2971 - static long config_lock_timeout_ms(struct repository *r)
2972 - {
2973 - static int configured;
2974 - static int timeout_ms = 1000;
2975 -
2976 - if (!configured) {
2977 - repo_config_get_int(r, "core.configlocktimeout", &timeout_ms);
2978 - configured = 1;
2979 - }
2980 -
2981 - return timeout_ms;
2982 - }
2983 -
2984 2906 static void validate_comment_string(const char *comment)
2985 2907 {
2986 2908 size_t leading_blanks;
@@ -3064,8 +2986,7 @@ int repo_config_set_multivar_in_file_gently(struct repository *r,
3064 2986 * The lock serves a purpose in addition to locking: the new
3065 2987 * contents of .git/config will be written into it.
3066 2988 */
3067 - fd = repo_hold_lock_file_for_update_timeout(r, &lock, config_filename, 0,
3068 - config_lock_timeout_ms(r));
2989 + fd = hold_lock_file_for_update(&lock, config_filename, 0);
3069 2990 if (fd < 0) {
3070 2991 error_errno(_("could not lock config file %s"), config_filename);
3071 2992 ret = CONFIG_NO_LOCK;
@@ -3410,9 +3331,7 @@ static int repo_config_copy_or_rename_section_in_file(
3410 3331 if (!config_filename)
3411 3332 config_filename = filename_buf = repo_git_path(r, "config");
3412 3333
3413 - out_fd = repo_hold_lock_file_for_update_timeout(r, &lock,
3414 - config_filename, 0,
3415 - config_lock_timeout_ms(r));
3334 + out_fd = hold_lock_file_for_update(&lock, config_filename, 0);
3416 3335 if (out_fd < 0) {
3417 3336 ret = error(_("could not lock config file %s"), config_filename);
3418 3337 goto out;
modified config.h
@@ -267,12 +267,6 @@ int git_config_int(const char *, const char *, const struct key_value_info *);
267 267 int64_t git_config_int64(const char *, const char *,
268 268 const struct key_value_info *);
269 269
270 - /**
271 - * Identical to `git_config_int`, but for unsigned ints.
272 - */
273 - unsigned int git_config_uint(const char *, const char *,
274 - const struct key_value_info *);
275 -
276 270 /**
277 271 * Identical to `git_config_int`, but for unsigned longs.
278 272 */
@@ -282,9 +276,6 @@ unsigned long git_config_ulong(const char *, const char *,
282 276 ssize_t git_config_ssize_t(const char *, const char *,
283 277 const struct key_value_info *);
284 278

This diff is too large to show in full - only the first part is shown.