forgit icon indicating copy to clipboard operation
forgit copied to clipboard

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

Open Halfwalker opened this issue 1 year ago • 6 comments

Check list

  • [x] I have read through the README
  • [x] I have the latest version of forgit
  • [x] I have searched through the existing issues

Environment info

  • OS
    • [x] Linux (Ubuntu 20.04.6)
    • [ ] Mac OS X
    • [ ] Windows
    • [ ] Others:
  • Shell
    • [ ] bash
    • [x] zsh
    • [ ] fish

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 version 2.25.1
  • zsh 5.8 (x86_64-ubuntu-linux-gnu)
❯ dpkg -l git\* | rg ii
ii  git                 1:2.25.1-1ubuntu3.11 amd64        fast, scalable, distributed revision control system
ii  git-extras          5.1.0-1              all          Extra commands for git
ii  git-lfs             2.9.2-1              amd64        Git Large File Support
ii  git-man             1:2.25.1-1ubuntu3.11 all          fast, scalable, distributed revision control system (manual pages)
❯ dpkg -l zsh\* | rg ii
ii  zsh            5.8-3ubuntu1.1 amd64        shell with lots of features
ii  zsh-common     5.8-3ubuntu1.1 all          architecture independent files for Zsh

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.

Halfwalker avatar Oct 27 '23 18:10 Halfwalker

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

sandr01d avatar Oct 27 '23 20:10 sandr01d

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

Halfwalker avatar Oct 27 '23 20:10 Halfwalker

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?

sandr01d avatar Oct 27 '23 20:10 sandr01d

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 !"

Halfwalker avatar Oct 27 '23 20:10 Halfwalker

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.

carlfriedrich avatar Oct 28 '23 10:10 carlfriedrich

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

sandr01d avatar Nov 05 '23 00:11 sandr01d