Skip to content

Setting --workdir results in an empty output #1369

Description

@ids-mau

Is there an existing issue for this?

  • I have searched the existing issues

Description of the bug

When setting --workdir <path> to the path of the repository or setting --workdir <parent-dir> to the parent of the repository: The git-cliff output is empty.

This used to work in 2.8.0. Maybe the meaning of --workdir changed related to some of the changes in the last few versions regarding --include-path, path resolution etc.

Steps To Reproduce

  1. Setup the repository:
    mkdir git-cliff-workdir
    cd git-cliff-workdir/
    git init
    git commit -m "feat: Changelog entry" --allow-empty
  2. These commands work as expected:
    # from inside git-cliff-workdir/
    # works
    git-cliff
    
    cd ..
    # works
    git-cliff --repository git-cliff-workdir
  3. These however, output an empty changelog:
    # from inside git-cliff-workdir/
    git-cliff --workdir .
    cd ..
    # from the parent directory of git-cliff-workdir/
    git-cliff --workdir git-cliff-workdir/
    git-cliff --repository git-cliff-workdir --workdir ./

Expected behavior

git-cliff should output the same changelog as for the other two commands, so for the example above:

## [unreleased]

### 🚀 Features

- Changelog entry

Screenshots / Logs

> ./git-cliff-workdir-repro.sh
+ mkdir git-cliff-workdir
+ cd git-cliff-workdir/
+ git init
...
+ git commit -m 'feat: Changelog entry' --allow-empty
[master (root-commit) 927f9d3] feat: Changelog entry
+ git-cliff
 WARN  git_cliff > "cliff.toml" is not found, using the default configuration
## [unreleased]

### 🚀 Features

- Changelog entry
+ git-cliff --workdir .
 WARN  git_cliff > "./cliff.toml" is not found, using the default configuration
+ cd ..
+ git-cliff --repository git-cliff-workdir
 WARN  git_cliff > "cliff.toml" is not found, using the default configuration
## [unreleased]

### 🚀 Features

- Changelog entry
+ git-cliff --workdir git-cliff-workdir/
 WARN  git_cliff > "git-cliff-workdir/cliff.toml" is not found, using the default configuration
+ git-cliff --repository git-cliff-workdir --workdir ./
 WARN  git_cliff > "./cliff.toml" is not found, using the default configuration
+ rm -rf git-cliff-workdir/

Software information

  • Project version: git-cliff 2.12.0

Additional context

Might be related to:

After further investigation:

  • Since setting --workdir now also sets the include path, empty commits without any file changes will be ignored.
  • Absolute paths passed as --workdir are not handled properly. The include patterns themselves include the absolute path, while the path of the files itself are compared using the relative path in Repository::should_retain_commit.

Activity

  1. added
    bug
    on Feb 9, 2026
  2. felixoswald commented on Feb 10, 2026

    @felixoswald

    +1 for v2.12.0 and v2.11.0
    running git cliff with the option -w <path> in these versions results in an empty output.

    the last working version was 2.10.1

  3. ids-mau commented on Feb 12, 2026

    @ids-mau
    Author

    I added some more information above. The problem seems to be related to --workdir setting the include path automatically, which ignores empty commits and the handling of absolute include paths in general.

    Repro script used:

    git-cliff --version
    
    mkdir git-cliff-workdir
    cd git-cliff-workdir/ || exit
    echo "Setting up repo in git-cliff-workdir/"
    git init
    git commit -m "feat: Meta commit without file change" --allow-empty
    
    echo "foo" > foo.txt
    git add foo.txt
    git commit -m "feat: Commit with file"
    
    echo "Works: 'git-cliff' inside git-cliff-workdir/"
    git-cliff
    echo
    
    echo "Broken: 'git-cliff --workdir .' inside git-cliff-workdir/"
    echo "   -> does not output meta/empty commits without file changes"
    git-cliff --workdir .
    echo
    
    echo "Going up one directory..."
    cd ..
    
    echo "Works: 'git-cliff --repository git-cliff-workdir' in the parent directory of git-cliff-workdir/"
    git-cliff --repository git-cliff-workdir
    echo
    
    echo "Broken: 'git-cliff --workdir git-cliff-workdir/' in the parent directory of git-cliff-workdir/"
    echo "   -> no commits"
    git-cliff --workdir git-cliff-workdir/
    echo
    
    echo "Broken: 'git-cliff --repository git-cliff-workdir --workdir ./' in the parent directory of git-cliff-workdir/"
    echo "   -> does not output meta/empty commits without file changes"
    git-cliff --repository git-cliff-workdir --workdir ./
    echo
    
    echo "Broken: 'git-cliff --repository git-cliff-workdir --workdir \$PWD' in the parent directory of git-cliff-workdir/"
    echo "   -> no commits"
    git-cliff --repository git-cliff-workdir --workdir "$PWD"
    echo
  4. orhun commented on Feb 14, 2026

    @orhun
    Owner

    Hello, thanks for reporting! 👋🏼

    Seems like this is caused by:

    1. fix(args): set the include-path if workdir is set #1293
    2. 0fbc625

    Those were implemented for fixing #1292

    The issue is when adding the workdir to the include_path list, we do not take the path relative to the repository root (which result in not including the files). I have vibe-coded a fix here which worked for me locally. However, our logic for resolving these path arguments is complex enough for now and just slapping would make the maintenance more difficult in the future.

    So I'd like to step back and think about how include-paths and other arguments interact with each other first and potentially refactor:

    // Include only the current directory if not running from the root repository.
    //
    // NOTE:
    // The conditions for including the current directory when not running from the root repository
    // have grown quite complex. This may warrant additional documentation to explain the behavior.

    This might take some time but I believe we'll prevent future issues if we document the behavior and implement this cleanly.

    cc @ognis1205

  5. o1x3 commented on Feb 17, 2026

    @o1x3

    Hey @orhun, I'd like to take a crack at the refactor you mentioned, consolidating the path resolution logic so workdir, include/exclude paths, and repository paths are all
    normalized to repo-relative paths in one place.

    My rough plan:

    • Extract path resolution from the scattered locations in lib.rs into a single function that runs after repo discovery, when the repo root is available
    • Ensure all include/exclude patterns end up repo-relative before hitting should_retain_commit
    • Add test coverage for the edge cases from this issue (workdir=repo root, absolute paths, relative paths, empty commits)
  6. orhun commented on Feb 21, 2026

    @orhun
    Owner

    Hey @o1x3, that would be great! Feel free to create a draft PR while you're working on this, so that we can track the progress and provide feedback early. (This is gonna be quite a big refactor I'm guessing)

  7. ognis1205 commented on Feb 21, 2026

    @ognis1205
    Contributor

    @o1x3 cc: @orhun

    If you're moving forward with the refactor, I'm happy to take care of:

    and focus on improving the fixture/test coverage for the repository handling. That might help validate the refactor more confidently.

  8. removed their assignment
    on Feb 21, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    bug

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions