Commit graph

8 commits

Author SHA1 Message Date
Alex Riesen 08db81a9f1 allow git-update-ref create refs with slashes in names
Make git-update-ref create references with slashes in them. git-branch
and git-checkout already support such reference names.

git-branch can use git-update-ref to create the references in a more
formal manner now.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-14 17:15:32 -08:00
Petr Baudis ad7db62113 Fix confusing git-update-ref error message
When git-update-ref has hit the "Ref %s changed to %s" error, I just stare
at it, left puzzled. This patch attempts to reword that to a more useful
and less confusing error message.

Signed-off-by: Petr Baudis <pasky@suse.cz>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-11-10 15:57:21 -08:00
Linus Torvalds 4546738b58 Unlocalized isspace and friends
Do our own ctype.h, just to get the sane semantics: we want
locale-independence, _and_ we want the right signed behaviour. Plus we
only use a very small subset of ctype.h anyway (isspace, isalpha,
isdigit and isalnum).

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-14 17:17:27 -07:00
Junio C Hamano a876ed83be Use resolve_ref() to implement read_ref().
Symbolic refs are understood by resolve_ref(), so existing read_ref()
users will automatically understand them as well.

Signed-off-by: Junio C Hamano <junio@twinsun.com>
2005-10-01 23:19:33 -07:00
Junio C Hamano 9b143c6e15 Teach update-ref about a symbolic ref stored in a textfile.
A symbolic ref is a regular file whose contents is "ref:", followed by
optional leading whitespaces, followed by a GIT_DIR relative pathname,
followed by optional trailing whitespaces (the optional whitespaces
are unconditionally removed, so you cannot have leading nor trailing
whitespaces).  This can be used in place of a traditional symbolic
link .git/HEAD that usually points at "refs/heads/master".  You can
instead have a regular file .git/HEAD whose contents is
"ref: refs/heads/master".

[jc: currently the code does not enforce the symbolic ref to begin with
 refs/, unlike the symbolic link case.  It may be worthwhile to require
 either case to begin with refs/ and not have any /./ nor /../ in them.]

Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-10-01 23:19:32 -07:00
Peter Hagervall a7928f8ec7 [PATCH] Make some needlessly global stuff static
Insert 'static' where appropriate.

Signed-off-by: Peter Hagervall <hager@cs.umu.se>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-28 16:38:52 -07:00
Junio C Hamano 152da3dfcf Plug a small race in update-ref.c.
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-25 19:25:09 -07:00
Linus Torvalds 66bf85a462 [PATCH] Add "git-update-ref" to update the HEAD (or other) ref
This is a careful version of the script stuff that currently just
blindly writes HEAD with a new value.

You can use

	git-update-ref HEAD <newhead>

or

	git-update-ref HEAD <newhead> <oldhead>

where the latter version verifies that the old value of HEAD matches
oldhead.

It basically allows a "ref" file to be a symbolic pointer to another ref
file by starting with the four-byte header sequence of "ref:".

More importantly, it allows the update of a ref file to follow these
symbolic pointers, whether they are symlinks or these "regular file
symbolic refs".

NOTE! It follows _real_ symlinks only if they start with "refs/":
otherwise it will just try to read them and update them as a regular file
(ie it will allow the filesystem to follow them, but will overwrite such a
symlink to somewhere else with a regular filename).

In general, using

	git-update-ref HEAD "$head"

should be a _lot_ safer than doing

	echo "$head" > "$GIT_DIR/HEAD"

both from a symlink following standpoint _and_ an error checking
standpoint.  The "refs/" rule for symlinks means that symlinks that point
to "outside" the tree are safe: they'll be followed for reading but not
for writing (so we'll never write through a ref symlink to some other
tree, if you have copied a whole archive by creating a symlink tree).

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2005-09-25 16:18:25 -07:00