git/Documentation
Paulo Casaretto dbdcab6b89 lockfile: add PID file for debugging stale locks
When a lock file is held, it can be helpful to know which process owns
it, especially when debugging stale locks left behind by crashed
processes. Add an optional feature that creates a companion PID file
alongside each lock file, containing the PID of the lock holder.

For a lock file "foo.lock", the PID file is named "foo~pid.lock". The
tilde character is forbidden in refnames and allowed in Windows
filenames, which guarantees no collision with the refs namespace
(e.g., refs "foo" and "foo~pid" cannot both exist). The file contains
a single line in the format "pid <value>" followed by a newline.

The PID file is created when a lock is acquired (if enabled), and
automatically cleaned up when the lock is released (via commit or
rollback). The file is registered as a tempfile so it gets cleaned up
by signal and atexit handlers if the process terminates abnormally.

When a lock conflict occurs, the code checks for an existing PID file
and, if found, uses kill(pid, 0) to determine if the process is still
running. This allows providing context-aware error messages:

  Lock is held by process 12345. Wait for it to finish, or remove
  the lock file to continue.

Or for a stale lock:

  Lock was held by process 12345, which is no longer running.
  Remove the stale lock file to continue.

The feature is controlled via core.lockfilePid configuration (boolean).
Defaults to false. When enabled, PID files are created for all lock
operations.

Existing PID files are always read when displaying lock errors,
regardless of the core.lockfilePid setting. This ensures helpful
diagnostics even when the feature was previously enabled and later
disabled.

Signed-off-by: Paulo Casaretto <pcasaretto@gmail.com>
Signed-off-by: Junio C Hamano <gitster@pobox.com>
2026-01-22 12:15:46 -08:00
..
RelNotes The 10th batch 2025-12-17 14:11:53 +09:00
config lockfile: add PID file for debugging stale locks 2026-01-22 12:15:46 -08:00
howto meson: make GIT_HTML_PATH configurable 2025-11-06 09:58:56 -08:00
includes
mergetools doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
technical Merge branch 'en/xdiff-cleanup-2' 2025-12-05 14:49:56 +09:00
.gitignore
BreakingChanges.adoc refs/files: deprecate writing symrefs as symbolic links 2025-10-15 09:11:08 -07:00
CodingGuidelines Documentation: note styling for bit fields 2025-08-26 15:46:03 -07:00
DecisionMaking.adoc
Makefile Merge branch 'en/xdiff-cleanup-2' 2025-12-05 14:49:56 +09:00
MyFirstContribution.adoc MyFirstContribution: add note on confirming patches 2025-10-27 09:09:53 -07:00
MyFirstObjectWalk.adoc Merge branch 'jc/you-still-use-whatchanged' 2025-06-25 14:07:35 -07:00
ReviewingGuidelines.adoc
SubmittingPatches Merge branch 'cc/doc-submitting-patches-with-ai' 2025-11-04 07:48:06 -08:00
ToolsForGit.adoc
asciidoc.conf.in doc: git-log: convert rev list options to new doc format 2025-07-07 13:45:00 -07:00
asciidoctor-extensions.rb.in doc: git-log: convert rev list options to new doc format 2025-07-07 13:45:00 -07:00
blame-options.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
build-docdep.perl
cat-texi.perl
cmd-list.sh
config.adoc Merge branch 'jc/doc-includeif-hasconfig-remote-url-fix' into maint-2.51 2025-10-15 10:29:34 -07:00
date-formats.adoc
diff-algorithm-option.adoc blame: make diff algorithm configurable 2025-11-17 09:31:59 -08:00
diff-context-options.adoc add-patch: add diff.context command line overrides 2025-07-29 08:52:45 -07:00
diff-format.adoc doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
diff-generate-patch.adoc Merge branch 'ma/doc-diff-cc-headers' 2025-06-18 13:53:34 -07:00
diff-options.adoc blame: make diff algorithm configurable 2025-11-17 09:31:59 -08:00
doc-diff
docbook-xsl.css
docbook.xsl
docinfo-html.in
everyday.adoco
fetch-options.adoc doc: convert git pull to synopsis style 2025-11-19 15:00:42 -08:00
fix-texi.sh
for-each-ref-options.adoc Merge branch 'ja/doc-lint-sections-and-synopsis' 2025-08-25 14:22:02 -07:00
fsck-msgids.adoc Merge branch 'bc/sha1-256-interop-01' 2025-10-22 11:38:58 -07:00
generate-mergetool-list.sh
git-add.adoc add-patch: fully document option P 2025-10-21 14:35:44 -07:00
git-am.adoc Merge branch 'kh/doc-committer-date-is-author-date' 2025-12-05 14:49:57 +09:00
git-annotate.adoc
git-apply.adoc apply docs: clarify wording for --intent-to-add 2025-07-07 06:41:11 -07:00
git-archimport.adoc
git-archive.adoc
git-backfill.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-bisect-lk2009.adoc
git-bisect.adoc bisect: update usage and docs to match each other 2025-10-28 15:41:42 -07:00
git-blame.adoc blame: make diff algorithm configurable 2025-11-17 09:31:59 -08:00
git-branch.adoc
git-bugreport.adoc
git-bundle.adoc
git-cat-file.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-check-attr.adoc doc: check for absence of multiple terms in each entry of desc list 2025-08-11 14:16:04 -07:00
git-check-ignore.adoc doc: check for absence of multiple terms in each entry of desc list 2025-08-11 14:16:04 -07:00
git-check-mailmap.adoc
git-check-ref-format.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-checkout-index.adoc
git-checkout.adoc doc: git-checkout: fix placeholder markup 2025-10-28 12:01:23 -07:00
git-cherry-pick.adoc
git-cherry.adoc
git-citool.adoc
git-clean.adoc
git-clone.adoc Merge branch 'kr/clone-synopsis-fix' into maint-2.51 2025-10-15 10:29:32 -07:00
git-column.adoc doc: column: fix blank lines around block delimiters 2025-06-01 17:20:16 -07:00
git-commit-graph.adoc commit-graph: add new config for changed-paths & recommend it in scalar 2025-10-22 10:40:11 -07:00
git-commit-tree.adoc
git-commit.adoc doc: commit: link to git-status(1) on all format options 2025-11-14 08:56:35 -08:00
git-config.adoc Merge branch 'kh/doc-continued-paragraph-fix' 2025-10-20 14:12:17 -07:00
git-count-objects.adoc Merge branch 'ds/doc-count-objects-fix' into maint-2.51 2025-10-14 13:40:54 -07:00
git-credential-cache--daemon.adoc
git-credential-cache.adoc
git-credential-store.adoc
git-credential.adoc
git-cvsexportcommit.adoc
git-cvsimport.adoc
git-cvsserver.adoc
git-daemon.adoc
git-describe.adoc
git-diagnose.adoc
git-diff-files.adoc
git-diff-index.adoc
git-diff-pairs.adoc
git-diff-tree.adoc
git-diff.adoc
git-difftool.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-fast-export.adoc fast-(import|export): improve on commit signature output format 2025-07-09 16:08:29 -07:00
git-fast-import.adoc fast-import: add 'strip-if-invalid' mode to --signed-commits=<mode> 2025-11-26 08:43:44 -08:00
git-fetch-pack.adoc
git-fetch.adoc doc: convert git fetch to synopsis style 2025-11-19 15:00:37 -08:00
git-filter-branch.adoc
git-fmt-merge-msg.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-for-each-ref.adoc Merge branch 'ja/doc-lint-sections-and-synopsis' 2025-08-25 14:22:02 -07:00
git-for-each-repo.adoc
git-format-patch.adoc Merge branch 'js/doc-sending-patch-via-thunderbird' 2025-09-02 08:21:26 -07:00
git-fsck-objects.adoc
git-fsck.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-fsmonitor--daemon.adoc
git-gc.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-get-tar-commit-id.adoc
git-grep.adoc
git-gui.adoc
git-hash-object.adoc
git-help.adoc
git-hook.adoc
git-http-backend.adoc
git-http-fetch.adoc doc: check for absence of multiple terms in each entry of desc list 2025-08-11 14:16:04 -07:00
git-http-push.adoc
git-imap-send.adoc docs: explain how to use `git imap-send --list` command to get a list of available folders 2025-07-22 08:49:15 -07:00
git-index-pack.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-init-db.adoc
git-init.adoc breaking-changes: switch default branch to main 2025-09-10 13:34:58 -07:00
git-instaweb.adoc
git-interpret-trailers.adoc doc: interpret-trailers: close all pairs of single quotes 2025-08-22 11:12:27 -07:00
git-last-modified.adoc last-modified: new subcommand to show when files were last modified 2025-08-28 16:44:58 -07:00
git-log.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-ls-files.adoc
git-ls-remote.adoc
git-ls-tree.adoc
git-mailinfo.adoc
git-mailsplit.adoc
git-maintenance.adoc maintenance: add 'is-needed' subcommand 2025-11-10 09:28:48 -08:00
git-merge-base.adoc
git-merge-file.adoc
git-merge-index.adoc
git-merge-one-file.adoc
git-merge-tree.adoc Merge branch 'en/doc-merge-tree-describe-merge-base' 2025-10-10 12:51:46 -07:00
git-merge.adoc Merge branch 'ts/merge-orig-head-doc-fix' 2025-07-14 11:19:28 -07:00
git-mergetool--lib.adoc
git-mergetool.adoc
git-mktag.adoc
git-mktree.adoc
git-multi-pack-index.adoc Merge branch 'kh/doc-markup-fixes' into maint-2.51 2025-10-15 10:29:33 -07:00
git-mv.adoc
git-name-rev.adoc
git-notes.adoc
git-p4.adoc doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
git-pack-objects.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-pack-redundant.adoc
git-pack-refs.adoc doc: pack-refs: factor out common options 2025-09-19 10:02:56 -07:00
git-patch-id.adoc doc: patch-id: convert to the modern synopsis style 2025-10-13 08:53:13 -07:00
git-prune-packed.adoc
git-prune.adoc
git-pull.adoc Merge branch 'je/doc-pull' 2025-12-14 17:04:37 +09:00
git-push.adoc doc: convert git push to synopsis style 2025-11-19 15:00:45 -08:00
git-quiltimport.adoc
git-range-diff.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-read-tree.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-rebase.adoc Merge branch 'kh/doc-committer-date-is-author-date' 2025-12-05 14:49:57 +09:00
git-receive-pack.adoc
git-reflog.adoc builtin/reflog: implement subcommand to write new entries 2025-08-06 07:36:30 -07:00
git-refs.adoc Merge branch 'ms/refs-optimize' 2025-10-02 12:26:12 -07:00
git-remote-ext.adoc
git-remote-fd.adoc
git-remote-helpers.adoco
git-remote.adoc
git-repack.adoc Merge branch 'ds/path-walk-2' 2025-06-17 10:44:38 -07:00
git-replace.adoc
git-replay.adoc Documentation/git-replay.adoc: fix errors around revision range 2025-11-28 23:06:46 -08:00
git-repo.adoc repo: add -z as an alias for --format=nul to git-repo-structure 2025-12-05 11:39:19 +09:00
git-request-pull.adoc
git-rerere.adoc
git-reset.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-restore.adoc Merge branch 'lm/add-p-context' 2025-08-04 08:10:33 -07:00
git-rev-list.adoc
git-rev-parse.adoc Merge branch 'bc/sha1-256-interop-01' 2025-10-22 11:38:58 -07:00
git-revert.adoc
git-rm.adoc
git-send-email.adoc doc: send-email: fix broken list continuation 2025-12-09 07:27:13 +09:00
git-send-pack.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-sh-i18n--envsubst.adoc
git-sh-i18n.adoc
git-sh-setup.adoc
git-shell.adoc
git-shortlog.adoc doc: fix accidental literal blocks 2025-10-10 07:56:09 -07:00
git-show-branch.adoc
git-show-index.adoc
git-show-ref.adoc
git-show.adoc
git-sparse-checkout.adoc Merge branch 'ds/sparse-checkout-clean' 2025-10-28 10:29:09 -07:00
git-stage.adoc
git-stash.adoc doc: convert git-stash.adoc to synopis style 2025-10-05 16:09:03 -07:00
git-status.adoc
git-stripspace.adoc
git-submodule.adoc Merge branch 'ja/doc-lint-sections-and-synopsis' 2025-08-25 14:22:02 -07:00
git-svn.adoc doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
git-switch.adoc builtin: unmark git-switch and git-restore as experimental 2025-07-28 14:24:03 -07:00
git-symbolic-ref.adoc
git-tag.adoc Merge branch 'cc/fast-import-strip-signed-tags' 2025-10-28 10:29:09 -07:00
git-tools.adoc
git-unpack-file.adoc
git-unpack-objects.adoc
git-update-index.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-update-ref.adoc
git-update-server-info.adoc
git-upload-archive.adoc
git-upload-pack.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
git-var.adoc
git-verify-commit.adoc
git-verify-pack.adoc
git-verify-tag.adoc
git-version.adoc
git-web--browse.adoc
git-whatchanged.adoc whatchanged: remove not-even-shorter clause 2025-09-17 13:47:24 -07:00
git-worktree.adoc doc: convert git worktree to synopsis style 2025-10-05 16:09:03 -07:00
git-write-tree.adoc
git.adoc Merge branch 'js/progress-delay-fix' into maint-2.51 2025-10-14 13:40:54 -07:00
gitattributes.adoc
gitcli.adoc doc: clarify command equivalence comment 2025-11-04 09:25:51 -08:00
gitcore-tutorial.adoc
gitcredentials.adoc Merge branch 'mh/doc-credential-url-prefix' into maint-2.51 2025-10-15 10:29:35 -07:00
gitcvs-migration.adoc
gitdatamodel.adoc doc: remove stray text in Git data model 2025-12-03 00:17:07 -08:00
gitdiffcore.adoc
giteveryday.adoc
gitfaq.adoc
gitformat-bundle.adoc
gitformat-chunk.adoc
gitformat-commit-graph.adoc
gitformat-index.adoc
gitformat-loose.adoc docs: add documentation for loose objects 2025-10-09 17:46:14 -07:00
gitformat-pack.adoc docs: improve ambiguous areas of pack format documentation 2025-10-09 17:46:14 -07:00
gitformat-signature.adoc
gitglossary.adoc
githooks.adoc doc: join default pre-commit paragraphs 2025-12-08 22:20:14 +09:00
gitignore.adoc doc: document backslash in gitignore patterns 2025-10-29 09:17:21 -07:00
gitk.adoc Merge branch 'js/doc-gitk-history' into maint-2.51 2025-10-14 13:40:53 -07:00
gitmailmap.adoc
gitmodules.adoc
gitnamespaces.adoc
gitpacking.adoc
gitprotocol-capabilities.adoc
gitprotocol-common.adoc
gitprotocol-http.adoc doc: clarify server behavior for invalid 'want' lines in HTTP protocol 2025-11-06 09:45:38 -08:00
gitprotocol-pack.adoc
gitprotocol-v2.adoc promisor-remote: allow a server to advertise more fields 2025-09-08 10:30:54 -07:00
gitremote-helpers.adoc Merge branch 'bs/remote-helpers-doc-markup-fix' 2025-07-14 11:19:22 -07:00
gitrepository-layout.adoc
gitrevisions.adoc
gitsubmodules.adoc doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
gittutorial-2.adoc
gittutorial.adoc
gitweb.adoc
gitweb.conf.adoc doc: test linkgit macros for well-formedness 2025-08-11 14:16:03 -07:00
gitworkflows.adoc
glossary-content.adoc doc: add an explanation of Git's data model 2025-11-12 12:21:15 -08:00
i18n.adoc
install-doc-quick.sh
install-webdoc.sh
line-range-format.adoc doc: git-log: convert line range format to new doc format 2025-07-07 13:45:00 -07:00
line-range-options.adoc doc: git-log: convert line range options to new doc format 2025-07-07 13:45:00 -07:00
lint-delimited-sections.perl doc: check well-formedness of delimited sections 2025-08-11 14:16:03 -07:00
lint-documentation-style.perl doc lint: check that synopsis manpages have synopsis inlines 2025-08-11 14:16:04 -07:00
lint-fsck-msgids.perl
lint-gitlink.perl doc: test linkgit macros for well-formedness 2025-08-11 14:16:03 -07:00
lint-man-end-blurb.perl
lint-man-section-order.perl
lint-manpages.sh
manpage-bold-literal.xsl
manpage-normal.xsl
manpage.xsl
merge-options.adoc doc: convert git pull to synopsis style 2025-11-19 15:00:42 -08:00
merge-strategies.adoc
meson.build Merge branch 'je/doc-data-model' 2025-11-30 18:31:40 -08:00
object-format-disclaimer.adoc
pack-refs-options.adoc doc: pack-refs: factor out common options 2025-09-19 10:02:56 -07:00
pretty-formats.adoc Merge branch 'ja/doc-markup-attached-paragraph-fix' into maint-2.51 2025-10-15 10:29:35 -07:00
pretty-options.adoc doc: do not break sentences into "lego" pieces 2025-10-05 16:10:53 -07:00
pull-fetch-param.adoc doc: pull-fetch-param typofix 2025-11-24 10:55:48 -08:00
ref-reachability-filters.adoc
ref-storage-format.adoc
rerere-options.adoc
rev-list-description.adoc doc: git-log convert rev-list-description to new doc format 2025-07-07 13:45:00 -07:00
rev-list-options.adoc Merge branch 'ja/doc-git-log-markup' 2025-07-21 09:14:28 -07:00
revisions.adoc
scalar.adoc doc: check for absence of the form --[no-]parameter 2025-08-11 14:16:04 -07:00
sequencer.adoc
signoff-option.adoc
texi.xsl
trace2-target-values.adoc
transfer-data-leaks.adoc
urls-remotes.adoc doc: convert git pull to synopsis style 2025-11-19 15:00:42 -08:00
urls.adoc
user-manual.adoc config: drop `git_config()` wrapper 2025-07-23 08:15:18 -07:00