From 215e49725187889eeeb79e60be28eec033fe5789 Mon Sep 17 00:00:00 2001 From: "brian m. carlson" Date: Thu, 26 Oct 2023 13:52:09 +0000 Subject: [PATCH] track: don't modify `.gitattributes` with `--dry-run` In `--dry-run` mode, we're documented to not modify the disk, which means users will not expect us to be modifying `.gitattributes`. Fix this by setting the `--no-modify-attrs` flag implicitly if `--dry-run` is set. --- commands/command_track.go | 4 ++++ t/t-track-attrs.sh | 17 +++++++++++++++++ 2 files changed, 21 insertions(+) diff --git a/commands/command_track.go b/commands/command_track.go index dcc70c34..8153fae8 100644 --- a/commands/command_track.go +++ b/commands/command_track.go @@ -39,6 +39,10 @@ func trackCommand(cmd *cobra.Command, args []string) { requireGitVersion() setupWorkingCopy() + if trackDryRunFlag { + trackNoModifyAttrsFlag = true + } + if !cfg.Os.Bool("GIT_LFS_TRACK_NO_INSTALL_HOOKS", false) { installHooks(false) } diff --git a/t/t-track-attrs.sh b/t/t-track-attrs.sh index ad9d40f9..9f70a46f 100755 --- a/t/t-track-attrs.sh +++ b/t/t-track-attrs.sh @@ -35,3 +35,20 @@ begin_test "track (--no-modify-attrs)" ) end_test +begin_test "track (--dry-run)" +( + set -e + + reponame="track-dry-run" + git init "$reponame" + cd "$reponame" + + git lfs track --dry-run "*.dat" + + echo "contents" > a.dat + git add a.dat + + git commit -m "add a.dat" + refute_pointer "main" "a.dat" +) +end_test