Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Document that --refs parameters cannot start with a hyphen #469

Open
andry81 opened this issue May 20, 2023 · 3 comments
Open

Document that --refs parameters cannot start with a hyphen #469

andry81 opened this issue May 20, 2023 · 3 comments
Labels
docs Documentation related issues good first issue Good for newcomers

Comments

@andry81
Copy link

andry81 commented May 20, 2023

Found beside another issue: #468

If use --refs as range parameter just like in the git filter-branch:

git-filter-repo-replace-text.sh:

function call()
{
  local IFS=$' \t'
  echo ">$*"
  "$@"
}

expressions_text="$1"

TEMP_OUTPUT_FILE=`mktemp -t git_filter_repo_update_file_text.XXXXXXXXXX`

# cleanup on return
trap "rm -rf \"$TEMP_OUTPUT_FILE\" 2> /dev/null; trap - RETURN" RETURN

call git-filter-repo-replace-text --replace-text "$TEMP_OUTPUT_FILE" "${@:2}"
git-filter-repo-replace-text "<p/>==></p>" --refs master --not t1^@
>git filter-repo --replace-text /tmp/git_filter_repo_update_file_text.wSOPH7Vu7j --refs master --not t1^@
git-filter-repo: error: unrecognized arguments: --not t1^@

I know it has to be a bit corrected:

git-filter-repo-replace-text.sh "<p/>==></p>" --refs master ^t1^@

But nevertheless --refs is not completely compatible with the git rev-list format.

@newren newren changed the title --refs parameter does not respect git rev-list format Document that --refs parameters cannot start with a hyphen Jun 2, 2023
@newren
Copy link
Owner

newren commented Jun 2, 2023

I was certain I had already documented that --refs doesn't take any hyphenated options (such as --not), but it appears I didn't mention that anywhere. Oops.

Not a bug, though, it's just a somewhat natural consequence of the fact that python's argparse is going to attempt to parse all the hyphenated options, and if I wanted to make it work like git, then I'd have to specially treat double dashes and just let all the arguments be positional. I don't want to go that route. Besides, filter-repo is about scripting and folks can use git-for-each ref and git-rev-parse if they really need to...though I suspect that most attempts to be clever with --refs are more likely just misues of the tool (as per your other ticket).

Anyway, thanks for pointing out that I forgot to document this. We should mention that the things passed to --refs cannot begin with a hyphen.

@andry81
Copy link
Author

andry81 commented Jun 2, 2023

But this means that will be a challenge to convert git filter-branch into git filter-repo as a replacement. The git filter-branch uses generic git rev-list syntax, when you are not.

@newren
Copy link
Owner

newren commented Jun 2, 2023

But this means that will be a challenge to convert git filter-branch into git filter-repo as a replacement. The git filter-branch uses generic git rev-list syntax, when you are not.

git shortlog origin/next --branches --not origin/main

is equivalent to

git shortlog $(git rev-parse --symbolic origin/next --branches --not origin/main)

which is a pretty trivial conversion. If filter-repo was a command you used very frequently, I could understand possibly wanting to not need to do that conversion. However, since filter-branch and filter-repo are only supposed to be used once in a blue moon and only with special care, I don't think needing to convert like this is at all onerous. And if it discourages more people from using --refs, especially since that is often misused, all the better.

@newren newren added good first issue Good for newcomers docs Documentation related issues labels Nov 28, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
docs Documentation related issues good first issue Good for newcomers
Projects
None yet
Development

No branches or pull requests

2 participants