Commit graph

13 commits

Author SHA1 Message Date
Junio C Hamano d8285af481 show-ref: fix --exclude-existing
Do not falsely document --filter-invalid which does not even exist.
Also make sure the line is long enough to have ^{} suffix before
checking for it.

Pointed out by Dscho.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-18 13:40:25 -08:00
Junio C Hamano 64fe031a7a show-ref: fix --verify --hash=length
An earlier optimization for --verify broke a lot of stuff
because it did not take interaction with other flags into
account.

This also fixes an unrelated argument parsing error; --hash=8
should mean the same as "--hash --abbrev=8".

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-17 19:36:50 -08:00
Junio C Hamano dd9142993c show-ref: fix --quiet --verify
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-17 18:53:24 -08:00
Junio C Hamano 26cdd1e7c7 avoid accessing _all_ loose refs in git-show-ref --verify
If you want to verify a ref, it is overkill to first read all loose refs
into a linked list, and then check if the desired ref is there.

Signed-off-by: Junio C Hamano <junkio@cox.net>
Acked-by: Johannes Schindelin <Johannes.Schindelin@gmx.de>
2006-12-17 18:26:53 -08:00
Junio C Hamano ed9f7c954c git-fetch: Avoid reading packed refs over and over again
When checking which tags to fetch, the old code used to call
git-show-ref --verify for each remote tag. Since reading even
packed refs is not a cheap operation when there are a lot of
local refs, the code became quite slow.

This fixes it by teaching git-show-ref to filter out existing
refs using a new mode of operation of git-show-ref.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-12-17 17:57:19 -08:00
Junio C Hamano f4204ab9f6 Store peeled refs in packed-refs (take 2).
This fixes the previous implementation which failed to optimize
repositories with tons of lightweight tags.  The updated
packed-refs format begins with "# packed-refs with:" line that
lists the kind of extended data the file records.  Currently,
there is only one such extension defined, "peeled".  This stores
the "peeled tag" on a line that immediately follows a line for a
tag object itself in the format "^<sha-1>".

The header line itself and any extended data are ignored by
older implementation, so packed-refs file generated with this
version can still be used by older git.  packed-refs made by
older git can of course be used with this version.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-21 23:37:35 -08:00
Junio C Hamano cf0adba788 Store peeled refs in packed-refs file.
This would speed up "show-ref -d" in a repository with mostly
packed tags.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-11-19 18:45:44 -08:00
Lars Hjemli 97f7a7bd0d Fix show-ref usagestring
This describes the abbreviation possibilities for git-show-ref

Signed-off-by: Lars Hjemli <hjemli@gmail.com>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-26 18:38:05 -07:00
Junio C Hamano 2eaf22242f show-ref --hash=len, --abbrev=len, and --abbrev
This teaches show-ref to abbreviate the object name.

Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-10-01 00:32:44 -07:00
Junio C Hamano eaf12a8c7d Merge branch 'lt/refs' into jc/lt-ref2-with-lt-refs
* lt/refs: (58 commits)
  git-pack-refs --prune
  pack-refs: do not pack symbolic refs.
  Tell between packed, unpacked and symbolic refs.
  Add callback data to for_each_ref() family.
  symbolit-ref: fix resolve_ref conversion.
  Fix broken sha1 locking
  fsck-objects: adjust to resolve_ref() clean-up.
  gitignore: git-pack-refs is a generated file.
  wt-status: use simplified resolve_ref to find current branch
  Fix t1400-update-ref test minimally
  Enable the packed refs file format
  Make ref resolution saner
  Add support for negative refs
  Start handling references internally as a sorted in-memory list
  gitweb fix validating pg (page) parameter
  git-repack(1): document --window and --depth
  git-apply(1): document --unidiff-zero
  gitweb: fix warnings in PATH_INFO code and add export_ok/strict_export
  upload-archive: monitor child communication even more carefully.
  gitweb: export options
  ...
2006-09-21 00:40:28 -07:00
Christian Couder 9c13359aaf Fix show-ref usage for --dereference.
Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-20 08:35:48 -07:00
Christian Couder c40abef89f Add [-s|--hash] option to Linus' show-ref.
With this option only the sha1 hash of the ref should
be printed.

Signed-off-by: Christian Couder <chriscool@tuxfamily.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-17 02:43:02 -07:00
Linus Torvalds 358ddb62cf Add "git show-ref" builtin command
It's kind of like "git peek-remote", but works only locally (and thus
avoids the whole overhead of git_connect()) and has some extra
verification features.

For example, it allows you to filter the results, and to choose whether
you want the tag dereferencing or not. You can also use it to just test
whether a particular ref exists.

For example:

	git show-ref master

will show all references called "master", whether tags or heads or
anything else, and regardless of how deep in the reference naming
hierarchy they are (so it would show "refs/heads/master" but also
"refs/remote/other-repo/master").

When using the "--verify" flag, the command requires an exact ref path:

	git show-ref --verify refs/heads/master

will only match the exact branch called "master".

If nothing matches, show-ref will return an error code of 1, and in the
case of verification, it will show an error message.

For scripting, you can ask it to be quiet with the "--quiet" flag, which
allows you to do things like

	git-show-ref --quiet --verify -- "refs/heads/$headname" ||
		echo "$headname is not a valid branch"

to check whether a particular branch exists or not (notice how we don't
actually want to show any results, and we want to use the full refname for
it in order to not trigger the problem with ambiguous partial matches).

To show only tags, or only proper branch heads, use "--tags" and/or
"--heads" respectively (using both means that it shows tags _and_ heads,
but not other random references under the refs/ subdirectory).

To do automatic tag object dereferencing, use the "-d" or "--dereference"
flag, so you can do

	git show-ref --tags --dereference

to get a listing of all tags together with what they dereference.

Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Signed-off-by: Junio C Hamano <junkio@cox.net>
2006-09-16 02:23:51 -07:00