Commit 98333d5
committed
status: add --json output format to git status
Add a new --json flag to 'git status' that outputs repository state
in a structured JSON format. This enables reliable machine parsing
of status information for tools and automation.
The JSON output includes:
- Branch information (name, detached state, ahead/behind counts)
- Staged files array
- Unstaged files array
- Untracked files array
- Ignored files array (with --ignored flag)
Implementation details:
- Add STATUS_FORMAT_JSON to wt_status_format enum
- Add JSON output option to git status and git commit
- Implement JSON formatting helpers for arrays and branch info
- Structure output for easy parsing and future extensibility
Example:
$ git status --json
{
"branch": {
"current": "main",
"detached": false
},
"staged": ["file1.txt"],
"unstaged": ["file2.txt"],
"untracked": ["file3.txt"]
}
This provides a robust alternative to parsing traditional output
formats, making it easier to build reliable tools and automation
around Git status information.
Signed-off-by: Tachera Sasi <tachera@ekilie.com>
Signed-off-by: tacherasasi <tacherasasi@gmail.com>1 parent cb3b403 commit 98333d5
3 files changed
+107
-1
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1540 | 1540 | | |
1541 | 1541 | | |
1542 | 1542 | | |
| 1543 | + | |
| 1544 | + | |
| 1545 | + | |
1543 | 1546 | | |
1544 | 1547 | | |
1545 | 1548 | | |
| |||
1603 | 1606 | | |
1604 | 1607 | | |
1605 | 1608 | | |
1606 | | - | |
| 1609 | + | |
| 1610 | + | |
1607 | 1611 | | |
1608 | 1612 | | |
1609 | 1613 | | |
| |||
1735 | 1739 | | |
1736 | 1740 | | |
1737 | 1741 | | |
| 1742 | + | |
| 1743 | + | |
| 1744 | + | |
1738 | 1745 | | |
1739 | 1746 | | |
1740 | 1747 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
2564 | 2564 | | |
2565 | 2565 | | |
2566 | 2566 | | |
| 2567 | + | |
| 2568 | + | |
| 2569 | + | |
| 2570 | + | |
| 2571 | + | |
| 2572 | + | |
| 2573 | + | |
| 2574 | + | |
| 2575 | + | |
| 2576 | + | |
| 2577 | + | |
| 2578 | + | |
| 2579 | + | |
| 2580 | + | |
| 2581 | + | |
| 2582 | + | |
| 2583 | + | |
| 2584 | + | |
| 2585 | + | |
| 2586 | + | |
| 2587 | + | |
| 2588 | + | |
| 2589 | + | |
| 2590 | + | |
| 2591 | + | |
| 2592 | + | |
| 2593 | + | |
| 2594 | + | |
| 2595 | + | |
| 2596 | + | |
| 2597 | + | |
| 2598 | + | |
| 2599 | + | |
| 2600 | + | |
| 2601 | + | |
| 2602 | + | |
| 2603 | + | |
| 2604 | + | |
| 2605 | + | |
| 2606 | + | |
| 2607 | + | |
| 2608 | + | |
| 2609 | + | |
| 2610 | + | |
| 2611 | + | |
| 2612 | + | |
| 2613 | + | |
| 2614 | + | |
| 2615 | + | |
| 2616 | + | |
| 2617 | + | |
| 2618 | + | |
| 2619 | + | |
| 2620 | + | |
| 2621 | + | |
| 2622 | + | |
| 2623 | + | |
| 2624 | + | |
| 2625 | + | |
| 2626 | + | |
| 2627 | + | |
| 2628 | + | |
| 2629 | + | |
| 2630 | + | |
| 2631 | + | |
| 2632 | + | |
| 2633 | + | |
| 2634 | + | |
| 2635 | + | |
| 2636 | + | |
| 2637 | + | |
| 2638 | + | |
| 2639 | + | |
| 2640 | + | |
| 2641 | + | |
| 2642 | + | |
| 2643 | + | |
| 2644 | + | |
| 2645 | + | |
| 2646 | + | |
| 2647 | + | |
| 2648 | + | |
| 2649 | + | |
| 2650 | + | |
| 2651 | + | |
| 2652 | + | |
| 2653 | + | |
| 2654 | + | |
| 2655 | + | |
| 2656 | + | |
| 2657 | + | |
| 2658 | + | |
| 2659 | + | |
| 2660 | + | |
| 2661 | + | |
2567 | 2662 | | |
2568 | 2663 | | |
2569 | 2664 | | |
| |||
2583 | 2678 | | |
2584 | 2679 | | |
2585 | 2680 | | |
| 2681 | + | |
| 2682 | + | |
| 2683 | + | |
2586 | 2684 | | |
2587 | 2685 | | |
2588 | 2686 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
74 | 74 | | |
75 | 75 | | |
76 | 76 | | |
| 77 | + | |
77 | 78 | | |
78 | 79 | | |
79 | 80 | | |
| |||
0 commit comments