Skip to content

Commit ffc0fb8

Browse files
jeffhostetlerdscho
authored andcommitted
status: ignore status.aheadbehind in porcelain formats
Teach porcelain V[12] formats to ignore the status.aheadbehind config setting. They only respect the --[no-]ahead-behind command line argument. This is for backwards compatibility with existing scripts. Signed-off-by: Jeff Hostetler <jeffhost@microsoft.com>
1 parent dfb2016 commit ffc0fb8

3 files changed

Lines changed: 15 additions & 10 deletions

File tree

Documentation/config/status.txt

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ status.branch::
1515
status.aheadBehind::
1616
EXPERIMENTAL, Set to true to enable --ahead-behind and false to
1717
enable --no-ahead-behind by default in linkgit:git-status[1] for
18-
all status formats. Defaults to true. Changing this may
19-
break backwards compatibility for existing scripts.
18+
non-porcelain status formats. Defaults to true.
2019

2120
status.displayCommentPrefix::
2221
If set to true, linkgit:git-status[1] will insert a comment

builtin/commit.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1154,11 +1154,13 @@ static void finalize_deferred_config(struct wt_status *s)
11541154

11551155
/*
11561156
* If the user did not give a "--[no]-ahead-behind" command
1157-
* line argument, then we inherit the a/b config setting.
1158-
* If is not set, then we inherit _FULL for backwards
1159-
* compatibility.
1157+
* line argument *AND* we will print in a human-readable format
1158+
* (short, long etc.) then we inherit from the status.aheadbehind
1159+
* config setting. In all other cases (and porcelain V[12] formats
1160+
* in particular), we inherit _FULL for backwards compatibility.
11601161
*/
1161-
if (s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
1162+
if (use_deferred_config &&
1163+
s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
11621164
s->ahead_behind_flags = status_deferred_config.ahead_behind;
11631165

11641166
if (s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)

t/t7064-wtstatus-pv2.sh

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -436,10 +436,6 @@ test_expect_success 'verify --[no-]ahead-behind with V2 format' '
436436
git status --no-ahead-behind --porcelain=v2 --branch --untracked-files=all >actual &&
437437
test_cmp expect actual &&
438438
439-
# Confirmat that "status.aheadbehind" works on V2 format.
440-
git -c status.aheadbehind=false status --porcelain=v2 --branch --untracked-files=all >actual &&
441-
test_cmp expect actual &&
442-
443439
# Confirm --ahead-behind reports traditional branch.ab with 1/0.
444440
cat >expect <<-EOF &&
445441
# branch.oid $HUF
@@ -449,6 +445,14 @@ test_expect_success 'verify --[no-]ahead-behind with V2 format' '
449445
EOF
450446
451447
git status --ahead-behind --porcelain=v2 --branch --untracked-files=all >actual &&
448+
test_cmp expect actual &&
449+
450+
# Confirm that "status.aheadbehind" DOES NOT work on V2 format.
451+
git -c status.aheadbehind=false status --porcelain=v2 --branch --untracked-files=all >actual &&
452+
test_cmp expect actual &&
453+
454+
# Confirm that "status.aheadbehind" DOES NOT work on V2 format.
455+
git -c status.aheadbehind=true status --porcelain=v2 --branch --untracked-files=all >actual &&
452456
test_cmp expect actual
453457
)
454458
'

0 commit comments

Comments
 (0)