Commit Graph

24 Commits

Author SHA1 Message Date
brian m. carlson
781b99af47
commands/prune: make strings translatable 2022-01-18 17:03:38 +00:00
Dimitris Apostolou
21b0402690
Fix typos 2022-01-05 08:49:08 +02:00
brian m. carlson
d97c785f79
fs: specify a file as existing if it's empty
If the object has a size of zero, then we already have its object: it's
the empty file, and we shouldn't need to download it from anywhere.  If
we inquire if it exists, then say it does, and say its location is the
system's equivalent of /dev/null.

The only tricky case is if we're de-duplicating, linking, or writing to
a file, in which case we should not try to use a link or replace on the
file, since we neither want to link nor replace the system's /dev/null.
2021-09-28 12:33:22 +00:00
Chris Darroch
e855105a23
Merge branch 'main' into prune-hang 2021-08-25 17:02:34 -04:00
David McFarland
d1287f983f lfs/gitscanner_log.go: fix hang in scanner when long lines are present
I don't think there's a reasonable way to do this with bufio.Scanner, so
I switched it to bufio.Reader.
2021-08-25 13:22:07 -03:00
Chris Darroch
2752acc925 t: test fetch/prune diff parsing with ANSI escapes
We set the "color.diff" Git configuration directive to "always"
in several tests which exercise the scanning and parsing of
"git log -p" output in order to validate that they still
succeed even with ANSI color code escape sequences in the
Git diff output.

Unfortunately, at the present time, the tests will no longer
succeed as a result of this change, but we intend to resolve
that problem in a subsequent commit.
2021-08-17 19:47:36 -07:00
David McFarland
93b47157d9 t/t-prune.sh: add test showing hang in prune
When a commit contains a change from tracked to untracked or vice versa,
the log output can contain long lines of text.  These cause a hang in
the log parser.
2021-08-13 10:27:15 -03:00
Chris Darroch
fbac6e0a90 t: test additional stashed objects with prune
In each of our tests of the "git lfs prune" command
when it follows the "git stash" command, we add LFS
objects on a branch and stash them before the branch
is deleted.  In all cases we expect the additional
stashed objects to be retained by "git lfs prune"
while unreferenced objects on the deleted branch are
pruned.

Note that these chnanges also ensure we are test
the "git lfs prune" command with multiple stashed
entries rather than just a single stash entry.
2021-03-23 23:27:38 -07:00
Chris Darroch
46c06171d2 t: add unreferenced objects to prune stash tests
We add unreferenced LFS objects on a separate branch
to our tests of the "git lfs prune" command when it
follows a "git stash" command, and expect that in all
cases the unreferenced objects will be pruned.
2021-03-23 23:22:08 -07:00
Chris Darroch
8785a7e0a1 t: reorder prune stash checks to match actions
We slightly reorder the assertions following the
"git stash" command in several of our tests of the
"git lfs prune" command so that the assertions are
made in the same order as the stashed modifications.
This will ease the addition of more assertions in
subsequent commits.

We also drop the unnecessary cleanup of the stash
and working tree at the end of one test.
2021-03-23 22:34:45 -07:00
Chris Darroch
fbceac20f5 lfs,t: parse only stash log entries for prune
When looking for Git LFS pointers in the Git stash in order
to avoid pruning the corresponding local objects during a
"git lfs prune" command, we want to avoid looking further
back in the Git log file than necessary; otherwise, we may
potentially find many LFS object references which we should
prune but incorrectly consider to be part of the stashes.

We therefore proceed in two steps; first looking solely
at each stash entry's WIP merge commit using the command
"git log -m --first-parent <stash-sha>^..<stash-sha>",
and then looking at each entry's index merge commit and
possible additional untracked files merge commit using
the command "git log <stash-sha>^..<stash-sha>".  By
limiting these commands' commit ranges to just the stash
merge commits, we skip improperly traversing the full log.

We update the relevant tests to include older commits,
one of which should be pruned in each case; note that
with these changes the tests fail with the previous
version of the "git lfs prune" logic for stashes.
We also add stashes to two other tests and confirm that
in both cases the LFS objects from the stashed commits
are retained, but no additional objects are also
unexpectedly retained as a result of the stash.
2021-03-23 01:33:31 -07:00
brian m. carlson
fcb163272b
lfs: don't invoke diff drivers when pruning repositories
Certain file paths are associated with diff textconv patterns with Git
for Windows, and these are invoked by default when using git log.
However, when we're using git log to scan data to find LFS objects, we
don't want to invoke those programs.

Let's fix this by passing appropriate options to disabled these
invocations.  In the test, we set the driver to false, since Git will
fail if the process it calls also fails.
2021-02-22 14:34:26 +00:00
brian m. carlson
1481e9776d
prune: add options to be more aggressive about pruning
Some users really want to minimize the amount of data they store on the
local system, especially for large checkouts.  Let's add two options,
--recent and --force, the former which ignores the recency settings and
the latter which additionally prunes objects which are currently checked
out.  We will never prune objects that are unpushed, even with these
options, including stashed objects.

Add tests and documentation for both of these options.
2021-01-13 19:30:40 +00:00
Chris Darroch
fc2ac46cc8 t/t-prune.go: prefer printf to echo
Per PR advice from bk2204, we switch to using printf instead of
echo in the t-prune.go tests of stashed changes.

We also fixup one code comment to match the count of processes
in commands/command_prune.go.
2020-09-03 16:33:44 -07:00
Steve Streeting
c49b5790b4 Add test for untracked files in stash, fix parsing for full combo 2020-08-13 14:32:26 +01:00
Steve Streeting
eaa85a7fc8 Add test for stashed index AND working copy change 2020-08-12 15:30:47 +01:00
Steve Streeting
b1ccc8106a Hopefully final whitespace fix up 2020-08-10 09:48:39 +01:00
Steve Streeting
9da074cea1 cibuild still failing on whitespace, needs another blank line? 2020-08-08 11:27:46 +01:00
Steve Streeting
77056cbba6 Add trailing newline in test, was breaking cibuild 2020-08-08 11:12:09 +01:00
Steve Streeting
2dc718b38c prune: fix deleting objects referred to by stashes
It was impossible to pop a stash with LFS data successfully
after running any lfs prune command before this fix, because
prune would consider stashed data unreferenced.

This fixes #4206
2020-08-07 16:48:59 +01:00
brian m. carlson
9e006ac4e2
Rename default branch in tests to "main"
Currently, our default branch in tests is "master".  This is the Git
default, but the Git default will likely change in the future, so it
makes sense to update our testsuite to be explicit about the branch
name.  We'll ensure this continues by building against older versions of
Git as well as newer versions.

We use "main" for the new branch name, since that's the proposed value
upstream.

This commit was made entirely by automated means using the following
command:

  git grep -l master t | xargs sed -i -e 's/master/main/g'
2020-07-08 15:38:17 +00:00
Taylor Blau
7c244da198 tasklog/log.go: print "done" messages with a trailing period
We use package 'tasklog' to print progress messages to the command line
interface, as in the case of 'git-migrate-import(1)' or
'git-lfs-prune(1)'.

This package aims to mimic the style of upstream Git's progress log
lines, which are identical in every way, except for the trailing period
at the end of 'done'.

Git does print this period, but Git LFS does not. Let's make the two
more similar by having LFS print this period, too.
2019-08-23 17:04:37 -04:00
Taylor Blau
de9152049c t: load shell scripts from $(dirname) instead of 't' 2018-07-10 13:51:40 -05:00
Taylor Blau
219b7e0a3d t: prefix all existing tests with t- 2018-07-09 16:24:25 -05:00