Commit Graph

30 Commits (main)

Author SHA1 Message Date
Markus Heidelberg 4bc9022afc convert-svnexternals: fix parsing of wrongly transformed SVN revisions
SVN revision numbers from svn:externals property, which are a multiple
of 1024 (2^10), are transformed by SubGit to contain a binary suffix
("k", "m" and "g" have been checked) in .gitsvnextmodules file.
These aren't valid revision numbers in SVN either.

Examples:
  1024 -> 1k
  2048 -> 2k
  1048576 -> 1m
  1049600 -> 1025k
  1073741824 -> 1g

This led to the following error:
    svn_rev = int(parsed_config[section]['revision'])
ValueError: invalid literal for int() with base 10: '1k'

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Elijah Newren <newren@gmail.com>
1 year ago
Elijah Newren 111049a42a filter-lamely: fix a typo
Signed-off-by: Elijah Newren <newren@gmail.com>
2 years ago
Markus Heidelberg b164ffc988 contrib: new tool to convert svn:externals to Git submodules
This is meant to be a post-processing step after SVN-to-Git conversion
by SubGit (https://subgit.com/), which creates a ".gitsvnextmodules"
file that we will use for svn:externals conversion.

Signed-off-by: Markus Heidelberg <markus.heidelberg@web.de>
Signed-off-by: Elijah Newren <newren@gmail.com>
2 years ago
Elijah Newren 9cf6121b34 lint-history: fix broken --refs option
Commit 3e153806ff (lint-history: Add --refs argument, 2021-12-30)
added a --refs argument to lint-history, but attempting to inject it
directly into the parsed args fields, bypassing some of the important
logic from FilteringOptions.parse_args() -- particularly the bit where
it translates an empty --refs into a request for '--all' as as list of
references.  I somehow overlooked this in my earlier review.  Fix the
problem now.

Signed-off-by: Elijah Newren <newren@gmail.com>
2 years ago
Elijah Newren 5651f62f4c Merge branch 'rh/lint-history-refs-option'
Signed-off-by: Elijah Newren <newren@gmail.com>
2 years ago
Robert Haschke 3e153806ff lint-history: Add --refs argument
Signed-off-by: Robert Haschke <rhaschke@techfak.uni-bielefeld.de>
2 years ago
Francis Charette Migneault 4896736247 clean-ignore: use arguments provided as input instead of enforced defaults
Signed-off-by: Francis Charette Migneault <francis.charette.migneault@gmail.com>
2 years ago
Francis Charette Migneault f887b2d7c9 clean-ignore: move commands under main function
Signed-off-by: Francis Charette Migneault <francis.charette.migneault@gmail.com>
2 years ago
Elijah Newren e5d8938d48 lint-history: explain how TMPDIR can be used
Some users may want to take advantage of setting TMPDIR to another
location that might be faster for the linting process.

Reported-by: @ruv on GitHub
Signed-off-by: Elijah Newren <newren@gmail.com>
3 years ago
Elijah Newren ccc37d3423 lint-history: explain filename paths
It was not clear for some users that the filenames would be relative
paths from the toplevel of the repository.  Add some text to explain
this.

Reported-by: @ruv on GitHub
Signed-off-by: Elijah Newren <newren@gmail.com>
3 years ago
Elijah Newren dc012d277b bfg-ish: add some sanity checks on the specified repo
Signed-off-by: Elijah Newren <newren@gmail.com>
3 years ago
林博仁(Buo-ren Lin) e732141363 Fix relative path compatibility for --replace-text and bfg_args.repo
Users could specify relative paths on the command line, and then also
provide a directory other than '.' for the repo.  Since we did an
unconditional os.chdir() to move into the repo, that would invalidate
the original relative paths.  Fix that by changing the relative paths
into absolute paths.

Signed-off-by: 林博仁(Buo-ren Lin) <Buo.Ren.Lin@gmail.com>
[en: tweaked commit message to explain the problem]
Signed-off-by: Elijah Newren <newren@gmail.com>
3 years ago
Elijah Newren 8683d6fe48 Merge branch 'js/windows-fixes'
Signed-off-by: Elijah Newren <newren@gmail.com>
3 years ago
Johannes Schindelin fbaab1704c lint-history: do decode bytes
This fixes the "TypeError: a bytes-like object is required, not 'str'"
problem on Windows, letting t9391 pass.

Signed-off-by: Johannes Schindelin <johannes.schindelin@gmx.de>
3 years ago
Elijah Newren 97a1613f81 lint-history: fix binary blob detection
We had a lingering issue in the conversion from python2 to python3; as
reported by @thebrandre on GitHub:

    any(x==b'1' for x in b"123")
    # returns True in Python2 and False in Python3 because different
    # types are returned on iteration:
    [type(x) for x in b"123"]
    # Python2: [<type 'str'>, <type 'str'>, <type 'str'>]
    # Python3: [<class 'int'>, <class 'int'>, <class 'int'>]

Replace the
    any(x==b"0" for x in blob.data[0:8192])
construct with
    b"\0" in blob.data[0:8192]
to fix this.

Suggested-by: @thebrandre on GitHub
Signed-off-by: Elijah Newren <newren@gmail.com>
3 years ago
Elijah Newren b1606ba8ac Merge branch 'mr/fix-filter-lamely-name-error' into main
Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Marius Renner 70f83c2526 filter-lamely: fix NameError because of forgotten fr module prefix
In repositories with annotated tags filter-lamely crashes with the
message: "NameError: name 'Reset' is not defined".

This is because of a missing "fr" module prefix in the code, which this
commit adds.

Signed-off-by: Marius Renner <marius@mariusrenner.de>
4 years ago
Elijah Newren debe52000d contrib: rename no-op-example to barebones-example
"no-op" might suggest that it doesn't do anything, when in reality it
does exactly what filter-repo does.  Rename it to barebones-example.

Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Elijah Newren b8ebda97dd contrib: avoid applying --replace-text to binary files in bfg-ish
Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Elijah Newren 23bec32283 contrib, docs: make discovery of code formatting and linting easier
The desire to format or lint code throughout history has arisen several
times.  It's more natural to do this in filter-branch since it somewhat
forces people to run external commands, but we have an example contrib
demo that shows how to run an external command on each file in history
that I created even before any of these requests came in and yet I still
periodically get requests about it.

Make lint-history ever-so-slightly easier to apply to a subset of
filenames, and include its usage as an extra cheat sheet comparison for
filter-branch-vs-filter-repo commands.

Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Elijah Newren bd2c9c4d4d contrib: new simple no-op-example
The purpose of this example is to solely show what to import and run to
recover filter-repo's behavior as-is.  It doesn't modify any behavior,
but instead exists as an example so people can easily find a good
starting point for making their own modifications.

Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Marius Renner 3427ee171b contrib: fix special character handling in filter-lamely
filter-lamely does not handle filenames with special characters (such as
äöü or even \n and \t) properly when using a tree filter or index
filter. It either does not quote the input to git correctly or parses
git output incorrectly, causing affected filenames to be mangled with
extraneous double quotes in the history or even crashing the program.

Make filter-lamely correctly handle such filenames by using
NUL-delimited input and output modes for the affected git commands.

Signed-off-by: Marius Renner <marius@mariusrenner.de>
4 years ago
Elijah Newren 46549e7d3f lint-history: point people to issue with more linting examples
Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Elijah Newren 9d3d99593c lint-history: avoid dying when we get file deletions
When a file is deleted, there is nothing to lint, so we can just keep
the deletion as-is.

Reported-by: Thorben Kröger <dev@thorben.net>
Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Elijah Newren dab9386c47 contrib: update bfg-ish and filter-lamely with windows workaround
In commit f2729153 (filter-repo: workaround Windows' insistence that cwd
not be a bytestring, 2019-10-19), filter-repo was made to use a special
SubprocessWrapper class instead of the normal subprocess calls, due to
what appears to be in bugs in the python implementation on Windows not
working with arguments being bytestrings.  Add the same workarounds to
bfg-ish and filter-lamely.

Signed-off-by: Elijah Newren <newren@gmail.com>
4 years ago
Elijah Newren 0590c4193d contrib: clarify a few points of usage
Make it clearer that absolute paths should not be used for pathnames
within a git repository.  Also, fix the comment about how the
insert-beginning script could be implemented as a one-liner; the
example commented-out code should have used bytestrings.

Signed-off-by: Elijah Newren <newren@gmail.com>
5 years ago
Elijah Newren 320c85f941 filter-repo: improve support for partial history rewrites
Partial history rewrites were possible before with the (previously
hidden) --refs flag, but the defaults were wrong.  That could be worked
around with the --source or --target flags, but that disabled --no-data
for fast-export and thus slowed things down, and also would require
overridding --replace-refs.  And the defaults for --source and --target
may diverge further from what is wanted/needed for partial history
rewrites in the future.

So, add --partial as a first-class supported option with scary
documentation about how it permits mixing new and old history.  Make
--refs imply that flag.  Make the behavioral similarities (in regards to
which steps are skipped) between --source, --target, and --partial more
clear.  Add relevant documentation to round it out.

Signed-off-by: Elijah Newren <newren@gmail.com>
5 years ago
Elijah Newren 622afca813 contrib: new filter-repo demo named bfg-ish
This implements most of BFG Repo Cleaner, with several additional
features and bugfixes included.

Signed-off-by: Elijah Newren <newren@gmail.com>
5 years ago
Elijah Newren df575fb181 contrib: new filter-repo demo named filter-lamely (or filter-branch-ish)
This is a re-implementation of git-filter-branch that is nearly
perfectly bug compatible (it can replace git-filter-branch and still
pass the git testsuite).  It deviates in one minor way that should not
matter to real world usecases, but allows it to run a few times faster
than filter-branch.

Signed-off-by: Elijah Newren <newren@gmail.com>
5 years ago
Elijah Newren 6d231c0a94 contrib: simple examples of tools based on filter-repo
Signed-off-by: Elijah Newren <newren@gmail.com>
5 years ago