Tags: gitgitgadget/git
Tags
status: show comparison with configured goal branch
From: Harald Nordgren <haraldnordgren@gmail.com>
"git status" on a branch that follows a remote branch compares
commits on the current branch and the remote-tracking branch it
builds upon, to show "ahead", "behind", or "diverged" status.
When working on a feature branch that tracks a remote feature branch,
but you also want to track progress relative to a goal branch (e.g.,
upstream/main), you can configure status.goalBranch to show an
additional comparison.
Add support for status.goalBranch configuration option that specifies
a remote/branch to compare against. When set, git status shows both
the comparison with the tracking branch (as before) and an additional
comparison with the configured goal branch, if it differs from the
tracking branch. The goal branch comparison appears on a separate
line after the tracking branch status, using the same format:
- "Ahead of 'upstream/main' by N commits" when purely ahead
- "Behind 'upstream/main' by N commits" when purely behind
- "Diverged from 'upstream/main' by N commits" when diverged
Example output when tracking a feature branch with status.goalBranch
set to upstream/main:
On branch feature
Your branch is ahead of 'origin/feature' by 2 commits.
(use "git push" to publish your local commits)
Ahead of 'upstream/main' by 5 commits.
The comparison is only shown when status.goalBranch is configured
and the goal branch differs from the tracking branch.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Submitted-As: https://lore.kernel.org/git/pull.2138.v8.git.git.1766666006561.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v3.git.git.1766568665.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v4.git.git.1766571587.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v5.git.git.1766572715.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v6.git.git.1766619672.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v7.git.git.1766655947789.gitgitgadget@gmail.com
status: additional comparison with goal branch
From: Harald Nordgren <haraldnordgren@gmail.com>
"git status" on a branch that follows a remote branch compares
commits on the current branch and the remote-tracking branch it
builds upon, to show "ahead" (i.e. you have built new history,
while others are not touching it), "behind" (i.e. you haven't
added any work since you were in-sync, while others have added
their work on the branch), "diverged" (i.e. you have commits
that you haven't pushed out, while others have added commits).
When you fork a branch 'feature' from the 'main' branch of the
remote, but then create 'feature' branch at the remote and push
there, while you still occasionally pull from or rebase onto
their 'main', you'd also want to know how much you have diverged
from 'main', in addition to how your 'feature' and their
'feature' compares. Currently the comparison with 'main' is not
given, making it hard to know when to start thinking about
rebasing onto the upstream default branch.
Show two sets of comparison: one with the tracking branch (as
before), and another with the upstream's default branch (what
their HEAD points to, typically 'main' or 'master'). The latter
comparison appears on a separate line after the tracking branch
status, using the same format:
- "Ahead of 'origin/main' by N commits" when purely ahead
- "Behind 'origin/main' by N commits" when purely behind
- "Diverged from 'origin/main' by N commits" when diverged
Example output when tracking a feature branch:
On branch feature
Your branch is ahead of 'origin/feature' by 2 commits.
(use "git push" to publish your local commits)
Ahead of 'origin/main' by 5 commits.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Submitted-As: https://lore.kernel.org/git/pull.2138.v7.git.git.1766655947789.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v3.git.git.1766568665.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v4.git.git.1766571587.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v5.git.git.1766572715.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2138.v6.git.git.1766619672.gitgitgadget@gmail.com
status: show default branch comparison when tracking non-default branch cc: Chris Torek chris.torek@gmail.com cc: Yee Cheng Chin ychin.macvim@gmail.com cc: "brian m. carlson" sandals@crustytoothpaste.net Harald Nordgren (6): status: show comparison with upstream default branch Simplify default branch comparison logic Use repo.settings.statusGoalBranch config for status comparison Rename default_remote to goal_branch Add warning for malformed statusGoalBranch config Change config key to status.compareBranch remote.c | 92 +++++++++++ t/t6040-tracking-info.sh | 340 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 432 insertions(+) base-commit: c4a0c88 Submitted-As: https://lore.kernel.org/git/pull.2138.v6.git.git.1766619672.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v3.git.git.1766568665.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v4.git.git.1766571587.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v5.git.git.1766572715.gitgitgadget@gmail.com
status: show default branch comparison when tracking non-default branch cc: Chris Torek chris.torek@gmail.com cc: Yee Cheng Chin ychin.macvim@gmail.com cc: "brian m. carlson" sandals@crustytoothpaste.net Harald Nordgren (5): status: show comparison with upstream default branch Simplify default branch comparison logic Use repo.settings.statusGoalBranch config for status comparison Rename default_remote to goal_branch Add warning for malformed statusGoalBranch config remote.c | 92 +++++++++++ t/t6040-tracking-info.sh | 340 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 432 insertions(+) base-commit: c4a0c88 Submitted-As: https://lore.kernel.org/git/pull.2138.v5.git.git.1766572715.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v3.git.git.1766568665.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v4.git.git.1766571587.gitgitgadget@gmail.com
status: show default branch comparison when tracking non-default branch cc: Chris Torek chris.torek@gmail.com cc: Yee Cheng Chin ychin.macvim@gmail.com cc: "brian m. carlson" sandals@crustytoothpaste.net Harald Nordgren (4): status: show comparison with upstream default branch Simplify default branch comparison logic Use repo.settings.statusGoalBranch config for status comparison Rename default_remote to goal_branch remote.c | 92 ++++++++++++ t/t6040-tracking-info.sh | 317 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 409 insertions(+) base-commit: c4a0c88 Submitted-As: https://lore.kernel.org/git/pull.2138.v4.git.git.1766571587.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v3.git.git.1766568665.gitgitgadget@gmail.com
status: show default branch comparison when tracking non-default branch cc: Chris Torek chris.torek@gmail.com cc: Yee Cheng Chin ychin.macvim@gmail.com cc: "brian m. carlson" sandals@crustytoothpaste.net Harald Nordgren (3): status: show comparison with upstream default branch Simplify default branch comparison logic Use repo.settings.statusGoalBranch config for status comparison remote.c | 93 ++++++++++++ t/t6040-tracking-info.sh | 317 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 410 insertions(+) base-commit: c4a0c88 Submitted-As: https://lore.kernel.org/git/pull.2138.v3.git.git.1766568665.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com
lockfile: add PID file for debugging stale locks
From: Paulo Casaretto <pcasaretto@gmail.com>
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 uses a
simple key-value format ("pid <value>") following the same pattern as
Git object headers, making it extensible for future metadata.
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, which
accepts per-component values similar to core.fsync:
- none: Disable for all components (default)
- all: Enable for all components
- index, config, refs, commit-graph, midx, shallow, gc, other:
Enable for specific components
Multiple components can be combined with commas:
git config core.lockfilePid index,config
Each lock file call site specifies which component it belongs to,
allowing users fine-grained control over which locks create PID files.
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>
Submitted-As: https://lore.kernel.org/git/pull.2011.v3.git.1766579053136.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2011.git.1764688047077.gitgitgadget@gmail.com
In-Reply-To: https://lore.kernel.org/git/pull.2011.v2.git.1765997966593.gitgitgadget@gmail.com
xdiff: fix outdated xpatience comments referring to "ha" member var From: Yee Cheng Chin <ychin.git@gmail.com> The `ha` member variable was refactored to separate `line_hash` and `minimal_perfect_hash` ones in 6a26019. However, there is a stale comment in xpatience.c that still refers to it. Fix the comment to make sure it is consistent with code. Signed-off-by: Yee Cheng Chin <ychin.git@gmail.com> Submitted-As: https://lore.kernel.org/git/pull.2139.git.git.1766464905719.gitgitgadget@gmail.com
status: show default branch comparison when tracking non-default branch cc: Chris Torek chris.torek@gmail.com Harald Nordgren (2): status: show comparison with upstream default branch Simplify default branch comparison logic remote.c | 83 +++++++++++++ t/t6040-tracking-info.sh | 246 +++++++++++++++++++++++++++++++++++++++ 2 files changed, 329 insertions(+) base-commit: c4a0c88 Submitted-As: https://lore.kernel.org/git/pull.2138.v2.git.git.1766530448.gitgitgadget@gmail.com In-Reply-To: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com
status: show default branch comparison when tracking non-default branch
From: Harald Nordgren <haraldnordgren@gmail.com>
When a branch tracks a non-default remote branch (e.g.,
origin/feature), git status now also displays how the branch
compares to the default branch (origin/main or upstream/main).
This helps users understand if their branch has drifted from the
main development line even when it's in sync with its tracking
branch.
The comparison is shown as a separate line after the tracking
branch status:
- "Ahead of 'origin/main' by N commits" when purely ahead
- "Behind 'origin/main' by N commits" when purely behind
- "Diverged from 'origin/main' by N commits" when diverged
Example output when tracking a feature branch:
On branch feature
Your branch is ahead of 'origin/feature' by 2 commits.
(use "git push" to publish your local commits)
Ahead of 'origin/main' by 5 commits.
The default branch is determined dynamically by checking:
1. refs/remotes/upstream/HEAD (if upstream remote exists)
2. refs/remotes/origin/HEAD (fallback)
This works with any default branch name (main, master, develop,
etc.) as long as the symbolic ref is configured. The comparison
is also shown when the branch is up-to-date with its tracking
branch but differs from the default branch.
Signed-off-by: Harald Nordgren <haraldnordgren@gmail.com>
Submitted-As: https://lore.kernel.org/git/pull.2138.git.git.1766451217075.gitgitgadget@gmail.com
PreviousNext