wfxr / forgit

:zzz: A utility tool powered by fzf for using git interactively.
MIT License
4.32k stars 136 forks source link

forgit::stash::push failing with error: unknown option `pathspec-file-nul' #328

Closed Halfwalker closed 2 months ago

Halfwalker commented 8 months ago

Check list

Environment info

Problem / Steps to reproduce

Running forgit::stash::push via an alias gsp=forgit::stash::push results in the following error

❯ gsp
error: unknown option `pathspec-file-nul'
usage: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
          [-u|--include-untracked] [-a|--all] [-m|--message <message>]
          [--] [<pathspec>...]]

    -k, --keep-index      keep index
    -p, --patch           stash in patch mode
    -q, --quiet           quiet mode
    -u, --include-untracked
                          include untracked files in stash
    -a, --all             include ignore files
    -m, --message <message>
                          stash message

This is on Ubuntu 20.04.6 with zsh and git versions as follows

Git repo status is

❯ g status
On branch master
Your branch is up to date with 'origin/master'.

Changes not staged for commit:
  (use "git add <file>..." to update what will be committed)
  (use "git restore <file>..." to discard changes in working directory)
        modified:   docker/vault/keys/apinext_token.yaml
        modified:   docker/vault/keys/login_token.yaml

no changes added to commit (use "git add" and/or "git commit -a")

Selecting either of the modified files to stash results in immediate exit to the above error.

sandr01d commented 8 months ago

I'm suspecting your version of git does not have the --pathspec-file-nul flag that we use. I can not reproduce this using git 2.42.0. To validate this, please run the following command from inside a git repository and send me the output:

git stash push --pathspec-file-nul --pathspec-from-file
Halfwalker commented 8 months ago

Yup, looks like it ...

❯ git --version
git version 2.25.1

❯ git stash push --pathspec-file-nul --pathspec-from-file
error: unknown option `pathspec-file-nul'
usage: git stash [push [-p|--patch] [-k|--[no-]keep-index] [-q|--quiet]
          [-u|--include-untracked] [-a|--all] [-m|--message <message>]
          [--] [<pathspec>...]]

    -k, --keep-index      keep index
    -p, --patch           stash in patch mode
    -q, --quiet           quiet mode
    -u, --include-untracked
                          include untracked files in stash
    -a, --all             include ignore files
    -m, --message <message>
                          stash message

That's the default version for Ubuntu 20.04 focal ... Ubuntu 22.04 jammy has

❯ git --version
git version 2.34.1
sandr01d commented 8 months ago

Yes, that's what I expected. The git version that comes with jammy does have this option, so it works there. Given that git 1.25 (and Ubuntu 20.04) is quite old by now I personally would like to keep the current implementation with the --pathspec-file-nul flag, but I'll leave this issue open to see what the other maintainers think about this.

@carlfriedrich @cjappl what are your opinions?

Halfwalker commented 8 months ago

How about an alternative method behind an environment feature flag or something ? Unfortunately, at work our official images are 20.04 ... We're pushing for updates, but there's a lot of inertia to overcome. Classic argument we get is "Well, it's LTS supported for 2 more years !"

carlfriedrich commented 8 months ago

Haven't checked the implementation details and whether there might be a workaround without using this flag, but IMO we should support a major distribution's LTS version as long as it is officially maintained.

sandr01d commented 8 months ago

Ok, you both have convincing arguments. We should make it work for git 2.25.1.