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

Re: svn diff -c does not accept HEAD

From: Daniel Shahaf <d.s_at_daniel.shahaf.name>
Date: Tue, 08 Dec 2020 00:00:16 +0000

Nathan Hartman wrote on Mon, 07 Dec 2020 20:50 +00:00:
> On Mon, Dec 7, 2020 at 1:47 PM Yasuhito FUTATSUKI
> <futatuki_at_yf.bsdclub.org> wrote:
> >
> > As the error message says, '-c' option accepts only numeric revision.
> > It seems it is a kind of bug that the help text is not kind enough.
>
> A possible rationale is that the HEAD revision could change without
> your knowledge (e.g., another user commits something in the meantime)
> and you wouldn't get the revision you were expecting.

If this were the rationale, we wouldn't support «svn log -r HEAD» either.

Use of «HEAD» to refer to any specific revision is inherently racy.
Callsites that care about the race condition should handle it
explicitly; see tools/dist/release.py:bump_versions_on_branch() for
an example.

There isn't any conceptual problem with defining «-c HEAD» to mean
"Resolve HEAD to a revision number N and then behave as «-r N-1:N»
would". That wouldn't be any more racy than any other use of HEAD. We
just never did that.

(Why? For one, because -c is a lot newer than -r: -c was added in 1.4.0 (sic),
in 2006, while -r dates back to CVS. When we added -c, it was
implemented directly in the cmdline client's option parser, without any
API changes, so it was written to only support numeric arguments.)

Note that «svn diff -c HEAD» isn't generally a useful call unless the
repository root («^/») is given as the target.

> When I want to see the diff of the most recent revision I use 'svn log
> -l 1 --diff'. (Note, though, that will be from the BASE revision, not
> HEAD.)

There's also «svn log -r HEAD:0 -l 1 --diff».

Cheers,

Daniel
Received on 2020-12-08 01:00:50 CET

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

This site is subject to the Apache Privacy Policy and the Apache Public Forum Archive Policy.