(cmd *cobra.Command, args []string)
| 35 | ) |
| 36 | |
| 37 | func trackCommand(cmd *cobra.Command, args []string) { |
| 38 | requireGitVersion() |
| 39 | setupWorkingCopy() |
| 40 | |
| 41 | if trackDryRunFlag { |
| 42 | trackNoModifyAttrsFlag = true |
| 43 | } |
| 44 | |
| 45 | if !cfg.Os.Bool("GIT_LFS_TRACK_NO_INSTALL_HOOKS", false) { |
| 46 | installHooks(false) |
| 47 | } |
| 48 | |
| 49 | if len(args) == 0 { |
| 50 | listPatterns() |
| 51 | return |
| 52 | } |
| 53 | |
| 54 | if trackJSONFlag { |
| 55 | Exit(tr.Tr.Get("--json option can't be combined with arguments")) |
| 56 | } |
| 57 | |
| 58 | mp := gitattr.NewMacroProcessor() |
| 59 | |
| 60 | // Intentionally do _not_ consider global- and system-level |
| 61 | // .gitattributes here. Parse them still to expand any macros. |
| 62 | git.GetSystemAttributePaths(mp, cfg.Os) |
| 63 | git.GetRootAttributePaths(mp, cfg.Git) |
| 64 | knownPatterns := git.GetAttributePaths(mp, cfg.LocalWorkingDir(), cfg.LocalGitDir()) |
| 65 | lineEnd := getAttributeLineEnding(knownPatterns) |
| 66 | if len(lineEnd) == 0 { |
| 67 | lineEnd = gitLineEnding(cfg.Git) |
| 68 | } |
| 69 | |
| 70 | wd, _ := tools.Getwd() |
| 71 | wd = tools.ResolveSymlinks(wd) |
| 72 | relpath, err := filepath.Rel(cfg.LocalWorkingDir(), wd) |
| 73 | if err != nil { |
| 74 | Exit(tr.Tr.Get("Current directory %q outside of Git working directory %q.", wd, cfg.LocalWorkingDir())) |
| 75 | } |
| 76 | |
| 77 | changedAttribLines := make(map[string]string) |
| 78 | var readOnlyPatterns []string |
| 79 | var writeablePatterns []string |
| 80 | ArgsLoop: |
| 81 | for _, unsanitizedPattern := range args { |
| 82 | pattern := tools.TrimCurrentPrefix(cleanRootPath(unsanitizedPattern)) |
| 83 | |
| 84 | // Generate the new / changed attrib line for merging |
| 85 | var encodedArg string |
| 86 | if trackFilenameFlag { |
| 87 | encodedArg = escapeGlobCharacters(pattern) |
| 88 | pattern = escapeGlobCharacters(pattern) |
| 89 | } else { |
| 90 | encodedArg = escapeAttrPattern(pattern) |
| 91 | } |
| 92 | |
| 93 | if !trackNoModifyAttrsFlag { |
| 94 | for _, known := range knownPatterns { |
nothing calls this directly
no test coverage detected