Stupid Question

Linus Torvalds torvalds at linux-foundation.org
Thu Apr 14 10:22:57 PDT 2016


On Wed, Apr 13, 2016 at 2:27 PM, John Van Ostrand <john at vanostrand.com> wrote:
>
> I want to get rid of an entire dive computer's logs. It's a duplicate of the
> same computer because of changes I made to LDC and after I imported I failed
> to realized I had re-imported dives so there's no reason to keep both. I'm
> going to try a couple dumb things to fix this. An XML editor looks like it
> will work. I love that the data file is in XML, even if I have a 58MB file,
> which is also why I'm doing this.

So an XML editor will certainly work, but _if_ you are comfortable
using git for other reasons (ie maybe you use git for development),
then the git format is actually *really* convenient.

In particular, it allows you to use regular filesystem interfaces to
do things like this.

For example, here's a real session I did to emulate the editing
behavior you'd want, just as an example:

   # Clone my cloud cache copy to a temporary git location. Your
   # cloud hash will obviously be something different

   git clone .subsurface/cloudstorage/96768970dcbc1b59 test-repo
   cd test-repo/

   # Find every dive computer that is not the *only* dive computer
   # for a dive (such a dive computer file would be named just plain
   # 'Divecomputer' without the number suffix), and remove it if it
   # has the model name "EON Steel" in it.

   find . -name 'Divecomputer-0*' |
         xargs grep -l "model.*EON.Steel" |
         xargs rm

   # Commit the result

   git commit -a -m "Remove all EON Steel when another dive computer exists"

   # check the end result in subsurface. Your git branch name will
   # obviously be something different

   subsurface ./[linus at linux.com]

   # throw that temporary git tree away, because the EON Steel is
   # actually my favorite dive computer, so I wouldn't actually want
   # to do this for real

   cd
   rm -rf test-repo

so _if_ you're a command line person, and _if_ you are comfy with git,
the git format actually ends up being very powerful. It's much more
powerful for these kinds of things than the XML one.

                    Linus


More information about the subsurface mailing list