{"record":{"id":"701b43ba16490ed9","repo":"jesseduffield/lazygit","slug":"nested-rename-found","errorCode":null,"errorMessage":"Nested rename found","messagePattern":"Nested rename found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"info","filePath":"pkg/commands/git_commands/working_tree.go","lineNumber":116,"sourceCode":"\tvar beforeFile *models.File\n\tvar afterFile *models.File\n\tfor _, f := range filesWithoutRenames {\n\t\tif f.Path == file.PreviousPath {\n\t\t\tbeforeFile = f\n\t\t}\n\n\t\tif f.Path == file.Path {\n\t\t\tafterFile = f\n\t\t}\n\t}\n\n\tif beforeFile == nil || afterFile == nil {\n\t\treturn nil, nil, errors.New(\"Could not find deleted file or new file for file rename\")\n\t}\n\n\tif beforeFile.IsRename() || afterFile.IsRename() {\n\t\t// probably won't happen but we want to ensure we don't get an infinite loop\n\t\treturn nil, nil, errors.New(\"Nested rename found\")\n\t}\n\n\treturn beforeFile, afterFile, nil\n}\n\n// DiscardAllFileChanges directly\nfunc (self *WorkingTreeCommands) DiscardAllFileChanges(file *models.File) error {\n\tif file.IsRename() {\n\t\tbeforeFile, afterFile, err := self.BeforeAndAfterFileForRename(file)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := self.DiscardAllFileChanges(beforeFile); err != nil {\n\t\t\treturn err\n\t\t}\n\n\t\tif err := self.DiscardAllFileChanges(afterFile); err != nil {","sourceCodeStart":98,"sourceCodeEnd":134,"githubUrl":"https://github.com/jesseduffield/lazygit/blob/c477a2959b229fbf3284be0d4d2904ab61ec3c94/pkg/commands/git_commands/working_tree.go#L98-L134","documentation":"Defensive recursion guard in BeforeAndAfterFileForRename: after expanding a rename into its before/after files using --no-renames, either half still reports IsRename(). The comment notes this 'probably won't happen' — with --no-renames git should never emit rename entries — but the check prevents an infinite recursion if it ever did.","triggerScenarios":"Essentially unreachable with current git: would require the no-renames status listing to still carry rename pairs (custom git wrapper, exotic git version, or pathological index state).","commonSituations":"A git wrapper script that strips the --no-renames flag; git implementations that ignore the flag.","solutions":["Check `git status --no-renames` actually lists delete+add pairs, not 'R' entries, in the affected repo","Remove any git wrapper/shim from PATH that drops the --no-renames argument","Report upstream if a stock git exhibits it"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"Practically unreachable defensive guard: if hit, log the no-renames status output and report upstream; there is no caller-side workaround other than verifying `git status --no-renames` behaves correctly and removing git shims from PATH.","preventionTips":["Don't wrap git with scripts that drop flags like --no-renames","Use stock git builds for lazygit workflows","Test exotic setups with `git status --no-renames` directly"],"tags":["git","rename","defensive","edge-case"],"backgroundTag":null,"analyzedSha":"c477a2959b229fbf3284be0d4d2904ab61ec3c94","analyzedAt":"2026-08-15T08:34:32.451Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}