# absorb
Automatically distribute working tree changes into the commits that last touched the affected lines. Uses blame to determine the correct target for each hunk, then amends those commits — all in a single operation.
## Usage
```
git loom absorb [-n] [files...]
```
### Options
| `-n, --dry-run` | Show what would be absorbed without making changes |
### Arguments
| `[files...]` | Files to restrict absorption to (default: all tracked changed files) |
## How It Works
For each file with uncommitted changes:
1. Parses the unified diff into individual hunks
2. For each hunk, blames the modified/deleted lines to find their originating commit
3. If all hunks trace to the **same in-scope commit**, the whole file is absorbed
4. If hunks trace to **different commits**, each hunk is independently absorbed into its target
5. Hunks that can't be attributed (pure additions, ambiguous) are **skipped** and left in the working tree
After analysis, all assigned hunks are folded into their target commits in a single rebase operation.
## Examples
### Absorb all changes
```bash
git loom absorb
# src/auth.rs -> a1b2c3d "Add authentication" (feature-auth)
# src/utils.rs -> d4e5f6a "Add utility helpers" (feature-utils)
# Absorbed 2 hunk(s) from 2 file(s) into 2 commit(s)
```
### Absorb hunks into different commits
```bash
# src/shared.rs has changes in two separate regions,
# each originating from a different commit
git loom absorb
# src/shared.rs [hunk 1/2] -> a1b2c3d "Add login form" (feature-auth)
# src/shared.rs [hunk 2/2] -> d4e5f6a "Add dashboard" (feature-dashboard)
# Absorbed 2 hunk(s) from 1 file(s) into 2 commit(s)
```
### Dry run
```bash
git loom absorb --dry-run
# src/auth.rs -> a1b2c3d "Add authentication" (feature-auth)
# src/shared.rs [hunk 1/2] -> d4e5f6a "Add utility helpers" (feature-utils)
# src/shared.rs [hunk 2/2] -- skipped (pure addition)
# Dry run: would absorb 2 hunk(s) from 2 file(s) into 2 commit(s)
```
### Restrict to specific files
```bash
git loom absorb src/auth.rs src/utils.rs
# src/auth.rs -> a1b2c3d "Add authentication" (feature-auth)
# src/utils.rs -> d4e5f6a "Add utility helpers" (feature-utils)
# Absorbed 2 hunk(s) from 2 file(s) into 2 commit(s)
```
## Commits that are already upstream
If a target commit's own changes are all upstream already, it has nothing left
to apply. Loom refuses rather than let git drop it and squash the hunks into
whatever commit sits below:
```console
$ loom absorb
# ✗ Commit `4783c1b` is redundant — the history below it already has its change
# › Nothing was rewritten. Run `loom update` if it landed upstream
```
Your changes stay in the working tree.
## Conflicts
If the rebase that folds the fixup commits hits a conflict, the operation is
**paused**. Pre-existing staged changes are saved aside automatically.
```bash
git loom absorb
# src/auth.rs -> a1b2c3d "Add authentication" (feature-auth)
# ! Conflicts detected — resolve them with git, then run:
# loom continue to complete the absorb
# loom abort to cancel and restore original state
```
```bash
git add <resolved-files> && git loom continue
# ✓ Absorbed 1 hunk(s) from 1 file(s) into 1 commit(s)
```
See [`continue`](continue.md) and [`abort`](abort.md) for details.
## Prerequisites
- Must be on an integration branch
- Working tree must have uncommitted changes
- Target commits must be in scope (between merge-base and HEAD)