Skip to content

Commit feea3f6

Browse files
jeffhostetlerderrickstolee
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 <[email protected]> Signed-off-by: Derrick Stolee <[email protected]>
1 parent c105654 commit feea3f6

File tree

2 files changed

+14
-8
lines changed

2 files changed

+14
-8
lines changed

builtin/commit.c

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

11121112
/*
11131113
* If the user did not give a "--[no]-ahead-behind" command
1114-
* line argument, then we inherit the a/b config setting.
1115-
* If is not set, then we inherit _FULL for backwards
1116-
* compatibility.
1114+
* line argument *AND* we will print in a human-readable format
1115+
* (short, long etc.) then we inherit from the status.aheadbehind
1116+
* config setting. In all other cases (and porcelain V[12] formats
1117+
* in particular), we inherit _FULL for backwards compatibility.
11171118
*/
1118-
if (s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
1119+
if (use_deferred_config &&
1120+
s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
11191121
s->ahead_behind_flags = status_deferred_config.ahead_behind;
11201122

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