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> Signed-off-by: Derrick Stolee <dstolee@microsoft.com> Signed-off-by: Junio C Hamano <gitster@pobox.com>
Jeff Hostetler committed
Jun 18, 2019 at 13:21 UTC
fb4db1a298b75536a861485bda27e3f1e098d6f6
2 files changed
+14
-8
builtin/commit.c
+6
-4
@@ -1111,11 +1111,13 @@ static void finalize_deferred_config(struct wt_status *s)
1111
1112
/*
1113
* 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.
1118
*/
1118
- if (s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
1119
+ if (use_deferred_config &&
1120
+ s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
1121
s->ahead_behind_flags = status_deferred_config.ahead_behind;
1122
1123
if (s->ahead_behind_flags == AHEAD_BEHIND_UNSPECIFIED)
t/t7064-wtstatus-pv2.sh
+8
-4
@@ -436,10 +436,6 @@ test_expect_success 'verify --[no-]ahead-behind with V2 format' '
436
git status --no-ahead-behind --porcelain=v2 --branch --untracked-files=all >actual &&
437
test_cmp expect actual &&
438
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
-
439
# Confirm --ahead-behind reports traditional branch.ab with 1/0.
440
cat >expect <<-EOF &&
441
# branch.oid $HUF
@@ -449,6 +445,14 @@ test_expect_success 'verify --[no-]ahead-behind with V2 format' '
445
EOF
446
447
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 &&
456
test_cmp expect actual
457
)
458
'