Skip to content

stg refresh errors out when index contains added files and path limiting is given #85

Closed
@NonLogicalDev

Description

@NonLogicalDev

To reproduce:

( set -ex
  rm -rf test

  # Create Test Repo
  mkdir -p test && cd test
  git init && git commit -m "INIT" --allow-empty

  # Init StGit
  stg init

  # Create two new patches
  stg new patch1 -m patch1
  stg new patch2 -m patch2

  # Assert patch2 as topmost patch
  test "$(stg top)" == patch2

  # Touch a few files
  touch a.txt b.txt c.txt

  # Add all files to staging area (to make sure index is not dirty)
  stg add -A

  # Attempt to send only a.txt to patch1
  stg refresh -p patch1 -- a.txt

  ## ERROR: ##
  #
  # error: a.txt: cannot add to the index - missing --add option?
  # fatal: Unable to process path a.txt
  # stg refresh: git failed with code 128

  ## EXPECTED: ##

  stg files patch1
  ## OUTPUT: ##
  # A a.txt

  stg files patch2
  ## OUTPUT: ##
  # <EMPTY>

  stg status
  ## OUTPUT: ##
  # A b.txt
  # A c.txt
)

I narrowed down the problem to the following function:
https://github.com/stacked-git/stgit/blob/master/stgit/lib/git/iw.py#L332

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions