Commit 0ccde04
committed
refactor(klipper): optimize git command execution by eliminating directory changes
• Remove initial 'cd $KLIPPER_DIR' approach in checkout_target_branch() function
• Replace with explicit '-C $KLIPPER_DIR' flags on all individual git commands
• Update all git commands to use explicit directory specification:
- git symbolic-ref HEAD
- git checkout -b (temporary branch creation)
- git show-ref --verify --quiet (branch existence check)
- git checkout (existing branch switch)
- git checkout -b (new branch from remote)
- git branch -D (cleanup commands in both error and success paths)
• Eliminate directory access validation at function start (no longer needed)
Benefits:
- Eliminates side effects: Working directory of calling context remains unchanged
- Improves error recovery: ERR trap cleanup doesn't need to worry about directory state
- Enhances code clarity: Each git command explicitly specifies its target directory
- Reduces complexity: No need for directory access validation at function start
- Better isolation: Function becomes more self-contained and predictable
- Maintains all existing error handling and logging behavior
- Preserves ERR trap cleanup mechanism for temporary branches
Technical Implementation:
- All git commands now use '-C $KLIPPER_DIR' for explicit directory context
- Cleanup function updated to use explicit directory specification
- Function behavior remains identical after the change
- No changes to error codes, logging, or trap mechanisms1 parent b921b93 commit 0ccde04
1 file changed
+7
-12
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
280 | 280 | | |
281 | 281 | | |
282 | 282 | | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
287 | | - | |
288 | 283 | | |
289 | 284 | | |
290 | 285 | | |
| |||
293 | 288 | | |
294 | 289 | | |
295 | 290 | | |
296 | | - | |
| 291 | + | |
297 | 292 | | |
298 | 293 | | |
299 | 294 | | |
| |||
306 | 301 | | |
307 | 302 | | |
308 | 303 | | |
309 | | - | |
| 304 | + | |
310 | 305 | | |
311 | 306 | | |
312 | 307 | | |
313 | | - | |
| 308 | + | |
314 | 309 | | |
315 | 310 | | |
316 | 311 | | |
| |||
319 | 314 | | |
320 | 315 | | |
321 | 316 | | |
322 | | - | |
| 317 | + | |
323 | 318 | | |
324 | | - | |
| 319 | + | |
325 | 320 | | |
326 | 321 | | |
327 | 322 | | |
328 | 323 | | |
329 | 324 | | |
330 | 325 | | |
331 | | - | |
| 326 | + | |
332 | 327 | | |
333 | 328 | | |
334 | 329 | | |
| |||
339 | 334 | | |
340 | 335 | | |
341 | 336 | | |
342 | | - | |
| 337 | + | |
343 | 338 | | |
344 | 339 | | |
345 | 340 | | |
| |||
0 commit comments