@@ -133,57 +133,57 @@ function Git.is_amending()
133
133
return false
134
134
end
135
135
136
- -- Check if we're in an amend scenario by examining the COMMIT_EDITMSG content
137
- -- During amend, git pre-populates COMMIT_EDITMSG with the previous commit message
138
- local git_dir = vim .trim (vim .fn .system (" git rev-parse --git-dir" ))
139
- if vim .v .shell_error ~= 0 then
140
- return false
141
- end
142
-
143
- -- Use platform-appropriate path separator
144
- local path_sep = package.config :sub (1 , 1 )
145
- local commit_editmsg = git_dir .. path_sep .. " COMMIT_EDITMSG"
146
- local stat = vim .uv .fs_stat (commit_editmsg )
147
- if not stat then
148
- return false
149
- end
150
-
151
- -- Additional check: verify HEAD commit exists (not initial commit)
152
- local redirect = (vim .uv .os_uname ().sysname == " Windows_NT" ) and " 2>nul" or " 2>/dev/null"
153
- vim .fn .system (" git rev-parse --verify HEAD" .. redirect )
154
- if vim .v .shell_error ~= 0 then
155
- return false
156
- end
157
-
158
- -- Read COMMIT_EDITMSG content and check if it contains a previous commit message
159
- -- During amend, git pre-populates this file with the previous commit message
160
- local fd = vim .uv .fs_open (commit_editmsg , " r" , 438 )
161
- if not fd then
162
- return false
163
- end
164
-
165
- local content = vim .uv .fs_read (fd , stat .size , 0 )
166
- vim .uv .fs_close (fd )
167
-
168
- if not content then
169
- return false
170
- end
171
-
172
- -- Check if there's non-comment content in COMMIT_EDITMSG
173
- -- During amend, this indicates we're editing an existing commit
174
- local lines = vim .split (content , " \n " )
175
- local has_existing_message = false
176
- for _ , line in ipairs (lines ) do
177
- local trimmed = vim .trim (line )
178
- -- Skip empty lines and comment lines (starting with #)
179
- if trimmed ~= " " and not trimmed :match (" ^#" ) then
180
- has_existing_message = true
181
- break
182
- end
183
- end
184
-
185
- -- If COMMIT_EDITMSG has existing content and HEAD exists, likely an amend
186
- return has_existing_message
136
+ -- Check if we're in an amend scenario by examining the COMMIT_EDITMSG content
137
+ -- During amend, git pre-populates COMMIT_EDITMSG with the previous commit message
138
+ local git_dir = vim .trim (vim .fn .system (" git rev-parse --git-dir" ))
139
+ if vim .v .shell_error ~= 0 then
140
+ return false
141
+ end
142
+
143
+ -- Use platform-appropriate path separator
144
+ local path_sep = package.config :sub (1 , 1 )
145
+ local commit_editmsg = git_dir .. path_sep .. " COMMIT_EDITMSG"
146
+ local stat = vim .uv .fs_stat (commit_editmsg )
147
+ if not stat then
148
+ return false
149
+ end
150
+
151
+ -- Additional check: verify HEAD commit exists (not initial commit)
152
+ local redirect = (vim .uv .os_uname ().sysname == " Windows_NT" ) and " 2>nul" or " 2>/dev/null"
153
+ vim .fn .system (" git rev-parse --verify HEAD" .. redirect )
154
+ if vim .v .shell_error ~= 0 then
155
+ return false
156
+ end
157
+
158
+ -- Read COMMIT_EDITMSG content and check if it contains a previous commit message
159
+ -- During amend, git pre-populates this file with the previous commit message
160
+ local fd = vim .uv .fs_open (commit_editmsg , " r" , 438 )
161
+ if not fd then
162
+ return false
163
+ end
164
+
165
+ local content = vim .uv .fs_read (fd , stat .size , 0 )
166
+ vim .uv .fs_close (fd )
167
+
168
+ if not content then
169
+ return false
170
+ end
171
+
172
+ -- Check if there's non-comment content in COMMIT_EDITMSG
173
+ -- During amend, this indicates we're editing an existing commit
174
+ local lines = vim .split (content , " \n " )
175
+ local has_existing_message = false
176
+ for _ , line in ipairs (lines ) do
177
+ local trimmed = vim .trim (line )
178
+ -- Skip empty lines and comment lines (starting with #)
179
+ if trimmed ~= " " and not trimmed :match (" ^#" ) then
180
+ has_existing_message = true
181
+ break
182
+ end
183
+ end
184
+
185
+ -- If COMMIT_EDITMSG has existing content and HEAD exists, likely an amend
186
+ return has_existing_message
187
187
end )
188
188
189
189
return ok and result or false
0 commit comments