[svn.haxx.se] · SVN Dev · SVN Users · SVN Org · TSVN Dev · TSVN Users · Subclipse Dev · Subclipse Users · this month's index

Re: Do we want 'svn patch' to be able to add empty files?

From: Daniel Näslund <daniel_at_longitudo.com>
Date: Thu, 2 Sep 2010 07:05:41 +0200

On Wed, Sep 01, 2010 at 10:54:08PM +0300, Daniel Shahaf wrote:
> Daniel Näslund wrote on Wed, Sep 01, 2010 at 11:28:51 +0200:
> > (This started out as me trying to apply added paths using the information
> > from a patch file in the git diff format. The only that I could come up
> > with where an add could not be detected by just looking at the regular
> > unidiff headers was adding an empty file (it has no unidiff headers).
> > If anyone has any other cases, please let me know.)
> >
>
> How does a diff adding an empty file look?

Like this:

Index: empty
===================================================================
diff --git a/trunk/empty b/trunk/empty
new file mode 10644

Note that we allow empty files to be created for regular diffs too if
they have property changes. This patch will create an empty file with
property 'foo' set on it:

Index: empty
===================================================================

Property changes on: empty
___________________________________________________________________
Added: foo
## -0,0 +1 ##
+value

> > The question is: Do we want 'svn patch to be able to add empty files.
> >
> > + It's consistent with the idea of a git diff dealing with tree changes.
> > - It adds an extra special case to the code. I've seen GNU patch with
> > its gigantic if-spaghetti's. Just don't want to obscure the code with
> > something that's not needed.
>
> > - There might not be a use case for it, though I think I've heard of the
> > use of empty files as markers. Just can't come up with an example
> > right now.
>
> Two examples:
>
> * vimrc. (Vim behaves differently with no vimrc than with an empty vimrc)
>
> * pseudo-targets for makefiles
> foo:
> $commands
> touch $@

Good examples. I think configuration files and build files are the
typical use cases for empty files.

Daniel (Näslund)
Received on 2010-09-02 07:07:07 CEST

This is an archived mail posted to the Subversion Dev mailing list.