Skip to content

Commit 94e7e1f

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 f098615 commit 94e7e1f

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
@@ -1157,11 +1157,13 @@ static void finalize_deferred_config(struct wt_status *s)
11571157

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

11671169
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)