From b678bb728331fbc575b8eee7948f08eec167d951 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2026 10:37:26 -0400 Subject: [PATCH 1/2] t0014: factor out choice of deprecated commands We have a few tests related to aliasing deprecated commands which use "whatchanged" and "pack-redundant", as these are the only two deprecated commands we have. Let's pull those names into variables so that we can refactor the tests without relying on the specific names. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t0014-alias.sh | 23 +++++++++++++---------- 1 file changed, 13 insertions(+), 10 deletions(-) diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh index 5144b0effd..9d7c737355 100755 --- a/t/t0014-alias.sh +++ b/t/t0014-alias.sh @@ -27,17 +27,20 @@ test_expect_success 'looping aliases - internal execution' ' test_grep "^fatal: alias loop detected: expansion of" output ' +deprecated1=whatchanged +deprecated2=pack-redundant + test_expect_success 'looping aliases - deprecated builtins' ' - test_config alias.whatchanged pack-redundant && - test_config alias.pack-redundant whatchanged && + test_config alias.$deprecated1 $deprecated2 && + test_config alias.$deprecated2 $deprecated1 && cat >expect <<-EOF && - ${SQ}whatchanged${SQ} is aliased to ${SQ}pack-redundant${SQ} - ${SQ}pack-redundant${SQ} is aliased to ${SQ}whatchanged${SQ} - fatal: alias loop detected: expansion of ${SQ}whatchanged${SQ} does not terminate: - whatchanged <== - pack-redundant ==> + ${SQ}$deprecated1${SQ} is aliased to ${SQ}$deprecated2${SQ} + ${SQ}$deprecated2${SQ} is aliased to ${SQ}$deprecated1${SQ} + fatal: alias loop detected: expansion of ${SQ}$deprecated1${SQ} does not terminate: + $deprecated1 <== + $deprecated2 ==> EOF - test_must_fail git whatchanged -h 2>actual && + test_must_fail git $deprecated1 -h 2>actual && test_cmp expect actual ' @@ -90,8 +93,8 @@ test_expect_success 'can alias-shadow via two deprecated builtins' ' # some git(1) commands will fail... (see above) test_might_fail git status -h >expect && test_file_not_empty expect && - test_might_fail git -c alias.whatchanged=pack-redundant \ - -c alias.pack-redundant=status whatchanged -h >actual && + test_might_fail git -c alias.$deprecated1=$deprecated2 \ + -c alias.$deprecated2=status $deprecated1 -h >actual && test_cmp expect actual ' From bc57ecb91537c776d0f34233746b09a88000bd26 Mon Sep 17 00:00:00 2001 From: Jeff King Date: Tue, 28 Jul 2026 10:38:45 -0400 Subject: [PATCH 2/2] t0014: generate deprecated command names dynamically We have a few tests related to aliasing of deprecated commands. They use whatchanged and pack-redundant because those are the only two deprecated commands we have. Eventually those commands will be removed, at which point these tests will be checking nothing useful (they'll just be regular aliases, which we already cover in other tests). We could remove them at that point, but the code to handle deprecated commands will still remain. We probably do want to keep the tests around for the eventual day that we deprecate more commands. So let's ask Git for its list of deprecated commands, and if we don't have any, skip those tests. This also prevents an annoying corner case when your build directory contains old build products. Right now those commands are marked as deprecated builtins and treated specially; we allow aliases and never look for them as dashed external commands. But after they are removed, they aren't special anymore. If your directory happens to contain hardlinks from the build of an older version, that confuses Git: it sees the old hardlinks in place, thinks those are actual external commands, and refuses to allow aliasing. You can see that today like this: make make WITH_BREAKING_CHANGES=1 test The first "make" creates git-whatchanged as a hardlink to Git, and the second does not clean it up (it doesn't know about the whatchanged command at all anymore). t0014 fails because Git won't create an alias to the "external" whatchanged command. Signed-off-by: Jeff King Signed-off-by: Junio C Hamano --- t/t0014-alias.sh | 13 +++++++++---- 1 file changed, 9 insertions(+), 4 deletions(-) diff --git a/t/t0014-alias.sh b/t/t0014-alias.sh index 9d7c737355..cbc447b481 100755 --- a/t/t0014-alias.sh +++ b/t/t0014-alias.sh @@ -27,10 +27,15 @@ test_expect_success 'looping aliases - internal execution' ' test_grep "^fatal: alias loop detected: expansion of" output ' -deprecated1=whatchanged -deprecated2=pack-redundant +test_expect_success 'detect deprecated commands' ' + git --list-cmds=deprecated >deprecated && + if read deprecated1 && read deprecated2 + then + test_set_prereq HAVE_DEPRECATED + fi expect <<-EOF && @@ -89,7 +94,7 @@ test_expect_success 'can alias-shadow deprecated builtins' ' done ' -test_expect_success 'can alias-shadow via two deprecated builtins' ' +test_expect_success HAVE_DEPRECATED 'can alias-shadow via two deprecated builtins' ' # some git(1) commands will fail... (see above) test_might_fail git status -h >expect && test_file_not_empty expect &&