kisslinux / kiss

KISS Linux - Package Manager
https://kisslinux.github.io
MIT License
464 stars 62 forks source link

kiss: fix pkg_update for extra colons in KISS_PATH #304

Closed aabacchus closed 5 months ago

aabacchus commented 2 years ago

If KISS_PATH=:: or even KISS_PATH=:/repo1:/repo2, the IFS=:; set -- $KISS_PATH trick leaves some of $@ as empty strings. These cause git to print errors. Instead, skip empty arguments.

Demonstration of bug:

$ cd
$ KISS_PATH=::: kiss u 2>&1 | sed '/Checking/q'
-> Updating repositories
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
fatal: not a git repository (or any of the parent directories): .git
-> Checking for new package versions

The git commands producing the errors are:

git -C "" rev-parse 'HEAD@{upstream}'

and when the argument to -C is empty, the current working directory is unchanged. Therefore, if PWD happens to be inside a git tree, this command could have unexpected effects: currently, if KISS_PATH contains (an) extra colon(s), and PWD is in a git repo with an upstream, the repo is updated irrespective of whether it is in KISS_PATH or a package repo. This behaviour is also fixed by this commit.

dilyn-corner commented 2 years ago

I think the behavior is half intentional; if $PWD is in$KISS_PATH we should probably still update it on kiss u, but otherwise no. 

Note that I just responded to my email and didn't actually check the commit. Aug 7, 2022, 2:18 PM by @.***:

If > KISS_PATH=::> or even > KISS_PATH=:/repo1:/repo2> , the > IFS=:; set -- $KISS_PATH trick leaves some of $@ as empty strings. These cause git to print errors. Instead, skip empty arguments.

Demonstration of bug:

$ cd$ KISS_PATH=::: kiss u 2>&1 | sed '/Checking/q'-> Updating repositoriesfatal: not a git repository (or any of the parent directories): .gitfatal: not a git repository (or any of the parent directories): .gitfatal: not a git repository (or any of the parent directories): .git-> Checking for new package versions

The git commands producing the errors are:

git -C "" rev-parse 'HEAD@{upstream}'

and when the argument to -C is empty, the current working directory is unchanged. Therefore, if PWD happens to be inside a git tree, this command could have unexpected effects: currently, if KISS_PATH contains (an) extra colon(s), and PWD is in a git repo with an upstream, the repo is updated irrespective of whether it is in KISS_PATH or a package repo. This behaviour is also fixed by this commit.

You can view, comment on, or merge this pull request online at:

  > https://github.com/kisslinux/kiss/pull/304

Commit Summary 7c2ca7d https://github.com/kisslinux/kiss/pull/304/commits/7c2ca7d5bfdb6221d6e32eb6a9d51e94c6cc1d77> kiss: fix pkg_update for extra colons in KISS_PATH File Changes

(> 1 file https://github.com/kisslinux/kiss/pull/304/files> )

M> > kiss https://github.com/kisslinux/kiss/pull/304/files#diff-89d19d63941a517f4921ec8496fbf07c4b444537352cc585461a1b4de469fde5> (1) Patch Links: https://github.com/kisslinux/kiss/pull/304.patch https://github.com/kisslinux/kiss/pull/304.diff

— Reply to this email directly, > view it on GitHub https://github.com/kisslinux/kiss/pull/304> , or > unsubscribe https://github.com/notifications/unsubscribe-auth/AEVM3SLHT3N32ECKBNJYRQLVX74XBANCNFSM5523IBMA> . You are receiving this because you are subscribed to this thread.> Message ID: > <kisslinux/kiss/pull/304> @> github> .> com>

aabacchus commented 2 years ago

I also assumed it was intentional until just now noticing that my patch stopped the behaviour of updating PWD (my KISS_PATH has extra colons). This patch doesn't mess with if PWD is in KISS_PATH.