Use branch tip, not newest date to choose 'latest' in BranchList._mksubs().

Previously 'latest' was chosen in the VFS by taking max(revs), which
would pick the most recent commit by rev_list date, which only has a
resolution of integer seconds.

That approach could fail if two commits (i.e. two "bup save" runs)
executed close enough together that both commits ended up with the
same rev_list date.  In that case, the sort order was determined by
the commit hash, which is effectively random.

Since I couldn't think of a case where you wouldn't want 'latest' to
refer to the most recent commit (save) to the relevant branch,
'latest' is now computed as revs[0], i.e. the first commit returned by
rev_list.

Thanks to Zoran and Gabriel for some helpful sanity checks while
tracking this down.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Since 'latest' is computed by revs[0], it must exist, so don't test it.

Remove the unnecessary "if latest:" conditional from
BranchList._mksubs().  Given the fact that latest used to be computed
via max(revs), and is now computed by revs[0], there's no way it
wouldn't exist.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Unmount and remove testfs instances correctly during make clean.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Save metadata during "bup save".

Record metadata in a hidden/mangled file named .bupm in each
directory, so that the metadata for /foo/ is stored in /foo/.bupm,
with the first entry being the metadata for foo/ itself.

Record an empty index file for each special file so that index entries
and .bupm entries correspond correctly.

Rework the strip/graft functions to return both the save-name, and the
underlying filesystem path to the save-name (when there is one) for
each component.  There may not be corresponding filesystem paths if
graft options rewrite the path prefix.

For now, record "/" metadata only when there are no strip/graft
options.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Tested-by: Alexander Barton <alex@barton.de>
Restore any metadata during "bup restore"; add "bup meta --edit".

Use "bup meta --edit" to test "bup restore" and the new tar/rsync-like
restoration behaviors.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Tested-by: Alexander Barton <alex@barton.de>
t/test.sh: fix test failure when $top_dir has a dot-name

Fix the admittedly rare case where we're running tests from a tree
that has a dot-name at its base, which only 'bup ls -a' will print.
This problem was originally encountered on a system that keeps mounts
under '/.autofs/'.

Signed-off-by: Yung-Chin Oei <yungchin@yungchin.nl>
Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Use python, not groups to grab a user group in t/test-meta.sh.

Group names may actually contain spaces, and since the groups commmand
only reports a space-delimited list of groups on stdout, we had
a problem.

Thanks to "Oei, Yung-Chin" <yungchin@yungchin.nl> and Gabriel Filion
<lelutin@gmail.com> for tracking this down.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Quote EXIT cleanup trap properly in test-meta.sh.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Handle the possibility of a sgid/suid parent dir in one of the meta tests.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Update README regarding metadata support.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Disallow empty graft points.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Defer errors when the restore target doesn't support relevant metadata.

When the restore target doesn't support POSIX1e ACLs, extended
attributes, or Linux attributes, handle the failures via add_error()
(i.e. defer them).

Test these cases by creating a loopback VFAT filesystem
(testfs-limited) and using it as a restore target.

Signed-off-by: Rob Browning <rlb@defaultvalue.org>
Reviewed-by: Zoran Zaric <zz@zoranzaric.de>
Add traverse_ref and traverse_objects to git.CatPipe
Add a bup push command
Add documentation for bup push
Add testcase for bup push